kernel: bump to 3.18.84
[15.05/openwrt.git] / target / linux / generic / patches-3.18 / 027-bcma-from-4.1.patch
1 --- a/drivers/bcma/bcma_private.h
2 +++ b/drivers/bcma/bcma_private.h
3 @@ -24,6 +24,7 @@ bool bcma_wait_value(struct bcma_device
4                      int timeout);
5  void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core);
6  void bcma_init_bus(struct bcma_bus *bus);
7 +void bcma_unregister_cores(struct bcma_bus *bus);
8  int bcma_bus_register(struct bcma_bus *bus);
9  void bcma_bus_unregister(struct bcma_bus *bus);
10  int __init bcma_bus_early_register(struct bcma_bus *bus);
11 @@ -40,6 +41,9 @@ int bcma_bus_scan(struct bcma_bus *bus);
12  int bcma_sprom_get(struct bcma_bus *bus);
13  
14  /* driver_chipcommon.c */
15 +void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
16 +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
17 +void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
18  #ifdef CONFIG_BCMA_DRIVER_MIPS
19  void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
20  extern struct platform_device bcma_pflash_dev;
21 @@ -50,6 +54,8 @@ int bcma_core_chipcommon_b_init(struct b
22  void bcma_core_chipcommon_b_free(struct bcma_drv_cc_b *ccb);
23  
24  /* driver_chipcommon_pmu.c */
25 +void bcma_pmu_early_init(struct bcma_drv_cc *cc);
26 +void bcma_pmu_init(struct bcma_drv_cc *cc);
27  u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
28  u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
29  
30 @@ -98,7 +104,35 @@ static inline void __exit bcma_host_soc_
31  #endif /* CONFIG_BCMA_HOST_SOC && CONFIG_OF */
32  
33  /* driver_pci.c */
34 +#ifdef CONFIG_BCMA_DRIVER_PCI
35  u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
36 +void bcma_core_pci_early_init(struct bcma_drv_pci *pc);
37 +void bcma_core_pci_init(struct bcma_drv_pci *pc);
38 +void bcma_core_pci_up(struct bcma_drv_pci *pc);
39 +void bcma_core_pci_down(struct bcma_drv_pci *pc);
40 +#else
41 +static inline void bcma_core_pci_early_init(struct bcma_drv_pci *pc)
42 +{
43 +       WARN_ON(pc->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
44 +}
45 +static inline void bcma_core_pci_init(struct bcma_drv_pci *pc)
46 +{
47 +       /* Initialization is required for PCI hosted bus */
48 +       WARN_ON(pc->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
49 +}
50 +#endif
51 +
52 +/* driver_pcie2.c */
53 +#ifdef CONFIG_BCMA_DRIVER_PCI
54 +void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2);
55 +void bcma_core_pcie2_up(struct bcma_drv_pcie2 *pcie2);
56 +#else
57 +static inline void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2)
58 +{
59 +       /* Initialization is required for PCI hosted bus */
60 +       WARN_ON(pcie2->core->bus->hosttype == BCMA_HOSTTYPE_PCI);
61 +}
62 +#endif
63  
64  extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
65  
66 @@ -115,6 +149,39 @@ static inline void bcma_core_pci_hostmod
67  }
68  #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
69  
70 +/**************************************************
71 + * driver_mips.c
72 + **************************************************/
73 +
74 +#ifdef CONFIG_BCMA_DRIVER_MIPS
75 +unsigned int bcma_core_mips_irq(struct bcma_device *dev);
76 +void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
77 +void bcma_core_mips_init(struct bcma_drv_mips *mcore);
78 +#else
79 +static inline unsigned int bcma_core_mips_irq(struct bcma_device *dev)
80 +{
81 +       return 0;
82 +}
83 +static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
84 +{
85 +}
86 +static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore)
87 +{
88 +}
89 +#endif
90 +
91 +/**************************************************
92 + * driver_gmac_cmn.c
93 + **************************************************/
94 +
95 +#ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
96 +void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
97 +#else
98 +static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc)
99 +{
100 +}
101 +#endif
102 +
103  #ifdef CONFIG_BCMA_DRIVER_GPIO
104  /* driver_gpio.c */
105  int bcma_gpio_init(struct bcma_drv_cc *cc);
106 --- a/drivers/bcma/driver_gpio.c
107 +++ b/drivers/bcma/driver_gpio.c
108 @@ -17,6 +17,8 @@
109  
110  #include "bcma_private.h"
111  
112 +#define BCMA_GPIO_MAX_PINS     32
113 +
114  static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
115  {
116         return container_of(chip, struct bcma_drv_cc, gpio);
117 @@ -76,7 +78,7 @@ static void bcma_gpio_free(struct gpio_c
118         bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
119  }
120  
121 -#if IS_BUILTIN(CONFIG_BCM47XX)
122 +#if IS_BUILTIN(CONFIG_BCM47XX) || IS_BUILTIN(CONFIG_ARCH_BCM_5301X)
123  static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
124  {
125         struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
126 @@ -204,6 +206,7 @@ static void bcma_gpio_irq_domain_exit(st
127  
128  int bcma_gpio_init(struct bcma_drv_cc *cc)
129  {
130 +       struct bcma_bus *bus = cc->core->bus;
131         struct gpio_chip *chip = &cc->gpio;
132         int err;
133  
134 @@ -215,14 +218,14 @@ int bcma_gpio_init(struct bcma_drv_cc *c
135         chip->set               = bcma_gpio_set_value;
136         chip->direction_input   = bcma_gpio_direction_input;
137         chip->direction_output  = bcma_gpio_direction_output;
138 -#if IS_BUILTIN(CONFIG_BCM47XX)
139 +#if IS_BUILTIN(CONFIG_BCM47XX) || IS_BUILTIN(CONFIG_ARCH_BCM_5301X)
140         chip->to_irq            = bcma_gpio_to_irq;
141  #endif
142  #if IS_BUILTIN(CONFIG_OF)
143         if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
144                 chip->of_node   = cc->core->dev.of_node;
145  #endif
146 -       switch (cc->core->bus->chipinfo.id) {
147 +       switch (bus->chipinfo.id) {
148         case BCMA_CHIP_ID_BCM5357:
149         case BCMA_CHIP_ID_BCM53572:
150                 chip->ngpio     = 32;
151 @@ -231,13 +234,17 @@ int bcma_gpio_init(struct bcma_drv_cc *c
152                 chip->ngpio     = 16;
153         }
154  
155 -       /* There is just one SoC in one device and its GPIO addresses should be
156 -        * deterministic to address them more easily. The other buses could get
157 -        * a random base number. */
158 -       if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
159 -               chip->base              = 0;
160 -       else
161 -               chip->base              = -1;
162 +       /*
163 +        * On MIPS we register GPIO devices (LEDs, buttons) using absolute GPIO
164 +        * pin numbers. We don't have Device Tree there and we can't really use
165 +        * relative (per chip) numbers.
166 +        * So let's use predictable base for BCM47XX and "random" for all other.
167 +        */
168 +#if IS_BUILTIN(CONFIG_BCM47XX)
169 +       chip->base              = bus->num * BCMA_GPIO_MAX_PINS;
170 +#else
171 +       chip->base              = -1;
172 +#endif
173  
174         err = bcma_gpio_irq_domain_init(cc);
175         if (err)
176 --- a/drivers/bcma/driver_pci.c
177 +++ b/drivers/bcma/driver_pci.c
178 @@ -282,39 +282,6 @@ void bcma_core_pci_power_save(struct bcm
179  }
180  EXPORT_SYMBOL_GPL(bcma_core_pci_power_save);
181  
182 -int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
183 -                         bool enable)
184 -{
185 -       struct pci_dev *pdev;
186 -       u32 coremask, tmp;
187 -       int err = 0;
188 -
189 -       if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
190 -               /* This bcma device is not on a PCI host-bus. So the IRQs are
191 -                * not routed through the PCI core.
192 -                * So we must not enable routing through the PCI core. */
193 -               goto out;
194 -       }
195 -
196 -       pdev = pc->core->bus->host_pci;
197 -
198 -       err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
199 -       if (err)
200 -               goto out;
201 -
202 -       coremask = BIT(core->core_index) << 8;
203 -       if (enable)
204 -               tmp |= coremask;
205 -       else
206 -               tmp &= ~coremask;
207 -
208 -       err = pci_write_config_dword(pdev, BCMA_PCI_IRQMASK, tmp);
209 -
210 -out:
211 -       return err;
212 -}
213 -EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
214 -
215  static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
216  {
217         u32 w;
218 @@ -328,28 +295,12 @@ static void bcma_core_pci_extend_L1timer
219         bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
220  }
221  
222 -void bcma_core_pci_up(struct bcma_bus *bus)
223 +void bcma_core_pci_up(struct bcma_drv_pci *pc)
224  {
225 -       struct bcma_drv_pci *pc;
226 -
227 -       if (bus->hosttype != BCMA_HOSTTYPE_PCI)
228 -               return;
229 -
230 -       pc = &bus->drv_pci[0];
231 -
232         bcma_core_pci_extend_L1timer(pc, true);
233  }
234 -EXPORT_SYMBOL_GPL(bcma_core_pci_up);
235  
236 -void bcma_core_pci_down(struct bcma_bus *bus)
237 +void bcma_core_pci_down(struct bcma_drv_pci *pc)
238  {
239 -       struct bcma_drv_pci *pc;
240 -
241 -       if (bus->hosttype != BCMA_HOSTTYPE_PCI)
242 -               return;
243 -
244 -       pc = &bus->drv_pci[0];
245 -
246         bcma_core_pci_extend_L1timer(pc, false);
247  }
248 -EXPORT_SYMBOL_GPL(bcma_core_pci_down);
249 --- a/drivers/bcma/driver_pci_host.c
250 +++ b/drivers/bcma/driver_pci_host.c
251 @@ -11,6 +11,7 @@
252  
253  #include "bcma_private.h"
254  #include <linux/pci.h>
255 +#include <linux/slab.h>
256  #include <linux/export.h>
257  #include <linux/bcma/bcma.h>
258  #include <asm/paccess.h>
259 --- a/drivers/bcma/driver_pcie2.c
260 +++ b/drivers/bcma/driver_pcie2.c
261 @@ -10,6 +10,7 @@
262  
263  #include "bcma_private.h"
264  #include <linux/bcma/bcma.h>
265 +#include <linux/pci.h>
266  
267  /**************************************************
268   * R/W ops.
269 @@ -156,14 +157,23 @@ static void pciedev_reg_pm_clk_period(st
270  
271  void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2)
272  {
273 -       struct bcma_chipinfo *ci = &pcie2->core->bus->chipinfo;
274 +       struct bcma_bus *bus = pcie2->core->bus;
275 +       struct bcma_chipinfo *ci = &bus->chipinfo;
276         u32 tmp;
277  
278         tmp = pcie2_read32(pcie2, BCMA_CORE_PCIE2_SPROM(54));
279         if ((tmp & 0xe) >> 1 == 2)
280                 bcma_core_pcie2_cfg_write(pcie2, 0x4e0, 0x17);
281  
282 -       /* TODO: Do we need pcie_reqsize? */
283 +       switch (bus->chipinfo.id) {
284 +       case BCMA_CHIP_ID_BCM4360:
285 +       case BCMA_CHIP_ID_BCM4352:
286 +               pcie2->reqsize = 1024;
287 +               break;
288 +       default:
289 +               pcie2->reqsize = 128;
290 +               break;
291 +       }
292  
293         if (ci->id == BCMA_CHIP_ID_BCM4360 && ci->rev > 3)
294                 bcma_core_pcie2_war_delay_perst_enab(pcie2, true);
295 @@ -173,3 +183,18 @@ void bcma_core_pcie2_init(struct bcma_dr
296         pciedev_crwlpciegen2_180(pcie2);
297         pciedev_crwlpciegen2_182(pcie2);
298  }
299 +
300 +/**************************************************
301 + * Runtime ops.
302 + **************************************************/
303 +
304 +void bcma_core_pcie2_up(struct bcma_drv_pcie2 *pcie2)
305 +{
306 +       struct bcma_bus *bus = pcie2->core->bus;
307 +       struct pci_dev *dev = bus->host_pci;
308 +       int err;
309 +
310 +       err = pcie_set_readrq(dev, pcie2->reqsize);
311 +       if (err)
312 +               bcma_err(bus, "Error setting PCI_EXP_DEVCTL_READRQ: %d\n", err);
313 +}
314 --- a/drivers/bcma/host_pci.c
315 +++ b/drivers/bcma/host_pci.c
316 @@ -213,16 +213,26 @@ static int bcma_host_pci_probe(struct pc
317         /* Initialize struct, detect chip */
318         bcma_init_bus(bus);
319  
320 +       /* Scan bus to find out generation of PCIe core */
321 +       err = bcma_bus_scan(bus);
322 +       if (err)
323 +               goto err_pci_unmap_mmio;
324 +
325 +       if (bcma_find_core(bus, BCMA_CORE_PCIE2))
326 +               bus->host_is_pcie2 = true;
327 +
328         /* Register */
329         err = bcma_bus_register(bus);
330         if (err)
331 -               goto err_pci_unmap_mmio;
332 +               goto err_unregister_cores;
333  
334         pci_set_drvdata(dev, bus);
335  
336  out:
337         return err;
338  
339 +err_unregister_cores:
340 +       bcma_unregister_cores(bus);
341  err_pci_unmap_mmio:
342         pci_iounmap(dev, bus->mmio);
343  err_pci_release_regions:
344 @@ -283,9 +293,12 @@ static const struct pci_device_id bcma_p
345         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
346         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
347         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
348 +       { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4360) },
349         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
350 +       { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a0) },
351         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) },
352         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) },
353 +       { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43b1) },
354         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
355         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) },  /* 0xa8db, BCM43217 (sic!) */
356         { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43228) },  /* 0xa8dc */
357 @@ -310,3 +323,65 @@ void __exit bcma_host_pci_exit(void)
358  {
359         pci_unregister_driver(&bcma_pci_bridge_driver);
360  }
361 +
362 +/**************************************************
363 + * Runtime ops for drivers.
364 + **************************************************/
365 +
366 +/* See also pcicore_up */
367 +void bcma_host_pci_up(struct bcma_bus *bus)
368 +{
369 +       if (bus->hosttype != BCMA_HOSTTYPE_PCI)
370 +               return;
371 +
372 +       if (bus->host_is_pcie2)
373 +               bcma_core_pcie2_up(&bus->drv_pcie2);
374 +       else
375 +               bcma_core_pci_up(&bus->drv_pci[0]);
376 +}
377 +EXPORT_SYMBOL_GPL(bcma_host_pci_up);
378 +
379 +/* See also pcicore_down */
380 +void bcma_host_pci_down(struct bcma_bus *bus)
381 +{
382 +       if (bus->hosttype != BCMA_HOSTTYPE_PCI)
383 +               return;
384 +
385 +       if (!bus->host_is_pcie2)
386 +               bcma_core_pci_down(&bus->drv_pci[0]);
387 +}
388 +EXPORT_SYMBOL_GPL(bcma_host_pci_down);
389 +
390 +/* See also si_pci_setup */
391 +int bcma_host_pci_irq_ctl(struct bcma_bus *bus, struct bcma_device *core,
392 +                         bool enable)
393 +{
394 +       struct pci_dev *pdev;
395 +       u32 coremask, tmp;
396 +       int err = 0;
397 +
398 +       if (bus->hosttype != BCMA_HOSTTYPE_PCI) {
399 +               /* This bcma device is not on a PCI host-bus. So the IRQs are
400 +                * not routed through the PCI core.
401 +                * So we must not enable routing through the PCI core. */
402 +               goto out;
403 +       }
404 +
405 +       pdev = bus->host_pci;
406 +
407 +       err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
408 +       if (err)
409 +               goto out;
410 +
411 +       coremask = BIT(core->core_index) << 8;
412 +       if (enable)
413 +               tmp |= coremask;
414 +       else
415 +               tmp &= ~coremask;
416 +
417 +       err = pci_write_config_dword(pdev, BCMA_PCI_IRQMASK, tmp);
418 +
419 +out:
420 +       return err;
421 +}
422 +EXPORT_SYMBOL_GPL(bcma_host_pci_irq_ctl);
423 --- a/drivers/bcma/main.c
424 +++ b/drivers/bcma/main.c
425 @@ -363,7 +363,7 @@ static int bcma_register_devices(struct
426         return 0;
427  }
428  
429 -static void bcma_unregister_cores(struct bcma_bus *bus)
430 +void bcma_unregister_cores(struct bcma_bus *bus)
431  {
432         struct bcma_device *core, *tmp;
433  
434 --- a/drivers/net/wireless/b43/main.c
435 +++ b/drivers/net/wireless/b43/main.c
436 @@ -4770,7 +4770,7 @@ static void b43_wireless_core_exit(struc
437         switch (dev->dev->bus_type) {
438  #ifdef CONFIG_B43_BCMA
439         case B43_BUS_BCMA:
440 -               bcma_core_pci_down(dev->dev->bdev->bus);
441 +               bcma_host_pci_down(dev->dev->bdev->bus);
442                 break;
443  #endif
444  #ifdef CONFIG_B43_SSB
445 @@ -4817,9 +4817,9 @@ static int b43_wireless_core_init(struct
446         switch (dev->dev->bus_type) {
447  #ifdef CONFIG_B43_BCMA
448         case B43_BUS_BCMA:
449 -               bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
450 +               bcma_host_pci_irq_ctl(dev->dev->bdev->bus,
451                                       dev->dev->bdev, true);
452 -               bcma_core_pci_up(dev->dev->bdev->bus);
453 +               bcma_host_pci_up(dev->dev->bdev->bus);
454                 break;
455  #endif
456  #ifdef CONFIG_B43_SSB
457 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
458 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
459 @@ -4669,7 +4669,7 @@ static int brcms_b_attach(struct brcms_c
460         brcms_c_coredisable(wlc_hw);
461  
462         /* Match driver "down" state */
463 -       bcma_core_pci_down(wlc_hw->d11core->bus);
464 +       bcma_host_pci_down(wlc_hw->d11core->bus);
465  
466         /* turn off pll and xtal to match driver "down" state */
467         brcms_b_xtal(wlc_hw, OFF);
468 @@ -4960,7 +4960,7 @@ static int brcms_b_up_prep(struct brcms_
469          * Configure pci/pcmcia here instead of in brcms_c_attach()
470          * to allow mfg hotswap:  down, hotswap (chip power cycle), up.
471          */
472 -       bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci[0], wlc_hw->d11core,
473 +       bcma_host_pci_irq_ctl(wlc_hw->d11core->bus, wlc_hw->d11core,
474                               true);
475  
476         /*
477 @@ -4970,12 +4970,12 @@ static int brcms_b_up_prep(struct brcms_
478          */
479         if (brcms_b_radio_read_hwdisabled(wlc_hw)) {
480                 /* put SB PCI in down state again */
481 -               bcma_core_pci_down(wlc_hw->d11core->bus);
482 +               bcma_host_pci_down(wlc_hw->d11core->bus);
483                 brcms_b_xtal(wlc_hw, OFF);
484                 return -ENOMEDIUM;
485         }
486  
487 -       bcma_core_pci_up(wlc_hw->d11core->bus);
488 +       bcma_host_pci_up(wlc_hw->d11core->bus);
489  
490         /* reset the d11 core */
491         brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
492 @@ -5172,7 +5172,7 @@ static int brcms_b_down_finish(struct br
493  
494                 /* turn off primary xtal and pll */
495                 if (!wlc_hw->noreset) {
496 -                       bcma_core_pci_down(wlc_hw->d11core->bus);
497 +                       bcma_host_pci_down(wlc_hw->d11core->bus);
498                         brcms_b_xtal(wlc_hw, OFF);
499                 }
500         }
501 --- a/include/linux/bcma/bcma.h
502 +++ b/include/linux/bcma/bcma.h
503 @@ -435,6 +435,27 @@ static inline struct bcma_device *bcma_f
504         return bcma_find_core_unit(bus, coreid, 0);
505  }
506  
507 +#ifdef CONFIG_BCMA_HOST_PCI
508 +extern void bcma_host_pci_up(struct bcma_bus *bus);
509 +extern void bcma_host_pci_down(struct bcma_bus *bus);
510 +extern int bcma_host_pci_irq_ctl(struct bcma_bus *bus,
511 +                                struct bcma_device *core, bool enable);
512 +#else
513 +static inline void bcma_host_pci_up(struct bcma_bus *bus)
514 +{
515 +}
516 +static inline void bcma_host_pci_down(struct bcma_bus *bus)
517 +{
518 +}
519 +static inline int bcma_host_pci_irq_ctl(struct bcma_bus *bus,
520 +                                       struct bcma_device *core, bool enable)
521 +{
522 +       if (bus->hosttype == BCMA_HOSTTYPE_PCI)
523 +               return -ENOTSUPP;
524 +       return 0;
525 +}
526 +#endif
527 +
528  extern bool bcma_core_is_enabled(struct bcma_device *core);
529  extern void bcma_core_disable(struct bcma_device *core, u32 flags);
530  extern int bcma_core_enable(struct bcma_device *core, u32 flags);
531 --- a/include/linux/bcma/bcma_driver_pci.h
532 +++ b/include/linux/bcma/bcma_driver_pci.h
533 @@ -238,13 +238,13 @@ struct bcma_drv_pci {
534  #define pcicore_write16(pc, offset, val)       bcma_write16((pc)->core, offset, val)
535  #define pcicore_write32(pc, offset, val)       bcma_write32((pc)->core, offset, val)
536  
537 -extern void bcma_core_pci_early_init(struct bcma_drv_pci *pc);
538 -extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
539 -extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
540 -                                struct bcma_device *core, bool enable);
541 -extern void bcma_core_pci_up(struct bcma_bus *bus);
542 -extern void bcma_core_pci_down(struct bcma_bus *bus);
543 +#ifdef CONFIG_BCMA_DRIVER_PCI
544  extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up);
545 +#else
546 +static inline void bcma_core_pci_power_save(struct bcma_bus *bus, bool up)
547 +{
548 +}
549 +#endif
550  
551  extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
552  extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
553 --- a/include/linux/bcma/bcma_driver_pcie2.h
554 +++ b/include/linux/bcma/bcma_driver_pcie2.h
555 @@ -143,6 +143,8 @@
556  
557  struct bcma_drv_pcie2 {
558         struct bcma_device *core;
559 +
560 +       u16 reqsize;
561  };
562  
563  #define pcie2_read16(pcie2, offset)            bcma_read16((pcie2)->core, offset)
564 @@ -153,6 +155,4 @@ struct bcma_drv_pcie2 {
565  #define pcie2_set32(pcie2, offset, set)                bcma_set32((pcie2)->core, offset, set)
566  #define pcie2_mask32(pcie2, offset, mask)      bcma_mask32((pcie2)->core, offset, mask)
567  
568 -void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2);
569 -
570  #endif /* LINUX_BCMA_DRIVER_PCIE2_H_ */
571 --- a/drivers/bcma/Kconfig
572 +++ b/drivers/bcma/Kconfig
573 @@ -26,6 +26,7 @@ config BCMA_HOST_PCI_POSSIBLE
574  config BCMA_HOST_PCI
575         bool "Support for BCMA on PCI-host bus"
576         depends on BCMA_HOST_PCI_POSSIBLE
577 +       select BCMA_DRIVER_PCI
578         default y
579  
580  config BCMA_DRIVER_PCI_HOSTMODE
581 @@ -44,6 +45,22 @@ config BCMA_HOST_SOC
582  
583           If unsure, say N
584  
585 +config BCMA_DRIVER_PCI
586 +       bool "BCMA Broadcom PCI core driver"
587 +       depends on BCMA && PCI
588 +       default y
589 +       help
590 +         BCMA bus may have many versions of PCIe core. This driver
591 +         supports:
592 +         1) PCIe core working in clientmode
593 +         2) PCIe Gen 2 clientmode core
594 +
595 +         In general PCIe (Gen 2) clientmode core is required on PCIe
596 +         hosted buses. It's responsible for initialization and basic
597 +         hardware management.
598 +         This driver is also prerequisite for a hostmode PCIe core
599 +         support.
600 +
601  config BCMA_DRIVER_MIPS
602         bool "BCMA Broadcom MIPS core driver"
603         depends on BCMA && MIPS
604 --- a/drivers/bcma/Makefile
605 +++ b/drivers/bcma/Makefile
606 @@ -3,8 +3,8 @@ bcma-y                                  += driver_chipcommon.o driver
607  bcma-y                                 += driver_chipcommon_b.o
608  bcma-$(CONFIG_BCMA_SFLASH)             += driver_chipcommon_sflash.o
609  bcma-$(CONFIG_BCMA_NFLASH)             += driver_chipcommon_nflash.o
610 -bcma-y                                 += driver_pci.o
611 -bcma-y                                 += driver_pcie2.o
612 +bcma-$(CONFIG_BCMA_DRIVER_PCI)         += driver_pci.o
613 +bcma-$(CONFIG_BCMA_DRIVER_PCI)         += driver_pcie2.o
614  bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE)        += driver_pci_host.o
615  bcma-$(CONFIG_BCMA_DRIVER_MIPS)                += driver_mips.o
616  bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN)    += driver_gmac_cmn.o
617 --- a/include/linux/bcma/bcma_driver_chipcommon.h
618 +++ b/include/linux/bcma/bcma_driver_chipcommon.h
619 @@ -663,14 +663,6 @@ struct bcma_drv_cc_b {
620  #define bcma_cc_maskset32(cc, offset, mask, set) \
621         bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
622  
623 -extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
624 -extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
625 -
626 -extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
627 -extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
628 -
629 -void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
630 -
631  extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
632  
633  extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
634 @@ -690,9 +682,6 @@ u32 bcma_chipco_gpio_pullup(struct bcma_
635  u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
636  
637  /* PMU support */
638 -extern void bcma_pmu_init(struct bcma_drv_cc *cc);
639 -extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
640 -
641  extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
642                                   u32 value);
643  extern void bcma_chipco_pll_maskset(struct bcma_drv_cc *cc, u32 offset,
644 --- a/include/linux/bcma/bcma_driver_gmac_cmn.h
645 +++ b/include/linux/bcma/bcma_driver_gmac_cmn.h
646 @@ -91,10 +91,4 @@ struct bcma_drv_gmac_cmn {
647  #define gmac_cmn_write16(gc, offset, val)      bcma_write16((gc)->core, offset, val)
648  #define gmac_cmn_write32(gc, offset, val)      bcma_write32((gc)->core, offset, val)
649  
650 -#ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
651 -extern void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
652 -#else
653 -static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc) { }
654 -#endif
655 -
656  #endif /* LINUX_BCMA_DRIVER_GMAC_CMN_H_ */
657 --- a/include/linux/bcma/bcma_driver_mips.h
658 +++ b/include/linux/bcma/bcma_driver_mips.h
659 @@ -39,21 +39,6 @@ struct bcma_drv_mips {
660         u8 early_setup_done:1;
661  };
662  
663 -#ifdef CONFIG_BCMA_DRIVER_MIPS
664 -extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
665 -extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
666 -
667 -extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
668 -#else
669 -static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
670 -static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
671 -
672 -static inline unsigned int bcma_core_mips_irq(struct bcma_device *dev)
673 -{
674 -       return 0;
675 -}
676 -#endif
677 -
678  extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
679  
680  #endif /* LINUX_BCMA_DRIVER_MIPS_H_ */