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>
27 #include "wl1271_init.h"
28 #include "wl12xx_80211.h"
29 #include "wl1271_acx.h"
30 #include "wl1271_cmd.h"
31 #include "wl1271_reg.h"
33 static int wl1271_init_hwenc_config(struct wl1271 *wl)
37 ret = wl1271_acx_feature_cfg(wl);
39 wl1271_warning("couldn't set feature config");
43 ret = wl1271_cmd_set_default_wep_key(wl, wl->default_key);
45 wl1271_warning("couldn't set default key");
52 int wl1271_init_templates_config(struct wl1271 *wl)
56 /* send empty templates for fw memory reservation */
57 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL,
58 sizeof(struct wl12xx_probe_req_template),
63 if (wl1271_11a_enabled()) {
64 size_t size = sizeof(struct wl12xx_probe_req_template);
65 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
71 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
72 sizeof(struct wl12xx_null_data_template),
77 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
78 sizeof(struct wl12xx_ps_poll_template),
83 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
85 (struct wl12xx_qos_null_data_template),
90 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
92 (struct wl12xx_probe_resp_template),
97 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
99 (struct wl12xx_beacon_template),
104 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
105 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
106 WL1271_CMD_TEMPL_MAX_SIZE, i);
114 static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
118 ret = wl1271_acx_rx_msdu_life_time(wl);
122 ret = wl1271_acx_rx_config(wl, config, filter);
129 int wl1271_init_phy_config(struct wl1271 *wl)
133 ret = wl1271_acx_pd_threshold(wl);
137 ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
141 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
145 ret = wl1271_acx_service_period_timeout(wl);
149 ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold);
156 static int wl1271_init_beacon_filter(struct wl1271 *wl)
160 /* disable beacon filtering at this stage */
161 ret = wl1271_acx_beacon_filter_opt(wl, false);
165 ret = wl1271_acx_beacon_filter_table(wl);
172 int wl1271_init_pta(struct wl1271 *wl)
176 ret = wl1271_acx_sg_cfg(wl);
180 ret = wl1271_acx_sg_enable(wl, wl->sg_enabled);
187 int wl1271_init_energy_detection(struct wl1271 *wl)
191 ret = wl1271_acx_cca_threshold(wl);
198 static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
202 ret = wl1271_acx_bcn_dtim_options(wl);
209 int wl1271_hw_init(struct wl1271 *wl)
211 struct conf_tx_ac_category *conf_ac;
212 struct conf_tx_tid *conf_tid;
215 ret = wl1271_cmd_general_parms(wl);
219 ret = wl1271_cmd_radio_parms(wl);
223 /* Template settings */
224 ret = wl1271_init_templates_config(wl);
228 /* Default memory configuration */
229 ret = wl1271_acx_init_mem_config(wl);
234 ret = wl1271_init_rx_config(wl,
235 RX_CFG_PROMISCUOUS | RX_CFG_TSF,
236 RX_FILTER_OPTION_DEF);
237 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
238 RX_FILTER_OPTION_FILTER_ALL); */
240 goto out_free_memmap;
242 /* PHY layer config */
243 ret = wl1271_init_phy_config(wl);
245 goto out_free_memmap;
247 ret = wl1271_acx_dco_itrim_params(wl);
249 goto out_free_memmap;
251 /* Initialize connection monitoring thresholds */
252 ret = wl1271_acx_conn_monit_params(wl, false);
254 goto out_free_memmap;
256 /* Beacon filtering */
257 ret = wl1271_init_beacon_filter(wl);
259 goto out_free_memmap;
261 /* Configure TX patch complete interrupt behavior */
262 ret = wl1271_acx_tx_config_options(wl);
264 goto out_free_memmap;
266 /* RX complete interrupt pacing */
267 ret = wl1271_acx_init_rx_interrupt(wl);
269 goto out_free_memmap;
271 /* Bluetooth WLAN coexistence */
272 ret = wl1271_init_pta(wl);
274 goto out_free_memmap;
276 /* Energy detection */
277 ret = wl1271_init_energy_detection(wl);
279 goto out_free_memmap;
281 /* Beacons and boradcast settings */
282 ret = wl1271_init_beacon_broadcast(wl);
284 goto out_free_memmap;
286 /* Default fragmentation threshold */
287 ret = wl1271_acx_frag_threshold(wl);
289 goto out_free_memmap;
291 /* Default TID configuration */
292 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
293 conf_tid = &wl->conf.tx.tid_conf[i];
294 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
295 conf_tid->channel_type,
298 conf_tid->ack_policy,
299 conf_tid->apsd_conf[0],
300 conf_tid->apsd_conf[1]);
302 goto out_free_memmap;
305 /* Default AC configuration */
306 for (i = 0; i < wl->conf.tx.ac_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;
315 /* Configure TX rate classes */
316 ret = wl1271_acx_rate_policies(wl);
318 goto out_free_memmap;
320 /* Enable data path */
321 ret = wl1271_cmd_data_path(wl, 1);
323 goto out_free_memmap;
325 /* Configure for ELP power saving */
326 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
328 goto out_free_memmap;
330 /* Configure HW encryption */
331 ret = wl1271_init_hwenc_config(wl);
333 goto out_free_memmap;
336 ret = wl1271_acx_pm_config(wl);
338 goto out_free_memmap;
340 /* disable all keep-alive templates */
341 for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
342 ret = wl1271_acx_keep_alive_config(wl, i,
343 ACX_KEEP_ALIVE_TPL_INVALID);
345 goto out_free_memmap;
348 /* disable the keep-alive feature */
349 ret = wl1271_acx_keep_alive_mode(wl, false);
351 goto out_free_memmap;
356 kfree(wl->target_mem_map);
357 wl->target_mem_map = NULL;