1 From 9b3c1b50a35455e28c5b2fede615a304df42e758 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Mon, 5 Jan 2009 11:03:17 +0100
4 Subject: [PATCH 06/11] ath9k: introduce platform driver for AHB bus support
6 This patch adds the platform_driver itself, and modifies the main driver
9 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
10 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
12 drivers/net/wireless/ath9k/Makefile | 1 +
13 drivers/net/wireless/ath9k/ahb.c | 179 +++++++++++++++++++++++++++++++++++
14 drivers/net/wireless/ath9k/core.h | 9 ++
15 drivers/net/wireless/ath9k/main.c | 10 ++
16 4 files changed, 199 insertions(+), 0 deletions(-)
18 --- a/drivers/net/wireless/ath9k/Makefile
19 +++ b/drivers/net/wireless/ath9k/Makefile
20 @@ -12,6 +12,7 @@ ath9k-y += hw.o \
23 ath9k-$(CONFIG_PCI) += pci.o
24 +ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o
25 ath9k-$(CONFIG_ATH9K_DEBUG) += debug.o
27 obj-$(CONFIG_ATH9K) += ath9k.o
29 +++ b/drivers/net/wireless/ath9k/ahb.c
32 + * Copyright (c) 2008 Atheros Communications Inc.
33 + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
34 + * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
36 + * Permission to use, copy, modify, and/or distribute this software for any
37 + * purpose with or without fee is hereby granted, provided that the above
38 + * copyright notice and this permission notice appear in all copies.
40 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
41 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
42 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
43 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
44 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
45 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
46 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49 +#include <linux/nl80211.h>
50 +#include <linux/platform_device.h>
55 +/* return bus cachesize in 4B word units */
56 +static void ath_ahb_read_cachesize(struct ath_softc *sc, int *csz)
58 + *csz = L1_CACHE_BYTES >> 2;
61 +static void ath_ahb_cleanup(struct ath_softc *sc)
63 + struct ieee80211_hw *hw = sc->hw;
65 + free_irq(sc->irq, sc);
69 + ieee80211_free_hw(hw);
72 +static struct ath_bus_ops ath_ahb_bus_ops = {
73 + .read_cachesize = ath_ahb_read_cachesize,
74 + .cleanup = ath_ahb_cleanup,
77 +static int ath_ahb_probe(struct platform_device *pdev)
80 + struct ath_softc *sc;
81 + struct ieee80211_hw *hw;
82 + struct resource *res;
87 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
89 + dev_err(&pdev->dev, "no memory resource found\n");
94 + mem = ioremap_nocache(res->start, res->end - res->start + 1);
96 + dev_err(&pdev->dev, "ioremap failed\n");
101 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
103 + dev_err(&pdev->dev, "no IRQ resource found\n");
110 + hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
112 + dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
117 + hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
118 + IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
119 + IEEE80211_HW_SIGNAL_DBM |
120 + IEEE80211_HW_NOISE_DBM;
122 + hw->wiphy->interface_modes =
123 + BIT(NL80211_IFTYPE_AP) |
124 + BIT(NL80211_IFTYPE_STATION) |
125 + BIT(NL80211_IFTYPE_ADHOC);
127 + SET_IEEE80211_DEV(hw, &pdev->dev);
128 + platform_set_drvdata(pdev, hw);
132 + sc->dev = &pdev->dev;
134 + sc->bus_ops = &ath_ahb_bus_ops;
137 + ret = ath_attach(AR5416_AR9100_DEVID, sc);
139 + dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret);
144 + ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc);
146 + dev_err(&pdev->dev, "request_irq failed, err=%d\n", ret);
153 + "%s: Atheros AR%s MAC/BB Rev:%x, "
154 + "AR%s RF Rev:%x, mem=0x%lx, irq=%d\n",
155 + wiphy_name(hw->wiphy),
156 + ath_mac_bb_name(ah->ah_macVersion),
158 + ath_rf_name((ah->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR)),
160 + (unsigned long)mem, irq);
167 + ieee80211_free_hw(hw);
168 + platform_set_drvdata(pdev, NULL);
175 +static int ath_ahb_remove(struct platform_device *pdev)
177 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
180 + struct ath_softc *sc = hw->priv;
182 + free_irq(sc->irq, sc);
185 + ieee80211_free_hw(hw);
186 + platform_set_drvdata(pdev, NULL);
192 +static struct platform_driver ath_ahb_driver = {
193 + .probe = ath_ahb_probe,
194 + .remove = ath_ahb_remove,
197 + .owner = THIS_MODULE,
201 +int ath_ahb_init(void)
203 + return platform_driver_register(&ath_ahb_driver);
206 +void ath_ahb_exit(void)
208 + platform_driver_register(&ath_ahb_driver);
210 --- a/drivers/net/wireless/ath9k/core.h
211 +++ b/drivers/net/wireless/ath9k/core.h
212 @@ -705,6 +705,7 @@ struct ath_softc {
213 struct tasklet_struct bcon_tasklet;
214 struct ath_hal *sc_ah;
217 spinlock_t sc_resetlock;
220 @@ -782,4 +783,12 @@ static inline int ath_pci_init(void) { r
221 static inline void ath_pci_exit(void) {};
224 +#ifdef CONFIG_ATHEROS_AR71XX
225 +int ath_ahb_init(void);
226 +void ath_ahb_exit(void);
228 +static inline int ath_ahb_init(void) { return 0; };
229 +static inline void ath_ahb_exit(void) {};
233 --- a/drivers/net/wireless/ath9k/main.c
234 +++ b/drivers/net/wireless/ath9k/main.c
235 @@ -2514,8 +2514,17 @@ static int __init ath9k_init(void)
236 goto err_rate_unregister;
239 + error = ath_ahb_init();
251 ath_rate_control_unregister();
253 @@ -2525,6 +2534,7 @@ module_init(ath9k_init);
255 static void __exit ath9k_exit(void)
259 ath_rate_control_unregister();
260 printk(KERN_INFO "%s: Driver unloaded\n", dev_info);