aboutsummaryrefslogtreecommitdiffstats
path: root/package/madwifi/patches/109-soc_platform.patch
blob: 2cc338b0513fcfde8a25b1938419597c7a07aaea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
diff -ur madwifi.old/ath/if_ath_ahb.c madwifi.dev/ath/if_ath_ahb.c
--- madwifi.old/ath/if_ath_ahb.c	2006-12-22 03:57:28.000000000 +0100
+++ madwifi.dev/ath/if_ath_ahb.c	2006-12-22 04:09:48.000000000 +0100
@@ -17,6 +17,9 @@
 #include <linux/if.h>
 #include <linux/netdevice.h>
 #include <linux/cache.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+#include <linux/platform_device.h>
+#endif
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -39,6 +42,7 @@
 static struct ath_ahb_softc *sclist[2] = {NULL, NULL};
 static u_int8_t num_activesc = 0;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
 static struct ar531x_boarddata *ar5312_boardConfig = NULL;
 static char *radioConfig = NULL;
 
@@ -136,6 +140,8 @@
 		data[i] = eepromAddr[off];
 }
 
+#endif
+
 /* set bus cachesize in 4B word units */
 void
 bus_read_cachesize(struct ath_softc *sc, u_int8_t *csz)
@@ -180,7 +186,8 @@
 	u_int32_t reset;
 	u_int32_t enable;
 	
-	if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
+	if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
+		((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
 		u_int32_t reg;
 		u_int32_t *en = (u_int32_t *) AR5315_AHB_ARB_CTL;
 		
@@ -241,7 +248,8 @@
 ahb_disable_wmac(u_int16_t devid, u_int16_t wlanNum)
 {
 	u_int32_t enable;
-	if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
+	if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
+		((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
 		u_int32_t *en = (u_int32_t *) AR5315_AHB_ARB_CTL;
 
 		KASSERT(wlanNum == 0, ("invalid wlan # %d", wlanNum) ); 
@@ -295,7 +303,7 @@
 }
 
 int
-init_ath_wmac(u_int16_t devid, u_int16_t wlanNum)
+init_ath_wmac(u_int16_t devid, u_int16_t wlanNum, struct ar531x_config *config)
 {
 	const char *athname;
 	struct net_device *dev;
@@ -329,7 +337,8 @@
 
 	switch (wlanNum) {
 	case AR531X_WLAN0_NUM:
-		if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) {
+		if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
+			((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ)) {
 			dev->irq = AR5315_IRQ_WLAN0_INTRS;
 			dev->mem_start = AR5315_WLAN0;
 		} else {
@@ -352,12 +361,7 @@
 		goto bad3;
 	}
 	
-	struct ar531x_config config;
-	config.board = ar5312_boardConfig;
-	config.radio = radioConfig;
-	config.unit = wlanNum;
-	config.tag = NULL;
-	if (ath_attach(devid, dev, &config) != 0)
+	if (ath_attach(devid, dev, config) != 0)
 		goto bad4;
 	athname = ath_hal_probe(ATHEROS_VENDOR_ID, devid);
 	printk(KERN_INFO "%s: %s: mem=0x%lx, irq=%d\n",
@@ -379,24 +383,63 @@
 	return -ENODEV;
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+static int ahb_wmac_probe(struct platform_device *pdev)
+{
+	u32 devid;
+	struct ar531x_config *config;
+
+	config = (struct ar531x_config *) pdev->dev.platform_data;
+	devid = (u32) config->tag;
+	config->tag = NULL;
+	
+	return init_ath_wmac((u_int16_t) devid, pdev->id, config);
+}
+
+
+static int ahb_wmac_remove(struct platform_device *pdev)
+{
+	exit_ath_wmac(pdev->id);
+
+	return 0;
+}
+
+struct platform_driver ahb_wmac_driver = {
+	.driver.name = "ar531x-wmac",
+	.probe = ahb_wmac_probe,
+	.remove = ahb_wmac_remove
+};
+
+#else
+
 int
 init_ahb(void)
 {
 	int ret;
 	u_int16_t devid, radioMask;
 	const char *sysType;
+	struct ar531x_config config;
+	
 	sysType = get_system_type();
+	
+	/* Probe to find out the silicon revision and enable the
+	   correct number of macs */
+	if (!ar5312SetupFlash())
+		return -ENODEV;
+
+	config.board = ar5312_boardConfig;
+	config.radio = radioConfig;
+	config.unit = wlanNum;
+	config.tag = NULL;
+
 	if (!strcmp(sysType,"Atheros AR5315")) {
 		devid = (u_int16_t) (sysRegRead(AR5315_SREV) &
 			(AR5315_REV_MAJ_M | AR5315_REV_MIN_M));
-		if ((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ)
+		if (((devid & AR5315_REV_MAJ_M) == AR5315_REV_MAJ) ||
+			((devid & AR5315_REV_MAJ_M) == AR5317_REV_MAJ))
 			return init_ath_wmac(devid, 0);
 	}
 
-	/* Probe to find out the silicon revision and enable the
-	   correct number of macs */
-	if (!ar5312SetupFlash())
-		return -ENODEV;
 	devid = (u_int16_t) ((sysRegRead(AR531X_REV) >>8) &
 		(AR531X_REV_MAJ | AR531X_REV_MIN));
 	switch (devid) {
@@ -420,6 +463,7 @@
 	return 0;
 }
 
+#endif
 
 /*
  * Module glue.
@@ -460,13 +504,19 @@
 {
 	printk(KERN_INFO "%s: %s\n", dev_info, version);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+	platform_driver_register(&ahb_wmac_driver);
+#else
 	if (init_ahb() != 0) {
 		printk("ath_ahb: No devices found, driver not installed.\n");
 		return (-ENODEV);
 	}
+#endif
+
 #ifdef CONFIG_SYSCTL
 	ath_sysctl_register();
 #endif
+
 	return 0;
 }
 module_init(init_ath_ahb);
@@ -477,8 +527,13 @@
 #ifdef CONFIG_SYSCTL
 	ath_sysctl_unregister();
 #endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
+	platform_driver_register(&ahb_wmac_driver);
+#else
 	exit_ath_wmac(AR531X_WLAN0_NUM);
 	exit_ath_wmac(AR531X_WLAN1_NUM);
+#endif
 
 	printk(KERN_INFO "%s: driver unloaded\n", dev_info);
 }
diff -ur madwifi.old/ath/if_ath_ahb.h madwifi.dev/ath/if_ath_ahb.h
--- madwifi.old/ath/if_ath_ahb.h	2006-12-22 03:57:28.000000000 +0100
+++ madwifi.dev/ath/if_ath_ahb.h	2006-12-22 04:07:47.000000000 +0100
@@ -59,6 +59,7 @@
 #define AR5315_SREV		0xb1000014
 
 #define AR5315_REV_MAJ		0x0080
+#define AR5317_REV_MAJ		0x0090
 #define AR5315_REV_MAJ_M	0x00f0
 #define AR5315_REV_MAJ_S	4
 #define AR5315_REV_MIN_M	0x000f
diff -urN madwifi-0.9.2.old/ath/if_ath.c madwifi-0.9.2.dev/ath/if_ath.c
--- madwifi-0.9.2.old/ath/if_ath.c	2006-08-29 20:38:48.000000000 +0200
+++ madwifi-0.9.2.dev/ath/if_ath.c	2006-08-29 20:38:48.000000000 +0200
@@ -658,7 +658,10 @@
 	 * 5211 minipci cards.  Users can also manually enable/disable
 	 * support with a sysctl.
 	 */
-	sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID);
+	sc->sc_softled = ((devid == AR5212_DEVID_IBM) || (devid == AR5211_DEVID) ||
+		(devid == AR5212_AR2315_REV6) || (devid == AR5212_AR2315_REV7) ||
+		(devid == AR5212_AR2317_REV1) || (devid == AR5212_AR2317_REV2));
+
 	if (sc->sc_softled) {
 		ath_hal_gpioCfgOutput(ah, sc->sc_ledpin);
 		ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon);
diff -urN madwifi-0.9.2.old/hal/ah_devid.h madwifi-0.9.2.dev/hal/ah_devid.h
--- madwifi-0.9.2.old/hal/ah_devid.h	2006-02-11 13:04:39.000000000 +0100
+++ madwifi-0.9.2.dev/hal/ah_devid.h	2006-08-29 20:38:48.000000000 +0200
@@ -68,9 +68,10 @@
 #define AR5212_AR5312_REV2      0x0052          /* AR5312 WMAC (AP31) */
 #define AR5212_AR5312_REV7      0x0057          /* AR5312 WMAC (AP30-040) */
 #define AR5212_AR2313_REV8      0x0058          /* AR2313 WMAC (AP43-030) */
-#define AR5212_AR2315_REV6      0x0086          /* AR2315 WMAC (AP51-Light) */
+#define AR5212_AR2315_REV6      0x0086          /* AR2315 WMAC (AP51-Lite) */
 #define AR5212_AR2315_REV7      0x0087          /* AR2315 WMAC (AP51-Full) */
-#define AR5212_AR2317_REV1      0x0091          /* AR2317 WMAC (AP61) */
+#define AR5212_AR2317_REV1      0x0090          /* AR2317 WMAC (AP61-Lite) */
+#define AR5212_AR2317_REV2      0x0091          /* AR2317 WMAC (AP61-Full) */
 
 /* AR5212 compatible devid's also attach to 5212 */
 #define	AR5212_DEVID_0014	0x0014