6e659507db82ff12bed177fc8687ad9cdcdb2712
[openwrt/svn-archive/archive.git] / package / kernel / mac80211 / patches / 085-bcma-from-4.1.patch
1 --- a/drivers/bcma/bcma_private.h
2 +++ b/drivers/bcma/bcma_private.h
3 @@ -41,6 +41,7 @@ int __init bcma_bus_scan_early(struct bc
4 struct bcma_device_id *match,
5 struct bcma_device *core);
6 void bcma_init_bus(struct bcma_bus *bus);
7 +void bcma_unregister_cores(struct bcma_bus *bus);
8
9 /* sprom.c */
10 int bcma_sprom_get(struct bcma_bus *bus);
11 @@ -105,6 +106,11 @@ static inline void __exit bcma_host_soc_
12
13 /* driver_pci.c */
14 u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
15 +void bcma_core_pci_up(struct bcma_drv_pci *pc);
16 +void bcma_core_pci_down(struct bcma_drv_pci *pc);
17 +
18 +/* driver_pcie2.c */
19 +void bcma_core_pcie2_up(struct bcma_drv_pcie2 *pcie2);
20
21 extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
22
23 --- a/drivers/bcma/driver_gpio.c
24 +++ b/drivers/bcma/driver_gpio.c
25 @@ -76,7 +76,7 @@ static void bcma_gpio_free(struct gpio_c
26 bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
27 }
28
29 -#if IS_BUILTIN(CONFIG_BCM47XX)
30 +#if IS_BUILTIN(CONFIG_BCM47XX) || IS_BUILTIN(CONFIG_ARCH_BCM_5301X)
31 static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
32 {
33 struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
34 @@ -215,7 +215,7 @@ int bcma_gpio_init(struct bcma_drv_cc *c
35 chip->set = bcma_gpio_set_value;
36 chip->direction_input = bcma_gpio_direction_input;
37 chip->direction_output = bcma_gpio_direction_output;
38 -#if IS_BUILTIN(CONFIG_BCM47XX)
39 +#if IS_BUILTIN(CONFIG_BCM47XX) || IS_BUILTIN(CONFIG_ARCH_BCM_5301X)
40 chip->to_irq = bcma_gpio_to_irq;
41 #endif
42 #if IS_BUILTIN(CONFIG_OF)
43 --- a/drivers/bcma/driver_pci.c
44 +++ b/drivers/bcma/driver_pci.c
45 @@ -262,21 +262,21 @@ void bcma_core_pci_power_save(struct bcm
46 }
47 EXPORT_SYMBOL_GPL(bcma_core_pci_power_save);
48
49 -int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
50 +int bcma_core_pci_irq_ctl(struct bcma_bus *bus, struct bcma_device *core,
51 bool enable)
52 {
53 struct pci_dev *pdev;
54 u32 coremask, tmp;
55 int err = 0;
56
57 - if (!pc || core->bus->hosttype != BCMA_HOSTTYPE_PCI) {
58 + if (bus->hosttype != BCMA_HOSTTYPE_PCI) {
59 /* This bcma device is not on a PCI host-bus. So the IRQs are
60 * not routed through the PCI core.
61 * So we must not enable routing through the PCI core. */
62 goto out;
63 }
64
65 - pdev = pc->core->bus->host_pci;
66 + pdev = bus->host_pci;
67
68 err = pci_read_config_dword(pdev, BCMA_PCI_IRQMASK, &tmp);
69 if (err)
70 @@ -308,28 +308,12 @@ static void bcma_core_pci_extend_L1timer
71 bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
72 }
73
74 -void bcma_core_pci_up(struct bcma_bus *bus)
75 +void bcma_core_pci_up(struct bcma_drv_pci *pc)
76 {
77 - struct bcma_drv_pci *pc;
78 -
79 - if (bus->hosttype != BCMA_HOSTTYPE_PCI)
80 - return;
81 -
82 - pc = &bus->drv_pci[0];
83 -
84 bcma_core_pci_extend_L1timer(pc, true);
85 }
86 -EXPORT_SYMBOL_GPL(bcma_core_pci_up);
87
88 -void bcma_core_pci_down(struct bcma_bus *bus)
89 +void bcma_core_pci_down(struct bcma_drv_pci *pc)
90 {
91 - struct bcma_drv_pci *pc;
92 -
93 - if (bus->hosttype != BCMA_HOSTTYPE_PCI)
94 - return;
95 -
96 - pc = &bus->drv_pci[0];
97 -
98 bcma_core_pci_extend_L1timer(pc, false);
99 }
100 -EXPORT_SYMBOL_GPL(bcma_core_pci_down);
101 --- a/drivers/bcma/driver_pci_host.c
102 +++ b/drivers/bcma/driver_pci_host.c
103 @@ -11,6 +11,7 @@
104
105 #include "bcma_private.h"
106 #include <linux/pci.h>
107 +#include <linux/slab.h>
108 #include <linux/export.h>
109 #include <linux/bcma/bcma.h>
110 #include <asm/paccess.h>
111 --- a/drivers/bcma/driver_pcie2.c
112 +++ b/drivers/bcma/driver_pcie2.c
113 @@ -10,6 +10,7 @@
114
115 #include "bcma_private.h"
116 #include <linux/bcma/bcma.h>
117 +#include <linux/pci.h>
118
119 /**************************************************
120 * R/W ops.
121 @@ -156,14 +157,23 @@ static void pciedev_reg_pm_clk_period(st
122
123 void bcma_core_pcie2_init(struct bcma_drv_pcie2 *pcie2)
124 {
125 - struct bcma_chipinfo *ci = &pcie2->core->bus->chipinfo;
126 + struct bcma_bus *bus = pcie2->core->bus;
127 + struct bcma_chipinfo *ci = &bus->chipinfo;
128 u32 tmp;
129
130 tmp = pcie2_read32(pcie2, BCMA_CORE_PCIE2_SPROM(54));
131 if ((tmp & 0xe) >> 1 == 2)
132 bcma_core_pcie2_cfg_write(pcie2, 0x4e0, 0x17);
133
134 - /* TODO: Do we need pcie_reqsize? */
135 + switch (bus->chipinfo.id) {
136 + case BCMA_CHIP_ID_BCM4360:
137 + case BCMA_CHIP_ID_BCM4352:
138 + pcie2->reqsize = 1024;
139 + break;
140 + default:
141 + pcie2->reqsize = 128;
142 + break;
143 + }
144
145 if (ci->id == BCMA_CHIP_ID_BCM4360 && ci->rev > 3)
146 bcma_core_pcie2_war_delay_perst_enab(pcie2, true);
147 @@ -173,3 +183,18 @@ void bcma_core_pcie2_init(struct bcma_dr
148 pciedev_crwlpciegen2_180(pcie2);
149 pciedev_crwlpciegen2_182(pcie2);
150 }
151 +
152 +/**************************************************
153 + * Runtime ops.
154 + **************************************************/
155 +
156 +void bcma_core_pcie2_up(struct bcma_drv_pcie2 *pcie2)
157 +{
158 + struct bcma_bus *bus = pcie2->core->bus;
159 + struct pci_dev *dev = bus->host_pci;
160 + int err;
161 +
162 + err = pcie_set_readrq(dev, pcie2->reqsize);
163 + if (err)
164 + bcma_err(bus, "Error setting PCI_EXP_DEVCTL_READRQ: %d\n", err);
165 +}
166 --- a/drivers/bcma/host_pci.c
167 +++ b/drivers/bcma/host_pci.c
168 @@ -211,16 +211,26 @@ static int bcma_host_pci_probe(struct pc
169 /* Initialize struct, detect chip */
170 bcma_init_bus(bus);
171
172 + /* Scan bus to find out generation of PCIe core */
173 + err = bcma_bus_scan(bus);
174 + if (err)
175 + goto err_pci_unmap_mmio;
176 +
177 + if (bcma_find_core(bus, BCMA_CORE_PCIE2))
178 + bus->host_is_pcie2 = true;
179 +
180 /* Register */
181 err = bcma_bus_register(bus);
182 if (err)
183 - goto err_pci_unmap_mmio;
184 + goto err_unregister_cores;
185
186 pci_set_drvdata(dev, bus);
187
188 out:
189 return err;
190
191 +err_unregister_cores:
192 + bcma_unregister_cores(bus);
193 err_pci_unmap_mmio:
194 pci_iounmap(dev, bus->mmio);
195 err_pci_release_regions:
196 @@ -281,9 +291,12 @@ static const struct pci_device_id bcma_p
197 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
198 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
199 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
200 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4360) },
201 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
202 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a0) },
203 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43a9) },
204 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43aa) },
205 + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x43b1) },
206 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
207 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43227) }, /* 0xa8db, BCM43217 (sic!) */
208 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 43228) }, /* 0xa8dc */
209 @@ -308,3 +321,31 @@ void __exit bcma_host_pci_exit(void)
210 {
211 pci_unregister_driver(&bcma_pci_bridge_driver);
212 }
213 +
214 +/**************************************************
215 + * Runtime ops for drivers.
216 + **************************************************/
217 +
218 +/* See also pcicore_up */
219 +void bcma_host_pci_up(struct bcma_bus *bus)
220 +{
221 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
222 + return;
223 +
224 + if (bus->host_is_pcie2)
225 + bcma_core_pcie2_up(&bus->drv_pcie2);
226 + else
227 + bcma_core_pci_up(&bus->drv_pci[0]);
228 +}
229 +EXPORT_SYMBOL_GPL(bcma_host_pci_up);
230 +
231 +/* See also pcicore_down */
232 +void bcma_host_pci_down(struct bcma_bus *bus)
233 +{
234 + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
235 + return;
236 +
237 + if (!bus->host_is_pcie2)
238 + bcma_core_pci_down(&bus->drv_pci[0]);
239 +}
240 +EXPORT_SYMBOL_GPL(bcma_host_pci_down);
241 --- a/drivers/bcma/main.c
242 +++ b/drivers/bcma/main.c
243 @@ -288,7 +288,7 @@ static int bcma_register_devices(struct
244 return 0;
245 }
246
247 -static void bcma_unregister_cores(struct bcma_bus *bus)
248 +void bcma_unregister_cores(struct bcma_bus *bus)
249 {
250 struct bcma_device *core, *tmp;
251
252 --- a/drivers/net/wireless/b43/main.c
253 +++ b/drivers/net/wireless/b43/main.c
254 @@ -4770,7 +4770,7 @@ static void b43_wireless_core_exit(struc
255 switch (dev->dev->bus_type) {
256 #ifdef CPTCFG_B43_BCMA
257 case B43_BUS_BCMA:
258 - bcma_core_pci_down(dev->dev->bdev->bus);
259 + bcma_host_pci_down(dev->dev->bdev->bus);
260 break;
261 #endif
262 #ifdef CPTCFG_B43_SSB
263 @@ -4817,9 +4817,9 @@ static int b43_wireless_core_init(struct
264 switch (dev->dev->bus_type) {
265 #ifdef CPTCFG_B43_BCMA
266 case B43_BUS_BCMA:
267 - bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
268 + bcma_core_pci_irq_ctl(dev->dev->bdev->bus,
269 dev->dev->bdev, true);
270 - bcma_core_pci_up(dev->dev->bdev->bus);
271 + bcma_host_pci_up(dev->dev->bdev->bus);
272 break;
273 #endif
274 #ifdef CPTCFG_B43_SSB
275 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
276 +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
277 @@ -4669,7 +4669,7 @@ static int brcms_b_attach(struct brcms_c
278 brcms_c_coredisable(wlc_hw);
279
280 /* Match driver "down" state */
281 - bcma_core_pci_down(wlc_hw->d11core->bus);
282 + bcma_host_pci_down(wlc_hw->d11core->bus);
283
284 /* turn off pll and xtal to match driver "down" state */
285 brcms_b_xtal(wlc_hw, OFF);
286 @@ -4960,7 +4960,7 @@ static int brcms_b_up_prep(struct brcms_
287 * Configure pci/pcmcia here instead of in brcms_c_attach()
288 * to allow mfg hotswap: down, hotswap (chip power cycle), up.
289 */
290 - bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci[0], wlc_hw->d11core,
291 + bcma_core_pci_irq_ctl(wlc_hw->d11core->bus, wlc_hw->d11core,
292 true);
293
294 /*
295 @@ -4970,12 +4970,12 @@ static int brcms_b_up_prep(struct brcms_
296 */
297 if (brcms_b_radio_read_hwdisabled(wlc_hw)) {
298 /* put SB PCI in down state again */
299 - bcma_core_pci_down(wlc_hw->d11core->bus);
300 + bcma_host_pci_down(wlc_hw->d11core->bus);
301 brcms_b_xtal(wlc_hw, OFF);
302 return -ENOMEDIUM;
303 }
304
305 - bcma_core_pci_up(wlc_hw->d11core->bus);
306 + bcma_host_pci_up(wlc_hw->d11core->bus);
307
308 /* reset the d11 core */
309 brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
310 @@ -5172,7 +5172,7 @@ static int brcms_b_down_finish(struct br
311
312 /* turn off primary xtal and pll */
313 if (!wlc_hw->noreset) {
314 - bcma_core_pci_down(wlc_hw->d11core->bus);
315 + bcma_host_pci_down(wlc_hw->d11core->bus);
316 brcms_b_xtal(wlc_hw, OFF);
317 }
318 }