ar71xx: add wmac callback for reading soc revision on ar934x
[openwrt/staging/wigyori.git] / package / kernel / mac80211 / patches / 300-pending_work.patch
1 commit c11113bc25df22898fb995d3205bdc4f27c98073
2 Author: Felix Fietkau <nbd@openwrt.org>
3 Date: Sat Sep 27 18:04:58 2014 +0200
4
5 ath5k: add missing include for debug code
6
7 Needed for calling vmalloc()/vfree()
8
9 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
10
11 commit 83f76a9f9a42773c7eef90bb86b4b2c16b0b3755
12 Author: Felix Fietkau <nbd@openwrt.org>
13 Date: Sat Sep 27 15:58:51 2014 +0200
14
15 ath5k: fix AHB kconfig dependency
16
17 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
18
19 commit ddd67f2a5cfd73fad4b78190025402d419b9f0a9
20 Author: Felix Fietkau <nbd@openwrt.org>
21 Date: Sat Sep 27 15:57:09 2014 +0200
22
23 Revert "ath5k: Remove AHB bus support"
24
25 This reverts commit 093ec3c5337434f40d77c1af06c139da3e5ba6dc.
26
27 --- a/drivers/net/wireless/ath/ath5k/Kconfig
28 +++ b/drivers/net/wireless/ath/ath5k/Kconfig
29 @@ -2,12 +2,14 @@ config ATH5K
30 tristate "Atheros 5xxx wireless cards support"
31 depends on m
32 depends on PCI && MAC80211
33 + depends on (PCI || ATHEROS_AR231X) && MAC80211
34 select ATH_COMMON
35 select MAC80211_LEDS
36 select BACKPORT_LEDS_CLASS
37 select BACKPORT_NEW_LEDS
38 select BACKPORT_AVERAGE
39 - select ATH5K_PCI
40 + select ATH5K_AHB if ATHEROS_AR231X
41 + select ATH5K_PCI if !ATHEROS_AR231X
42 ---help---
43 This module adds support for wireless adapters based on
44 Atheros 5xxx chipset.
45 @@ -52,9 +54,16 @@ config ATH5K_TRACER
46
47 If unsure, say N.
48
49 +config ATH5K_AHB
50 + bool "Atheros 5xxx AHB bus support"
51 + depends on ATHEROS_AR231X
52 + ---help---
53 + This adds support for WiSoC type chipsets of the 5xxx Atheros
54 + family.
55 +
56 config ATH5K_PCI
57 bool "Atheros 5xxx PCI bus support"
58 - depends on PCI
59 + depends on !ATHEROS_AR231X
60 ---help---
61 This adds support for PCI type chipsets of the 5xxx Atheros
62 family.
63 --- /dev/null
64 +++ b/drivers/net/wireless/ath/ath5k/ahb.c
65 @@ -0,0 +1,234 @@
66 +/*
67 + * Copyright (c) 2008-2009 Atheros Communications Inc.
68 + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
69 + * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
70 + *
71 + * Permission to use, copy, modify, and/or distribute this software for any
72 + * purpose with or without fee is hereby granted, provided that the above
73 + * copyright notice and this permission notice appear in all copies.
74 + *
75 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
76 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
77 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
78 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
79 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
80 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
81 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
82 + */
83 +
84 +#include <linux/nl80211.h>
85 +#include <linux/platform_device.h>
86 +#include <linux/etherdevice.h>
87 +#include <linux/export.h>
88 +#include <ar231x_platform.h>
89 +#include "ath5k.h"
90 +#include "debug.h"
91 +#include "base.h"
92 +#include "reg.h"
93 +
94 +/* return bus cachesize in 4B word units */
95 +static void ath5k_ahb_read_cachesize(struct ath_common *common, int *csz)
96 +{
97 + *csz = L1_CACHE_BYTES >> 2;
98 +}
99 +
100 +static bool
101 +ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
102 +{
103 + struct ath5k_hw *ah = common->priv;
104 + struct platform_device *pdev = to_platform_device(ah->dev);
105 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
106 + u16 *eeprom, *eeprom_end;
107 +
108 + eeprom = (u16 *) bcfg->radio;
109 + eeprom_end = ((void *) bcfg->config) + BOARD_CONFIG_BUFSZ;
110 +
111 + eeprom += off;
112 + if (eeprom > eeprom_end)
113 + return false;
114 +
115 + *data = *eeprom;
116 + return true;
117 +}
118 +
119 +int ath5k_hw_read_srev(struct ath5k_hw *ah)
120 +{
121 + struct platform_device *pdev = to_platform_device(ah->dev);
122 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
123 + ah->ah_mac_srev = bcfg->devid;
124 + return 0;
125 +}
126 +
127 +static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
128 +{
129 + struct platform_device *pdev = to_platform_device(ah->dev);
130 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
131 + u8 *cfg_mac;
132 +
133 + if (to_platform_device(ah->dev)->id == 0)
134 + cfg_mac = bcfg->config->wlan0_mac;
135 + else
136 + cfg_mac = bcfg->config->wlan1_mac;
137 +
138 + memcpy(mac, cfg_mac, ETH_ALEN);
139 + return 0;
140 +}
141 +
142 +static const struct ath_bus_ops ath_ahb_bus_ops = {
143 + .ath_bus_type = ATH_AHB,
144 + .read_cachesize = ath5k_ahb_read_cachesize,
145 + .eeprom_read = ath5k_ahb_eeprom_read,
146 + .eeprom_read_mac = ath5k_ahb_eeprom_read_mac,
147 +};
148 +
149 +/*Initialization*/
150 +static int ath_ahb_probe(struct platform_device *pdev)
151 +{
152 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
153 + struct ath5k_hw *ah;
154 + struct ieee80211_hw *hw;
155 + struct resource *res;
156 + void __iomem *mem;
157 + int irq;
158 + int ret = 0;
159 + u32 reg;
160 +
161 + if (!dev_get_platdata(&pdev->dev)) {
162 + dev_err(&pdev->dev, "no platform data specified\n");
163 + ret = -EINVAL;
164 + goto err_out;
165 + }
166 +
167 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
168 + if (res == NULL) {
169 + dev_err(&pdev->dev, "no memory resource found\n");
170 + ret = -ENXIO;
171 + goto err_out;
172 + }
173 +
174 + mem = ioremap_nocache(res->start, resource_size(res));
175 + if (mem == NULL) {
176 + dev_err(&pdev->dev, "ioremap failed\n");
177 + ret = -ENOMEM;
178 + goto err_out;
179 + }
180 +
181 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
182 + if (res == NULL) {
183 + dev_err(&pdev->dev, "no IRQ resource found\n");
184 + ret = -ENXIO;
185 + goto err_iounmap;
186 + }
187 +
188 + irq = res->start;
189 +
190 + hw = ieee80211_alloc_hw(sizeof(struct ath5k_hw), &ath5k_hw_ops);
191 + if (hw == NULL) {
192 + dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
193 + ret = -ENOMEM;
194 + goto err_iounmap;
195 + }
196 +
197 + ah = hw->priv;
198 + ah->hw = hw;
199 + ah->dev = &pdev->dev;
200 + ah->iobase = mem;
201 + ah->irq = irq;
202 + ah->devid = bcfg->devid;
203 +
204 + if (bcfg->devid >= AR5K_SREV_AR2315_R6) {
205 + /* Enable WMAC AHB arbitration */
206 + reg = ioread32((void __iomem *) AR5K_AR2315_AHB_ARB_CTL);
207 + reg |= AR5K_AR2315_AHB_ARB_CTL_WLAN;
208 + iowrite32(reg, (void __iomem *) AR5K_AR2315_AHB_ARB_CTL);
209 +
210 + /* Enable global WMAC swapping */
211 + reg = ioread32((void __iomem *) AR5K_AR2315_BYTESWAP);
212 + reg |= AR5K_AR2315_BYTESWAP_WMAC;
213 + iowrite32(reg, (void __iomem *) AR5K_AR2315_BYTESWAP);
214 + } else {
215 + /* Enable WMAC DMA access (assuming 5312 or 231x*/
216 + /* TODO: check other platforms */
217 + reg = ioread32((void __iomem *) AR5K_AR5312_ENABLE);
218 + if (to_platform_device(ah->dev)->id == 0)
219 + reg |= AR5K_AR5312_ENABLE_WLAN0;
220 + else
221 + reg |= AR5K_AR5312_ENABLE_WLAN1;
222 + iowrite32(reg, (void __iomem *) AR5K_AR5312_ENABLE);
223 +
224 + /*
225 + * On a dual-band AR5312, the multiband radio is only
226 + * used as pass-through. Disable 2 GHz support in the
227 + * driver for it
228 + */
229 + if (to_platform_device(ah->dev)->id == 0 &&
230 + (bcfg->config->flags & (BD_WLAN0 | BD_WLAN1)) ==
231 + (BD_WLAN1 | BD_WLAN0))
232 + ah->ah_capabilities.cap_needs_2GHz_ovr = true;
233 + else
234 + ah->ah_capabilities.cap_needs_2GHz_ovr = false;
235 + }
236 +
237 + ret = ath5k_init_ah(ah, &ath_ahb_bus_ops);
238 + if (ret != 0) {
239 + dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret);
240 + ret = -ENODEV;
241 + goto err_free_hw;
242 + }
243 +
244 + platform_set_drvdata(pdev, hw);
245 +
246 + return 0;
247 +
248 + err_free_hw:
249 + ieee80211_free_hw(hw);
250 + err_iounmap:
251 + iounmap(mem);
252 + err_out:
253 + return ret;
254 +}
255 +
256 +static int ath_ahb_remove(struct platform_device *pdev)
257 +{
258 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
259 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
260 + struct ath5k_hw *ah;
261 + u32 reg;
262 +
263 + if (!hw)
264 + return 0;
265 +
266 + ah = hw->priv;
267 +
268 + if (bcfg->devid >= AR5K_SREV_AR2315_R6) {
269 + /* Disable WMAC AHB arbitration */
270 + reg = ioread32((void __iomem *) AR5K_AR2315_AHB_ARB_CTL);
271 + reg &= ~AR5K_AR2315_AHB_ARB_CTL_WLAN;
272 + iowrite32(reg, (void __iomem *) AR5K_AR2315_AHB_ARB_CTL);
273 + } else {
274 + /*Stop DMA access */
275 + reg = ioread32((void __iomem *) AR5K_AR5312_ENABLE);
276 + if (to_platform_device(ah->dev)->id == 0)
277 + reg &= ~AR5K_AR5312_ENABLE_WLAN0;
278 + else
279 + reg &= ~AR5K_AR5312_ENABLE_WLAN1;
280 + iowrite32(reg, (void __iomem *) AR5K_AR5312_ENABLE);
281 + }
282 +
283 + ath5k_deinit_ah(ah);
284 + iounmap(ah->iobase);
285 + ieee80211_free_hw(hw);
286 +
287 + return 0;
288 +}
289 +
290 +static struct platform_driver ath_ahb_driver = {
291 + .probe = ath_ahb_probe,
292 + .remove = ath_ahb_remove,
293 + .driver = {
294 + .name = "ar231x-wmac",
295 + .owner = THIS_MODULE,
296 + },
297 +};
298 +
299 +module_platform_driver(ath_ahb_driver);
300 --- a/drivers/net/wireless/ath/ath5k/ath5k.h
301 +++ b/drivers/net/wireless/ath/ath5k/ath5k.h
302 @@ -1647,6 +1647,32 @@ static inline struct ath_regulatory *ath
303 return &(ath5k_hw_common(ah)->regulatory);
304 }
305
306 +#ifdef CONFIG_ATHEROS_AR231X
307 +#define AR5K_AR2315_PCI_BASE ((void __iomem *)0xb0100000)
308 +
309 +static inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg)
310 +{
311 + /* On AR2315 and AR2317 the PCI clock domain registers
312 + * are outside of the WMAC register space */
313 + if (unlikely((reg >= 0x4000) && (reg < 0x5000) &&
314 + (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6)))
315 + return AR5K_AR2315_PCI_BASE + reg;
316 +
317 + return ah->iobase + reg;
318 +}
319 +
320 +static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
321 +{
322 + return ioread32(ath5k_ahb_reg(ah, reg));
323 +}
324 +
325 +static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
326 +{
327 + iowrite32(val, ath5k_ahb_reg(ah, reg));
328 +}
329 +
330 +#else
331 +
332 static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
333 {
334 return ioread32(ah->iobase + reg);
335 @@ -1657,6 +1683,8 @@ static inline void ath5k_hw_reg_write(st
336 iowrite32(val, ah->iobase + reg);
337 }
338
339 +#endif
340 +
341 static inline enum ath_bus_type ath5k_get_bus_type(struct ath5k_hw *ah)
342 {
343 return ath5k_hw_common(ah)->bus_ops->ath_bus_type;
344 --- a/drivers/net/wireless/ath/ath5k/base.c
345 +++ b/drivers/net/wireless/ath/ath5k/base.c
346 @@ -99,6 +99,15 @@ static int ath5k_reset(struct ath5k_hw *
347
348 /* Known SREVs */
349 static const struct ath5k_srev_name srev_names[] = {
350 +#ifdef CONFIG_ATHEROS_AR231X
351 + { "5312", AR5K_VERSION_MAC, AR5K_SREV_AR5312_R2 },
352 + { "5312", AR5K_VERSION_MAC, AR5K_SREV_AR5312_R7 },
353 + { "2313", AR5K_VERSION_MAC, AR5K_SREV_AR2313_R8 },
354 + { "2315", AR5K_VERSION_MAC, AR5K_SREV_AR2315_R6 },
355 + { "2315", AR5K_VERSION_MAC, AR5K_SREV_AR2315_R7 },
356 + { "2317", AR5K_VERSION_MAC, AR5K_SREV_AR2317_R1 },
357 + { "2317", AR5K_VERSION_MAC, AR5K_SREV_AR2317_R2 },
358 +#else
359 { "5210", AR5K_VERSION_MAC, AR5K_SREV_AR5210 },
360 { "5311", AR5K_VERSION_MAC, AR5K_SREV_AR5311 },
361 { "5311A", AR5K_VERSION_MAC, AR5K_SREV_AR5311A },
362 @@ -117,6 +126,7 @@ static const struct ath5k_srev_name srev
363 { "5418", AR5K_VERSION_MAC, AR5K_SREV_AR5418 },
364 { "2425", AR5K_VERSION_MAC, AR5K_SREV_AR2425 },
365 { "2417", AR5K_VERSION_MAC, AR5K_SREV_AR2417 },
366 +#endif
367 { "xxxxx", AR5K_VERSION_MAC, AR5K_SREV_UNKNOWN },
368 { "5110", AR5K_VERSION_RAD, AR5K_SREV_RAD_5110 },
369 { "5111", AR5K_VERSION_RAD, AR5K_SREV_RAD_5111 },
370 @@ -132,6 +142,10 @@ static const struct ath5k_srev_name srev
371 { "5413", AR5K_VERSION_RAD, AR5K_SREV_RAD_5413 },
372 { "5424", AR5K_VERSION_RAD, AR5K_SREV_RAD_5424 },
373 { "5133", AR5K_VERSION_RAD, AR5K_SREV_RAD_5133 },
374 +#ifdef CONFIG_ATHEROS_AR231X
375 + { "2316", AR5K_VERSION_RAD, AR5K_SREV_RAD_2316 },
376 + { "2317", AR5K_VERSION_RAD, AR5K_SREV_RAD_2317 },
377 +#endif
378 { "xxxxx", AR5K_VERSION_RAD, AR5K_SREV_UNKNOWN },
379 };
380
381 --- a/drivers/net/wireless/ath/ath5k/led.c
382 +++ b/drivers/net/wireless/ath/ath5k/led.c
383 @@ -163,14 +163,20 @@ int ath5k_init_leds(struct ath5k_hw *ah)
384 {
385 int ret = 0;
386 struct ieee80211_hw *hw = ah->hw;
387 +#ifndef CONFIG_ATHEROS_AR231X
388 struct pci_dev *pdev = ah->pdev;
389 +#endif
390 char name[ATH5K_LED_MAX_NAME_LEN + 1];
391 const struct pci_device_id *match;
392
393 if (!ah->pdev)
394 return 0;
395
396 +#ifdef CONFIG_ATHEROS_AR231X
397 + match = NULL;
398 +#else
399 match = pci_match_id(&ath5k_led_devices[0], pdev);
400 +#endif
401 if (match) {
402 __set_bit(ATH_STAT_LEDSOFT, ah->status);
403 ah->led_pin = ATH_PIN(match->driver_data);
404 --- a/drivers/net/wireless/ath/ath5k/debug.c
405 +++ b/drivers/net/wireless/ath/ath5k/debug.c
406 @@ -65,6 +65,7 @@
407
408 #include <linux/seq_file.h>
409 #include <linux/list.h>
410 +#include <linux/vmalloc.h>
411 #include "debug.h"
412 #include "ath5k.h"
413 #include "reg.h"