add SoC support to madwifi
[openwrt/svn-archive/archive.git] / package / madwifi / patches / 109-soc_platform.patch
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 2006-12-16 00:57:08.000000000 +0100
3 +++ madwifi.dev/ath/if_ath_ahb.c 2006-12-16 01:29:38.000000000 +0100
4 @@ -17,6 +17,9 @@
5 #include <linux/if.h>
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>
10 +#endif
11
12 #include <asm/io.h>
13 #include <asm/uaccess.h>
14 @@ -39,6 +42,7 @@
15 static struct ath_ahb_softc *sclist[2] = {NULL, NULL};
16 static u_int8_t num_activesc = 0;
17
18 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
19 static struct ar531x_boarddata *ar5312_boardConfig = NULL;
20 static char *radioConfig = NULL;
21
22 @@ -136,6 +140,8 @@
23 data[i] = eepromAddr[off];
24 }
25
26 +#endif
27 +
28 /* set bus cachesize in 4B word units */
29 void
30 bus_read_cachesize(struct ath_softc *sc, u_int8_t *csz)
31 @@ -295,7 +301,7 @@
32 }
33
34 int
35 -init_ath_wmac(u_int16_t devid, u_int16_t wlanNum)
36 +init_ath_wmac(u_int16_t devid, u_int16_t wlanNum, struct ar531x_config *config)
37 {
38 const char *athname;
39 struct net_device *dev;
40 @@ -352,12 +358,7 @@
41 goto bad3;
42 }
43
44 - struct ar531x_config config;
45 - config.board = ar5312_boardConfig;
46 - config.radio = radioConfig;
47 - config.unit = wlanNum;
48 - config.tag = NULL;
49 - if (ath_attach(devid, dev, &config) != 0)
50 + if (ath_attach(devid, dev, config) != 0)
51 goto bad4;
52 athname = ath_hal_probe(ATHEROS_VENDOR_ID, devid);
53 printk(KERN_INFO "%s: %s: mem=0x%lx, irq=%d\n",
54 @@ -379,13 +380,55 @@
55 return -ENODEV;
56 }
57
58 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
59 +static int ahb_wmac_probe(struct platform_device *pdev)
60 +{
61 + u32 devid;
62 + struct ar531x_config *config;
63 +
64 + config = (struct ar531x_config *) pdev->dev.platform_data;
65 + devid = (u32) config->tag;
66 + config->tag = NULL;
67 +
68 + return init_ath_wmac((u_int16_t) devid, pdev->id, config);
69 +}
70 +
71 +
72 +static int ahb_wmac_remove(struct platform_device *pdev)
73 +{
74 + exit_ath_wmac(pdev->id);
75 +
76 + return 0;
77 +}
78 +
79 +struct platform_driver ahb_wmac_driver = {
80 + .driver.name = "ar531x-wmac",
81 + .probe = ahb_wmac_probe,
82 + .remove = ahb_wmac_remove
83 +};
84 +
85 +#else
86 +
87 int
88 init_ahb(void)
89 {
90 int ret;
91 u_int16_t devid, radioMask;
92 const char *sysType;
93 + struct ar531x_config config;
94 +
95 sysType = get_system_type();
96 +
97 + /* Probe to find out the silicon revision and enable the
98 + correct number of macs */
99 + if (!ar5312SetupFlash())
100 + return -ENODEV;
101 +
102 + config.board = ar5312_boardConfig;
103 + config.radio = radioConfig;
104 + config.unit = wlanNum;
105 + config.tag = NULL;
106 +
107 if (!strcmp(sysType,"Atheros AR5315")) {
108 devid = (u_int16_t) (sysRegRead(AR5315_SREV) &
109 (AR5315_REV_MAJ_M | AR5315_REV_MIN_M));
110 @@ -393,10 +436,6 @@
111 return init_ath_wmac(devid, 0);
112 }
113
114 - /* Probe to find out the silicon revision and enable the
115 - correct number of macs */
116 - if (!ar5312SetupFlash())
117 - return -ENODEV;
118 devid = (u_int16_t) ((sysRegRead(AR531X_REV) >>8) &
119 (AR531X_REV_MAJ | AR531X_REV_MIN));
120 switch (devid) {
121 @@ -420,6 +459,7 @@
122 return 0;
123 }
124
125 +#endif
126
127 /*
128 * Module glue.
129 @@ -460,13 +500,19 @@
130 {
131 printk(KERN_INFO "%s: %s\n", dev_info, version);
132
133 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
134 + platform_driver_register(&ahb_wmac_driver);
135 +#else
136 if (init_ahb() != 0) {
137 printk("ath_ahb: No devices found, driver not installed.\n");
138 return (-ENODEV);
139 }
140 +#endif
141 +
142 #ifdef CONFIG_SYSCTL
143 ath_sysctl_register();
144 #endif
145 +
146 return 0;
147 }
148 module_init(init_ath_ahb);
149 @@ -477,8 +523,13 @@
150 #ifdef CONFIG_SYSCTL
151 ath_sysctl_unregister();
152 #endif
153 +
154 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
155 + platform_driver_register(&ahb_wmac_driver);
156 +#else
157 exit_ath_wmac(AR531X_WLAN0_NUM);
158 exit_ath_wmac(AR531X_WLAN1_NUM);
159 +#endif
160
161 printk(KERN_INFO "%s: driver unloaded\n", dev_info);
162 }