aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ssb
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2013-02-21 10:16:55 -0500
committerRalf Baechle <ralf@linux-mips.org>2013-02-22 04:07:30 -0500
commitedb15d83a875a1f4b1576188844db5c330c3267d (patch)
tree74d54eab401b6ccf2a6ad4821227108a8d160f03 /drivers/ssb
parent8bfc245f9ad7bd4e461179e4e7852ef99b8b6144 (diff)
parenta0b1c42951dd06ec83cc1bc2c9788131d9fefcd8 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux into mips-for-linux-next
Conflicts: include/linux/ssb/ssb_driver_gige.h Also resolves a logical merge conflict in drivers/net/ethernet/broadcom/- bgmac.c due to change of an API.
Diffstat (limited to 'drivers/ssb')
-rw-r--r--drivers/ssb/Kconfig5
-rw-r--r--drivers/ssb/Makefile1
-rw-r--r--drivers/ssb/driver_chipcommon_sflash.c140
-rw-r--r--drivers/ssb/driver_gpio.c22
-rw-r--r--drivers/ssb/driver_mipscore.c51
-rw-r--r--drivers/ssb/main.c8
-rw-r--r--drivers/ssb/ssb_private.h15
7 files changed, 231 insertions, 11 deletions
diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig
index 5d6f2ec1c705..5ff3a4f19443 100644
--- a/drivers/ssb/Kconfig
+++ b/drivers/ssb/Kconfig
@@ -136,6 +136,11 @@ config SSB_DRIVER_MIPS
136 136
137 If unsure, say N 137 If unsure, say N
138 138
139config SSB_SFLASH
140 bool "SSB serial flash support"
141 depends on SSB_DRIVER_MIPS && BROKEN
142 default y
143
139# Assumption: We are on embedded, if we compile the MIPS core. 144# Assumption: We are on embedded, if we compile the MIPS core.
140config SSB_EMBEDDED 145config SSB_EMBEDDED
141 bool 146 bool
diff --git a/drivers/ssb/Makefile b/drivers/ssb/Makefile
index 9159ba77c388..b1ddc116d387 100644
--- a/drivers/ssb/Makefile
+++ b/drivers/ssb/Makefile
@@ -11,6 +11,7 @@ ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o
11# built-in drivers 11# built-in drivers
12ssb-y += driver_chipcommon.o 12ssb-y += driver_chipcommon.o
13ssb-y += driver_chipcommon_pmu.o 13ssb-y += driver_chipcommon_pmu.o
14ssb-$(CONFIG_SSB_SFLASH) += driver_chipcommon_sflash.o
14ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o 15ssb-$(CONFIG_SSB_DRIVER_MIPS) += driver_mipscore.o
15ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o 16ssb-$(CONFIG_SSB_DRIVER_EXTIF) += driver_extif.o
16ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o 17ssb-$(CONFIG_SSB_DRIVER_PCICORE) += driver_pcicore.o
diff --git a/drivers/ssb/driver_chipcommon_sflash.c b/drivers/ssb/driver_chipcommon_sflash.c
new file mode 100644
index 000000000000..720665ca2bb1
--- /dev/null
+++ b/drivers/ssb/driver_chipcommon_sflash.c
@@ -0,0 +1,140 @@
1/*
2 * Sonics Silicon Backplane
3 * ChipCommon serial flash interface
4 *
5 * Licensed under the GNU/GPL. See COPYING for details.
6 */
7
8#include <linux/ssb/ssb.h>
9
10#include "ssb_private.h"
11
12struct ssb_sflash_tbl_e {
13 char *name;
14 u32 id;
15 u32 blocksize;
16 u16 numblocks;
17};
18
19static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
20 { "M25P20", 0x11, 0x10000, 4, },
21 { "M25P40", 0x12, 0x10000, 8, },
22
23 { "M25P16", 0x14, 0x10000, 32, },
24 { "M25P32", 0x15, 0x10000, 64, },
25 { "M25P64", 0x16, 0x10000, 128, },
26 { "M25FL128", 0x17, 0x10000, 256, },
27 { 0 },
28};
29
30static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
31 { "SST25WF512", 1, 0x1000, 16, },
32 { "SST25VF512", 0x48, 0x1000, 16, },
33 { "SST25WF010", 2, 0x1000, 32, },
34 { "SST25VF010", 0x49, 0x1000, 32, },
35 { "SST25WF020", 3, 0x1000, 64, },
36 { "SST25VF020", 0x43, 0x1000, 64, },
37 { "SST25WF040", 4, 0x1000, 128, },
38 { "SST25VF040", 0x44, 0x1000, 128, },
39 { "SST25VF040B", 0x8d, 0x1000, 128, },
40 { "SST25WF080", 5, 0x1000, 256, },
41 { "SST25VF080B", 0x8e, 0x1000, 256, },
42 { "SST25VF016", 0x41, 0x1000, 512, },
43 { "SST25VF032", 0x4a, 0x1000, 1024, },
44 { "SST25VF064", 0x4b, 0x1000, 2048, },
45 { 0 },
46};
47
48static struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
49 { "AT45DB011", 0xc, 256, 512, },
50 { "AT45DB021", 0x14, 256, 1024, },
51 { "AT45DB041", 0x1c, 256, 2048, },
52 { "AT45DB081", 0x24, 256, 4096, },
53 { "AT45DB161", 0x2c, 512, 4096, },
54 { "AT45DB321", 0x34, 512, 8192, },
55 { "AT45DB642", 0x3c, 1024, 8192, },
56 { 0 },
57};
58
59static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32 opcode)
60{
61 int i;
62 chipco_write32(cc, SSB_CHIPCO_FLASHCTL,
63 SSB_CHIPCO_FLASHCTL_START | opcode);
64 for (i = 0; i < 1000; i++) {
65 if (!(chipco_read32(cc, SSB_CHIPCO_FLASHCTL) &
66 SSB_CHIPCO_FLASHCTL_BUSY))
67 return;
68 cpu_relax();
69 }
70 pr_err("SFLASH control command failed (timeout)!\n");
71}
72
73/* Initialize serial flash access */
74int ssb_sflash_init(struct ssb_chipcommon *cc)
75{
76 struct ssb_sflash_tbl_e *e;
77 u32 id, id2;
78
79 switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) {
80 case SSB_CHIPCO_FLASHT_STSER:
81 ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_DP);
82
83 chipco_write32(cc, SSB_CHIPCO_FLASHADDR, 0);
84 ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_RES);
85 id = chipco_read32(cc, SSB_CHIPCO_FLASHDATA);
86
87 chipco_write32(cc, SSB_CHIPCO_FLASHADDR, 1);
88 ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_ST_RES);
89 id2 = chipco_read32(cc, SSB_CHIPCO_FLASHDATA);
90
91 switch (id) {
92 case 0xbf:
93 for (e = ssb_sflash_sst_tbl; e->name; e++) {
94 if (e->id == id2)
95 break;
96 }
97 break;
98 case 0x13:
99 return -ENOTSUPP;
100 default:
101 for (e = ssb_sflash_st_tbl; e->name; e++) {
102 if (e->id == id)
103 break;
104 }
105 break;
106 }
107 if (!e->name) {
108 pr_err("Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n",
109 id, id2);
110 return -ENOTSUPP;
111 }
112
113 break;
114 case SSB_CHIPCO_FLASHT_ATSER:
115 ssb_sflash_cmd(cc, SSB_CHIPCO_FLASHCTL_AT_STATUS);
116 id = chipco_read32(cc, SSB_CHIPCO_FLASHDATA) & 0x3c;
117
118 for (e = ssb_sflash_at_tbl; e->name; e++) {
119 if (e->id == id)
120 break;
121 }
122 if (!e->name) {
123 pr_err("Unsupported Atmel serial flash (id: 0x%X)\n",
124 id);
125 return -ENOTSUPP;
126 }
127
128 break;
129 default:
130 pr_err("Unsupported flash type\n");
131 return -ENOTSUPP;
132 }
133
134 pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n",
135 e->name, e->blocksize, e->numblocks);
136
137 pr_err("Serial flash support is not implemented yet!\n");
138
139 return -ENOTSUPP;
140}
diff --git a/drivers/ssb/driver_gpio.c b/drivers/ssb/driver_gpio.c
index eb2753008ef0..dc109de228c6 100644
--- a/drivers/ssb/driver_gpio.c
+++ b/drivers/ssb/driver_gpio.c
@@ -74,6 +74,16 @@ static void ssb_gpio_chipco_free(struct gpio_chip *chip, unsigned gpio)
74 ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 0); 74 ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 0);
75} 75}
76 76
77static int ssb_gpio_chipco_to_irq(struct gpio_chip *chip, unsigned gpio)
78{
79 struct ssb_bus *bus = ssb_gpio_get_bus(chip);
80
81 if (bus->bustype == SSB_BUSTYPE_SSB)
82 return ssb_mips_irq(bus->chipco.dev) + 2;
83 else
84 return -EINVAL;
85}
86
77static int ssb_gpio_chipco_init(struct ssb_bus *bus) 87static int ssb_gpio_chipco_init(struct ssb_bus *bus)
78{ 88{
79 struct gpio_chip *chip = &bus->gpio; 89 struct gpio_chip *chip = &bus->gpio;
@@ -86,6 +96,7 @@ static int ssb_gpio_chipco_init(struct ssb_bus *bus)
86 chip->set = ssb_gpio_chipco_set_value; 96 chip->set = ssb_gpio_chipco_set_value;
87 chip->direction_input = ssb_gpio_chipco_direction_input; 97 chip->direction_input = ssb_gpio_chipco_direction_input;
88 chip->direction_output = ssb_gpio_chipco_direction_output; 98 chip->direction_output = ssb_gpio_chipco_direction_output;
99 chip->to_irq = ssb_gpio_chipco_to_irq;
89 chip->ngpio = 16; 100 chip->ngpio = 16;
90 /* There is just one SoC in one device and its GPIO addresses should be 101 /* There is just one SoC in one device and its GPIO addresses should be
91 * deterministic to address them more easily. The other buses could get 102 * deterministic to address them more easily. The other buses could get
@@ -134,6 +145,16 @@ static int ssb_gpio_extif_direction_output(struct gpio_chip *chip,
134 return 0; 145 return 0;
135} 146}
136 147
148static int ssb_gpio_extif_to_irq(struct gpio_chip *chip, unsigned gpio)
149{
150 struct ssb_bus *bus = ssb_gpio_get_bus(chip);
151
152 if (bus->bustype == SSB_BUSTYPE_SSB)
153 return ssb_mips_irq(bus->extif.dev) + 2;
154 else
155 return -EINVAL;
156}
157
137static int ssb_gpio_extif_init(struct ssb_bus *bus) 158static int ssb_gpio_extif_init(struct ssb_bus *bus)
138{ 159{
139 struct gpio_chip *chip = &bus->gpio; 160 struct gpio_chip *chip = &bus->gpio;
@@ -144,6 +165,7 @@ static int ssb_gpio_extif_init(struct ssb_bus *bus)
144 chip->set = ssb_gpio_extif_set_value; 165 chip->set = ssb_gpio_extif_set_value;
145 chip->direction_input = ssb_gpio_extif_direction_input; 166 chip->direction_input = ssb_gpio_extif_direction_input;
146 chip->direction_output = ssb_gpio_extif_direction_output; 167 chip->direction_output = ssb_gpio_extif_direction_output;
168 chip->to_irq = ssb_gpio_extif_to_irq;
147 chip->ngpio = 5; 169 chip->ngpio = 5;
148 /* There is just one SoC in one device and its GPIO addresses should be 170 /* There is just one SoC in one device and its GPIO addresses should be
149 * deterministic to address them more easily. The other buses could get 171 * deterministic to address them more easily. The other buses could get
diff --git a/drivers/ssb/driver_mipscore.c b/drivers/ssb/driver_mipscore.c
index 5bd05b136d22..33b37dac40bd 100644
--- a/drivers/ssb/driver_mipscore.c
+++ b/drivers/ssb/driver_mipscore.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/ssb/ssb.h> 11#include <linux/ssb/ssb.h>
12 12
13#include <linux/mtd/physmap.h>
13#include <linux/serial.h> 14#include <linux/serial.h>
14#include <linux/serial_core.h> 15#include <linux/serial_core.h>
15#include <linux/serial_reg.h> 16#include <linux/serial_reg.h>
@@ -17,6 +18,25 @@
17 18
18#include "ssb_private.h" 19#include "ssb_private.h"
19 20
21static const char *part_probes[] = { "bcm47xxpart", NULL };
22
23static struct physmap_flash_data ssb_pflash_data = {
24 .part_probe_types = part_probes,
25};
26
27static struct resource ssb_pflash_resource = {
28 .name = "ssb_pflash",
29 .flags = IORESOURCE_MEM,
30};
31
32struct platform_device ssb_pflash_dev = {
33 .name = "physmap-flash",
34 .dev = {
35 .platform_data = &ssb_pflash_data,
36 },
37 .resource = &ssb_pflash_resource,
38 .num_resources = 1,
39};
20 40
21static inline u32 mips_read32(struct ssb_mipscore *mcore, 41static inline u32 mips_read32(struct ssb_mipscore *mcore,
22 u16 offset) 42 u16 offset)
@@ -189,34 +209,43 @@ static void ssb_mips_serial_init(struct ssb_mipscore *mcore)
189static void ssb_mips_flash_detect(struct ssb_mipscore *mcore) 209static void ssb_mips_flash_detect(struct ssb_mipscore *mcore)
190{ 210{
191 struct ssb_bus *bus = mcore->dev->bus; 211 struct ssb_bus *bus = mcore->dev->bus;
212 struct ssb_pflash *pflash = &mcore->pflash;
192 213
193 /* When there is no chipcommon on the bus there is 4MB flash */ 214 /* When there is no chipcommon on the bus there is 4MB flash */
194 if (!ssb_chipco_available(&bus->chipco)) { 215 if (!ssb_chipco_available(&bus->chipco)) {
195 mcore->pflash.present = true; 216 pflash->present = true;
196 mcore->pflash.buswidth = 2; 217 pflash->buswidth = 2;
197 mcore->pflash.window = SSB_FLASH1; 218 pflash->window = SSB_FLASH1;
198 mcore->pflash.window_size = SSB_FLASH1_SZ; 219 pflash->window_size = SSB_FLASH1_SZ;
199 return; 220 goto ssb_pflash;
200 } 221 }
201 222
202 /* There is ChipCommon, so use it to read info about flash */ 223 /* There is ChipCommon, so use it to read info about flash */
203 switch (bus->chipco.capabilities & SSB_CHIPCO_CAP_FLASHT) { 224 switch (bus->chipco.capabilities & SSB_CHIPCO_CAP_FLASHT) {
204 case SSB_CHIPCO_FLASHT_STSER: 225 case SSB_CHIPCO_FLASHT_STSER:
205 case SSB_CHIPCO_FLASHT_ATSER: 226 case SSB_CHIPCO_FLASHT_ATSER:
206 pr_err("Serial flash not supported\n"); 227 pr_debug("Found serial flash\n");
228 ssb_sflash_init(&bus->chipco);
207 break; 229 break;
208 case SSB_CHIPCO_FLASHT_PARA: 230 case SSB_CHIPCO_FLASHT_PARA:
209 pr_debug("Found parallel flash\n"); 231 pr_debug("Found parallel flash\n");
210 mcore->pflash.present = true; 232 pflash->present = true;
211 mcore->pflash.window = SSB_FLASH2; 233 pflash->window = SSB_FLASH2;
212 mcore->pflash.window_size = SSB_FLASH2_SZ; 234 pflash->window_size = SSB_FLASH2_SZ;
213 if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG) 235 if ((ssb_read32(bus->chipco.dev, SSB_CHIPCO_FLASH_CFG)
214 & SSB_CHIPCO_CFG_DS16) == 0) 236 & SSB_CHIPCO_CFG_DS16) == 0)
215 mcore->pflash.buswidth = 1; 237 pflash->buswidth = 1;
216 else 238 else
217 mcore->pflash.buswidth = 2; 239 pflash->buswidth = 2;
218 break; 240 break;
219 } 241 }
242
243ssb_pflash:
244 if (pflash->present) {
245 ssb_pflash_data.width = pflash->buswidth;
246 ssb_pflash_resource.start = pflash->window;
247 ssb_pflash_resource.end = pflash->window + pflash->window_size;
248 }
220} 249}
221 250
222u32 ssb_cpu_clock(struct ssb_mipscore *mcore) 251u32 ssb_cpu_clock(struct ssb_mipscore *mcore)
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 24dc331b4701..3b645b8a261f 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -549,6 +549,14 @@ static int ssb_devices_register(struct ssb_bus *bus)
549 dev_idx++; 549 dev_idx++;
550 } 550 }
551 551
552#ifdef CONFIG_SSB_DRIVER_MIPS
553 if (bus->mipscore.pflash.present) {
554 err = platform_device_register(&ssb_pflash_dev);
555 if (err)
556 pr_err("Error registering parallel flash\n");
557 }
558#endif
559
552 return 0; 560 return 0;
553error: 561error:
554 /* Unwind the already registered devices. */ 562 /* Unwind the already registered devices. */
diff --git a/drivers/ssb/ssb_private.h b/drivers/ssb/ssb_private.h
index da38305a2d22..466171b77f68 100644
--- a/drivers/ssb/ssb_private.h
+++ b/drivers/ssb/ssb_private.h
@@ -217,6 +217,21 @@ extern u32 ssb_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
217 u32 ticks); 217 u32 ticks);
218extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); 218extern u32 ssb_chipco_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
219 219
220/* driver_chipcommon_sflash.c */
221#ifdef CONFIG_SSB_SFLASH
222int ssb_sflash_init(struct ssb_chipcommon *cc);
223#else
224static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
225{
226 pr_err("Serial flash not supported\n");
227 return 0;
228}
229#endif /* CONFIG_SSB_SFLASH */
230
231#ifdef CONFIG_SSB_DRIVER_MIPS
232extern struct platform_device ssb_pflash_dev;
233#endif
234
220#ifdef CONFIG_SSB_DRIVER_EXTIF 235#ifdef CONFIG_SSB_DRIVER_EXTIF
221extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks); 236extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
222extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms); 237extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);