blob: 2dbc08331ca95aa6cef445b17232358eb5c3d1a8 [file] [log] [blame]
Luciano Coelhof5fc0f82009-08-06 16:25:28 +03001/*
2 * This file is part of wl1271
3 *
4 * Copyright (C) 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
24#include <linux/kernel.h>
25#include <linux/module.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090026#include <linux/slab.h>
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030027
Shahar Levi00d20102010-11-08 11:20:10 +000028#include "init.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030029#include "wl12xx_80211.h"
Shahar Levi00d20102010-11-08 11:20:10 +000030#include "acx.h"
31#include "cmd.h"
32#include "reg.h"
Arik Nemtsove0fe3712010-10-16 18:19:53 +020033#include "tx.h"
Shahar Levi48a61472011-03-06 16:32:08 +020034#include "io.h"
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030035
Arik Nemtsove0fe3712010-10-16 18:19:53 +020036int wl1271_sta_init_templates_config(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030037{
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020038 int ret, i;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030039
40 /* send empty templates for fw memory reservation */
41 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL,
Guy Eilamea559b42010-12-09 16:54:59 +020042 WL1271_CMD_TEMPL_MAX_SIZE,
Juuso Oikarinen606c1482010-04-01 11:38:21 +030043 0, WL1271_RATE_AUTOMATIC);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030044 if (ret < 0)
45 return ret;
46
Juuso Oikarinen11eb5422010-08-24 06:28:03 +030047 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
Guy Eilamea559b42010-12-09 16:54:59 +020048 NULL, WL1271_CMD_TEMPL_MAX_SIZE, 0,
Juuso Oikarinen11eb5422010-08-24 06:28:03 +030049 WL1271_RATE_AUTOMATIC);
50 if (ret < 0)
51 return ret;
Teemu Paasikiviabb0b3b2009-10-13 12:47:50 +030052
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030053 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020054 sizeof(struct wl12xx_null_data_template),
Juuso Oikarinen606c1482010-04-01 11:38:21 +030055 0, WL1271_RATE_AUTOMATIC);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030056 if (ret < 0)
57 return ret;
58
59 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020060 sizeof(struct wl12xx_ps_poll_template),
Juuso Oikarinen606c1482010-04-01 11:38:21 +030061 0, WL1271_RATE_AUTOMATIC);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030062 if (ret < 0)
63 return ret;
64
65 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
66 sizeof
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020067 (struct wl12xx_qos_null_data_template),
Juuso Oikarinen606c1482010-04-01 11:38:21 +030068 0, WL1271_RATE_AUTOMATIC);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030069 if (ret < 0)
70 return ret;
71
72 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
73 sizeof
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020074 (struct wl12xx_probe_resp_template),
Juuso Oikarinen606c1482010-04-01 11:38:21 +030075 0, WL1271_RATE_AUTOMATIC);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030076 if (ret < 0)
77 return ret;
78
79 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
80 sizeof
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020081 (struct wl12xx_beacon_template),
Juuso Oikarinen606c1482010-04-01 11:38:21 +030082 0, WL1271_RATE_AUTOMATIC);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +030083 if (ret < 0)
84 return ret;
85
Eliad Pellerc5312772010-12-09 11:31:27 +020086 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, NULL,
87 sizeof
88 (struct wl12xx_arp_rsp_template),
89 0, WL1271_RATE_AUTOMATIC);
90 if (ret < 0)
91 return ret;
92
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020093 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
94 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
Juuso Oikarinen606c1482010-04-01 11:38:21 +030095 WL1271_CMD_TEMPL_MAX_SIZE, i,
96 WL1271_RATE_AUTOMATIC);
Juuso Oikarinenbfb24c92010-03-26 12:53:31 +020097 if (ret < 0)
98 return ret;
99 }
100
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300101 return 0;
102}
103
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200104static int wl1271_ap_init_deauth_template(struct wl1271 *wl)
105{
106 struct wl12xx_disconn_template *tmpl;
107 int ret;
108
109 tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL);
110 if (!tmpl) {
111 ret = -ENOMEM;
112 goto out;
113 }
114
115 tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
116 IEEE80211_STYPE_DEAUTH);
117
118 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP,
119 tmpl, sizeof(*tmpl), 0,
120 wl1271_tx_min_rate_get(wl));
121
122out:
123 kfree(tmpl);
124 return ret;
125}
126
127static int wl1271_ap_init_null_template(struct wl1271 *wl)
128{
129 struct ieee80211_hdr_3addr *nullfunc;
130 int ret;
131
132 nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL);
133 if (!nullfunc) {
134 ret = -ENOMEM;
135 goto out;
136 }
137
138 nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
139 IEEE80211_STYPE_NULLFUNC |
140 IEEE80211_FCTL_FROMDS);
141
142 /* nullfunc->addr1 is filled by FW */
143
144 memcpy(nullfunc->addr2, wl->mac_addr, ETH_ALEN);
145 memcpy(nullfunc->addr3, wl->mac_addr, ETH_ALEN);
146
147 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc,
148 sizeof(*nullfunc), 0,
149 wl1271_tx_min_rate_get(wl));
150
151out:
152 kfree(nullfunc);
153 return ret;
154}
155
156static int wl1271_ap_init_qos_null_template(struct wl1271 *wl)
157{
158 struct ieee80211_qos_hdr *qosnull;
159 int ret;
160
161 qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL);
162 if (!qosnull) {
163 ret = -ENOMEM;
164 goto out;
165 }
166
167 qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
168 IEEE80211_STYPE_QOS_NULLFUNC |
169 IEEE80211_FCTL_FROMDS);
170
171 /* qosnull->addr1 is filled by FW */
172
173 memcpy(qosnull->addr2, wl->mac_addr, ETH_ALEN);
174 memcpy(qosnull->addr3, wl->mac_addr, ETH_ALEN);
175
176 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull,
177 sizeof(*qosnull), 0,
178 wl1271_tx_min_rate_get(wl));
179
180out:
181 kfree(qosnull);
182 return ret;
183}
184
185static int wl1271_ap_init_templates_config(struct wl1271 *wl)
186{
187 int ret;
188
189 /*
190 * Put very large empty placeholders for all templates. These
191 * reserve memory for later.
192 */
193 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
194 sizeof
195 (struct wl12xx_probe_resp_template),
196 0, WL1271_RATE_AUTOMATIC);
197 if (ret < 0)
198 return ret;
199
200 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
201 sizeof
202 (struct wl12xx_beacon_template),
203 0, WL1271_RATE_AUTOMATIC);
204 if (ret < 0)
205 return ret;
206
207 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
208 sizeof
209 (struct wl12xx_disconn_template),
210 0, WL1271_RATE_AUTOMATIC);
211 if (ret < 0)
212 return ret;
213
214 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
215 sizeof(struct wl12xx_null_data_template),
216 0, WL1271_RATE_AUTOMATIC);
217 if (ret < 0)
218 return ret;
219
220 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
221 sizeof
222 (struct wl12xx_qos_null_data_template),
223 0, WL1271_RATE_AUTOMATIC);
224 if (ret < 0)
225 return ret;
226
227 return 0;
228}
229
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300230static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
231{
232 int ret;
233
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +0300234 ret = wl1271_acx_rx_msdu_life_time(wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300235 if (ret < 0)
236 return ret;
237
238 ret = wl1271_acx_rx_config(wl, config, filter);
239 if (ret < 0)
240 return ret;
241
242 return 0;
243}
244
Luciano Coelho12419cc2010-02-18 13:25:44 +0200245int wl1271_init_phy_config(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300246{
247 int ret;
248
249 ret = wl1271_acx_pd_threshold(wl);
250 if (ret < 0)
251 return ret;
252
253 ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
254 if (ret < 0)
255 return ret;
256
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300257 ret = wl1271_acx_service_period_timeout(wl);
258 if (ret < 0)
259 return ret;
260
Juuso Oikarinen8793f9b2009-10-13 12:47:40 +0300261 ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300262 if (ret < 0)
263 return ret;
264
265 return 0;
266}
267
268static int wl1271_init_beacon_filter(struct wl1271 *wl)
269{
270 int ret;
271
Juuso Oikarinen19221672009-10-08 21:56:35 +0300272 /* disable beacon filtering at this stage */
273 ret = wl1271_acx_beacon_filter_opt(wl, false);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300274 if (ret < 0)
275 return ret;
276
277 ret = wl1271_acx_beacon_filter_table(wl);
278 if (ret < 0)
279 return ret;
280
281 return 0;
282}
283
Luciano Coelho12419cc2010-02-18 13:25:44 +0200284int wl1271_init_pta(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300285{
286 int ret;
287
Juuso Oikarinen1b00f542010-03-18 12:26:30 +0200288 ret = wl1271_acx_sg_cfg(wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300289 if (ret < 0)
290 return ret;
291
Juuso Oikarinen7fc3a862010-03-18 12:26:32 +0200292 ret = wl1271_acx_sg_enable(wl, wl->sg_enabled);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300293 if (ret < 0)
294 return ret;
295
296 return 0;
297}
298
Luciano Coelho12419cc2010-02-18 13:25:44 +0200299int wl1271_init_energy_detection(struct wl1271 *wl)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300300{
301 int ret;
302
303 ret = wl1271_acx_cca_threshold(wl);
304 if (ret < 0)
305 return ret;
306
307 return 0;
308}
309
310static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
311{
312 int ret;
313
314 ret = wl1271_acx_bcn_dtim_options(wl);
315 if (ret < 0)
316 return ret;
317
318 return 0;
319}
320
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200321static int wl1271_sta_hw_init(struct wl1271 *wl)
322{
323 int ret;
324
Shahar Levi49d750ca2011-03-06 16:32:09 +0200325 if (wl->chip.id != CHIP_ID_1283_PG20) {
326 ret = wl1271_cmd_ext_radio_parms(wl);
327 if (ret < 0)
328 return ret;
329 }
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200330
Eliad Pellerc8bde242011-02-02 09:59:35 +0200331 /* PS config */
332 ret = wl1271_acx_config_ps(wl);
333 if (ret < 0)
334 return ret;
335
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200336 ret = wl1271_sta_init_templates_config(wl);
337 if (ret < 0)
338 return ret;
339
340 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
341 if (ret < 0)
342 return ret;
343
344 /* Initialize connection monitoring thresholds */
345 ret = wl1271_acx_conn_monit_params(wl, false);
346 if (ret < 0)
347 return ret;
348
349 /* Beacon filtering */
350 ret = wl1271_init_beacon_filter(wl);
351 if (ret < 0)
352 return ret;
353
354 /* Bluetooth WLAN coexistence */
355 ret = wl1271_init_pta(wl);
356 if (ret < 0)
357 return ret;
358
359 /* Beacons and broadcast settings */
360 ret = wl1271_init_beacon_broadcast(wl);
361 if (ret < 0)
362 return ret;
363
364 /* Configure for ELP power saving */
365 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
366 if (ret < 0)
367 return ret;
368
369 /* Configure rssi/snr averaging weights */
370 ret = wl1271_acx_rssi_snr_avg_weights(wl);
371 if (ret < 0)
372 return ret;
373
374 ret = wl1271_acx_sta_rate_policies(wl);
375 if (ret < 0)
376 return ret;
377
Eliad Pellerc8bde242011-02-02 09:59:35 +0200378 ret = wl1271_acx_sta_mem_cfg(wl);
379 if (ret < 0)
380 return ret;
381
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200382 return 0;
383}
384
385static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl)
386{
387 int ret, i;
388
389 ret = wl1271_cmd_set_sta_default_wep_key(wl, wl->default_key);
390 if (ret < 0) {
391 wl1271_warning("couldn't set default key");
392 return ret;
393 }
394
395 /* disable all keep-alive templates */
396 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
397 ret = wl1271_acx_keep_alive_config(wl, i,
398 ACX_KEEP_ALIVE_TPL_INVALID);
399 if (ret < 0)
400 return ret;
401 }
402
403 /* disable the keep-alive feature */
404 ret = wl1271_acx_keep_alive_mode(wl, false);
405 if (ret < 0)
406 return ret;
407
408 return 0;
409}
410
411static int wl1271_ap_hw_init(struct wl1271 *wl)
412{
413 int ret, i;
414
415 ret = wl1271_ap_init_templates_config(wl);
416 if (ret < 0)
417 return ret;
418
419 /* Configure for power always on */
420 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
421 if (ret < 0)
422 return ret;
423
424 /* Configure initial TX rate classes */
425 for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
426 ret = wl1271_acx_ap_rate_policy(wl,
427 &wl->conf.tx.ap_rc_conf[i], i);
428 if (ret < 0)
429 return ret;
430 }
431
432 ret = wl1271_acx_ap_rate_policy(wl,
433 &wl->conf.tx.ap_mgmt_conf,
434 ACX_TX_AP_MODE_MGMT_RATE);
435 if (ret < 0)
436 return ret;
437
438 ret = wl1271_acx_ap_rate_policy(wl,
439 &wl->conf.tx.ap_bcst_conf,
440 ACX_TX_AP_MODE_BCST_RATE);
441 if (ret < 0)
442 return ret;
443
444 ret = wl1271_acx_max_tx_retry(wl);
445 if (ret < 0)
446 return ret;
447
Eliad Pellerc8bde242011-02-02 09:59:35 +0200448 ret = wl1271_acx_ap_mem_cfg(wl);
449 if (ret < 0)
450 return ret;
451
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200452 return 0;
453}
454
455static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl)
456{
457 int ret;
458
459 ret = wl1271_ap_init_deauth_template(wl);
460 if (ret < 0)
461 return ret;
462
463 ret = wl1271_ap_init_null_template(wl);
464 if (ret < 0)
465 return ret;
466
467 ret = wl1271_ap_init_qos_null_template(wl);
468 if (ret < 0)
469 return ret;
470
471 return 0;
472}
473
Levi, Shahar4b7fac72011-01-23 07:27:22 +0100474static void wl1271_check_ba_support(struct wl1271 *wl)
475{
476 /* validate FW cose ver x.x.x.50-60.x */
477 if ((wl->chip.fw_ver[3] >= WL12XX_BA_SUPPORT_FW_COST_VER2_START) &&
478 (wl->chip.fw_ver[3] < WL12XX_BA_SUPPORT_FW_COST_VER2_END)) {
479 wl->ba_support = true;
480 return;
481 }
482
483 wl->ba_support = false;
484}
485
486static int wl1271_set_ba_policies(struct wl1271 *wl)
487{
488 u8 tid_index;
Dan Carpenter03c5a9c2011-02-07 19:47:42 +0300489 int ret = 0;
Levi, Shahar4b7fac72011-01-23 07:27:22 +0100490
491 /* Reset the BA RX indicators */
Levi, Shahar4b7fac72011-01-23 07:27:22 +0100492 wl->ba_rx_bitmap = 0;
493
494 /* validate that FW support BA */
495 wl1271_check_ba_support(wl);
496
497 if (wl->ba_support)
498 /* 802.11n initiator BA session setting */
499 for (tid_index = 0; tid_index < CONF_TX_MAX_TID_COUNT;
500 ++tid_index) {
501 ret = wl1271_acx_set_ba_session(wl, WLAN_BACK_INITIATOR,
502 tid_index, true);
503 if (ret < 0)
504 break;
505 }
506
507 return ret;
508}
509
Shahar Levi48a61472011-03-06 16:32:08 +0200510int wl1271_chip_specific_init(struct wl1271 *wl)
511{
512 int ret = 0;
513
514 if (wl->chip.id == CHIP_ID_1283_PG20) {
515 u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;
516
517 if (wl1271_set_block_size(wl))
518 /* Enable SDIO padding */
519 host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
520
521 /* Must be before wl1271_acx_init_mem_config() */
522 ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap);
523 if (ret < 0)
524 goto out;
525 }
526out:
527 return ret;
528}
529
530
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300531int wl1271_hw_init(struct wl1271 *wl)
532{
Kalle Valo243eeb52010-02-18 13:25:39 +0200533 struct conf_tx_ac_category *conf_ac;
Kalle Valof2054df2010-02-18 13:25:40 +0200534 struct conf_tx_tid *conf_tid;
Kalle Valo243eeb52010-02-18 13:25:39 +0200535 int ret, i;
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200536 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300537
Shahar Levi49d750ca2011-03-06 16:32:09 +0200538 if (wl->chip.id == CHIP_ID_1283_PG20)
539 ret = wl128x_cmd_general_parms(wl);
540 else
541 ret = wl1271_cmd_general_parms(wl);
Luciano Coelho4a904062009-11-23 23:22:18 +0200542 if (ret < 0)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300543 return ret;
544
Shahar Levi49d750ca2011-03-06 16:32:09 +0200545 if (wl->chip.id == CHIP_ID_1283_PG20)
546 ret = wl128x_cmd_radio_parms(wl);
547 else
548 ret = wl1271_cmd_radio_parms(wl);
Luciano Coelho4a904062009-11-23 23:22:18 +0200549 if (ret < 0)
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300550 return ret;
551
Shahar Levi48a61472011-03-06 16:32:08 +0200552 /* Chip-specific init */
553 ret = wl1271_chip_specific_init(wl);
554 if (ret < 0)
555 return ret;
556
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200557 /* Mode specific init */
558 if (is_ap)
559 ret = wl1271_ap_hw_init(wl);
560 else
561 ret = wl1271_sta_hw_init(wl);
Juuso Oikarinen644a4862010-10-05 13:11:56 +0200562
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300563 if (ret < 0)
564 return ret;
565
566 /* Default memory configuration */
567 ret = wl1271_acx_init_mem_config(wl);
568 if (ret < 0)
569 return ret;
570
571 /* RX config */
572 ret = wl1271_init_rx_config(wl,
Juuso Oikarineneb5b28d2009-10-13 12:47:45 +0300573 RX_CFG_PROMISCUOUS | RX_CFG_TSF,
574 RX_FILTER_OPTION_DEF);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300575 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
576 RX_FILTER_OPTION_FILTER_ALL); */
577 if (ret < 0)
578 goto out_free_memmap;
579
580 /* PHY layer config */
581 ret = wl1271_init_phy_config(wl);
582 if (ret < 0)
583 goto out_free_memmap;
584
Luciano Coelho6e92b412009-12-11 15:40:50 +0200585 ret = wl1271_acx_dco_itrim_params(wl);
586 if (ret < 0)
587 goto out_free_memmap;
588
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300589 /* Configure TX patch complete interrupt behavior */
590 ret = wl1271_acx_tx_config_options(wl);
591 if (ret < 0)
592 goto out_free_memmap;
593
594 /* RX complete interrupt pacing */
595 ret = wl1271_acx_init_rx_interrupt(wl);
596 if (ret < 0)
597 goto out_free_memmap;
598
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300599 /* Energy detection */
600 ret = wl1271_init_energy_detection(wl);
601 if (ret < 0)
602 goto out_free_memmap;
603
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300604 /* Default fragmentation threshold */
Arik Nemtsov68d069c2010-11-08 10:51:07 +0100605 ret = wl1271_acx_frag_threshold(wl, wl->conf.tx.frag_threshold);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300606 if (ret < 0)
607 goto out_free_memmap;
608
Juuso Oikarinen9987a9d2010-09-01 11:31:12 +0200609 /* Default TID/AC configuration */
610 BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
Kalle Valof2054df2010-02-18 13:25:40 +0200611 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
Juuso Oikarinen9987a9d2010-09-01 11:31:12 +0200612 conf_ac = &wl->conf.tx.ac_conf[i];
613 ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
614 conf_ac->cw_max, conf_ac->aifsn,
615 conf_ac->tx_op_limit);
616 if (ret < 0)
617 goto out_free_memmap;
618
Kalle Valof2054df2010-02-18 13:25:40 +0200619 conf_tid = &wl->conf.tx.tid_conf[i];
620 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
621 conf_tid->channel_type,
622 conf_tid->tsid,
623 conf_tid->ps_scheme,
624 conf_tid->ack_policy,
625 conf_tid->apsd_conf[0],
626 conf_tid->apsd_conf[1]);
627 if (ret < 0)
628 goto out_free_memmap;
629 }
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300630
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300631 /* Enable data path */
Luciano Coelho94210892009-12-11 15:40:55 +0200632 ret = wl1271_cmd_data_path(wl, 1);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300633 if (ret < 0)
634 goto out_free_memmap;
635
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300636 /* Configure HW encryption */
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200637 ret = wl1271_acx_feature_cfg(wl);
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300638 if (ret < 0)
639 goto out_free_memmap;
640
Juuso Oikarinen38ad2d82009-12-11 15:41:08 +0200641 /* configure PM */
642 ret = wl1271_acx_pm_config(wl);
643 if (ret < 0)
644 goto out_free_memmap;
645
Arik Nemtsove0fe3712010-10-16 18:19:53 +0200646 /* Mode specific init - post mem init */
647 if (is_ap)
648 ret = wl1271_ap_hw_init_post_mem(wl);
649 else
650 ret = wl1271_sta_hw_init_post_mem(wl);
Juuso Oikarinenc1899552010-03-26 12:53:32 +0200651
Juuso Oikarinen00236aed2010-04-09 11:07:30 +0300652 if (ret < 0)
653 goto out_free_memmap;
654
Levi, Shahar4b7fac72011-01-23 07:27:22 +0100655 /* Configure initiator BA sessions policies */
656 ret = wl1271_set_ba_policies(wl);
657 if (ret < 0)
658 goto out_free_memmap;
659
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300660 return 0;
661
662 out_free_memmap:
663 kfree(wl->target_mem_map);
Juuso Oikarinen34415232009-10-08 21:56:33 +0300664 wl->target_mem_map = NULL;
Luciano Coelhof5fc0f82009-08-06 16:25:28 +0300665
666 return ret;
667}