aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1251_cmd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1251_cmd.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_cmd.c133
1 files changed, 66 insertions, 67 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1251_cmd.c b/drivers/net/wireless/wl12xx/wl1251_cmd.c
index 92c7fb6853e..dc04d1fc2ee 100644
--- a/drivers/net/wireless/wl12xx/wl1251_cmd.c
+++ b/drivers/net/wireless/wl12xx/wl1251_cmd.c
@@ -5,7 +5,6 @@
5#include <linux/spi/spi.h> 5#include <linux/spi/spi.h>
6 6
7#include "wl1251.h" 7#include "wl1251.h"
8#include "wl12xx_80211.h"
9#include "reg.h" 8#include "reg.h"
10#include "wl1251_spi.h" 9#include "wl1251_spi.h"
11#include "wl1251_ps.h" 10#include "wl1251_ps.h"
@@ -19,9 +18,9 @@
19 * @buf: buffer containing the command, must work with dma 18 * @buf: buffer containing the command, must work with dma
20 * @len: length of the buffer 19 * @len: length of the buffer
21 */ 20 */
22int wl12xx_cmd_send(struct wl12xx *wl, u16 id, void *buf, size_t len) 21int wl1251_cmd_send(struct wl1251 *wl, u16 id, void *buf, size_t len)
23{ 22{
24 struct wl12xx_cmd_header *cmd; 23 struct wl1251_cmd_header *cmd;
25 unsigned long timeout; 24 unsigned long timeout;
26 u32 intr; 25 u32 intr;
27 int ret = 0; 26 int ret = 0;
@@ -32,26 +31,26 @@ int wl12xx_cmd_send(struct wl12xx *wl, u16 id, void *buf, size_t len)
32 31
33 WARN_ON(len % 4 != 0); 32 WARN_ON(len % 4 != 0);
34 33
35 wl12xx_spi_mem_write(wl, wl->cmd_box_addr, buf, len); 34 wl1251_spi_mem_write(wl, wl->cmd_box_addr, buf, len);
36 35
37 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); 36 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD);
38 37
39 timeout = jiffies + msecs_to_jiffies(WL12XX_COMMAND_TIMEOUT); 38 timeout = jiffies + msecs_to_jiffies(WL1251_COMMAND_TIMEOUT);
40 39
41 intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); 40 intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
42 while (!(intr & wl->chip.intr_cmd_complete)) { 41 while (!(intr & wl->chip.intr_cmd_complete)) {
43 if (time_after(jiffies, timeout)) { 42 if (time_after(jiffies, timeout)) {
44 wl12xx_error("command complete timeout"); 43 wl1251_error("command complete timeout");
45 ret = -ETIMEDOUT; 44 ret = -ETIMEDOUT;
46 goto out; 45 goto out;
47 } 46 }
48 47
49 msleep(1); 48 msleep(1);
50 49
51 intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); 50 intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
52 } 51 }
53 52
54 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_ACK, 53 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_ACK,
55 wl->chip.intr_cmd_complete); 54 wl->chip.intr_cmd_complete);
56 55
57out: 56out:
@@ -66,33 +65,33 @@ out:
66 * @len: length of the buffer 65 * @len: length of the buffer
67 * @answer: is answer needed 66 * @answer: is answer needed
68 */ 67 */
69int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer) 68int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer)
70{ 69{
71 int ret; 70 int ret;
72 71
73 wl12xx_debug(DEBUG_CMD, "cmd test"); 72 wl1251_debug(DEBUG_CMD, "cmd test");
74 73
75 ret = wl12xx_cmd_send(wl, CMD_TEST, buf, buf_len); 74 ret = wl1251_cmd_send(wl, CMD_TEST, buf, buf_len);
76 75
77 if (ret < 0) { 76 if (ret < 0) {
78 wl12xx_warning("TEST command failed"); 77 wl1251_warning("TEST command failed");
79 return ret; 78 return ret;
80 } 79 }
81 80
82 if (answer) { 81 if (answer) {
83 struct wl12xx_command *cmd_answer; 82 struct wl1251_command *cmd_answer;
84 83
85 /* 84 /*
86 * The test command got in, we can read the answer. 85 * The test command got in, we can read the answer.
87 * The answer would be a wl12xx_command, where the 86 * The answer would be a wl1251_command, where the
88 * parameter array contains the actual answer. 87 * parameter array contains the actual answer.
89 */ 88 */
90 wl12xx_spi_mem_read(wl, wl->cmd_box_addr, buf, buf_len); 89 wl1251_spi_mem_read(wl, wl->cmd_box_addr, buf, buf_len);
91 90
92 cmd_answer = buf; 91 cmd_answer = buf;
93 92
94 if (cmd_answer->header.status != CMD_STATUS_SUCCESS) 93 if (cmd_answer->header.status != CMD_STATUS_SUCCESS)
95 wl12xx_error("TEST command answer error: %d", 94 wl1251_error("TEST command answer error: %d",
96 cmd_answer->header.status); 95 cmd_answer->header.status);
97 } 96 }
98 97
@@ -107,30 +106,30 @@ int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer)
107 * @buf: buffer for the response, including all headers, must work with dma 106 * @buf: buffer for the response, including all headers, must work with dma
108 * @len: lenght of buf 107 * @len: lenght of buf
109 */ 108 */
110int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 id, void *buf, size_t len) 109int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len)
111{ 110{
112 struct acx_header *acx = buf; 111 struct acx_header *acx = buf;
113 int ret; 112 int ret;
114 113
115 wl12xx_debug(DEBUG_CMD, "cmd interrogate"); 114 wl1251_debug(DEBUG_CMD, "cmd interrogate");
116 115
117 acx->id = id; 116 acx->id = id;
118 117
119 /* payload length, does not include any headers */ 118 /* payload length, does not include any headers */
120 acx->len = len - sizeof(*acx); 119 acx->len = len - sizeof(*acx);
121 120
122 ret = wl12xx_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx)); 121 ret = wl1251_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx));
123 if (ret < 0) { 122 if (ret < 0) {
124 wl12xx_error("INTERROGATE command failed"); 123 wl1251_error("INTERROGATE command failed");
125 goto out; 124 goto out;
126 } 125 }
127 126
128 /* the interrogate command got in, we can read the answer */ 127 /* the interrogate command got in, we can read the answer */
129 wl12xx_spi_mem_read(wl, wl->cmd_box_addr, buf, len); 128 wl1251_spi_mem_read(wl, wl->cmd_box_addr, buf, len);
130 129
131 acx = buf; 130 acx = buf;
132 if (acx->cmd.status != CMD_STATUS_SUCCESS) 131 if (acx->cmd.status != CMD_STATUS_SUCCESS)
133 wl12xx_error("INTERROGATE command error: %d", 132 wl1251_error("INTERROGATE command error: %d",
134 acx->cmd.status); 133 acx->cmd.status);
135 134
136out: 135out:
@@ -145,34 +144,34 @@ out:
145 * @buf: buffer containing acx, including all headers, must work with dma 144 * @buf: buffer containing acx, including all headers, must work with dma
146 * @len: length of buf 145 * @len: length of buf
147 */ 146 */
148int wl12xx_cmd_configure(struct wl12xx *wl, u16 id, void *buf, size_t len) 147int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len)
149{ 148{
150 struct acx_header *acx = buf; 149 struct acx_header *acx = buf;
151 int ret; 150 int ret;
152 151
153 wl12xx_debug(DEBUG_CMD, "cmd configure"); 152 wl1251_debug(DEBUG_CMD, "cmd configure");
154 153
155 acx->id = id; 154 acx->id = id;
156 155
157 /* payload length, does not include any headers */ 156 /* payload length, does not include any headers */
158 acx->len = len - sizeof(*acx); 157 acx->len = len - sizeof(*acx);
159 158
160 ret = wl12xx_cmd_send(wl, CMD_CONFIGURE, acx, len); 159 ret = wl1251_cmd_send(wl, CMD_CONFIGURE, acx, len);
161 if (ret < 0) { 160 if (ret < 0) {
162 wl12xx_warning("CONFIGURE command NOK"); 161 wl1251_warning("CONFIGURE command NOK");
163 return ret; 162 return ret;
164 } 163 }
165 164
166 return 0; 165 return 0;
167} 166}
168 167
169int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity, 168int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity,
170 void *bitmap, u16 bitmap_len, u8 bitmap_control) 169 void *bitmap, u16 bitmap_len, u8 bitmap_control)
171{ 170{
172 struct wl12xx_cmd_vbm_update *vbm; 171 struct wl1251_cmd_vbm_update *vbm;
173 int ret; 172 int ret;
174 173
175 wl12xx_debug(DEBUG_CMD, "cmd vbm"); 174 wl1251_debug(DEBUG_CMD, "cmd vbm");
176 175
177 vbm = kzalloc(sizeof(*vbm), GFP_KERNEL); 176 vbm = kzalloc(sizeof(*vbm), GFP_KERNEL);
178 if (!vbm) { 177 if (!vbm) {
@@ -183,7 +182,7 @@ int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity,
183 /* Count and period will be filled by the target */ 182 /* Count and period will be filled by the target */
184 vbm->tim.bitmap_ctrl = bitmap_control; 183 vbm->tim.bitmap_ctrl = bitmap_control;
185 if (bitmap_len > PARTIAL_VBM_MAX) { 184 if (bitmap_len > PARTIAL_VBM_MAX) {
186 wl12xx_warning("cmd vbm len is %d B, truncating to %d", 185 wl1251_warning("cmd vbm len is %d B, truncating to %d",
187 bitmap_len, PARTIAL_VBM_MAX); 186 bitmap_len, PARTIAL_VBM_MAX);
188 bitmap_len = PARTIAL_VBM_MAX; 187 bitmap_len = PARTIAL_VBM_MAX;
189 } 188 }
@@ -193,9 +192,9 @@ int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity,
193 192
194 vbm->len = cpu_to_le16(bitmap_len + 5); 193 vbm->len = cpu_to_le16(bitmap_len + 5);
195 194
196 ret = wl12xx_cmd_send(wl, CMD_VBM, vbm, sizeof(*vbm)); 195 ret = wl1251_cmd_send(wl, CMD_VBM, vbm, sizeof(*vbm));
197 if (ret < 0) { 196 if (ret < 0) {
198 wl12xx_error("VBM command failed"); 197 wl1251_error("VBM command failed");
199 goto out; 198 goto out;
200 } 199 }
201 200
@@ -204,13 +203,13 @@ out:
204 return 0; 203 return 0;
205} 204}
206 205
207int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, bool enable) 206int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable)
208{ 207{
209 struct cmd_enabledisable_path *cmd; 208 struct cmd_enabledisable_path *cmd;
210 int ret; 209 int ret;
211 u16 cmd_rx, cmd_tx; 210 u16 cmd_rx, cmd_tx;
212 211
213 wl12xx_debug(DEBUG_CMD, "cmd data path"); 212 wl1251_debug(DEBUG_CMD, "cmd data path");
214 213
215 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 214 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
216 if (!cmd) { 215 if (!cmd) {
@@ -228,24 +227,24 @@ int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, bool enable)
228 cmd_tx = CMD_DISABLE_TX; 227 cmd_tx = CMD_DISABLE_TX;
229 } 228 }
230 229
231 ret = wl12xx_cmd_send(wl, cmd_rx, cmd, sizeof(*cmd)); 230 ret = wl1251_cmd_send(wl, cmd_rx, cmd, sizeof(*cmd));
232 if (ret < 0) { 231 if (ret < 0) {
233 wl12xx_error("rx %s cmd for channel %d failed", 232 wl1251_error("rx %s cmd for channel %d failed",
234 enable ? "start" : "stop", channel); 233 enable ? "start" : "stop", channel);
235 goto out; 234 goto out;
236 } 235 }
237 236
238 wl12xx_debug(DEBUG_BOOT, "rx %s cmd channel %d", 237 wl1251_debug(DEBUG_BOOT, "rx %s cmd channel %d",
239 enable ? "start" : "stop", channel); 238 enable ? "start" : "stop", channel);
240 239
241 ret = wl12xx_cmd_send(wl, cmd_tx, cmd, sizeof(*cmd)); 240 ret = wl1251_cmd_send(wl, cmd_tx, cmd, sizeof(*cmd));
242 if (ret < 0) { 241 if (ret < 0) {
243 wl12xx_error("tx %s cmd for channel %d failed", 242 wl1251_error("tx %s cmd for channel %d failed",
244 enable ? "start" : "stop", channel); 243 enable ? "start" : "stop", channel);
245 return ret; 244 return ret;
246 } 245 }
247 246
248 wl12xx_debug(DEBUG_BOOT, "tx %s cmd channel %d", 247 wl1251_debug(DEBUG_BOOT, "tx %s cmd channel %d",
249 enable ? "start" : "stop", channel); 248 enable ? "start" : "stop", channel);
250 249
251out: 250out:
@@ -253,7 +252,7 @@ out:
253 return ret; 252 return ret;
254} 253}
255 254
256int wl1251_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval, 255int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 dtim_interval,
257 u16 beacon_interval, u8 wait) 256 u16 beacon_interval, u8 wait)
258{ 257{
259 unsigned long timeout; 258 unsigned long timeout;
@@ -268,14 +267,14 @@ int wl1251_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval,
268 } 267 }
269 268
270 /* FIXME: this should be in main.c */ 269 /* FIXME: this should be in main.c */
271 ret = wl12xx_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE, 270 ret = wl1251_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE,
272 DEFAULT_HW_GEN_MODULATION_TYPE, 271 DEFAULT_HW_GEN_MODULATION_TYPE,
273 wl->tx_mgmt_frm_rate, 272 wl->tx_mgmt_frm_rate,
274 wl->tx_mgmt_frm_mod); 273 wl->tx_mgmt_frm_mod);
275 if (ret < 0) 274 if (ret < 0)
276 goto out; 275 goto out;
277 276
278 wl12xx_debug(DEBUG_CMD, "cmd join"); 277 wl1251_debug(DEBUG_CMD, "cmd join");
279 278
280 /* Reverse order BSSID */ 279 /* Reverse order BSSID */
281 bssid = (u8 *) &join->bssid_lsb; 280 bssid = (u8 *) &join->bssid_lsb;
@@ -294,9 +293,9 @@ int wl1251_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval,
294 join->channel = wl->channel; 293 join->channel = wl->channel;
295 join->ctrl = JOIN_CMD_CTRL_TX_FLUSH; 294 join->ctrl = JOIN_CMD_CTRL_TX_FLUSH;
296 295
297 ret = wl12xx_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join)); 296 ret = wl1251_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join));
298 if (ret < 0) { 297 if (ret < 0) {
299 wl12xx_error("failed to initiate cmd join"); 298 wl1251_error("failed to initiate cmd join");
300 goto out; 299 goto out;
301 } 300 }
302 301
@@ -314,20 +313,20 @@ out:
314 return ret; 313 return ret;
315} 314}
316 315
317int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode) 316int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode)
318{ 317{
319 struct wl12xx_cmd_ps_params *ps_params = NULL; 318 struct wl1251_cmd_ps_params *ps_params = NULL;
320 int ret = 0; 319 int ret = 0;
321 320
322 /* FIXME: this should be in ps.c */ 321 /* FIXME: this should be in ps.c */
323 ret = wl12xx_acx_wake_up_conditions(wl, WAKE_UP_EVENT_DTIM_BITMAP, 322 ret = wl1251_acx_wake_up_conditions(wl, WAKE_UP_EVENT_DTIM_BITMAP,
324 wl->listen_int); 323 wl->listen_int);
325 if (ret < 0) { 324 if (ret < 0) {
326 wl12xx_error("couldn't set wake up conditions"); 325 wl1251_error("couldn't set wake up conditions");
327 goto out; 326 goto out;
328 } 327 }
329 328
330 wl12xx_debug(DEBUG_CMD, "cmd set ps mode"); 329 wl1251_debug(DEBUG_CMD, "cmd set ps mode");
331 330
332 ps_params = kzalloc(sizeof(*ps_params), GFP_KERNEL); 331 ps_params = kzalloc(sizeof(*ps_params), GFP_KERNEL);
333 if (!ps_params) { 332 if (!ps_params) {
@@ -341,10 +340,10 @@ int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode)
341 ps_params->hang_over_period = 128; 340 ps_params->hang_over_period = 128;
342 ps_params->null_data_rate = 1; /* 1 Mbps */ 341 ps_params->null_data_rate = 1; /* 1 Mbps */
343 342
344 ret = wl12xx_cmd_send(wl, CMD_SET_PS_MODE, ps_params, 343 ret = wl1251_cmd_send(wl, CMD_SET_PS_MODE, ps_params,
345 sizeof(*ps_params)); 344 sizeof(*ps_params));
346 if (ret < 0) { 345 if (ret < 0) {
347 wl12xx_error("cmd set_ps_mode failed"); 346 wl1251_error("cmd set_ps_mode failed");
348 goto out; 347 goto out;
349 } 348 }
350 349
@@ -353,13 +352,13 @@ out:
353 return ret; 352 return ret;
354} 353}
355 354
356int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, void *answer, 355int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
357 size_t len) 356 size_t len)
358{ 357{
359 struct cmd_read_write_memory *cmd; 358 struct cmd_read_write_memory *cmd;
360 int ret = 0; 359 int ret = 0;
361 360
362 wl12xx_debug(DEBUG_CMD, "cmd read memory"); 361 wl1251_debug(DEBUG_CMD, "cmd read memory");
363 362
364 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); 363 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
365 if (!cmd) { 364 if (!cmd) {
@@ -373,17 +372,17 @@ int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, void *answer,
373 cmd->addr = addr; 372 cmd->addr = addr;
374 cmd->size = len; 373 cmd->size = len;
375 374
376 ret = wl12xx_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd)); 375 ret = wl1251_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd));
377 if (ret < 0) { 376 if (ret < 0) {
378 wl12xx_error("read memory command failed: %d", ret); 377 wl1251_error("read memory command failed: %d", ret);
379 goto out; 378 goto out;
380 } 379 }
381 380
382 /* the read command got in, we can now read the answer */ 381 /* the read command got in, we can now read the answer */
383 wl12xx_spi_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd)); 382 wl1251_spi_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd));
384 383
385 if (cmd->header.status != CMD_STATUS_SUCCESS) 384 if (cmd->header.status != CMD_STATUS_SUCCESS)
386 wl12xx_error("error in read command result: %d", 385 wl1251_error("error in read command result: %d",
387 cmd->header.status); 386 cmd->header.status);
388 387
389 memcpy(answer, cmd->value, len); 388 memcpy(answer, cmd->value, len);
@@ -393,17 +392,17 @@ out:
393 return ret; 392 return ret;
394} 393}
395 394
396int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id, 395int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
397 void *buf, size_t buf_len) 396 void *buf, size_t buf_len)
398{ 397{
399 struct wl12xx_cmd_packet_template *cmd; 398 struct wl1251_cmd_packet_template *cmd;
400 size_t cmd_len; 399 size_t cmd_len;
401 int ret = 0; 400 int ret = 0;
402 401
403 wl12xx_debug(DEBUG_CMD, "cmd template %d", cmd_id); 402 wl1251_debug(DEBUG_CMD, "cmd template %d", cmd_id);
404 403
405 WARN_ON(buf_len > WL12XX_MAX_TEMPLATE_SIZE); 404 WARN_ON(buf_len > WL1251_MAX_TEMPLATE_SIZE);
406 buf_len = min_t(size_t, buf_len, WL12XX_MAX_TEMPLATE_SIZE); 405 buf_len = min_t(size_t, buf_len, WL1251_MAX_TEMPLATE_SIZE);
407 cmd_len = ALIGN(sizeof(*cmd) + buf_len, 4); 406 cmd_len = ALIGN(sizeof(*cmd) + buf_len, 4);
408 407
409 cmd = kzalloc(cmd_len, GFP_KERNEL); 408 cmd = kzalloc(cmd_len, GFP_KERNEL);
@@ -417,9 +416,9 @@ int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id,
417 if (buf) 416 if (buf)
418 memcpy(cmd->data, buf, buf_len); 417 memcpy(cmd->data, buf, buf_len);
419 418
420 ret = wl12xx_cmd_send(wl, cmd_id, cmd, cmd_len); 419 ret = wl1251_cmd_send(wl, cmd_id, cmd, cmd_len);
421 if (ret < 0) { 420 if (ret < 0) {
422 wl12xx_warning("cmd set_template failed: %d", ret); 421 wl1251_warning("cmd set_template failed: %d", ret);
423 goto out; 422 goto out;
424 } 423 }
425 424