diff options
author | Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com> | 2010-02-22 01:38:21 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-03-09 15:02:56 -0500 |
commit | 2d5e82b8bcda58ec1e2fae5277a81e5fd067e627 (patch) | |
tree | 1bd34f7cf0f04bbea1ce940fb858ed6ffd2bb6e5 /drivers/net/wireless/wl12xx/wl1271_spi.c | |
parent | d57b87fde86a641da7782b99bec0a3130ed32f4a (diff) |
wl1271: Moved module basics to wl1271_spi.c
Moved wl1271 drivers probe, remove etc. functions and structres to
wl1271_spi.c from wl1271_main.c in preparation of implementing SDIO interface.
Signed-off-by: Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>
Reviewed-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_spi.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_spi.c | 180 |
1 files changed, 180 insertions, 0 deletions
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); | ||