1 diff --git a/drivers/ssb/Kconfig b/drivers/ssb/Kconfig
2 index 5ff3a4f..36171fd 100644
3 --- a/drivers/ssb/Kconfig
4 +++ b/drivers/ssb/Kconfig
5 @@ -144,7 +144,7 @@ config SSB_SFLASH
6 # Assumption: We are on embedded, if we compile the MIPS core.
9 - depends on SSB_DRIVER_MIPS
10 + depends on SSB_DRIVER_MIPS && SSB_PCICORE_HOSTMODE
13 config SSB_DRIVER_EXTIF
14 diff --git a/drivers/ssb/driver_chipcommon_sflash.c b/drivers/ssb/driver_chipcommon_sflash.c
15 index 720665c..e84cf04 100644
16 --- a/drivers/ssb/driver_chipcommon_sflash.c
17 +++ b/drivers/ssb/driver_chipcommon_sflash.c
20 #include "ssb_private.h"
22 +static struct resource ssb_sflash_resource = {
23 + .name = "ssb_sflash",
24 + .start = SSB_FLASH2,
26 + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
29 +struct platform_device ssb_sflash_dev = {
30 + .name = "ssb_sflash",
31 + .resource = &ssb_sflash_resource,
35 struct ssb_sflash_tbl_e {
38 @@ -16,7 +29,7 @@ struct ssb_sflash_tbl_e {
42 -static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
43 +static const struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
44 { "M25P20", 0x11, 0x10000, 4, },
45 { "M25P40", 0x12, 0x10000, 8, },
47 @@ -27,7 +40,7 @@ static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
51 -static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
52 +static const struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
53 { "SST25WF512", 1, 0x1000, 16, },
54 { "SST25VF512", 0x48, 0x1000, 16, },
55 { "SST25WF010", 2, 0x1000, 32, },
56 @@ -45,7 +58,7 @@ static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
60 -static struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
61 +static const struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
62 { "AT45DB011", 0xc, 256, 512, },
63 { "AT45DB021", 0x14, 256, 1024, },
64 { "AT45DB041", 0x1c, 256, 2048, },
65 @@ -73,7 +86,8 @@ static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32 opcode)
66 /* Initialize serial flash access */
67 int ssb_sflash_init(struct ssb_chipcommon *cc)
69 - struct ssb_sflash_tbl_e *e;
70 + struct ssb_sflash *sflash = &cc->dev->bus->mipscore.sflash;
71 + const struct ssb_sflash_tbl_e *e;
74 switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) {
75 @@ -131,9 +145,21 @@ int ssb_sflash_init(struct ssb_chipcommon *cc)
79 + sflash->window = SSB_FLASH2;
80 + sflash->blocksize = e->blocksize;
81 + sflash->numblocks = e->numblocks;
82 + sflash->size = sflash->blocksize * sflash->numblocks;
83 + sflash->present = true;
85 pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n",
86 e->name, e->blocksize, e->numblocks);
88 + /* Prepare platform device, but don't register it yet. It's too early,
89 + * malloc (required by device_private_init) is not available yet. */
90 + ssb_sflash_dev.resource[0].end = ssb_sflash_dev.resource[0].start +
92 + ssb_sflash_dev.dev.platform_data = sflash;
94 pr_err("Serial flash support is not implemented yet!\n");
97 diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
98 index 812775a..e55ddf7 100644
99 --- a/drivers/ssb/main.c
100 +++ b/drivers/ssb/main.c
101 @@ -553,6 +553,14 @@ static int ssb_devices_register(struct ssb_bus *bus)
105 +#ifdef CONFIG_SSB_SFLASH
106 + if (bus->mipscore.sflash.present) {
107 + err = platform_device_register(&ssb_sflash_dev);
109 + pr_err("Error registering serial flash\n");
115 /* Unwind the already registered devices. */
116 diff --git a/drivers/ssb/pcihost_wrapper.c b/drivers/ssb/pcihost_wrapper.c
117 index 32ed1fa..69161bb 100644
118 --- a/drivers/ssb/pcihost_wrapper.c
119 +++ b/drivers/ssb/pcihost_wrapper.c
120 @@ -38,7 +38,7 @@ static int ssb_pcihost_resume(struct pci_dev *dev)
121 struct ssb_bus *ssb = pci_get_drvdata(dev);
124 - pci_set_power_state(dev, 0);
125 + pci_set_power_state(dev, PCI_D0);
126 err = pci_enable_device(dev);
129 diff --git a/drivers/ssb/sprom.c b/drivers/ssb/sprom.c
130 index a3b2364..e753fbe 100644
131 --- a/drivers/ssb/sprom.c
132 +++ b/drivers/ssb/sprom.c
133 @@ -54,7 +54,7 @@ static int hex2sprom(u16 *sprom, const char *dump, size_t len,
134 while (cnt < sprom_size_words) {
135 memcpy(tmp, dump, 4);
137 - err = strict_strtoul(tmp, 16, &parsed);
138 + err = kstrtoul(tmp, 16, &parsed);
141 sprom[cnt++] = swab16((u16)parsed);
142 diff --git a/drivers/ssb/ssb_private.h b/drivers/ssb/ssb_private.h
143 index 4671f17..eb507a5 100644
144 --- a/drivers/ssb/ssb_private.h
145 +++ b/drivers/ssb/ssb_private.h
146 @@ -243,6 +243,10 @@ static inline int ssb_sflash_init(struct ssb_chipcommon *cc)
147 extern struct platform_device ssb_pflash_dev;
150 +#ifdef CONFIG_SSB_SFLASH
151 +extern struct platform_device ssb_sflash_dev;
154 #ifdef CONFIG_SSB_DRIVER_EXTIF
155 extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
156 extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
157 diff --git a/include/linux/ssb/ssb_driver_mips.h b/include/linux/ssb/ssb_driver_mips.h
158 index afe79d4..6535e47 100644
159 --- a/include/linux/ssb/ssb_driver_mips.h
160 +++ b/include/linux/ssb/ssb_driver_mips.h
161 @@ -20,6 +20,18 @@ struct ssb_pflash {
165 +#ifdef CONFIG_SSB_SFLASH
177 struct ssb_mipscore {
178 struct ssb_device *dev;
180 @@ -27,6 +39,9 @@ struct ssb_mipscore {
181 struct ssb_serial_port serial_ports[4];
183 struct ssb_pflash pflash;
184 +#ifdef CONFIG_SSB_SFLASH
185 + struct ssb_sflash sflash;
189 extern void ssb_mipscore_init(struct ssb_mipscore *mcore);
190 diff --git a/include/linux/ssb/ssb_regs.h b/include/linux/ssb/ssb_regs.h
191 index 3a72569..f9f931c 100644
192 --- a/include/linux/ssb/ssb_regs.h
193 +++ b/include/linux/ssb/ssb_regs.h
195 #define SSB_SPROMSIZE_WORDS_R4 220
196 #define SSB_SPROMSIZE_BYTES_R123 (SSB_SPROMSIZE_WORDS_R123 * sizeof(u16))
197 #define SSB_SPROMSIZE_BYTES_R4 (SSB_SPROMSIZE_WORDS_R4 * sizeof(u16))
198 +#define SSB_SPROMSIZE_WORDS_R10 230
199 #define SSB_SPROM_BASE1 0x1000
200 #define SSB_SPROM_BASE31 0x0800
201 #define SSB_SPROM_REVISION 0x007E