wl1251: remove wl1251_plt_start/stop()
[linux-2.6.git] / drivers / net / wireless / wl12xx / wl1251_main.c
1 /*
2  * This file is part of wl1251
3  *
4  * Copyright (C) 2008-2009 Nokia Corporation
5  *
6  * Contact: Kalle Valo <kalle.valo@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
24 #include <linux/module.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
34 #include "wl1251.h"
35 #include "wl12xx_80211.h"
36 #include "reg.h"
37 #include "wl1251_ops.h"
38 #include "wl1251_spi.h"
39 #include "wl1251_event.h"
40 #include "wl1251_tx.h"
41 #include "wl1251_rx.h"
42 #include "wl1251_ps.h"
43 #include "wl1251_init.h"
44 #include "wl1251_debugfs.h"
45
46 static void wl1251_disable_interrupts(struct wl1251 *wl)
47 {
48         disable_irq(wl->irq);
49 }
50
51 static void wl1251_power_off(struct wl1251 *wl)
52 {
53         wl->set_power(false);
54 }
55
56 static void wl1251_power_on(struct wl1251 *wl)
57 {
58         wl->set_power(true);
59 }
60
61 static irqreturn_t wl1251_irq(int irq, void *cookie)
62 {
63         struct wl1251 *wl;
64
65         wl1251_debug(DEBUG_IRQ, "IRQ");
66
67         wl = cookie;
68
69         schedule_work(&wl->irq_work);
70
71         return IRQ_HANDLED;
72 }
73
74 static int wl1251_fetch_firmware(struct wl1251 *wl)
75 {
76         const struct firmware *fw;
77         int ret;
78
79         ret = request_firmware(&fw, wl->chip.fw_filename, &wl->spi->dev);
80
81         if (ret < 0) {
82                 wl1251_error("could not get firmware: %d", ret);
83                 return ret;
84         }
85
86         if (fw->size % 4) {
87                 wl1251_error("firmware size is not multiple of 32 bits: %zu",
88                              fw->size);
89                 ret = -EILSEQ;
90                 goto out;
91         }
92
93         wl->fw_len = fw->size;
94         wl->fw = kmalloc(wl->fw_len, GFP_KERNEL);
95
96         if (!wl->fw) {
97                 wl1251_error("could not allocate memory for the firmware");
98                 ret = -ENOMEM;
99                 goto out;
100         }
101
102         memcpy(wl->fw, fw->data, wl->fw_len);
103
104         ret = 0;
105
106 out:
107         release_firmware(fw);
108
109         return ret;
110 }
111
112 static int wl1251_fetch_nvs(struct wl1251 *wl)
113 {
114         const struct firmware *fw;
115         int ret;
116
117         ret = request_firmware(&fw, wl->chip.nvs_filename, &wl->spi->dev);
118
119         if (ret < 0) {
120                 wl1251_error("could not get nvs file: %d", ret);
121                 return ret;
122         }
123
124         if (fw->size % 4) {
125                 wl1251_error("nvs size is not multiple of 32 bits: %zu",
126                              fw->size);
127                 ret = -EILSEQ;
128                 goto out;
129         }
130
131         wl->nvs_len = fw->size;
132         wl->nvs = kmalloc(wl->nvs_len, GFP_KERNEL);
133
134         if (!wl->nvs) {
135                 wl1251_error("could not allocate memory for the nvs file");
136                 ret = -ENOMEM;
137                 goto out;
138         }
139
140         memcpy(wl->nvs, fw->data, wl->nvs_len);
141
142         ret = 0;
143
144 out:
145         release_firmware(fw);
146
147         return ret;
148 }
149
150 static void wl1251_fw_wakeup(struct wl1251 *wl)
151 {
152         u32 elp_reg;
153
154         elp_reg = ELPCTRL_WAKE_UP;
155         wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
156         elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
157
158         if (!(elp_reg & ELPCTRL_WLAN_READY))
159                 wl1251_warning("WLAN not ready");
160 }
161
162 static int wl1251_chip_wakeup(struct wl1251 *wl)
163 {
164         int ret = 0;
165
166         wl1251_power_on(wl);
167         msleep(wl->chip.power_on_sleep);
168         wl1251_spi_reset(wl);
169         wl1251_spi_init(wl);
170
171         /* We don't need a real memory partition here, because we only want
172          * to use the registers at this point. */
173         wl1251_set_partition(wl,
174                              0x00000000,
175                              0x00000000,
176                              REGISTERS_BASE,
177                              REGISTERS_DOWN_SIZE);
178
179         /* ELP module wake up */
180         wl1251_fw_wakeup(wl);
181
182         /* whal_FwCtrl_BootSm() */
183
184         /* 0. read chip id from CHIP_ID */
185         wl->chip.id = wl1251_reg_read32(wl, CHIP_ID_B);
186
187         /* 1. check if chip id is valid */
188
189         switch (wl->chip.id) {
190         case CHIP_ID_1251_PG12:
191                 wl1251_debug(DEBUG_BOOT, "chip id 0x%x (1251 PG12)",
192                              wl->chip.id);
193
194                 wl1251_setup(wl);
195
196                 break;
197         case CHIP_ID_1251_PG10:
198         case CHIP_ID_1251_PG11:
199         default:
200                 wl1251_error("unsupported chip id: 0x%x", wl->chip.id);
201                 ret = -ENODEV;
202                 goto out;
203         }
204
205         if (wl->fw == NULL) {
206                 ret = wl1251_fetch_firmware(wl);
207                 if (ret < 0)
208                         goto out;
209         }
210
211         /* No NVS from netlink, try to get it from the filesystem */
212         if (wl->nvs == NULL) {
213                 ret = wl1251_fetch_nvs(wl);
214                 if (ret < 0)
215                         goto out;
216         }
217
218 out:
219         return ret;
220 }
221
222 static void wl1251_filter_work(struct work_struct *work)
223 {
224         struct wl1251 *wl =
225                 container_of(work, struct wl1251, filter_work);
226         int ret;
227
228         mutex_lock(&wl->mutex);
229
230         if (wl->state == WL1251_STATE_OFF)
231                 goto out;
232
233         ret = wl1251_ps_elp_wakeup(wl);
234         if (ret < 0)
235                 goto out;
236
237         /* FIXME: replace the magic numbers with proper definitions */
238         ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0);
239         if (ret < 0)
240                 goto out_sleep;
241
242 out_sleep:
243         wl1251_ps_elp_sleep(wl);
244
245 out:
246         mutex_unlock(&wl->mutex);
247 }
248
249 static int wl1251_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
250 {
251         struct wl1251 *wl = hw->priv;
252
253         skb_queue_tail(&wl->tx_queue, skb);
254
255         /*
256          * The chip specific setup must run before the first TX packet -
257          * before that, the tx_work will not be initialized!
258          */
259
260         schedule_work(&wl->tx_work);
261
262         /*
263          * The workqueue is slow to process the tx_queue and we need stop
264          * the queue here, otherwise the queue will get too long.
265          */
266         if (skb_queue_len(&wl->tx_queue) >= WL1251_TX_QUEUE_MAX_LENGTH) {
267                 ieee80211_stop_queues(wl->hw);
268
269                 /*
270                  * FIXME: this is racy, the variable is not properly
271                  * protected. Maybe fix this by removing the stupid
272                  * variable altogether and checking the real queue state?
273                  */
274                 wl->tx_queue_stopped = true;
275         }
276
277         return NETDEV_TX_OK;
278 }
279
280 static int wl1251_op_start(struct ieee80211_hw *hw)
281 {
282         struct wl1251 *wl = hw->priv;
283         int ret = 0;
284
285         wl1251_debug(DEBUG_MAC80211, "mac80211 start");
286
287         mutex_lock(&wl->mutex);
288
289         if (wl->state != WL1251_STATE_OFF) {
290                 wl1251_error("cannot start because not in off state: %d",
291                              wl->state);
292                 ret = -EBUSY;
293                 goto out;
294         }
295
296         ret = wl1251_chip_wakeup(wl);
297         if (ret < 0)
298                 goto out;
299
300         ret = wl->chip.op_boot(wl);
301         if (ret < 0)
302                 goto out;
303
304         ret = wl->chip.op_hw_init(wl);
305         if (ret < 0)
306                 goto out;
307
308         ret = wl1251_acx_station_id(wl);
309         if (ret < 0)
310                 goto out;
311
312         wl->state = WL1251_STATE_ON;
313
314         wl1251_info("firmware booted (%s)", wl->chip.fw_ver);
315
316 out:
317         if (ret < 0)
318                 wl1251_power_off(wl);
319
320         mutex_unlock(&wl->mutex);
321
322         return ret;
323 }
324
325 static void wl1251_op_stop(struct ieee80211_hw *hw)
326 {
327         struct wl1251 *wl = hw->priv;
328
329         wl1251_info("down");
330
331         wl1251_debug(DEBUG_MAC80211, "mac80211 stop");
332
333         mutex_lock(&wl->mutex);
334
335         WARN_ON(wl->state != WL1251_STATE_ON);
336
337         if (wl->scanning) {
338                 mutex_unlock(&wl->mutex);
339                 ieee80211_scan_completed(wl->hw, true);
340                 mutex_lock(&wl->mutex);
341                 wl->scanning = false;
342         }
343
344         wl->state = WL1251_STATE_OFF;
345
346         wl1251_disable_interrupts(wl);
347
348         mutex_unlock(&wl->mutex);
349
350         cancel_work_sync(&wl->irq_work);
351         cancel_work_sync(&wl->tx_work);
352         cancel_work_sync(&wl->filter_work);
353
354         mutex_lock(&wl->mutex);
355
356         /* let's notify MAC80211 about the remaining pending TX frames */
357         wl->chip.op_tx_flush(wl);
358         wl1251_power_off(wl);
359
360         memset(wl->bssid, 0, ETH_ALEN);
361         wl->listen_int = 1;
362         wl->bss_type = MAX_BSS_TYPE;
363
364         wl->data_in_count = 0;
365         wl->rx_counter = 0;
366         wl->rx_handled = 0;
367         wl->rx_current_buffer = 0;
368         wl->rx_last_id = 0;
369         wl->next_tx_complete = 0;
370         wl->elp = false;
371         wl->psm = 0;
372         wl->tx_queue_stopped = false;
373         wl->power_level = WL1251_DEFAULT_POWER_LEVEL;
374
375         wl1251_debugfs_reset(wl);
376
377         mutex_unlock(&wl->mutex);
378 }
379
380 static int wl1251_op_add_interface(struct ieee80211_hw *hw,
381                                    struct ieee80211_if_init_conf *conf)
382 {
383         struct wl1251 *wl = hw->priv;
384         int ret = 0;
385
386         wl1251_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM",
387                      conf->type, conf->mac_addr);
388
389         mutex_lock(&wl->mutex);
390
391         switch (conf->type) {
392         case NL80211_IFTYPE_STATION:
393                 wl->bss_type = BSS_TYPE_STA_BSS;
394                 break;
395         case NL80211_IFTYPE_ADHOC:
396                 wl->bss_type = BSS_TYPE_IBSS;
397                 break;
398         default:
399                 ret = -EOPNOTSUPP;
400                 goto out;
401         }
402
403         if (memcmp(wl->mac_addr, conf->mac_addr, ETH_ALEN)) {
404                 memcpy(wl->mac_addr, conf->mac_addr, ETH_ALEN);
405                 SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
406                 ret = wl1251_acx_station_id(wl);
407                 if (ret < 0)
408                         goto out;
409         }
410
411 out:
412         mutex_unlock(&wl->mutex);
413         return ret;
414 }
415
416 static void wl1251_op_remove_interface(struct ieee80211_hw *hw,
417                                          struct ieee80211_if_init_conf *conf)
418 {
419         wl1251_debug(DEBUG_MAC80211, "mac80211 remove interface");
420 }
421
422 static int wl1251_build_null_data(struct wl1251 *wl)
423 {
424         struct wl12xx_null_data_template template;
425
426         if (!is_zero_ether_addr(wl->bssid)) {
427                 memcpy(template.header.da, wl->bssid, ETH_ALEN);
428                 memcpy(template.header.bssid, wl->bssid, ETH_ALEN);
429         } else {
430                 memset(template.header.da, 0xff, ETH_ALEN);
431                 memset(template.header.bssid, 0xff, ETH_ALEN);
432         }
433
434         memcpy(template.header.sa, wl->mac_addr, ETH_ALEN);
435         template.header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
436                                                 IEEE80211_STYPE_NULLFUNC);
437
438         return wl1251_cmd_template_set(wl, CMD_NULL_DATA, &template,
439                                        sizeof(template));
440
441 }
442
443 static int wl1251_build_ps_poll(struct wl1251 *wl, u16 aid)
444 {
445         struct wl12xx_ps_poll_template template;
446
447         memcpy(template.bssid, wl->bssid, ETH_ALEN);
448         memcpy(template.ta, wl->mac_addr, ETH_ALEN);
449         template.aid = aid;
450         template.fc = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
451
452         return wl1251_cmd_template_set(wl, CMD_PS_POLL, &template,
453                                        sizeof(template));
454
455 }
456
457 static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed)
458 {
459         struct wl1251 *wl = hw->priv;
460         struct ieee80211_conf *conf = &hw->conf;
461         int channel, ret = 0;
462
463         channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
464
465         wl1251_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d",
466                      channel,
467                      conf->flags & IEEE80211_CONF_PS ? "on" : "off",
468                      conf->power_level);
469
470         mutex_lock(&wl->mutex);
471
472         ret = wl1251_ps_elp_wakeup(wl);
473         if (ret < 0)
474                 goto out;
475
476         if (channel != wl->channel) {
477                 /* FIXME: use beacon interval provided by mac80211 */
478                 ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0);
479                 if (ret < 0)
480                         goto out_sleep;
481
482                 wl->channel = channel;
483         }
484
485         ret = wl1251_build_null_data(wl);
486         if (ret < 0)
487                 goto out_sleep;
488
489         if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) {
490                 wl1251_debug(DEBUG_PSM, "psm enabled");
491
492                 wl->psm_requested = true;
493
494                 /*
495                  * We enter PSM only if we're already associated.
496                  * If we're not, we'll enter it when joining an SSID,
497                  * through the bss_info_changed() hook.
498                  */
499                 ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE);
500         } else if (!(conf->flags & IEEE80211_CONF_PS) &&
501                    wl->psm_requested) {
502                 wl1251_debug(DEBUG_PSM, "psm disabled");
503
504                 wl->psm_requested = false;
505
506                 if (wl->psm)
507                         ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE);
508         }
509
510         if (conf->power_level != wl->power_level) {
511                 ret = wl1251_acx_tx_power(wl, conf->power_level);
512                 if (ret < 0)
513                         goto out;
514
515                 wl->power_level = conf->power_level;
516         }
517
518 out_sleep:
519         wl1251_ps_elp_sleep(wl);
520
521 out:
522         mutex_unlock(&wl->mutex);
523
524         return ret;
525 }
526
527 #define WL1251_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \
528                                   FIF_ALLMULTI | \
529                                   FIF_FCSFAIL | \
530                                   FIF_BCN_PRBRESP_PROMISC | \
531                                   FIF_CONTROL | \
532                                   FIF_OTHER_BSS)
533
534 static void wl1251_op_configure_filter(struct ieee80211_hw *hw,
535                                        unsigned int changed,
536                                        unsigned int *total,
537                                        int mc_count,
538                                        struct dev_addr_list *mc_list)
539 {
540         struct wl1251 *wl = hw->priv;
541
542         wl1251_debug(DEBUG_MAC80211, "mac80211 configure filter");
543
544         *total &= WL1251_SUPPORTED_FILTERS;
545         changed &= WL1251_SUPPORTED_FILTERS;
546
547         if (changed == 0)
548                 /* no filters which we support changed */
549                 return;
550
551         /* FIXME: wl->rx_config and wl->rx_filter are not protected */
552
553         wl->rx_config = WL1251_DEFAULT_RX_CONFIG;
554         wl->rx_filter = WL1251_DEFAULT_RX_FILTER;
555
556         if (*total & FIF_PROMISC_IN_BSS) {
557                 wl->rx_config |= CFG_BSSID_FILTER_EN;
558                 wl->rx_config |= CFG_RX_ALL_GOOD;
559         }
560         if (*total & FIF_ALLMULTI)
561                 /*
562                  * CFG_MC_FILTER_EN in rx_config needs to be 0 to receive
563                  * all multicast frames
564                  */
565                 wl->rx_config &= ~CFG_MC_FILTER_EN;
566         if (*total & FIF_FCSFAIL)
567                 wl->rx_filter |= CFG_RX_FCS_ERROR;
568         if (*total & FIF_BCN_PRBRESP_PROMISC) {
569                 wl->rx_config &= ~CFG_BSSID_FILTER_EN;
570                 wl->rx_config &= ~CFG_SSID_FILTER_EN;
571         }
572         if (*total & FIF_CONTROL)
573                 wl->rx_filter |= CFG_RX_CTL_EN;
574         if (*total & FIF_OTHER_BSS)
575                 wl->rx_filter &= ~CFG_BSSID_FILTER_EN;
576
577         /*
578          * FIXME: workqueues need to be properly cancelled on stop(), for
579          * now let's just disable changing the filter settings. They will
580          * be updated any on config().
581          */
582         /* schedule_work(&wl->filter_work); */
583 }
584
585 /* HW encryption */
586 static int wl1251_set_key_type(struct wl1251 *wl,
587                                struct wl1251_cmd_set_keys *key,
588                                enum set_key_cmd cmd,
589                                struct ieee80211_key_conf *mac80211_key,
590                                const u8 *addr)
591 {
592         switch (mac80211_key->alg) {
593         case ALG_WEP:
594                 if (is_broadcast_ether_addr(addr))
595                         key->key_type = KEY_WEP_DEFAULT;
596                 else
597                         key->key_type = KEY_WEP_ADDR;
598
599                 mac80211_key->hw_key_idx = mac80211_key->keyidx;
600                 break;
601         case ALG_TKIP:
602                 if (is_broadcast_ether_addr(addr))
603                         key->key_type = KEY_TKIP_MIC_GROUP;
604                 else
605                         key->key_type = KEY_TKIP_MIC_PAIRWISE;
606
607                 mac80211_key->hw_key_idx = mac80211_key->keyidx;
608                 break;
609         case ALG_CCMP:
610                 if (is_broadcast_ether_addr(addr))
611                         key->key_type = KEY_AES_GROUP;
612                 else
613                         key->key_type = KEY_AES_PAIRWISE;
614                 mac80211_key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
615                 break;
616         default:
617                 wl1251_error("Unknown key algo 0x%x", mac80211_key->alg);
618                 return -EOPNOTSUPP;
619         }
620
621         return 0;
622 }
623
624 static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
625                              struct ieee80211_vif *vif,
626                              struct ieee80211_sta *sta,
627                              struct ieee80211_key_conf *key)
628 {
629         struct wl1251 *wl = hw->priv;
630         struct wl1251_cmd_set_keys *wl_cmd;
631         const u8 *addr;
632         int ret;
633
634         static const u8 bcast_addr[ETH_ALEN] =
635                 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
636
637         wl1251_debug(DEBUG_MAC80211, "mac80211 set key");
638
639         wl_cmd = kzalloc(sizeof(*wl_cmd), GFP_KERNEL);
640         if (!wl_cmd) {
641                 ret = -ENOMEM;
642                 goto out;
643         }
644
645         addr = sta ? sta->addr : bcast_addr;
646
647         wl1251_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd);
648         wl1251_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN);
649         wl1251_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x",
650                      key->alg, key->keyidx, key->keylen, key->flags);
651         wl1251_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen);
652
653         if (is_zero_ether_addr(addr)) {
654                 /* We dont support TX only encryption */
655                 ret = -EOPNOTSUPP;
656                 goto out;
657         }
658
659         mutex_lock(&wl->mutex);
660
661         ret = wl1251_ps_elp_wakeup(wl);
662         if (ret < 0)
663                 goto out_unlock;
664
665         switch (cmd) {
666         case SET_KEY:
667                 wl_cmd->key_action = KEY_ADD_OR_REPLACE;
668                 break;
669         case DISABLE_KEY:
670                 wl_cmd->key_action = KEY_REMOVE;
671                 break;
672         default:
673                 wl1251_error("Unsupported key cmd 0x%x", cmd);
674                 break;
675         }
676
677         ret = wl1251_set_key_type(wl, wl_cmd, cmd, key, addr);
678         if (ret < 0) {
679                 wl1251_error("Set KEY type failed");
680                 goto out_sleep;
681         }
682
683         if (wl_cmd->key_type != KEY_WEP_DEFAULT)
684                 memcpy(wl_cmd->addr, addr, ETH_ALEN);
685
686         if ((wl_cmd->key_type == KEY_TKIP_MIC_GROUP) ||
687             (wl_cmd->key_type == KEY_TKIP_MIC_PAIRWISE)) {
688                 /*
689                  * We get the key in the following form:
690                  * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes)
691                  * but the target is expecting:
692                  * TKIP - RX MIC - TX MIC
693                  */
694                 memcpy(wl_cmd->key, key->key, 16);
695                 memcpy(wl_cmd->key + 16, key->key + 24, 8);
696                 memcpy(wl_cmd->key + 24, key->key + 16, 8);
697
698         } else {
699                 memcpy(wl_cmd->key, key->key, key->keylen);
700         }
701         wl_cmd->key_size = key->keylen;
702
703         wl_cmd->id = key->keyidx;
704         wl_cmd->ssid_profile = 0;
705
706         wl1251_dump(DEBUG_CRYPT, "TARGET KEY: ", wl_cmd, sizeof(*wl_cmd));
707
708         ret = wl1251_cmd_send(wl, CMD_SET_KEYS, wl_cmd, sizeof(*wl_cmd));
709         if (ret < 0) {
710                 wl1251_warning("could not set keys");
711                 goto out_sleep;
712         }
713
714 out_sleep:
715         wl1251_ps_elp_sleep(wl);
716
717 out_unlock:
718         mutex_unlock(&wl->mutex);
719
720 out:
721         kfree(wl_cmd);
722
723         return ret;
724 }
725
726 static int wl1251_build_basic_rates(char *rates)
727 {
728         u8 index = 0;
729
730         rates[index++] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB;
731         rates[index++] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_2MB;
732         rates[index++] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB;
733         rates[index++] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB;
734
735         return index;
736 }
737
738 static int wl1251_build_extended_rates(char *rates)
739 {
740         u8 index = 0;
741
742         rates[index++] = IEEE80211_OFDM_RATE_6MB;
743         rates[index++] = IEEE80211_OFDM_RATE_9MB;
744         rates[index++] = IEEE80211_OFDM_RATE_12MB;
745         rates[index++] = IEEE80211_OFDM_RATE_18MB;
746         rates[index++] = IEEE80211_OFDM_RATE_24MB;
747         rates[index++] = IEEE80211_OFDM_RATE_36MB;
748         rates[index++] = IEEE80211_OFDM_RATE_48MB;
749         rates[index++] = IEEE80211_OFDM_RATE_54MB;
750
751         return index;
752 }
753
754
755 static int wl1251_build_probe_req(struct wl1251 *wl, u8 *ssid, size_t ssid_len)
756 {
757         struct wl12xx_probe_req_template template;
758         struct wl12xx_ie_rates *rates;
759         char *ptr;
760         u16 size;
761
762         ptr = (char *)&template;
763         size = sizeof(struct ieee80211_header);
764
765         memset(template.header.da, 0xff, ETH_ALEN);
766         memset(template.header.bssid, 0xff, ETH_ALEN);
767         memcpy(template.header.sa, wl->mac_addr, ETH_ALEN);
768         template.header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ);
769
770         /* IEs */
771         /* SSID */
772         template.ssid.header.id = WLAN_EID_SSID;
773         template.ssid.header.len = ssid_len;
774         if (ssid_len && ssid)
775                 memcpy(template.ssid.ssid, ssid, ssid_len);
776         size += sizeof(struct wl12xx_ie_header) + ssid_len;
777         ptr += size;
778
779         /* Basic Rates */
780         rates = (struct wl12xx_ie_rates *)ptr;
781         rates->header.id = WLAN_EID_SUPP_RATES;
782         rates->header.len = wl1251_build_basic_rates(rates->rates);
783         size += sizeof(struct wl12xx_ie_header) + rates->header.len;
784         ptr += sizeof(struct wl12xx_ie_header) + rates->header.len;
785
786         /* Extended rates */
787         rates = (struct wl12xx_ie_rates *)ptr;
788         rates->header.id = WLAN_EID_EXT_SUPP_RATES;
789         rates->header.len = wl1251_build_extended_rates(rates->rates);
790         size += sizeof(struct wl12xx_ie_header) + rates->header.len;
791
792         wl1251_dump(DEBUG_SCAN, "PROBE REQ: ", &template, size);
793
794         return wl1251_cmd_template_set(wl, CMD_PROBE_REQ, &template,
795                                       size);
796 }
797
798 static int wl1251_hw_scan(struct wl1251 *wl, u8 *ssid, size_t len,
799                           u8 active_scan, u8 high_prio, u8 num_channels,
800                           u8 probe_requests)
801 {
802         struct wl1251_cmd_trigger_scan_to *trigger = NULL;
803         struct cmd_scan *params = NULL;
804         int i, ret;
805         u16 scan_options = 0;
806
807         if (wl->scanning)
808                 return -EINVAL;
809
810         params = kzalloc(sizeof(*params), GFP_KERNEL);
811         if (!params)
812                 return -ENOMEM;
813
814         params->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD);
815         params->params.rx_filter_options =
816                 cpu_to_le32(CFG_RX_PRSP_EN | CFG_RX_MGMT_EN | CFG_RX_BCN_EN);
817
818         /* High priority scan */
819         if (!active_scan)
820                 scan_options |= SCAN_PASSIVE;
821         if (high_prio)
822                 scan_options |= SCAN_PRIORITY_HIGH;
823         params->params.scan_options = scan_options;
824
825         params->params.num_channels = num_channels;
826         params->params.num_probe_requests = probe_requests;
827         params->params.tx_rate = cpu_to_le16(1 << 1); /* 2 Mbps */
828         params->params.tid_trigger = 0;
829
830         for (i = 0; i < num_channels; i++) {
831                 params->channels[i].min_duration = cpu_to_le32(30000);
832                 params->channels[i].max_duration = cpu_to_le32(60000);
833                 memset(&params->channels[i].bssid_lsb, 0xff, 4);
834                 memset(&params->channels[i].bssid_msb, 0xff, 2);
835                 params->channels[i].early_termination = 0;
836                 params->channels[i].tx_power_att = 0;
837                 params->channels[i].channel = i + 1;
838                 memset(params->channels[i].pad, 0, 3);
839         }
840
841         for (i = num_channels; i < SCAN_MAX_NUM_OF_CHANNELS; i++)
842                 memset(&params->channels[i], 0,
843                        sizeof(struct basic_scan_channel_parameters));
844
845         if (len && ssid) {
846                 params->params.ssid_len = len;
847                 memcpy(params->params.ssid, ssid, len);
848         } else {
849                 params->params.ssid_len = 0;
850                 memset(params->params.ssid, 0, 32);
851         }
852
853         ret = wl1251_build_probe_req(wl, ssid, len);
854         if (ret < 0) {
855                 wl1251_error("PROBE request template failed");
856                 goto out;
857         }
858
859         trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
860         if (!trigger)
861                 goto out;
862
863         trigger->timeout = 0;
864
865         ret = wl1251_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
866                               sizeof(*trigger));
867         if (ret < 0) {
868                 wl1251_error("trigger scan to failed for hw scan");
869                 goto out;
870         }
871
872         wl1251_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params));
873
874         wl->scanning = true;
875
876         ret = wl1251_cmd_send(wl, CMD_SCAN, params, sizeof(*params));
877         if (ret < 0)
878                 wl1251_error("SCAN failed");
879
880         wl1251_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params));
881
882         if (params->header.status != CMD_STATUS_SUCCESS) {
883                 wl1251_error("TEST command answer error: %d",
884                              params->header.status);
885                 wl->scanning = false;
886                 ret = -EIO;
887                 goto out;
888         }
889
890 out:
891         kfree(params);
892         return ret;
893
894 }
895
896 static int wl1251_op_hw_scan(struct ieee80211_hw *hw,
897                              struct cfg80211_scan_request *req)
898 {
899         struct wl1251 *wl = hw->priv;
900         int ret;
901         u8 *ssid = NULL;
902         size_t ssid_len = 0;
903
904         wl1251_debug(DEBUG_MAC80211, "mac80211 hw scan");
905
906         if (req->n_ssids) {
907                 ssid = req->ssids[0].ssid;
908                 ssid_len = req->ssids[0].ssid_len;
909         }
910
911         mutex_lock(&wl->mutex);
912
913         ret = wl1251_ps_elp_wakeup(wl);
914         if (ret < 0)
915                 goto out;
916
917         ret = wl1251_hw_scan(hw->priv, ssid, ssid_len, 1, 0, 13, 3);
918
919         wl1251_ps_elp_sleep(wl);
920
921 out:
922         mutex_unlock(&wl->mutex);
923
924         return ret;
925 }
926
927 static int wl1251_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
928 {
929         struct wl1251 *wl = hw->priv;
930         int ret;
931
932         mutex_lock(&wl->mutex);
933
934         ret = wl1251_ps_elp_wakeup(wl);
935         if (ret < 0)
936                 goto out;
937
938         ret = wl1251_acx_rts_threshold(wl, (u16) value);
939         if (ret < 0)
940                 wl1251_warning("wl1251_op_set_rts_threshold failed: %d", ret);
941
942         wl1251_ps_elp_sleep(wl);
943
944 out:
945         mutex_unlock(&wl->mutex);
946
947         return ret;
948 }
949
950 static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
951                                        struct ieee80211_vif *vif,
952                                        struct ieee80211_bss_conf *bss_conf,
953                                        u32 changed)
954 {
955         enum wl1251_cmd_ps_mode mode;
956         struct wl1251 *wl = hw->priv;
957         struct sk_buff *beacon;
958         int ret;
959
960         wl1251_debug(DEBUG_MAC80211, "mac80211 bss info changed");
961
962         mutex_lock(&wl->mutex);
963
964         ret = wl1251_ps_elp_wakeup(wl);
965         if (ret < 0)
966                 goto out;
967
968         if (changed & BSS_CHANGED_ASSOC) {
969                 if (bss_conf->assoc) {
970                         wl->aid = bss_conf->aid;
971
972                         ret = wl1251_build_ps_poll(wl, wl->aid);
973                         if (ret < 0)
974                                 goto out_sleep;
975
976                         ret = wl1251_acx_aid(wl, wl->aid);
977                         if (ret < 0)
978                                 goto out_sleep;
979
980                         /* If we want to go in PSM but we're not there yet */
981                         if (wl->psm_requested && !wl->psm) {
982                                 mode = STATION_POWER_SAVE_MODE;
983                                 ret = wl1251_ps_set_mode(wl, mode);
984                                 if (ret < 0)
985                                         goto out_sleep;
986                         }
987                 }
988         }
989         if (changed & BSS_CHANGED_ERP_SLOT) {
990                 if (bss_conf->use_short_slot)
991                         ret = wl1251_acx_slot(wl, SLOT_TIME_SHORT);
992                 else
993                         ret = wl1251_acx_slot(wl, SLOT_TIME_LONG);
994                 if (ret < 0) {
995                         wl1251_warning("Set slot time failed %d", ret);
996                         goto out_sleep;
997                 }
998         }
999
1000         if (changed & BSS_CHANGED_ERP_PREAMBLE) {
1001                 if (bss_conf->use_short_preamble)
1002                         wl1251_acx_set_preamble(wl, ACX_PREAMBLE_SHORT);
1003                 else
1004                         wl1251_acx_set_preamble(wl, ACX_PREAMBLE_LONG);
1005         }
1006
1007         if (changed & BSS_CHANGED_ERP_CTS_PROT) {
1008                 if (bss_conf->use_cts_prot)
1009                         ret = wl1251_acx_cts_protect(wl, CTSPROTECT_ENABLE);
1010                 else
1011                         ret = wl1251_acx_cts_protect(wl, CTSPROTECT_DISABLE);
1012                 if (ret < 0) {
1013                         wl1251_warning("Set ctsprotect failed %d", ret);
1014                         goto out;
1015                 }
1016         }
1017
1018         if (changed & BSS_CHANGED_BSSID) {
1019                 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1020
1021                 ret = wl1251_build_null_data(wl);
1022                 if (ret < 0)
1023                         goto out;
1024
1025                 if (wl->bss_type != BSS_TYPE_IBSS) {
1026                         ret = wl1251_cmd_join(wl, wl->bss_type, 5, 100, 1);
1027                         if (ret < 0)
1028                                 goto out_sleep;
1029                         wl1251_warning("Set ctsprotect failed %d", ret);
1030                         goto out_sleep;
1031                 }
1032         }
1033
1034         if (changed & BSS_CHANGED_BEACON) {
1035                 beacon = ieee80211_beacon_get(hw, vif);
1036                 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data,
1037                                               beacon->len);
1038
1039                 if (ret < 0) {
1040                         dev_kfree_skb(beacon);
1041                         goto out;
1042                 }
1043
1044                 ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, beacon->data,
1045                                               beacon->len);
1046
1047                 dev_kfree_skb(beacon);
1048
1049                 if (ret < 0)
1050                         goto out;
1051
1052                 ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0);
1053
1054                 if (ret < 0)
1055                         goto out;
1056         }
1057
1058 out_sleep:
1059         wl1251_ps_elp_sleep(wl);
1060
1061 out:
1062         mutex_unlock(&wl->mutex);
1063 }
1064
1065
1066 /* can't be const, mac80211 writes to this */
1067 static struct ieee80211_rate wl1251_rates[] = {
1068         { .bitrate = 10,
1069           .hw_value = 0x1,
1070           .hw_value_short = 0x1, },
1071         { .bitrate = 20,
1072           .hw_value = 0x2,
1073           .hw_value_short = 0x2,
1074           .flags = IEEE80211_RATE_SHORT_PREAMBLE },
1075         { .bitrate = 55,
1076           .hw_value = 0x4,
1077           .hw_value_short = 0x4,
1078           .flags = IEEE80211_RATE_SHORT_PREAMBLE },
1079         { .bitrate = 110,
1080           .hw_value = 0x20,
1081           .hw_value_short = 0x20,
1082           .flags = IEEE80211_RATE_SHORT_PREAMBLE },
1083         { .bitrate = 60,
1084           .hw_value = 0x8,
1085           .hw_value_short = 0x8, },
1086         { .bitrate = 90,
1087           .hw_value = 0x10,
1088           .hw_value_short = 0x10, },
1089         { .bitrate = 120,
1090           .hw_value = 0x40,
1091           .hw_value_short = 0x40, },
1092         { .bitrate = 180,
1093           .hw_value = 0x80,
1094           .hw_value_short = 0x80, },
1095         { .bitrate = 240,
1096           .hw_value = 0x200,
1097           .hw_value_short = 0x200, },
1098         { .bitrate = 360,
1099          .hw_value = 0x400,
1100          .hw_value_short = 0x400, },
1101         { .bitrate = 480,
1102           .hw_value = 0x800,
1103           .hw_value_short = 0x800, },
1104         { .bitrate = 540,
1105           .hw_value = 0x1000,
1106           .hw_value_short = 0x1000, },
1107 };
1108
1109 /* can't be const, mac80211 writes to this */
1110 static struct ieee80211_channel wl1251_channels[] = {
1111         { .hw_value = 1, .center_freq = 2412},
1112         { .hw_value = 2, .center_freq = 2417},
1113         { .hw_value = 3, .center_freq = 2422},
1114         { .hw_value = 4, .center_freq = 2427},
1115         { .hw_value = 5, .center_freq = 2432},
1116         { .hw_value = 6, .center_freq = 2437},
1117         { .hw_value = 7, .center_freq = 2442},
1118         { .hw_value = 8, .center_freq = 2447},
1119         { .hw_value = 9, .center_freq = 2452},
1120         { .hw_value = 10, .center_freq = 2457},
1121         { .hw_value = 11, .center_freq = 2462},
1122         { .hw_value = 12, .center_freq = 2467},
1123         { .hw_value = 13, .center_freq = 2472},
1124 };
1125
1126 /* can't be const, mac80211 writes to this */
1127 static struct ieee80211_supported_band wl1251_band_2ghz = {
1128         .channels = wl1251_channels,
1129         .n_channels = ARRAY_SIZE(wl1251_channels),
1130         .bitrates = wl1251_rates,
1131         .n_bitrates = ARRAY_SIZE(wl1251_rates),
1132 };
1133
1134 static const struct ieee80211_ops wl1251_ops = {
1135         .start = wl1251_op_start,
1136         .stop = wl1251_op_stop,
1137         .add_interface = wl1251_op_add_interface,
1138         .remove_interface = wl1251_op_remove_interface,
1139         .config = wl1251_op_config,
1140         .configure_filter = wl1251_op_configure_filter,
1141         .tx = wl1251_op_tx,
1142         .set_key = wl1251_op_set_key,
1143         .hw_scan = wl1251_op_hw_scan,
1144         .bss_info_changed = wl1251_op_bss_info_changed,
1145         .set_rts_threshold = wl1251_op_set_rts_threshold,
1146 };
1147
1148 static int wl1251_register_hw(struct wl1251 *wl)
1149 {
1150         int ret;
1151
1152         if (wl->mac80211_registered)
1153                 return 0;
1154
1155         SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
1156
1157         ret = ieee80211_register_hw(wl->hw);
1158         if (ret < 0) {
1159                 wl1251_error("unable to register mac80211 hw: %d", ret);
1160                 return ret;
1161         }
1162
1163         wl->mac80211_registered = true;
1164
1165         wl1251_notice("loaded");
1166
1167         return 0;
1168 }
1169
1170 static int wl1251_init_ieee80211(struct wl1251 *wl)
1171 {
1172         /* The tx descriptor buffer and the TKIP space */
1173         wl->hw->extra_tx_headroom = sizeof(struct tx_double_buffer_desc)
1174                 + WL1251_TKIP_IV_SPACE;
1175
1176         /* unit us */
1177         /* FIXME: find a proper value */
1178         wl->hw->channel_change_time = 10000;
1179
1180         wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
1181                 IEEE80211_HW_NOISE_DBM;
1182
1183         wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
1184         wl->hw->wiphy->max_scan_ssids = 1;
1185         wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl1251_band_2ghz;
1186
1187         SET_IEEE80211_DEV(wl->hw, &wl->spi->dev);
1188
1189         return 0;
1190 }
1191
1192 #define WL1251_DEFAULT_CHANNEL 1
1193 static int __devinit wl1251_probe(struct spi_device *spi)
1194 {
1195         struct wl12xx_platform_data *pdata;
1196         struct ieee80211_hw *hw;
1197         struct wl1251 *wl;
1198         int ret, i;
1199         static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
1200
1201         pdata = spi->dev.platform_data;
1202         if (!pdata) {
1203                 wl1251_error("no platform data");
1204                 return -ENODEV;
1205         }
1206
1207         hw = ieee80211_alloc_hw(sizeof(*wl), &wl1251_ops);
1208         if (!hw) {
1209                 wl1251_error("could not alloc ieee80211_hw");
1210                 return -ENOMEM;
1211         }
1212
1213         wl = hw->priv;
1214         memset(wl, 0, sizeof(*wl));
1215
1216         wl->hw = hw;
1217         dev_set_drvdata(&spi->dev, wl);
1218         wl->spi = spi;
1219
1220         wl->data_in_count = 0;
1221
1222         skb_queue_head_init(&wl->tx_queue);
1223
1224         INIT_WORK(&wl->filter_work, wl1251_filter_work);
1225         wl->channel = WL1251_DEFAULT_CHANNEL;
1226         wl->scanning = false;
1227         wl->default_key = 0;
1228         wl->listen_int = 1;
1229         wl->rx_counter = 0;
1230         wl->rx_handled = 0;
1231         wl->rx_current_buffer = 0;
1232         wl->rx_last_id = 0;
1233         wl->rx_config = WL1251_DEFAULT_RX_CONFIG;
1234         wl->rx_filter = WL1251_DEFAULT_RX_FILTER;
1235         wl->elp = false;
1236         wl->psm = 0;
1237         wl->psm_requested = false;
1238         wl->tx_queue_stopped = false;
1239         wl->power_level = WL1251_DEFAULT_POWER_LEVEL;
1240
1241         /* We use the default power on sleep time until we know which chip
1242          * we're using */
1243         wl->chip.power_on_sleep = WL1251_DEFAULT_POWER_ON_SLEEP;
1244
1245         for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
1246                 wl->tx_frames[i] = NULL;
1247
1248         wl->next_tx_complete = 0;
1249
1250         /*
1251          * In case our MAC address is not correctly set,
1252          * we use a random but Nokia MAC.
1253          */
1254         memcpy(wl->mac_addr, nokia_oui, 3);
1255         get_random_bytes(wl->mac_addr + 3, 3);
1256
1257         wl->state = WL1251_STATE_OFF;
1258         mutex_init(&wl->mutex);
1259
1260         wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE;
1261         wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE;
1262
1263         wl->rx_descriptor = kmalloc(sizeof(*wl->rx_descriptor), GFP_KERNEL);
1264         if (!wl->rx_descriptor) {
1265                 wl1251_error("could not allocate memory for rx descriptor");
1266                 ret = -ENOMEM;
1267                 goto out_free;
1268         }
1269
1270         /* This is the only SPI value that we need to set here, the rest
1271          * comes from the board-peripherals file */
1272         spi->bits_per_word = 32;
1273
1274         ret = spi_setup(spi);
1275         if (ret < 0) {
1276                 wl1251_error("spi_setup failed");
1277                 goto out_free;
1278         }
1279
1280         wl->set_power = pdata->set_power;
1281         if (!wl->set_power) {
1282                 wl1251_error("set power function missing in platform data");
1283                 ret = -ENODEV;
1284                 goto out_free;
1285         }
1286
1287         wl->irq = spi->irq;
1288         if (wl->irq < 0) {
1289                 wl1251_error("irq missing in platform data");
1290                 ret = -ENODEV;
1291                 goto out_free;
1292         }
1293
1294         ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl);
1295         if (ret < 0) {
1296                 wl1251_error("request_irq() failed: %d", ret);
1297                 goto out_free;
1298         }
1299
1300         set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
1301
1302         disable_irq(wl->irq);
1303
1304         ret = wl1251_init_ieee80211(wl);
1305         if (ret)
1306                 goto out_irq;
1307
1308         ret = wl1251_register_hw(wl);
1309         if (ret)
1310                 goto out_irq;
1311
1312         wl1251_debugfs_init(wl);
1313
1314         wl1251_notice("initialized");
1315
1316         return 0;
1317
1318  out_irq:
1319         free_irq(wl->irq, wl);
1320
1321  out_free:
1322         kfree(wl->rx_descriptor);
1323         wl->rx_descriptor = NULL;
1324
1325         ieee80211_free_hw(hw);
1326
1327         return ret;
1328 }
1329
1330 static int __devexit wl1251_remove(struct spi_device *spi)
1331 {
1332         struct wl1251 *wl = dev_get_drvdata(&spi->dev);
1333
1334         ieee80211_unregister_hw(wl->hw);
1335
1336         wl1251_debugfs_exit(wl);
1337
1338         free_irq(wl->irq, wl);
1339         kfree(wl->target_mem_map);
1340         kfree(wl->data_path);
1341         kfree(wl->fw);
1342         wl->fw = NULL;
1343         kfree(wl->nvs);
1344         wl->nvs = NULL;
1345
1346         kfree(wl->rx_descriptor);
1347         wl->rx_descriptor = NULL;
1348
1349         ieee80211_free_hw(wl->hw);
1350
1351         return 0;
1352 }
1353
1354
1355 static struct spi_driver wl1251_spi_driver = {
1356         .driver = {
1357                 /* FIXME: use wl12xx name to not break the user space */
1358                 .name           = "wl12xx",
1359                 .bus            = &spi_bus_type,
1360                 .owner          = THIS_MODULE,
1361         },
1362
1363         .probe          = wl1251_probe,
1364         .remove         = __devexit_p(wl1251_remove),
1365 };
1366
1367 static int __init wl1251_init(void)
1368 {
1369         int ret;
1370
1371         ret = spi_register_driver(&wl1251_spi_driver);
1372         if (ret < 0) {
1373                 wl1251_error("failed to register spi driver: %d", ret);
1374                 goto out;
1375         }
1376
1377 out:
1378         return ret;
1379 }
1380
1381 static void __exit wl1251_exit(void)
1382 {
1383         spi_unregister_driver(&wl1251_spi_driver);
1384
1385         wl1251_notice("unloaded");
1386 }
1387
1388 module_init(wl1251_init);
1389 module_exit(wl1251_exit);
1390
1391 MODULE_LICENSE("GPL");
1392 MODULE_AUTHOR("Kalle Valo <Kalle.Valo@nokia.com>, "
1393                 "Luciano Coelho <luciano.coelho@nokia.com>");