1 commit c11113bc25df22898fb995d3205bdc4f27c98073
2 Author: Felix Fietkau <nbd@openwrt.org>
3 Date: Sat Sep 27 18:04:58 2014 +0200
5 ath5k: add missing include for debug code
7 Needed for calling vmalloc()/vfree()
9 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 commit 83f76a9f9a42773c7eef90bb86b4b2c16b0b3755
12 Author: Felix Fietkau <nbd@openwrt.org>
13 Date: Sat Sep 27 15:58:51 2014 +0200
15 ath5k: fix AHB kconfig dependency
17 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
19 commit ddd67f2a5cfd73fad4b78190025402d419b9f0a9
20 Author: Felix Fietkau <nbd@openwrt.org>
21 Date: Sat Sep 27 15:57:09 2014 +0200
23 Revert "ath5k: Remove AHB bus support"
25 This reverts commit 093ec3c5337434f40d77c1af06c139da3e5ba6dc.
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"
32 depends on PCI && MAC80211
33 + depends on (PCI || ATHEROS_AR231X) && MAC80211
36 select BACKPORT_LEDS_CLASS
37 select BACKPORT_NEW_LEDS
38 select BACKPORT_AVERAGE
40 + select ATH5K_AHB if ATHEROS_AR231X
41 + select ATH5K_PCI if !ATHEROS_AR231X
43 This module adds support for wireless adapters based on
45 @@ -52,9 +54,16 @@ config ATH5K_TRACER
50 + bool "Atheros 5xxx AHB bus support"
51 + depends on ATHEROS_AR231X
53 + This adds support for WiSoC type chipsets of the 5xxx Atheros
57 bool "Atheros 5xxx PCI bus support"
59 + depends on !ATHEROS_AR231X
61 This adds support for PCI type chipsets of the 5xxx Atheros
64 +++ b/drivers/net/wireless/ath/ath5k/ahb.c
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>
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.
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.
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>
94 +/* return bus cachesize in 4B word units */
95 +static void ath5k_ahb_read_cachesize(struct ath_common *common, int *csz)
97 + *csz = L1_CACHE_BYTES >> 2;
101 +ath5k_ahb_eeprom_read(struct ath_common *common, u32 off, u16 *data)
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;
108 + eeprom = (u16 *) bcfg->radio;
109 + eeprom_end = ((void *) bcfg->config) + BOARD_CONFIG_BUFSZ;
112 + if (eeprom > eeprom_end)
119 +int ath5k_hw_read_srev(struct ath5k_hw *ah)
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;
127 +static int ath5k_ahb_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
129 + struct platform_device *pdev = to_platform_device(ah->dev);
130 + struct ar231x_board_config *bcfg = dev_get_platdata(&pdev->dev);
133 + if (to_platform_device(ah->dev)->id == 0)
134 + cfg_mac = bcfg->config->wlan0_mac;
136 + cfg_mac = bcfg->config->wlan1_mac;
138 + memcpy(mac, cfg_mac, ETH_ALEN);
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,
150 +static int ath_ahb_probe(struct platform_device *pdev)
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;
161 + if (!dev_get_platdata(&pdev->dev)) {
162 + dev_err(&pdev->dev, "no platform data specified\n");
167 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
169 + dev_err(&pdev->dev, "no memory resource found\n");
174 + mem = ioremap_nocache(res->start, resource_size(res));
176 + dev_err(&pdev->dev, "ioremap failed\n");
181 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
183 + dev_err(&pdev->dev, "no IRQ resource found\n");
190 + hw = ieee80211_alloc_hw(sizeof(struct ath5k_hw), &ath5k_hw_ops);
192 + dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
199 + ah->dev = &pdev->dev;
202 + ah->devid = bcfg->devid;
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);
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);
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;
221 + reg |= AR5K_AR5312_ENABLE_WLAN1;
222 + iowrite32(reg, (void __iomem *) AR5K_AR5312_ENABLE);
225 + * On a dual-band AR5312, the multiband radio is only
226 + * used as pass-through. Disable 2 GHz support in the
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;
234 + ah->ah_capabilities.cap_needs_2GHz_ovr = false;
237 + ret = ath5k_init_ah(ah, &ath_ahb_bus_ops);
239 + dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret);
244 + platform_set_drvdata(pdev, hw);
249 + ieee80211_free_hw(hw);
256 +static int ath_ahb_remove(struct platform_device *pdev)
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;
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);
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;
279 + reg &= ~AR5K_AR5312_ENABLE_WLAN1;
280 + iowrite32(reg, (void __iomem *) AR5K_AR5312_ENABLE);
283 + ath5k_deinit_ah(ah);
284 + iounmap(ah->iobase);
285 + ieee80211_free_hw(hw);
290 +static struct platform_driver ath_ahb_driver = {
291 + .probe = ath_ahb_probe,
292 + .remove = ath_ahb_remove,
294 + .name = "ar231x-wmac",
295 + .owner = THIS_MODULE,
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);
306 +#ifdef CONFIG_ATHEROS_AR231X
307 +#define AR5K_AR2315_PCI_BASE ((void __iomem *)0xb0100000)
309 +static inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg)
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;
317 + return ah->iobase + reg;
320 +static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
322 + return ioread32(ath5k_ahb_reg(ah, reg));
325 +static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
327 + iowrite32(val, ath5k_ahb_reg(ah, reg));
332 static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
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);
341 static inline enum ath_bus_type ath5k_get_bus_type(struct ath5k_hw *ah)
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 *
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 },
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 },
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 },
378 { "xxxxx", AR5K_VERSION_RAD, AR5K_SREV_UNKNOWN },
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)
386 struct ieee80211_hw *hw = ah->hw;
387 +#ifndef CONFIG_ATHEROS_AR231X
388 struct pci_dev *pdev = ah->pdev;
390 char name[ATH5K_LED_MAX_NAME_LEN + 1];
391 const struct pci_device_id *match;
396 +#ifdef CONFIG_ATHEROS_AR231X
399 match = pci_match_id(&ath5k_led_devices[0], pdev);
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
408 #include <linux/seq_file.h>
409 #include <linux/list.h>
410 +#include <linux/vmalloc.h>