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_init_general_parms(struct wl1271 *wl)
198 struct wl1271_general_parms *gen_parms;
199 struct conf_general_parms *g = &wl->conf.init.genparam;
202 gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
206 gen_parms->id = TEST_CMD_INI_FILE_GENERAL_PARAM;
208 gen_parms->ref_clk = g->ref_clk;
209 gen_parms->settling_time = g->settling_time;
210 gen_parms->clk_valid_on_wakeup = g->clk_valid_on_wakeup;
211 gen_parms->dc2dcmode = g->dc2dcmode;
212 gen_parms->single_dual_band = g->single_dual_band;
213 gen_parms->tx_bip_fem_autodetect = g->tx_bip_fem_autodetect;
214 gen_parms->tx_bip_fem_manufacturer = g->tx_bip_fem_manufacturer;
215 gen_parms->settings = g->settings;
217 ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), 0);
219 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
227 int wl1271_init_radio_parms(struct wl1271 *wl)
229 struct wl1271_radio_parms *radio_parms;
230 struct conf_radio_parms *r = &wl->conf.init.radioparam;
233 radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL);
237 radio_parms->id = TEST_CMD_INI_FILE_RADIO_PARAM;
239 /* Static radio parameters */
240 radio_parms->rx_trace_loss = r->rx_trace_loss;
241 radio_parms->tx_trace_loss = r->tx_trace_loss;
242 memcpy(radio_parms->rx_rssi_and_proc_compens,
243 r->rx_rssi_and_proc_compens,
244 CONF_RSSI_AND_PROCESS_COMPENSATION_SIZE);
246 memcpy(radio_parms->rx_trace_loss_5, r->rx_trace_loss_5,
247 CONF_NUMBER_OF_SUB_BANDS_5);
248 memcpy(radio_parms->tx_trace_loss_5, r->tx_trace_loss_5,
249 CONF_NUMBER_OF_SUB_BANDS_5);
250 memcpy(radio_parms->rx_rssi_and_proc_compens_5,
251 r->rx_rssi_and_proc_compens_5,
252 CONF_RSSI_AND_PROCESS_COMPENSATION_SIZE);
254 /* Dynamic radio parameters */
255 radio_parms->tx_ref_pd_voltage = cpu_to_le16(r->tx_ref_pd_voltage);
256 radio_parms->tx_ref_power = r->tx_ref_power;
257 radio_parms->tx_offset_db = r->tx_offset_db;
259 memcpy(radio_parms->tx_rate_limits_normal, r->tx_rate_limits_normal,
260 CONF_NUMBER_OF_RATE_GROUPS);
261 memcpy(radio_parms->tx_rate_limits_degraded, r->tx_rate_limits_degraded,
262 CONF_NUMBER_OF_RATE_GROUPS);
264 memcpy(radio_parms->tx_channel_limits_11b, r->tx_channel_limits_11b,
265 CONF_NUMBER_OF_CHANNELS_2_4);
266 memcpy(radio_parms->tx_channel_limits_ofdm, r->tx_channel_limits_ofdm,
267 CONF_NUMBER_OF_CHANNELS_2_4);
268 memcpy(radio_parms->tx_pdv_rate_offsets, r->tx_pdv_rate_offsets,
269 CONF_NUMBER_OF_RATE_GROUPS);
270 memcpy(radio_parms->tx_ibias, r->tx_ibias, CONF_NUMBER_OF_RATE_GROUPS);
272 radio_parms->rx_fem_insertion_loss = r->rx_fem_insertion_loss;
274 for (i = 0; i < CONF_NUMBER_OF_SUB_BANDS_5; i++)
275 radio_parms->tx_ref_pd_voltage_5[i] =
276 cpu_to_le16(r->tx_ref_pd_voltage_5[i]);
277 memcpy(radio_parms->tx_ref_power_5, r->tx_ref_power_5,
278 CONF_NUMBER_OF_SUB_BANDS_5);
279 memcpy(radio_parms->tx_offset_db_5, r->tx_offset_db_5,
280 CONF_NUMBER_OF_SUB_BANDS_5);
281 memcpy(radio_parms->tx_rate_limits_normal_5,
282 r->tx_rate_limits_normal_5, CONF_NUMBER_OF_RATE_GROUPS);
283 memcpy(radio_parms->tx_rate_limits_degraded_5,
284 r->tx_rate_limits_degraded_5, CONF_NUMBER_OF_RATE_GROUPS);
285 memcpy(radio_parms->tx_channel_limits_ofdm_5,
286 r->tx_channel_limits_ofdm_5, CONF_NUMBER_OF_CHANNELS_5);
287 memcpy(radio_parms->tx_pdv_rate_offsets_5, r->tx_pdv_rate_offsets_5,
288 CONF_NUMBER_OF_RATE_GROUPS);
289 memcpy(radio_parms->tx_ibias_5, r->tx_ibias_5,
290 CONF_NUMBER_OF_RATE_GROUPS);
291 memcpy(radio_parms->rx_fem_insertion_loss_5,
292 r->rx_fem_insertion_loss_5, CONF_NUMBER_OF_SUB_BANDS_5);
294 ret = wl1271_cmd_test(wl, radio_parms, sizeof(*radio_parms), 0);
296 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
302 int wl1271_hw_init(struct wl1271 *wl)
306 /* FIXME: the following parameter setting functions return error
307 * codes - the reason is so far unknown. The -EIO is therefore
308 * ignored for the time being. */
309 ret = wl1271_init_general_parms(wl);
310 if (ret < 0 && ret != -EIO)
313 ret = wl1271_init_radio_parms(wl);
314 if (ret < 0 && ret != -EIO)
317 /* Template settings */
318 ret = wl1271_init_templates_config(wl);
322 /* Default memory configuration */
323 ret = wl1271_acx_init_mem_config(wl);
328 ret = wl1271_init_rx_config(wl,
329 RX_CFG_PROMISCUOUS | RX_CFG_TSF,
330 RX_FILTER_OPTION_DEF);
331 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
332 RX_FILTER_OPTION_FILTER_ALL); */
334 goto out_free_memmap;
336 /* PHY layer config */
337 ret = wl1271_init_phy_config(wl);
339 goto out_free_memmap;
341 /* Initialize connection monitoring thresholds */
342 ret = wl1271_acx_conn_monit_params(wl);
344 goto out_free_memmap;
346 /* Beacon filtering */
347 ret = wl1271_init_beacon_filter(wl);
349 goto out_free_memmap;
351 /* Configure TX patch complete interrupt behavior */
352 ret = wl1271_acx_tx_config_options(wl);
354 goto out_free_memmap;
356 /* RX complete interrupt pacing */
357 ret = wl1271_acx_init_rx_interrupt(wl);
359 goto out_free_memmap;
361 /* Bluetooth WLAN coexistence */
362 ret = wl1271_init_pta(wl);
364 goto out_free_memmap;
366 /* Energy detection */
367 ret = wl1271_init_energy_detection(wl);
369 goto out_free_memmap;
371 /* Beacons and boradcast settings */
372 ret = wl1271_init_beacon_broadcast(wl);
374 goto out_free_memmap;
376 /* Default fragmentation threshold */
377 ret = wl1271_acx_frag_threshold(wl);
379 goto out_free_memmap;
381 /* Default TID configuration */
382 ret = wl1271_acx_tid_cfg(wl);
384 goto out_free_memmap;
386 /* Default AC configuration */
387 ret = wl1271_acx_ac_cfg(wl);
389 goto out_free_memmap;
391 /* Configure TX rate classes */
392 ret = wl1271_acx_rate_policies(wl, CONF_TX_RATE_MASK_ALL);
394 goto out_free_memmap;
396 /* Enable data path */
397 ret = wl1271_cmd_data_path(wl, wl->channel, 1);
399 goto out_free_memmap;
401 /* Configure for ELP power saving */
402 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
404 goto out_free_memmap;
406 /* Configure HW encryption */
407 ret = wl1271_init_hwenc_config(wl);
409 goto out_free_memmap;
411 /* Configure smart reflex */
412 ret = wl1271_acx_smart_reflex(wl);
414 goto out_free_memmap;
419 kfree(wl->target_mem_map);
420 wl->target_mem_map = NULL;