diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_io.h | 8 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_main.c | 191 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_spi.c | 180 |
3 files changed, 193 insertions, 186 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_io.h b/drivers/net/wireless/wl12xx/wl1271_io.h index fa9a0b35788f..38fce4caf4a1 100644 --- a/drivers/net/wireless/wl12xx/wl1271_io.h +++ b/drivers/net/wireless/wl12xx/wl1271_io.h | |||
@@ -65,4 +65,12 @@ static inline void wl1271_raw_write32(struct wl1271 *wl, int addr, u32 val) | |||
65 | wl1271_raw_write(wl, addr, &wl->buffer_32, | 65 | wl1271_raw_write(wl, addr, &wl->buffer_32, |
66 | sizeof(wl->buffer_32), false); | 66 | sizeof(wl->buffer_32), false); |
67 | } | 67 | } |
68 | |||
69 | /* Functions from wl1271_main.c */ | ||
70 | |||
71 | int wl1271_register_hw(struct wl1271 *wl); | ||
72 | int wl1271_init_ieee80211(struct wl1271 *wl); | ||
73 | struct ieee80211_hw *wl1271_alloc_hw(void); | ||
74 | int wl1271_free_hw(struct wl1271 *wl); | ||
75 | |||
68 | #endif | 76 | #endif |
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c index 2a864b24291d..66319aabf263 100644 --- a/drivers/net/wireless/wl12xx/wl1271_main.c +++ b/drivers/net/wireless/wl12xx/wl1271_main.c | |||
@@ -22,16 +22,12 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/platform_device.h> | ||
26 | #include <linux/interrupt.h> | ||
27 | #include <linux/firmware.h> | 25 | #include <linux/firmware.h> |
28 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
29 | #include <linux/irq.h> | ||
30 | #include <linux/spi/spi.h> | 27 | #include <linux/spi/spi.h> |
31 | #include <linux/crc32.h> | 28 | #include <linux/crc32.h> |
32 | #include <linux/etherdevice.h> | 29 | #include <linux/etherdevice.h> |
33 | #include <linux/vmalloc.h> | 30 | #include <linux/vmalloc.h> |
34 | #include <linux/spi/wl12xx.h> | ||
35 | #include <linux/inetdevice.h> | 31 | #include <linux/inetdevice.h> |
36 | 32 | ||
37 | #include "wl1271.h" | 33 | #include "wl1271.h" |
@@ -484,28 +480,6 @@ out: | |||
484 | mutex_unlock(&wl->mutex); | 480 | mutex_unlock(&wl->mutex); |
485 | } | 481 | } |
486 | 482 | ||
487 | static irqreturn_t wl1271_irq(int irq, void *cookie) | ||
488 | { | ||
489 | struct wl1271 *wl; | ||
490 | unsigned long flags; | ||
491 | |||
492 | wl1271_debug(DEBUG_IRQ, "IRQ"); | ||
493 | |||
494 | wl = cookie; | ||
495 | |||
496 | /* complete the ELP completion */ | ||
497 | spin_lock_irqsave(&wl->wl_lock, flags); | ||
498 | if (wl->elp_compl) { | ||
499 | complete(wl->elp_compl); | ||
500 | wl->elp_compl = NULL; | ||
501 | } | ||
502 | |||
503 | ieee80211_queue_work(wl->hw, &wl->irq_work); | ||
504 | spin_unlock_irqrestore(&wl->wl_lock, flags); | ||
505 | |||
506 | return IRQ_HANDLED; | ||
507 | } | ||
508 | |||
509 | static int wl1271_fetch_firmware(struct wl1271 *wl) | 483 | static int wl1271_fetch_firmware(struct wl1271 *wl) |
510 | { | 484 | { |
511 | const struct firmware *fw; | 485 | const struct firmware *fw; |
@@ -1959,7 +1933,7 @@ static const struct ieee80211_ops wl1271_ops = { | |||
1959 | CFG80211_TESTMODE_CMD(wl1271_tm_cmd) | 1933 | CFG80211_TESTMODE_CMD(wl1271_tm_cmd) |
1960 | }; | 1934 | }; |
1961 | 1935 | ||
1962 | static int wl1271_register_hw(struct wl1271 *wl) | 1936 | int wl1271_register_hw(struct wl1271 *wl) |
1963 | { | 1937 | { |
1964 | int ret; | 1938 | int ret; |
1965 | 1939 | ||
@@ -1981,7 +1955,7 @@ static int wl1271_register_hw(struct wl1271 *wl) | |||
1981 | return 0; | 1955 | return 0; |
1982 | } | 1956 | } |
1983 | 1957 | ||
1984 | static int wl1271_init_ieee80211(struct wl1271 *wl) | 1958 | int wl1271_init_ieee80211(struct wl1271 *wl) |
1985 | { | 1959 | { |
1986 | /* The tx descriptor buffer and the TKIP space. */ | 1960 | /* The tx descriptor buffer and the TKIP space. */ |
1987 | wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE + | 1961 | wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE + |
@@ -2009,24 +1983,9 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) | |||
2009 | return 0; | 1983 | return 0; |
2010 | } | 1984 | } |
2011 | 1985 | ||
2012 | static void wl1271_device_release(struct device *dev) | ||
2013 | { | ||
2014 | |||
2015 | } | ||
2016 | |||
2017 | static struct platform_device wl1271_device = { | ||
2018 | .name = "wl1271", | ||
2019 | .id = -1, | ||
2020 | |||
2021 | /* device model insists to have a release function */ | ||
2022 | .dev = { | ||
2023 | .release = wl1271_device_release, | ||
2024 | }, | ||
2025 | }; | ||
2026 | |||
2027 | #define WL1271_DEFAULT_CHANNEL 0 | 1986 | #define WL1271_DEFAULT_CHANNEL 0 |
2028 | 1987 | ||
2029 | static struct ieee80211_hw *wl1271_alloc_hw(void) | 1988 | struct ieee80211_hw *wl1271_alloc_hw(void) |
2030 | { | 1989 | { |
2031 | struct ieee80211_hw *hw; | 1990 | struct ieee80211_hw *hw; |
2032 | struct wl1271 *wl; | 1991 | struct wl1271 *wl; |
@@ -2073,6 +2032,8 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) | |||
2073 | /* Apply default driver configuration. */ | 2032 | /* Apply default driver configuration. */ |
2074 | wl1271_conf_init(wl); | 2033 | wl1271_conf_init(wl); |
2075 | 2034 | ||
2035 | wl1271_debugfs_init(wl); | ||
2036 | |||
2076 | return hw; | 2037 | return hw; |
2077 | } | 2038 | } |
2078 | 2039 | ||
@@ -2095,145 +2056,3 @@ int wl1271_free_hw(struct wl1271 *wl) | |||
2095 | 2056 | ||
2096 | return 0; | 2057 | return 0; |
2097 | } | 2058 | } |
2098 | |||
2099 | static int __devinit wl1271_probe(struct spi_device *spi) | ||
2100 | { | ||
2101 | struct wl12xx_platform_data *pdata; | ||
2102 | struct ieee80211_hw *hw; | ||
2103 | struct wl1271 *wl; | ||
2104 | int ret; | ||
2105 | |||
2106 | pdata = spi->dev.platform_data; | ||
2107 | if (!pdata) { | ||
2108 | wl1271_error("no platform data"); | ||
2109 | return -ENODEV; | ||
2110 | } | ||
2111 | |||
2112 | hw = wl1271_alloc_hw(); | ||
2113 | if (IS_ERR(hw)) | ||
2114 | return PTR_ERR(hw); | ||
2115 | |||
2116 | wl = hw->priv; | ||
2117 | |||
2118 | dev_set_drvdata(&spi->dev, wl); | ||
2119 | wl->spi = spi; | ||
2120 | |||
2121 | /* This is the only SPI value that we need to set here, the rest | ||
2122 | * comes from the board-peripherals file */ | ||
2123 | spi->bits_per_word = 32; | ||
2124 | |||
2125 | ret = spi_setup(spi); | ||
2126 | if (ret < 0) { | ||
2127 | wl1271_error("spi_setup failed"); | ||
2128 | goto out_free; | ||
2129 | } | ||
2130 | |||
2131 | wl->set_power = pdata->set_power; | ||
2132 | if (!wl->set_power) { | ||
2133 | wl1271_error("set power function missing in platform data"); | ||
2134 | ret = -ENODEV; | ||
2135 | goto out_free; | ||
2136 | } | ||
2137 | |||
2138 | wl->irq = spi->irq; | ||
2139 | if (wl->irq < 0) { | ||
2140 | wl1271_error("irq missing in platform data"); | ||
2141 | ret = -ENODEV; | ||
2142 | goto out_free; | ||
2143 | } | ||
2144 | |||
2145 | ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl); | ||
2146 | if (ret < 0) { | ||
2147 | wl1271_error("request_irq() failed: %d", ret); | ||
2148 | goto out_free; | ||
2149 | } | ||
2150 | |||
2151 | set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); | ||
2152 | |||
2153 | disable_irq(wl->irq); | ||
2154 | |||
2155 | ret = platform_device_register(&wl1271_device); | ||
2156 | if (ret) { | ||
2157 | wl1271_error("couldn't register platform device"); | ||
2158 | goto out_irq; | ||
2159 | } | ||
2160 | dev_set_drvdata(&wl1271_device.dev, wl); | ||
2161 | |||
2162 | ret = wl1271_init_ieee80211(wl); | ||
2163 | if (ret) | ||
2164 | goto out_platform; | ||
2165 | |||
2166 | ret = wl1271_register_hw(wl); | ||
2167 | if (ret) | ||
2168 | goto out_platform; | ||
2169 | |||
2170 | wl1271_debugfs_init(wl); | ||
2171 | |||
2172 | wl1271_notice("initialized"); | ||
2173 | |||
2174 | return 0; | ||
2175 | |||
2176 | out_platform: | ||
2177 | platform_device_unregister(&wl1271_device); | ||
2178 | |||
2179 | out_irq: | ||
2180 | free_irq(wl->irq, wl); | ||
2181 | |||
2182 | out_free: | ||
2183 | ieee80211_free_hw(hw); | ||
2184 | |||
2185 | return ret; | ||
2186 | } | ||
2187 | |||
2188 | static int __devexit wl1271_remove(struct spi_device *spi) | ||
2189 | { | ||
2190 | struct wl1271 *wl = dev_get_drvdata(&spi->dev); | ||
2191 | |||
2192 | platform_device_unregister(&wl1271_device); | ||
2193 | free_irq(wl->irq, wl); | ||
2194 | |||
2195 | wl1271_free_hw(wl); | ||
2196 | |||
2197 | return 0; | ||
2198 | } | ||
2199 | |||
2200 | |||
2201 | static struct spi_driver wl1271_spi_driver = { | ||
2202 | .driver = { | ||
2203 | .name = "wl1271", | ||
2204 | .bus = &spi_bus_type, | ||
2205 | .owner = THIS_MODULE, | ||
2206 | }, | ||
2207 | |||
2208 | .probe = wl1271_probe, | ||
2209 | .remove = __devexit_p(wl1271_remove), | ||
2210 | }; | ||
2211 | |||
2212 | static int __init wl1271_init(void) | ||
2213 | { | ||
2214 | int ret; | ||
2215 | |||
2216 | ret = spi_register_driver(&wl1271_spi_driver); | ||
2217 | if (ret < 0) { | ||
2218 | wl1271_error("failed to register spi driver: %d", ret); | ||
2219 | goto out; | ||
2220 | } | ||
2221 | |||
2222 | out: | ||
2223 | return ret; | ||
2224 | } | ||
2225 | |||
2226 | static void __exit wl1271_exit(void) | ||
2227 | { | ||
2228 | spi_unregister_driver(&wl1271_spi_driver); | ||
2229 | |||
2230 | wl1271_notice("unloaded"); | ||
2231 | } | ||
2232 | |||
2233 | module_init(wl1271_init); | ||
2234 | module_exit(wl1271_exit); | ||
2235 | |||
2236 | MODULE_LICENSE("GPL"); | ||
2237 | MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>"); | ||
2238 | MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>"); | ||
2239 | MODULE_FIRMWARE(WL1271_FW_NAME); | ||
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.c b/drivers/net/wireless/wl12xx/wl1271_spi.c index 67a82934f36e..c26726a06237 100644 --- a/drivers/net/wireless/wl12xx/wl1271_spi.c +++ b/drivers/net/wireless/wl12xx/wl1271_spi.c | |||
@@ -21,14 +21,17 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/irq.h> | ||
24 | #include <linux/module.h> | 25 | #include <linux/module.h> |
25 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
26 | #include <linux/crc7.h> | 27 | #include <linux/crc7.h> |
27 | #include <linux/spi/spi.h> | 28 | #include <linux/spi/spi.h> |
29 | #include <linux/spi/wl12xx.h> | ||
28 | 30 | ||
29 | #include "wl1271.h" | 31 | #include "wl1271.h" |
30 | #include "wl12xx_80211.h" | 32 | #include "wl12xx_80211.h" |
31 | #include "wl1271_spi.h" | 33 | #include "wl1271_spi.h" |
34 | #include "wl1271_io.h" | ||
32 | 35 | ||
33 | 36 | ||
34 | void wl1271_spi_reset(struct wl1271 *wl) | 37 | void wl1271_spi_reset(struct wl1271 *wl) |
@@ -255,3 +258,180 @@ void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, | |||
255 | wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); | 258 | wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); |
256 | wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); | 259 | wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); |
257 | } | 260 | } |
261 | |||
262 | static irqreturn_t wl1271_irq(int irq, void *cookie) | ||
263 | { | ||
264 | struct wl1271 *wl; | ||
265 | unsigned long flags; | ||
266 | |||
267 | wl1271_debug(DEBUG_IRQ, "IRQ"); | ||
268 | |||
269 | wl = cookie; | ||
270 | |||
271 | /* complete the ELP completion */ | ||
272 | spin_lock_irqsave(&wl->wl_lock, flags); | ||
273 | if (wl->elp_compl) { | ||
274 | complete(wl->elp_compl); | ||
275 | wl->elp_compl = NULL; | ||
276 | } | ||
277 | |||
278 | ieee80211_queue_work(wl->hw, &wl->irq_work); | ||
279 | spin_unlock_irqrestore(&wl->wl_lock, flags); | ||
280 | |||
281 | return IRQ_HANDLED; | ||
282 | } | ||
283 | |||
284 | static void wl1271_device_release(struct device *dev) | ||
285 | { | ||
286 | |||
287 | } | ||
288 | |||
289 | static struct platform_device wl1271_device = { | ||
290 | .name = "wl1271", | ||
291 | .id = -1, | ||
292 | |||
293 | /* device model insists to have a release function */ | ||
294 | .dev = { | ||
295 | .release = wl1271_device_release, | ||
296 | }, | ||
297 | }; | ||
298 | |||
299 | static int __devinit wl1271_probe(struct spi_device *spi) | ||
300 | { | ||
301 | struct wl12xx_platform_data *pdata; | ||
302 | struct ieee80211_hw *hw; | ||
303 | struct wl1271 *wl; | ||
304 | int ret; | ||
305 | |||
306 | pdata = spi->dev.platform_data; | ||
307 | if (!pdata) { | ||
308 | wl1271_error("no platform data"); | ||
309 | return -ENODEV; | ||
310 | } | ||
311 | |||
312 | hw = wl1271_alloc_hw(); | ||
313 | if (IS_ERR(hw)) | ||
314 | return PTR_ERR(hw); | ||
315 | |||
316 | wl = hw->priv; | ||
317 | |||
318 | dev_set_drvdata(&spi->dev, wl); | ||
319 | wl->spi = spi; | ||
320 | |||
321 | /* This is the only SPI value that we need to set here, the rest | ||
322 | * comes from the board-peripherals file */ | ||
323 | spi->bits_per_word = 32; | ||
324 | |||
325 | ret = spi_setup(spi); | ||
326 | if (ret < 0) { | ||
327 | wl1271_error("spi_setup failed"); | ||
328 | goto out_free; | ||
329 | } | ||
330 | |||
331 | wl->set_power = pdata->set_power; | ||
332 | if (!wl->set_power) { | ||
333 | wl1271_error("set power function missing in platform data"); | ||
334 | ret = -ENODEV; | ||
335 | goto out_free; | ||
336 | } | ||
337 | |||
338 | wl->irq = spi->irq; | ||
339 | if (wl->irq < 0) { | ||
340 | wl1271_error("irq missing in platform data"); | ||
341 | ret = -ENODEV; | ||
342 | goto out_free; | ||
343 | } | ||
344 | |||
345 | ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl); | ||
346 | if (ret < 0) { | ||
347 | wl1271_error("request_irq() failed: %d", ret); | ||
348 | goto out_free; | ||
349 | } | ||
350 | |||
351 | set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); | ||
352 | |||
353 | disable_irq(wl->irq); | ||
354 | |||
355 | ret = platform_device_register(&wl1271_device); | ||
356 | if (ret) { | ||
357 | wl1271_error("couldn't register platform device"); | ||
358 | goto out_irq; | ||
359 | } | ||
360 | dev_set_drvdata(&wl1271_device.dev, wl); | ||
361 | |||
362 | ret = wl1271_init_ieee80211(wl); | ||
363 | if (ret) | ||
364 | goto out_platform; | ||
365 | |||
366 | ret = wl1271_register_hw(wl); | ||
367 | if (ret) | ||
368 | goto out_platform; | ||
369 | |||
370 | wl1271_notice("initialized"); | ||
371 | |||
372 | return 0; | ||
373 | |||
374 | out_platform: | ||
375 | platform_device_unregister(&wl1271_device); | ||
376 | |||
377 | out_irq: | ||
378 | free_irq(wl->irq, wl); | ||
379 | |||
380 | out_free: | ||
381 | ieee80211_free_hw(hw); | ||
382 | |||
383 | return ret; | ||
384 | } | ||
385 | |||
386 | static int __devexit wl1271_remove(struct spi_device *spi) | ||
387 | { | ||
388 | struct wl1271 *wl = dev_get_drvdata(&spi->dev); | ||
389 | |||
390 | platform_device_unregister(&wl1271_device); | ||
391 | free_irq(wl->irq, wl); | ||
392 | |||
393 | wl1271_free_hw(wl); | ||
394 | |||
395 | return 0; | ||
396 | } | ||
397 | |||
398 | |||
399 | static struct spi_driver wl1271_spi_driver = { | ||
400 | .driver = { | ||
401 | .name = "wl1271", | ||
402 | .bus = &spi_bus_type, | ||
403 | .owner = THIS_MODULE, | ||
404 | }, | ||
405 | |||
406 | .probe = wl1271_probe, | ||
407 | .remove = __devexit_p(wl1271_remove), | ||
408 | }; | ||
409 | |||
410 | static int __init wl1271_init(void) | ||
411 | { | ||
412 | int ret; | ||
413 | |||
414 | ret = spi_register_driver(&wl1271_spi_driver); | ||
415 | if (ret < 0) { | ||
416 | wl1271_error("failed to register spi driver: %d", ret); | ||
417 | goto out; | ||
418 | } | ||
419 | |||
420 | out: | ||
421 | return ret; | ||
422 | } | ||
423 | |||
424 | static void __exit wl1271_exit(void) | ||
425 | { | ||
426 | spi_unregister_driver(&wl1271_spi_driver); | ||
427 | |||
428 | wl1271_notice("unloaded"); | ||
429 | } | ||
430 | |||
431 | module_init(wl1271_init); | ||
432 | module_exit(wl1271_exit); | ||
433 | |||
434 | MODULE_LICENSE("GPL"); | ||
435 | MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>"); | ||
436 | MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>"); | ||
437 | MODULE_FIRMWARE(WL1271_FW_NAME); | ||