kernel: update 3.10 to 3.10.2
[openwrt.git] / target / linux / generic / patches-3.10 / 020-ssb_update.patch
1 --- a/drivers/ssb/Kconfig
2 +++ b/drivers/ssb/Kconfig
3 @@ -144,7 +144,7 @@ config SSB_SFLASH
4  # Assumption: We are on embedded, if we compile the MIPS core.
5  config SSB_EMBEDDED
6         bool
7 -       depends on SSB_DRIVER_MIPS
8 +       depends on SSB_DRIVER_MIPS && SSB_PCICORE_HOSTMODE
9         default y
10  
11  config SSB_DRIVER_EXTIF
12 --- a/drivers/ssb/driver_chipcommon_sflash.c
13 +++ b/drivers/ssb/driver_chipcommon_sflash.c
14 @@ -9,6 +9,19 @@
15  
16  #include "ssb_private.h"
17  
18 +static struct resource ssb_sflash_resource = {
19 +       .name   = "ssb_sflash",
20 +       .start  = SSB_FLASH2,
21 +       .end    = 0,
22 +       .flags  = IORESOURCE_MEM | IORESOURCE_READONLY,
23 +};
24 +
25 +struct platform_device ssb_sflash_dev = {
26 +       .name           = "ssb_sflash",
27 +       .resource       = &ssb_sflash_resource,
28 +       .num_resources  = 1,
29 +};
30 +
31  struct ssb_sflash_tbl_e {
32         char *name;
33         u32 id;
34 @@ -16,7 +29,7 @@ struct ssb_sflash_tbl_e {
35         u16 numblocks;
36  };
37  
38 -static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
39 +static const struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
40         { "M25P20", 0x11, 0x10000, 4, },
41         { "M25P40", 0x12, 0x10000, 8, },
42  
43 @@ -27,7 +40,7 @@ static struct ssb_sflash_tbl_e ssb_sflas
44         { 0 },
45  };
46  
47 -static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
48 +static const struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
49         { "SST25WF512", 1, 0x1000, 16, },
50         { "SST25VF512", 0x48, 0x1000, 16, },
51         { "SST25WF010", 2, 0x1000, 32, },
52 @@ -45,7 +58,7 @@ static struct ssb_sflash_tbl_e ssb_sflas
53         { 0 },
54  };
55  
56 -static struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
57 +static const struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
58         { "AT45DB011", 0xc, 256, 512, },
59         { "AT45DB021", 0x14, 256, 1024, },
60         { "AT45DB041", 0x1c, 256, 2048, },
61 @@ -73,7 +86,8 @@ static void ssb_sflash_cmd(struct ssb_ch
62  /* Initialize serial flash access */
63  int ssb_sflash_init(struct ssb_chipcommon *cc)
64  {
65 -       struct ssb_sflash_tbl_e *e;
66 +       struct ssb_sflash *sflash = &cc->dev->bus->mipscore.sflash;
67 +       const struct ssb_sflash_tbl_e *e;
68         u32 id, id2;
69  
70         switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) {
71 @@ -131,9 +145,21 @@ int ssb_sflash_init(struct ssb_chipcommo
72                 return -ENOTSUPP;
73         }
74  
75 +       sflash->window = SSB_FLASH2;
76 +       sflash->blocksize = e->blocksize;
77 +       sflash->numblocks = e->numblocks;
78 +       sflash->size = sflash->blocksize * sflash->numblocks;
79 +       sflash->present = true;
80 +
81         pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n",
82                 e->name, e->blocksize, e->numblocks);
83  
84 +       /* Prepare platform device, but don't register it yet. It's too early,
85 +        * malloc (required by device_private_init) is not available yet. */
86 +       ssb_sflash_dev.resource[0].end = ssb_sflash_dev.resource[0].start +
87 +                                        sflash->size;
88 +       ssb_sflash_dev.dev.platform_data = sflash;
89 +
90         pr_err("Serial flash support is not implemented yet!\n");
91  
92         return -ENOTSUPP;
93 --- a/drivers/ssb/main.c
94 +++ b/drivers/ssb/main.c
95 @@ -553,6 +553,14 @@ static int ssb_devices_register(struct s
96         }
97  #endif
98  
99 +#ifdef CONFIG_SSB_SFLASH
100 +       if (bus->mipscore.sflash.present) {
101 +               err = platform_device_register(&ssb_sflash_dev);
102 +               if (err)
103 +                       pr_err("Error registering serial flash\n");
104 +       }
105 +#endif
106 +
107         return 0;
108  error:
109         /* Unwind the already registered devices. */
110 --- a/drivers/ssb/pcihost_wrapper.c
111 +++ b/drivers/ssb/pcihost_wrapper.c
112 @@ -38,7 +38,7 @@ static int ssb_pcihost_resume(struct pci
113         struct ssb_bus *ssb = pci_get_drvdata(dev);
114         int err;
115  
116 -       pci_set_power_state(dev, 0);
117 +       pci_set_power_state(dev, PCI_D0);
118         err = pci_enable_device(dev);
119         if (err)
120                 return err;
121 --- a/drivers/ssb/sprom.c
122 +++ b/drivers/ssb/sprom.c
123 @@ -54,7 +54,7 @@ static int hex2sprom(u16 *sprom, const c
124         while (cnt < sprom_size_words) {
125                 memcpy(tmp, dump, 4);
126                 dump += 4;
127 -               err = strict_strtoul(tmp, 16, &parsed);
128 +               err = kstrtoul(tmp, 16, &parsed);
129                 if (err)
130                         return err;
131                 sprom[cnt++] = swab16((u16)parsed);
132 --- a/drivers/ssb/ssb_private.h
133 +++ b/drivers/ssb/ssb_private.h
134 @@ -243,6 +243,10 @@ static inline int ssb_sflash_init(struct
135  extern struct platform_device ssb_pflash_dev;
136  #endif
137  
138 +#ifdef CONFIG_SSB_SFLASH
139 +extern struct platform_device ssb_sflash_dev;
140 +#endif
141 +
142  #ifdef CONFIG_SSB_DRIVER_EXTIF
143  extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
144  extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
145 --- a/include/linux/ssb/ssb_driver_mips.h
146 +++ b/include/linux/ssb/ssb_driver_mips.h
147 @@ -20,6 +20,18 @@ struct ssb_pflash {
148         u32 window_size;
149  };
150  
151 +#ifdef CONFIG_SSB_SFLASH
152 +struct ssb_sflash {
153 +       bool present;
154 +       u32 window;
155 +       u32 blocksize;
156 +       u16 numblocks;
157 +       u32 size;
158 +
159 +       void *priv;
160 +};
161 +#endif
162 +
163  struct ssb_mipscore {
164         struct ssb_device *dev;
165  
166 @@ -27,6 +39,9 @@ struct ssb_mipscore {
167         struct ssb_serial_port serial_ports[4];
168  
169         struct ssb_pflash pflash;
170 +#ifdef CONFIG_SSB_SFLASH
171 +       struct ssb_sflash sflash;
172 +#endif
173  };
174  
175  extern void ssb_mipscore_init(struct ssb_mipscore *mcore);
176 --- a/include/linux/ssb/ssb_regs.h
177 +++ b/include/linux/ssb/ssb_regs.h
178 @@ -172,6 +172,7 @@
179  #define SSB_SPROMSIZE_WORDS_R4         220
180  #define SSB_SPROMSIZE_BYTES_R123       (SSB_SPROMSIZE_WORDS_R123 * sizeof(u16))
181  #define SSB_SPROMSIZE_BYTES_R4         (SSB_SPROMSIZE_WORDS_R4 * sizeof(u16))
182 +#define SSB_SPROMSIZE_WORDS_R10                230
183  #define SSB_SPROM_BASE1                        0x1000
184  #define SSB_SPROM_BASE31               0x0800
185  #define SSB_SPROM_REVISION             0x007E