wl1271_main.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 2008-2009 Nokia Corporation
  5. *
  6. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #include <linux/module.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/firmware.h>
  27. #include <linux/delay.h>
  28. #include <linux/irq.h>
  29. #include <linux/spi/spi.h>
  30. #include <linux/crc32.h>
  31. #include <linux/etherdevice.h>
  32. #include <linux/spi/wl12xx.h>
  33. #include "wl1271.h"
  34. #include "wl12xx_80211.h"
  35. #include "wl1271_reg.h"
  36. #include "wl1271_spi.h"
  37. #include "wl1271_event.h"
  38. #include "wl1271_tx.h"
  39. #include "wl1271_rx.h"
  40. #include "wl1271_ps.h"
  41. #include "wl1271_init.h"
  42. #include "wl1271_debugfs.h"
  43. #include "wl1271_cmd.h"
  44. #include "wl1271_boot.h"
  45. static int wl1271_plt_init(struct wl1271 *wl)
  46. {
  47. int ret;
  48. ret = wl1271_acx_init_mem_config(wl);
  49. if (ret < 0)
  50. return ret;
  51. ret = wl1271_cmd_data_path(wl, wl->channel, 1);
  52. if (ret < 0)
  53. return ret;
  54. return 0;
  55. }
  56. static void wl1271_disable_interrupts(struct wl1271 *wl)
  57. {
  58. disable_irq(wl->irq);
  59. }
  60. static void wl1271_power_off(struct wl1271 *wl)
  61. {
  62. wl->set_power(false);
  63. }
  64. static void wl1271_power_on(struct wl1271 *wl)
  65. {
  66. wl->set_power(true);
  67. }
  68. static void wl1271_fw_status(struct wl1271 *wl, struct wl1271_fw_status *status)
  69. {
  70. u32 total = 0;
  71. int i;
  72. /*
  73. * FIXME: Reading the FW status directly from the registers seems to
  74. * be the right thing to do, but it doesn't work. And in the
  75. * reference driver, there is a workaround called
  76. * USE_SDIO_24M_WORKAROUND, which reads the status from memory
  77. * instead, so we do the same here.
  78. */
  79. wl1271_spi_mem_read(wl, STATUS_MEM_ADDRESS, status, sizeof(*status));
  80. wl1271_debug(DEBUG_IRQ, "intr: 0x%x (fw_rx_counter = %d, "
  81. "drv_rx_counter = %d, tx_results_counter = %d)",
  82. status->intr,
  83. status->fw_rx_counter,
  84. status->drv_rx_counter,
  85. status->tx_results_counter);
  86. /* update number of available TX blocks */
  87. for (i = 0; i < NUM_TX_QUEUES; i++) {
  88. u32 cnt = status->tx_released_blks[i] - wl->tx_blocks_freed[i];
  89. wl->tx_blocks_freed[i] = status->tx_released_blks[i];
  90. wl->tx_blocks_available += cnt;
  91. total += cnt;
  92. }
  93. /* if more blocks are available now, schedule some tx work */
  94. if (total && !skb_queue_empty(&wl->tx_queue))
  95. schedule_work(&wl->tx_work);
  96. /* update the host-chipset time offset */
  97. wl->time_offset = jiffies_to_usecs(jiffies) - status->fw_localtime;
  98. }
  99. #define WL1271_IRQ_MAX_LOOPS 10
  100. static void wl1271_irq_work(struct work_struct *work)
  101. {
  102. u32 intr, ctr = WL1271_IRQ_MAX_LOOPS;
  103. int ret;
  104. struct wl1271 *wl =
  105. container_of(work, struct wl1271, irq_work);
  106. mutex_lock(&wl->mutex);
  107. wl1271_debug(DEBUG_IRQ, "IRQ work");
  108. if (wl->state == WL1271_STATE_OFF)
  109. goto out;
  110. ret = wl1271_ps_elp_wakeup(wl, true);
  111. if (ret < 0)
  112. goto out;
  113. wl1271_reg_write32(wl, ACX_REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL);
  114. intr = wl1271_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR);
  115. if (!intr) {
  116. wl1271_debug(DEBUG_IRQ, "Zero interrupt received.");
  117. goto out_sleep;
  118. }
  119. intr &= WL1271_INTR_MASK;
  120. do {
  121. wl1271_fw_status(wl, wl->fw_status);
  122. if (intr & (WL1271_ACX_INTR_EVENT_A |
  123. WL1271_ACX_INTR_EVENT_B)) {
  124. wl1271_debug(DEBUG_IRQ,
  125. "WL1271_ACX_INTR_EVENT (0x%x)", intr);
  126. if (intr & WL1271_ACX_INTR_EVENT_A)
  127. wl1271_event_handle(wl, 0);
  128. else
  129. wl1271_event_handle(wl, 1);
  130. }
  131. if (intr & WL1271_ACX_INTR_INIT_COMPLETE)
  132. wl1271_debug(DEBUG_IRQ,
  133. "WL1271_ACX_INTR_INIT_COMPLETE");
  134. if (intr & WL1271_ACX_INTR_HW_AVAILABLE)
  135. wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_HW_AVAILABLE");
  136. if (intr & WL1271_ACX_INTR_DATA) {
  137. u8 tx_res_cnt = wl->fw_status->tx_results_counter -
  138. wl->tx_results_count;
  139. wl1271_debug(DEBUG_IRQ, "WL1271_ACX_INTR_DATA");
  140. /* check for tx results */
  141. if (tx_res_cnt)
  142. wl1271_tx_complete(wl, tx_res_cnt);
  143. wl1271_rx(wl, wl->fw_status);
  144. }
  145. intr = wl1271_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR);
  146. intr &= WL1271_INTR_MASK;
  147. } while (intr && --ctr);
  148. out_sleep:
  149. wl1271_reg_write32(wl, ACX_REG_INTERRUPT_MASK,
  150. WL1271_ACX_INTR_ALL & ~(WL1271_INTR_MASK));
  151. wl1271_ps_elp_sleep(wl);
  152. out:
  153. mutex_unlock(&wl->mutex);
  154. }
  155. static irqreturn_t wl1271_irq(int irq, void *cookie)
  156. {
  157. struct wl1271 *wl;
  158. unsigned long flags;
  159. wl1271_debug(DEBUG_IRQ, "IRQ");
  160. wl = cookie;
  161. /* complete the ELP completion */
  162. spin_lock_irqsave(&wl->wl_lock, flags);
  163. if (wl->elp_compl) {
  164. complete(wl->elp_compl);
  165. wl->elp_compl = NULL;
  166. }
  167. schedule_work(&wl->irq_work);
  168. spin_unlock_irqrestore(&wl->wl_lock, flags);
  169. return IRQ_HANDLED;
  170. }
  171. static int wl1271_fetch_firmware(struct wl1271 *wl)
  172. {
  173. const struct firmware *fw;
  174. int ret;
  175. ret = request_firmware(&fw, WL1271_FW_NAME, &wl->spi->dev);
  176. if (ret < 0) {
  177. wl1271_error("could not get firmware: %d", ret);
  178. return ret;
  179. }
  180. if (fw->size % 4) {
  181. wl1271_error("firmware size is not multiple of 32 bits: %zu",
  182. fw->size);
  183. ret = -EILSEQ;
  184. goto out;
  185. }
  186. wl->fw_len = fw->size;
  187. wl->fw = kmalloc(wl->fw_len, GFP_KERNEL);
  188. if (!wl->fw) {
  189. wl1271_error("could not allocate memory for the firmware");
  190. ret = -ENOMEM;
  191. goto out;
  192. }
  193. memcpy(wl->fw, fw->data, wl->fw_len);
  194. ret = 0;
  195. out:
  196. release_firmware(fw);
  197. return ret;
  198. }
  199. static int wl1271_fetch_nvs(struct wl1271 *wl)
  200. {
  201. const struct firmware *fw;
  202. int ret;
  203. ret = request_firmware(&fw, WL1271_NVS_NAME, &wl->spi->dev);
  204. if (ret < 0) {
  205. wl1271_error("could not get nvs file: %d", ret);
  206. return ret;
  207. }
  208. if (fw->size % 4) {
  209. wl1271_error("nvs size is not multiple of 32 bits: %zu",
  210. fw->size);
  211. ret = -EILSEQ;
  212. goto out;
  213. }
  214. wl->nvs_len = fw->size;
  215. wl->nvs = kmalloc(wl->nvs_len, GFP_KERNEL);
  216. if (!wl->nvs) {
  217. wl1271_error("could not allocate memory for the nvs file");
  218. ret = -ENOMEM;
  219. goto out;
  220. }
  221. memcpy(wl->nvs, fw->data, wl->nvs_len);
  222. ret = 0;
  223. out:
  224. release_firmware(fw);
  225. return ret;
  226. }
  227. static void wl1271_fw_wakeup(struct wl1271 *wl)
  228. {
  229. u32 elp_reg;
  230. elp_reg = ELPCTRL_WAKE_UP;
  231. wl1271_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
  232. }
  233. static int wl1271_setup(struct wl1271 *wl)
  234. {
  235. wl->fw_status = kmalloc(sizeof(*wl->fw_status), GFP_KERNEL);
  236. if (!wl->fw_status)
  237. return -ENOMEM;
  238. wl->tx_res_if = kmalloc(sizeof(*wl->tx_res_if), GFP_KERNEL);
  239. if (!wl->tx_res_if) {
  240. kfree(wl->fw_status);
  241. return -ENOMEM;
  242. }
  243. INIT_WORK(&wl->irq_work, wl1271_irq_work);
  244. INIT_WORK(&wl->tx_work, wl1271_tx_work);
  245. return 0;
  246. }
  247. static int wl1271_chip_wakeup(struct wl1271 *wl)
  248. {
  249. int ret = 0;
  250. wl1271_power_on(wl);
  251. msleep(WL1271_POWER_ON_SLEEP);
  252. wl1271_spi_reset(wl);
  253. wl1271_spi_init(wl);
  254. /* We don't need a real memory partition here, because we only want
  255. * to use the registers at this point. */
  256. wl1271_set_partition(wl,
  257. 0x00000000,
  258. 0x00000000,
  259. REGISTERS_BASE,
  260. REGISTERS_DOWN_SIZE);
  261. /* ELP module wake up */
  262. wl1271_fw_wakeup(wl);
  263. /* whal_FwCtrl_BootSm() */
  264. /* 0. read chip id from CHIP_ID */
  265. wl->chip.id = wl1271_reg_read32(wl, CHIP_ID_B);
  266. /* 1. check if chip id is valid */
  267. switch (wl->chip.id) {
  268. case CHIP_ID_1271_PG10:
  269. wl1271_warning("chip id 0x%x (1271 PG10) support is obsolete",
  270. wl->chip.id);
  271. ret = wl1271_setup(wl);
  272. if (ret < 0)
  273. goto out;
  274. break;
  275. case CHIP_ID_1271_PG20:
  276. wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1271 PG20)",
  277. wl->chip.id);
  278. ret = wl1271_setup(wl);
  279. if (ret < 0)
  280. goto out;
  281. break;
  282. default:
  283. wl1271_error("unsupported chip id: 0x%x", wl->chip.id);
  284. ret = -ENODEV;
  285. goto out;
  286. }
  287. if (wl->fw == NULL) {
  288. ret = wl1271_fetch_firmware(wl);
  289. if (ret < 0)
  290. goto out;
  291. }
  292. /* No NVS from netlink, try to get it from the filesystem */
  293. if (wl->nvs == NULL) {
  294. ret = wl1271_fetch_nvs(wl);
  295. if (ret < 0)
  296. goto out;
  297. }
  298. out:
  299. return ret;
  300. }
  301. static void wl1271_filter_work(struct work_struct *work)
  302. {
  303. struct wl1271 *wl =
  304. container_of(work, struct wl1271, filter_work);
  305. int ret;
  306. mutex_lock(&wl->mutex);
  307. if (wl->state == WL1271_STATE_OFF)
  308. goto out;
  309. ret = wl1271_ps_elp_wakeup(wl, false);
  310. if (ret < 0)
  311. goto out;
  312. /* FIXME: replace the magic numbers with proper definitions */
  313. ret = wl1271_cmd_join(wl, wl->bss_type, 1, 100, 0);
  314. if (ret < 0)
  315. goto out_sleep;
  316. out_sleep:
  317. wl1271_ps_elp_sleep(wl);
  318. out:
  319. mutex_unlock(&wl->mutex);
  320. }
  321. int wl1271_plt_start(struct wl1271 *wl)
  322. {
  323. int ret;
  324. mutex_lock(&wl->mutex);
  325. wl1271_notice("power up");
  326. if (wl->state != WL1271_STATE_OFF) {
  327. wl1271_error("cannot go into PLT state because not "
  328. "in off state: %d", wl->state);
  329. ret = -EBUSY;
  330. goto out;
  331. }
  332. wl->state = WL1271_STATE_PLT;
  333. ret = wl1271_chip_wakeup(wl);
  334. if (ret < 0)
  335. goto out;
  336. ret = wl1271_boot(wl);
  337. if (ret < 0)
  338. goto out;
  339. wl1271_notice("firmware booted in PLT mode (%s)", wl->chip.fw_ver);
  340. ret = wl1271_plt_init(wl);
  341. if (ret < 0)
  342. goto out;
  343. out:
  344. mutex_unlock(&wl->mutex);
  345. return ret;
  346. }
  347. int wl1271_plt_stop(struct wl1271 *wl)
  348. {
  349. int ret = 0;
  350. mutex_lock(&wl->mutex);
  351. wl1271_notice("power down");
  352. if (wl->state != WL1271_STATE_PLT) {
  353. wl1271_error("cannot power down because not in PLT "
  354. "state: %d", wl->state);
  355. ret = -EBUSY;
  356. goto out;
  357. }
  358. wl1271_disable_interrupts(wl);
  359. wl1271_power_off(wl);
  360. wl->state = WL1271_STATE_OFF;
  361. out:
  362. mutex_unlock(&wl->mutex);
  363. return ret;
  364. }
  365. static int wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
  366. {
  367. struct wl1271 *wl = hw->priv;
  368. skb_queue_tail(&wl->tx_queue, skb);
  369. /*
  370. * The chip specific setup must run before the first TX packet -
  371. * before that, the tx_work will not be initialized!
  372. */
  373. schedule_work(&wl->tx_work);
  374. /*
  375. * The workqueue is slow to process the tx_queue and we need stop
  376. * the queue here, otherwise the queue will get too long.
  377. */
  378. if (skb_queue_len(&wl->tx_queue) >= WL1271_TX_QUEUE_MAX_LENGTH) {
  379. ieee80211_stop_queues(wl->hw);
  380. /*
  381. * FIXME: this is racy, the variable is not properly
  382. * protected. Maybe fix this by removing the stupid
  383. * variable altogether and checking the real queue state?
  384. */
  385. wl->tx_queue_stopped = true;
  386. }
  387. return NETDEV_TX_OK;
  388. }
  389. static int wl1271_op_start(struct ieee80211_hw *hw)
  390. {
  391. struct wl1271 *wl = hw->priv;
  392. int ret = 0;
  393. wl1271_debug(DEBUG_MAC80211, "mac80211 start");
  394. mutex_lock(&wl->mutex);
  395. if (wl->state != WL1271_STATE_OFF) {
  396. wl1271_error("cannot start because not in off state: %d",
  397. wl->state);
  398. ret = -EBUSY;
  399. goto out;
  400. }
  401. ret = wl1271_chip_wakeup(wl);
  402. if (ret < 0)
  403. goto out;
  404. ret = wl1271_boot(wl);
  405. if (ret < 0)
  406. goto out;
  407. ret = wl1271_hw_init(wl);
  408. if (ret < 0)
  409. goto out;
  410. wl->state = WL1271_STATE_ON;
  411. wl1271_info("firmware booted (%s)", wl->chip.fw_ver);
  412. out:
  413. if (ret < 0)
  414. wl1271_power_off(wl);
  415. mutex_unlock(&wl->mutex);
  416. return ret;
  417. }
  418. static void wl1271_op_stop(struct ieee80211_hw *hw)
  419. {
  420. struct wl1271 *wl = hw->priv;
  421. int i;
  422. wl1271_info("down");
  423. wl1271_debug(DEBUG_MAC80211, "mac80211 stop");
  424. mutex_lock(&wl->mutex);
  425. WARN_ON(wl->state != WL1271_STATE_ON);
  426. if (wl->scanning) {
  427. mutex_unlock(&wl->mutex);
  428. ieee80211_scan_completed(wl->hw, true);
  429. mutex_lock(&wl->mutex);
  430. wl->scanning = false;
  431. }
  432. wl->state = WL1271_STATE_OFF;
  433. wl1271_disable_interrupts(wl);
  434. mutex_unlock(&wl->mutex);
  435. cancel_work_sync(&wl->irq_work);
  436. cancel_work_sync(&wl->tx_work);
  437. cancel_work_sync(&wl->filter_work);
  438. mutex_lock(&wl->mutex);
  439. /* let's notify MAC80211 about the remaining pending TX frames */
  440. wl1271_tx_flush(wl);
  441. wl1271_power_off(wl);
  442. memset(wl->bssid, 0, ETH_ALEN);
  443. memset(wl->ssid, 0, IW_ESSID_MAX_SIZE + 1);
  444. wl->ssid_len = 0;
  445. wl->listen_int = 1;
  446. wl->bss_type = MAX_BSS_TYPE;
  447. wl->rx_counter = 0;
  448. wl->elp = false;
  449. wl->psm = 0;
  450. wl->tx_queue_stopped = false;
  451. wl->power_level = WL1271_DEFAULT_POWER_LEVEL;
  452. wl->tx_blocks_available = 0;
  453. wl->tx_results_count = 0;
  454. wl->tx_packets_count = 0;
  455. wl->time_offset = 0;
  456. wl->session_counter = 0;
  457. for (i = 0; i < NUM_TX_QUEUES; i++)
  458. wl->tx_blocks_freed[i] = 0;
  459. wl1271_debugfs_reset(wl);
  460. mutex_unlock(&wl->mutex);
  461. }
  462. static int wl1271_op_add_interface(struct ieee80211_hw *hw,
  463. struct ieee80211_if_init_conf *conf)
  464. {
  465. struct wl1271 *wl = hw->priv;
  466. int ret = 0;
  467. wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM",
  468. conf->type, conf->mac_addr);
  469. mutex_lock(&wl->mutex);
  470. switch (conf->type) {
  471. case NL80211_IFTYPE_STATION:
  472. wl->bss_type = BSS_TYPE_STA_BSS;
  473. break;
  474. case NL80211_IFTYPE_ADHOC:
  475. wl->bss_type = BSS_TYPE_IBSS;
  476. break;
  477. default:
  478. ret = -EOPNOTSUPP;
  479. goto out;
  480. }
  481. /* FIXME: what if conf->mac_addr changes? */
  482. out:
  483. mutex_unlock(&wl->mutex);
  484. return ret;
  485. }
  486. static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
  487. struct ieee80211_if_init_conf *conf)
  488. {
  489. wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface");
  490. }
  491. #if 0
  492. static int wl1271_op_config_interface(struct ieee80211_hw *hw,
  493. struct ieee80211_vif *vif,
  494. struct ieee80211_if_conf *conf)
  495. {
  496. struct wl1271 *wl = hw->priv;
  497. struct sk_buff *beacon;
  498. int ret;
  499. wl1271_debug(DEBUG_MAC80211, "mac80211 config_interface bssid %pM",
  500. conf->bssid);
  501. wl1271_dump_ascii(DEBUG_MAC80211, "ssid: ", conf->ssid,
  502. conf->ssid_len);
  503. mutex_lock(&wl->mutex);
  504. ret = wl1271_ps_elp_wakeup(wl, false);
  505. if (ret < 0)
  506. goto out;
  507. memcpy(wl->bssid, conf->bssid, ETH_ALEN);
  508. ret = wl1271_cmd_build_null_data(wl);
  509. if (ret < 0)
  510. goto out_sleep;
  511. wl->ssid_len = conf->ssid_len;
  512. if (wl->ssid_len)
  513. memcpy(wl->ssid, conf->ssid, wl->ssid_len);
  514. if (wl->bss_type != BSS_TYPE_IBSS) {
  515. /* FIXME: replace the magic numbers with proper definitions */
  516. ret = wl1271_cmd_join(wl, wl->bss_type, 5, 100, 1);
  517. if (ret < 0)
  518. goto out_sleep;
  519. }
  520. if (conf->changed & IEEE80211_IFCC_BEACON) {
  521. beacon = ieee80211_beacon_get(hw, vif);
  522. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON,
  523. beacon->data, beacon->len);
  524. if (ret < 0) {
  525. dev_kfree_skb(beacon);
  526. goto out_sleep;
  527. }
  528. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE,
  529. beacon->data, beacon->len);
  530. dev_kfree_skb(beacon);
  531. if (ret < 0)
  532. goto out_sleep;
  533. /* FIXME: replace the magic numbers with proper definitions */
  534. ret = wl1271_cmd_join(wl, wl->bss_type, 1, 100, 0);
  535. if (ret < 0)
  536. goto out_sleep;
  537. }
  538. out_sleep:
  539. wl1271_ps_elp_sleep(wl);
  540. out:
  541. mutex_unlock(&wl->mutex);
  542. return ret;
  543. }
  544. #endif
  545. static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
  546. {
  547. struct wl1271 *wl = hw->priv;
  548. struct ieee80211_conf *conf = &hw->conf;
  549. int channel, ret = 0;
  550. channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
  551. wl1271_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d",
  552. channel,
  553. conf->flags & IEEE80211_CONF_PS ? "on" : "off",
  554. conf->power_level);
  555. mutex_lock(&wl->mutex);
  556. ret = wl1271_ps_elp_wakeup(wl, false);
  557. if (ret < 0)
  558. goto out;
  559. if (channel != wl->channel) {
  560. u8 old_channel = wl->channel;
  561. wl->channel = channel;
  562. /* FIXME: use beacon interval provided by mac80211 */
  563. ret = wl1271_cmd_join(wl, wl->bss_type, 1, 100, 0);
  564. if (ret < 0) {
  565. wl->channel = old_channel;
  566. goto out_sleep;
  567. }
  568. }
  569. ret = wl1271_cmd_build_null_data(wl);
  570. if (ret < 0)
  571. goto out_sleep;
  572. if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) {
  573. wl1271_info("psm enabled");
  574. wl->psm_requested = true;
  575. /*
  576. * We enter PSM only if we're already associated.
  577. * If we're not, we'll enter it when joining an SSID,
  578. * through the bss_info_changed() hook.
  579. */
  580. ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE);
  581. } else if (!(conf->flags & IEEE80211_CONF_PS) &&
  582. wl->psm_requested) {
  583. wl1271_info("psm disabled");
  584. wl->psm_requested = false;
  585. if (wl->psm)
  586. ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE);
  587. }
  588. if (conf->power_level != wl->power_level) {
  589. ret = wl1271_acx_tx_power(wl, conf->power_level);
  590. if (ret < 0)
  591. goto out;
  592. wl->power_level = conf->power_level;
  593. }
  594. out_sleep:
  595. wl1271_ps_elp_sleep(wl);
  596. out:
  597. mutex_unlock(&wl->mutex);
  598. return ret;
  599. }
  600. #define WL1271_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \
  601. FIF_ALLMULTI | \
  602. FIF_FCSFAIL | \
  603. FIF_BCN_PRBRESP_PROMISC | \
  604. FIF_CONTROL | \
  605. FIF_OTHER_BSS)
  606. static void wl1271_op_configure_filter(struct ieee80211_hw *hw,
  607. unsigned int changed,
  608. unsigned int *total,u64 multicast)
  609. {
  610. struct wl1271 *wl = hw->priv;
  611. wl1271_debug(DEBUG_MAC80211, "mac80211 configure filter");
  612. *total &= WL1271_SUPPORTED_FILTERS;
  613. changed &= WL1271_SUPPORTED_FILTERS;
  614. if (changed == 0)
  615. return;
  616. /* FIXME: wl->rx_config and wl->rx_filter are not protected */
  617. wl->rx_config = WL1271_DEFAULT_RX_CONFIG;
  618. wl->rx_filter = WL1271_DEFAULT_RX_FILTER;
  619. /*
  620. * FIXME: workqueues need to be properly cancelled on stop(), for
  621. * now let's just disable changing the filter settings. They will
  622. * be updated any on config().
  623. */
  624. /* schedule_work(&wl->filter_work); */
  625. }
  626. static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
  627. struct ieee80211_vif *vif,
  628. struct ieee80211_sta *sta,
  629. struct ieee80211_key_conf *key_conf)
  630. {
  631. struct wl1271 *wl = hw->priv;
  632. const u8 *addr;
  633. int ret;
  634. u8 key_type;
  635. static const u8 bcast_addr[ETH_ALEN] =
  636. { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
  637. wl1271_debug(DEBUG_MAC80211, "mac80211 set key");
  638. addr = sta ? sta->addr : bcast_addr;
  639. wl1271_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd);
  640. wl1271_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN);
  641. wl1271_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x",
  642. key_conf->alg, key_conf->keyidx,
  643. key_conf->keylen, key_conf->flags);
  644. wl1271_dump(DEBUG_CRYPT, "KEY: ", key_conf->key, key_conf->keylen);
  645. if (is_zero_ether_addr(addr)) {
  646. /* We dont support TX only encryption */
  647. ret = -EOPNOTSUPP;
  648. goto out;
  649. }
  650. mutex_lock(&wl->mutex);
  651. ret = wl1271_ps_elp_wakeup(wl, false);
  652. if (ret < 0)
  653. goto out_unlock;
  654. switch (key_conf->alg) {
  655. case ALG_WEP:
  656. key_type = KEY_WEP;
  657. key_conf->hw_key_idx = key_conf->keyidx;
  658. break;
  659. case ALG_TKIP:
  660. key_type = KEY_TKIP;
  661. key_conf->hw_key_idx = key_conf->keyidx;
  662. break;
  663. case ALG_CCMP:
  664. key_type = KEY_AES;
  665. key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
  666. break;
  667. default:
  668. wl1271_error("Unknown key algo 0x%x", key_conf->alg);
  669. ret = -EOPNOTSUPP;
  670. goto out_sleep;
  671. }
  672. switch (cmd) {
  673. case SET_KEY:
  674. ret = wl1271_cmd_set_key(wl, KEY_ADD_OR_REPLACE,
  675. key_conf->keyidx, key_type,
  676. key_conf->keylen, key_conf->key,
  677. addr);
  678. if (ret < 0) {
  679. wl1271_error("Could not add or replace key");
  680. goto out_sleep;
  681. }
  682. break;
  683. case DISABLE_KEY:
  684. ret = wl1271_cmd_set_key(wl, KEY_REMOVE,
  685. key_conf->keyidx, key_type,
  686. key_conf->keylen, key_conf->key,
  687. addr);
  688. if (ret < 0) {
  689. wl1271_error("Could not remove key");
  690. goto out_sleep;
  691. }
  692. break;
  693. default:
  694. wl1271_error("Unsupported key cmd 0x%x", cmd);
  695. ret = -EOPNOTSUPP;
  696. goto out_sleep;
  697. break;
  698. }
  699. out_sleep:
  700. wl1271_ps_elp_sleep(wl);
  701. out_unlock:
  702. mutex_unlock(&wl->mutex);
  703. out:
  704. return ret;
  705. }
  706. static int wl1271_op_hw_scan(struct ieee80211_hw *hw,
  707. struct cfg80211_scan_request *req)
  708. {
  709. struct wl1271 *wl = hw->priv;
  710. int ret;
  711. u8 *ssid = NULL;
  712. size_t ssid_len = 0;
  713. wl1271_debug(DEBUG_MAC80211, "mac80211 hw scan");
  714. if (req->n_ssids) {
  715. ssid = req->ssids[0].ssid;
  716. ssid_len = req->ssids[0].ssid_len;
  717. }
  718. mutex_lock(&wl->mutex);
  719. ret = wl1271_ps_elp_wakeup(wl, false);
  720. if (ret < 0)
  721. goto out;
  722. ret = wl1271_cmd_scan(hw->priv, ssid, ssid_len, 1, 0, 13, 3);
  723. wl1271_ps_elp_sleep(wl);
  724. out:
  725. mutex_unlock(&wl->mutex);
  726. return ret;
  727. }
  728. static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
  729. {
  730. struct wl1271 *wl = hw->priv;
  731. int ret;
  732. mutex_lock(&wl->mutex);
  733. ret = wl1271_ps_elp_wakeup(wl, false);
  734. if (ret < 0)
  735. goto out;
  736. ret = wl1271_acx_rts_threshold(wl, (u16) value);
  737. if (ret < 0)
  738. wl1271_warning("wl1271_op_set_rts_threshold failed: %d", ret);
  739. wl1271_ps_elp_sleep(wl);
  740. out:
  741. mutex_unlock(&wl->mutex);
  742. return ret;
  743. }
  744. static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw,
  745. struct ieee80211_vif *vif,
  746. struct ieee80211_bss_conf *bss_conf,
  747. u32 changed)
  748. {
  749. enum wl1271_cmd_ps_mode mode;
  750. struct wl1271 *wl = hw->priv;
  751. int ret;
  752. wl1271_debug(DEBUG_MAC80211, "mac80211 bss info changed");
  753. mutex_lock(&wl->mutex);
  754. ret = wl1271_ps_elp_wakeup(wl, false);
  755. if (ret < 0)
  756. goto out;
  757. if (changed & BSS_CHANGED_ASSOC) {
  758. if (bss_conf->assoc) {
  759. wl->aid = bss_conf->aid;
  760. ret = wl1271_cmd_build_ps_poll(wl, wl->aid);
  761. if (ret < 0)
  762. goto out_sleep;
  763. ret = wl1271_acx_aid(wl, wl->aid);
  764. if (ret < 0)
  765. goto out_sleep;
  766. /* If we want to go in PSM but we're not there yet */
  767. if (wl->psm_requested && !wl->psm) {
  768. mode = STATION_POWER_SAVE_MODE;
  769. ret = wl1271_ps_set_mode(wl, mode);
  770. if (ret < 0)
  771. goto out_sleep;
  772. }
  773. }
  774. }
  775. if (changed & BSS_CHANGED_ERP_SLOT) {
  776. if (bss_conf->use_short_slot)
  777. ret = wl1271_acx_slot(wl, SLOT_TIME_SHORT);
  778. else
  779. ret = wl1271_acx_slot(wl, SLOT_TIME_LONG);
  780. if (ret < 0) {
  781. wl1271_warning("Set slot time failed %d", ret);
  782. goto out_sleep;
  783. }
  784. }
  785. if (changed & BSS_CHANGED_ERP_PREAMBLE) {
  786. if (bss_conf->use_short_preamble)
  787. wl1271_acx_set_preamble(wl, ACX_PREAMBLE_SHORT);
  788. else
  789. wl1271_acx_set_preamble(wl, ACX_PREAMBLE_LONG);
  790. }
  791. if (changed & BSS_CHANGED_ERP_CTS_PROT) {
  792. if (bss_conf->use_cts_prot)
  793. ret = wl1271_acx_cts_protect(wl, CTSPROTECT_ENABLE);
  794. else
  795. ret = wl1271_acx_cts_protect(wl, CTSPROTECT_DISABLE);
  796. if (ret < 0) {
  797. wl1271_warning("Set ctsprotect failed %d", ret);
  798. goto out_sleep;
  799. }
  800. }
  801. out_sleep:
  802. wl1271_ps_elp_sleep(wl);
  803. out:
  804. mutex_unlock(&wl->mutex);
  805. }
  806. /* can't be const, mac80211 writes to this */
  807. static struct ieee80211_rate wl1271_rates[] = {
  808. { .bitrate = 10,
  809. .hw_value = 0x1,
  810. .hw_value_short = 0x1, },
  811. { .bitrate = 20,
  812. .hw_value = 0x2,
  813. .hw_value_short = 0x2,
  814. .flags = IEEE80211_RATE_SHORT_PREAMBLE },
  815. { .bitrate = 55,
  816. .hw_value = 0x4,
  817. .hw_value_short = 0x4,
  818. .flags = IEEE80211_RATE_SHORT_PREAMBLE },
  819. { .bitrate = 110,
  820. .hw_value = 0x20,
  821. .hw_value_short = 0x20,
  822. .flags = IEEE80211_RATE_SHORT_PREAMBLE },
  823. { .bitrate = 60,
  824. .hw_value = 0x8,
  825. .hw_value_short = 0x8, },
  826. { .bitrate = 90,
  827. .hw_value = 0x10,
  828. .hw_value_short = 0x10, },
  829. { .bitrate = 120,
  830. .hw_value = 0x40,
  831. .hw_value_short = 0x40, },
  832. { .bitrate = 180,
  833. .hw_value = 0x80,
  834. .hw_value_short = 0x80, },
  835. { .bitrate = 240,
  836. .hw_value = 0x200,
  837. .hw_value_short = 0x200, },
  838. { .bitrate = 360,
  839. .hw_value = 0x400,
  840. .hw_value_short = 0x400, },
  841. { .bitrate = 480,
  842. .hw_value = 0x800,
  843. .hw_value_short = 0x800, },
  844. { .bitrate = 540,
  845. .hw_value = 0x1000,
  846. .hw_value_short = 0x1000, },
  847. };
  848. /* can't be const, mac80211 writes to this */
  849. static struct ieee80211_channel wl1271_channels[] = {
  850. { .hw_value = 1, .center_freq = 2412},
  851. { .hw_value = 2, .center_freq = 2417},
  852. { .hw_value = 3, .center_freq = 2422},
  853. { .hw_value = 4, .center_freq = 2427},
  854. { .hw_value = 5, .center_freq = 2432},
  855. { .hw_value = 6, .center_freq = 2437},
  856. { .hw_value = 7, .center_freq = 2442},
  857. { .hw_value = 8, .center_freq = 2447},
  858. { .hw_value = 9, .center_freq = 2452},
  859. { .hw_value = 10, .center_freq = 2457},
  860. { .hw_value = 11, .center_freq = 2462},
  861. { .hw_value = 12, .center_freq = 2467},
  862. { .hw_value = 13, .center_freq = 2472},
  863. };
  864. /* can't be const, mac80211 writes to this */
  865. static struct ieee80211_supported_band wl1271_band_2ghz = {
  866. .channels = wl1271_channels,
  867. .n_channels = ARRAY_SIZE(wl1271_channels),
  868. .bitrates = wl1271_rates,
  869. .n_bitrates = ARRAY_SIZE(wl1271_rates),
  870. };
  871. static const struct ieee80211_ops wl1271_ops = {
  872. .start = wl1271_op_start,
  873. .stop = wl1271_op_stop,
  874. .add_interface = wl1271_op_add_interface,
  875. .remove_interface = wl1271_op_remove_interface,
  876. .config = wl1271_op_config,
  877. /* .config_interface = wl1271_op_config_interface, */
  878. .configure_filter = wl1271_op_configure_filter,
  879. .tx = wl1271_op_tx,
  880. .set_key = wl1271_op_set_key,
  881. .hw_scan = wl1271_op_hw_scan,
  882. .bss_info_changed = wl1271_op_bss_info_changed,
  883. .set_rts_threshold = wl1271_op_set_rts_threshold,
  884. };
  885. static int wl1271_register_hw(struct wl1271 *wl)
  886. {
  887. int ret;
  888. if (wl->mac80211_registered)
  889. return 0;
  890. SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
  891. ret = ieee80211_register_hw(wl->hw);
  892. if (ret < 0) {
  893. wl1271_error("unable to register mac80211 hw: %d", ret);
  894. return ret;
  895. }
  896. wl->mac80211_registered = true;
  897. wl1271_notice("loaded");
  898. return 0;
  899. }
  900. static int wl1271_init_ieee80211(struct wl1271 *wl)
  901. {
  902. /*
  903. * The tx descriptor buffer and the TKIP space.
  904. *
  905. * FIXME: add correct 1271 descriptor size
  906. */
  907. wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE;
  908. /* unit us */
  909. /* FIXME: find a proper value */
  910. wl->hw->channel_change_time = 10000;
  911. wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
  912. IEEE80211_HW_NOISE_DBM;
  913. wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
  914. wl->hw->wiphy->max_scan_ssids = 1;
  915. wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl1271_band_2ghz;
  916. SET_IEEE80211_DEV(wl->hw, &wl->spi->dev);
  917. return 0;
  918. }
  919. static void wl1271_device_release(struct device *dev)
  920. {
  921. }
  922. static struct platform_device wl1271_device = {
  923. .name = "wl1271",
  924. .id = -1,
  925. /* device model insists to have a release function */
  926. .dev = {
  927. .release = wl1271_device_release,
  928. },
  929. };
  930. #define WL1271_DEFAULT_CHANNEL 0
  931. static int __devinit wl1271_probe(struct spi_device *spi)
  932. {
  933. struct wl12xx_platform_data *pdata;
  934. struct ieee80211_hw *hw;
  935. struct wl1271 *wl;
  936. int ret, i;
  937. static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
  938. pdata = spi->dev.platform_data;
  939. if (!pdata) {
  940. wl1271_error("no platform data");
  941. return -ENODEV;
  942. }
  943. hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops);
  944. if (!hw) {
  945. wl1271_error("could not alloc ieee80211_hw");
  946. return -ENOMEM;
  947. }
  948. wl = hw->priv;
  949. memset(wl, 0, sizeof(*wl));
  950. wl->hw = hw;
  951. dev_set_drvdata(&spi->dev, wl);
  952. wl->spi = spi;
  953. skb_queue_head_init(&wl->tx_queue);
  954. INIT_WORK(&wl->filter_work, wl1271_filter_work);
  955. wl->channel = WL1271_DEFAULT_CHANNEL;
  956. wl->scanning = false;
  957. wl->default_key = 0;
  958. wl->listen_int = 1;
  959. wl->rx_counter = 0;
  960. wl->rx_config = WL1271_DEFAULT_RX_CONFIG;
  961. wl->rx_filter = WL1271_DEFAULT_RX_FILTER;
  962. wl->elp = false;
  963. wl->psm = 0;
  964. wl->psm_requested = false;
  965. wl->tx_queue_stopped = false;
  966. wl->power_level = WL1271_DEFAULT_POWER_LEVEL;
  967. /* We use the default power on sleep time until we know which chip
  968. * we're using */
  969. for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
  970. wl->tx_frames[i] = NULL;
  971. spin_lock_init(&wl->wl_lock);
  972. /*
  973. * In case our MAC address is not correctly set,
  974. * we use a random but Nokia MAC.
  975. */
  976. memcpy(wl->mac_addr, nokia_oui, 3);
  977. get_random_bytes(wl->mac_addr + 3, 3);
  978. wl->state = WL1271_STATE_OFF;
  979. mutex_init(&wl->mutex);
  980. wl->rx_descriptor = kmalloc(sizeof(*wl->rx_descriptor), GFP_KERNEL);
  981. if (!wl->rx_descriptor) {
  982. wl1271_error("could not allocate memory for rx descriptor");
  983. ret = -ENOMEM;
  984. goto out_free;
  985. }
  986. /* This is the only SPI value that we need to set here, the rest
  987. * comes from the board-peripherals file */
  988. spi->bits_per_word = 32;
  989. ret = spi_setup(spi);
  990. if (ret < 0) {
  991. wl1271_error("spi_setup failed");
  992. goto out_free;
  993. }
  994. wl->set_power = pdata->set_power;
  995. if (!wl->set_power) {
  996. wl1271_error("set power function missing in platform data");
  997. ret = -ENODEV;
  998. goto out_free;
  999. }
  1000. wl->irq = spi->irq;
  1001. if (wl->irq < 0) {
  1002. wl1271_error("irq missing in platform data");
  1003. ret = -ENODEV;
  1004. goto out_free;
  1005. }
  1006. ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl);
  1007. if (ret < 0) {
  1008. wl1271_error("request_irq() failed: %d", ret);
  1009. goto out_free;
  1010. }
  1011. set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
  1012. disable_irq(wl->irq);
  1013. ret = platform_device_register(&wl1271_device);
  1014. if (ret) {
  1015. wl1271_error("couldn't register platform device");
  1016. goto out_irq;
  1017. }
  1018. dev_set_drvdata(&wl1271_device.dev, wl);
  1019. ret = wl1271_init_ieee80211(wl);
  1020. if (ret)
  1021. goto out_platform;
  1022. ret = wl1271_register_hw(wl);
  1023. if (ret)
  1024. goto out_platform;
  1025. wl1271_debugfs_init(wl);
  1026. wl1271_notice("initialized");
  1027. return 0;
  1028. out_platform:
  1029. platform_device_unregister(&wl1271_device);
  1030. out_irq:
  1031. free_irq(wl->irq, wl);
  1032. out_free:
  1033. kfree(wl->rx_descriptor);
  1034. wl->rx_descriptor = NULL;
  1035. ieee80211_free_hw(hw);
  1036. return ret;
  1037. }
  1038. static int __devexit wl1271_remove(struct spi_device *spi)
  1039. {
  1040. struct wl1271 *wl = dev_get_drvdata(&spi->dev);
  1041. ieee80211_unregister_hw(wl->hw);
  1042. wl1271_debugfs_exit(wl);
  1043. platform_device_unregister(&wl1271_device);
  1044. free_irq(wl->irq, wl);
  1045. kfree(wl->target_mem_map);
  1046. kfree(wl->fw);
  1047. wl->fw = NULL;
  1048. kfree(wl->nvs);
  1049. wl->nvs = NULL;
  1050. kfree(wl->rx_descriptor);
  1051. wl->rx_descriptor = NULL;
  1052. kfree(wl->fw_status);
  1053. kfree(wl->tx_res_if);
  1054. ieee80211_free_hw(wl->hw);
  1055. return 0;
  1056. }
  1057. static struct spi_driver wl1271_spi_driver = {
  1058. .driver = {
  1059. .name = "wl1271",
  1060. .bus = &spi_bus_type,
  1061. .owner = THIS_MODULE,
  1062. },
  1063. .probe = wl1271_probe,
  1064. .remove = __devexit_p(wl1271_remove),
  1065. };
  1066. static int __init wl1271_init(void)
  1067. {
  1068. int ret;
  1069. ret = spi_register_driver(&wl1271_spi_driver);
  1070. if (ret < 0) {
  1071. wl1271_error("failed to register spi driver: %d", ret);
  1072. goto out;
  1073. }
  1074. out:
  1075. return ret;
  1076. }
  1077. static void __exit wl1271_exit(void)
  1078. {
  1079. spi_unregister_driver(&wl1271_spi_driver);
  1080. wl1271_notice("unloaded");
  1081. }
  1082. module_init(wl1271_init);
  1083. module_exit(wl1271_exit);
  1084. MODULE_LICENSE("GPL");
  1085. MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>");