1 From 23f9e44a18b5a2dfaa1326aa30dd07e1449e8b5f 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 v3 06/11] ath9k: introduce platform driver for AHB bus support
6 This patch adds the platform_driver itself, and modifies the main driver
9 Changes-licensed-under: ISC
11 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
12 Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
14 drivers/net/wireless/ath9k/Makefile | 1 +
15 drivers/net/wireless/ath9k/ahb.c | 160 +++++++++++++++++++++++++++++++++++
16 drivers/net/wireless/ath9k/core.h | 8 ++
17 drivers/net/wireless/ath9k/main.c | 10 ++
18 4 files changed, 179 insertions(+), 0 deletions(-)
19 create mode 100644 drivers/net/wireless/ath9k/ahb.c
21 --- a/drivers/net/wireless/ath9k/Makefile
22 +++ b/drivers/net/wireless/ath9k/Makefile
23 @@ -12,6 +12,7 @@ ath9k-y += hw.o \
26 ath9k-$(CONFIG_PCI) += pci.o
27 +ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o
28 ath9k-$(CONFIG_ATH9K_DEBUG) += debug.o
30 obj-$(CONFIG_ATH9K) += ath9k.o
32 +++ b/drivers/net/wireless/ath9k/ahb.c
35 + * Copyright (c) 2008 Atheros Communications Inc.
36 + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
37 + * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
39 + * Permission to use, copy, modify, and/or distribute this software for any
40 + * purpose with or without fee is hereby granted, provided that the above
41 + * copyright notice and this permission notice appear in all copies.
43 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
44 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
45 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
46 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
47 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
48 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
49 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52 +#include <linux/nl80211.h>
53 +#include <linux/platform_device.h>
58 +/* return bus cachesize in 4B word units */
59 +static void ath_ahb_read_cachesize(struct ath_softc *sc, int *csz)
61 + *csz = L1_CACHE_BYTES >> 2;
64 +static void ath_ahb_cleanup(struct ath_softc *sc)
69 +static struct ath_bus_ops ath_ahb_bus_ops = {
70 + .read_cachesize = ath_ahb_read_cachesize,
71 + .cleanup = ath_ahb_cleanup,
74 +static int ath_ahb_probe(struct platform_device *pdev)
77 + struct ath_softc *sc;
78 + struct ieee80211_hw *hw;
79 + struct resource *res;
84 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
86 + dev_err(&pdev->dev, "no memory resource found\n");
91 + mem = ioremap_nocache(res->start, res->end - res->start + 1);
93 + dev_err(&pdev->dev, "ioremap failed\n");
98 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
100 + dev_err(&pdev->dev, "no IRQ resource found\n");
107 + hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
109 + dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
114 + SET_IEEE80211_DEV(hw, &pdev->dev);
115 + platform_set_drvdata(pdev, hw);
119 + sc->dev = &pdev->dev;
121 + sc->bus_ops = &ath_ahb_bus_ops;
124 + ret = ath_attach(AR5416_AR9100_DEVID, sc);
126 + dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret);
131 + ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc);
133 + dev_err(&pdev->dev, "request_irq failed, err=%d\n", ret);
140 + "%s: Atheros AR%s MAC/BB Rev:%x, "
141 + "AR%s RF Rev:%x, mem=0x%lx, irq=%d\n",
142 + wiphy_name(hw->wiphy),
143 + ath_mac_bb_name(ah->ah_macVersion),
145 + ath_rf_name((ah->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR)),
147 + (unsigned long)mem, irq);
154 + ieee80211_free_hw(hw);
155 + platform_set_drvdata(pdev, NULL);
162 +static int ath_ahb_remove(struct platform_device *pdev)
164 + struct ieee80211_hw *hw = platform_get_drvdata(pdev);
167 + struct ath_softc *sc = hw->priv;
170 + platform_set_drvdata(pdev, NULL);
176 +static struct platform_driver ath_ahb_driver = {
177 + .probe = ath_ahb_probe,
178 + .remove = ath_ahb_remove,
181 + .owner = THIS_MODULE,
185 +int ath_ahb_init(void)
187 + return platform_driver_register(&ath_ahb_driver);
190 +void ath_ahb_exit(void)
192 + platform_driver_unregister(&ath_ahb_driver);
194 --- a/drivers/net/wireless/ath9k/core.h
195 +++ b/drivers/net/wireless/ath9k/core.h
196 @@ -784,4 +784,12 @@ static inline int ath_pci_init(void) { r
197 static inline void ath_pci_exit(void) {};
200 +#ifdef CONFIG_ATHEROS_AR71XX
201 +int ath_ahb_init(void);
202 +void ath_ahb_exit(void);
204 +static inline int ath_ahb_init(void) { return 0; };
205 +static inline void ath_ahb_exit(void) {};
209 --- a/drivers/net/wireless/ath9k/main.c
210 +++ b/drivers/net/wireless/ath9k/main.c
211 @@ -2531,8 +2531,17 @@ static int __init ath9k_init(void)
212 goto err_rate_unregister;
215 + error = ath_ahb_init();
227 ath_rate_control_unregister();
229 @@ -2542,6 +2551,7 @@ module_init(ath9k_init);
231 static void __exit ath9k_exit(void)
235 ath_rate_control_unregister();
236 printk(KERN_INFO "%s: Driver unloaded\n", dev_info);