aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1271_init.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/wireless/wl12xx/wl1271_init.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_init.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_init.c184
1 files changed, 61 insertions, 123 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_init.c b/drivers/net/wireless/wl12xx/wl1271_init.c
index 490df217605a..d189e8fe05a6 100644
--- a/drivers/net/wireless/wl12xx/wl1271_init.c
+++ b/drivers/net/wireless/wl12xx/wl1271_init.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/slab.h>
26 27
27#include "wl1271_init.h" 28#include "wl1271_init.h"
28#include "wl12xx_80211.h" 29#include "wl12xx_80211.h"
@@ -49,7 +50,7 @@ static int wl1271_init_hwenc_config(struct wl1271 *wl)
49 return 0; 50 return 0;
50} 51}
51 52
52static int wl1271_init_templates_config(struct wl1271 *wl) 53int wl1271_init_templates_config(struct wl1271 *wl)
53{ 54{
54 int ret; 55 int ret;
55 56
@@ -59,6 +60,14 @@ static int wl1271_init_templates_config(struct wl1271 *wl)
59 if (ret < 0) 60 if (ret < 0)
60 return ret; 61 return ret;
61 62
63 if (wl1271_11a_enabled()) {
64 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
65 NULL,
66 sizeof(struct wl12xx_probe_req_template));
67 if (ret < 0)
68 return ret;
69 }
70
62 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL, 71 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
63 sizeof(struct wl12xx_null_data_template)); 72 sizeof(struct wl12xx_null_data_template));
64 if (ret < 0) 73 if (ret < 0)
@@ -94,7 +103,7 @@ static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
94{ 103{
95 int ret; 104 int ret;
96 105
97 ret = wl1271_acx_rx_msdu_life_time(wl, RX_MSDU_LIFETIME_DEF); 106 ret = wl1271_acx_rx_msdu_life_time(wl);
98 if (ret < 0) 107 if (ret < 0)
99 return ret; 108 return ret;
100 109
@@ -105,7 +114,7 @@ static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
105 return 0; 114 return 0;
106} 115}
107 116
108static int wl1271_init_phy_config(struct wl1271 *wl) 117int wl1271_init_phy_config(struct wl1271 *wl)
109{ 118{
110 int ret; 119 int ret;
111 120
@@ -117,7 +126,7 @@ static int wl1271_init_phy_config(struct wl1271 *wl)
117 if (ret < 0) 126 if (ret < 0)
118 return ret; 127 return ret;
119 128
120 ret = wl1271_acx_group_address_tbl(wl); 129 ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
121 if (ret < 0) 130 if (ret < 0)
122 return ret; 131 return ret;
123 132
@@ -125,7 +134,7 @@ static int wl1271_init_phy_config(struct wl1271 *wl)
125 if (ret < 0) 134 if (ret < 0)
126 return ret; 135 return ret;
127 136
128 ret = wl1271_acx_rts_threshold(wl, RTS_THRESHOLD_DEF); 137 ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold);
129 if (ret < 0) 138 if (ret < 0)
130 return ret; 139 return ret;
131 140
@@ -136,7 +145,8 @@ static int wl1271_init_beacon_filter(struct wl1271 *wl)
136{ 145{
137 int ret; 146 int ret;
138 147
139 ret = wl1271_acx_beacon_filter_opt(wl); 148 /* disable beacon filtering at this stage */
149 ret = wl1271_acx_beacon_filter_opt(wl, false);
140 if (ret < 0) 150 if (ret < 0)
141 return ret; 151 return ret;
142 152
@@ -147,7 +157,7 @@ static int wl1271_init_beacon_filter(struct wl1271 *wl)
147 return 0; 157 return 0;
148} 158}
149 159
150static int wl1271_init_pta(struct wl1271 *wl) 160int wl1271_init_pta(struct wl1271 *wl)
151{ 161{
152 int ret; 162 int ret;
153 163
@@ -162,7 +172,7 @@ static int wl1271_init_pta(struct wl1271 *wl)
162 return 0; 172 return 0;
163} 173}
164 174
165static int wl1271_init_energy_detection(struct wl1271 *wl) 175int wl1271_init_energy_detection(struct wl1271 *wl)
166{ 176{
167 int ret; 177 int ret;
168 178
@@ -184,118 +194,17 @@ static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
184 return 0; 194 return 0;
185} 195}
186 196
187static int wl1271_init_general_parms(struct wl1271 *wl)
188{
189 struct wl1271_general_parms *gen_parms;
190 int ret;
191
192 gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL);
193 if (!gen_parms)
194 return -ENOMEM;
195
196 gen_parms->id = TEST_CMD_INI_FILE_GENERAL_PARAM;
197
198 gen_parms->ref_clk = REF_CLK_38_4_E;
199 /* FIXME: magic numbers */
200 gen_parms->settling_time = 5;
201 gen_parms->clk_valid_on_wakeup = 0;
202 gen_parms->dc2dcmode = 0;
203 gen_parms->single_dual_band = 0;
204 gen_parms->tx_bip_fem_autodetect = 1;
205 gen_parms->tx_bip_fem_manufacturer = 1;
206 gen_parms->settings = 1;
207
208 ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), 0);
209 if (ret < 0) {
210 wl1271_warning("CMD_INI_FILE_GENERAL_PARAM failed");
211 return ret;
212 }
213
214 kfree(gen_parms);
215 return 0;
216}
217
218static int wl1271_init_radio_parms(struct wl1271 *wl)
219{
220 /*
221 * FIXME: All these magic numbers should be moved to some place where
222 * they can be configured (separate file?)
223 */
224
225 struct wl1271_radio_parms *radio_parms;
226 int ret;
227 u8 compensation[] = { 0xec, 0xf6, 0x00, 0x0c, 0x18, 0xf8, 0xfc, 0x00,
228 0x08, 0x10, 0xf0, 0xf8, 0x00, 0x0a, 0x14 };
229
230 u8 tx_rate_limits_normal[] = { 0x1e, 0x1f, 0x22, 0x24, 0x28, 0x29 };
231 u8 tx_rate_limits_degraded[] = { 0x1b, 0x1c, 0x1e, 0x20, 0x24, 0x25 };
232
233 u8 tx_channel_limits_11b[] = { 0x22, 0x50, 0x50, 0x50,
234 0x50, 0x50, 0x50, 0x50,
235 0x50, 0x50, 0x22, 0x50,
236 0x22, 0x50 };
237
238 u8 tx_channel_limits_ofdm[] = { 0x20, 0x50, 0x50, 0x50,
239 0x50, 0x50, 0x50, 0x50,
240 0x50, 0x50, 0x20, 0x50,
241 0x20, 0x50 };
242
243 u8 tx_pdv_rate_offsets[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
244
245 u8 tx_ibias[] = { 0x1a, 0x1a, 0x1a, 0x1a, 0x1a, 0x27 };
246
247 radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL);
248 if (!radio_parms)
249 return -ENOMEM;
250
251 radio_parms->id = TEST_CMD_INI_FILE_RADIO_PARAM;
252
253 /* Static radio parameters */
254 radio_parms->rx_trace_loss = 10;
255 radio_parms->tx_trace_loss = 10;
256 memcpy(radio_parms->rx_rssi_and_proc_compens, compensation,
257 sizeof(compensation));
258
259 /* We don't set the 5GHz -- N/A */
260
261 /* Dynamic radio parameters */
262 radio_parms->tx_ref_pd_voltage = cpu_to_le16(0x24e);
263 radio_parms->tx_ref_power = 0x78;
264 radio_parms->tx_offset_db = 0x0;
265
266 memcpy(radio_parms->tx_rate_limits_normal, tx_rate_limits_normal,
267 sizeof(tx_rate_limits_normal));
268 memcpy(radio_parms->tx_rate_limits_degraded, tx_rate_limits_degraded,
269 sizeof(tx_rate_limits_degraded));
270
271 memcpy(radio_parms->tx_channel_limits_11b, tx_channel_limits_11b,
272 sizeof(tx_channel_limits_11b));
273 memcpy(radio_parms->tx_channel_limits_ofdm, tx_channel_limits_ofdm,
274 sizeof(tx_channel_limits_ofdm));
275 memcpy(radio_parms->tx_pdv_rate_offsets, tx_pdv_rate_offsets,
276 sizeof(tx_pdv_rate_offsets));
277 memcpy(radio_parms->tx_ibias, tx_ibias,
278 sizeof(tx_ibias));
279
280 radio_parms->rx_fem_insertion_loss = 0x14;
281
282 ret = wl1271_cmd_test(wl, radio_parms, sizeof(*radio_parms), 0);
283 if (ret < 0)
284 wl1271_warning("CMD_INI_FILE_RADIO_PARAM failed");
285
286 kfree(radio_parms);
287 return ret;
288}
289
290int wl1271_hw_init(struct wl1271 *wl) 197int wl1271_hw_init(struct wl1271 *wl)
291{ 198{
292 int ret; 199 struct conf_tx_ac_category *conf_ac;
200 struct conf_tx_tid *conf_tid;
201 int ret, i;
293 202
294 ret = wl1271_init_general_parms(wl); 203 ret = wl1271_cmd_general_parms(wl);
295 if (ret < 0) 204 if (ret < 0)
296 return ret; 205 return ret;
297 206
298 ret = wl1271_init_radio_parms(wl); 207 ret = wl1271_cmd_radio_parms(wl);
299 if (ret < 0) 208 if (ret < 0)
300 return ret; 209 return ret;
301 210
@@ -311,8 +220,8 @@ int wl1271_hw_init(struct wl1271 *wl)
311 220
312 /* RX config */ 221 /* RX config */
313 ret = wl1271_init_rx_config(wl, 222 ret = wl1271_init_rx_config(wl,
314 RX_CFG_PROMISCUOUS | RX_CFG_TSF, 223 RX_CFG_PROMISCUOUS | RX_CFG_TSF,
315 RX_FILTER_OPTION_DEF); 224 RX_FILTER_OPTION_DEF);
316 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS, 225 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
317 RX_FILTER_OPTION_FILTER_ALL); */ 226 RX_FILTER_OPTION_FILTER_ALL); */
318 if (ret < 0) 227 if (ret < 0)
@@ -323,6 +232,15 @@ int wl1271_hw_init(struct wl1271 *wl)
323 if (ret < 0) 232 if (ret < 0)
324 goto out_free_memmap; 233 goto out_free_memmap;
325 234
235 ret = wl1271_acx_dco_itrim_params(wl);
236 if (ret < 0)
237 goto out_free_memmap;
238
239 /* Initialize connection monitoring thresholds */
240 ret = wl1271_acx_conn_monit_params(wl);
241 if (ret < 0)
242 goto out_free_memmap;
243
326 /* Beacon filtering */ 244 /* Beacon filtering */
327 ret = wl1271_init_beacon_filter(wl); 245 ret = wl1271_init_beacon_filter(wl);
328 if (ret < 0) 246 if (ret < 0)
@@ -359,14 +277,28 @@ int wl1271_hw_init(struct wl1271 *wl)
359 goto out_free_memmap; 277 goto out_free_memmap;
360 278
361 /* Default TID configuration */ 279 /* Default TID configuration */
362 ret = wl1271_acx_tid_cfg(wl); 280 for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
363 if (ret < 0) 281 conf_tid = &wl->conf.tx.tid_conf[i];
364 goto out_free_memmap; 282 ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id,
283 conf_tid->channel_type,
284 conf_tid->tsid,
285 conf_tid->ps_scheme,
286 conf_tid->ack_policy,
287 conf_tid->apsd_conf[0],
288 conf_tid->apsd_conf[1]);
289 if (ret < 0)
290 goto out_free_memmap;
291 }
365 292
366 /* Default AC configuration */ 293 /* Default AC configuration */
367 ret = wl1271_acx_ac_cfg(wl); 294 for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
368 if (ret < 0) 295 conf_ac = &wl->conf.tx.ac_conf[i];
369 goto out_free_memmap; 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);
299 if (ret < 0)
300 goto out_free_memmap;
301 }
370 302
371 /* Configure TX rate classes */ 303 /* Configure TX rate classes */
372 ret = wl1271_acx_rate_policies(wl); 304 ret = wl1271_acx_rate_policies(wl);
@@ -374,7 +306,7 @@ int wl1271_hw_init(struct wl1271 *wl)
374 goto out_free_memmap; 306 goto out_free_memmap;
375 307
376 /* Enable data path */ 308 /* Enable data path */
377 ret = wl1271_cmd_data_path(wl, wl->channel, 1); 309 ret = wl1271_cmd_data_path(wl, 1);
378 if (ret < 0) 310 if (ret < 0)
379 goto out_free_memmap; 311 goto out_free_memmap;
380 312
@@ -388,10 +320,16 @@ int wl1271_hw_init(struct wl1271 *wl)
388 if (ret < 0) 320 if (ret < 0)
389 goto out_free_memmap; 321 goto out_free_memmap;
390 322
323 /* configure PM */
324 ret = wl1271_acx_pm_config(wl);
325 if (ret < 0)
326 goto out_free_memmap;
327
391 return 0; 328 return 0;
392 329
393 out_free_memmap: 330 out_free_memmap:
394 kfree(wl->target_mem_map); 331 kfree(wl->target_mem_map);
332 wl->target_mem_map = NULL;
395 333
396 return ret; 334 return ret;
397} 335}