diff options
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_cmd.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_cmd.c | 136 |
1 files changed, 28 insertions, 108 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c index a74259bb596b..36a64e06f290 100644 --- a/drivers/net/wireless/wl12xx/wl1271_cmd.c +++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "wl1271.h" | 30 | #include "wl1271.h" |
31 | #include "wl1271_reg.h" | 31 | #include "wl1271_reg.h" |
32 | #include "wl1271_spi.h" | 32 | #include "wl1271_spi.h" |
33 | #include "wl1271_io.h" | ||
33 | #include "wl1271_acx.h" | 34 | #include "wl1271_acx.h" |
34 | #include "wl12xx_80211.h" | 35 | #include "wl12xx_80211.h" |
35 | #include "wl1271_cmd.h" | 36 | #include "wl1271_cmd.h" |
@@ -57,13 +58,13 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len, | |||
57 | 58 | ||
58 | WARN_ON(len % 4 != 0); | 59 | WARN_ON(len % 4 != 0); |
59 | 60 | ||
60 | wl1271_spi_write(wl, wl->cmd_box_addr, buf, len, false); | 61 | wl1271_write(wl, wl->cmd_box_addr, buf, len, false); |
61 | 62 | ||
62 | wl1271_spi_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); | 63 | wl1271_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); |
63 | 64 | ||
64 | timeout = jiffies + msecs_to_jiffies(WL1271_COMMAND_TIMEOUT); | 65 | timeout = jiffies + msecs_to_jiffies(WL1271_COMMAND_TIMEOUT); |
65 | 66 | ||
66 | intr = wl1271_spi_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | 67 | intr = wl1271_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); |
67 | while (!(intr & WL1271_ACX_INTR_CMD_COMPLETE)) { | 68 | while (!(intr & WL1271_ACX_INTR_CMD_COMPLETE)) { |
68 | if (time_after(jiffies, timeout)) { | 69 | if (time_after(jiffies, timeout)) { |
69 | wl1271_error("command complete timeout"); | 70 | wl1271_error("command complete timeout"); |
@@ -73,13 +74,13 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len, | |||
73 | 74 | ||
74 | msleep(1); | 75 | msleep(1); |
75 | 76 | ||
76 | intr = wl1271_spi_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | 77 | intr = wl1271_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); |
77 | } | 78 | } |
78 | 79 | ||
79 | /* read back the status code of the command */ | 80 | /* read back the status code of the command */ |
80 | if (res_len == 0) | 81 | if (res_len == 0) |
81 | res_len = sizeof(struct wl1271_cmd_header); | 82 | res_len = sizeof(struct wl1271_cmd_header); |
82 | wl1271_spi_read(wl, wl->cmd_box_addr, cmd, res_len, false); | 83 | wl1271_read(wl, wl->cmd_box_addr, cmd, res_len, false); |
83 | 84 | ||
84 | status = le16_to_cpu(cmd->status); | 85 | status = le16_to_cpu(cmd->status); |
85 | if (status != CMD_STATUS_SUCCESS) { | 86 | if (status != CMD_STATUS_SUCCESS) { |
@@ -87,8 +88,8 @@ int wl1271_cmd_send(struct wl1271 *wl, u16 id, void *buf, size_t len, | |||
87 | ret = -EIO; | 88 | ret = -EIO; |
88 | } | 89 | } |
89 | 90 | ||
90 | wl1271_spi_write32(wl, ACX_REG_INTERRUPT_ACK, | 91 | wl1271_write32(wl, ACX_REG_INTERRUPT_ACK, |
91 | WL1271_ACX_INTR_CMD_COMPLETE); | 92 | WL1271_ACX_INTR_CMD_COMPLETE); |
92 | 93 | ||
93 | out: | 94 | out: |
94 | return ret; | 95 | return ret; |
@@ -191,43 +192,19 @@ static int wl1271_cmd_cal(struct wl1271 *wl) | |||
191 | int wl1271_cmd_general_parms(struct wl1271 *wl) | 192 | int wl1271_cmd_general_parms(struct wl1271 *wl) |
192 | { | 193 | { |
193 | struct wl1271_general_parms_cmd *gen_parms; | 194 | struct wl1271_general_parms_cmd *gen_parms; |
194 | struct conf_general_parms *g = &wl->conf.init.genparam; | ||
195 | int ret; | 195 | int ret; |
196 | 196 | ||
197 | if (!wl->nvs) | ||
198 | return -ENODEV; | ||
199 | |||
197 | gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL); | 200 | gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL); |
198 | if (!gen_parms) | 201 | if (!gen_parms) |
199 | return -ENOMEM; | 202 | return -ENOMEM; |
200 | 203 | ||
201 | gen_parms->test.id = TEST_CMD_INI_FILE_GENERAL_PARAM; | 204 | gen_parms->test.id = TEST_CMD_INI_FILE_GENERAL_PARAM; |
202 | 205 | ||
203 | gen_parms->ref_clk = g->ref_clk; | 206 | memcpy(gen_parms->params, wl->nvs->general_params, |
204 | gen_parms->settling_time = g->settling_time; | 207 | WL1271_NVS_GENERAL_PARAMS_SIZE); |
205 | gen_parms->clk_valid_on_wakeup = g->clk_valid_on_wakeup; | ||
206 | gen_parms->dc2dcmode = g->dc2dcmode; | ||
207 | gen_parms->single_dual_band = g->single_dual_band; | ||
208 | gen_parms->tx_bip_fem_autodetect = g->tx_bip_fem_autodetect; | ||
209 | gen_parms->tx_bip_fem_manufacturer = g->tx_bip_fem_manufacturer; | ||
210 | gen_parms->settings = g->settings; | ||
211 | |||
212 | gen_parms->sr_state = g->sr_state; | ||
213 | |||
214 | memcpy(gen_parms->srf1, | ||
215 | g->srf1, | ||
216 | CONF_MAX_SMART_REFLEX_PARAMS); | ||
217 | memcpy(gen_parms->srf2, | ||
218 | g->srf2, | ||
219 | CONF_MAX_SMART_REFLEX_PARAMS); | ||
220 | memcpy(gen_parms->srf3, | ||
221 | g->srf3, | ||
222 | CONF_MAX_SMART_REFLEX_PARAMS); | ||
223 | memcpy(gen_parms->sr_debug_table, | ||
224 | g->sr_debug_table, | ||
225 | CONF_MAX_SMART_REFLEX_PARAMS); | ||
226 | |||
227 | gen_parms->sr_sen_n_p = g->sr_sen_n_p; | ||
228 | gen_parms->sr_sen_n_p_gain = g->sr_sen_n_p_gain; | ||
229 | gen_parms->sr_sen_nrn = g->sr_sen_nrn; | ||
230 | gen_parms->sr_sen_prn = g->sr_sen_prn; | ||
231 | 208 | ||
232 | ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), 0); | 209 | ret = wl1271_cmd_test(wl, gen_parms, sizeof(*gen_parms), 0); |
233 | if (ret < 0) | 210 | if (ret < 0) |
@@ -240,8 +217,11 @@ int wl1271_cmd_general_parms(struct wl1271 *wl) | |||
240 | int wl1271_cmd_radio_parms(struct wl1271 *wl) | 217 | int wl1271_cmd_radio_parms(struct wl1271 *wl) |
241 | { | 218 | { |
242 | struct wl1271_radio_parms_cmd *radio_parms; | 219 | struct wl1271_radio_parms_cmd *radio_parms; |
243 | struct conf_radio_parms *r = &wl->conf.init.radioparam; | 220 | struct conf_radio_parms *rparam = &wl->conf.init.radioparam; |
244 | int i, ret; | 221 | int ret; |
222 | |||
223 | if (!wl->nvs) | ||
224 | return -ENODEV; | ||
245 | 225 | ||
246 | radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL); | 226 | radio_parms = kzalloc(sizeof(*radio_parms), GFP_KERNEL); |
247 | if (!radio_parms) | 227 | if (!radio_parms) |
@@ -249,73 +229,13 @@ int wl1271_cmd_radio_parms(struct wl1271 *wl) | |||
249 | 229 | ||
250 | radio_parms->test.id = TEST_CMD_INI_FILE_RADIO_PARAM; | 230 | radio_parms->test.id = TEST_CMD_INI_FILE_RADIO_PARAM; |
251 | 231 | ||
252 | /* Static radio parameters */ | 232 | memcpy(radio_parms->stat_radio_params, wl->nvs->stat_radio_params, |
253 | radio_parms->rx_trace_loss = r->rx_trace_loss; | 233 | WL1271_NVS_STAT_RADIO_PARAMS_SIZE); |
254 | radio_parms->tx_trace_loss = r->tx_trace_loss; | 234 | memcpy(radio_parms->dyn_radio_params, |
255 | memcpy(radio_parms->rx_rssi_and_proc_compens, | 235 | wl->nvs->dyn_radio_params[rparam->fem], |
256 | r->rx_rssi_and_proc_compens, | 236 | WL1271_NVS_DYN_RADIO_PARAMS_SIZE); |
257 | CONF_RSSI_AND_PROCESS_COMPENSATION_SIZE); | 237 | |
258 | 238 | /* FIXME: current NVS is missing 5GHz parameters */ | |
259 | memcpy(radio_parms->rx_trace_loss_5, r->rx_trace_loss_5, | ||
260 | CONF_NUMBER_OF_SUB_BANDS_5); | ||
261 | memcpy(radio_parms->tx_trace_loss_5, r->tx_trace_loss_5, | ||
262 | CONF_NUMBER_OF_SUB_BANDS_5); | ||
263 | memcpy(radio_parms->rx_rssi_and_proc_compens_5, | ||
264 | r->rx_rssi_and_proc_compens_5, | ||
265 | CONF_RSSI_AND_PROCESS_COMPENSATION_SIZE); | ||
266 | |||
267 | /* Dynamic radio parameters */ | ||
268 | radio_parms->tx_ref_pd_voltage = cpu_to_le16(r->tx_ref_pd_voltage); | ||
269 | radio_parms->tx_ref_power = r->tx_ref_power; | ||
270 | radio_parms->tx_offset_db = r->tx_offset_db; | ||
271 | |||
272 | memcpy(radio_parms->tx_rate_limits_normal, r->tx_rate_limits_normal, | ||
273 | CONF_NUMBER_OF_RATE_GROUPS); | ||
274 | memcpy(radio_parms->tx_rate_limits_degraded, r->tx_rate_limits_degraded, | ||
275 | CONF_NUMBER_OF_RATE_GROUPS); | ||
276 | memcpy(radio_parms->tx_rate_limits_extreme, r->tx_rate_limits_extreme, | ||
277 | CONF_NUMBER_OF_RATE_GROUPS); | ||
278 | |||
279 | memcpy(radio_parms->tx_channel_limits_11b, r->tx_channel_limits_11b, | ||
280 | CONF_NUMBER_OF_CHANNELS_2_4); | ||
281 | memcpy(radio_parms->tx_channel_limits_ofdm, r->tx_channel_limits_ofdm, | ||
282 | CONF_NUMBER_OF_CHANNELS_2_4); | ||
283 | memcpy(radio_parms->tx_pdv_rate_offsets, r->tx_pdv_rate_offsets, | ||
284 | CONF_NUMBER_OF_RATE_GROUPS); | ||
285 | memcpy(radio_parms->tx_ibias, r->tx_ibias, CONF_NUMBER_OF_RATE_GROUPS); | ||
286 | |||
287 | radio_parms->rx_fem_insertion_loss = r->rx_fem_insertion_loss; | ||
288 | radio_parms->degraded_low_to_normal_threshold = | ||
289 | r->degraded_low_to_normal_threshold; | ||
290 | radio_parms->degraded_normal_to_high_threshold = | ||
291 | r->degraded_normal_to_high_threshold; | ||
292 | |||
293 | |||
294 | for (i = 0; i < CONF_NUMBER_OF_SUB_BANDS_5; i++) | ||
295 | radio_parms->tx_ref_pd_voltage_5[i] = | ||
296 | cpu_to_le16(r->tx_ref_pd_voltage_5[i]); | ||
297 | memcpy(radio_parms->tx_ref_power_5, r->tx_ref_power_5, | ||
298 | CONF_NUMBER_OF_SUB_BANDS_5); | ||
299 | memcpy(radio_parms->tx_offset_db_5, r->tx_offset_db_5, | ||
300 | CONF_NUMBER_OF_SUB_BANDS_5); | ||
301 | memcpy(radio_parms->tx_rate_limits_normal_5, | ||
302 | r->tx_rate_limits_normal_5, CONF_NUMBER_OF_RATE_GROUPS); | ||
303 | memcpy(radio_parms->tx_rate_limits_degraded_5, | ||
304 | r->tx_rate_limits_degraded_5, CONF_NUMBER_OF_RATE_GROUPS); | ||
305 | memcpy(radio_parms->tx_rate_limits_extreme_5, | ||
306 | r->tx_rate_limits_extreme_5, CONF_NUMBER_OF_RATE_GROUPS); | ||
307 | memcpy(radio_parms->tx_channel_limits_ofdm_5, | ||
308 | r->tx_channel_limits_ofdm_5, CONF_NUMBER_OF_CHANNELS_5); | ||
309 | memcpy(radio_parms->tx_pdv_rate_offsets_5, r->tx_pdv_rate_offsets_5, | ||
310 | CONF_NUMBER_OF_RATE_GROUPS); | ||
311 | memcpy(radio_parms->tx_ibias_5, r->tx_ibias_5, | ||
312 | CONF_NUMBER_OF_RATE_GROUPS); | ||
313 | memcpy(radio_parms->rx_fem_insertion_loss_5, | ||
314 | r->rx_fem_insertion_loss_5, CONF_NUMBER_OF_SUB_BANDS_5); | ||
315 | radio_parms->degraded_low_to_normal_threshold_5 = | ||
316 | r->degraded_low_to_normal_threshold_5; | ||
317 | radio_parms->degraded_normal_to_high_threshold_5 = | ||
318 | r->degraded_normal_to_high_threshold_5; | ||
319 | 239 | ||
320 | wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ", | 240 | wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ", |
321 | radio_parms, sizeof(*radio_parms)); | 241 | radio_parms, sizeof(*radio_parms)); |
@@ -555,7 +475,7 @@ out: | |||
555 | return ret; | 475 | return ret; |
556 | } | 476 | } |
557 | 477 | ||
558 | int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode) | 478 | int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode, bool send) |
559 | { | 479 | { |
560 | struct wl1271_cmd_ps_params *ps_params = NULL; | 480 | struct wl1271_cmd_ps_params *ps_params = NULL; |
561 | int ret = 0; | 481 | int ret = 0; |
@@ -576,7 +496,7 @@ int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode) | |||
576 | } | 496 | } |
577 | 497 | ||
578 | ps_params->ps_mode = ps_mode; | 498 | ps_params->ps_mode = ps_mode; |
579 | ps_params->send_null_data = 1; | 499 | ps_params->send_null_data = send; |
580 | ps_params->retries = 5; | 500 | ps_params->retries = 5; |
581 | ps_params->hang_over_period = 128; | 501 | ps_params->hang_over_period = 128; |
582 | ps_params->null_data_rate = cpu_to_le32(1); /* 1 Mbps */ | 502 | ps_params->null_data_rate = cpu_to_le32(1); /* 1 Mbps */ |
@@ -1022,7 +942,7 @@ int wl1271_cmd_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, | |||
1022 | ret = wl1271_cmd_send(wl, CMD_SET_KEYS, cmd, sizeof(*cmd), 0); | 942 | ret = wl1271_cmd_send(wl, CMD_SET_KEYS, cmd, sizeof(*cmd), 0); |
1023 | if (ret < 0) { | 943 | if (ret < 0) { |
1024 | wl1271_warning("could not set keys"); | 944 | wl1271_warning("could not set keys"); |
1025 | goto out; | 945 | goto out; |
1026 | } | 946 | } |
1027 | 947 | ||
1028 | out: | 948 | out: |