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 static 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));
62 if (wl1271_11a_enabled()) {
63 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
65 sizeof(struct wl12xx_probe_req_template));
70 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
71 sizeof(struct wl12xx_null_data_template));
75 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
76 sizeof(struct wl12xx_ps_poll_template));
80 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
82 (struct wl12xx_qos_null_data_template));
86 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
88 (struct wl12xx_probe_resp_template));
92 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
94 (struct wl12xx_beacon_template));
101 static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
105 ret = wl1271_acx_rx_msdu_life_time(wl);
109 ret = wl1271_acx_rx_config(wl, config, filter);
116 static int wl1271_init_phy_config(struct wl1271 *wl)
120 ret = wl1271_acx_pd_threshold(wl);
124 ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
128 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
132 ret = wl1271_acx_service_period_timeout(wl);
136 ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold);
143 static int wl1271_init_beacon_filter(struct wl1271 *wl)
147 /* disable beacon filtering at this stage */
148 ret = wl1271_acx_beacon_filter_opt(wl, false);
152 ret = wl1271_acx_beacon_filter_table(wl);
159 static int wl1271_init_pta(struct wl1271 *wl)
163 ret = wl1271_acx_sg_enable(wl);
167 ret = wl1271_acx_sg_cfg(wl);
174 static int wl1271_init_energy_detection(struct wl1271 *wl)
178 ret = wl1271_acx_cca_threshold(wl);
185 static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
189 ret = wl1271_acx_bcn_dtim_options(wl);
196 int wl1271_hw_init(struct wl1271 *wl)
200 ret = wl1271_cmd_general_parms(wl);
204 ret = wl1271_cmd_radio_parms(wl);
208 /* Template settings */
209 ret = wl1271_init_templates_config(wl);
213 /* Default memory configuration */
214 ret = wl1271_acx_init_mem_config(wl);
219 ret = wl1271_init_rx_config(wl,
220 RX_CFG_PROMISCUOUS | RX_CFG_TSF,
221 RX_FILTER_OPTION_DEF);
222 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
223 RX_FILTER_OPTION_FILTER_ALL); */
225 goto out_free_memmap;
227 /* PHY layer config */
228 ret = wl1271_init_phy_config(wl);
230 goto out_free_memmap;
232 /* Initialize connection monitoring thresholds */
233 ret = wl1271_acx_conn_monit_params(wl);
235 goto out_free_memmap;
237 /* Beacon filtering */
238 ret = wl1271_init_beacon_filter(wl);
240 goto out_free_memmap;
242 /* Configure TX patch complete interrupt behavior */
243 ret = wl1271_acx_tx_config_options(wl);
245 goto out_free_memmap;
247 /* RX complete interrupt pacing */
248 ret = wl1271_acx_init_rx_interrupt(wl);
250 goto out_free_memmap;
252 /* Bluetooth WLAN coexistence */
253 ret = wl1271_init_pta(wl);
255 goto out_free_memmap;
257 /* Energy detection */
258 ret = wl1271_init_energy_detection(wl);
260 goto out_free_memmap;
262 /* Beacons and boradcast settings */
263 ret = wl1271_init_beacon_broadcast(wl);
265 goto out_free_memmap;
267 /* Default fragmentation threshold */
268 ret = wl1271_acx_frag_threshold(wl);
270 goto out_free_memmap;
272 /* Default TID configuration */
273 ret = wl1271_acx_tid_cfg(wl);
275 goto out_free_memmap;
277 /* Default AC configuration */
278 ret = wl1271_acx_ac_cfg(wl);
280 goto out_free_memmap;
282 /* Configure TX rate classes */
283 ret = wl1271_acx_rate_policies(wl, CONF_TX_RATE_MASK_ALL);
285 goto out_free_memmap;
287 /* Enable data path */
288 ret = wl1271_cmd_data_path(wl, wl->channel, 1);
290 goto out_free_memmap;
292 /* Configure for ELP power saving */
293 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
295 goto out_free_memmap;
297 /* Configure HW encryption */
298 ret = wl1271_init_hwenc_config(wl);
300 goto out_free_memmap;
302 /* Configure smart reflex */
303 ret = wl1271_acx_smart_reflex(wl);
305 goto out_free_memmap;
310 kfree(wl->target_mem_map);
311 wl->target_mem_map = NULL;