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 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
63 sizeof(struct wl12xx_null_data_template));
67 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
68 sizeof(struct wl12xx_ps_poll_template));
72 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
74 (struct wl12xx_qos_null_data_template));
78 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
80 (struct wl12xx_probe_resp_template));
84 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
86 (struct wl12xx_beacon_template));
93 static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
97 ret = wl1271_acx_rx_msdu_life_time(wl);
101 ret = wl1271_acx_rx_config(wl, config, filter);
108 static int wl1271_init_phy_config(struct wl1271 *wl)
112 ret = wl1271_acx_pd_threshold(wl);
116 ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
120 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
124 ret = wl1271_acx_service_period_timeout(wl);
128 ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold);
135 static int wl1271_init_beacon_filter(struct wl1271 *wl)
139 /* disable beacon filtering at this stage */
140 ret = wl1271_acx_beacon_filter_opt(wl, false);
144 ret = wl1271_acx_beacon_filter_table(wl);
151 static int wl1271_init_pta(struct wl1271 *wl)
155 ret = wl1271_acx_sg_enable(wl);
159 ret = wl1271_acx_sg_cfg(wl);
166 static int wl1271_init_energy_detection(struct wl1271 *wl)
170 ret = wl1271_acx_cca_threshold(wl);
177 static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
181 ret = wl1271_acx_bcn_dtim_options(wl);
188 static int wl1271_init_general_parms(struct wl1271 *wl)
190 struct wl1271_general_parms *gen_parms;
191 struct conf_general_parms *g = &wl->conf.init.genparam;
194 gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
198 gen_parms->id = TEST_CMD_INI_FILE_GENERAL_PARAM;
200 gen_parms->ref_clk = g->ref_clk;
201 gen_parms->settling_time = g->settling_time;
202 gen_parms->clk_valid_on_wakeup = g->clk_valid_on_wakeup;
203 gen_parms->dc2dcmode = g->dc2dcmode;
204 gen_parms->single_dual_band = g->single_dual_band;
205 gen_parms->tx_bip_fem_autodetect = g->tx_bip_fem_autodetect;
206 gen_parms->tx_bip_fem_manufacturer = g->tx_bip_fem_manufacturer;
207 gen_parms->settings = g->settings;
209 ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), 0);
211 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
219 static int wl1271_init_radio_parms(struct wl1271 *wl)
221 struct wl1271_radio_parms *radio_parms;
222 struct conf_radio_parms *r = &wl->conf.init.radioparam;
225 radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL);
229 radio_parms->id = TEST_CMD_INI_FILE_RADIO_PARAM;
231 /* Static radio parameters */
232 radio_parms->rx_trace_loss = r->rx_trace_loss;
233 radio_parms->tx_trace_loss = r->tx_trace_loss;
234 memcpy(radio_parms->rx_rssi_and_proc_compens,
235 r->rx_rssi_and_proc_compens,
236 CONF_RSSI_AND_PROCESS_COMPENSATION_SIZE);
238 memcpy(radio_parms->rx_trace_loss_5, r->rx_trace_loss_5,
239 CONF_NUMBER_OF_SUB_BANDS_5);
240 memcpy(radio_parms->tx_trace_loss_5, r->tx_trace_loss_5,
241 CONF_NUMBER_OF_SUB_BANDS_5);
242 memcpy(radio_parms->rx_rssi_and_proc_compens_5,
243 r->rx_rssi_and_proc_compens_5,
244 CONF_RSSI_AND_PROCESS_COMPENSATION_SIZE);
246 /* Dynamic radio parameters */
247 radio_parms->tx_ref_pd_voltage = cpu_to_le16(r->tx_ref_pd_voltage);
248 radio_parms->tx_ref_power = r->tx_ref_power;
249 radio_parms->tx_offset_db = r->tx_offset_db;
251 memcpy(radio_parms->tx_rate_limits_normal, r->tx_rate_limits_normal,
252 CONF_NUMBER_OF_RATE_GROUPS);
253 memcpy(radio_parms->tx_rate_limits_degraded, r->tx_rate_limits_degraded,
254 CONF_NUMBER_OF_RATE_GROUPS);
256 memcpy(radio_parms->tx_channel_limits_11b, r->tx_channel_limits_11b,
257 CONF_NUMBER_OF_CHANNELS_2_4);
258 memcpy(radio_parms->tx_channel_limits_ofdm, r->tx_channel_limits_ofdm,
259 CONF_NUMBER_OF_CHANNELS_2_4);
260 memcpy(radio_parms->tx_pdv_rate_offsets, r->tx_pdv_rate_offsets,
261 CONF_NUMBER_OF_RATE_GROUPS);
262 memcpy(radio_parms->tx_ibias, r->tx_ibias, CONF_NUMBER_OF_RATE_GROUPS);
264 radio_parms->rx_fem_insertion_loss = r->rx_fem_insertion_loss;
266 for (i = 0; i < CONF_NUMBER_OF_SUB_BANDS_5; i++)
267 radio_parms->tx_ref_pd_voltage_5[i] =
268 cpu_to_le16(r->tx_ref_pd_voltage_5[i]);
269 memcpy(radio_parms->tx_ref_power_5, r->tx_ref_power_5,
270 CONF_NUMBER_OF_SUB_BANDS_5);
271 memcpy(radio_parms->tx_offset_db_5, r->tx_offset_db_5,
272 CONF_NUMBER_OF_SUB_BANDS_5);
273 memcpy(radio_parms->tx_rate_limits_normal_5,
274 r->tx_rate_limits_normal_5, CONF_NUMBER_OF_RATE_GROUPS);
275 memcpy(radio_parms->tx_rate_limits_degraded_5,
276 r->tx_rate_limits_degraded_5, CONF_NUMBER_OF_RATE_GROUPS);
277 memcpy(radio_parms->tx_channel_limits_ofdm_5,
278 r->tx_channel_limits_ofdm_5, CONF_NUMBER_OF_CHANNELS_5);
279 memcpy(radio_parms->tx_pdv_rate_offsets_5, r->tx_pdv_rate_offsets_5,
280 CONF_NUMBER_OF_RATE_GROUPS);
281 memcpy(radio_parms->tx_ibias_5, r->tx_ibias_5,
282 CONF_NUMBER_OF_RATE_GROUPS);
283 memcpy(radio_parms->rx_fem_insertion_loss_5,
284 r->rx_fem_insertion_loss_5, CONF_NUMBER_OF_SUB_BANDS_5);
286 ret = wl1271_cmd_test(wl, radio_parms, sizeof(*radio_parms), 0);
288 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
294 int wl1271_hw_init(struct wl1271 *wl)
298 ret = wl1271_init_general_parms(wl);
302 ret = wl1271_init_radio_parms(wl);
306 /* Template settings */
307 ret = wl1271_init_templates_config(wl);
311 /* Default memory configuration */
312 ret = wl1271_acx_init_mem_config(wl);
317 ret = wl1271_init_rx_config(wl,
318 RX_CFG_PROMISCUOUS | RX_CFG_TSF,
319 RX_FILTER_OPTION_DEF);
320 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
321 RX_FILTER_OPTION_FILTER_ALL); */
323 goto out_free_memmap;
325 /* PHY layer config */
326 ret = wl1271_init_phy_config(wl);
328 goto out_free_memmap;
330 /* Initialize connection monitoring thresholds */
331 ret = wl1271_acx_conn_monit_params(wl);
333 goto out_free_memmap;
335 /* Beacon filtering */
336 ret = wl1271_init_beacon_filter(wl);
338 goto out_free_memmap;
340 /* Configure TX patch complete interrupt behavior */
341 ret = wl1271_acx_tx_config_options(wl);
343 goto out_free_memmap;
345 /* RX complete interrupt pacing */
346 ret = wl1271_acx_init_rx_interrupt(wl);
348 goto out_free_memmap;
350 /* Bluetooth WLAN coexistence */
351 ret = wl1271_init_pta(wl);
353 goto out_free_memmap;
355 /* Energy detection */
356 ret = wl1271_init_energy_detection(wl);
358 goto out_free_memmap;
360 /* Beacons and boradcast settings */
361 ret = wl1271_init_beacon_broadcast(wl);
363 goto out_free_memmap;
365 /* Default fragmentation threshold */
366 ret = wl1271_acx_frag_threshold(wl);
368 goto out_free_memmap;
370 /* Default TID configuration */
371 ret = wl1271_acx_tid_cfg(wl);
373 goto out_free_memmap;
375 /* Default AC configuration */
376 ret = wl1271_acx_ac_cfg(wl);
378 goto out_free_memmap;
380 /* Configure TX rate classes */
381 ret = wl1271_acx_rate_policies(wl, CONF_TX_RATE_MASK_ALL);
383 goto out_free_memmap;
385 /* Enable data path */
386 ret = wl1271_cmd_data_path(wl, wl->channel, 1);
388 goto out_free_memmap;
390 /* Configure for ELP power saving */
391 ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
393 goto out_free_memmap;
395 /* Configure HW encryption */
396 ret = wl1271_init_hwenc_config(wl);
398 goto out_free_memmap;
400 /* Configure smart reflex */
401 ret = wl1271_acx_smart_reflex(wl);
403 goto out_free_memmap;
408 kfree(wl->target_mem_map);
409 wl->target_mem_map = NULL;