aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/ath9k/Makefile1
-rw-r--r--drivers/net/wireless/ath9k/ahb.c160
-rw-r--r--drivers/net/wireless/ath9k/core.h8
-rw-r--r--drivers/net/wireless/ath9k/main.c10
4 files changed, 179 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath9k/Makefile b/drivers/net/wireless/ath9k/Makefile
index af3f39bbddd..00629587b79 100644
--- a/drivers/net/wireless/ath9k/Makefile
+++ b/drivers/net/wireless/ath9k/Makefile
@@ -12,6 +12,7 @@ ath9k-y += hw.o \
12 rc.o 12 rc.o
13 13
14ath9k-$(CONFIG_PCI) += pci.o 14ath9k-$(CONFIG_PCI) += pci.o
15ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o
15ath9k-$(CONFIG_ATH9K_DEBUG) += debug.o 16ath9k-$(CONFIG_ATH9K_DEBUG) += debug.o
16 17
17obj-$(CONFIG_ATH9K) += ath9k.o 18obj-$(CONFIG_ATH9K) += ath9k.o
diff --git a/drivers/net/wireless/ath9k/ahb.c b/drivers/net/wireless/ath9k/ahb.c
new file mode 100644
index 00000000000..8cbd4c2a7fa
--- /dev/null
+++ b/drivers/net/wireless/ath9k/ahb.c
@@ -0,0 +1,160 @@
1/*
2 * Copyright (c) 2008 Atheros Communications Inc.
3 * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org>
4 * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#include <linux/nl80211.h>
20#include <linux/platform_device.h>
21#include "core.h"
22#include "reg.h"
23#include "hw.h"
24
25/* return bus cachesize in 4B word units */
26static void ath_ahb_read_cachesize(struct ath_softc *sc, int *csz)
27{
28 *csz = L1_CACHE_BYTES >> 2;
29}
30
31static void ath_ahb_cleanup(struct ath_softc *sc)
32{
33 iounmap(sc->mem);
34}
35
36static struct ath_bus_ops ath_ahb_bus_ops = {
37 .read_cachesize = ath_ahb_read_cachesize,
38 .cleanup = ath_ahb_cleanup,
39};
40
41static int ath_ahb_probe(struct platform_device *pdev)
42{
43 void __iomem *mem;
44 struct ath_softc *sc;
45 struct ieee80211_hw *hw;
46 struct resource *res;
47 int irq;
48 int ret = 0;
49 struct ath_hal *ah;
50
51 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
52 if (res == NULL) {
53 dev_err(&pdev->dev, "no memory resource found\n");
54 ret = -ENXIO;
55 goto err_out;
56 }
57
58 mem = ioremap_nocache(res->start, res->end - res->start + 1);
59 if (mem == NULL) {
60 dev_err(&pdev->dev, "ioremap failed\n");
61 ret = -ENOMEM;
62 goto err_out;
63 }
64
65 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
66 if (res == NULL) {
67 dev_err(&pdev->dev, "no IRQ resource found\n");
68 ret = -ENXIO;
69 goto err_iounmap;
70 }
71
72 irq = res->start;
73
74 hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops);
75 if (hw == NULL) {
76 dev_err(&pdev->dev, "no memory for ieee80211_hw\n");
77 ret = -ENOMEM;
78 goto err_iounmap;
79 }
80
81 SET_IEEE80211_DEV(hw, &pdev->dev);
82 platform_set_drvdata(pdev, hw);
83
84 sc = hw->priv;
85 sc->hw = hw;
86 sc->dev = &pdev->dev;
87 sc->mem = mem;
88 sc->bus_ops = &ath_ahb_bus_ops;
89 sc->irq = irq;
90
91 ret = ath_attach(AR5416_AR9100_DEVID, sc);
92 if (ret != 0) {
93 dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret);
94 ret = -ENODEV;
95 goto err_free_hw;
96 }
97
98 ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc);
99 if (ret) {
100 dev_err(&pdev->dev, "request_irq failed, err=%d\n", ret);
101 ret = -EIO;
102 goto err_detach;
103 }
104
105 ah = sc->sc_ah;
106 printk(KERN_INFO
107 "%s: Atheros AR%s MAC/BB Rev:%x, "
108 "AR%s RF Rev:%x, mem=0x%lx, irq=%d\n",
109 wiphy_name(hw->wiphy),
110 ath_mac_bb_name(ah->ah_macVersion),
111 ah->ah_macRev,
112 ath_rf_name((ah->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR)),
113 ah->ah_phyRev,
114 (unsigned long)mem, irq);
115
116 return 0;
117
118 err_detach:
119 ath_detach(sc);
120 err_free_hw:
121 ieee80211_free_hw(hw);
122 platform_set_drvdata(pdev, NULL);
123 err_iounmap:
124 iounmap(mem);
125 err_out:
126 return ret;
127}
128
129static int ath_ahb_remove(struct platform_device *pdev)
130{
131 struct ieee80211_hw *hw = platform_get_drvdata(pdev);
132
133 if (hw) {
134 struct ath_softc *sc = hw->priv;
135
136 ath_cleanup(sc);
137 platform_set_drvdata(pdev, NULL);
138 }
139
140 return 0;
141}
142
143static struct platform_driver ath_ahb_driver = {
144 .probe = ath_ahb_probe,
145 .remove = ath_ahb_remove,
146 .driver = {
147 .name = "ath9k",
148 .owner = THIS_MODULE,
149 },
150};
151
152int ath_ahb_init(void)
153{
154 return platform_driver_register(&ath_ahb_driver);
155}
156
157void ath_ahb_exit(void)
158{
159 platform_driver_unregister(&ath_ahb_driver);
160}
diff --git a/drivers/net/wireless/ath9k/core.h b/drivers/net/wireless/ath9k/core.h
index 1e86a9cbe42..c5dae11d608 100644
--- a/drivers/net/wireless/ath9k/core.h
+++ b/drivers/net/wireless/ath9k/core.h
@@ -784,4 +784,12 @@ static inline int ath_pci_init(void) { return 0; };
784static inline void ath_pci_exit(void) {}; 784static inline void ath_pci_exit(void) {};
785#endif 785#endif
786 786
787#ifdef CONFIG_ATHEROS_AR71XX
788int ath_ahb_init(void);
789void ath_ahb_exit(void);
790#else
791static inline int ath_ahb_init(void) { return 0; };
792static inline void ath_ahb_exit(void) {};
793#endif
794
787#endif /* CORE_H */ 795#endif /* CORE_H */
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 6257790e49d..7f4d1bbaf6c 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -2527,8 +2527,17 @@ static int __init ath9k_init(void)
2527 goto err_rate_unregister; 2527 goto err_rate_unregister;
2528 } 2528 }
2529 2529
2530 error = ath_ahb_init();
2531 if (error < 0) {
2532 error = -ENODEV;
2533 goto err_pci_exit;
2534 }
2535
2530 return 0; 2536 return 0;
2531 2537
2538 err_pci_exit:
2539 ath_pci_exit();
2540
2532 err_rate_unregister: 2541 err_rate_unregister:
2533 ath_rate_control_unregister(); 2542 ath_rate_control_unregister();
2534 err_out: 2543 err_out:
@@ -2538,6 +2547,7 @@ module_init(ath9k_init);
2538 2547
2539static void __exit ath9k_exit(void) 2548static void __exit ath9k_exit(void)
2540{ 2549{
2550 ath_ahb_exit();
2541 ath_pci_exit(); 2551 ath_pci_exit();
2542 ath_rate_control_unregister(); 2552 ath_rate_control_unregister();
2543 printk(KERN_INFO "%s: Driver unloaded\n", dev_info); 2553 printk(KERN_INFO "%s: Driver unloaded\n", dev_info);