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>
28 #include "wl1271_init.h"
29 #include "wl12xx_80211.h"
30 #include "wl1271_acx.h"
31 #include "wl1271_cmd.h"
32 #include "wl1271_reg.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)
57 /* send empty templates for fw memory reservation */
58 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL,
59 sizeof(struct wl12xx_probe_req_template));
63 if (wl1271_11a_enabled()) {
64 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
66 sizeof(struct wl12xx_probe_req_template));
71 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
72 sizeof(struct wl12xx_null_data_template));
76 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
77 sizeof(struct wl12xx_ps_poll_template));
81 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
83 (struct wl12xx_qos_null_data_template));
87 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
89 (struct wl12xx_probe_resp_template));
93 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
95 (struct wl12xx_beacon_template));
102 static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
106 ret = wl1271_acx_rx_msdu_life_time(wl);
110 ret = wl1271_acx_rx_config(wl, config, filter);
117 int wl1271_init_phy_config(struct wl1271 *wl)
121 ret = wl1271_acx_pd_threshold(wl);
125 ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
129 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
133 ret = wl1271_acx_service_period_timeout(wl);
137 ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold);
144 static int wl1271_init_beacon_filter(struct wl1271 *wl)
148 /* disable beacon filtering at this stage */
149 ret = wl1271_acx_beacon_filter_opt(wl, false);
153 ret = wl1271_acx_beacon_filter_table(wl);
160 int wl1271_init_pta(struct wl1271 *wl)
164 ret = wl1271_acx_sg_enable(wl);
168 ret = wl1271_acx_sg_cfg(wl);
175 int wl1271_init_energy_detection(struct wl1271 *wl)
179 ret = wl1271_acx_cca_threshold(wl);
186 static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
190 ret = wl1271_acx_bcn_dtim_options(wl);
197 int wl1271_hw_init(struct wl1271 *wl)
199 struct conf_tx_ac_category *conf_ac;
200 struct conf_tx_tid *conf_tid;
203 ret = wl1271_cmd_general_parms(wl);
207 ret = wl1271_cmd_radio_parms(wl);
211 /* Template settings */
212 ret = wl1271_init_templates_config(wl);
216 /* Default memory configuration */
217 ret = wl1271_acx_init_mem_config(wl);
222 ret = wl1271_init_rx_config(wl,
223 RX_CFG_PROMISCUOUS | RX_CFG_TSF,
224 RX_FILTER_OPTION_DEF);
225 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
226 RX_FILTER_OPTION_FILTER_ALL); */
228 goto out_free_memmap;
230 /* PHY layer config */
231 ret = wl1271_init_phy_config(wl);
233 goto out_free_memmap;
235 ret = wl1271_acx_dco_itrim_params(wl);
237 goto out_free_memmap;
239 /* Initialize connection monitoring thresholds */
240 ret = wl1271_acx_conn_monit_params(wl);
242 goto out_free_memmap;
244 /* Beacon filtering */
245 ret = wl1271_init_beacon_filter(wl);
247 goto out_free_memmap;
249 /* Configure TX patch complete interrupt behavior */
250 ret = wl1271_acx_tx_config_options(wl);
252 goto out_free_memmap;
254 /* RX complete interrupt pacing */
255 ret = wl1271_acx_init_rx_interrupt(wl);
257 goto out_free_memmap;
259 /* Bluetooth WLAN coexistence */
260 ret = wl1271_init_pta(wl);
262 goto out_free_memmap;
264 /* Energy detection */
265 ret = wl1271_init_energy_detection(wl);
267 goto out_free_memmap;
269 /* Beacons and boradcast settings */
270 ret = wl1271_init_beacon_broadcast(wl);
272 goto out_free_memmap;
274 /* Default fragmentation threshold */
275 ret = wl1271_acx_frag_threshold(wl);
277 goto out_free_memmap;
279 /* Default TID configuration */
280 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
281 conf_tid = &wl->conf.tx.tid_conf[i];
282 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
283 conf_tid->channel_type,
286 conf_tid->ack_policy,
287 conf_tid->apsd_conf[0],
288 conf_tid->apsd_conf[1]);
290 goto out_free_memmap;
293 /* Default AC configuration */
294 for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
295 conf_ac = &wl->conf.tx.ac_conf[i];
296 ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min,
297 conf_ac->cw_max, conf_ac->aifsn,
298 conf_ac->tx_op_limit);
300 goto out_free_memmap;
303 /* Configure TX rate classes */
304 ret = wl1271_acx_rate_policies(wl);
306 goto out_free_memmap;
308 /* Enable data path */
309 ret = wl1271_cmd_data_path(wl, 1);
311 goto out_free_memmap;
313 /* Configure for ELP power saving */
314 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
316 goto out_free_memmap;
318 /* Configure HW encryption */
319 ret = wl1271_init_hwenc_config(wl);
321 goto out_free_memmap;
324 ret = wl1271_acx_pm_config(wl);
326 goto out_free_memmap;
331 kfree(wl->target_mem_map);
332 wl->target_mem_map = NULL;