4 #include "if_ath_ahb.h"
7 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
8 -#error "Kernel versions older than 2.6.19 are not supported!"
9 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
10 +#include <ar231x_platform.h>
13 struct ath_ahb_softc {
14 struct ath_softc aps_sc;
16 - u32 aps_pmstate[16];
18 + struct ar531x_config aps_config;
21 -static struct ath_ahb_softc *sclist[2] = {NULL, NULL};
22 -static u_int8_t num_activesc = 0;
27 @@ -101,13 +96,13 @@ ahb_enable_wmac(u_int16_t devid, u_int16
28 while (REG_READ(AR5315_PCI_MAC_PCICFG) & AR5315_PCI_MAC_PCICFG_SPWR_DN);
31 - case AR531X_WLAN0_NUM:
33 reset = (AR531X_RESET_WLAN0 |
34 AR531X_RESET_WARM_WLAN0_MAC |
35 AR531X_RESET_WARM_WLAN0_BB);
36 enable = AR531X_ENABLE_WLAN0;
38 - case AR531X_WLAN1_NUM:
40 reset = (AR531X_RESET_WLAN1 |
41 AR531X_RESET_WARM_WLAN1_MAC |
42 AR531X_RESET_WARM_WLAN1_BB);
43 @@ -144,10 +139,10 @@ ahb_disable_wmac(u_int16_t devid, u_int1
44 *en &= ~AR5315_ARB_WLAN;
47 - case AR531X_WLAN0_NUM:
49 enable = AR531X_ENABLE_WLAN0;
51 - case AR531X_WLAN1_NUM:
53 enable = AR531X_ENABLE_WLAN1;
56 @@ -159,29 +154,6 @@ ahb_disable_wmac(u_int16_t devid, u_int1
61 -exit_ath_wmac(u_int16_t wlanNum, struct ar531x_config *config)
63 - struct ath_ahb_softc *sc = sclist[wlanNum];
64 - struct net_device *dev;
68 - return -ENODEV; /* XXX: correct return value? */
70 - dev = sc->aps_sc.sc_dev;
73 - free_irq(dev->irq, dev);
74 - devid = sc->aps_sc.devid;
75 - config->tag = (void *)((unsigned long) devid);
77 - ahb_disable_wmac(devid, wlanNum);
79 - sclist[wlanNum] = NULL;
83 static const char ubnt[] = "Ubiquiti Networks";
84 static const struct ath_hw_detect cards[] = {
86 @@ -266,6 +238,114 @@ static const struct ath_hw_detect cards[
91 +ahb_hw_detect(struct ath_ahb_softc *sc, const char *radio)
93 + u16 *radio_data = (u16 *) radio;
95 + u16 vendor, id, subvendor, subid;
96 + vendor = radio_data[1];
98 + subvendor = radio_data[8];
99 + subid = radio_data[7];
100 + ath_hw_detect(&sc->aps_sc, cards, ARRAY_SIZE(cards), vendor, id, subvendor, subid);
104 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
106 +static int ahb_wmac_probe(struct platform_device *pdev)
108 + struct ar231x_board_config *bcfg = pdev->dev.platform_data;
109 + struct ath_ahb_softc *sc;
110 + struct net_device *dev;
111 + struct resource *res;
112 + const char *athname;
115 + ahb_enable_wmac(bcfg->devid, pdev->id);
116 + dev = alloc_netdev(sizeof(struct ath_ahb_softc), "wifi%d", ether_setup);
121 + sc->aps_sc.sc_dev = dev;
123 + dev->irq = platform_get_irq(pdev, 0);
124 + if (dev->irq <= 0) {
125 + printk("%s: Cannot find IRQ resource\n", dev->name);
129 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
131 + printk("%s: Cannot find MMIO resource\n", dev->name);
135 + dev->mem_start = KSEG1ADDR(res->start);
136 + dev->mem_end = KSEG1ADDR(res->end);
137 + sc->aps_sc.sc_iobase = (void __iomem *) dev->mem_start;
138 + sc->aps_sc.sc_bdev = NULL;
140 + /* bus information for the HAL */
141 + sc->aps_config.board = (const struct ar531x_boarddata *) bcfg->config;
142 + sc->aps_config.radio = bcfg->radio;
143 + sc->aps_config.unit = pdev->id;
144 + sc->aps_config.tag = NULL;
146 + err = ath_attach(bcfg->devid, dev, &sc->aps_config);
148 + printk("%s: ath_attach failed: %d\n", dev->name, err);
152 + athname = ath_hal_probe(ATHEROS_VENDOR_ID, bcfg->devid);
153 + printk(KERN_INFO "%s: %s: %s: mem=0x%lx, irq=%d\n",
154 + dev_info, dev->name, athname ? athname : "Atheros ???", dev->mem_start, dev->irq);
156 + if (request_irq(dev->irq, ath_intr, IRQF_SHARED|IRQF_DISABLED, dev->name, dev)) {
157 + printk(KERN_WARNING "%s: %s: request_irq failed\n", dev_info, dev->name);
161 + sc->aps_sc.sc_softled = 1; /* SoftLED over GPIO */
162 + sc->aps_sc.sc_ledpin = bcfg->config->sysLedGpio;
163 + sc->aps_sc.sc_invalid = 0;
164 + ahb_hw_detect(sc, bcfg->radio);
165 + platform_set_drvdata(pdev, dev);
169 + free_irq(dev->irq, dev);
177 +static int ahb_wmac_remove(struct platform_device *pdev)
179 + struct ar231x_board_config *bcfg = pdev->dev.platform_data;
180 + struct net_device *dev;
182 + dev = platform_get_drvdata(pdev);
186 + free_irq(dev->irq, dev);
188 + ahb_disable_wmac(bcfg->devid, pdev->id);
196 +static struct ath_ahb_softc *sclist[2] = {NULL, NULL};
199 init_ath_wmac(u_int16_t devid, u_int16_t wlanNum, struct ar531x_config *config)
201 @@ -318,7 +398,7 @@ init_ath_wmac(u_int16_t devid, u_int16_t
202 sc->aps_sc.sc_iobase = (void __iomem *) dev->mem_start;
203 sc->aps_sc.sc_bdev = NULL;
205 - if (request_irq(dev->irq, ath_intr, IRQF_SHARED, dev->name, dev)) {
206 + if (request_irq(dev->irq, ath_intr, IRQF_SHARED|IRQF_DISABLED, dev->name, dev)) {
207 printk(KERN_WARNING "%s: %s: request_irq failed\n", dev_info, dev->name);
210 @@ -328,21 +408,12 @@ init_ath_wmac(u_int16_t devid, u_int16_t
211 athname = ath_hal_probe(ATHEROS_VENDOR_ID, devid);
212 printk(KERN_INFO "%s: %s: %s: mem=0x%lx, irq=%d\n",
213 dev_info, dev->name, athname ? athname : "Atheros ???", dev->mem_start, dev->irq);
215 /* Ready to process interrupts */
217 sc->aps_sc.sc_softled = 1; /* SoftLED over GPIO */
218 sc->aps_sc.sc_ledpin = config->board->sysLedGpio;
219 sc->aps_sc.sc_invalid = 0;
220 - radio_data = (u16 *) config->radio;
222 - u16 vendor, id, subvendor, subid;
223 - vendor = radio_data[1];
224 - id = radio_data[0];
225 - subvendor = radio_data[8];
226 - subid = radio_data[7];
227 - ath_hw_detect(&sc->aps_sc, cards, ARRAY_SIZE(cards), vendor, id, subvendor, subid);
229 + ahb_hw_detect(sc, config->radio);
233 @@ -357,6 +428,29 @@ init_ath_wmac(u_int16_t devid, u_int16_t
238 +exit_ath_wmac(u_int16_t wlanNum, struct ar531x_config *config)
240 + struct ath_ahb_softc *sc = sclist[wlanNum];
241 + struct net_device *dev;
245 + return -ENODEV; /* XXX: correct return value? */
247 + dev = sc->aps_sc.sc_dev;
250 + free_irq(dev->irq, dev);
251 + devid = sc->aps_sc.devid;
252 + config->tag = (void *)((unsigned long) devid);
254 + ahb_disable_wmac(devid, wlanNum);
256 + sclist[wlanNum] = NULL;
260 static int ahb_wmac_probe(struct platform_device *pdev)
263 @@ -377,11 +471,18 @@ static int ahb_wmac_remove(struct platfo
269 static struct platform_driver ahb_wmac_driver = {
270 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
271 + .driver.name = "ar231x-wmac",
273 .driver.name = "ar531x-wmac",
275 .probe = ahb_wmac_probe,
276 .remove = ahb_wmac_remove
280 ath_ioctl_ethtool(struct ath_softc *sc, int cmd, void __user *addr)