remove CONFIG_MTD_PARTITIONS references from lantiq 3.0 patches
[openwrt.git] / target / linux / generic / patches-3.0 / 025-bcma_backport.patch
1 --- a/drivers/bcma/Kconfig
2 +++ b/drivers/bcma/Kconfig
3 @@ -13,6 +13,11 @@ config BCMA
4 Bus driver for Broadcom specific Advanced Microcontroller Bus
5 Architecture.
6
7 +# Support for Block-I/O. SELECT this from the driver that needs it.
8 +config BCMA_BLOCKIO
9 + bool
10 + depends on BCMA
11 +
12 config BCMA_HOST_PCI_POSSIBLE
13 bool
14 depends on BCMA && PCI = y
15 --- a/drivers/bcma/Makefile
16 +++ b/drivers/bcma/Makefile
17 @@ -1,4 +1,4 @@
18 -bcma-y += main.o scan.o core.o
19 +bcma-y += main.o scan.o core.o sprom.o
20 bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
21 bcma-y += driver_pci.o
22 bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
23 --- a/drivers/bcma/bcma_private.h
24 +++ b/drivers/bcma/bcma_private.h
25 @@ -13,12 +13,15 @@
26 struct bcma_bus;
27
28 /* main.c */
29 -extern int bcma_bus_register(struct bcma_bus *bus);
30 -extern void bcma_bus_unregister(struct bcma_bus *bus);
31 +int bcma_bus_register(struct bcma_bus *bus);
32 +void bcma_bus_unregister(struct bcma_bus *bus);
33
34 /* scan.c */
35 int bcma_bus_scan(struct bcma_bus *bus);
36
37 +/* sprom.c */
38 +int bcma_sprom_get(struct bcma_bus *bus);
39 +
40 #ifdef CONFIG_BCMA_HOST_PCI
41 /* host_pci.c */
42 extern int __init bcma_host_pci_init(void);
43 --- a/drivers/bcma/core.c
44 +++ b/drivers/bcma/core.c
45 @@ -19,7 +19,7 @@ bool bcma_core_is_enabled(struct bcma_de
46 }
47 EXPORT_SYMBOL_GPL(bcma_core_is_enabled);
48
49 -static void bcma_core_disable(struct bcma_device *core, u32 flags)
50 +void bcma_core_disable(struct bcma_device *core, u32 flags)
51 {
52 if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
53 return;
54 @@ -31,6 +31,7 @@ static void bcma_core_disable(struct bcm
55 bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
56 udelay(1);
57 }
58 +EXPORT_SYMBOL_GPL(bcma_core_disable);
59
60 int bcma_core_enable(struct bcma_device *core, u32 flags)
61 {
62 --- a/drivers/bcma/driver_chipcommon_pmu.c
63 +++ b/drivers/bcma/driver_chipcommon_pmu.c
64 @@ -53,6 +53,7 @@ static void bcma_pmu_resources_init(stru
65 max_msk = 0xFFFF;
66 break;
67 case 43224:
68 + case 43225:
69 break;
70 default:
71 pr_err("PMU resource config unknown for device 0x%04X\n",
72 @@ -74,6 +75,7 @@ void bcma_pmu_swreg_init(struct bcma_drv
73 case 0x4313:
74 case 0x4331:
75 case 43224:
76 + case 43225:
77 break;
78 default:
79 pr_err("PMU switch/regulators init unknown for device "
80 @@ -96,11 +98,13 @@ void bcma_pmu_workarounds(struct bcma_dr
81 if (bus->chipinfo.rev == 0) {
82 pr_err("Workarounds for 43224 rev 0 not fully "
83 "implemented\n");
84 - bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
85 + bcma_chipco_chipctl_maskset(cc, 0, ~0, 0x00F000F0);
86 } else {
87 bcma_chipco_chipctl_maskset(cc, 0, ~0, 0xF0);
88 }
89 break;
90 + case 43225:
91 + break;
92 default:
93 pr_err("Workarounds unknown for device 0x%04X\n",
94 bus->chipinfo.id);
95 --- a/drivers/bcma/driver_pci.c
96 +++ b/drivers/bcma/driver_pci.c
97 @@ -161,3 +161,27 @@ void bcma_core_pci_init(struct bcma_drv_
98 {
99 bcma_pcicore_serdes_workaround(pc);
100 }
101 +
102 +int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
103 + bool enable)
104 +{
105 + struct pci_dev *pdev = pc->core->bus->host_pci;
106 + u32 coremask, tmp;
107 + int err;
108 +
109 + err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
110 + if (err)
111 + goto out;
112 +
113 + coremask = BIT(core->core_index) << 8;
114 + if (enable)
115 + tmp |= coremask;
116 + else
117 + tmp &= ~coremask;
118 +
119 + err = pci_write_config_dword(pdev, BCMA_PCI_IRQMASK, tmp);
120 +
121 +out:
122 + return err;
123 +}
124 +EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
125 --- a/drivers/bcma/host_pci.c
126 +++ b/drivers/bcma/host_pci.c
127 @@ -65,6 +65,54 @@ static void bcma_host_pci_write32(struct
128 iowrite32(value, core->bus->mmio + offset);
129 }
130
131 +#ifdef CONFIG_BCMA_BLOCKIO
132 +void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
133 + size_t count, u16 offset, u8 reg_width)
134 +{
135 + void __iomem *addr = core->bus->mmio + offset;
136 + if (core->bus->mapped_core != core)
137 + bcma_host_pci_switch_core(core);
138 + switch (reg_width) {
139 + case sizeof(u8):
140 + ioread8_rep(addr, buffer, count);
141 + break;
142 + case sizeof(u16):
143 + WARN_ON(count & 1);
144 + ioread16_rep(addr, buffer, count >> 1);
145 + break;
146 + case sizeof(u32):
147 + WARN_ON(count & 3);
148 + ioread32_rep(addr, buffer, count >> 2);
149 + break;
150 + default:
151 + WARN_ON(1);
152 + }
153 +}
154 +
155 +void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
156 + size_t count, u16 offset, u8 reg_width)
157 +{
158 + void __iomem *addr = core->bus->mmio + offset;
159 + if (core->bus->mapped_core != core)
160 + bcma_host_pci_switch_core(core);
161 + switch (reg_width) {
162 + case sizeof(u8):
163 + iowrite8_rep(addr, buffer, count);
164 + break;
165 + case sizeof(u16):
166 + WARN_ON(count & 1);
167 + iowrite16_rep(addr, buffer, count >> 1);
168 + break;
169 + case sizeof(u32):
170 + WARN_ON(count & 3);
171 + iowrite32_rep(addr, buffer, count >> 2);
172 + break;
173 + default:
174 + WARN_ON(1);
175 + }
176 +}
177 +#endif
178 +
179 static u32 bcma_host_pci_aread32(struct bcma_device *core, u16 offset)
180 {
181 if (core->bus->mapped_core != core)
182 @@ -87,6 +135,10 @@ const struct bcma_host_ops bcma_host_pci
183 .write8 = bcma_host_pci_write8,
184 .write16 = bcma_host_pci_write16,
185 .write32 = bcma_host_pci_write32,
186 +#ifdef CONFIG_BCMA_BLOCKIO
187 + .block_read = bcma_host_pci_block_read,
188 + .block_write = bcma_host_pci_block_write,
189 +#endif
190 .aread32 = bcma_host_pci_aread32,
191 .awrite32 = bcma_host_pci_awrite32,
192 };
193 @@ -175,6 +227,7 @@ static DEFINE_PCI_DEVICE_TABLE(bcma_pci_
194 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
195 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
196 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
197 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
198 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
199 { 0, },
200 };
201 --- a/drivers/bcma/main.c
202 +++ b/drivers/bcma/main.c
203 @@ -7,6 +7,7 @@
204
205 #include "bcma_private.h"
206 #include <linux/bcma/bcma.h>
207 +#include <linux/slab.h>
208
209 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
210 MODULE_LICENSE("GPL");
211 @@ -89,6 +90,8 @@ static int bcma_register_cores(struct bc
212 switch (bus->hosttype) {
213 case BCMA_HOSTTYPE_PCI:
214 core->dev.parent = &bus->host_pci->dev;
215 + core->dma_dev = &bus->host_pci->dev;
216 + core->irq = bus->host_pci->irq;
217 break;
218 case BCMA_HOSTTYPE_NONE:
219 case BCMA_HOSTTYPE_SDIO:
220 @@ -144,6 +147,13 @@ int bcma_bus_register(struct bcma_bus *b
221 bcma_core_pci_init(&bus->drv_pci);
222 }
223
224 + /* Try to get SPROM */
225 + err = bcma_sprom_get(bus);
226 + if (err) {
227 + pr_err("Failed to get SPROM: %d\n", err);
228 + return -ENOENT;
229 + }
230 +
231 /* Register found cores */
232 bcma_register_cores(bus);
233
234 @@ -151,13 +161,11 @@ int bcma_bus_register(struct bcma_bus *b
235
236 return 0;
237 }
238 -EXPORT_SYMBOL_GPL(bcma_bus_register);
239
240 void bcma_bus_unregister(struct bcma_bus *bus)
241 {
242 bcma_unregister_cores(bus);
243 }
244 -EXPORT_SYMBOL_GPL(bcma_bus_unregister);
245
246 int __bcma_driver_register(struct bcma_driver *drv, struct module *owner)
247 {
248 --- /dev/null
249 +++ b/drivers/bcma/sprom.c
250 @@ -0,0 +1,162 @@
251 +/*
252 + * Broadcom specific AMBA
253 + * SPROM reading
254 + *
255 + * Licensed under the GNU/GPL. See COPYING for details.
256 + */
257 +
258 +#include "bcma_private.h"
259 +
260 +#include <linux/bcma/bcma.h>
261 +#include <linux/bcma/bcma_regs.h>
262 +#include <linux/pci.h>
263 +#include <linux/io.h>
264 +#include <linux/dma-mapping.h>
265 +#include <linux/slab.h>
266 +
267 +#define SPOFF(offset) ((offset) / sizeof(u16))
268 +
269 +/**************************************************
270 + * R/W ops.
271 + **************************************************/
272 +
273 +static void bcma_sprom_read(struct bcma_bus *bus, u16 *sprom)
274 +{
275 + int i;
276 + for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
277 + sprom[i] = bcma_read16(bus->drv_cc.core,
278 + BCMA_CC_SPROM + (i * 2));
279 +}
280 +
281 +/**************************************************
282 + * Validation.
283 + **************************************************/
284 +
285 +static inline u8 bcma_crc8(u8 crc, u8 data)
286 +{
287 + /* Polynomial: x^8 + x^7 + x^6 + x^4 + x^2 + 1 */
288 + static const u8 t[] = {
289 + 0x00, 0xF7, 0xB9, 0x4E, 0x25, 0xD2, 0x9C, 0x6B,
290 + 0x4A, 0xBD, 0xF3, 0x04, 0x6F, 0x98, 0xD6, 0x21,
291 + 0x94, 0x63, 0x2D, 0xDA, 0xB1, 0x46, 0x08, 0xFF,
292 + 0xDE, 0x29, 0x67, 0x90, 0xFB, 0x0C, 0x42, 0xB5,
293 + 0x7F, 0x88, 0xC6, 0x31, 0x5A, 0xAD, 0xE3, 0x14,
294 + 0x35, 0xC2, 0x8C, 0x7B, 0x10, 0xE7, 0xA9, 0x5E,
295 + 0xEB, 0x1C, 0x52, 0xA5, 0xCE, 0x39, 0x77, 0x80,
296 + 0xA1, 0x56, 0x18, 0xEF, 0x84, 0x73, 0x3D, 0xCA,
297 + 0xFE, 0x09, 0x47, 0xB0, 0xDB, 0x2C, 0x62, 0x95,
298 + 0xB4, 0x43, 0x0D, 0xFA, 0x91, 0x66, 0x28, 0xDF,
299 + 0x6A, 0x9D, 0xD3, 0x24, 0x4F, 0xB8, 0xF6, 0x01,
300 + 0x20, 0xD7, 0x99, 0x6E, 0x05, 0xF2, 0xBC, 0x4B,
301 + 0x81, 0x76, 0x38, 0xCF, 0xA4, 0x53, 0x1D, 0xEA,
302 + 0xCB, 0x3C, 0x72, 0x85, 0xEE, 0x19, 0x57, 0xA0,
303 + 0x15, 0xE2, 0xAC, 0x5B, 0x30, 0xC7, 0x89, 0x7E,
304 + 0x5F, 0xA8, 0xE6, 0x11, 0x7A, 0x8D, 0xC3, 0x34,
305 + 0xAB, 0x5C, 0x12, 0xE5, 0x8E, 0x79, 0x37, 0xC0,
306 + 0xE1, 0x16, 0x58, 0xAF, 0xC4, 0x33, 0x7D, 0x8A,
307 + 0x3F, 0xC8, 0x86, 0x71, 0x1A, 0xED, 0xA3, 0x54,
308 + 0x75, 0x82, 0xCC, 0x3B, 0x50, 0xA7, 0xE9, 0x1E,
309 + 0xD4, 0x23, 0x6D, 0x9A, 0xF1, 0x06, 0x48, 0xBF,
310 + 0x9E, 0x69, 0x27, 0xD0, 0xBB, 0x4C, 0x02, 0xF5,
311 + 0x40, 0xB7, 0xF9, 0x0E, 0x65, 0x92, 0xDC, 0x2B,
312 + 0x0A, 0xFD, 0xB3, 0x44, 0x2F, 0xD8, 0x96, 0x61,
313 + 0x55, 0xA2, 0xEC, 0x1B, 0x70, 0x87, 0xC9, 0x3E,
314 + 0x1F, 0xE8, 0xA6, 0x51, 0x3A, 0xCD, 0x83, 0x74,
315 + 0xC1, 0x36, 0x78, 0x8F, 0xE4, 0x13, 0x5D, 0xAA,
316 + 0x8B, 0x7C, 0x32, 0xC5, 0xAE, 0x59, 0x17, 0xE0,
317 + 0x2A, 0xDD, 0x93, 0x64, 0x0F, 0xF8, 0xB6, 0x41,
318 + 0x60, 0x97, 0xD9, 0x2E, 0x45, 0xB2, 0xFC, 0x0B,
319 + 0xBE, 0x49, 0x07, 0xF0, 0x9B, 0x6C, 0x22, 0xD5,
320 + 0xF4, 0x03, 0x4D, 0xBA, 0xD1, 0x26, 0x68, 0x9F,
321 + };
322 + return t[crc ^ data];
323 +}
324 +
325 +static u8 bcma_sprom_crc(const u16 *sprom)
326 +{
327 + int word;
328 + u8 crc = 0xFF;
329 +
330 + for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) {
331 + crc = bcma_crc8(crc, sprom[word] & 0x00FF);
332 + crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8);
333 + }
334 + crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
335 + crc ^= 0xFF;
336 +
337 + return crc;
338 +}
339 +
340 +static int bcma_sprom_check_crc(const u16 *sprom)
341 +{
342 + u8 crc;
343 + u8 expected_crc;
344 + u16 tmp;
345 +
346 + crc = bcma_sprom_crc(sprom);
347 + tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC;
348 + expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
349 + if (crc != expected_crc)
350 + return -EPROTO;
351 +
352 + return 0;
353 +}
354 +
355 +static int bcma_sprom_valid(const u16 *sprom)
356 +{
357 + u16 revision;
358 + int err;
359 +
360 + err = bcma_sprom_check_crc(sprom);
361 + if (err)
362 + return err;
363 +
364 + revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
365 + if (revision != 8) {
366 + pr_err("Unsupported SPROM revision: %d\n", revision);
367 + return -ENOENT;
368 + }
369 +
370 + return 0;
371 +}
372 +
373 +/**************************************************
374 + * SPROM extraction.
375 + **************************************************/
376 +
377 +static void bcma_sprom_extract_r8(struct bcma_bus *bus, const u16 *sprom)
378 +{
379 + u16 v;
380 + int i;
381 +
382 + for (i = 0; i < 3; i++) {
383 + v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
384 + *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
385 + }
386 +}
387 +
388 +int bcma_sprom_get(struct bcma_bus *bus)
389 +{
390 + u16 *sprom;
391 + int err = 0;
392 +
393 + if (!bus->drv_cc.core)
394 + return -EOPNOTSUPP;
395 +
396 + sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
397 + GFP_KERNEL);
398 + if (!sprom)
399 + return -ENOMEM;
400 +
401 + bcma_sprom_read(bus, sprom);
402 +
403 + err = bcma_sprom_valid(sprom);
404 + if (err)
405 + goto out;
406 +
407 + bcma_sprom_extract_r8(bus, sprom);
408 +
409 +out:
410 + kfree(sprom);
411 + return err;
412 +}
413 --- a/include/linux/bcma/bcma.h
414 +++ b/include/linux/bcma/bcma.h
415 @@ -6,6 +6,7 @@
416
417 #include <linux/bcma/bcma_driver_chipcommon.h>
418 #include <linux/bcma/bcma_driver_pci.h>
419 +#include <linux/ssb/ssb.h> /* SPROM sharing */
420
421 #include "bcma_regs.h"
422
423 @@ -31,6 +32,12 @@ struct bcma_host_ops {
424 void (*write8)(struct bcma_device *core, u16 offset, u8 value);
425 void (*write16)(struct bcma_device *core, u16 offset, u16 value);
426 void (*write32)(struct bcma_device *core, u16 offset, u32 value);
427 +#ifdef CONFIG_BCMA_BLOCKIO
428 + void (*block_read)(struct bcma_device *core, void *buffer,
429 + size_t count, u16 offset, u8 reg_width);
430 + void (*block_write)(struct bcma_device *core, const void *buffer,
431 + size_t count, u16 offset, u8 reg_width);
432 +#endif
433 /* Agent ops */
434 u32 (*aread32)(struct bcma_device *core, u16 offset);
435 void (*awrite32)(struct bcma_device *core, u16 offset, u32 value);
436 @@ -117,6 +124,8 @@ struct bcma_device {
437 struct bcma_device_id id;
438
439 struct device dev;
440 + struct device *dma_dev;
441 + unsigned int irq;
442 bool dev_registered;
443
444 u8 core_index;
445 @@ -179,6 +188,10 @@ struct bcma_bus {
446
447 struct bcma_drv_cc drv_cc;
448 struct bcma_drv_pci drv_pci;
449 +
450 + /* We decided to share SPROM struct with SSB as long as we do not need
451 + * any hacks for BCMA. This simplifies drivers code. */
452 + struct ssb_sprom sprom;
453 };
454
455 extern inline u32 bcma_read8(struct bcma_device *core, u16 offset)
456 @@ -208,6 +221,18 @@ void bcma_write32(struct bcma_device *co
457 {
458 core->bus->ops->write32(core, offset, value);
459 }
460 +#ifdef CONFIG_BCMA_BLOCKIO
461 +extern inline void bcma_block_read(struct bcma_device *core, void *buffer,
462 + size_t count, u16 offset, u8 reg_width)
463 +{
464 + core->bus->ops->block_read(core, buffer, count, offset, reg_width);
465 +}
466 +extern inline void bcma_block_write(struct bcma_device *core, const void *buffer,
467 + size_t count, u16 offset, u8 reg_width)
468 +{
469 + core->bus->ops->block_write(core, buffer, count, offset, reg_width);
470 +}
471 +#endif
472 extern inline u32 bcma_aread32(struct bcma_device *core, u16 offset)
473 {
474 return core->bus->ops->aread32(core, offset);
475 @@ -219,6 +244,7 @@ void bcma_awrite32(struct bcma_device *c
476 }
477
478 extern bool bcma_core_is_enabled(struct bcma_device *core);
479 +extern void bcma_core_disable(struct bcma_device *core, u32 flags);
480 extern int bcma_core_enable(struct bcma_device *core, u32 flags);
481
482 #endif /* LINUX_BCMA_H_ */
483 --- a/include/linux/bcma/bcma_driver_chipcommon.h
484 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
485 @@ -244,6 +244,7 @@
486 #define BCMA_CC_REGCTL_DATA 0x065C
487 #define BCMA_CC_PLLCTL_ADDR 0x0660
488 #define BCMA_CC_PLLCTL_DATA 0x0664
489 +#define BCMA_CC_SPROM 0x0830 /* SPROM beginning */
490
491 /* Data for the PMU, if available.
492 * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
493 --- a/include/linux/bcma/bcma_driver_pci.h
494 +++ b/include/linux/bcma/bcma_driver_pci.h
495 @@ -85,5 +85,7 @@ struct bcma_drv_pci {
496 #define pcicore_write32(pc, offset, val) bcma_write32((pc)->core, offset, val)
497
498 extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
499 +extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
500 + struct bcma_device *core, bool enable);
501
502 #endif /* LINUX_BCMA_DRIVER_PCI_H_ */
This page took 0.071181 seconds and 5 git commands to generate.