2 * This file is part of wl1271
4 * Copyright (C) 2009 Nokia Corporation
6 * Contact: Luciano Coelho <luciano.coelho@nokia.com>
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.
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.
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
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/slab.h>
29 #include "wl12xx_80211.h"
34 static int wl1271_init_hwenc_config(struct wl1271
*wl
)
38 ret
= wl1271_acx_feature_cfg(wl
);
40 wl1271_warning("couldn't set feature config");
44 ret
= wl1271_cmd_set_default_wep_key(wl
, wl
->default_key
);
46 wl1271_warning("couldn't set default key");
53 int wl1271_init_templates_config(struct wl1271
*wl
)
58 /* send empty templates for fw memory reservation */
59 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_CFG_PROBE_REQ_2_4
, NULL
,
60 sizeof(struct wl12xx_probe_req_template
),
61 0, WL1271_RATE_AUTOMATIC
);
65 size
= sizeof(struct wl12xx_probe_req_template
);
66 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_CFG_PROBE_REQ_5
,
68 WL1271_RATE_AUTOMATIC
);
72 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_NULL_DATA
, NULL
,
73 sizeof(struct wl12xx_null_data_template
),
74 0, WL1271_RATE_AUTOMATIC
);
78 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_PS_POLL
, NULL
,
79 sizeof(struct wl12xx_ps_poll_template
),
80 0, WL1271_RATE_AUTOMATIC
);
84 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_QOS_NULL_DATA
, NULL
,
86 (struct wl12xx_qos_null_data_template
),
87 0, WL1271_RATE_AUTOMATIC
);
91 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_PROBE_RESPONSE
, NULL
,
93 (struct wl12xx_probe_resp_template
),
94 0, WL1271_RATE_AUTOMATIC
);
98 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_BEACON
, NULL
,
100 (struct wl12xx_beacon_template
),
101 0, WL1271_RATE_AUTOMATIC
);
105 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_ARP_RSP
, NULL
,
107 (struct wl12xx_arp_rsp_template
),
108 0, WL1271_RATE_AUTOMATIC
);
112 for (i
= 0; i
< CMD_TEMPL_KLV_IDX_MAX
; i
++) {
113 ret
= wl1271_cmd_template_set(wl
, CMD_TEMPL_KLV
, NULL
,
114 WL1271_CMD_TEMPL_MAX_SIZE
, i
,
115 WL1271_RATE_AUTOMATIC
);
123 static int wl1271_init_rx_config(struct wl1271
*wl
, u32 config
, u32 filter
)
127 ret
= wl1271_acx_rx_msdu_life_time(wl
);
131 ret
= wl1271_acx_rx_config(wl
, config
, filter
);
138 int wl1271_init_phy_config(struct wl1271
*wl
)
142 ret
= wl1271_acx_pd_threshold(wl
);
146 ret
= wl1271_acx_slot(wl
, DEFAULT_SLOT_TIME
);
150 ret
= wl1271_acx_group_address_tbl(wl
, true, NULL
, 0);
154 ret
= wl1271_acx_service_period_timeout(wl
);
158 ret
= wl1271_acx_rts_threshold(wl
, wl
->conf
.rx
.rts_threshold
);
165 static int wl1271_init_beacon_filter(struct wl1271
*wl
)
169 /* disable beacon filtering at this stage */
170 ret
= wl1271_acx_beacon_filter_opt(wl
, false);
174 ret
= wl1271_acx_beacon_filter_table(wl
);
181 int wl1271_init_pta(struct wl1271
*wl
)
185 ret
= wl1271_acx_sg_cfg(wl
);
189 ret
= wl1271_acx_sg_enable(wl
, wl
->sg_enabled
);
196 int wl1271_init_energy_detection(struct wl1271
*wl
)
200 ret
= wl1271_acx_cca_threshold(wl
);
207 static int wl1271_init_beacon_broadcast(struct wl1271
*wl
)
211 ret
= wl1271_acx_bcn_dtim_options(wl
);
218 int wl1271_hw_init(struct wl1271
*wl
)
220 struct conf_tx_ac_category
*conf_ac
;
221 struct conf_tx_tid
*conf_tid
;
224 ret
= wl1271_cmd_general_parms(wl
);
228 ret
= wl1271_cmd_radio_parms(wl
);
232 ret
= wl1271_cmd_ext_radio_parms(wl
);
236 /* Template settings */
237 ret
= wl1271_init_templates_config(wl
);
241 /* Default memory configuration */
242 ret
= wl1271_acx_init_mem_config(wl
);
247 ret
= wl1271_init_rx_config(wl
,
248 RX_CFG_PROMISCUOUS
| RX_CFG_TSF
,
249 RX_FILTER_OPTION_DEF
);
250 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
251 RX_FILTER_OPTION_FILTER_ALL); */
253 goto out_free_memmap
;
255 /* PHY layer config */
256 ret
= wl1271_init_phy_config(wl
);
258 goto out_free_memmap
;
260 ret
= wl1271_acx_dco_itrim_params(wl
);
262 goto out_free_memmap
;
264 /* Initialize connection monitoring thresholds */
265 ret
= wl1271_acx_conn_monit_params(wl
, false);
267 goto out_free_memmap
;
269 /* Beacon filtering */
270 ret
= wl1271_init_beacon_filter(wl
);
272 goto out_free_memmap
;
274 /* Configure TX patch complete interrupt behavior */
275 ret
= wl1271_acx_tx_config_options(wl
);
277 goto out_free_memmap
;
279 /* RX complete interrupt pacing */
280 ret
= wl1271_acx_init_rx_interrupt(wl
);
282 goto out_free_memmap
;
284 /* Bluetooth WLAN coexistence */
285 ret
= wl1271_init_pta(wl
);
287 goto out_free_memmap
;
289 /* Energy detection */
290 ret
= wl1271_init_energy_detection(wl
);
292 goto out_free_memmap
;
294 /* Beacons and boradcast settings */
295 ret
= wl1271_init_beacon_broadcast(wl
);
297 goto out_free_memmap
;
299 /* Default fragmentation threshold */
300 ret
= wl1271_acx_frag_threshold(wl
, wl
->conf
.tx
.frag_threshold
);
302 goto out_free_memmap
;
304 /* Default TID/AC configuration */
305 BUG_ON(wl
->conf
.tx
.tid_conf_count
!= wl
->conf
.tx
.ac_conf_count
);
306 for (i
= 0; i
< wl
->conf
.tx
.tid_conf_count
; i
++) {
307 conf_ac
= &wl
->conf
.tx
.ac_conf
[i
];
308 ret
= wl1271_acx_ac_cfg(wl
, conf_ac
->ac
, conf_ac
->cw_min
,
309 conf_ac
->cw_max
, conf_ac
->aifsn
,
310 conf_ac
->tx_op_limit
);
312 goto out_free_memmap
;
314 conf_tid
= &wl
->conf
.tx
.tid_conf
[i
];
315 ret
= wl1271_acx_tid_cfg(wl
, conf_tid
->queue_id
,
316 conf_tid
->channel_type
,
319 conf_tid
->ack_policy
,
320 conf_tid
->apsd_conf
[0],
321 conf_tid
->apsd_conf
[1]);
323 goto out_free_memmap
;
326 /* Configure TX rate classes */
327 ret
= wl1271_acx_rate_policies(wl
);
329 goto out_free_memmap
;
331 /* Enable data path */
332 ret
= wl1271_cmd_data_path(wl
, 1);
334 goto out_free_memmap
;
336 /* Configure for ELP power saving */
337 ret
= wl1271_acx_sleep_auth(wl
, WL1271_PSM_ELP
);
339 goto out_free_memmap
;
341 /* Configure HW encryption */
342 ret
= wl1271_init_hwenc_config(wl
);
344 goto out_free_memmap
;
347 ret
= wl1271_acx_pm_config(wl
);
349 goto out_free_memmap
;
351 /* disable all keep-alive templates */
352 for (i
= 0; i
< CMD_TEMPL_KLV_IDX_MAX
; i
++) {
353 ret
= wl1271_acx_keep_alive_config(wl
, i
,
354 ACX_KEEP_ALIVE_TPL_INVALID
);
356 goto out_free_memmap
;
359 /* disable the keep-alive feature */
360 ret
= wl1271_acx_keep_alive_mode(wl
, false);
362 goto out_free_memmap
;
364 /* Configure rssi/snr averaging weights */
365 ret
= wl1271_acx_rssi_snr_avg_weights(wl
);
367 goto out_free_memmap
;
372 kfree(wl
->target_mem_map
);
373 wl
->target_mem_map
= NULL
;