1 diff -ur madwifi.old/ath/if_ath_ahb.c madwifi.dev/ath/if_ath_ahb.c
2 --- madwifi.old/ath/if_ath_ahb.c 2007-02-04 04:07:15.810701232 +0100
3 +++ madwifi.dev/ath/if_ath_ahb.c 2007-02-04 04:14:02.699844680 +0100
6 #include <linux/netdevice.h>
7 #include <linux/cache.h>
8 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
9 +#include <linux/platform_device.h>
13 #include <asm/uaccess.h>
15 static struct ath_ahb_softc *sclist[2] = {NULL, NULL};
16 static u_int8_t num_activesc = 0;
18 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
19 static struct ar531x_boarddata *ar5312_boardConfig = NULL;
20 static char *radioConfig = NULL;
23 data[i] = eepromAddr[off];
28 /* set bus cachesize in 4B word units */
30 bus_read_cachesize(struct ath_softc *sc, u_int8_t *csz)
35 - if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
36 + if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
37 + ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
39 u_int32_t *en = (u_int32_t *) AR5315_AHB_ARB_CTL;
42 ahb_disable_wmac(u_int16_t devid, u_int16_t wlanNum)
45 - if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
46 + if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
47 + ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
48 u_int32_t *en = (u_int32_t *) AR5315_AHB_ARB_CTL;
50 KASSERT(wlanNum == 0, ("invalid wlan # %d", wlanNum) );
57 -exit_ath_wmac(u_int16_t wlanNum)
58 +exit_ath_wmac(u_int16_t wlanNum, struct ar531x_config *config)
60 struct ath_ahb_softc *sc = sclist[wlanNum];
61 struct net_device *dev;
62 - const char *sysType;
69 free_irq(dev->irq, dev);
70 - sysType = get_system_type();
71 - if (!strcmp(sysType, "Atheros AR5315"))
73 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
74 + devid = (u32) config->tag;
76 + if (!strcmp(get_system_type(), "Atheros AR5315"))
77 devid = (u_int16_t) (sysRegRead(AR5315_SREV) &
78 (AR5315_REV_MAJ_M | AR5315_REV_MIN_M));
80 devid = (u_int16_t) ((sysRegRead(AR531X_REV) >> 8) &
81 (AR531X_REV_MAJ | AR531X_REV_MIN));
84 ahb_disable_wmac(devid, wlanNum);
90 -init_ath_wmac(u_int16_t devid, u_int16_t wlanNum)
91 +init_ath_wmac(u_int16_t devid, u_int16_t wlanNum, struct ar531x_config *config)
94 struct net_device *dev;
98 case AR531X_WLAN0_NUM:
99 - if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
100 + if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
101 + ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
102 dev->irq = AR5315_IRQ_WLAN0_INTRS;
103 dev->mem_start = AR5315_WLAN0;
109 - struct ar531x_config config;
110 - config.board = ar5312_boardConfig;
111 - config.radio = radioConfig;
112 - config.unit = wlanNum;
114 - if (ath_attach(devid, dev, &config) != 0)
115 + if (ath_attach(devid, dev, config) != 0)
117 athname = ath_hal_probe(ATHEROS_VENDOR_ID, devid);
118 printk(KERN_INFO "%s: %s: mem=0x%lx, irq=%d\n",
119 @@ -379,24 +387,63 @@
123 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
124 +static int ahb_wmac_probe(struct platform_device *pdev)
127 + struct ar531x_config *config;
129 + config = (struct ar531x_config *) pdev->dev.platform_data;
130 + devid = (u32) config->tag;
131 + config->tag = NULL;
133 + return init_ath_wmac((u_int16_t) devid, pdev->id, config);
137 +static int ahb_wmac_remove(struct platform_device *pdev)
139 + exit_ath_wmac(pdev->id, (struct ar531x_config *) pdev->dev.platform_data);
144 +struct platform_driver ahb_wmac_driver = {
145 + .driver.name = "ar531x-wmac",
146 + .probe = ahb_wmac_probe,
147 + .remove = ahb_wmac_remove
156 u_int16_t devid, radioMask;
158 + struct ar531x_config config;
160 sysType = get_system_type();
162 + /* Probe to find out the silicon revision and enable the
163 + correct number of macs */
164 + if (!ar5312SetupFlash())
167 + config.board = ar5312_boardConfig;
168 + config.radio = radioConfig;
169 + config.unit = wlanNum;
172 if (!strcmp(sysType,"Atheros AR5315")) {
173 devid = (u_int16_t) (sysRegRead(AR5315_SREV) &
174 (AR5315_REV_MAJ_M | AR5315_REV_MIN_M));
175 - if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ)
176 + if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
177 + ((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ))
178 return init_ath_wmac(devid, 0);
181 - /* Probe to find out the silicon revision and enable the
182 - correct number of macs */
183 - if (!ar5312SetupFlash())
185 devid = (u_int16_t) ((sysRegRead(AR531X_REV) >>8) &
186 (AR531X_REV_MAJ | AR531X_REV_MIN));
196 @@ -460,13 +508,19 @@
198 printk(KERN_INFO "%s: %s\n", dev_info, version);
200 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
201 + platform_driver_register(&ahb_wmac_driver);
203 if (init_ahb() != 0) {
204 printk("ath_ahb: No devices found, driver not installed.\n");
210 ath_sysctl_register();
215 module_init(init_ath_ahb);
218 ath_sysctl_unregister();
221 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
222 + platform_driver_unregister(&ahb_wmac_driver);
224 exit_ath_wmac(AR531X_WLAN0_NUM);
225 exit_ath_wmac(AR531X_WLAN1_NUM);
228 printk(KERN_INFO "%s: driver unloaded\n", dev_info);
230 diff -ur madwifi.old/ath/if_ath_ahb.h madwifi.dev/ath/if_ath_ahb.h
231 --- madwifi.old/ath/if_ath_ahb.h 2007-02-04 04:07:15.810701232 +0100
232 +++ madwifi.dev/ath/if_ath_ahb.h 2007-02-04 04:06:49.070766320 +0100
234 #define AR5315_SREV 0xb1000014
236 #define AR5315_REV_MAJ 0x0080
237 +#define AR5317_REV_MAJ 0x0090
238 #define AR5315_REV_MAJ_M 0x00f0
239 #define AR5315_REV_MAJ_S 4
240 #define AR5315_REV_MIN_M 0x000f