diff options
author | Kalle Valo <kvalo@adurom.com> | 2010-10-10 04:28:32 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-10-11 15:04:23 -0400 |
commit | 9bc6772e15d25f58c1be638031280e04514287d4 (patch) | |
tree | 4cff1bcbeb40698df1bbdff7c06cd3a089bcc205 /drivers/net/wireless/wl1251 | |
parent | f03ee1ec73d8cad07b0ef5ba6106a9fc4d179ecb (diff) |
wl1251: move to it's own directory
wl1271 driver is under heavy development but on the other hand the older
wl1251 driver is currently considered more as a legacy driver. To make it
easier to develop wl1271 features move wl1251 to it's own directory,
drivers/net/wireless/wl1251.
There are no functional changes, only moving of files. One regression
is that Kconfig won't be updated automatically and user needs to enable
wl1251 manually with an older config file.
Signed-off-by: Kalle Valo <kvalo@adurom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl1251')
28 files changed, 10264 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl1251/Kconfig b/drivers/net/wireless/wl1251/Kconfig new file mode 100644 index 000000000000..1fb65849414f --- /dev/null +++ b/drivers/net/wireless/wl1251/Kconfig | |||
@@ -0,0 +1,33 @@ | |||
1 | menuconfig WL1251 | ||
2 | tristate "TI wl1251 driver support" | ||
3 | depends on MAC80211 && EXPERIMENTAL && GENERIC_HARDIRQS | ||
4 | select FW_LOADER | ||
5 | select CRC7 | ||
6 | ---help--- | ||
7 | This will enable TI wl1251 driver support. The drivers make | ||
8 | use of the mac80211 stack. | ||
9 | |||
10 | If you choose to build a module, it'll be called wl1251. Say | ||
11 | N if unsure. | ||
12 | |||
13 | config WL1251_SPI | ||
14 | tristate "TI wl1251 SPI support" | ||
15 | depends on WL1251 && SPI_MASTER | ||
16 | ---help--- | ||
17 | This module adds support for the SPI interface of adapters using | ||
18 | TI wl1251 chipset. Select this if your platform is using | ||
19 | the SPI bus. | ||
20 | |||
21 | If you choose to build a module, it'll be called wl1251_spi. | ||
22 | Say N if unsure. | ||
23 | |||
24 | config WL1251_SDIO | ||
25 | tristate "TI wl1251 SDIO support" | ||
26 | depends on WL1251 && MMC | ||
27 | ---help--- | ||
28 | This module adds support for the SDIO interface of adapters using | ||
29 | TI wl1251 chipset. Select this if your platform is using | ||
30 | the SDIO bus. | ||
31 | |||
32 | If you choose to build a module, it'll be called | ||
33 | wl1251_sdio. Say N if unsure. | ||
diff --git a/drivers/net/wireless/wl1251/Makefile b/drivers/net/wireless/wl1251/Makefile new file mode 100644 index 000000000000..4fe246824db3 --- /dev/null +++ b/drivers/net/wireless/wl1251/Makefile | |||
@@ -0,0 +1,6 @@ | |||
1 | wl1251-objs = main.o event.o tx.o rx.o ps.o cmd.o \ | ||
2 | acx.o boot.o init.o debugfs.o io.o | ||
3 | |||
4 | obj-$(CONFIG_WL1251) += wl1251.o | ||
5 | obj-$(CONFIG_WL1251_SPI) += spi.o | ||
6 | obj-$(CONFIG_WL1251_SDIO) += sdio.o | ||
diff --git a/drivers/net/wireless/wl1251/acx.c b/drivers/net/wireless/wl1251/acx.c new file mode 100644 index 000000000000..64a0214cfb29 --- /dev/null +++ b/drivers/net/wireless/wl1251/acx.c | |||
@@ -0,0 +1,1048 @@ | |||
1 | #include "acx.h" | ||
2 | |||
3 | #include <linux/module.h> | ||
4 | #include <linux/slab.h> | ||
5 | #include <linux/crc7.h> | ||
6 | |||
7 | #include "wl1251.h" | ||
8 | #include "reg.h" | ||
9 | #include "cmd.h" | ||
10 | #include "ps.h" | ||
11 | |||
12 | int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod, | ||
13 | u8 mgt_rate, u8 mgt_mod) | ||
14 | { | ||
15 | struct acx_fw_gen_frame_rates *rates; | ||
16 | int ret; | ||
17 | |||
18 | wl1251_debug(DEBUG_ACX, "acx frame rates"); | ||
19 | |||
20 | rates = kzalloc(sizeof(*rates), GFP_KERNEL); | ||
21 | if (!rates) { | ||
22 | ret = -ENOMEM; | ||
23 | goto out; | ||
24 | } | ||
25 | |||
26 | rates->tx_ctrl_frame_rate = ctrl_rate; | ||
27 | rates->tx_ctrl_frame_mod = ctrl_mod; | ||
28 | rates->tx_mgt_frame_rate = mgt_rate; | ||
29 | rates->tx_mgt_frame_mod = mgt_mod; | ||
30 | |||
31 | ret = wl1251_cmd_configure(wl, ACX_FW_GEN_FRAME_RATES, | ||
32 | rates, sizeof(*rates)); | ||
33 | if (ret < 0) { | ||
34 | wl1251_error("Failed to set FW rates and modulation"); | ||
35 | goto out; | ||
36 | } | ||
37 | |||
38 | out: | ||
39 | kfree(rates); | ||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | |||
44 | int wl1251_acx_station_id(struct wl1251 *wl) | ||
45 | { | ||
46 | struct acx_dot11_station_id *mac; | ||
47 | int ret, i; | ||
48 | |||
49 | wl1251_debug(DEBUG_ACX, "acx dot11_station_id"); | ||
50 | |||
51 | mac = kzalloc(sizeof(*mac), GFP_KERNEL); | ||
52 | if (!mac) { | ||
53 | ret = -ENOMEM; | ||
54 | goto out; | ||
55 | } | ||
56 | |||
57 | for (i = 0; i < ETH_ALEN; i++) | ||
58 | mac->mac[i] = wl->mac_addr[ETH_ALEN - 1 - i]; | ||
59 | |||
60 | ret = wl1251_cmd_configure(wl, DOT11_STATION_ID, mac, sizeof(*mac)); | ||
61 | if (ret < 0) | ||
62 | goto out; | ||
63 | |||
64 | out: | ||
65 | kfree(mac); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id) | ||
70 | { | ||
71 | struct acx_dot11_default_key *default_key; | ||
72 | int ret; | ||
73 | |||
74 | wl1251_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id); | ||
75 | |||
76 | default_key = kzalloc(sizeof(*default_key), GFP_KERNEL); | ||
77 | if (!default_key) { | ||
78 | ret = -ENOMEM; | ||
79 | goto out; | ||
80 | } | ||
81 | |||
82 | default_key->id = key_id; | ||
83 | |||
84 | ret = wl1251_cmd_configure(wl, DOT11_DEFAULT_KEY, | ||
85 | default_key, sizeof(*default_key)); | ||
86 | if (ret < 0) { | ||
87 | wl1251_error("Couldn't set default key"); | ||
88 | goto out; | ||
89 | } | ||
90 | |||
91 | wl->default_key = key_id; | ||
92 | |||
93 | out: | ||
94 | kfree(default_key); | ||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event, | ||
99 | u8 listen_interval) | ||
100 | { | ||
101 | struct acx_wake_up_condition *wake_up; | ||
102 | int ret; | ||
103 | |||
104 | wl1251_debug(DEBUG_ACX, "acx wake up conditions"); | ||
105 | |||
106 | wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL); | ||
107 | if (!wake_up) { | ||
108 | ret = -ENOMEM; | ||
109 | goto out; | ||
110 | } | ||
111 | |||
112 | wake_up->wake_up_event = wake_up_event; | ||
113 | wake_up->listen_interval = listen_interval; | ||
114 | |||
115 | ret = wl1251_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS, | ||
116 | wake_up, sizeof(*wake_up)); | ||
117 | if (ret < 0) { | ||
118 | wl1251_warning("could not set wake up conditions: %d", ret); | ||
119 | goto out; | ||
120 | } | ||
121 | |||
122 | out: | ||
123 | kfree(wake_up); | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth) | ||
128 | { | ||
129 | struct acx_sleep_auth *auth; | ||
130 | int ret; | ||
131 | |||
132 | wl1251_debug(DEBUG_ACX, "acx sleep auth"); | ||
133 | |||
134 | auth = kzalloc(sizeof(*auth), GFP_KERNEL); | ||
135 | if (!auth) { | ||
136 | ret = -ENOMEM; | ||
137 | goto out; | ||
138 | } | ||
139 | |||
140 | auth->sleep_auth = sleep_auth; | ||
141 | |||
142 | ret = wl1251_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth)); | ||
143 | if (ret < 0) | ||
144 | return ret; | ||
145 | |||
146 | out: | ||
147 | kfree(auth); | ||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len) | ||
152 | { | ||
153 | struct acx_revision *rev; | ||
154 | int ret; | ||
155 | |||
156 | wl1251_debug(DEBUG_ACX, "acx fw rev"); | ||
157 | |||
158 | rev = kzalloc(sizeof(*rev), GFP_KERNEL); | ||
159 | if (!rev) { | ||
160 | ret = -ENOMEM; | ||
161 | goto out; | ||
162 | } | ||
163 | |||
164 | ret = wl1251_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev)); | ||
165 | if (ret < 0) { | ||
166 | wl1251_warning("ACX_FW_REV interrogate failed"); | ||
167 | goto out; | ||
168 | } | ||
169 | |||
170 | /* be careful with the buffer sizes */ | ||
171 | strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); | ||
172 | |||
173 | /* | ||
174 | * if the firmware version string is exactly | ||
175 | * sizeof(rev->fw_version) long or fw_len is less than | ||
176 | * sizeof(rev->fw_version) it won't be null terminated | ||
177 | */ | ||
178 | buf[min(len, sizeof(rev->fw_version)) - 1] = '\0'; | ||
179 | |||
180 | out: | ||
181 | kfree(rev); | ||
182 | return ret; | ||
183 | } | ||
184 | |||
185 | int wl1251_acx_tx_power(struct wl1251 *wl, int power) | ||
186 | { | ||
187 | struct acx_current_tx_power *acx; | ||
188 | int ret; | ||
189 | |||
190 | wl1251_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr"); | ||
191 | |||
192 | if (power < 0 || power > 25) | ||
193 | return -EINVAL; | ||
194 | |||
195 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
196 | if (!acx) { | ||
197 | ret = -ENOMEM; | ||
198 | goto out; | ||
199 | } | ||
200 | |||
201 | acx->current_tx_power = power * 10; | ||
202 | |||
203 | ret = wl1251_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx)); | ||
204 | if (ret < 0) { | ||
205 | wl1251_warning("configure of tx power failed: %d", ret); | ||
206 | goto out; | ||
207 | } | ||
208 | |||
209 | out: | ||
210 | kfree(acx); | ||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | int wl1251_acx_feature_cfg(struct wl1251 *wl) | ||
215 | { | ||
216 | struct acx_feature_config *feature; | ||
217 | int ret; | ||
218 | |||
219 | wl1251_debug(DEBUG_ACX, "acx feature cfg"); | ||
220 | |||
221 | feature = kzalloc(sizeof(*feature), GFP_KERNEL); | ||
222 | if (!feature) { | ||
223 | ret = -ENOMEM; | ||
224 | goto out; | ||
225 | } | ||
226 | |||
227 | /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */ | ||
228 | feature->data_flow_options = 0; | ||
229 | feature->options = 0; | ||
230 | |||
231 | ret = wl1251_cmd_configure(wl, ACX_FEATURE_CFG, | ||
232 | feature, sizeof(*feature)); | ||
233 | if (ret < 0) { | ||
234 | wl1251_error("Couldn't set HW encryption"); | ||
235 | goto out; | ||
236 | } | ||
237 | |||
238 | out: | ||
239 | kfree(feature); | ||
240 | return ret; | ||
241 | } | ||
242 | |||
243 | int wl1251_acx_mem_map(struct wl1251 *wl, struct acx_header *mem_map, | ||
244 | size_t len) | ||
245 | { | ||
246 | int ret; | ||
247 | |||
248 | wl1251_debug(DEBUG_ACX, "acx mem map"); | ||
249 | |||
250 | ret = wl1251_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len); | ||
251 | if (ret < 0) | ||
252 | return ret; | ||
253 | |||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | int wl1251_acx_data_path_params(struct wl1251 *wl, | ||
258 | struct acx_data_path_params_resp *resp) | ||
259 | { | ||
260 | struct acx_data_path_params *params; | ||
261 | int ret; | ||
262 | |||
263 | wl1251_debug(DEBUG_ACX, "acx data path params"); | ||
264 | |||
265 | params = kzalloc(sizeof(*params), GFP_KERNEL); | ||
266 | if (!params) { | ||
267 | ret = -ENOMEM; | ||
268 | goto out; | ||
269 | } | ||
270 | |||
271 | params->rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE; | ||
272 | params->tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE; | ||
273 | |||
274 | params->rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM; | ||
275 | params->tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM; | ||
276 | |||
277 | params->tx_complete_threshold = 1; | ||
278 | |||
279 | params->tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE; | ||
280 | |||
281 | params->tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT; | ||
282 | |||
283 | ret = wl1251_cmd_configure(wl, ACX_DATA_PATH_PARAMS, | ||
284 | params, sizeof(*params)); | ||
285 | if (ret < 0) | ||
286 | goto out; | ||
287 | |||
288 | /* FIXME: shouldn't this be ACX_DATA_PATH_RESP_PARAMS? */ | ||
289 | ret = wl1251_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS, | ||
290 | resp, sizeof(*resp)); | ||
291 | |||
292 | if (ret < 0) { | ||
293 | wl1251_warning("failed to read data path parameters: %d", ret); | ||
294 | goto out; | ||
295 | } else if (resp->header.cmd.status != CMD_STATUS_SUCCESS) { | ||
296 | wl1251_warning("data path parameter acx status failed"); | ||
297 | ret = -EIO; | ||
298 | goto out; | ||
299 | } | ||
300 | |||
301 | out: | ||
302 | kfree(params); | ||
303 | return ret; | ||
304 | } | ||
305 | |||
306 | int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time) | ||
307 | { | ||
308 | struct acx_rx_msdu_lifetime *acx; | ||
309 | int ret; | ||
310 | |||
311 | wl1251_debug(DEBUG_ACX, "acx rx msdu life time"); | ||
312 | |||
313 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
314 | if (!acx) { | ||
315 | ret = -ENOMEM; | ||
316 | goto out; | ||
317 | } | ||
318 | |||
319 | acx->lifetime = life_time; | ||
320 | ret = wl1251_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME, | ||
321 | acx, sizeof(*acx)); | ||
322 | if (ret < 0) { | ||
323 | wl1251_warning("failed to set rx msdu life time: %d", ret); | ||
324 | goto out; | ||
325 | } | ||
326 | |||
327 | out: | ||
328 | kfree(acx); | ||
329 | return ret; | ||
330 | } | ||
331 | |||
332 | int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter) | ||
333 | { | ||
334 | struct acx_rx_config *rx_config; | ||
335 | int ret; | ||
336 | |||
337 | wl1251_debug(DEBUG_ACX, "acx rx config"); | ||
338 | |||
339 | rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL); | ||
340 | if (!rx_config) { | ||
341 | ret = -ENOMEM; | ||
342 | goto out; | ||
343 | } | ||
344 | |||
345 | rx_config->config_options = config; | ||
346 | rx_config->filter_options = filter; | ||
347 | |||
348 | ret = wl1251_cmd_configure(wl, ACX_RX_CFG, | ||
349 | rx_config, sizeof(*rx_config)); | ||
350 | if (ret < 0) { | ||
351 | wl1251_warning("failed to set rx config: %d", ret); | ||
352 | goto out; | ||
353 | } | ||
354 | |||
355 | out: | ||
356 | kfree(rx_config); | ||
357 | return ret; | ||
358 | } | ||
359 | |||
360 | int wl1251_acx_pd_threshold(struct wl1251 *wl) | ||
361 | { | ||
362 | struct acx_packet_detection *pd; | ||
363 | int ret; | ||
364 | |||
365 | wl1251_debug(DEBUG_ACX, "acx data pd threshold"); | ||
366 | |||
367 | pd = kzalloc(sizeof(*pd), GFP_KERNEL); | ||
368 | if (!pd) { | ||
369 | ret = -ENOMEM; | ||
370 | goto out; | ||
371 | } | ||
372 | |||
373 | /* FIXME: threshold value not set */ | ||
374 | |||
375 | ret = wl1251_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd)); | ||
376 | if (ret < 0) { | ||
377 | wl1251_warning("failed to set pd threshold: %d", ret); | ||
378 | goto out; | ||
379 | } | ||
380 | |||
381 | out: | ||
382 | kfree(pd); | ||
383 | return ret; | ||
384 | } | ||
385 | |||
386 | int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time) | ||
387 | { | ||
388 | struct acx_slot *slot; | ||
389 | int ret; | ||
390 | |||
391 | wl1251_debug(DEBUG_ACX, "acx slot"); | ||
392 | |||
393 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | ||
394 | if (!slot) { | ||
395 | ret = -ENOMEM; | ||
396 | goto out; | ||
397 | } | ||
398 | |||
399 | slot->wone_index = STATION_WONE_INDEX; | ||
400 | slot->slot_time = slot_time; | ||
401 | |||
402 | ret = wl1251_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot)); | ||
403 | if (ret < 0) { | ||
404 | wl1251_warning("failed to set slot time: %d", ret); | ||
405 | goto out; | ||
406 | } | ||
407 | |||
408 | out: | ||
409 | kfree(slot); | ||
410 | return ret; | ||
411 | } | ||
412 | |||
413 | int wl1251_acx_group_address_tbl(struct wl1251 *wl) | ||
414 | { | ||
415 | struct acx_dot11_grp_addr_tbl *acx; | ||
416 | int ret; | ||
417 | |||
418 | wl1251_debug(DEBUG_ACX, "acx group address tbl"); | ||
419 | |||
420 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
421 | if (!acx) { | ||
422 | ret = -ENOMEM; | ||
423 | goto out; | ||
424 | } | ||
425 | |||
426 | /* MAC filtering */ | ||
427 | acx->enabled = 0; | ||
428 | acx->num_groups = 0; | ||
429 | memset(acx->mac_table, 0, ADDRESS_GROUP_MAX_LEN); | ||
430 | |||
431 | ret = wl1251_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL, | ||
432 | acx, sizeof(*acx)); | ||
433 | if (ret < 0) { | ||
434 | wl1251_warning("failed to set group addr table: %d", ret); | ||
435 | goto out; | ||
436 | } | ||
437 | |||
438 | out: | ||
439 | kfree(acx); | ||
440 | return ret; | ||
441 | } | ||
442 | |||
443 | int wl1251_acx_service_period_timeout(struct wl1251 *wl) | ||
444 | { | ||
445 | struct acx_rx_timeout *rx_timeout; | ||
446 | int ret; | ||
447 | |||
448 | rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL); | ||
449 | if (!rx_timeout) { | ||
450 | ret = -ENOMEM; | ||
451 | goto out; | ||
452 | } | ||
453 | |||
454 | wl1251_debug(DEBUG_ACX, "acx service period timeout"); | ||
455 | |||
456 | rx_timeout->ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF; | ||
457 | rx_timeout->upsd_timeout = RX_TIMEOUT_UPSD_DEF; | ||
458 | |||
459 | ret = wl1251_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT, | ||
460 | rx_timeout, sizeof(*rx_timeout)); | ||
461 | if (ret < 0) { | ||
462 | wl1251_warning("failed to set service period timeout: %d", | ||
463 | ret); | ||
464 | goto out; | ||
465 | } | ||
466 | |||
467 | out: | ||
468 | kfree(rx_timeout); | ||
469 | return ret; | ||
470 | } | ||
471 | |||
472 | int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold) | ||
473 | { | ||
474 | struct acx_rts_threshold *rts; | ||
475 | int ret; | ||
476 | |||
477 | wl1251_debug(DEBUG_ACX, "acx rts threshold"); | ||
478 | |||
479 | rts = kzalloc(sizeof(*rts), GFP_KERNEL); | ||
480 | if (!rts) { | ||
481 | ret = -ENOMEM; | ||
482 | goto out; | ||
483 | } | ||
484 | |||
485 | rts->threshold = rts_threshold; | ||
486 | |||
487 | ret = wl1251_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts)); | ||
488 | if (ret < 0) { | ||
489 | wl1251_warning("failed to set rts threshold: %d", ret); | ||
490 | goto out; | ||
491 | } | ||
492 | |||
493 | out: | ||
494 | kfree(rts); | ||
495 | return ret; | ||
496 | } | ||
497 | |||
498 | int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter) | ||
499 | { | ||
500 | struct acx_beacon_filter_option *beacon_filter; | ||
501 | int ret; | ||
502 | |||
503 | wl1251_debug(DEBUG_ACX, "acx beacon filter opt"); | ||
504 | |||
505 | beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL); | ||
506 | if (!beacon_filter) { | ||
507 | ret = -ENOMEM; | ||
508 | goto out; | ||
509 | } | ||
510 | |||
511 | beacon_filter->enable = enable_filter; | ||
512 | beacon_filter->max_num_beacons = 0; | ||
513 | |||
514 | ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_OPT, | ||
515 | beacon_filter, sizeof(*beacon_filter)); | ||
516 | if (ret < 0) { | ||
517 | wl1251_warning("failed to set beacon filter opt: %d", ret); | ||
518 | goto out; | ||
519 | } | ||
520 | |||
521 | out: | ||
522 | kfree(beacon_filter); | ||
523 | return ret; | ||
524 | } | ||
525 | |||
526 | int wl1251_acx_beacon_filter_table(struct wl1251 *wl) | ||
527 | { | ||
528 | struct acx_beacon_filter_ie_table *ie_table; | ||
529 | int idx = 0; | ||
530 | int ret; | ||
531 | |||
532 | wl1251_debug(DEBUG_ACX, "acx beacon filter table"); | ||
533 | |||
534 | ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL); | ||
535 | if (!ie_table) { | ||
536 | ret = -ENOMEM; | ||
537 | goto out; | ||
538 | } | ||
539 | |||
540 | /* configure default beacon pass-through rules */ | ||
541 | ie_table->num_ie = 1; | ||
542 | ie_table->table[idx++] = BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN; | ||
543 | ie_table->table[idx++] = BEACON_RULE_PASS_ON_APPEARANCE; | ||
544 | |||
545 | ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE, | ||
546 | ie_table, sizeof(*ie_table)); | ||
547 | if (ret < 0) { | ||
548 | wl1251_warning("failed to set beacon filter table: %d", ret); | ||
549 | goto out; | ||
550 | } | ||
551 | |||
552 | out: | ||
553 | kfree(ie_table); | ||
554 | return ret; | ||
555 | } | ||
556 | |||
557 | int wl1251_acx_conn_monit_params(struct wl1251 *wl) | ||
558 | { | ||
559 | struct acx_conn_monit_params *acx; | ||
560 | int ret; | ||
561 | |||
562 | wl1251_debug(DEBUG_ACX, "acx connection monitor parameters"); | ||
563 | |||
564 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
565 | if (!acx) { | ||
566 | ret = -ENOMEM; | ||
567 | goto out; | ||
568 | } | ||
569 | |||
570 | acx->synch_fail_thold = SYNCH_FAIL_DEFAULT_THRESHOLD; | ||
571 | acx->bss_lose_timeout = NO_BEACON_DEFAULT_TIMEOUT; | ||
572 | |||
573 | ret = wl1251_cmd_configure(wl, ACX_CONN_MONIT_PARAMS, | ||
574 | acx, sizeof(*acx)); | ||
575 | if (ret < 0) { | ||
576 | wl1251_warning("failed to set connection monitor " | ||
577 | "parameters: %d", ret); | ||
578 | goto out; | ||
579 | } | ||
580 | |||
581 | out: | ||
582 | kfree(acx); | ||
583 | return ret; | ||
584 | } | ||
585 | |||
586 | int wl1251_acx_sg_enable(struct wl1251 *wl) | ||
587 | { | ||
588 | struct acx_bt_wlan_coex *pta; | ||
589 | int ret; | ||
590 | |||
591 | wl1251_debug(DEBUG_ACX, "acx sg enable"); | ||
592 | |||
593 | pta = kzalloc(sizeof(*pta), GFP_KERNEL); | ||
594 | if (!pta) { | ||
595 | ret = -ENOMEM; | ||
596 | goto out; | ||
597 | } | ||
598 | |||
599 | pta->enable = SG_ENABLE; | ||
600 | |||
601 | ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta)); | ||
602 | if (ret < 0) { | ||
603 | wl1251_warning("failed to set softgemini enable: %d", ret); | ||
604 | goto out; | ||
605 | } | ||
606 | |||
607 | out: | ||
608 | kfree(pta); | ||
609 | return ret; | ||
610 | } | ||
611 | |||
612 | int wl1251_acx_sg_cfg(struct wl1251 *wl) | ||
613 | { | ||
614 | struct acx_bt_wlan_coex_param *param; | ||
615 | int ret; | ||
616 | |||
617 | wl1251_debug(DEBUG_ACX, "acx sg cfg"); | ||
618 | |||
619 | param = kzalloc(sizeof(*param), GFP_KERNEL); | ||
620 | if (!param) { | ||
621 | ret = -ENOMEM; | ||
622 | goto out; | ||
623 | } | ||
624 | |||
625 | /* BT-WLAN coext parameters */ | ||
626 | param->min_rate = RATE_INDEX_24MBPS; | ||
627 | param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF; | ||
628 | param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF; | ||
629 | param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF; | ||
630 | param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF; | ||
631 | param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF; | ||
632 | param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF; | ||
633 | param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF; | ||
634 | param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF; | ||
635 | param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF; | ||
636 | param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF; | ||
637 | param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF; | ||
638 | param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF; | ||
639 | param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF; | ||
640 | param->antenna_type = PTA_ANTENNA_TYPE_DEF; | ||
641 | param->signal_type = PTA_SIGNALING_TYPE_DEF; | ||
642 | param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF; | ||
643 | param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF; | ||
644 | param->max_cts = PTA_MAX_NUM_CTS_DEF; | ||
645 | param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF; | ||
646 | param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF; | ||
647 | param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF; | ||
648 | param->wlan_elp_hp = PTA_ELP_HP_DEF; | ||
649 | param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF; | ||
650 | param->ack_mode_dual_ant = PTA_ACK_MODE_DEF; | ||
651 | param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF; | ||
652 | param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF; | ||
653 | param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF; | ||
654 | |||
655 | ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param)); | ||
656 | if (ret < 0) { | ||
657 | wl1251_warning("failed to set sg config: %d", ret); | ||
658 | goto out; | ||
659 | } | ||
660 | |||
661 | out: | ||
662 | kfree(param); | ||
663 | return ret; | ||
664 | } | ||
665 | |||
666 | int wl1251_acx_cca_threshold(struct wl1251 *wl) | ||
667 | { | ||
668 | struct acx_energy_detection *detection; | ||
669 | int ret; | ||
670 | |||
671 | wl1251_debug(DEBUG_ACX, "acx cca threshold"); | ||
672 | |||
673 | detection = kzalloc(sizeof(*detection), GFP_KERNEL); | ||
674 | if (!detection) { | ||
675 | ret = -ENOMEM; | ||
676 | goto out; | ||
677 | } | ||
678 | |||
679 | detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D; | ||
680 | detection->tx_energy_detection = 0; | ||
681 | |||
682 | ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD, | ||
683 | detection, sizeof(*detection)); | ||
684 | if (ret < 0) { | ||
685 | wl1251_warning("failed to set cca threshold: %d", ret); | ||
686 | return ret; | ||
687 | } | ||
688 | |||
689 | out: | ||
690 | kfree(detection); | ||
691 | return ret; | ||
692 | } | ||
693 | |||
694 | int wl1251_acx_bcn_dtim_options(struct wl1251 *wl) | ||
695 | { | ||
696 | struct acx_beacon_broadcast *bb; | ||
697 | int ret; | ||
698 | |||
699 | wl1251_debug(DEBUG_ACX, "acx bcn dtim options"); | ||
700 | |||
701 | bb = kzalloc(sizeof(*bb), GFP_KERNEL); | ||
702 | if (!bb) { | ||
703 | ret = -ENOMEM; | ||
704 | goto out; | ||
705 | } | ||
706 | |||
707 | bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE; | ||
708 | bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE; | ||
709 | bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE; | ||
710 | bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF; | ||
711 | |||
712 | ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb)); | ||
713 | if (ret < 0) { | ||
714 | wl1251_warning("failed to set rx config: %d", ret); | ||
715 | goto out; | ||
716 | } | ||
717 | |||
718 | out: | ||
719 | kfree(bb); | ||
720 | return ret; | ||
721 | } | ||
722 | |||
723 | int wl1251_acx_aid(struct wl1251 *wl, u16 aid) | ||
724 | { | ||
725 | struct acx_aid *acx_aid; | ||
726 | int ret; | ||
727 | |||
728 | wl1251_debug(DEBUG_ACX, "acx aid"); | ||
729 | |||
730 | acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL); | ||
731 | if (!acx_aid) { | ||
732 | ret = -ENOMEM; | ||
733 | goto out; | ||
734 | } | ||
735 | |||
736 | acx_aid->aid = aid; | ||
737 | |||
738 | ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid)); | ||
739 | if (ret < 0) { | ||
740 | wl1251_warning("failed to set aid: %d", ret); | ||
741 | goto out; | ||
742 | } | ||
743 | |||
744 | out: | ||
745 | kfree(acx_aid); | ||
746 | return ret; | ||
747 | } | ||
748 | |||
749 | int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask) | ||
750 | { | ||
751 | struct acx_event_mask *mask; | ||
752 | int ret; | ||
753 | |||
754 | wl1251_debug(DEBUG_ACX, "acx event mbox mask"); | ||
755 | |||
756 | mask = kzalloc(sizeof(*mask), GFP_KERNEL); | ||
757 | if (!mask) { | ||
758 | ret = -ENOMEM; | ||
759 | goto out; | ||
760 | } | ||
761 | |||
762 | /* high event mask is unused */ | ||
763 | mask->high_event_mask = 0xffffffff; | ||
764 | |||
765 | mask->event_mask = event_mask; | ||
766 | |||
767 | ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK, | ||
768 | mask, sizeof(*mask)); | ||
769 | if (ret < 0) { | ||
770 | wl1251_warning("failed to set acx_event_mbox_mask: %d", ret); | ||
771 | goto out; | ||
772 | } | ||
773 | |||
774 | out: | ||
775 | kfree(mask); | ||
776 | return ret; | ||
777 | } | ||
778 | |||
779 | int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble) | ||
780 | { | ||
781 | struct acx_preamble *acx; | ||
782 | int ret; | ||
783 | |||
784 | wl1251_debug(DEBUG_ACX, "acx_set_preamble"); | ||
785 | |||
786 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
787 | if (!acx) { | ||
788 | ret = -ENOMEM; | ||
789 | goto out; | ||
790 | } | ||
791 | |||
792 | acx->preamble = preamble; | ||
793 | |||
794 | ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx)); | ||
795 | if (ret < 0) { | ||
796 | wl1251_warning("Setting of preamble failed: %d", ret); | ||
797 | goto out; | ||
798 | } | ||
799 | |||
800 | out: | ||
801 | kfree(acx); | ||
802 | return ret; | ||
803 | } | ||
804 | |||
805 | int wl1251_acx_cts_protect(struct wl1251 *wl, | ||
806 | enum acx_ctsprotect_type ctsprotect) | ||
807 | { | ||
808 | struct acx_ctsprotect *acx; | ||
809 | int ret; | ||
810 | |||
811 | wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect"); | ||
812 | |||
813 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
814 | if (!acx) { | ||
815 | ret = -ENOMEM; | ||
816 | goto out; | ||
817 | } | ||
818 | |||
819 | acx->ctsprotect = ctsprotect; | ||
820 | |||
821 | ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx)); | ||
822 | if (ret < 0) { | ||
823 | wl1251_warning("Setting of ctsprotect failed: %d", ret); | ||
824 | goto out; | ||
825 | } | ||
826 | |||
827 | out: | ||
828 | kfree(acx); | ||
829 | return ret; | ||
830 | } | ||
831 | |||
832 | int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime) | ||
833 | { | ||
834 | struct acx_tsf_info *tsf_info; | ||
835 | int ret; | ||
836 | |||
837 | tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL); | ||
838 | if (!tsf_info) { | ||
839 | ret = -ENOMEM; | ||
840 | goto out; | ||
841 | } | ||
842 | |||
843 | ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO, | ||
844 | tsf_info, sizeof(*tsf_info)); | ||
845 | if (ret < 0) { | ||
846 | wl1251_warning("ACX_FW_REV interrogate failed"); | ||
847 | goto out; | ||
848 | } | ||
849 | |||
850 | *mactime = tsf_info->current_tsf_lsb | | ||
851 | (tsf_info->current_tsf_msb << 31); | ||
852 | |||
853 | out: | ||
854 | kfree(tsf_info); | ||
855 | return ret; | ||
856 | } | ||
857 | |||
858 | int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats) | ||
859 | { | ||
860 | int ret; | ||
861 | |||
862 | wl1251_debug(DEBUG_ACX, "acx statistics"); | ||
863 | |||
864 | ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats, | ||
865 | sizeof(*stats)); | ||
866 | if (ret < 0) { | ||
867 | wl1251_warning("acx statistics failed: %d", ret); | ||
868 | return -ENOMEM; | ||
869 | } | ||
870 | |||
871 | return 0; | ||
872 | } | ||
873 | |||
874 | int wl1251_acx_rate_policies(struct wl1251 *wl) | ||
875 | { | ||
876 | struct acx_rate_policy *acx; | ||
877 | int ret = 0; | ||
878 | |||
879 | wl1251_debug(DEBUG_ACX, "acx rate policies"); | ||
880 | |||
881 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
882 | |||
883 | if (!acx) { | ||
884 | ret = -ENOMEM; | ||
885 | goto out; | ||
886 | } | ||
887 | |||
888 | /* configure one default (one-size-fits-all) rate class */ | ||
889 | acx->rate_class_cnt = 1; | ||
890 | acx->rate_class[0].enabled_rates = ACX_RATE_MASK_UNSPECIFIED; | ||
891 | acx->rate_class[0].short_retry_limit = ACX_RATE_RETRY_LIMIT; | ||
892 | acx->rate_class[0].long_retry_limit = ACX_RATE_RETRY_LIMIT; | ||
893 | acx->rate_class[0].aflags = 0; | ||
894 | |||
895 | ret = wl1251_cmd_configure(wl, ACX_RATE_POLICY, acx, sizeof(*acx)); | ||
896 | if (ret < 0) { | ||
897 | wl1251_warning("Setting of rate policies failed: %d", ret); | ||
898 | goto out; | ||
899 | } | ||
900 | |||
901 | out: | ||
902 | kfree(acx); | ||
903 | return ret; | ||
904 | } | ||
905 | |||
906 | int wl1251_acx_mem_cfg(struct wl1251 *wl) | ||
907 | { | ||
908 | struct wl1251_acx_config_memory *mem_conf; | ||
909 | int ret, i; | ||
910 | |||
911 | wl1251_debug(DEBUG_ACX, "acx mem cfg"); | ||
912 | |||
913 | mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL); | ||
914 | if (!mem_conf) { | ||
915 | ret = -ENOMEM; | ||
916 | goto out; | ||
917 | } | ||
918 | |||
919 | /* memory config */ | ||
920 | mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS); | ||
921 | mem_conf->mem_config.rx_mem_block_num = 35; | ||
922 | mem_conf->mem_config.tx_min_mem_block_num = 64; | ||
923 | mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES; | ||
924 | mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING; | ||
925 | mem_conf->mem_config.num_ssid_profiles = 1; | ||
926 | mem_conf->mem_config.debug_buffer_size = | ||
927 | cpu_to_le16(TRACE_BUFFER_MAX_SIZE); | ||
928 | |||
929 | /* RX queue config */ | ||
930 | mem_conf->rx_queue_config.dma_address = 0; | ||
931 | mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF; | ||
932 | mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY; | ||
933 | mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE; | ||
934 | |||
935 | /* TX queue config */ | ||
936 | for (i = 0; i < MAX_TX_QUEUES; i++) { | ||
937 | mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF; | ||
938 | mem_conf->tx_queue_config[i].attributes = i; | ||
939 | } | ||
940 | |||
941 | ret = wl1251_cmd_configure(wl, ACX_MEM_CFG, mem_conf, | ||
942 | sizeof(*mem_conf)); | ||
943 | if (ret < 0) { | ||
944 | wl1251_warning("wl1251 mem config failed: %d", ret); | ||
945 | goto out; | ||
946 | } | ||
947 | |||
948 | out: | ||
949 | kfree(mem_conf); | ||
950 | return ret; | ||
951 | } | ||
952 | |||
953 | int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim) | ||
954 | { | ||
955 | struct wl1251_acx_wr_tbtt_and_dtim *acx; | ||
956 | int ret; | ||
957 | |||
958 | wl1251_debug(DEBUG_ACX, "acx tbtt and dtim"); | ||
959 | |||
960 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
961 | if (!acx) { | ||
962 | ret = -ENOMEM; | ||
963 | goto out; | ||
964 | } | ||
965 | |||
966 | acx->tbtt = tbtt; | ||
967 | acx->dtim = dtim; | ||
968 | |||
969 | ret = wl1251_cmd_configure(wl, ACX_WR_TBTT_AND_DTIM, | ||
970 | acx, sizeof(*acx)); | ||
971 | if (ret < 0) { | ||
972 | wl1251_warning("failed to set tbtt and dtim: %d", ret); | ||
973 | goto out; | ||
974 | } | ||
975 | |||
976 | out: | ||
977 | kfree(acx); | ||
978 | return ret; | ||
979 | } | ||
980 | |||
981 | int wl1251_acx_ac_cfg(struct wl1251 *wl, u8 ac, u8 cw_min, u16 cw_max, | ||
982 | u8 aifs, u16 txop) | ||
983 | { | ||
984 | struct wl1251_acx_ac_cfg *acx; | ||
985 | int ret = 0; | ||
986 | |||
987 | wl1251_debug(DEBUG_ACX, "acx ac cfg %d cw_ming %d cw_max %d " | ||
988 | "aifs %d txop %d", ac, cw_min, cw_max, aifs, txop); | ||
989 | |||
990 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
991 | |||
992 | if (!acx) { | ||
993 | ret = -ENOMEM; | ||
994 | goto out; | ||
995 | } | ||
996 | |||
997 | acx->ac = ac; | ||
998 | acx->cw_min = cw_min; | ||
999 | acx->cw_max = cw_max; | ||
1000 | acx->aifsn = aifs; | ||
1001 | acx->txop_limit = txop; | ||
1002 | |||
1003 | ret = wl1251_cmd_configure(wl, ACX_AC_CFG, acx, sizeof(*acx)); | ||
1004 | if (ret < 0) { | ||
1005 | wl1251_warning("acx ac cfg failed: %d", ret); | ||
1006 | goto out; | ||
1007 | } | ||
1008 | |||
1009 | out: | ||
1010 | kfree(acx); | ||
1011 | return ret; | ||
1012 | } | ||
1013 | |||
1014 | int wl1251_acx_tid_cfg(struct wl1251 *wl, u8 queue, | ||
1015 | enum wl1251_acx_channel_type type, | ||
1016 | u8 tsid, enum wl1251_acx_ps_scheme ps_scheme, | ||
1017 | enum wl1251_acx_ack_policy ack_policy) | ||
1018 | { | ||
1019 | struct wl1251_acx_tid_cfg *acx; | ||
1020 | int ret = 0; | ||
1021 | |||
1022 | wl1251_debug(DEBUG_ACX, "acx tid cfg %d type %d tsid %d " | ||
1023 | "ps_scheme %d ack_policy %d", queue, type, tsid, | ||
1024 | ps_scheme, ack_policy); | ||
1025 | |||
1026 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
1027 | |||
1028 | if (!acx) { | ||
1029 | ret = -ENOMEM; | ||
1030 | goto out; | ||
1031 | } | ||
1032 | |||
1033 | acx->queue = queue; | ||
1034 | acx->type = type; | ||
1035 | acx->tsid = tsid; | ||
1036 | acx->ps_scheme = ps_scheme; | ||
1037 | acx->ack_policy = ack_policy; | ||
1038 | |||
1039 | ret = wl1251_cmd_configure(wl, ACX_TID_CFG, acx, sizeof(*acx)); | ||
1040 | if (ret < 0) { | ||
1041 | wl1251_warning("acx tid cfg failed: %d", ret); | ||
1042 | goto out; | ||
1043 | } | ||
1044 | |||
1045 | out: | ||
1046 | kfree(acx); | ||
1047 | return ret; | ||
1048 | } | ||
diff --git a/drivers/net/wireless/wl1251/acx.h b/drivers/net/wireless/wl1251/acx.h new file mode 100644 index 000000000000..e54b21a4f8b1 --- /dev/null +++ b/drivers/net/wireless/wl1251/acx.h | |||
@@ -0,0 +1,1411 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __WL1251_ACX_H__ | ||
24 | #define __WL1251_ACX_H__ | ||
25 | |||
26 | #include "wl1251.h" | ||
27 | #include "cmd.h" | ||
28 | |||
29 | /* Target's information element */ | ||
30 | struct acx_header { | ||
31 | struct wl1251_cmd_header cmd; | ||
32 | |||
33 | /* acx (or information element) header */ | ||
34 | u16 id; | ||
35 | |||
36 | /* payload length (not including headers */ | ||
37 | u16 len; | ||
38 | } __packed; | ||
39 | |||
40 | struct acx_error_counter { | ||
41 | struct acx_header header; | ||
42 | |||
43 | /* The number of PLCP errors since the last time this */ | ||
44 | /* information element was interrogated. This field is */ | ||
45 | /* automatically cleared when it is interrogated.*/ | ||
46 | u32 PLCP_error; | ||
47 | |||
48 | /* The number of FCS errors since the last time this */ | ||
49 | /* information element was interrogated. This field is */ | ||
50 | /* automatically cleared when it is interrogated.*/ | ||
51 | u32 FCS_error; | ||
52 | |||
53 | /* The number of MPDUs without PLCP header errors received*/ | ||
54 | /* since the last time this information element was interrogated. */ | ||
55 | /* This field is automatically cleared when it is interrogated.*/ | ||
56 | u32 valid_frame; | ||
57 | |||
58 | /* the number of missed sequence numbers in the squentially */ | ||
59 | /* values of frames seq numbers */ | ||
60 | u32 seq_num_miss; | ||
61 | } __packed; | ||
62 | |||
63 | struct acx_revision { | ||
64 | struct acx_header header; | ||
65 | |||
66 | /* | ||
67 | * The WiLink firmware version, an ASCII string x.x.x.x, | ||
68 | * that uniquely identifies the current firmware. | ||
69 | * The left most digit is incremented each time a | ||
70 | * significant change is made to the firmware, such as | ||
71 | * code redesign or new platform support. | ||
72 | * The second digit is incremented when major enhancements | ||
73 | * are added or major fixes are made. | ||
74 | * The third digit is incremented for each GA release. | ||
75 | * The fourth digit is incremented for each build. | ||
76 | * The first two digits identify a firmware release version, | ||
77 | * in other words, a unique set of features. | ||
78 | * The first three digits identify a GA release. | ||
79 | */ | ||
80 | char fw_version[20]; | ||
81 | |||
82 | /* | ||
83 | * This 4 byte field specifies the WiLink hardware version. | ||
84 | * bits 0 - 15: Reserved. | ||
85 | * bits 16 - 23: Version ID - The WiLink version ID | ||
86 | * (1 = first spin, 2 = second spin, and so on). | ||
87 | * bits 24 - 31: Chip ID - The WiLink chip ID. | ||
88 | */ | ||
89 | u32 hw_version; | ||
90 | } __packed; | ||
91 | |||
92 | enum wl1251_psm_mode { | ||
93 | /* Active mode */ | ||
94 | WL1251_PSM_CAM = 0, | ||
95 | |||
96 | /* Power save mode */ | ||
97 | WL1251_PSM_PS = 1, | ||
98 | |||
99 | /* Extreme low power */ | ||
100 | WL1251_PSM_ELP = 2, | ||
101 | }; | ||
102 | |||
103 | struct acx_sleep_auth { | ||
104 | struct acx_header header; | ||
105 | |||
106 | /* The sleep level authorization of the device. */ | ||
107 | /* 0 - Always active*/ | ||
108 | /* 1 - Power down mode: light / fast sleep*/ | ||
109 | /* 2 - ELP mode: Deep / Max sleep*/ | ||
110 | u8 sleep_auth; | ||
111 | u8 padding[3]; | ||
112 | } __packed; | ||
113 | |||
114 | enum { | ||
115 | HOSTIF_PCI_MASTER_HOST_INDIRECT, | ||
116 | HOSTIF_PCI_MASTER_HOST_DIRECT, | ||
117 | HOSTIF_SLAVE, | ||
118 | HOSTIF_PKT_RING, | ||
119 | HOSTIF_DONTCARE = 0xFF | ||
120 | }; | ||
121 | |||
122 | #define DEFAULT_UCAST_PRIORITY 0 | ||
123 | #define DEFAULT_RX_Q_PRIORITY 0 | ||
124 | #define DEFAULT_NUM_STATIONS 1 | ||
125 | #define DEFAULT_RXQ_PRIORITY 0 /* low 0 .. 15 high */ | ||
126 | #define DEFAULT_RXQ_TYPE 0x07 /* All frames, Data/Ctrl/Mgmt */ | ||
127 | #define TRACE_BUFFER_MAX_SIZE 256 | ||
128 | |||
129 | #define DP_RX_PACKET_RING_CHUNK_SIZE 1600 | ||
130 | #define DP_TX_PACKET_RING_CHUNK_SIZE 1600 | ||
131 | #define DP_RX_PACKET_RING_CHUNK_NUM 2 | ||
132 | #define DP_TX_PACKET_RING_CHUNK_NUM 2 | ||
133 | #define DP_TX_COMPLETE_TIME_OUT 20 | ||
134 | #define FW_TX_CMPLT_BLOCK_SIZE 16 | ||
135 | |||
136 | struct acx_data_path_params { | ||
137 | struct acx_header header; | ||
138 | |||
139 | u16 rx_packet_ring_chunk_size; | ||
140 | u16 tx_packet_ring_chunk_size; | ||
141 | |||
142 | u8 rx_packet_ring_chunk_num; | ||
143 | u8 tx_packet_ring_chunk_num; | ||
144 | |||
145 | /* | ||
146 | * Maximum number of packets that can be gathered | ||
147 | * in the TX complete ring before an interrupt | ||
148 | * is generated. | ||
149 | */ | ||
150 | u8 tx_complete_threshold; | ||
151 | |||
152 | /* Number of pending TX complete entries in cyclic ring.*/ | ||
153 | u8 tx_complete_ring_depth; | ||
154 | |||
155 | /* | ||
156 | * Max num microseconds since a packet enters the TX | ||
157 | * complete ring until an interrupt is generated. | ||
158 | */ | ||
159 | u32 tx_complete_timeout; | ||
160 | } __packed; | ||
161 | |||
162 | |||
163 | struct acx_data_path_params_resp { | ||
164 | struct acx_header header; | ||
165 | |||
166 | u16 rx_packet_ring_chunk_size; | ||
167 | u16 tx_packet_ring_chunk_size; | ||
168 | |||
169 | u8 rx_packet_ring_chunk_num; | ||
170 | u8 tx_packet_ring_chunk_num; | ||
171 | |||
172 | u8 pad[2]; | ||
173 | |||
174 | u32 rx_packet_ring_addr; | ||
175 | u32 tx_packet_ring_addr; | ||
176 | |||
177 | u32 rx_control_addr; | ||
178 | u32 tx_control_addr; | ||
179 | |||
180 | u32 tx_complete_addr; | ||
181 | } __packed; | ||
182 | |||
183 | #define TX_MSDU_LIFETIME_MIN 0 | ||
184 | #define TX_MSDU_LIFETIME_MAX 3000 | ||
185 | #define TX_MSDU_LIFETIME_DEF 512 | ||
186 | #define RX_MSDU_LIFETIME_MIN 0 | ||
187 | #define RX_MSDU_LIFETIME_MAX 0xFFFFFFFF | ||
188 | #define RX_MSDU_LIFETIME_DEF 512000 | ||
189 | |||
190 | struct acx_rx_msdu_lifetime { | ||
191 | struct acx_header header; | ||
192 | |||
193 | /* | ||
194 | * The maximum amount of time, in TU, before the | ||
195 | * firmware discards the MSDU. | ||
196 | */ | ||
197 | u32 lifetime; | ||
198 | } __packed; | ||
199 | |||
200 | /* | ||
201 | * RX Config Options Table | ||
202 | * Bit Definition | ||
203 | * === ========== | ||
204 | * 31:14 Reserved | ||
205 | * 13 Copy RX Status - when set, write three receive status words | ||
206 | * to top of rx'd MPDUs. | ||
207 | * When cleared, do not write three status words (added rev 1.5) | ||
208 | * 12 Reserved | ||
209 | * 11 RX Complete upon FCS error - when set, give rx complete | ||
210 | * interrupt for FCS errors, after the rx filtering, e.g. unicast | ||
211 | * frames not to us with FCS error will not generate an interrupt. | ||
212 | * 10 SSID Filter Enable - When set, the WiLink discards all beacon, | ||
213 | * probe request, and probe response frames with an SSID that does | ||
214 | * not match the SSID specified by the host in the START/JOIN | ||
215 | * command. | ||
216 | * When clear, the WiLink receives frames with any SSID. | ||
217 | * 9 Broadcast Filter Enable - When set, the WiLink discards all | ||
218 | * broadcast frames. When clear, the WiLink receives all received | ||
219 | * broadcast frames. | ||
220 | * 8:6 Reserved | ||
221 | * 5 BSSID Filter Enable - When set, the WiLink discards any frames | ||
222 | * with a BSSID that does not match the BSSID specified by the | ||
223 | * host. | ||
224 | * When clear, the WiLink receives frames from any BSSID. | ||
225 | * 4 MAC Addr Filter - When set, the WiLink discards any frames | ||
226 | * with a destination address that does not match the MAC address | ||
227 | * of the adaptor. | ||
228 | * When clear, the WiLink receives frames destined to any MAC | ||
229 | * address. | ||
230 | * 3 Promiscuous - When set, the WiLink receives all valid frames | ||
231 | * (i.e., all frames that pass the FCS check). | ||
232 | * When clear, only frames that pass the other filters specified | ||
233 | * are received. | ||
234 | * 2 FCS - When set, the WiLink includes the FCS with the received | ||
235 | * frame. | ||
236 | * When cleared, the FCS is discarded. | ||
237 | * 1 PLCP header - When set, write all data from baseband to frame | ||
238 | * buffer including PHY header. | ||
239 | * 0 Reserved - Always equal to 0. | ||
240 | * | ||
241 | * RX Filter Options Table | ||
242 | * Bit Definition | ||
243 | * === ========== | ||
244 | * 31:12 Reserved - Always equal to 0. | ||
245 | * 11 Association - When set, the WiLink receives all association | ||
246 | * related frames (association request/response, reassocation | ||
247 | * request/response, and disassociation). When clear, these frames | ||
248 | * are discarded. | ||
249 | * 10 Auth/De auth - When set, the WiLink receives all authentication | ||
250 | * and de-authentication frames. When clear, these frames are | ||
251 | * discarded. | ||
252 | * 9 Beacon - When set, the WiLink receives all beacon frames. | ||
253 | * When clear, these frames are discarded. | ||
254 | * 8 Contention Free - When set, the WiLink receives all contention | ||
255 | * free frames. | ||
256 | * When clear, these frames are discarded. | ||
257 | * 7 Control - When set, the WiLink receives all control frames. | ||
258 | * When clear, these frames are discarded. | ||
259 | * 6 Data - When set, the WiLink receives all data frames. | ||
260 | * When clear, these frames are discarded. | ||
261 | * 5 FCS Error - When set, the WiLink receives frames that have FCS | ||
262 | * errors. | ||
263 | * When clear, these frames are discarded. | ||
264 | * 4 Management - When set, the WiLink receives all management | ||
265 | * frames. | ||
266 | * When clear, these frames are discarded. | ||
267 | * 3 Probe Request - When set, the WiLink receives all probe request | ||
268 | * frames. | ||
269 | * When clear, these frames are discarded. | ||
270 | * 2 Probe Response - When set, the WiLink receives all probe | ||
271 | * response frames. | ||
272 | * When clear, these frames are discarded. | ||
273 | * 1 RTS/CTS/ACK - When set, the WiLink receives all RTS, CTS and ACK | ||
274 | * frames. | ||
275 | * When clear, these frames are discarded. | ||
276 | * 0 Rsvd Type/Sub Type - When set, the WiLink receives all frames | ||
277 | * that have reserved frame types and sub types as defined by the | ||
278 | * 802.11 specification. | ||
279 | * When clear, these frames are discarded. | ||
280 | */ | ||
281 | struct acx_rx_config { | ||
282 | struct acx_header header; | ||
283 | |||
284 | u32 config_options; | ||
285 | u32 filter_options; | ||
286 | } __packed; | ||
287 | |||
288 | enum { | ||
289 | QOS_AC_BE = 0, | ||
290 | QOS_AC_BK, | ||
291 | QOS_AC_VI, | ||
292 | QOS_AC_VO, | ||
293 | QOS_HIGHEST_AC_INDEX = QOS_AC_VO, | ||
294 | }; | ||
295 | |||
296 | #define MAX_NUM_OF_AC (QOS_HIGHEST_AC_INDEX+1) | ||
297 | #define FIRST_AC_INDEX QOS_AC_BE | ||
298 | #define MAX_NUM_OF_802_1d_TAGS 8 | ||
299 | #define AC_PARAMS_MAX_TSID 15 | ||
300 | #define MAX_APSD_CONF 0xffff | ||
301 | |||
302 | #define QOS_TX_HIGH_MIN (0) | ||
303 | #define QOS_TX_HIGH_MAX (100) | ||
304 | |||
305 | #define QOS_TX_HIGH_BK_DEF (25) | ||
306 | #define QOS_TX_HIGH_BE_DEF (35) | ||
307 | #define QOS_TX_HIGH_VI_DEF (35) | ||
308 | #define QOS_TX_HIGH_VO_DEF (35) | ||
309 | |||
310 | #define QOS_TX_LOW_BK_DEF (15) | ||
311 | #define QOS_TX_LOW_BE_DEF (25) | ||
312 | #define QOS_TX_LOW_VI_DEF (25) | ||
313 | #define QOS_TX_LOW_VO_DEF (25) | ||
314 | |||
315 | struct acx_tx_queue_qos_config { | ||
316 | struct acx_header header; | ||
317 | |||
318 | u8 qid; | ||
319 | u8 pad[3]; | ||
320 | |||
321 | /* Max number of blocks allowd in the queue */ | ||
322 | u16 high_threshold; | ||
323 | |||
324 | /* Lowest memory blocks guaranteed for this queue */ | ||
325 | u16 low_threshold; | ||
326 | } __packed; | ||
327 | |||
328 | struct acx_packet_detection { | ||
329 | struct acx_header header; | ||
330 | |||
331 | u32 threshold; | ||
332 | } __packed; | ||
333 | |||
334 | |||
335 | enum acx_slot_type { | ||
336 | SLOT_TIME_LONG = 0, | ||
337 | SLOT_TIME_SHORT = 1, | ||
338 | DEFAULT_SLOT_TIME = SLOT_TIME_SHORT, | ||
339 | MAX_SLOT_TIMES = 0xFF | ||
340 | }; | ||
341 | |||
342 | #define STATION_WONE_INDEX 0 | ||
343 | |||
344 | struct acx_slot { | ||
345 | struct acx_header header; | ||
346 | |||
347 | u8 wone_index; /* Reserved */ | ||
348 | u8 slot_time; | ||
349 | u8 reserved[6]; | ||
350 | } __packed; | ||
351 | |||
352 | |||
353 | #define ADDRESS_GROUP_MAX (8) | ||
354 | #define ADDRESS_GROUP_MAX_LEN (ETH_ALEN * ADDRESS_GROUP_MAX) | ||
355 | |||
356 | struct acx_dot11_grp_addr_tbl { | ||
357 | struct acx_header header; | ||
358 | |||
359 | u8 enabled; | ||
360 | u8 num_groups; | ||
361 | u8 pad[2]; | ||
362 | u8 mac_table[ADDRESS_GROUP_MAX_LEN]; | ||
363 | } __packed; | ||
364 | |||
365 | |||
366 | #define RX_TIMEOUT_PS_POLL_MIN 0 | ||
367 | #define RX_TIMEOUT_PS_POLL_MAX (200000) | ||
368 | #define RX_TIMEOUT_PS_POLL_DEF (15) | ||
369 | #define RX_TIMEOUT_UPSD_MIN 0 | ||
370 | #define RX_TIMEOUT_UPSD_MAX (200000) | ||
371 | #define RX_TIMEOUT_UPSD_DEF (15) | ||
372 | |||
373 | struct acx_rx_timeout { | ||
374 | struct acx_header header; | ||
375 | |||
376 | /* | ||
377 | * The longest time the STA will wait to receive | ||
378 | * traffic from the AP after a PS-poll has been | ||
379 | * transmitted. | ||
380 | */ | ||
381 | u16 ps_poll_timeout; | ||
382 | |||
383 | /* | ||
384 | * The longest time the STA will wait to receive | ||
385 | * traffic from the AP after a frame has been sent | ||
386 | * from an UPSD enabled queue. | ||
387 | */ | ||
388 | u16 upsd_timeout; | ||
389 | } __packed; | ||
390 | |||
391 | #define RTS_THRESHOLD_MIN 0 | ||
392 | #define RTS_THRESHOLD_MAX 4096 | ||
393 | #define RTS_THRESHOLD_DEF 2347 | ||
394 | |||
395 | struct acx_rts_threshold { | ||
396 | struct acx_header header; | ||
397 | |||
398 | u16 threshold; | ||
399 | u8 pad[2]; | ||
400 | } __packed; | ||
401 | |||
402 | struct acx_beacon_filter_option { | ||
403 | struct acx_header header; | ||
404 | |||
405 | u8 enable; | ||
406 | |||
407 | /* | ||
408 | * The number of beacons without the unicast TIM | ||
409 | * bit set that the firmware buffers before | ||
410 | * signaling the host about ready frames. | ||
411 | * When set to 0 and the filter is enabled, beacons | ||
412 | * without the unicast TIM bit set are dropped. | ||
413 | */ | ||
414 | u8 max_num_beacons; | ||
415 | u8 pad[2]; | ||
416 | } __packed; | ||
417 | |||
418 | /* | ||
419 | * ACXBeaconFilterEntry (not 221) | ||
420 | * Byte Offset Size (Bytes) Definition | ||
421 | * =========== ============ ========== | ||
422 | * 0 1 IE identifier | ||
423 | * 1 1 Treatment bit mask | ||
424 | * | ||
425 | * ACXBeaconFilterEntry (221) | ||
426 | * Byte Offset Size (Bytes) Definition | ||
427 | * =========== ============ ========== | ||
428 | * 0 1 IE identifier | ||
429 | * 1 1 Treatment bit mask | ||
430 | * 2 3 OUI | ||
431 | * 5 1 Type | ||
432 | * 6 2 Version | ||
433 | * | ||
434 | * | ||
435 | * Treatment bit mask - The information element handling: | ||
436 | * bit 0 - The information element is compared and transferred | ||
437 | * in case of change. | ||
438 | * bit 1 - The information element is transferred to the host | ||
439 | * with each appearance or disappearance. | ||
440 | * Note that both bits can be set at the same time. | ||
441 | */ | ||
442 | #define BEACON_FILTER_TABLE_MAX_IE_NUM (32) | ||
443 | #define BEACON_FILTER_TABLE_MAX_VENDOR_SPECIFIC_IE_NUM (6) | ||
444 | #define BEACON_FILTER_TABLE_IE_ENTRY_SIZE (2) | ||
445 | #define BEACON_FILTER_TABLE_EXTRA_VENDOR_SPECIFIC_IE_SIZE (6) | ||
446 | #define BEACON_FILTER_TABLE_MAX_SIZE ((BEACON_FILTER_TABLE_MAX_IE_NUM * \ | ||
447 | BEACON_FILTER_TABLE_IE_ENTRY_SIZE) + \ | ||
448 | (BEACON_FILTER_TABLE_MAX_VENDOR_SPECIFIC_IE_NUM * \ | ||
449 | BEACON_FILTER_TABLE_EXTRA_VENDOR_SPECIFIC_IE_SIZE)) | ||
450 | |||
451 | #define BEACON_RULE_PASS_ON_CHANGE BIT(0) | ||
452 | #define BEACON_RULE_PASS_ON_APPEARANCE BIT(1) | ||
453 | |||
454 | #define BEACON_FILTER_IE_ID_CHANNEL_SWITCH_ANN (37) | ||
455 | |||
456 | struct acx_beacon_filter_ie_table { | ||
457 | struct acx_header header; | ||
458 | |||
459 | u8 num_ie; | ||
460 | u8 pad[3]; | ||
461 | u8 table[BEACON_FILTER_TABLE_MAX_SIZE]; | ||
462 | } __packed; | ||
463 | |||
464 | #define SYNCH_FAIL_DEFAULT_THRESHOLD 10 /* number of beacons */ | ||
465 | #define NO_BEACON_DEFAULT_TIMEOUT (500) /* in microseconds */ | ||
466 | |||
467 | struct acx_conn_monit_params { | ||
468 | struct acx_header header; | ||
469 | |||
470 | u32 synch_fail_thold; /* number of beacons missed */ | ||
471 | u32 bss_lose_timeout; /* number of TU's from synch fail */ | ||
472 | } __packed; | ||
473 | |||
474 | enum { | ||
475 | SG_ENABLE = 0, | ||
476 | SG_DISABLE, | ||
477 | SG_SENSE_NO_ACTIVITY, | ||
478 | SG_SENSE_ACTIVE | ||
479 | }; | ||
480 | |||
481 | struct acx_bt_wlan_coex { | ||
482 | struct acx_header header; | ||
483 | |||
484 | /* | ||
485 | * 0 -> PTA enabled | ||
486 | * 1 -> PTA disabled | ||
487 | * 2 -> sense no active mode, i.e. | ||
488 | * an interrupt is sent upon | ||
489 | * BT activity. | ||
490 | * 3 -> PTA is switched on in response | ||
491 | * to the interrupt sending. | ||
492 | */ | ||
493 | u8 enable; | ||
494 | u8 pad[3]; | ||
495 | } __packed; | ||
496 | |||
497 | #define PTA_ANTENNA_TYPE_DEF (0) | ||
498 | #define PTA_BT_HP_MAXTIME_DEF (2000) | ||
499 | #define PTA_WLAN_HP_MAX_TIME_DEF (5000) | ||
500 | #define PTA_SENSE_DISABLE_TIMER_DEF (1350) | ||
501 | #define PTA_PROTECTIVE_RX_TIME_DEF (1500) | ||
502 | #define PTA_PROTECTIVE_TX_TIME_DEF (1500) | ||
503 | #define PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF (3000) | ||
504 | #define PTA_SIGNALING_TYPE_DEF (1) | ||
505 | #define PTA_AFH_LEVERAGE_ON_DEF (0) | ||
506 | #define PTA_NUMBER_QUIET_CYCLE_DEF (0) | ||
507 | #define PTA_MAX_NUM_CTS_DEF (3) | ||
508 | #define PTA_NUMBER_OF_WLAN_PACKETS_DEF (2) | ||
509 | #define PTA_NUMBER_OF_BT_PACKETS_DEF (2) | ||
510 | #define PTA_PROTECTIVE_RX_TIME_FAST_DEF (1500) | ||
511 | #define PTA_PROTECTIVE_TX_TIME_FAST_DEF (3000) | ||
512 | #define PTA_CYCLE_TIME_FAST_DEF (8700) | ||
513 | #define PTA_RX_FOR_AVALANCHE_DEF (5) | ||
514 | #define PTA_ELP_HP_DEF (0) | ||
515 | #define PTA_ANTI_STARVE_PERIOD_DEF (500) | ||
516 | #define PTA_ANTI_STARVE_NUM_CYCLE_DEF (4) | ||
517 | #define PTA_ALLOW_PA_SD_DEF (1) | ||
518 | #define PTA_TIME_BEFORE_BEACON_DEF (6300) | ||
519 | #define PTA_HPDM_MAX_TIME_DEF (1600) | ||
520 | #define PTA_TIME_OUT_NEXT_WLAN_DEF (2550) | ||
521 | #define PTA_AUTO_MODE_NO_CTS_DEF (0) | ||
522 | #define PTA_BT_HP_RESPECTED_DEF (3) | ||
523 | #define PTA_WLAN_RX_MIN_RATE_DEF (24) | ||
524 | #define PTA_ACK_MODE_DEF (1) | ||
525 | |||
526 | struct acx_bt_wlan_coex_param { | ||
527 | struct acx_header header; | ||
528 | |||
529 | /* | ||
530 | * The minimum rate of a received WLAN packet in the STA, | ||
531 | * during protective mode, of which a new BT-HP request | ||
532 | * during this Rx will always be respected and gain the antenna. | ||
533 | */ | ||
534 | u32 min_rate; | ||
535 | |||
536 | /* Max time the BT HP will be respected. */ | ||
537 | u16 bt_hp_max_time; | ||
538 | |||
539 | /* Max time the WLAN HP will be respected. */ | ||
540 | u16 wlan_hp_max_time; | ||
541 | |||
542 | /* | ||
543 | * The time between the last BT activity | ||
544 | * and the moment when the sense mode returns | ||
545 | * to SENSE_INACTIVE. | ||
546 | */ | ||
547 | u16 sense_disable_timer; | ||
548 | |||
549 | /* Time before the next BT HP instance */ | ||
550 | u16 rx_time_bt_hp; | ||
551 | u16 tx_time_bt_hp; | ||
552 | |||
553 | /* range: 10-20000 default: 1500 */ | ||
554 | u16 rx_time_bt_hp_fast; | ||
555 | u16 tx_time_bt_hp_fast; | ||
556 | |||
557 | /* range: 2000-65535 default: 8700 */ | ||
558 | u16 wlan_cycle_fast; | ||
559 | |||
560 | /* range: 0 - 15000 (Msec) default: 1000 */ | ||
561 | u16 bt_anti_starvation_period; | ||
562 | |||
563 | /* range 400-10000(Usec) default: 3000 */ | ||
564 | u16 next_bt_lp_packet; | ||
565 | |||
566 | /* Deafult: worst case for BT DH5 traffic */ | ||
567 | u16 wake_up_beacon; | ||
568 | |||
569 | /* range: 0-50000(Usec) default: 1050 */ | ||
570 | u16 hp_dm_max_guard_time; | ||
571 | |||
572 | /* | ||
573 | * This is to prevent both BT & WLAN antenna | ||
574 | * starvation. | ||
575 | * Range: 100-50000(Usec) default:2550 | ||
576 | */ | ||
577 | u16 next_wlan_packet; | ||
578 | |||
579 | /* 0 -> shared antenna */ | ||
580 | u8 antenna_type; | ||
581 | |||
582 | /* | ||
583 | * 0 -> TI legacy | ||
584 | * 1 -> Palau | ||
585 | */ | ||
586 | u8 signal_type; | ||
587 | |||
588 | /* | ||
589 | * BT AFH status | ||
590 | * 0 -> no AFH | ||
591 | * 1 -> from dedicated GPIO | ||
592 | * 2 -> AFH on (from host) | ||
593 | */ | ||
594 | u8 afh_leverage_on; | ||
595 | |||
596 | /* | ||
597 | * The number of cycles during which no | ||
598 | * TX will be sent after 1 cycle of RX | ||
599 | * transaction in protective mode | ||
600 | */ | ||
601 | u8 quiet_cycle_num; | ||
602 | |||
603 | /* | ||
604 | * The maximum number of CTSs that will | ||
605 | * be sent for receiving RX packet in | ||
606 | * protective mode | ||
607 | */ | ||
608 | u8 max_cts; | ||
609 | |||
610 | /* | ||
611 | * The number of WLAN packets | ||
612 | * transferred in common mode before | ||
613 | * switching to BT. | ||
614 | */ | ||
615 | u8 wlan_packets_num; | ||
616 | |||
617 | /* | ||
618 | * The number of BT packets | ||
619 | * transferred in common mode before | ||
620 | * switching to WLAN. | ||
621 | */ | ||
622 | u8 bt_packets_num; | ||
623 | |||
624 | /* range: 1-255 default: 5 */ | ||
625 | u8 missed_rx_avalanche; | ||
626 | |||
627 | /* range: 0-1 default: 1 */ | ||
628 | u8 wlan_elp_hp; | ||
629 | |||
630 | /* range: 0 - 15 default: 4 */ | ||
631 | u8 bt_anti_starvation_cycles; | ||
632 | |||
633 | u8 ack_mode_dual_ant; | ||
634 | |||
635 | /* | ||
636 | * Allow PA_SD assertion/de-assertion | ||
637 | * during enabled BT activity. | ||
638 | */ | ||
639 | u8 pa_sd_enable; | ||
640 | |||
641 | /* | ||
642 | * Enable/Disable PTA in auto mode: | ||
643 | * Support Both Active & P.S modes | ||
644 | */ | ||
645 | u8 pta_auto_mode_enable; | ||
646 | |||
647 | /* range: 0 - 20 default: 1 */ | ||
648 | u8 bt_hp_respected_num; | ||
649 | } __packed; | ||
650 | |||
651 | #define CCA_THRSH_ENABLE_ENERGY_D 0x140A | ||
652 | #define CCA_THRSH_DISABLE_ENERGY_D 0xFFEF | ||
653 | |||
654 | struct acx_energy_detection { | ||
655 | struct acx_header header; | ||
656 | |||
657 | /* The RX Clear Channel Assessment threshold in the PHY */ | ||
658 | u16 rx_cca_threshold; | ||
659 | u8 tx_energy_detection; | ||
660 | u8 pad; | ||
661 | } __packed; | ||
662 | |||
663 | #define BCN_RX_TIMEOUT_DEF_VALUE 10000 | ||
664 | #define BROADCAST_RX_TIMEOUT_DEF_VALUE 20000 | ||
665 | #define RX_BROADCAST_IN_PS_DEF_VALUE 1 | ||
666 | #define CONSECUTIVE_PS_POLL_FAILURE_DEF 4 | ||
667 | |||
668 | struct acx_beacon_broadcast { | ||
669 | struct acx_header header; | ||
670 | |||
671 | u16 beacon_rx_timeout; | ||
672 | u16 broadcast_timeout; | ||
673 | |||
674 | /* Enables receiving of broadcast packets in PS mode */ | ||
675 | u8 rx_broadcast_in_ps; | ||
676 | |||
677 | /* Consecutive PS Poll failures before updating the host */ | ||
678 | u8 ps_poll_threshold; | ||
679 | u8 pad[2]; | ||
680 | } __packed; | ||
681 | |||
682 | struct acx_event_mask { | ||
683 | struct acx_header header; | ||
684 | |||
685 | u32 event_mask; | ||
686 | u32 high_event_mask; /* Unused */ | ||
687 | } __packed; | ||
688 | |||
689 | #define CFG_RX_FCS BIT(2) | ||
690 | #define CFG_RX_ALL_GOOD BIT(3) | ||
691 | #define CFG_UNI_FILTER_EN BIT(4) | ||
692 | #define CFG_BSSID_FILTER_EN BIT(5) | ||
693 | #define CFG_MC_FILTER_EN BIT(6) | ||
694 | #define CFG_MC_ADDR0_EN BIT(7) | ||
695 | #define CFG_MC_ADDR1_EN BIT(8) | ||
696 | #define CFG_BC_REJECT_EN BIT(9) | ||
697 | #define CFG_SSID_FILTER_EN BIT(10) | ||
698 | #define CFG_RX_INT_FCS_ERROR BIT(11) | ||
699 | #define CFG_RX_INT_ENCRYPTED BIT(12) | ||
700 | #define CFG_RX_WR_RX_STATUS BIT(13) | ||
701 | #define CFG_RX_FILTER_NULTI BIT(14) | ||
702 | #define CFG_RX_RESERVE BIT(15) | ||
703 | #define CFG_RX_TIMESTAMP_TSF BIT(16) | ||
704 | |||
705 | #define CFG_RX_RSV_EN BIT(0) | ||
706 | #define CFG_RX_RCTS_ACK BIT(1) | ||
707 | #define CFG_RX_PRSP_EN BIT(2) | ||
708 | #define CFG_RX_PREQ_EN BIT(3) | ||
709 | #define CFG_RX_MGMT_EN BIT(4) | ||
710 | #define CFG_RX_FCS_ERROR BIT(5) | ||
711 | #define CFG_RX_DATA_EN BIT(6) | ||
712 | #define CFG_RX_CTL_EN BIT(7) | ||
713 | #define CFG_RX_CF_EN BIT(8) | ||
714 | #define CFG_RX_BCN_EN BIT(9) | ||
715 | #define CFG_RX_AUTH_EN BIT(10) | ||
716 | #define CFG_RX_ASSOC_EN BIT(11) | ||
717 | |||
718 | #define SCAN_PASSIVE BIT(0) | ||
719 | #define SCAN_5GHZ_BAND BIT(1) | ||
720 | #define SCAN_TRIGGERED BIT(2) | ||
721 | #define SCAN_PRIORITY_HIGH BIT(3) | ||
722 | |||
723 | struct acx_fw_gen_frame_rates { | ||
724 | struct acx_header header; | ||
725 | |||
726 | u8 tx_ctrl_frame_rate; /* RATE_* */ | ||
727 | u8 tx_ctrl_frame_mod; /* CCK_* or PBCC_* */ | ||
728 | u8 tx_mgt_frame_rate; | ||
729 | u8 tx_mgt_frame_mod; | ||
730 | } __packed; | ||
731 | |||
732 | /* STA MAC */ | ||
733 | struct acx_dot11_station_id { | ||
734 | struct acx_header header; | ||
735 | |||
736 | u8 mac[ETH_ALEN]; | ||
737 | u8 pad[2]; | ||
738 | } __packed; | ||
739 | |||
740 | struct acx_feature_config { | ||
741 | struct acx_header header; | ||
742 | |||
743 | u32 options; | ||
744 | u32 data_flow_options; | ||
745 | } __packed; | ||
746 | |||
747 | struct acx_current_tx_power { | ||
748 | struct acx_header header; | ||
749 | |||
750 | u8 current_tx_power; | ||
751 | u8 padding[3]; | ||
752 | } __packed; | ||
753 | |||
754 | struct acx_dot11_default_key { | ||
755 | struct acx_header header; | ||
756 | |||
757 | u8 id; | ||
758 | u8 pad[3]; | ||
759 | } __packed; | ||
760 | |||
761 | struct acx_tsf_info { | ||
762 | struct acx_header header; | ||
763 | |||
764 | u32 current_tsf_msb; | ||
765 | u32 current_tsf_lsb; | ||
766 | u32 last_TBTT_msb; | ||
767 | u32 last_TBTT_lsb; | ||
768 | u8 last_dtim_count; | ||
769 | u8 pad[3]; | ||
770 | } __packed; | ||
771 | |||
772 | enum acx_wake_up_event { | ||
773 | WAKE_UP_EVENT_BEACON_BITMAP = 0x01, /* Wake on every Beacon*/ | ||
774 | WAKE_UP_EVENT_DTIM_BITMAP = 0x02, /* Wake on every DTIM*/ | ||
775 | WAKE_UP_EVENT_N_DTIM_BITMAP = 0x04, /* Wake on every Nth DTIM */ | ||
776 | WAKE_UP_EVENT_N_BEACONS_BITMAP = 0x08, /* Wake on every Nth Beacon */ | ||
777 | WAKE_UP_EVENT_BITS_MASK = 0x0F | ||
778 | }; | ||
779 | |||
780 | struct acx_wake_up_condition { | ||
781 | struct acx_header header; | ||
782 | |||
783 | u8 wake_up_event; /* Only one bit can be set */ | ||
784 | u8 listen_interval; | ||
785 | u8 pad[2]; | ||
786 | } __packed; | ||
787 | |||
788 | struct acx_aid { | ||
789 | struct acx_header header; | ||
790 | |||
791 | /* | ||
792 | * To be set when associated with an AP. | ||
793 | */ | ||
794 | u16 aid; | ||
795 | u8 pad[2]; | ||
796 | } __packed; | ||
797 | |||
798 | enum acx_preamble_type { | ||
799 | ACX_PREAMBLE_LONG = 0, | ||
800 | ACX_PREAMBLE_SHORT = 1 | ||
801 | }; | ||
802 | |||
803 | struct acx_preamble { | ||
804 | struct acx_header header; | ||
805 | |||
806 | /* | ||
807 | * When set, the WiLink transmits the frames with a short preamble and | ||
808 | * when cleared, the WiLink transmits the frames with a long preamble. | ||
809 | */ | ||
810 | u8 preamble; | ||
811 | u8 padding[3]; | ||
812 | } __packed; | ||
813 | |||
814 | enum acx_ctsprotect_type { | ||
815 | CTSPROTECT_DISABLE = 0, | ||
816 | CTSPROTECT_ENABLE = 1 | ||
817 | }; | ||
818 | |||
819 | struct acx_ctsprotect { | ||
820 | struct acx_header header; | ||
821 | u8 ctsprotect; | ||
822 | u8 padding[3]; | ||
823 | } __packed; | ||
824 | |||
825 | struct acx_tx_statistics { | ||
826 | u32 internal_desc_overflow; | ||
827 | } __packed; | ||
828 | |||
829 | struct acx_rx_statistics { | ||
830 | u32 out_of_mem; | ||
831 | u32 hdr_overflow; | ||
832 | u32 hw_stuck; | ||
833 | u32 dropped; | ||
834 | u32 fcs_err; | ||
835 | u32 xfr_hint_trig; | ||
836 | u32 path_reset; | ||
837 | u32 reset_counter; | ||
838 | } __packed; | ||
839 | |||
840 | struct acx_dma_statistics { | ||
841 | u32 rx_requested; | ||
842 | u32 rx_errors; | ||
843 | u32 tx_requested; | ||
844 | u32 tx_errors; | ||
845 | } __packed; | ||
846 | |||
847 | struct acx_isr_statistics { | ||
848 | /* host command complete */ | ||
849 | u32 cmd_cmplt; | ||
850 | |||
851 | /* fiqisr() */ | ||
852 | u32 fiqs; | ||
853 | |||
854 | /* (INT_STS_ND & INT_TRIG_RX_HEADER) */ | ||
855 | u32 rx_headers; | ||
856 | |||
857 | /* (INT_STS_ND & INT_TRIG_RX_CMPLT) */ | ||
858 | u32 rx_completes; | ||
859 | |||
860 | /* (INT_STS_ND & INT_TRIG_NO_RX_BUF) */ | ||
861 | u32 rx_mem_overflow; | ||
862 | |||
863 | /* (INT_STS_ND & INT_TRIG_S_RX_RDY) */ | ||
864 | u32 rx_rdys; | ||
865 | |||
866 | /* irqisr() */ | ||
867 | u32 irqs; | ||
868 | |||
869 | /* (INT_STS_ND & INT_TRIG_TX_PROC) */ | ||
870 | u32 tx_procs; | ||
871 | |||
872 | /* (INT_STS_ND & INT_TRIG_DECRYPT_DONE) */ | ||
873 | u32 decrypt_done; | ||
874 | |||
875 | /* (INT_STS_ND & INT_TRIG_DMA0) */ | ||
876 | u32 dma0_done; | ||
877 | |||
878 | /* (INT_STS_ND & INT_TRIG_DMA1) */ | ||
879 | u32 dma1_done; | ||
880 | |||
881 | /* (INT_STS_ND & INT_TRIG_TX_EXC_CMPLT) */ | ||
882 | u32 tx_exch_complete; | ||
883 | |||
884 | /* (INT_STS_ND & INT_TRIG_COMMAND) */ | ||
885 | u32 commands; | ||
886 | |||
887 | /* (INT_STS_ND & INT_TRIG_RX_PROC) */ | ||
888 | u32 rx_procs; | ||
889 | |||
890 | /* (INT_STS_ND & INT_TRIG_PM_802) */ | ||
891 | u32 hw_pm_mode_changes; | ||
892 | |||
893 | /* (INT_STS_ND & INT_TRIG_ACKNOWLEDGE) */ | ||
894 | u32 host_acknowledges; | ||
895 | |||
896 | /* (INT_STS_ND & INT_TRIG_PM_PCI) */ | ||
897 | u32 pci_pm; | ||
898 | |||
899 | /* (INT_STS_ND & INT_TRIG_ACM_WAKEUP) */ | ||
900 | u32 wakeups; | ||
901 | |||
902 | /* (INT_STS_ND & INT_TRIG_LOW_RSSI) */ | ||
903 | u32 low_rssi; | ||
904 | } __packed; | ||
905 | |||
906 | struct acx_wep_statistics { | ||
907 | /* WEP address keys configured */ | ||
908 | u32 addr_key_count; | ||
909 | |||
910 | /* default keys configured */ | ||
911 | u32 default_key_count; | ||
912 | |||
913 | u32 reserved; | ||
914 | |||
915 | /* number of times that WEP key not found on lookup */ | ||
916 | u32 key_not_found; | ||
917 | |||
918 | /* number of times that WEP key decryption failed */ | ||
919 | u32 decrypt_fail; | ||
920 | |||
921 | /* WEP packets decrypted */ | ||
922 | u32 packets; | ||
923 | |||
924 | /* WEP decrypt interrupts */ | ||
925 | u32 interrupt; | ||
926 | } __packed; | ||
927 | |||
928 | #define ACX_MISSED_BEACONS_SPREAD 10 | ||
929 | |||
930 | struct acx_pwr_statistics { | ||
931 | /* the amount of enters into power save mode (both PD & ELP) */ | ||
932 | u32 ps_enter; | ||
933 | |||
934 | /* the amount of enters into ELP mode */ | ||
935 | u32 elp_enter; | ||
936 | |||
937 | /* the amount of missing beacon interrupts to the host */ | ||
938 | u32 missing_bcns; | ||
939 | |||
940 | /* the amount of wake on host-access times */ | ||
941 | u32 wake_on_host; | ||
942 | |||
943 | /* the amount of wake on timer-expire */ | ||
944 | u32 wake_on_timer_exp; | ||
945 | |||
946 | /* the number of packets that were transmitted with PS bit set */ | ||
947 | u32 tx_with_ps; | ||
948 | |||
949 | /* the number of packets that were transmitted with PS bit clear */ | ||
950 | u32 tx_without_ps; | ||
951 | |||
952 | /* the number of received beacons */ | ||
953 | u32 rcvd_beacons; | ||
954 | |||
955 | /* the number of entering into PowerOn (power save off) */ | ||
956 | u32 power_save_off; | ||
957 | |||
958 | /* the number of entries into power save mode */ | ||
959 | u16 enable_ps; | ||
960 | |||
961 | /* | ||
962 | * the number of exits from power save, not including failed PS | ||
963 | * transitions | ||
964 | */ | ||
965 | u16 disable_ps; | ||
966 | |||
967 | /* | ||
968 | * the number of times the TSF counter was adjusted because | ||
969 | * of drift | ||
970 | */ | ||
971 | u32 fix_tsf_ps; | ||
972 | |||
973 | /* Gives statistics about the spread continuous missed beacons. | ||
974 | * The 16 LSB are dedicated for the PS mode. | ||
975 | * The 16 MSB are dedicated for the PS mode. | ||
976 | * cont_miss_bcns_spread[0] - single missed beacon. | ||
977 | * cont_miss_bcns_spread[1] - two continuous missed beacons. | ||
978 | * cont_miss_bcns_spread[2] - three continuous missed beacons. | ||
979 | * ... | ||
980 | * cont_miss_bcns_spread[9] - ten and more continuous missed beacons. | ||
981 | */ | ||
982 | u32 cont_miss_bcns_spread[ACX_MISSED_BEACONS_SPREAD]; | ||
983 | |||
984 | /* the number of beacons in awake mode */ | ||
985 | u32 rcvd_awake_beacons; | ||
986 | } __packed; | ||
987 | |||
988 | struct acx_mic_statistics { | ||
989 | u32 rx_pkts; | ||
990 | u32 calc_failure; | ||
991 | } __packed; | ||
992 | |||
993 | struct acx_aes_statistics { | ||
994 | u32 encrypt_fail; | ||
995 | u32 decrypt_fail; | ||
996 | u32 encrypt_packets; | ||
997 | u32 decrypt_packets; | ||
998 | u32 encrypt_interrupt; | ||
999 | u32 decrypt_interrupt; | ||
1000 | } __packed; | ||
1001 | |||
1002 | struct acx_event_statistics { | ||
1003 | u32 heart_beat; | ||
1004 | u32 calibration; | ||
1005 | u32 rx_mismatch; | ||
1006 | u32 rx_mem_empty; | ||
1007 | u32 rx_pool; | ||
1008 | u32 oom_late; | ||
1009 | u32 phy_transmit_error; | ||
1010 | u32 tx_stuck; | ||
1011 | } __packed; | ||
1012 | |||
1013 | struct acx_ps_statistics { | ||
1014 | u32 pspoll_timeouts; | ||
1015 | u32 upsd_timeouts; | ||
1016 | u32 upsd_max_sptime; | ||
1017 | u32 upsd_max_apturn; | ||
1018 | u32 pspoll_max_apturn; | ||
1019 | u32 pspoll_utilization; | ||
1020 | u32 upsd_utilization; | ||
1021 | } __packed; | ||
1022 | |||
1023 | struct acx_rxpipe_statistics { | ||
1024 | u32 rx_prep_beacon_drop; | ||
1025 | u32 descr_host_int_trig_rx_data; | ||
1026 | u32 beacon_buffer_thres_host_int_trig_rx_data; | ||
1027 | u32 missed_beacon_host_int_trig_rx_data; | ||
1028 | u32 tx_xfr_host_int_trig_rx_data; | ||
1029 | } __packed; | ||
1030 | |||
1031 | struct acx_statistics { | ||
1032 | struct acx_header header; | ||
1033 | |||
1034 | struct acx_tx_statistics tx; | ||
1035 | struct acx_rx_statistics rx; | ||
1036 | struct acx_dma_statistics dma; | ||
1037 | struct acx_isr_statistics isr; | ||
1038 | struct acx_wep_statistics wep; | ||
1039 | struct acx_pwr_statistics pwr; | ||
1040 | struct acx_aes_statistics aes; | ||
1041 | struct acx_mic_statistics mic; | ||
1042 | struct acx_event_statistics event; | ||
1043 | struct acx_ps_statistics ps; | ||
1044 | struct acx_rxpipe_statistics rxpipe; | ||
1045 | } __packed; | ||
1046 | |||
1047 | #define ACX_MAX_RATE_CLASSES 8 | ||
1048 | #define ACX_RATE_MASK_UNSPECIFIED 0 | ||
1049 | #define ACX_RATE_RETRY_LIMIT 10 | ||
1050 | |||
1051 | struct acx_rate_class { | ||
1052 | u32 enabled_rates; | ||
1053 | u8 short_retry_limit; | ||
1054 | u8 long_retry_limit; | ||
1055 | u8 aflags; | ||
1056 | u8 reserved; | ||
1057 | } __packed; | ||
1058 | |||
1059 | struct acx_rate_policy { | ||
1060 | struct acx_header header; | ||
1061 | |||
1062 | u32 rate_class_cnt; | ||
1063 | struct acx_rate_class rate_class[ACX_MAX_RATE_CLASSES]; | ||
1064 | } __packed; | ||
1065 | |||
1066 | struct wl1251_acx_memory { | ||
1067 | __le16 num_stations; /* number of STAs to be supported. */ | ||
1068 | u16 reserved_1; | ||
1069 | |||
1070 | /* | ||
1071 | * Nmber of memory buffers for the RX mem pool. | ||
1072 | * The actual number may be less if there are | ||
1073 | * not enough blocks left for the minimum num | ||
1074 | * of TX ones. | ||
1075 | */ | ||
1076 | u8 rx_mem_block_num; | ||
1077 | u8 reserved_2; | ||
1078 | u8 num_tx_queues; /* From 1 to 16 */ | ||
1079 | u8 host_if_options; /* HOST_IF* */ | ||
1080 | u8 tx_min_mem_block_num; | ||
1081 | u8 num_ssid_profiles; | ||
1082 | __le16 debug_buffer_size; | ||
1083 | } __packed; | ||
1084 | |||
1085 | |||
1086 | #define ACX_RX_DESC_MIN 1 | ||
1087 | #define ACX_RX_DESC_MAX 127 | ||
1088 | #define ACX_RX_DESC_DEF 32 | ||
1089 | struct wl1251_acx_rx_queue_config { | ||
1090 | u8 num_descs; | ||
1091 | u8 pad; | ||
1092 | u8 type; | ||
1093 | u8 priority; | ||
1094 | __le32 dma_address; | ||
1095 | } __packed; | ||
1096 | |||
1097 | #define ACX_TX_DESC_MIN 1 | ||
1098 | #define ACX_TX_DESC_MAX 127 | ||
1099 | #define ACX_TX_DESC_DEF 16 | ||
1100 | struct wl1251_acx_tx_queue_config { | ||
1101 | u8 num_descs; | ||
1102 | u8 pad[2]; | ||
1103 | u8 attributes; | ||
1104 | } __packed; | ||
1105 | |||
1106 | #define MAX_TX_QUEUE_CONFIGS 5 | ||
1107 | #define MAX_TX_QUEUES 4 | ||
1108 | struct wl1251_acx_config_memory { | ||
1109 | struct acx_header header; | ||
1110 | |||
1111 | struct wl1251_acx_memory mem_config; | ||
1112 | struct wl1251_acx_rx_queue_config rx_queue_config; | ||
1113 | struct wl1251_acx_tx_queue_config tx_queue_config[MAX_TX_QUEUE_CONFIGS]; | ||
1114 | } __packed; | ||
1115 | |||
1116 | struct wl1251_acx_mem_map { | ||
1117 | struct acx_header header; | ||
1118 | |||
1119 | void *code_start; | ||
1120 | void *code_end; | ||
1121 | |||
1122 | void *wep_defkey_start; | ||
1123 | void *wep_defkey_end; | ||
1124 | |||
1125 | void *sta_table_start; | ||
1126 | void *sta_table_end; | ||
1127 | |||
1128 | void *packet_template_start; | ||
1129 | void *packet_template_end; | ||
1130 | |||
1131 | void *queue_memory_start; | ||
1132 | void *queue_memory_end; | ||
1133 | |||
1134 | void *packet_memory_pool_start; | ||
1135 | void *packet_memory_pool_end; | ||
1136 | |||
1137 | void *debug_buffer1_start; | ||
1138 | void *debug_buffer1_end; | ||
1139 | |||
1140 | void *debug_buffer2_start; | ||
1141 | void *debug_buffer2_end; | ||
1142 | |||
1143 | /* Number of blocks FW allocated for TX packets */ | ||
1144 | u32 num_tx_mem_blocks; | ||
1145 | |||
1146 | /* Number of blocks FW allocated for RX packets */ | ||
1147 | u32 num_rx_mem_blocks; | ||
1148 | } __packed; | ||
1149 | |||
1150 | |||
1151 | struct wl1251_acx_wr_tbtt_and_dtim { | ||
1152 | |||
1153 | struct acx_header header; | ||
1154 | |||
1155 | /* Time in TUs between two consecutive beacons */ | ||
1156 | u16 tbtt; | ||
1157 | |||
1158 | /* | ||
1159 | * DTIM period | ||
1160 | * For BSS: Number of TBTTs in a DTIM period (range: 1-10) | ||
1161 | * For IBSS: value shall be set to 1 | ||
1162 | */ | ||
1163 | u8 dtim; | ||
1164 | u8 padding; | ||
1165 | } __packed; | ||
1166 | |||
1167 | struct wl1251_acx_ac_cfg { | ||
1168 | struct acx_header header; | ||
1169 | |||
1170 | /* | ||
1171 | * Access Category - The TX queue's access category | ||
1172 | * (refer to AccessCategory_enum) | ||
1173 | */ | ||
1174 | u8 ac; | ||
1175 | |||
1176 | /* | ||
1177 | * The contention window minimum size (in slots) for | ||
1178 | * the access class. | ||
1179 | */ | ||
1180 | u8 cw_min; | ||
1181 | |||
1182 | /* | ||
1183 | * The contention window maximum size (in slots) for | ||
1184 | * the access class. | ||
1185 | */ | ||
1186 | u16 cw_max; | ||
1187 | |||
1188 | /* The AIF value (in slots) for the access class. */ | ||
1189 | u8 aifsn; | ||
1190 | |||
1191 | u8 reserved; | ||
1192 | |||
1193 | /* The TX Op Limit (in microseconds) for the access class. */ | ||
1194 | u16 txop_limit; | ||
1195 | } __packed; | ||
1196 | |||
1197 | |||
1198 | enum wl1251_acx_channel_type { | ||
1199 | CHANNEL_TYPE_DCF = 0, | ||
1200 | CHANNEL_TYPE_EDCF = 1, | ||
1201 | CHANNEL_TYPE_HCCA = 2, | ||
1202 | }; | ||
1203 | |||
1204 | enum wl1251_acx_ps_scheme { | ||
1205 | /* regular ps: simple sending of packets */ | ||
1206 | WL1251_ACX_PS_SCHEME_LEGACY = 0, | ||
1207 | |||
1208 | /* sending a packet triggers a unscheduled apsd downstream */ | ||
1209 | WL1251_ACX_PS_SCHEME_UPSD_TRIGGER = 1, | ||
1210 | |||
1211 | /* a pspoll packet will be sent before every data packet */ | ||
1212 | WL1251_ACX_PS_SCHEME_LEGACY_PSPOLL = 2, | ||
1213 | |||
1214 | /* scheduled apsd mode */ | ||
1215 | WL1251_ACX_PS_SCHEME_SAPSD = 3, | ||
1216 | }; | ||
1217 | |||
1218 | enum wl1251_acx_ack_policy { | ||
1219 | WL1251_ACX_ACK_POLICY_LEGACY = 0, | ||
1220 | WL1251_ACX_ACK_POLICY_NO_ACK = 1, | ||
1221 | WL1251_ACX_ACK_POLICY_BLOCK = 2, | ||
1222 | }; | ||
1223 | |||
1224 | struct wl1251_acx_tid_cfg { | ||
1225 | struct acx_header header; | ||
1226 | |||
1227 | /* tx queue id number (0-7) */ | ||
1228 | u8 queue; | ||
1229 | |||
1230 | /* channel access type for the queue, enum wl1251_acx_channel_type */ | ||
1231 | u8 type; | ||
1232 | |||
1233 | /* EDCA: ac index (0-3), HCCA: traffic stream id (8-15) */ | ||
1234 | u8 tsid; | ||
1235 | |||
1236 | /* ps scheme of the specified queue, enum wl1251_acx_ps_scheme */ | ||
1237 | u8 ps_scheme; | ||
1238 | |||
1239 | /* the tx queue ack policy, enum wl1251_acx_ack_policy */ | ||
1240 | u8 ack_policy; | ||
1241 | |||
1242 | u8 padding[3]; | ||
1243 | |||
1244 | /* not supported */ | ||
1245 | u32 apsdconf[2]; | ||
1246 | } __packed; | ||
1247 | |||
1248 | /************************************************************************* | ||
1249 | |||
1250 | Host Interrupt Register (WiLink -> Host) | ||
1251 | |||
1252 | **************************************************************************/ | ||
1253 | |||
1254 | /* RX packet is ready in Xfer buffer #0 */ | ||
1255 | #define WL1251_ACX_INTR_RX0_DATA BIT(0) | ||
1256 | |||
1257 | /* TX result(s) are in the TX complete buffer */ | ||
1258 | #define WL1251_ACX_INTR_TX_RESULT BIT(1) | ||
1259 | |||
1260 | /* OBSOLETE */ | ||
1261 | #define WL1251_ACX_INTR_TX_XFR BIT(2) | ||
1262 | |||
1263 | /* RX packet is ready in Xfer buffer #1 */ | ||
1264 | #define WL1251_ACX_INTR_RX1_DATA BIT(3) | ||
1265 | |||
1266 | /* Event was entered to Event MBOX #A */ | ||
1267 | #define WL1251_ACX_INTR_EVENT_A BIT(4) | ||
1268 | |||
1269 | /* Event was entered to Event MBOX #B */ | ||
1270 | #define WL1251_ACX_INTR_EVENT_B BIT(5) | ||
1271 | |||
1272 | /* OBSOLETE */ | ||
1273 | #define WL1251_ACX_INTR_WAKE_ON_HOST BIT(6) | ||
1274 | |||
1275 | /* Trace meassge on MBOX #A */ | ||
1276 | #define WL1251_ACX_INTR_TRACE_A BIT(7) | ||
1277 | |||
1278 | /* Trace meassge on MBOX #B */ | ||
1279 | #define WL1251_ACX_INTR_TRACE_B BIT(8) | ||
1280 | |||
1281 | /* Command processing completion */ | ||
1282 | #define WL1251_ACX_INTR_CMD_COMPLETE BIT(9) | ||
1283 | |||
1284 | /* Init sequence is done */ | ||
1285 | #define WL1251_ACX_INTR_INIT_COMPLETE BIT(14) | ||
1286 | |||
1287 | #define WL1251_ACX_INTR_ALL 0xFFFFFFFF | ||
1288 | |||
1289 | enum { | ||
1290 | ACX_WAKE_UP_CONDITIONS = 0x0002, | ||
1291 | ACX_MEM_CFG = 0x0003, | ||
1292 | ACX_SLOT = 0x0004, | ||
1293 | ACX_QUEUE_HEAD = 0x0005, /* for MASTER mode only */ | ||
1294 | ACX_AC_CFG = 0x0007, | ||
1295 | ACX_MEM_MAP = 0x0008, | ||
1296 | ACX_AID = 0x000A, | ||
1297 | ACX_RADIO_PARAM = 0x000B, /* Not used */ | ||
1298 | ACX_CFG = 0x000C, /* Not used */ | ||
1299 | ACX_FW_REV = 0x000D, | ||
1300 | ACX_MEDIUM_USAGE = 0x000F, | ||
1301 | ACX_RX_CFG = 0x0010, | ||
1302 | ACX_TX_QUEUE_CFG = 0x0011, /* FIXME: only used by wl1251 */ | ||
1303 | ACX_BSS_IN_PS = 0x0012, /* for AP only */ | ||
1304 | ACX_STATISTICS = 0x0013, /* Debug API */ | ||
1305 | ACX_FEATURE_CFG = 0x0015, | ||
1306 | ACX_MISC_CFG = 0x0017, /* Not used */ | ||
1307 | ACX_TID_CFG = 0x001A, | ||
1308 | ACX_BEACON_FILTER_OPT = 0x001F, | ||
1309 | ACX_LOW_RSSI = 0x0020, | ||
1310 | ACX_NOISE_HIST = 0x0021, | ||
1311 | ACX_HDK_VERSION = 0x0022, /* ??? */ | ||
1312 | ACX_PD_THRESHOLD = 0x0023, | ||
1313 | ACX_DATA_PATH_PARAMS = 0x0024, /* WO */ | ||
1314 | ACX_DATA_PATH_RESP_PARAMS = 0x0024, /* RO */ | ||
1315 | ACX_CCA_THRESHOLD = 0x0025, | ||
1316 | ACX_EVENT_MBOX_MASK = 0x0026, | ||
1317 | #ifdef FW_RUNNING_AS_AP | ||
1318 | ACX_DTIM_PERIOD = 0x0027, /* for AP only */ | ||
1319 | #else | ||
1320 | ACX_WR_TBTT_AND_DTIM = 0x0027, /* STA only */ | ||
1321 | #endif | ||
1322 | ACX_ACI_OPTION_CFG = 0x0029, /* OBSOLETE (for 1251)*/ | ||
1323 | ACX_GPIO_CFG = 0x002A, /* Not used */ | ||
1324 | ACX_GPIO_SET = 0x002B, /* Not used */ | ||
1325 | ACX_PM_CFG = 0x002C, /* To Be Documented */ | ||
1326 | ACX_CONN_MONIT_PARAMS = 0x002D, | ||
1327 | ACX_AVERAGE_RSSI = 0x002E, /* Not used */ | ||
1328 | ACX_CONS_TX_FAILURE = 0x002F, | ||
1329 | ACX_BCN_DTIM_OPTIONS = 0x0031, | ||
1330 | ACX_SG_ENABLE = 0x0032, | ||
1331 | ACX_SG_CFG = 0x0033, | ||
1332 | ACX_ANTENNA_DIVERSITY_CFG = 0x0035, /* To Be Documented */ | ||
1333 | ACX_LOW_SNR = 0x0037, /* To Be Documented */ | ||
1334 | ACX_BEACON_FILTER_TABLE = 0x0038, | ||
1335 | ACX_ARP_IP_FILTER = 0x0039, | ||
1336 | ACX_ROAMING_STATISTICS_TBL = 0x003B, | ||
1337 | ACX_RATE_POLICY = 0x003D, | ||
1338 | ACX_CTS_PROTECTION = 0x003E, | ||
1339 | ACX_SLEEP_AUTH = 0x003F, | ||
1340 | ACX_PREAMBLE_TYPE = 0x0040, | ||
1341 | ACX_ERROR_CNT = 0x0041, | ||
1342 | ACX_FW_GEN_FRAME_RATES = 0x0042, | ||
1343 | ACX_IBSS_FILTER = 0x0044, | ||
1344 | ACX_SERVICE_PERIOD_TIMEOUT = 0x0045, | ||
1345 | ACX_TSF_INFO = 0x0046, | ||
1346 | ACX_CONFIG_PS_WMM = 0x0049, | ||
1347 | ACX_ENABLE_RX_DATA_FILTER = 0x004A, | ||
1348 | ACX_SET_RX_DATA_FILTER = 0x004B, | ||
1349 | ACX_GET_DATA_FILTER_STATISTICS = 0x004C, | ||
1350 | ACX_POWER_LEVEL_TABLE = 0x004D, | ||
1351 | ACX_BET_ENABLE = 0x0050, | ||
1352 | DOT11_STATION_ID = 0x1001, | ||
1353 | DOT11_RX_MSDU_LIFE_TIME = 0x1004, | ||
1354 | DOT11_CUR_TX_PWR = 0x100D, | ||
1355 | DOT11_DEFAULT_KEY = 0x1010, | ||
1356 | DOT11_RX_DOT11_MODE = 0x1012, | ||
1357 | DOT11_RTS_THRESHOLD = 0x1013, | ||
1358 | DOT11_GROUP_ADDRESS_TBL = 0x1014, | ||
1359 | |||
1360 | MAX_DOT11_IE = DOT11_GROUP_ADDRESS_TBL, | ||
1361 | |||
1362 | MAX_IE = 0xFFFF | ||
1363 | }; | ||
1364 | |||
1365 | |||
1366 | int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod, | ||
1367 | u8 mgt_rate, u8 mgt_mod); | ||
1368 | int wl1251_acx_station_id(struct wl1251 *wl); | ||
1369 | int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id); | ||
1370 | int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event, | ||
1371 | u8 listen_interval); | ||
1372 | int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth); | ||
1373 | int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len); | ||
1374 | int wl1251_acx_tx_power(struct wl1251 *wl, int power); | ||
1375 | int wl1251_acx_feature_cfg(struct wl1251 *wl); | ||
1376 | int wl1251_acx_mem_map(struct wl1251 *wl, | ||
1377 | struct acx_header *mem_map, size_t len); | ||
1378 | int wl1251_acx_data_path_params(struct wl1251 *wl, | ||
1379 | struct acx_data_path_params_resp *data_path); | ||
1380 | int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time); | ||
1381 | int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter); | ||
1382 | int wl1251_acx_pd_threshold(struct wl1251 *wl); | ||
1383 | int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time); | ||
1384 | int wl1251_acx_group_address_tbl(struct wl1251 *wl); | ||
1385 | int wl1251_acx_service_period_timeout(struct wl1251 *wl); | ||
1386 | int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold); | ||
1387 | int wl1251_acx_beacon_filter_opt(struct wl1251 *wl, bool enable_filter); | ||
1388 | int wl1251_acx_beacon_filter_table(struct wl1251 *wl); | ||
1389 | int wl1251_acx_conn_monit_params(struct wl1251 *wl); | ||
1390 | int wl1251_acx_sg_enable(struct wl1251 *wl); | ||
1391 | int wl1251_acx_sg_cfg(struct wl1251 *wl); | ||
1392 | int wl1251_acx_cca_threshold(struct wl1251 *wl); | ||
1393 | int wl1251_acx_bcn_dtim_options(struct wl1251 *wl); | ||
1394 | int wl1251_acx_aid(struct wl1251 *wl, u16 aid); | ||
1395 | int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask); | ||
1396 | int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble); | ||
1397 | int wl1251_acx_cts_protect(struct wl1251 *wl, | ||
1398 | enum acx_ctsprotect_type ctsprotect); | ||
1399 | int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats); | ||
1400 | int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime); | ||
1401 | int wl1251_acx_rate_policies(struct wl1251 *wl); | ||
1402 | int wl1251_acx_mem_cfg(struct wl1251 *wl); | ||
1403 | int wl1251_acx_wr_tbtt_and_dtim(struct wl1251 *wl, u16 tbtt, u8 dtim); | ||
1404 | int wl1251_acx_ac_cfg(struct wl1251 *wl, u8 ac, u8 cw_min, u16 cw_max, | ||
1405 | u8 aifs, u16 txop); | ||
1406 | int wl1251_acx_tid_cfg(struct wl1251 *wl, u8 queue, | ||
1407 | enum wl1251_acx_channel_type type, | ||
1408 | u8 tsid, enum wl1251_acx_ps_scheme ps_scheme, | ||
1409 | enum wl1251_acx_ack_policy ack_policy); | ||
1410 | |||
1411 | #endif /* __WL1251_ACX_H__ */ | ||
diff --git a/drivers/net/wireless/wl1251/boot.c b/drivers/net/wireless/wl1251/boot.c new file mode 100644 index 000000000000..61572dfa1f60 --- /dev/null +++ b/drivers/net/wireless/wl1251/boot.c | |||
@@ -0,0 +1,557 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/gpio.h> | ||
23 | #include <linux/slab.h> | ||
24 | |||
25 | #include "reg.h" | ||
26 | #include "boot.h" | ||
27 | #include "io.h" | ||
28 | #include "spi.h" | ||
29 | #include "event.h" | ||
30 | #include "acx.h" | ||
31 | |||
32 | void wl1251_boot_target_enable_interrupts(struct wl1251 *wl) | ||
33 | { | ||
34 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); | ||
35 | wl1251_reg_write32(wl, HI_CFG, HI_CFG_DEF_VAL); | ||
36 | } | ||
37 | |||
38 | int wl1251_boot_soft_reset(struct wl1251 *wl) | ||
39 | { | ||
40 | unsigned long timeout; | ||
41 | u32 boot_data; | ||
42 | |||
43 | /* perform soft reset */ | ||
44 | wl1251_reg_write32(wl, ACX_REG_SLV_SOFT_RESET, ACX_SLV_SOFT_RESET_BIT); | ||
45 | |||
46 | /* SOFT_RESET is self clearing */ | ||
47 | timeout = jiffies + usecs_to_jiffies(SOFT_RESET_MAX_TIME); | ||
48 | while (1) { | ||
49 | boot_data = wl1251_reg_read32(wl, ACX_REG_SLV_SOFT_RESET); | ||
50 | wl1251_debug(DEBUG_BOOT, "soft reset bootdata 0x%x", boot_data); | ||
51 | if ((boot_data & ACX_SLV_SOFT_RESET_BIT) == 0) | ||
52 | break; | ||
53 | |||
54 | if (time_after(jiffies, timeout)) { | ||
55 | /* 1.2 check pWhalBus->uSelfClearTime if the | ||
56 | * timeout was reached */ | ||
57 | wl1251_error("soft reset timeout"); | ||
58 | return -1; | ||
59 | } | ||
60 | |||
61 | udelay(SOFT_RESET_STALL_TIME); | ||
62 | } | ||
63 | |||
64 | /* disable Rx/Tx */ | ||
65 | wl1251_reg_write32(wl, ENABLE, 0x0); | ||
66 | |||
67 | /* disable auto calibration on start*/ | ||
68 | wl1251_reg_write32(wl, SPARE_A2, 0xffff); | ||
69 | |||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | int wl1251_boot_init_seq(struct wl1251 *wl) | ||
74 | { | ||
75 | u32 scr_pad6, init_data, tmp, elp_cmd, ref_freq; | ||
76 | |||
77 | /* | ||
78 | * col #1: INTEGER_DIVIDER | ||
79 | * col #2: FRACTIONAL_DIVIDER | ||
80 | * col #3: ATTN_BB | ||
81 | * col #4: ALPHA_BB | ||
82 | * col #5: STOP_TIME_BB | ||
83 | * col #6: BB_PLL_LOOP_FILTER | ||
84 | */ | ||
85 | static const u32 LUT[REF_FREQ_NUM][LUT_PARAM_NUM] = { | ||
86 | |||
87 | { 83, 87381, 0xB, 5, 0xF00, 3}, /* REF_FREQ_19_2*/ | ||
88 | { 61, 141154, 0xB, 5, 0x1450, 2}, /* REF_FREQ_26_0*/ | ||
89 | { 41, 174763, 0xC, 6, 0x2D00, 1}, /* REF_FREQ_38_4*/ | ||
90 | { 40, 0, 0xC, 6, 0x2EE0, 1}, /* REF_FREQ_40_0*/ | ||
91 | { 47, 162280, 0xC, 6, 0x2760, 1} /* REF_FREQ_33_6 */ | ||
92 | }; | ||
93 | |||
94 | /* read NVS params */ | ||
95 | scr_pad6 = wl1251_reg_read32(wl, SCR_PAD6); | ||
96 | wl1251_debug(DEBUG_BOOT, "scr_pad6 0x%x", scr_pad6); | ||
97 | |||
98 | /* read ELP_CMD */ | ||
99 | elp_cmd = wl1251_reg_read32(wl, ELP_CMD); | ||
100 | wl1251_debug(DEBUG_BOOT, "elp_cmd 0x%x", elp_cmd); | ||
101 | |||
102 | /* set the BB calibration time to be 300 usec (PLL_CAL_TIME) */ | ||
103 | ref_freq = scr_pad6 & 0x000000FF; | ||
104 | wl1251_debug(DEBUG_BOOT, "ref_freq 0x%x", ref_freq); | ||
105 | |||
106 | wl1251_reg_write32(wl, PLL_CAL_TIME, 0x9); | ||
107 | |||
108 | /* | ||
109 | * PG 1.2: set the clock buffer time to be 210 usec (CLK_BUF_TIME) | ||
110 | */ | ||
111 | wl1251_reg_write32(wl, CLK_BUF_TIME, 0x6); | ||
112 | |||
113 | /* | ||
114 | * set the clock detect feature to work in the restart wu procedure | ||
115 | * (ELP_CFG_MODE[14]) and Select the clock source type | ||
116 | * (ELP_CFG_MODE[13:12]) | ||
117 | */ | ||
118 | tmp = ((scr_pad6 & 0x0000FF00) << 4) | 0x00004000; | ||
119 | wl1251_reg_write32(wl, ELP_CFG_MODE, tmp); | ||
120 | |||
121 | /* PG 1.2: enable the BB PLL fix. Enable the PLL_LIMP_CLK_EN_CMD */ | ||
122 | elp_cmd |= 0x00000040; | ||
123 | wl1251_reg_write32(wl, ELP_CMD, elp_cmd); | ||
124 | |||
125 | /* PG 1.2: Set the BB PLL stable time to be 1000usec | ||
126 | * (PLL_STABLE_TIME) */ | ||
127 | wl1251_reg_write32(wl, CFG_PLL_SYNC_CNT, 0x20); | ||
128 | |||
129 | /* PG 1.2: read clock request time */ | ||
130 | init_data = wl1251_reg_read32(wl, CLK_REQ_TIME); | ||
131 | |||
132 | /* | ||
133 | * PG 1.2: set the clock request time to be ref_clk_settling_time - | ||
134 | * 1ms = 4ms | ||
135 | */ | ||
136 | if (init_data > 0x21) | ||
137 | tmp = init_data - 0x21; | ||
138 | else | ||
139 | tmp = 0; | ||
140 | wl1251_reg_write32(wl, CLK_REQ_TIME, tmp); | ||
141 | |||
142 | /* set BB PLL configurations in RF AFE */ | ||
143 | wl1251_reg_write32(wl, 0x003058cc, 0x4B5); | ||
144 | |||
145 | /* set RF_AFE_REG_5 */ | ||
146 | wl1251_reg_write32(wl, 0x003058d4, 0x50); | ||
147 | |||
148 | /* set RF_AFE_CTRL_REG_2 */ | ||
149 | wl1251_reg_write32(wl, 0x00305948, 0x11c001); | ||
150 | |||
151 | /* | ||
152 | * change RF PLL and BB PLL divider for VCO clock and adjust VCO | ||
153 | * bais current(RF_AFE_REG_13) | ||
154 | */ | ||
155 | wl1251_reg_write32(wl, 0x003058f4, 0x1e); | ||
156 | |||
157 | /* set BB PLL configurations */ | ||
158 | tmp = LUT[ref_freq][LUT_PARAM_INTEGER_DIVIDER] | 0x00017000; | ||
159 | wl1251_reg_write32(wl, 0x00305840, tmp); | ||
160 | |||
161 | /* set fractional divider according to Appendix C-BB PLL | ||
162 | * Calculations | ||
163 | */ | ||
164 | tmp = LUT[ref_freq][LUT_PARAM_FRACTIONAL_DIVIDER]; | ||
165 | wl1251_reg_write32(wl, 0x00305844, tmp); | ||
166 | |||
167 | /* set the initial data for the sigma delta */ | ||
168 | wl1251_reg_write32(wl, 0x00305848, 0x3039); | ||
169 | |||
170 | /* | ||
171 | * set the accumulator attenuation value, calibration loop1 | ||
172 | * (alpha), calibration loop2 (beta), calibration loop3 (gamma) and | ||
173 | * the VCO gain | ||
174 | */ | ||
175 | tmp = (LUT[ref_freq][LUT_PARAM_ATTN_BB] << 16) | | ||
176 | (LUT[ref_freq][LUT_PARAM_ALPHA_BB] << 12) | 0x1; | ||
177 | wl1251_reg_write32(wl, 0x00305854, tmp); | ||
178 | |||
179 | /* | ||
180 | * set the calibration stop time after holdoff time expires and set | ||
181 | * settling time HOLD_OFF_TIME_BB | ||
182 | */ | ||
183 | tmp = LUT[ref_freq][LUT_PARAM_STOP_TIME_BB] | 0x000A0000; | ||
184 | wl1251_reg_write32(wl, 0x00305858, tmp); | ||
185 | |||
186 | /* | ||
187 | * set BB PLL Loop filter capacitor3- BB_C3[2:0] and set BB PLL | ||
188 | * constant leakage current to linearize PFD to 0uA - | ||
189 | * BB_ILOOPF[7:3] | ||
190 | */ | ||
191 | tmp = LUT[ref_freq][LUT_PARAM_BB_PLL_LOOP_FILTER] | 0x00000030; | ||
192 | wl1251_reg_write32(wl, 0x003058f8, tmp); | ||
193 | |||
194 | /* | ||
195 | * set regulator output voltage for n divider to | ||
196 | * 1.35-BB_REFDIV[1:0], set charge pump current- BB_CPGAIN[4:2], | ||
197 | * set BB PLL Loop filter capacitor2- BB_C2[7:5], set gain of BB | ||
198 | * PLL auto-call to normal mode- BB_CALGAIN_3DB[8] | ||
199 | */ | ||
200 | wl1251_reg_write32(wl, 0x003058f0, 0x29); | ||
201 | |||
202 | /* enable restart wakeup sequence (ELP_CMD[0]) */ | ||
203 | wl1251_reg_write32(wl, ELP_CMD, elp_cmd | 0x1); | ||
204 | |||
205 | /* restart sequence completed */ | ||
206 | udelay(2000); | ||
207 | |||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | static void wl1251_boot_set_ecpu_ctrl(struct wl1251 *wl, u32 flag) | ||
212 | { | ||
213 | u32 cpu_ctrl; | ||
214 | |||
215 | /* 10.5.0 run the firmware (I) */ | ||
216 | cpu_ctrl = wl1251_reg_read32(wl, ACX_REG_ECPU_CONTROL); | ||
217 | |||
218 | /* 10.5.1 run the firmware (II) */ | ||
219 | cpu_ctrl &= ~flag; | ||
220 | wl1251_reg_write32(wl, ACX_REG_ECPU_CONTROL, cpu_ctrl); | ||
221 | } | ||
222 | |||
223 | int wl1251_boot_run_firmware(struct wl1251 *wl) | ||
224 | { | ||
225 | int loop, ret; | ||
226 | u32 chip_id, acx_intr; | ||
227 | |||
228 | wl1251_boot_set_ecpu_ctrl(wl, ECPU_CONTROL_HALT); | ||
229 | |||
230 | chip_id = wl1251_reg_read32(wl, CHIP_ID_B); | ||
231 | |||
232 | wl1251_debug(DEBUG_BOOT, "chip id after firmware boot: 0x%x", chip_id); | ||
233 | |||
234 | if (chip_id != wl->chip_id) { | ||
235 | wl1251_error("chip id doesn't match after firmware boot"); | ||
236 | return -EIO; | ||
237 | } | ||
238 | |||
239 | /* wait for init to complete */ | ||
240 | loop = 0; | ||
241 | while (loop++ < INIT_LOOP) { | ||
242 | udelay(INIT_LOOP_DELAY); | ||
243 | acx_intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | ||
244 | |||
245 | if (acx_intr == 0xffffffff) { | ||
246 | wl1251_error("error reading hardware complete " | ||
247 | "init indication"); | ||
248 | return -EIO; | ||
249 | } | ||
250 | /* check that ACX_INTR_INIT_COMPLETE is enabled */ | ||
251 | else if (acx_intr & WL1251_ACX_INTR_INIT_COMPLETE) { | ||
252 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_ACK, | ||
253 | WL1251_ACX_INTR_INIT_COMPLETE); | ||
254 | break; | ||
255 | } | ||
256 | } | ||
257 | |||
258 | if (loop > INIT_LOOP) { | ||
259 | wl1251_error("timeout waiting for the hardware to " | ||
260 | "complete initialization"); | ||
261 | return -EIO; | ||
262 | } | ||
263 | |||
264 | /* get hardware config command mail box */ | ||
265 | wl->cmd_box_addr = wl1251_reg_read32(wl, REG_COMMAND_MAILBOX_PTR); | ||
266 | |||
267 | /* get hardware config event mail box */ | ||
268 | wl->event_box_addr = wl1251_reg_read32(wl, REG_EVENT_MAILBOX_PTR); | ||
269 | |||
270 | /* set the working partition to its "running" mode offset */ | ||
271 | wl1251_set_partition(wl, WL1251_PART_WORK_MEM_START, | ||
272 | WL1251_PART_WORK_MEM_SIZE, | ||
273 | WL1251_PART_WORK_REG_START, | ||
274 | WL1251_PART_WORK_REG_SIZE); | ||
275 | |||
276 | wl1251_debug(DEBUG_MAILBOX, "cmd_box_addr 0x%x event_box_addr 0x%x", | ||
277 | wl->cmd_box_addr, wl->event_box_addr); | ||
278 | |||
279 | wl1251_acx_fw_version(wl, wl->fw_ver, sizeof(wl->fw_ver)); | ||
280 | |||
281 | /* | ||
282 | * in case of full asynchronous mode the firmware event must be | ||
283 | * ready to receive event from the command mailbox | ||
284 | */ | ||
285 | |||
286 | /* enable gpio interrupts */ | ||
287 | wl1251_enable_interrupts(wl); | ||
288 | |||
289 | /* Enable target's interrupts */ | ||
290 | wl->intr_mask = WL1251_ACX_INTR_RX0_DATA | | ||
291 | WL1251_ACX_INTR_RX1_DATA | | ||
292 | WL1251_ACX_INTR_TX_RESULT | | ||
293 | WL1251_ACX_INTR_EVENT_A | | ||
294 | WL1251_ACX_INTR_EVENT_B | | ||
295 | WL1251_ACX_INTR_INIT_COMPLETE; | ||
296 | wl1251_boot_target_enable_interrupts(wl); | ||
297 | |||
298 | wl->event_mask = SCAN_COMPLETE_EVENT_ID | BSS_LOSE_EVENT_ID | | ||
299 | SYNCHRONIZATION_TIMEOUT_EVENT_ID | | ||
300 | ROAMING_TRIGGER_LOW_RSSI_EVENT_ID | | ||
301 | ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID | | ||
302 | REGAINED_BSS_EVENT_ID | BT_PTA_SENSE_EVENT_ID | | ||
303 | BT_PTA_PREDICTION_EVENT_ID | JOIN_EVENT_COMPLETE_ID; | ||
304 | |||
305 | ret = wl1251_event_unmask(wl); | ||
306 | if (ret < 0) { | ||
307 | wl1251_error("EVENT mask setting failed"); | ||
308 | return ret; | ||
309 | } | ||
310 | |||
311 | wl1251_event_mbox_config(wl); | ||
312 | |||
313 | /* firmware startup completed */ | ||
314 | return 0; | ||
315 | } | ||
316 | |||
317 | static int wl1251_boot_upload_firmware(struct wl1251 *wl) | ||
318 | { | ||
319 | int addr, chunk_num, partition_limit; | ||
320 | size_t fw_data_len, len; | ||
321 | u8 *p, *buf; | ||
322 | |||
323 | /* whal_FwCtrl_LoadFwImageSm() */ | ||
324 | |||
325 | wl1251_debug(DEBUG_BOOT, "chip id before fw upload: 0x%x", | ||
326 | wl1251_reg_read32(wl, CHIP_ID_B)); | ||
327 | |||
328 | /* 10.0 check firmware length and set partition */ | ||
329 | fw_data_len = (wl->fw[4] << 24) | (wl->fw[5] << 16) | | ||
330 | (wl->fw[6] << 8) | (wl->fw[7]); | ||
331 | |||
332 | wl1251_debug(DEBUG_BOOT, "fw_data_len %zu chunk_size %d", fw_data_len, | ||
333 | CHUNK_SIZE); | ||
334 | |||
335 | if ((fw_data_len % 4) != 0) { | ||
336 | wl1251_error("firmware length not multiple of four"); | ||
337 | return -EIO; | ||
338 | } | ||
339 | |||
340 | buf = kmalloc(CHUNK_SIZE, GFP_KERNEL); | ||
341 | if (!buf) { | ||
342 | wl1251_error("allocation for firmware upload chunk failed"); | ||
343 | return -ENOMEM; | ||
344 | } | ||
345 | |||
346 | wl1251_set_partition(wl, WL1251_PART_DOWN_MEM_START, | ||
347 | WL1251_PART_DOWN_MEM_SIZE, | ||
348 | WL1251_PART_DOWN_REG_START, | ||
349 | WL1251_PART_DOWN_REG_SIZE); | ||
350 | |||
351 | /* 10.1 set partition limit and chunk num */ | ||
352 | chunk_num = 0; | ||
353 | partition_limit = WL1251_PART_DOWN_MEM_SIZE; | ||
354 | |||
355 | while (chunk_num < fw_data_len / CHUNK_SIZE) { | ||
356 | /* 10.2 update partition, if needed */ | ||
357 | addr = WL1251_PART_DOWN_MEM_START + | ||
358 | (chunk_num + 2) * CHUNK_SIZE; | ||
359 | if (addr > partition_limit) { | ||
360 | addr = WL1251_PART_DOWN_MEM_START + | ||
361 | chunk_num * CHUNK_SIZE; | ||
362 | partition_limit = chunk_num * CHUNK_SIZE + | ||
363 | WL1251_PART_DOWN_MEM_SIZE; | ||
364 | wl1251_set_partition(wl, | ||
365 | addr, | ||
366 | WL1251_PART_DOWN_MEM_SIZE, | ||
367 | WL1251_PART_DOWN_REG_START, | ||
368 | WL1251_PART_DOWN_REG_SIZE); | ||
369 | } | ||
370 | |||
371 | /* 10.3 upload the chunk */ | ||
372 | addr = WL1251_PART_DOWN_MEM_START + chunk_num * CHUNK_SIZE; | ||
373 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; | ||
374 | wl1251_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x", | ||
375 | p, addr); | ||
376 | |||
377 | /* need to copy the chunk for dma */ | ||
378 | len = CHUNK_SIZE; | ||
379 | memcpy(buf, p, len); | ||
380 | wl1251_mem_write(wl, addr, buf, len); | ||
381 | |||
382 | chunk_num++; | ||
383 | } | ||
384 | |||
385 | /* 10.4 upload the last chunk */ | ||
386 | addr = WL1251_PART_DOWN_MEM_START + chunk_num * CHUNK_SIZE; | ||
387 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; | ||
388 | |||
389 | /* need to copy the chunk for dma */ | ||
390 | len = fw_data_len % CHUNK_SIZE; | ||
391 | memcpy(buf, p, len); | ||
392 | |||
393 | wl1251_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x", | ||
394 | len, p, addr); | ||
395 | wl1251_mem_write(wl, addr, buf, len); | ||
396 | |||
397 | kfree(buf); | ||
398 | |||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | static int wl1251_boot_upload_nvs(struct wl1251 *wl) | ||
403 | { | ||
404 | size_t nvs_len, nvs_bytes_written, burst_len; | ||
405 | int nvs_start, i; | ||
406 | u32 dest_addr, val; | ||
407 | u8 *nvs_ptr, *nvs; | ||
408 | |||
409 | nvs = wl->nvs; | ||
410 | if (nvs == NULL) | ||
411 | return -ENODEV; | ||
412 | |||
413 | nvs_ptr = nvs; | ||
414 | |||
415 | nvs_len = wl->nvs_len; | ||
416 | nvs_start = wl->fw_len; | ||
417 | |||
418 | /* | ||
419 | * Layout before the actual NVS tables: | ||
420 | * 1 byte : burst length. | ||
421 | * 2 bytes: destination address. | ||
422 | * n bytes: data to burst copy. | ||
423 | * | ||
424 | * This is ended by a 0 length, then the NVS tables. | ||
425 | */ | ||
426 | |||
427 | while (nvs_ptr[0]) { | ||
428 | burst_len = nvs_ptr[0]; | ||
429 | dest_addr = (nvs_ptr[1] & 0xfe) | ((u32)(nvs_ptr[2] << 8)); | ||
430 | |||
431 | /* We move our pointer to the data */ | ||
432 | nvs_ptr += 3; | ||
433 | |||
434 | for (i = 0; i < burst_len; i++) { | ||
435 | val = (nvs_ptr[0] | (nvs_ptr[1] << 8) | ||
436 | | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); | ||
437 | |||
438 | wl1251_debug(DEBUG_BOOT, | ||
439 | "nvs burst write 0x%x: 0x%x", | ||
440 | dest_addr, val); | ||
441 | wl1251_mem_write32(wl, dest_addr, val); | ||
442 | |||
443 | nvs_ptr += 4; | ||
444 | dest_addr += 4; | ||
445 | } | ||
446 | } | ||
447 | |||
448 | /* | ||
449 | * We've reached the first zero length, the first NVS table | ||
450 | * is 7 bytes further. | ||
451 | */ | ||
452 | nvs_ptr += 7; | ||
453 | nvs_len -= nvs_ptr - nvs; | ||
454 | nvs_len = ALIGN(nvs_len, 4); | ||
455 | |||
456 | /* Now we must set the partition correctly */ | ||
457 | wl1251_set_partition(wl, nvs_start, | ||
458 | WL1251_PART_DOWN_MEM_SIZE, | ||
459 | WL1251_PART_DOWN_REG_START, | ||
460 | WL1251_PART_DOWN_REG_SIZE); | ||
461 | |||
462 | /* And finally we upload the NVS tables */ | ||
463 | nvs_bytes_written = 0; | ||
464 | while (nvs_bytes_written < nvs_len) { | ||
465 | val = (nvs_ptr[0] | (nvs_ptr[1] << 8) | ||
466 | | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); | ||
467 | |||
468 | val = cpu_to_le32(val); | ||
469 | |||
470 | wl1251_debug(DEBUG_BOOT, | ||
471 | "nvs write table 0x%x: 0x%x", | ||
472 | nvs_start, val); | ||
473 | wl1251_mem_write32(wl, nvs_start, val); | ||
474 | |||
475 | nvs_ptr += 4; | ||
476 | nvs_bytes_written += 4; | ||
477 | nvs_start += 4; | ||
478 | } | ||
479 | |||
480 | return 0; | ||
481 | } | ||
482 | |||
483 | int wl1251_boot(struct wl1251 *wl) | ||
484 | { | ||
485 | int ret = 0, minor_minor_e2_ver; | ||
486 | u32 tmp, boot_data; | ||
487 | |||
488 | /* halt embedded ARM CPU while loading firmware */ | ||
489 | wl1251_reg_write32(wl, ACX_REG_ECPU_CONTROL, ECPU_CONTROL_HALT); | ||
490 | |||
491 | ret = wl1251_boot_soft_reset(wl); | ||
492 | if (ret < 0) | ||
493 | goto out; | ||
494 | |||
495 | /* 2. start processing NVS file */ | ||
496 | if (wl->use_eeprom) { | ||
497 | wl1251_reg_write32(wl, ACX_REG_EE_START, START_EEPROM_MGR); | ||
498 | /* Wait for EEPROM NVS burst read to complete */ | ||
499 | msleep(40); | ||
500 | wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, USE_EEPROM); | ||
501 | } else { | ||
502 | ret = wl1251_boot_upload_nvs(wl); | ||
503 | if (ret < 0) | ||
504 | goto out; | ||
505 | |||
506 | /* write firmware's last address (ie. it's length) to | ||
507 | * ACX_EEPROMLESS_IND_REG */ | ||
508 | wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len); | ||
509 | } | ||
510 | |||
511 | /* 6. read the EEPROM parameters */ | ||
512 | tmp = wl1251_reg_read32(wl, SCR_PAD2); | ||
513 | |||
514 | /* 7. read bootdata */ | ||
515 | wl->boot_attr.radio_type = (tmp & 0x0000FF00) >> 8; | ||
516 | wl->boot_attr.major = (tmp & 0x00FF0000) >> 16; | ||
517 | tmp = wl1251_reg_read32(wl, SCR_PAD3); | ||
518 | |||
519 | /* 8. check bootdata and call restart sequence */ | ||
520 | wl->boot_attr.minor = (tmp & 0x00FF0000) >> 16; | ||
521 | minor_minor_e2_ver = (tmp & 0xFF000000) >> 24; | ||
522 | |||
523 | wl1251_debug(DEBUG_BOOT, "radioType 0x%x majorE2Ver 0x%x " | ||
524 | "minorE2Ver 0x%x minor_minor_e2_ver 0x%x", | ||
525 | wl->boot_attr.radio_type, wl->boot_attr.major, | ||
526 | wl->boot_attr.minor, minor_minor_e2_ver); | ||
527 | |||
528 | ret = wl1251_boot_init_seq(wl); | ||
529 | if (ret < 0) | ||
530 | goto out; | ||
531 | |||
532 | /* 9. NVS processing done */ | ||
533 | boot_data = wl1251_reg_read32(wl, ACX_REG_ECPU_CONTROL); | ||
534 | |||
535 | wl1251_debug(DEBUG_BOOT, "halt boot_data 0x%x", boot_data); | ||
536 | |||
537 | /* 10. check that ECPU_CONTROL_HALT bits are set in | ||
538 | * pWhalBus->uBootData and start uploading firmware | ||
539 | */ | ||
540 | if ((boot_data & ECPU_CONTROL_HALT) == 0) { | ||
541 | wl1251_error("boot failed, ECPU_CONTROL_HALT not set"); | ||
542 | ret = -EIO; | ||
543 | goto out; | ||
544 | } | ||
545 | |||
546 | ret = wl1251_boot_upload_firmware(wl); | ||
547 | if (ret < 0) | ||
548 | goto out; | ||
549 | |||
550 | /* 10.5 start firmware */ | ||
551 | ret = wl1251_boot_run_firmware(wl); | ||
552 | if (ret < 0) | ||
553 | goto out; | ||
554 | |||
555 | out: | ||
556 | return ret; | ||
557 | } | ||
diff --git a/drivers/net/wireless/wl1251/boot.h b/drivers/net/wireless/wl1251/boot.h new file mode 100644 index 000000000000..7661bc5e4662 --- /dev/null +++ b/drivers/net/wireless/wl1251/boot.h | |||
@@ -0,0 +1,39 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #ifndef __BOOT_H__ | ||
23 | #define __BOOT_H__ | ||
24 | |||
25 | #include "wl1251.h" | ||
26 | |||
27 | int wl1251_boot_soft_reset(struct wl1251 *wl); | ||
28 | int wl1251_boot_init_seq(struct wl1251 *wl); | ||
29 | int wl1251_boot_run_firmware(struct wl1251 *wl); | ||
30 | void wl1251_boot_target_enable_interrupts(struct wl1251 *wl); | ||
31 | int wl1251_boot(struct wl1251 *wl); | ||
32 | |||
33 | /* number of times we try to read the INIT interrupt */ | ||
34 | #define INIT_LOOP 20000 | ||
35 | |||
36 | /* delay between retries */ | ||
37 | #define INIT_LOOP_DELAY 50 | ||
38 | |||
39 | #endif | ||
diff --git a/drivers/net/wireless/wl1251/cmd.c b/drivers/net/wireless/wl1251/cmd.c new file mode 100644 index 000000000000..0ade4bd617c0 --- /dev/null +++ b/drivers/net/wireless/wl1251/cmd.c | |||
@@ -0,0 +1,496 @@ | |||
1 | #include "cmd.h" | ||
2 | |||
3 | #include <linux/module.h> | ||
4 | #include <linux/slab.h> | ||
5 | #include <linux/crc7.h> | ||
6 | |||
7 | #include "wl1251.h" | ||
8 | #include "reg.h" | ||
9 | #include "io.h" | ||
10 | #include "ps.h" | ||
11 | #include "acx.h" | ||
12 | |||
13 | /** | ||
14 | * send command to firmware | ||
15 | * | ||
16 | * @wl: wl struct | ||
17 | * @id: command id | ||
18 | * @buf: buffer containing the command, must work with dma | ||
19 | * @len: length of the buffer | ||
20 | */ | ||
21 | int wl1251_cmd_send(struct wl1251 *wl, u16 id, void *buf, size_t len) | ||
22 | { | ||
23 | struct wl1251_cmd_header *cmd; | ||
24 | unsigned long timeout; | ||
25 | u32 intr; | ||
26 | int ret = 0; | ||
27 | |||
28 | cmd = buf; | ||
29 | cmd->id = id; | ||
30 | cmd->status = 0; | ||
31 | |||
32 | WARN_ON(len % 4 != 0); | ||
33 | |||
34 | wl1251_mem_write(wl, wl->cmd_box_addr, buf, len); | ||
35 | |||
36 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); | ||
37 | |||
38 | timeout = jiffies + msecs_to_jiffies(WL1251_COMMAND_TIMEOUT); | ||
39 | |||
40 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | ||
41 | while (!(intr & WL1251_ACX_INTR_CMD_COMPLETE)) { | ||
42 | if (time_after(jiffies, timeout)) { | ||
43 | wl1251_error("command complete timeout"); | ||
44 | ret = -ETIMEDOUT; | ||
45 | goto out; | ||
46 | } | ||
47 | |||
48 | msleep(1); | ||
49 | |||
50 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | ||
51 | } | ||
52 | |||
53 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_ACK, | ||
54 | WL1251_ACX_INTR_CMD_COMPLETE); | ||
55 | |||
56 | out: | ||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * send test command to firmware | ||
62 | * | ||
63 | * @wl: wl struct | ||
64 | * @buf: buffer containing the command, with all headers, must work with dma | ||
65 | * @len: length of the buffer | ||
66 | * @answer: is answer needed | ||
67 | */ | ||
68 | int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer) | ||
69 | { | ||
70 | int ret; | ||
71 | |||
72 | wl1251_debug(DEBUG_CMD, "cmd test"); | ||
73 | |||
74 | ret = wl1251_cmd_send(wl, CMD_TEST, buf, buf_len); | ||
75 | |||
76 | if (ret < 0) { | ||
77 | wl1251_warning("TEST command failed"); | ||
78 | return ret; | ||
79 | } | ||
80 | |||
81 | if (answer) { | ||
82 | struct wl1251_command *cmd_answer; | ||
83 | |||
84 | /* | ||
85 | * The test command got in, we can read the answer. | ||
86 | * The answer would be a wl1251_command, where the | ||
87 | * parameter array contains the actual answer. | ||
88 | */ | ||
89 | wl1251_mem_read(wl, wl->cmd_box_addr, buf, buf_len); | ||
90 | |||
91 | cmd_answer = buf; | ||
92 | |||
93 | if (cmd_answer->header.status != CMD_STATUS_SUCCESS) | ||
94 | wl1251_error("TEST command answer error: %d", | ||
95 | cmd_answer->header.status); | ||
96 | } | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * read acx from firmware | ||
103 | * | ||
104 | * @wl: wl struct | ||
105 | * @id: acx id | ||
106 | * @buf: buffer for the response, including all headers, must work with dma | ||
107 | * @len: lenght of buf | ||
108 | */ | ||
109 | int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len) | ||
110 | { | ||
111 | struct acx_header *acx = buf; | ||
112 | int ret; | ||
113 | |||
114 | wl1251_debug(DEBUG_CMD, "cmd interrogate"); | ||
115 | |||
116 | acx->id = id; | ||
117 | |||
118 | /* payload length, does not include any headers */ | ||
119 | acx->len = len - sizeof(*acx); | ||
120 | |||
121 | ret = wl1251_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx)); | ||
122 | if (ret < 0) { | ||
123 | wl1251_error("INTERROGATE command failed"); | ||
124 | goto out; | ||
125 | } | ||
126 | |||
127 | /* the interrogate command got in, we can read the answer */ | ||
128 | wl1251_mem_read(wl, wl->cmd_box_addr, buf, len); | ||
129 | |||
130 | acx = buf; | ||
131 | if (acx->cmd.status != CMD_STATUS_SUCCESS) | ||
132 | wl1251_error("INTERROGATE command error: %d", | ||
133 | acx->cmd.status); | ||
134 | |||
135 | out: | ||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * write acx value to firmware | ||
141 | * | ||
142 | * @wl: wl struct | ||
143 | * @id: acx id | ||
144 | * @buf: buffer containing acx, including all headers, must work with dma | ||
145 | * @len: length of buf | ||
146 | */ | ||
147 | int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len) | ||
148 | { | ||
149 | struct acx_header *acx = buf; | ||
150 | int ret; | ||
151 | |||
152 | wl1251_debug(DEBUG_CMD, "cmd configure"); | ||
153 | |||
154 | acx->id = id; | ||
155 | |||
156 | /* payload length, does not include any headers */ | ||
157 | acx->len = len - sizeof(*acx); | ||
158 | |||
159 | ret = wl1251_cmd_send(wl, CMD_CONFIGURE, acx, len); | ||
160 | if (ret < 0) { | ||
161 | wl1251_warning("CONFIGURE command NOK"); | ||
162 | return ret; | ||
163 | } | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity, | ||
169 | void *bitmap, u16 bitmap_len, u8 bitmap_control) | ||
170 | { | ||
171 | struct wl1251_cmd_vbm_update *vbm; | ||
172 | int ret; | ||
173 | |||
174 | wl1251_debug(DEBUG_CMD, "cmd vbm"); | ||
175 | |||
176 | vbm = kzalloc(sizeof(*vbm), GFP_KERNEL); | ||
177 | if (!vbm) { | ||
178 | ret = -ENOMEM; | ||
179 | goto out; | ||
180 | } | ||
181 | |||
182 | /* Count and period will be filled by the target */ | ||
183 | vbm->tim.bitmap_ctrl = bitmap_control; | ||
184 | if (bitmap_len > PARTIAL_VBM_MAX) { | ||
185 | wl1251_warning("cmd vbm len is %d B, truncating to %d", | ||
186 | bitmap_len, PARTIAL_VBM_MAX); | ||
187 | bitmap_len = PARTIAL_VBM_MAX; | ||
188 | } | ||
189 | memcpy(vbm->tim.pvb_field, bitmap, bitmap_len); | ||
190 | vbm->tim.identity = identity; | ||
191 | vbm->tim.length = bitmap_len + 3; | ||
192 | |||
193 | vbm->len = cpu_to_le16(bitmap_len + 5); | ||
194 | |||
195 | ret = wl1251_cmd_send(wl, CMD_VBM, vbm, sizeof(*vbm)); | ||
196 | if (ret < 0) { | ||
197 | wl1251_error("VBM command failed"); | ||
198 | goto out; | ||
199 | } | ||
200 | |||
201 | out: | ||
202 | kfree(vbm); | ||
203 | return ret; | ||
204 | } | ||
205 | |||
206 | int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable) | ||
207 | { | ||
208 | struct cmd_enabledisable_path *cmd; | ||
209 | int ret; | ||
210 | u16 cmd_rx, cmd_tx; | ||
211 | |||
212 | wl1251_debug(DEBUG_CMD, "cmd data path"); | ||
213 | |||
214 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
215 | if (!cmd) { | ||
216 | ret = -ENOMEM; | ||
217 | goto out; | ||
218 | } | ||
219 | |||
220 | cmd->channel = channel; | ||
221 | |||
222 | if (enable) { | ||
223 | cmd_rx = CMD_ENABLE_RX; | ||
224 | cmd_tx = CMD_ENABLE_TX; | ||
225 | } else { | ||
226 | cmd_rx = CMD_DISABLE_RX; | ||
227 | cmd_tx = CMD_DISABLE_TX; | ||
228 | } | ||
229 | |||
230 | ret = wl1251_cmd_send(wl, cmd_rx, cmd, sizeof(*cmd)); | ||
231 | if (ret < 0) { | ||
232 | wl1251_error("rx %s cmd for channel %d failed", | ||
233 | enable ? "start" : "stop", channel); | ||
234 | goto out; | ||
235 | } | ||
236 | |||
237 | wl1251_debug(DEBUG_BOOT, "rx %s cmd channel %d", | ||
238 | enable ? "start" : "stop", channel); | ||
239 | |||
240 | ret = wl1251_cmd_send(wl, cmd_tx, cmd, sizeof(*cmd)); | ||
241 | if (ret < 0) { | ||
242 | wl1251_error("tx %s cmd for channel %d failed", | ||
243 | enable ? "start" : "stop", channel); | ||
244 | return ret; | ||
245 | } | ||
246 | |||
247 | wl1251_debug(DEBUG_BOOT, "tx %s cmd channel %d", | ||
248 | enable ? "start" : "stop", channel); | ||
249 | |||
250 | out: | ||
251 | kfree(cmd); | ||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel, | ||
256 | u16 beacon_interval, u8 dtim_interval) | ||
257 | { | ||
258 | struct cmd_join *join; | ||
259 | int ret, i; | ||
260 | u8 *bssid; | ||
261 | |||
262 | join = kzalloc(sizeof(*join), GFP_KERNEL); | ||
263 | if (!join) { | ||
264 | ret = -ENOMEM; | ||
265 | goto out; | ||
266 | } | ||
267 | |||
268 | wl1251_debug(DEBUG_CMD, "cmd join%s ch %d %d/%d", | ||
269 | bss_type == BSS_TYPE_IBSS ? " ibss" : "", | ||
270 | channel, beacon_interval, dtim_interval); | ||
271 | |||
272 | /* Reverse order BSSID */ | ||
273 | bssid = (u8 *) &join->bssid_lsb; | ||
274 | for (i = 0; i < ETH_ALEN; i++) | ||
275 | bssid[i] = wl->bssid[ETH_ALEN - i - 1]; | ||
276 | |||
277 | join->rx_config_options = wl->rx_config; | ||
278 | join->rx_filter_options = wl->rx_filter; | ||
279 | |||
280 | /* | ||
281 | * FIXME: disable temporarily all filters because after commit | ||
282 | * 9cef8737 "mac80211: fix managed mode BSSID handling" broke | ||
283 | * association. The filter logic needs to be implemented properly | ||
284 | * and once that is done, this hack can be removed. | ||
285 | */ | ||
286 | join->rx_config_options = 0; | ||
287 | join->rx_filter_options = WL1251_DEFAULT_RX_FILTER; | ||
288 | |||
289 | join->basic_rate_set = RATE_MASK_1MBPS | RATE_MASK_2MBPS | | ||
290 | RATE_MASK_5_5MBPS | RATE_MASK_11MBPS; | ||
291 | |||
292 | join->beacon_interval = beacon_interval; | ||
293 | join->dtim_interval = dtim_interval; | ||
294 | join->bss_type = bss_type; | ||
295 | join->channel = channel; | ||
296 | join->ctrl = JOIN_CMD_CTRL_TX_FLUSH; | ||
297 | |||
298 | ret = wl1251_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join)); | ||
299 | if (ret < 0) { | ||
300 | wl1251_error("failed to initiate cmd join"); | ||
301 | goto out; | ||
302 | } | ||
303 | |||
304 | out: | ||
305 | kfree(join); | ||
306 | return ret; | ||
307 | } | ||
308 | |||
309 | int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode) | ||
310 | { | ||
311 | struct wl1251_cmd_ps_params *ps_params = NULL; | ||
312 | int ret = 0; | ||
313 | |||
314 | wl1251_debug(DEBUG_CMD, "cmd set ps mode"); | ||
315 | |||
316 | ps_params = kzalloc(sizeof(*ps_params), GFP_KERNEL); | ||
317 | if (!ps_params) { | ||
318 | ret = -ENOMEM; | ||
319 | goto out; | ||
320 | } | ||
321 | |||
322 | ps_params->ps_mode = ps_mode; | ||
323 | ps_params->send_null_data = 1; | ||
324 | ps_params->retries = 5; | ||
325 | ps_params->hang_over_period = 128; | ||
326 | ps_params->null_data_rate = 1; /* 1 Mbps */ | ||
327 | |||
328 | ret = wl1251_cmd_send(wl, CMD_SET_PS_MODE, ps_params, | ||
329 | sizeof(*ps_params)); | ||
330 | if (ret < 0) { | ||
331 | wl1251_error("cmd set_ps_mode failed"); | ||
332 | goto out; | ||
333 | } | ||
334 | |||
335 | out: | ||
336 | kfree(ps_params); | ||
337 | return ret; | ||
338 | } | ||
339 | |||
340 | int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer, | ||
341 | size_t len) | ||
342 | { | ||
343 | struct cmd_read_write_memory *cmd; | ||
344 | int ret = 0; | ||
345 | |||
346 | wl1251_debug(DEBUG_CMD, "cmd read memory"); | ||
347 | |||
348 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
349 | if (!cmd) { | ||
350 | ret = -ENOMEM; | ||
351 | goto out; | ||
352 | } | ||
353 | |||
354 | WARN_ON(len > MAX_READ_SIZE); | ||
355 | len = min_t(size_t, len, MAX_READ_SIZE); | ||
356 | |||
357 | cmd->addr = addr; | ||
358 | cmd->size = len; | ||
359 | |||
360 | ret = wl1251_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd)); | ||
361 | if (ret < 0) { | ||
362 | wl1251_error("read memory command failed: %d", ret); | ||
363 | goto out; | ||
364 | } | ||
365 | |||
366 | /* the read command got in, we can now read the answer */ | ||
367 | wl1251_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd)); | ||
368 | |||
369 | if (cmd->header.status != CMD_STATUS_SUCCESS) | ||
370 | wl1251_error("error in read command result: %d", | ||
371 | cmd->header.status); | ||
372 | |||
373 | memcpy(answer, cmd->value, len); | ||
374 | |||
375 | out: | ||
376 | kfree(cmd); | ||
377 | return ret; | ||
378 | } | ||
379 | |||
380 | int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id, | ||
381 | void *buf, size_t buf_len) | ||
382 | { | ||
383 | struct wl1251_cmd_packet_template *cmd; | ||
384 | size_t cmd_len; | ||
385 | int ret = 0; | ||
386 | |||
387 | wl1251_debug(DEBUG_CMD, "cmd template %d", cmd_id); | ||
388 | |||
389 | WARN_ON(buf_len > WL1251_MAX_TEMPLATE_SIZE); | ||
390 | buf_len = min_t(size_t, buf_len, WL1251_MAX_TEMPLATE_SIZE); | ||
391 | cmd_len = ALIGN(sizeof(*cmd) + buf_len, 4); | ||
392 | |||
393 | cmd = kzalloc(cmd_len, GFP_KERNEL); | ||
394 | if (!cmd) { | ||
395 | ret = -ENOMEM; | ||
396 | goto out; | ||
397 | } | ||
398 | |||
399 | cmd->size = cpu_to_le16(buf_len); | ||
400 | |||
401 | if (buf) | ||
402 | memcpy(cmd->data, buf, buf_len); | ||
403 | |||
404 | ret = wl1251_cmd_send(wl, cmd_id, cmd, cmd_len); | ||
405 | if (ret < 0) { | ||
406 | wl1251_warning("cmd set_template failed: %d", ret); | ||
407 | goto out; | ||
408 | } | ||
409 | |||
410 | out: | ||
411 | kfree(cmd); | ||
412 | return ret; | ||
413 | } | ||
414 | |||
415 | int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len, | ||
416 | struct ieee80211_channel *channels[], | ||
417 | unsigned int n_channels, unsigned int n_probes) | ||
418 | { | ||
419 | struct wl1251_cmd_scan *cmd; | ||
420 | int i, ret = 0; | ||
421 | |||
422 | wl1251_debug(DEBUG_CMD, "cmd scan"); | ||
423 | |||
424 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
425 | if (!cmd) | ||
426 | return -ENOMEM; | ||
427 | |||
428 | cmd->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD); | ||
429 | cmd->params.rx_filter_options = cpu_to_le32(CFG_RX_PRSP_EN | | ||
430 | CFG_RX_MGMT_EN | | ||
431 | CFG_RX_BCN_EN); | ||
432 | cmd->params.scan_options = 0; | ||
433 | cmd->params.num_channels = n_channels; | ||
434 | cmd->params.num_probe_requests = n_probes; | ||
435 | cmd->params.tx_rate = cpu_to_le16(1 << 1); /* 2 Mbps */ | ||
436 | cmd->params.tid_trigger = 0; | ||
437 | |||
438 | for (i = 0; i < n_channels; i++) { | ||
439 | cmd->channels[i].min_duration = | ||
440 | cpu_to_le32(WL1251_SCAN_MIN_DURATION); | ||
441 | cmd->channels[i].max_duration = | ||
442 | cpu_to_le32(WL1251_SCAN_MAX_DURATION); | ||
443 | memset(&cmd->channels[i].bssid_lsb, 0xff, 4); | ||
444 | memset(&cmd->channels[i].bssid_msb, 0xff, 2); | ||
445 | cmd->channels[i].early_termination = 0; | ||
446 | cmd->channels[i].tx_power_att = 0; | ||
447 | cmd->channels[i].channel = channels[i]->hw_value; | ||
448 | } | ||
449 | |||
450 | cmd->params.ssid_len = ssid_len; | ||
451 | if (ssid) | ||
452 | memcpy(cmd->params.ssid, ssid, ssid_len); | ||
453 | |||
454 | ret = wl1251_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd)); | ||
455 | if (ret < 0) { | ||
456 | wl1251_error("cmd scan failed: %d", ret); | ||
457 | goto out; | ||
458 | } | ||
459 | |||
460 | wl1251_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd)); | ||
461 | |||
462 | if (cmd->header.status != CMD_STATUS_SUCCESS) { | ||
463 | wl1251_error("cmd scan status wasn't success: %d", | ||
464 | cmd->header.status); | ||
465 | ret = -EIO; | ||
466 | goto out; | ||
467 | } | ||
468 | |||
469 | out: | ||
470 | kfree(cmd); | ||
471 | return ret; | ||
472 | } | ||
473 | |||
474 | int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout) | ||
475 | { | ||
476 | struct wl1251_cmd_trigger_scan_to *cmd; | ||
477 | int ret; | ||
478 | |||
479 | wl1251_debug(DEBUG_CMD, "cmd trigger scan to"); | ||
480 | |||
481 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
482 | if (!cmd) | ||
483 | return -ENOMEM; | ||
484 | |||
485 | cmd->timeout = timeout; | ||
486 | |||
487 | ret = wl1251_cmd_send(wl, CMD_TRIGGER_SCAN_TO, cmd, sizeof(*cmd)); | ||
488 | if (ret < 0) { | ||
489 | wl1251_error("cmd trigger scan to failed: %d", ret); | ||
490 | goto out; | ||
491 | } | ||
492 | |||
493 | out: | ||
494 | kfree(cmd); | ||
495 | return ret; | ||
496 | } | ||
diff --git a/drivers/net/wireless/wl1251/cmd.h b/drivers/net/wireless/wl1251/cmd.h new file mode 100644 index 000000000000..e5c74c631374 --- /dev/null +++ b/drivers/net/wireless/wl1251/cmd.h | |||
@@ -0,0 +1,415 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __WL1251_CMD_H__ | ||
24 | #define __WL1251_CMD_H__ | ||
25 | |||
26 | #include "wl1251.h" | ||
27 | |||
28 | #include <net/cfg80211.h> | ||
29 | |||
30 | struct acx_header; | ||
31 | |||
32 | int wl1251_cmd_send(struct wl1251 *wl, u16 type, void *buf, size_t buf_len); | ||
33 | int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer); | ||
34 | int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len); | ||
35 | int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len); | ||
36 | int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity, | ||
37 | void *bitmap, u16 bitmap_len, u8 bitmap_control); | ||
38 | int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable); | ||
39 | int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 channel, | ||
40 | u16 beacon_interval, u8 dtim_interval); | ||
41 | int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode); | ||
42 | int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer, | ||
43 | size_t len); | ||
44 | int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id, | ||
45 | void *buf, size_t buf_len); | ||
46 | int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len, | ||
47 | struct ieee80211_channel *channels[], | ||
48 | unsigned int n_channels, unsigned int n_probes); | ||
49 | int wl1251_cmd_trigger_scan_to(struct wl1251 *wl, u32 timeout); | ||
50 | |||
51 | /* unit ms */ | ||
52 | #define WL1251_COMMAND_TIMEOUT 2000 | ||
53 | |||
54 | enum wl1251_commands { | ||
55 | CMD_RESET = 0, | ||
56 | CMD_INTERROGATE = 1, /*use this to read information elements*/ | ||
57 | CMD_CONFIGURE = 2, /*use this to write information elements*/ | ||
58 | CMD_ENABLE_RX = 3, | ||
59 | CMD_ENABLE_TX = 4, | ||
60 | CMD_DISABLE_RX = 5, | ||
61 | CMD_DISABLE_TX = 6, | ||
62 | CMD_SCAN = 8, | ||
63 | CMD_STOP_SCAN = 9, | ||
64 | CMD_VBM = 10, | ||
65 | CMD_START_JOIN = 11, | ||
66 | CMD_SET_KEYS = 12, | ||
67 | CMD_READ_MEMORY = 13, | ||
68 | CMD_WRITE_MEMORY = 14, | ||
69 | CMD_BEACON = 19, | ||
70 | CMD_PROBE_RESP = 20, | ||
71 | CMD_NULL_DATA = 21, | ||
72 | CMD_PROBE_REQ = 22, | ||
73 | CMD_TEST = 23, | ||
74 | CMD_RADIO_CALIBRATE = 25, /* OBSOLETE */ | ||
75 | CMD_ENABLE_RX_PATH = 27, /* OBSOLETE */ | ||
76 | CMD_NOISE_HIST = 28, | ||
77 | CMD_RX_RESET = 29, | ||
78 | CMD_PS_POLL = 30, | ||
79 | CMD_QOS_NULL_DATA = 31, | ||
80 | CMD_LNA_CONTROL = 32, | ||
81 | CMD_SET_BCN_MODE = 33, | ||
82 | CMD_MEASUREMENT = 34, | ||
83 | CMD_STOP_MEASUREMENT = 35, | ||
84 | CMD_DISCONNECT = 36, | ||
85 | CMD_SET_PS_MODE = 37, | ||
86 | CMD_CHANNEL_SWITCH = 38, | ||
87 | CMD_STOP_CHANNEL_SWICTH = 39, | ||
88 | CMD_AP_DISCOVERY = 40, | ||
89 | CMD_STOP_AP_DISCOVERY = 41, | ||
90 | CMD_SPS_SCAN = 42, | ||
91 | CMD_STOP_SPS_SCAN = 43, | ||
92 | CMD_HEALTH_CHECK = 45, | ||
93 | CMD_DEBUG = 46, | ||
94 | CMD_TRIGGER_SCAN_TO = 47, | ||
95 | |||
96 | NUM_COMMANDS, | ||
97 | MAX_COMMAND_ID = 0xFFFF, | ||
98 | }; | ||
99 | |||
100 | #define MAX_CMD_PARAMS 572 | ||
101 | |||
102 | struct wl1251_cmd_header { | ||
103 | u16 id; | ||
104 | u16 status; | ||
105 | /* payload */ | ||
106 | u8 data[0]; | ||
107 | } __packed; | ||
108 | |||
109 | struct wl1251_command { | ||
110 | struct wl1251_cmd_header header; | ||
111 | u8 parameters[MAX_CMD_PARAMS]; | ||
112 | } __packed; | ||
113 | |||
114 | enum { | ||
115 | CMD_MAILBOX_IDLE = 0, | ||
116 | CMD_STATUS_SUCCESS = 1, | ||
117 | CMD_STATUS_UNKNOWN_CMD = 2, | ||
118 | CMD_STATUS_UNKNOWN_IE = 3, | ||
119 | CMD_STATUS_REJECT_MEAS_SG_ACTIVE = 11, | ||
120 | CMD_STATUS_RX_BUSY = 13, | ||
121 | CMD_STATUS_INVALID_PARAM = 14, | ||
122 | CMD_STATUS_TEMPLATE_TOO_LARGE = 15, | ||
123 | CMD_STATUS_OUT_OF_MEMORY = 16, | ||
124 | CMD_STATUS_STA_TABLE_FULL = 17, | ||
125 | CMD_STATUS_RADIO_ERROR = 18, | ||
126 | CMD_STATUS_WRONG_NESTING = 19, | ||
127 | CMD_STATUS_TIMEOUT = 21, /* Driver internal use.*/ | ||
128 | CMD_STATUS_FW_RESET = 22, /* Driver internal use.*/ | ||
129 | MAX_COMMAND_STATUS = 0xff | ||
130 | }; | ||
131 | |||
132 | |||
133 | /* | ||
134 | * CMD_READ_MEMORY | ||
135 | * | ||
136 | * The host issues this command to read the WiLink device memory/registers. | ||
137 | * | ||
138 | * Note: The Base Band address has special handling (16 bits registers and | ||
139 | * addresses). For more information, see the hardware specification. | ||
140 | */ | ||
141 | /* | ||
142 | * CMD_WRITE_MEMORY | ||
143 | * | ||
144 | * The host issues this command to write the WiLink device memory/registers. | ||
145 | * | ||
146 | * The Base Band address has special handling (16 bits registers and | ||
147 | * addresses). For more information, see the hardware specification. | ||
148 | */ | ||
149 | #define MAX_READ_SIZE 256 | ||
150 | |||
151 | struct cmd_read_write_memory { | ||
152 | struct wl1251_cmd_header header; | ||
153 | |||
154 | /* The address of the memory to read from or write to.*/ | ||
155 | u32 addr; | ||
156 | |||
157 | /* The amount of data in bytes to read from or write to the WiLink | ||
158 | * device.*/ | ||
159 | u32 size; | ||
160 | |||
161 | /* The actual value read from or written to the Wilink. The source | ||
162 | of this field is the Host in WRITE command or the Wilink in READ | ||
163 | command. */ | ||
164 | u8 value[MAX_READ_SIZE]; | ||
165 | } __packed; | ||
166 | |||
167 | #define CMDMBOX_HEADER_LEN 4 | ||
168 | #define CMDMBOX_INFO_ELEM_HEADER_LEN 4 | ||
169 | |||
170 | #define WL1251_SCAN_MIN_DURATION 30000 | ||
171 | #define WL1251_SCAN_MAX_DURATION 60000 | ||
172 | |||
173 | #define WL1251_SCAN_NUM_PROBES 3 | ||
174 | |||
175 | struct wl1251_scan_parameters { | ||
176 | __le32 rx_config_options; | ||
177 | __le32 rx_filter_options; | ||
178 | |||
179 | /* | ||
180 | * Scan options: | ||
181 | * bit 0: When this bit is set, passive scan. | ||
182 | * bit 1: Band, when this bit is set we scan | ||
183 | * in the 5Ghz band. | ||
184 | * bit 2: voice mode, 0 for normal scan. | ||
185 | * bit 3: scan priority, 1 for high priority. | ||
186 | */ | ||
187 | __le16 scan_options; | ||
188 | |||
189 | /* Number of channels to scan */ | ||
190 | u8 num_channels; | ||
191 | |||
192 | /* Number opf probe requests to send, per channel */ | ||
193 | u8 num_probe_requests; | ||
194 | |||
195 | /* Rate and modulation for probe requests */ | ||
196 | __le16 tx_rate; | ||
197 | |||
198 | u8 tid_trigger; | ||
199 | u8 ssid_len; | ||
200 | u8 ssid[32]; | ||
201 | |||
202 | } __packed; | ||
203 | |||
204 | struct wl1251_scan_ch_parameters { | ||
205 | __le32 min_duration; /* in TU */ | ||
206 | __le32 max_duration; /* in TU */ | ||
207 | u32 bssid_lsb; | ||
208 | u16 bssid_msb; | ||
209 | |||
210 | /* | ||
211 | * bits 0-3: Early termination count. | ||
212 | * bits 4-5: Early termination condition. | ||
213 | */ | ||
214 | u8 early_termination; | ||
215 | |||
216 | u8 tx_power_att; | ||
217 | u8 channel; | ||
218 | u8 pad[3]; | ||
219 | } __packed; | ||
220 | |||
221 | /* SCAN parameters */ | ||
222 | #define SCAN_MAX_NUM_OF_CHANNELS 16 | ||
223 | |||
224 | struct wl1251_cmd_scan { | ||
225 | struct wl1251_cmd_header header; | ||
226 | |||
227 | struct wl1251_scan_parameters params; | ||
228 | struct wl1251_scan_ch_parameters channels[SCAN_MAX_NUM_OF_CHANNELS]; | ||
229 | } __packed; | ||
230 | |||
231 | enum { | ||
232 | BSS_TYPE_IBSS = 0, | ||
233 | BSS_TYPE_STA_BSS = 2, | ||
234 | BSS_TYPE_AP_BSS = 3, | ||
235 | MAX_BSS_TYPE = 0xFF | ||
236 | }; | ||
237 | |||
238 | #define JOIN_CMD_CTRL_TX_FLUSH 0x80 /* Firmware flushes all Tx */ | ||
239 | #define JOIN_CMD_CTRL_EARLY_WAKEUP_ENABLE 0x01 /* Early wakeup time */ | ||
240 | |||
241 | |||
242 | struct cmd_join { | ||
243 | struct wl1251_cmd_header header; | ||
244 | |||
245 | u32 bssid_lsb; | ||
246 | u16 bssid_msb; | ||
247 | u16 beacon_interval; /* in TBTTs */ | ||
248 | u32 rx_config_options; | ||
249 | u32 rx_filter_options; | ||
250 | |||
251 | /* | ||
252 | * The target uses this field to determine the rate at | ||
253 | * which to transmit control frame responses (such as | ||
254 | * ACK or CTS frames). | ||
255 | */ | ||
256 | u16 basic_rate_set; | ||
257 | u8 dtim_interval; | ||
258 | u8 tx_ctrl_frame_rate; /* OBSOLETE */ | ||
259 | u8 tx_ctrl_frame_mod; /* OBSOLETE */ | ||
260 | /* | ||
261 | * bits 0-2: This bitwise field specifies the type | ||
262 | * of BSS to start or join (BSS_TYPE_*). | ||
263 | * bit 4: Band - The radio band in which to join | ||
264 | * or start. | ||
265 | * 0 - 2.4GHz band | ||
266 | * 1 - 5GHz band | ||
267 | * bits 3, 5-7: Reserved | ||
268 | */ | ||
269 | u8 bss_type; | ||
270 | u8 channel; | ||
271 | u8 ssid_len; | ||
272 | u8 ssid[IW_ESSID_MAX_SIZE]; | ||
273 | u8 ctrl; /* JOIN_CMD_CTRL_* */ | ||
274 | u8 tx_mgt_frame_rate; /* OBSOLETE */ | ||
275 | u8 tx_mgt_frame_mod; /* OBSOLETE */ | ||
276 | u8 reserved; | ||
277 | } __packed; | ||
278 | |||
279 | struct cmd_enabledisable_path { | ||
280 | struct wl1251_cmd_header header; | ||
281 | |||
282 | u8 channel; | ||
283 | u8 padding[3]; | ||
284 | } __packed; | ||
285 | |||
286 | #define WL1251_MAX_TEMPLATE_SIZE 300 | ||
287 | |||
288 | struct wl1251_cmd_packet_template { | ||
289 | struct wl1251_cmd_header header; | ||
290 | |||
291 | __le16 size; | ||
292 | u8 data[0]; | ||
293 | } __packed; | ||
294 | |||
295 | #define TIM_ELE_ID 5 | ||
296 | #define PARTIAL_VBM_MAX 251 | ||
297 | |||
298 | struct wl1251_tim { | ||
299 | u8 identity; | ||
300 | u8 length; | ||
301 | u8 dtim_count; | ||
302 | u8 dtim_period; | ||
303 | u8 bitmap_ctrl; | ||
304 | u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */ | ||
305 | } __packed; | ||
306 | |||
307 | /* Virtual Bit Map update */ | ||
308 | struct wl1251_cmd_vbm_update { | ||
309 | struct wl1251_cmd_header header; | ||
310 | __le16 len; | ||
311 | u8 padding[2]; | ||
312 | struct wl1251_tim tim; | ||
313 | } __packed; | ||
314 | |||
315 | enum wl1251_cmd_ps_mode { | ||
316 | STATION_ACTIVE_MODE, | ||
317 | STATION_POWER_SAVE_MODE | ||
318 | }; | ||
319 | |||
320 | struct wl1251_cmd_ps_params { | ||
321 | struct wl1251_cmd_header header; | ||
322 | |||
323 | u8 ps_mode; /* STATION_* */ | ||
324 | u8 send_null_data; /* Do we have to send NULL data packet ? */ | ||
325 | u8 retries; /* Number of retires for the initial NULL data packet */ | ||
326 | |||
327 | /* | ||
328 | * TUs during which the target stays awake after switching | ||
329 | * to power save mode. | ||
330 | */ | ||
331 | u8 hang_over_period; | ||
332 | u16 null_data_rate; | ||
333 | u8 pad[2]; | ||
334 | } __packed; | ||
335 | |||
336 | struct wl1251_cmd_trigger_scan_to { | ||
337 | struct wl1251_cmd_header header; | ||
338 | |||
339 | u32 timeout; | ||
340 | } __packed; | ||
341 | |||
342 | /* HW encryption keys */ | ||
343 | #define NUM_ACCESS_CATEGORIES_COPY 4 | ||
344 | #define MAX_KEY_SIZE 32 | ||
345 | |||
346 | /* When set, disable HW encryption */ | ||
347 | #define DF_ENCRYPTION_DISABLE 0x01 | ||
348 | /* When set, disable HW decryption */ | ||
349 | #define DF_SNIFF_MODE_ENABLE 0x80 | ||
350 | |||
351 | enum wl1251_cmd_key_action { | ||
352 | KEY_ADD_OR_REPLACE = 1, | ||
353 | KEY_REMOVE = 2, | ||
354 | KEY_SET_ID = 3, | ||
355 | MAX_KEY_ACTION = 0xffff, | ||
356 | }; | ||
357 | |||
358 | enum wl1251_cmd_key_type { | ||
359 | KEY_WEP_DEFAULT = 0, | ||
360 | KEY_WEP_ADDR = 1, | ||
361 | KEY_AES_GROUP = 4, | ||
362 | KEY_AES_PAIRWISE = 5, | ||
363 | KEY_WEP_GROUP = 6, | ||
364 | KEY_TKIP_MIC_GROUP = 10, | ||
365 | KEY_TKIP_MIC_PAIRWISE = 11, | ||
366 | }; | ||
367 | |||
368 | /* | ||
369 | * | ||
370 | * key_type_e key size key format | ||
371 | * ---------- --------- ---------- | ||
372 | * 0x00 5, 13, 29 Key data | ||
373 | * 0x01 5, 13, 29 Key data | ||
374 | * 0x04 16 16 bytes of key data | ||
375 | * 0x05 16 16 bytes of key data | ||
376 | * 0x0a 32 16 bytes of TKIP key data | ||
377 | * 8 bytes of RX MIC key data | ||
378 | * 8 bytes of TX MIC key data | ||
379 | * 0x0b 32 16 bytes of TKIP key data | ||
380 | * 8 bytes of RX MIC key data | ||
381 | * 8 bytes of TX MIC key data | ||
382 | * | ||
383 | */ | ||
384 | |||
385 | struct wl1251_cmd_set_keys { | ||
386 | struct wl1251_cmd_header header; | ||
387 | |||
388 | /* Ignored for default WEP key */ | ||
389 | u8 addr[ETH_ALEN]; | ||
390 | |||
391 | /* key_action_e */ | ||
392 | u16 key_action; | ||
393 | |||
394 | u16 reserved_1; | ||
395 | |||
396 | /* key size in bytes */ | ||
397 | u8 key_size; | ||
398 | |||
399 | /* key_type_e */ | ||
400 | u8 key_type; | ||
401 | u8 ssid_profile; | ||
402 | |||
403 | /* | ||
404 | * TKIP, AES: frame's key id field. | ||
405 | * For WEP default key: key id; | ||
406 | */ | ||
407 | u8 id; | ||
408 | u8 reserved_2[6]; | ||
409 | u8 key[MAX_KEY_SIZE]; | ||
410 | u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY]; | ||
411 | u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY]; | ||
412 | } __packed; | ||
413 | |||
414 | |||
415 | #endif /* __WL1251_CMD_H__ */ | ||
diff --git a/drivers/net/wireless/wl1251/debugfs.c b/drivers/net/wireless/wl1251/debugfs.c new file mode 100644 index 000000000000..6e5caaa9f613 --- /dev/null +++ b/drivers/net/wireless/wl1251/debugfs.c | |||
@@ -0,0 +1,541 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2009 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include "debugfs.h" | ||
23 | |||
24 | #include <linux/skbuff.h> | ||
25 | #include <linux/slab.h> | ||
26 | |||
27 | #include "wl1251.h" | ||
28 | #include "acx.h" | ||
29 | #include "ps.h" | ||
30 | |||
31 | /* ms */ | ||
32 | #define WL1251_DEBUGFS_STATS_LIFETIME 1000 | ||
33 | |||
34 | /* debugfs macros idea from mac80211 */ | ||
35 | |||
36 | #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...) \ | ||
37 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ | ||
38 | size_t count, loff_t *ppos) \ | ||
39 | { \ | ||
40 | struct wl1251 *wl = file->private_data; \ | ||
41 | char buf[buflen]; \ | ||
42 | int res; \ | ||
43 | \ | ||
44 | res = scnprintf(buf, buflen, fmt "\n", ##value); \ | ||
45 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ | ||
46 | } \ | ||
47 | \ | ||
48 | static const struct file_operations name## _ops = { \ | ||
49 | .read = name## _read, \ | ||
50 | .open = wl1251_open_file_generic, \ | ||
51 | }; | ||
52 | |||
53 | #define DEBUGFS_ADD(name, parent) \ | ||
54 | wl->debugfs.name = debugfs_create_file(#name, 0400, parent, \ | ||
55 | wl, &name## _ops); \ | ||
56 | if (IS_ERR(wl->debugfs.name)) { \ | ||
57 | ret = PTR_ERR(wl->debugfs.name); \ | ||
58 | wl->debugfs.name = NULL; \ | ||
59 | goto out; \ | ||
60 | } | ||
61 | |||
62 | #define DEBUGFS_DEL(name) \ | ||
63 | do { \ | ||
64 | debugfs_remove(wl->debugfs.name); \ | ||
65 | wl->debugfs.name = NULL; \ | ||
66 | } while (0) | ||
67 | |||
68 | #define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt) \ | ||
69 | static ssize_t sub## _ ##name## _read(struct file *file, \ | ||
70 | char __user *userbuf, \ | ||
71 | size_t count, loff_t *ppos) \ | ||
72 | { \ | ||
73 | struct wl1251 *wl = file->private_data; \ | ||
74 | char buf[buflen]; \ | ||
75 | int res; \ | ||
76 | \ | ||
77 | wl1251_debugfs_update_stats(wl); \ | ||
78 | \ | ||
79 | res = scnprintf(buf, buflen, fmt "\n", \ | ||
80 | wl->stats.fw_stats->sub.name); \ | ||
81 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ | ||
82 | } \ | ||
83 | \ | ||
84 | static const struct file_operations sub## _ ##name## _ops = { \ | ||
85 | .read = sub## _ ##name## _read, \ | ||
86 | .open = wl1251_open_file_generic, \ | ||
87 | }; | ||
88 | |||
89 | #define DEBUGFS_FWSTATS_ADD(sub, name) \ | ||
90 | DEBUGFS_ADD(sub## _ ##name, wl->debugfs.fw_statistics) | ||
91 | |||
92 | #define DEBUGFS_FWSTATS_DEL(sub, name) \ | ||
93 | DEBUGFS_DEL(sub## _ ##name) | ||
94 | |||
95 | static void wl1251_debugfs_update_stats(struct wl1251 *wl) | ||
96 | { | ||
97 | int ret; | ||
98 | |||
99 | mutex_lock(&wl->mutex); | ||
100 | |||
101 | ret = wl1251_ps_elp_wakeup(wl); | ||
102 | if (ret < 0) | ||
103 | goto out; | ||
104 | |||
105 | if (wl->state == WL1251_STATE_ON && | ||
106 | time_after(jiffies, wl->stats.fw_stats_update + | ||
107 | msecs_to_jiffies(WL1251_DEBUGFS_STATS_LIFETIME))) { | ||
108 | wl1251_acx_statistics(wl, wl->stats.fw_stats); | ||
109 | wl->stats.fw_stats_update = jiffies; | ||
110 | } | ||
111 | |||
112 | wl1251_ps_elp_sleep(wl); | ||
113 | |||
114 | out: | ||
115 | mutex_unlock(&wl->mutex); | ||
116 | } | ||
117 | |||
118 | static int wl1251_open_file_generic(struct inode *inode, struct file *file) | ||
119 | { | ||
120 | file->private_data = inode->i_private; | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | DEBUGFS_FWSTATS_FILE(tx, internal_desc_overflow, 20, "%u"); | ||
125 | |||
126 | DEBUGFS_FWSTATS_FILE(rx, out_of_mem, 20, "%u"); | ||
127 | DEBUGFS_FWSTATS_FILE(rx, hdr_overflow, 20, "%u"); | ||
128 | DEBUGFS_FWSTATS_FILE(rx, hw_stuck, 20, "%u"); | ||
129 | DEBUGFS_FWSTATS_FILE(rx, dropped, 20, "%u"); | ||
130 | DEBUGFS_FWSTATS_FILE(rx, fcs_err, 20, "%u"); | ||
131 | DEBUGFS_FWSTATS_FILE(rx, xfr_hint_trig, 20, "%u"); | ||
132 | DEBUGFS_FWSTATS_FILE(rx, path_reset, 20, "%u"); | ||
133 | DEBUGFS_FWSTATS_FILE(rx, reset_counter, 20, "%u"); | ||
134 | |||
135 | DEBUGFS_FWSTATS_FILE(dma, rx_requested, 20, "%u"); | ||
136 | DEBUGFS_FWSTATS_FILE(dma, rx_errors, 20, "%u"); | ||
137 | DEBUGFS_FWSTATS_FILE(dma, tx_requested, 20, "%u"); | ||
138 | DEBUGFS_FWSTATS_FILE(dma, tx_errors, 20, "%u"); | ||
139 | |||
140 | DEBUGFS_FWSTATS_FILE(isr, cmd_cmplt, 20, "%u"); | ||
141 | DEBUGFS_FWSTATS_FILE(isr, fiqs, 20, "%u"); | ||
142 | DEBUGFS_FWSTATS_FILE(isr, rx_headers, 20, "%u"); | ||
143 | DEBUGFS_FWSTATS_FILE(isr, rx_mem_overflow, 20, "%u"); | ||
144 | DEBUGFS_FWSTATS_FILE(isr, rx_rdys, 20, "%u"); | ||
145 | DEBUGFS_FWSTATS_FILE(isr, irqs, 20, "%u"); | ||
146 | DEBUGFS_FWSTATS_FILE(isr, tx_procs, 20, "%u"); | ||
147 | DEBUGFS_FWSTATS_FILE(isr, decrypt_done, 20, "%u"); | ||
148 | DEBUGFS_FWSTATS_FILE(isr, dma0_done, 20, "%u"); | ||
149 | DEBUGFS_FWSTATS_FILE(isr, dma1_done, 20, "%u"); | ||
150 | DEBUGFS_FWSTATS_FILE(isr, tx_exch_complete, 20, "%u"); | ||
151 | DEBUGFS_FWSTATS_FILE(isr, commands, 20, "%u"); | ||
152 | DEBUGFS_FWSTATS_FILE(isr, rx_procs, 20, "%u"); | ||
153 | DEBUGFS_FWSTATS_FILE(isr, hw_pm_mode_changes, 20, "%u"); | ||
154 | DEBUGFS_FWSTATS_FILE(isr, host_acknowledges, 20, "%u"); | ||
155 | DEBUGFS_FWSTATS_FILE(isr, pci_pm, 20, "%u"); | ||
156 | DEBUGFS_FWSTATS_FILE(isr, wakeups, 20, "%u"); | ||
157 | DEBUGFS_FWSTATS_FILE(isr, low_rssi, 20, "%u"); | ||
158 | |||
159 | DEBUGFS_FWSTATS_FILE(wep, addr_key_count, 20, "%u"); | ||
160 | DEBUGFS_FWSTATS_FILE(wep, default_key_count, 20, "%u"); | ||
161 | /* skipping wep.reserved */ | ||
162 | DEBUGFS_FWSTATS_FILE(wep, key_not_found, 20, "%u"); | ||
163 | DEBUGFS_FWSTATS_FILE(wep, decrypt_fail, 20, "%u"); | ||
164 | DEBUGFS_FWSTATS_FILE(wep, packets, 20, "%u"); | ||
165 | DEBUGFS_FWSTATS_FILE(wep, interrupt, 20, "%u"); | ||
166 | |||
167 | DEBUGFS_FWSTATS_FILE(pwr, ps_enter, 20, "%u"); | ||
168 | DEBUGFS_FWSTATS_FILE(pwr, elp_enter, 20, "%u"); | ||
169 | DEBUGFS_FWSTATS_FILE(pwr, missing_bcns, 20, "%u"); | ||
170 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_host, 20, "%u"); | ||
171 | DEBUGFS_FWSTATS_FILE(pwr, wake_on_timer_exp, 20, "%u"); | ||
172 | DEBUGFS_FWSTATS_FILE(pwr, tx_with_ps, 20, "%u"); | ||
173 | DEBUGFS_FWSTATS_FILE(pwr, tx_without_ps, 20, "%u"); | ||
174 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_beacons, 20, "%u"); | ||
175 | DEBUGFS_FWSTATS_FILE(pwr, power_save_off, 20, "%u"); | ||
176 | DEBUGFS_FWSTATS_FILE(pwr, enable_ps, 20, "%u"); | ||
177 | DEBUGFS_FWSTATS_FILE(pwr, disable_ps, 20, "%u"); | ||
178 | DEBUGFS_FWSTATS_FILE(pwr, fix_tsf_ps, 20, "%u"); | ||
179 | /* skipping cont_miss_bcns_spread for now */ | ||
180 | DEBUGFS_FWSTATS_FILE(pwr, rcvd_awake_beacons, 20, "%u"); | ||
181 | |||
182 | DEBUGFS_FWSTATS_FILE(mic, rx_pkts, 20, "%u"); | ||
183 | DEBUGFS_FWSTATS_FILE(mic, calc_failure, 20, "%u"); | ||
184 | |||
185 | DEBUGFS_FWSTATS_FILE(aes, encrypt_fail, 20, "%u"); | ||
186 | DEBUGFS_FWSTATS_FILE(aes, decrypt_fail, 20, "%u"); | ||
187 | DEBUGFS_FWSTATS_FILE(aes, encrypt_packets, 20, "%u"); | ||
188 | DEBUGFS_FWSTATS_FILE(aes, decrypt_packets, 20, "%u"); | ||
189 | DEBUGFS_FWSTATS_FILE(aes, encrypt_interrupt, 20, "%u"); | ||
190 | DEBUGFS_FWSTATS_FILE(aes, decrypt_interrupt, 20, "%u"); | ||
191 | |||
192 | DEBUGFS_FWSTATS_FILE(event, heart_beat, 20, "%u"); | ||
193 | DEBUGFS_FWSTATS_FILE(event, calibration, 20, "%u"); | ||
194 | DEBUGFS_FWSTATS_FILE(event, rx_mismatch, 20, "%u"); | ||
195 | DEBUGFS_FWSTATS_FILE(event, rx_mem_empty, 20, "%u"); | ||
196 | DEBUGFS_FWSTATS_FILE(event, rx_pool, 20, "%u"); | ||
197 | DEBUGFS_FWSTATS_FILE(event, oom_late, 20, "%u"); | ||
198 | DEBUGFS_FWSTATS_FILE(event, phy_transmit_error, 20, "%u"); | ||
199 | DEBUGFS_FWSTATS_FILE(event, tx_stuck, 20, "%u"); | ||
200 | |||
201 | DEBUGFS_FWSTATS_FILE(ps, pspoll_timeouts, 20, "%u"); | ||
202 | DEBUGFS_FWSTATS_FILE(ps, upsd_timeouts, 20, "%u"); | ||
203 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_sptime, 20, "%u"); | ||
204 | DEBUGFS_FWSTATS_FILE(ps, upsd_max_apturn, 20, "%u"); | ||
205 | DEBUGFS_FWSTATS_FILE(ps, pspoll_max_apturn, 20, "%u"); | ||
206 | DEBUGFS_FWSTATS_FILE(ps, pspoll_utilization, 20, "%u"); | ||
207 | DEBUGFS_FWSTATS_FILE(ps, upsd_utilization, 20, "%u"); | ||
208 | |||
209 | DEBUGFS_FWSTATS_FILE(rxpipe, rx_prep_beacon_drop, 20, "%u"); | ||
210 | DEBUGFS_FWSTATS_FILE(rxpipe, descr_host_int_trig_rx_data, 20, "%u"); | ||
211 | DEBUGFS_FWSTATS_FILE(rxpipe, beacon_buffer_thres_host_int_trig_rx_data, | ||
212 | 20, "%u"); | ||
213 | DEBUGFS_FWSTATS_FILE(rxpipe, missed_beacon_host_int_trig_rx_data, 20, "%u"); | ||
214 | DEBUGFS_FWSTATS_FILE(rxpipe, tx_xfr_host_int_trig_rx_data, 20, "%u"); | ||
215 | |||
216 | DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count); | ||
217 | DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u", | ||
218 | wl->stats.excessive_retries); | ||
219 | |||
220 | static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, | ||
221 | size_t count, loff_t *ppos) | ||
222 | { | ||
223 | struct wl1251 *wl = file->private_data; | ||
224 | u32 queue_len; | ||
225 | char buf[20]; | ||
226 | int res; | ||
227 | |||
228 | queue_len = skb_queue_len(&wl->tx_queue); | ||
229 | |||
230 | res = scnprintf(buf, sizeof(buf), "%u\n", queue_len); | ||
231 | return simple_read_from_buffer(userbuf, count, ppos, buf, res); | ||
232 | } | ||
233 | |||
234 | static const struct file_operations tx_queue_len_ops = { | ||
235 | .read = tx_queue_len_read, | ||
236 | .open = wl1251_open_file_generic, | ||
237 | }; | ||
238 | |||
239 | static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf, | ||
240 | size_t count, loff_t *ppos) | ||
241 | { | ||
242 | struct wl1251 *wl = file->private_data; | ||
243 | char buf[3], status; | ||
244 | int len; | ||
245 | |||
246 | if (wl->tx_queue_stopped) | ||
247 | status = 's'; | ||
248 | else | ||
249 | status = 'r'; | ||
250 | |||
251 | len = scnprintf(buf, sizeof(buf), "%c\n", status); | ||
252 | return simple_read_from_buffer(userbuf, count, ppos, buf, len); | ||
253 | } | ||
254 | |||
255 | static const struct file_operations tx_queue_status_ops = { | ||
256 | .read = tx_queue_status_read, | ||
257 | .open = wl1251_open_file_generic, | ||
258 | }; | ||
259 | |||
260 | static void wl1251_debugfs_delete_files(struct wl1251 *wl) | ||
261 | { | ||
262 | DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow); | ||
263 | |||
264 | DEBUGFS_FWSTATS_DEL(rx, out_of_mem); | ||
265 | DEBUGFS_FWSTATS_DEL(rx, hdr_overflow); | ||
266 | DEBUGFS_FWSTATS_DEL(rx, hw_stuck); | ||
267 | DEBUGFS_FWSTATS_DEL(rx, dropped); | ||
268 | DEBUGFS_FWSTATS_DEL(rx, fcs_err); | ||
269 | DEBUGFS_FWSTATS_DEL(rx, xfr_hint_trig); | ||
270 | DEBUGFS_FWSTATS_DEL(rx, path_reset); | ||
271 | DEBUGFS_FWSTATS_DEL(rx, reset_counter); | ||
272 | |||
273 | DEBUGFS_FWSTATS_DEL(dma, rx_requested); | ||
274 | DEBUGFS_FWSTATS_DEL(dma, rx_errors); | ||
275 | DEBUGFS_FWSTATS_DEL(dma, tx_requested); | ||
276 | DEBUGFS_FWSTATS_DEL(dma, tx_errors); | ||
277 | |||
278 | DEBUGFS_FWSTATS_DEL(isr, cmd_cmplt); | ||
279 | DEBUGFS_FWSTATS_DEL(isr, fiqs); | ||
280 | DEBUGFS_FWSTATS_DEL(isr, rx_headers); | ||
281 | DEBUGFS_FWSTATS_DEL(isr, rx_mem_overflow); | ||
282 | DEBUGFS_FWSTATS_DEL(isr, rx_rdys); | ||
283 | DEBUGFS_FWSTATS_DEL(isr, irqs); | ||
284 | DEBUGFS_FWSTATS_DEL(isr, tx_procs); | ||
285 | DEBUGFS_FWSTATS_DEL(isr, decrypt_done); | ||
286 | DEBUGFS_FWSTATS_DEL(isr, dma0_done); | ||
287 | DEBUGFS_FWSTATS_DEL(isr, dma1_done); | ||
288 | DEBUGFS_FWSTATS_DEL(isr, tx_exch_complete); | ||
289 | DEBUGFS_FWSTATS_DEL(isr, commands); | ||
290 | DEBUGFS_FWSTATS_DEL(isr, rx_procs); | ||
291 | DEBUGFS_FWSTATS_DEL(isr, hw_pm_mode_changes); | ||
292 | DEBUGFS_FWSTATS_DEL(isr, host_acknowledges); | ||
293 | DEBUGFS_FWSTATS_DEL(isr, pci_pm); | ||
294 | DEBUGFS_FWSTATS_DEL(isr, wakeups); | ||
295 | DEBUGFS_FWSTATS_DEL(isr, low_rssi); | ||
296 | |||
297 | DEBUGFS_FWSTATS_DEL(wep, addr_key_count); | ||
298 | DEBUGFS_FWSTATS_DEL(wep, default_key_count); | ||
299 | /* skipping wep.reserved */ | ||
300 | DEBUGFS_FWSTATS_DEL(wep, key_not_found); | ||
301 | DEBUGFS_FWSTATS_DEL(wep, decrypt_fail); | ||
302 | DEBUGFS_FWSTATS_DEL(wep, packets); | ||
303 | DEBUGFS_FWSTATS_DEL(wep, interrupt); | ||
304 | |||
305 | DEBUGFS_FWSTATS_DEL(pwr, ps_enter); | ||
306 | DEBUGFS_FWSTATS_DEL(pwr, elp_enter); | ||
307 | DEBUGFS_FWSTATS_DEL(pwr, missing_bcns); | ||
308 | DEBUGFS_FWSTATS_DEL(pwr, wake_on_host); | ||
309 | DEBUGFS_FWSTATS_DEL(pwr, wake_on_timer_exp); | ||
310 | DEBUGFS_FWSTATS_DEL(pwr, tx_with_ps); | ||
311 | DEBUGFS_FWSTATS_DEL(pwr, tx_without_ps); | ||
312 | DEBUGFS_FWSTATS_DEL(pwr, rcvd_beacons); | ||
313 | DEBUGFS_FWSTATS_DEL(pwr, power_save_off); | ||
314 | DEBUGFS_FWSTATS_DEL(pwr, enable_ps); | ||
315 | DEBUGFS_FWSTATS_DEL(pwr, disable_ps); | ||
316 | DEBUGFS_FWSTATS_DEL(pwr, fix_tsf_ps); | ||
317 | /* skipping cont_miss_bcns_spread for now */ | ||
318 | DEBUGFS_FWSTATS_DEL(pwr, rcvd_awake_beacons); | ||
319 | |||
320 | DEBUGFS_FWSTATS_DEL(mic, rx_pkts); | ||
321 | DEBUGFS_FWSTATS_DEL(mic, calc_failure); | ||
322 | |||
323 | DEBUGFS_FWSTATS_DEL(aes, encrypt_fail); | ||
324 | DEBUGFS_FWSTATS_DEL(aes, decrypt_fail); | ||
325 | DEBUGFS_FWSTATS_DEL(aes, encrypt_packets); | ||
326 | DEBUGFS_FWSTATS_DEL(aes, decrypt_packets); | ||
327 | DEBUGFS_FWSTATS_DEL(aes, encrypt_interrupt); | ||
328 | DEBUGFS_FWSTATS_DEL(aes, decrypt_interrupt); | ||
329 | |||
330 | DEBUGFS_FWSTATS_DEL(event, heart_beat); | ||
331 | DEBUGFS_FWSTATS_DEL(event, calibration); | ||
332 | DEBUGFS_FWSTATS_DEL(event, rx_mismatch); | ||
333 | DEBUGFS_FWSTATS_DEL(event, rx_mem_empty); | ||
334 | DEBUGFS_FWSTATS_DEL(event, rx_pool); | ||
335 | DEBUGFS_FWSTATS_DEL(event, oom_late); | ||
336 | DEBUGFS_FWSTATS_DEL(event, phy_transmit_error); | ||
337 | DEBUGFS_FWSTATS_DEL(event, tx_stuck); | ||
338 | |||
339 | DEBUGFS_FWSTATS_DEL(ps, pspoll_timeouts); | ||
340 | DEBUGFS_FWSTATS_DEL(ps, upsd_timeouts); | ||
341 | DEBUGFS_FWSTATS_DEL(ps, upsd_max_sptime); | ||
342 | DEBUGFS_FWSTATS_DEL(ps, upsd_max_apturn); | ||
343 | DEBUGFS_FWSTATS_DEL(ps, pspoll_max_apturn); | ||
344 | DEBUGFS_FWSTATS_DEL(ps, pspoll_utilization); | ||
345 | DEBUGFS_FWSTATS_DEL(ps, upsd_utilization); | ||
346 | |||
347 | DEBUGFS_FWSTATS_DEL(rxpipe, rx_prep_beacon_drop); | ||
348 | DEBUGFS_FWSTATS_DEL(rxpipe, descr_host_int_trig_rx_data); | ||
349 | DEBUGFS_FWSTATS_DEL(rxpipe, beacon_buffer_thres_host_int_trig_rx_data); | ||
350 | DEBUGFS_FWSTATS_DEL(rxpipe, missed_beacon_host_int_trig_rx_data); | ||
351 | DEBUGFS_FWSTATS_DEL(rxpipe, tx_xfr_host_int_trig_rx_data); | ||
352 | |||
353 | DEBUGFS_DEL(tx_queue_len); | ||
354 | DEBUGFS_DEL(tx_queue_status); | ||
355 | DEBUGFS_DEL(retry_count); | ||
356 | DEBUGFS_DEL(excessive_retries); | ||
357 | } | ||
358 | |||
359 | static int wl1251_debugfs_add_files(struct wl1251 *wl) | ||
360 | { | ||
361 | int ret = 0; | ||
362 | |||
363 | DEBUGFS_FWSTATS_ADD(tx, internal_desc_overflow); | ||
364 | |||
365 | DEBUGFS_FWSTATS_ADD(rx, out_of_mem); | ||
366 | DEBUGFS_FWSTATS_ADD(rx, hdr_overflow); | ||
367 | DEBUGFS_FWSTATS_ADD(rx, hw_stuck); | ||
368 | DEBUGFS_FWSTATS_ADD(rx, dropped); | ||
369 | DEBUGFS_FWSTATS_ADD(rx, fcs_err); | ||
370 | DEBUGFS_FWSTATS_ADD(rx, xfr_hint_trig); | ||
371 | DEBUGFS_FWSTATS_ADD(rx, path_reset); | ||
372 | DEBUGFS_FWSTATS_ADD(rx, reset_counter); | ||
373 | |||
374 | DEBUGFS_FWSTATS_ADD(dma, rx_requested); | ||
375 | DEBUGFS_FWSTATS_ADD(dma, rx_errors); | ||
376 | DEBUGFS_FWSTATS_ADD(dma, tx_requested); | ||
377 | DEBUGFS_FWSTATS_ADD(dma, tx_errors); | ||
378 | |||
379 | DEBUGFS_FWSTATS_ADD(isr, cmd_cmplt); | ||
380 | DEBUGFS_FWSTATS_ADD(isr, fiqs); | ||
381 | DEBUGFS_FWSTATS_ADD(isr, rx_headers); | ||
382 | DEBUGFS_FWSTATS_ADD(isr, rx_mem_overflow); | ||
383 | DEBUGFS_FWSTATS_ADD(isr, rx_rdys); | ||
384 | DEBUGFS_FWSTATS_ADD(isr, irqs); | ||
385 | DEBUGFS_FWSTATS_ADD(isr, tx_procs); | ||
386 | DEBUGFS_FWSTATS_ADD(isr, decrypt_done); | ||
387 | DEBUGFS_FWSTATS_ADD(isr, dma0_done); | ||
388 | DEBUGFS_FWSTATS_ADD(isr, dma1_done); | ||
389 | DEBUGFS_FWSTATS_ADD(isr, tx_exch_complete); | ||
390 | DEBUGFS_FWSTATS_ADD(isr, commands); | ||
391 | DEBUGFS_FWSTATS_ADD(isr, rx_procs); | ||
392 | DEBUGFS_FWSTATS_ADD(isr, hw_pm_mode_changes); | ||
393 | DEBUGFS_FWSTATS_ADD(isr, host_acknowledges); | ||
394 | DEBUGFS_FWSTATS_ADD(isr, pci_pm); | ||
395 | DEBUGFS_FWSTATS_ADD(isr, wakeups); | ||
396 | DEBUGFS_FWSTATS_ADD(isr, low_rssi); | ||
397 | |||
398 | DEBUGFS_FWSTATS_ADD(wep, addr_key_count); | ||
399 | DEBUGFS_FWSTATS_ADD(wep, default_key_count); | ||
400 | /* skipping wep.reserved */ | ||
401 | DEBUGFS_FWSTATS_ADD(wep, key_not_found); | ||
402 | DEBUGFS_FWSTATS_ADD(wep, decrypt_fail); | ||
403 | DEBUGFS_FWSTATS_ADD(wep, packets); | ||
404 | DEBUGFS_FWSTATS_ADD(wep, interrupt); | ||
405 | |||
406 | DEBUGFS_FWSTATS_ADD(pwr, ps_enter); | ||
407 | DEBUGFS_FWSTATS_ADD(pwr, elp_enter); | ||
408 | DEBUGFS_FWSTATS_ADD(pwr, missing_bcns); | ||
409 | DEBUGFS_FWSTATS_ADD(pwr, wake_on_host); | ||
410 | DEBUGFS_FWSTATS_ADD(pwr, wake_on_timer_exp); | ||
411 | DEBUGFS_FWSTATS_ADD(pwr, tx_with_ps); | ||
412 | DEBUGFS_FWSTATS_ADD(pwr, tx_without_ps); | ||
413 | DEBUGFS_FWSTATS_ADD(pwr, rcvd_beacons); | ||
414 | DEBUGFS_FWSTATS_ADD(pwr, power_save_off); | ||
415 | DEBUGFS_FWSTATS_ADD(pwr, enable_ps); | ||
416 | DEBUGFS_FWSTATS_ADD(pwr, disable_ps); | ||
417 | DEBUGFS_FWSTATS_ADD(pwr, fix_tsf_ps); | ||
418 | /* skipping cont_miss_bcns_spread for now */ | ||
419 | DEBUGFS_FWSTATS_ADD(pwr, rcvd_awake_beacons); | ||
420 | |||
421 | DEBUGFS_FWSTATS_ADD(mic, rx_pkts); | ||
422 | DEBUGFS_FWSTATS_ADD(mic, calc_failure); | ||
423 | |||
424 | DEBUGFS_FWSTATS_ADD(aes, encrypt_fail); | ||
425 | DEBUGFS_FWSTATS_ADD(aes, decrypt_fail); | ||
426 | DEBUGFS_FWSTATS_ADD(aes, encrypt_packets); | ||
427 | DEBUGFS_FWSTATS_ADD(aes, decrypt_packets); | ||
428 | DEBUGFS_FWSTATS_ADD(aes, encrypt_interrupt); | ||
429 | DEBUGFS_FWSTATS_ADD(aes, decrypt_interrupt); | ||
430 | |||
431 | DEBUGFS_FWSTATS_ADD(event, heart_beat); | ||
432 | DEBUGFS_FWSTATS_ADD(event, calibration); | ||
433 | DEBUGFS_FWSTATS_ADD(event, rx_mismatch); | ||
434 | DEBUGFS_FWSTATS_ADD(event, rx_mem_empty); | ||
435 | DEBUGFS_FWSTATS_ADD(event, rx_pool); | ||
436 | DEBUGFS_FWSTATS_ADD(event, oom_late); | ||
437 | DEBUGFS_FWSTATS_ADD(event, phy_transmit_error); | ||
438 | DEBUGFS_FWSTATS_ADD(event, tx_stuck); | ||
439 | |||
440 | DEBUGFS_FWSTATS_ADD(ps, pspoll_timeouts); | ||
441 | DEBUGFS_FWSTATS_ADD(ps, upsd_timeouts); | ||
442 | DEBUGFS_FWSTATS_ADD(ps, upsd_max_sptime); | ||
443 | DEBUGFS_FWSTATS_ADD(ps, upsd_max_apturn); | ||
444 | DEBUGFS_FWSTATS_ADD(ps, pspoll_max_apturn); | ||
445 | DEBUGFS_FWSTATS_ADD(ps, pspoll_utilization); | ||
446 | DEBUGFS_FWSTATS_ADD(ps, upsd_utilization); | ||
447 | |||
448 | DEBUGFS_FWSTATS_ADD(rxpipe, rx_prep_beacon_drop); | ||
449 | DEBUGFS_FWSTATS_ADD(rxpipe, descr_host_int_trig_rx_data); | ||
450 | DEBUGFS_FWSTATS_ADD(rxpipe, beacon_buffer_thres_host_int_trig_rx_data); | ||
451 | DEBUGFS_FWSTATS_ADD(rxpipe, missed_beacon_host_int_trig_rx_data); | ||
452 | DEBUGFS_FWSTATS_ADD(rxpipe, tx_xfr_host_int_trig_rx_data); | ||
453 | |||
454 | DEBUGFS_ADD(tx_queue_len, wl->debugfs.rootdir); | ||
455 | DEBUGFS_ADD(tx_queue_status, wl->debugfs.rootdir); | ||
456 | DEBUGFS_ADD(retry_count, wl->debugfs.rootdir); | ||
457 | DEBUGFS_ADD(excessive_retries, wl->debugfs.rootdir); | ||
458 | |||
459 | out: | ||
460 | if (ret < 0) | ||
461 | wl1251_debugfs_delete_files(wl); | ||
462 | |||
463 | return ret; | ||
464 | } | ||
465 | |||
466 | void wl1251_debugfs_reset(struct wl1251 *wl) | ||
467 | { | ||
468 | if (wl->stats.fw_stats != NULL) | ||
469 | memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); | ||
470 | wl->stats.retry_count = 0; | ||
471 | wl->stats.excessive_retries = 0; | ||
472 | } | ||
473 | |||
474 | int wl1251_debugfs_init(struct wl1251 *wl) | ||
475 | { | ||
476 | int ret; | ||
477 | |||
478 | wl->debugfs.rootdir = debugfs_create_dir(KBUILD_MODNAME, NULL); | ||
479 | |||
480 | if (IS_ERR(wl->debugfs.rootdir)) { | ||
481 | ret = PTR_ERR(wl->debugfs.rootdir); | ||
482 | wl->debugfs.rootdir = NULL; | ||
483 | goto err; | ||
484 | } | ||
485 | |||
486 | wl->debugfs.fw_statistics = debugfs_create_dir("fw-statistics", | ||
487 | wl->debugfs.rootdir); | ||
488 | |||
489 | if (IS_ERR(wl->debugfs.fw_statistics)) { | ||
490 | ret = PTR_ERR(wl->debugfs.fw_statistics); | ||
491 | wl->debugfs.fw_statistics = NULL; | ||
492 | goto err_root; | ||
493 | } | ||
494 | |||
495 | wl->stats.fw_stats = kzalloc(sizeof(*wl->stats.fw_stats), | ||
496 | GFP_KERNEL); | ||
497 | |||
498 | if (!wl->stats.fw_stats) { | ||
499 | ret = -ENOMEM; | ||
500 | goto err_fw; | ||
501 | } | ||
502 | |||
503 | wl->stats.fw_stats_update = jiffies; | ||
504 | |||
505 | ret = wl1251_debugfs_add_files(wl); | ||
506 | |||
507 | if (ret < 0) | ||
508 | goto err_file; | ||
509 | |||
510 | return 0; | ||
511 | |||
512 | err_file: | ||
513 | kfree(wl->stats.fw_stats); | ||
514 | wl->stats.fw_stats = NULL; | ||
515 | |||
516 | err_fw: | ||
517 | debugfs_remove(wl->debugfs.fw_statistics); | ||
518 | wl->debugfs.fw_statistics = NULL; | ||
519 | |||
520 | err_root: | ||
521 | debugfs_remove(wl->debugfs.rootdir); | ||
522 | wl->debugfs.rootdir = NULL; | ||
523 | |||
524 | err: | ||
525 | return ret; | ||
526 | } | ||
527 | |||
528 | void wl1251_debugfs_exit(struct wl1251 *wl) | ||
529 | { | ||
530 | wl1251_debugfs_delete_files(wl); | ||
531 | |||
532 | kfree(wl->stats.fw_stats); | ||
533 | wl->stats.fw_stats = NULL; | ||
534 | |||
535 | debugfs_remove(wl->debugfs.fw_statistics); | ||
536 | wl->debugfs.fw_statistics = NULL; | ||
537 | |||
538 | debugfs_remove(wl->debugfs.rootdir); | ||
539 | wl->debugfs.rootdir = NULL; | ||
540 | |||
541 | } | ||
diff --git a/drivers/net/wireless/wl1251/debugfs.h b/drivers/net/wireless/wl1251/debugfs.h new file mode 100644 index 000000000000..b3417c02a218 --- /dev/null +++ b/drivers/net/wireless/wl1251/debugfs.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2009 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #ifndef WL1251_DEBUGFS_H | ||
23 | #define WL1251_DEBUGFS_H | ||
24 | |||
25 | #include "wl1251.h" | ||
26 | |||
27 | int wl1251_debugfs_init(struct wl1251 *wl); | ||
28 | void wl1251_debugfs_exit(struct wl1251 *wl); | ||
29 | void wl1251_debugfs_reset(struct wl1251 *wl); | ||
30 | |||
31 | #endif /* WL1251_DEBUGFS_H */ | ||
diff --git a/drivers/net/wireless/wl1251/event.c b/drivers/net/wireless/wl1251/event.c new file mode 100644 index 000000000000..712372e50a87 --- /dev/null +++ b/drivers/net/wireless/wl1251/event.c | |||
@@ -0,0 +1,168 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include "wl1251.h" | ||
24 | #include "reg.h" | ||
25 | #include "io.h" | ||
26 | #include "event.h" | ||
27 | #include "ps.h" | ||
28 | |||
29 | static int wl1251_event_scan_complete(struct wl1251 *wl, | ||
30 | struct event_mailbox *mbox) | ||
31 | { | ||
32 | wl1251_debug(DEBUG_EVENT, "status: 0x%x, channels: %d", | ||
33 | mbox->scheduled_scan_status, | ||
34 | mbox->scheduled_scan_channels); | ||
35 | |||
36 | if (wl->scanning) { | ||
37 | ieee80211_scan_completed(wl->hw, false); | ||
38 | wl1251_debug(DEBUG_MAC80211, "mac80211 hw scan completed"); | ||
39 | wl->scanning = false; | ||
40 | } | ||
41 | |||
42 | return 0; | ||
43 | } | ||
44 | |||
45 | static void wl1251_event_mbox_dump(struct event_mailbox *mbox) | ||
46 | { | ||
47 | wl1251_debug(DEBUG_EVENT, "MBOX DUMP:"); | ||
48 | wl1251_debug(DEBUG_EVENT, "\tvector: 0x%x", mbox->events_vector); | ||
49 | wl1251_debug(DEBUG_EVENT, "\tmask: 0x%x", mbox->events_mask); | ||
50 | } | ||
51 | |||
52 | static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox) | ||
53 | { | ||
54 | int ret; | ||
55 | u32 vector; | ||
56 | |||
57 | wl1251_event_mbox_dump(mbox); | ||
58 | |||
59 | vector = mbox->events_vector & ~(mbox->events_mask); | ||
60 | wl1251_debug(DEBUG_EVENT, "vector: 0x%x", vector); | ||
61 | |||
62 | if (vector & SCAN_COMPLETE_EVENT_ID) { | ||
63 | ret = wl1251_event_scan_complete(wl, mbox); | ||
64 | if (ret < 0) | ||
65 | return ret; | ||
66 | } | ||
67 | |||
68 | if (vector & BSS_LOSE_EVENT_ID) { | ||
69 | wl1251_debug(DEBUG_EVENT, "BSS_LOSE_EVENT"); | ||
70 | |||
71 | if (wl->psm_requested && wl->psm) { | ||
72 | ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE); | ||
73 | if (ret < 0) | ||
74 | return ret; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | if (vector & SYNCHRONIZATION_TIMEOUT_EVENT_ID && wl->psm) { | ||
79 | wl1251_debug(DEBUG_EVENT, "SYNCHRONIZATION_TIMEOUT_EVENT"); | ||
80 | |||
81 | /* indicate to the stack, that beacons have been lost */ | ||
82 | ieee80211_beacon_loss(wl->vif); | ||
83 | } | ||
84 | |||
85 | if (vector & REGAINED_BSS_EVENT_ID) { | ||
86 | if (wl->psm_requested) { | ||
87 | ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE); | ||
88 | if (ret < 0) | ||
89 | return ret; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * Poll the mailbox event field until any of the bits in the mask is set or a | ||
98 | * timeout occurs (WL1251_EVENT_TIMEOUT in msecs) | ||
99 | */ | ||
100 | int wl1251_event_wait(struct wl1251 *wl, u32 mask, int timeout_ms) | ||
101 | { | ||
102 | u32 events_vector, event; | ||
103 | unsigned long timeout; | ||
104 | |||
105 | timeout = jiffies + msecs_to_jiffies(timeout_ms); | ||
106 | |||
107 | do { | ||
108 | if (time_after(jiffies, timeout)) | ||
109 | return -ETIMEDOUT; | ||
110 | |||
111 | msleep(1); | ||
112 | |||
113 | /* read from both event fields */ | ||
114 | wl1251_mem_read(wl, wl->mbox_ptr[0], &events_vector, | ||
115 | sizeof(events_vector)); | ||
116 | event = events_vector & mask; | ||
117 | wl1251_mem_read(wl, wl->mbox_ptr[1], &events_vector, | ||
118 | sizeof(events_vector)); | ||
119 | event |= events_vector & mask; | ||
120 | } while (!event); | ||
121 | |||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | int wl1251_event_unmask(struct wl1251 *wl) | ||
126 | { | ||
127 | int ret; | ||
128 | |||
129 | ret = wl1251_acx_event_mbox_mask(wl, ~(wl->event_mask)); | ||
130 | if (ret < 0) | ||
131 | return ret; | ||
132 | |||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | void wl1251_event_mbox_config(struct wl1251 *wl) | ||
137 | { | ||
138 | wl->mbox_ptr[0] = wl1251_reg_read32(wl, REG_EVENT_MAILBOX_PTR); | ||
139 | wl->mbox_ptr[1] = wl->mbox_ptr[0] + sizeof(struct event_mailbox); | ||
140 | |||
141 | wl1251_debug(DEBUG_EVENT, "MBOX ptrs: 0x%x 0x%x", | ||
142 | wl->mbox_ptr[0], wl->mbox_ptr[1]); | ||
143 | } | ||
144 | |||
145 | int wl1251_event_handle(struct wl1251 *wl, u8 mbox_num) | ||
146 | { | ||
147 | struct event_mailbox mbox; | ||
148 | int ret; | ||
149 | |||
150 | wl1251_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num); | ||
151 | |||
152 | if (mbox_num > 1) | ||
153 | return -EINVAL; | ||
154 | |||
155 | /* first we read the mbox descriptor */ | ||
156 | wl1251_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox, | ||
157 | sizeof(struct event_mailbox)); | ||
158 | |||
159 | /* process the descriptor */ | ||
160 | ret = wl1251_event_process(wl, &mbox); | ||
161 | if (ret < 0) | ||
162 | return ret; | ||
163 | |||
164 | /* then we let the firmware know it can go on...*/ | ||
165 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_EVENT_ACK); | ||
166 | |||
167 | return 0; | ||
168 | } | ||
diff --git a/drivers/net/wireless/wl1251/event.h b/drivers/net/wireless/wl1251/event.h new file mode 100644 index 000000000000..30eb5d150bf7 --- /dev/null +++ b/drivers/net/wireless/wl1251/event.h | |||
@@ -0,0 +1,120 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __WL1251_EVENT_H__ | ||
24 | #define __WL1251_EVENT_H__ | ||
25 | |||
26 | /* | ||
27 | * Mbox events | ||
28 | * | ||
29 | * The event mechanism is based on a pair of event buffers (buffers A and | ||
30 | * B) at fixed locations in the target's memory. The host processes one | ||
31 | * buffer while the other buffer continues to collect events. If the host | ||
32 | * is not processing events, an interrupt is issued to signal that a buffer | ||
33 | * is ready. Once the host is done with processing events from one buffer, | ||
34 | * it signals the target (with an ACK interrupt) that the event buffer is | ||
35 | * free. | ||
36 | */ | ||
37 | |||
38 | enum { | ||
39 | RESERVED1_EVENT_ID = BIT(0), | ||
40 | RESERVED2_EVENT_ID = BIT(1), | ||
41 | MEASUREMENT_START_EVENT_ID = BIT(2), | ||
42 | SCAN_COMPLETE_EVENT_ID = BIT(3), | ||
43 | CALIBRATION_COMPLETE_EVENT_ID = BIT(4), | ||
44 | ROAMING_TRIGGER_LOW_RSSI_EVENT_ID = BIT(5), | ||
45 | PS_REPORT_EVENT_ID = BIT(6), | ||
46 | SYNCHRONIZATION_TIMEOUT_EVENT_ID = BIT(7), | ||
47 | HEALTH_REPORT_EVENT_ID = BIT(8), | ||
48 | ACI_DETECTION_EVENT_ID = BIT(9), | ||
49 | DEBUG_REPORT_EVENT_ID = BIT(10), | ||
50 | MAC_STATUS_EVENT_ID = BIT(11), | ||
51 | DISCONNECT_EVENT_COMPLETE_ID = BIT(12), | ||
52 | JOIN_EVENT_COMPLETE_ID = BIT(13), | ||
53 | CHANNEL_SWITCH_COMPLETE_EVENT_ID = BIT(14), | ||
54 | BSS_LOSE_EVENT_ID = BIT(15), | ||
55 | ROAMING_TRIGGER_MAX_TX_RETRY_EVENT_ID = BIT(16), | ||
56 | MEASUREMENT_COMPLETE_EVENT_ID = BIT(17), | ||
57 | AP_DISCOVERY_COMPLETE_EVENT_ID = BIT(18), | ||
58 | SCHEDULED_SCAN_COMPLETE_EVENT_ID = BIT(19), | ||
59 | PSPOLL_DELIVERY_FAILURE_EVENT_ID = BIT(20), | ||
60 | RESET_BSS_EVENT_ID = BIT(21), | ||
61 | REGAINED_BSS_EVENT_ID = BIT(22), | ||
62 | ROAMING_TRIGGER_REGAINED_RSSI_EVENT_ID = BIT(23), | ||
63 | ROAMING_TRIGGER_LOW_SNR_EVENT_ID = BIT(24), | ||
64 | ROAMING_TRIGGER_REGAINED_SNR_EVENT_ID = BIT(25), | ||
65 | |||
66 | DBG_EVENT_ID = BIT(26), | ||
67 | BT_PTA_SENSE_EVENT_ID = BIT(27), | ||
68 | BT_PTA_PREDICTION_EVENT_ID = BIT(28), | ||
69 | BT_PTA_AVALANCHE_EVENT_ID = BIT(29), | ||
70 | |||
71 | PLT_RX_CALIBRATION_COMPLETE_EVENT_ID = BIT(30), | ||
72 | |||
73 | EVENT_MBOX_ALL_EVENT_ID = 0x7fffffff, | ||
74 | }; | ||
75 | |||
76 | struct event_debug_report { | ||
77 | u8 debug_event_id; | ||
78 | u8 num_params; | ||
79 | u16 pad; | ||
80 | u32 report_1; | ||
81 | u32 report_2; | ||
82 | u32 report_3; | ||
83 | } __packed; | ||
84 | |||
85 | struct event_mailbox { | ||
86 | u32 events_vector; | ||
87 | u32 events_mask; | ||
88 | u32 reserved_1; | ||
89 | u32 reserved_2; | ||
90 | |||
91 | char average_rssi_level; | ||
92 | u8 ps_status; | ||
93 | u8 channel_switch_status; | ||
94 | u8 scheduled_scan_status; | ||
95 | |||
96 | /* Channels scanned by the scheduled scan */ | ||
97 | u16 scheduled_scan_channels; | ||
98 | |||
99 | /* If bit 0 is set -> target's fatal error */ | ||
100 | u16 health_report; | ||
101 | u16 bad_fft_counter; | ||
102 | u8 bt_pta_sense_info; | ||
103 | u8 bt_pta_protective_info; | ||
104 | u32 reserved; | ||
105 | u32 debug_report[2]; | ||
106 | |||
107 | /* Number of FCS errors since last event */ | ||
108 | u32 fcs_err_counter; | ||
109 | |||
110 | struct event_debug_report report; | ||
111 | u8 average_snr_level; | ||
112 | u8 padding[19]; | ||
113 | } __packed; | ||
114 | |||
115 | int wl1251_event_unmask(struct wl1251 *wl); | ||
116 | void wl1251_event_mbox_config(struct wl1251 *wl); | ||
117 | int wl1251_event_handle(struct wl1251 *wl, u8 mbox); | ||
118 | int wl1251_event_wait(struct wl1251 *wl, u32 mask, int timeout_ms); | ||
119 | |||
120 | #endif | ||
diff --git a/drivers/net/wireless/wl1251/init.c b/drivers/net/wireless/wl1251/init.c new file mode 100644 index 000000000000..89b43d35473c --- /dev/null +++ b/drivers/net/wireless/wl1251/init.c | |||
@@ -0,0 +1,423 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2009 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/slab.h> | ||
25 | |||
26 | #include "init.h" | ||
27 | #include "wl12xx_80211.h" | ||
28 | #include "acx.h" | ||
29 | #include "cmd.h" | ||
30 | #include "reg.h" | ||
31 | |||
32 | int wl1251_hw_init_hwenc_config(struct wl1251 *wl) | ||
33 | { | ||
34 | int ret; | ||
35 | |||
36 | ret = wl1251_acx_feature_cfg(wl); | ||
37 | if (ret < 0) { | ||
38 | wl1251_warning("couldn't set feature config"); | ||
39 | return ret; | ||
40 | } | ||
41 | |||
42 | ret = wl1251_acx_default_key(wl, wl->default_key); | ||
43 | if (ret < 0) { | ||
44 | wl1251_warning("couldn't set default key"); | ||
45 | return ret; | ||
46 | } | ||
47 | |||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | int wl1251_hw_init_templates_config(struct wl1251 *wl) | ||
52 | { | ||
53 | int ret; | ||
54 | u8 partial_vbm[PARTIAL_VBM_MAX]; | ||
55 | |||
56 | /* send empty templates for fw memory reservation */ | ||
57 | ret = wl1251_cmd_template_set(wl, CMD_PROBE_REQ, NULL, | ||
58 | sizeof(struct wl12xx_probe_req_template)); | ||
59 | if (ret < 0) | ||
60 | return ret; | ||
61 | |||
62 | ret = wl1251_cmd_template_set(wl, CMD_NULL_DATA, NULL, | ||
63 | sizeof(struct wl12xx_null_data_template)); | ||
64 | if (ret < 0) | ||
65 | return ret; | ||
66 | |||
67 | ret = wl1251_cmd_template_set(wl, CMD_PS_POLL, NULL, | ||
68 | sizeof(struct wl12xx_ps_poll_template)); | ||
69 | if (ret < 0) | ||
70 | return ret; | ||
71 | |||
72 | ret = wl1251_cmd_template_set(wl, CMD_QOS_NULL_DATA, NULL, | ||
73 | sizeof | ||
74 | (struct wl12xx_qos_null_data_template)); | ||
75 | if (ret < 0) | ||
76 | return ret; | ||
77 | |||
78 | ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, NULL, | ||
79 | sizeof | ||
80 | (struct wl12xx_probe_resp_template)); | ||
81 | if (ret < 0) | ||
82 | return ret; | ||
83 | |||
84 | ret = wl1251_cmd_template_set(wl, CMD_BEACON, NULL, | ||
85 | sizeof | ||
86 | (struct wl12xx_beacon_template)); | ||
87 | if (ret < 0) | ||
88 | return ret; | ||
89 | |||
90 | /* tim templates, first reserve space then allocate an empty one */ | ||
91 | memset(partial_vbm, 0, PARTIAL_VBM_MAX); | ||
92 | ret = wl1251_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, PARTIAL_VBM_MAX, 0); | ||
93 | if (ret < 0) | ||
94 | return ret; | ||
95 | |||
96 | ret = wl1251_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, 1, 0); | ||
97 | if (ret < 0) | ||
98 | return ret; | ||
99 | |||
100 | return 0; | ||
101 | } | ||
102 | |||
103 | int wl1251_hw_init_rx_config(struct wl1251 *wl, u32 config, u32 filter) | ||
104 | { | ||
105 | int ret; | ||
106 | |||
107 | ret = wl1251_acx_rx_msdu_life_time(wl, RX_MSDU_LIFETIME_DEF); | ||
108 | if (ret < 0) | ||
109 | return ret; | ||
110 | |||
111 | ret = wl1251_acx_rx_config(wl, config, filter); | ||
112 | if (ret < 0) | ||
113 | return ret; | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | int wl1251_hw_init_phy_config(struct wl1251 *wl) | ||
119 | { | ||
120 | int ret; | ||
121 | |||
122 | ret = wl1251_acx_pd_threshold(wl); | ||
123 | if (ret < 0) | ||
124 | return ret; | ||
125 | |||
126 | ret = wl1251_acx_slot(wl, DEFAULT_SLOT_TIME); | ||
127 | if (ret < 0) | ||
128 | return ret; | ||
129 | |||
130 | ret = wl1251_acx_group_address_tbl(wl); | ||
131 | if (ret < 0) | ||
132 | return ret; | ||
133 | |||
134 | ret = wl1251_acx_service_period_timeout(wl); | ||
135 | if (ret < 0) | ||
136 | return ret; | ||
137 | |||
138 | ret = wl1251_acx_rts_threshold(wl, RTS_THRESHOLD_DEF); | ||
139 | if (ret < 0) | ||
140 | return ret; | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | int wl1251_hw_init_beacon_filter(struct wl1251 *wl) | ||
146 | { | ||
147 | int ret; | ||
148 | |||
149 | /* disable beacon filtering at this stage */ | ||
150 | ret = wl1251_acx_beacon_filter_opt(wl, false); | ||
151 | if (ret < 0) | ||
152 | return ret; | ||
153 | |||
154 | ret = wl1251_acx_beacon_filter_table(wl); | ||
155 | if (ret < 0) | ||
156 | return ret; | ||
157 | |||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | int wl1251_hw_init_pta(struct wl1251 *wl) | ||
162 | { | ||
163 | int ret; | ||
164 | |||
165 | ret = wl1251_acx_sg_enable(wl); | ||
166 | if (ret < 0) | ||
167 | return ret; | ||
168 | |||
169 | ret = wl1251_acx_sg_cfg(wl); | ||
170 | if (ret < 0) | ||
171 | return ret; | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | int wl1251_hw_init_energy_detection(struct wl1251 *wl) | ||
177 | { | ||
178 | int ret; | ||
179 | |||
180 | ret = wl1251_acx_cca_threshold(wl); | ||
181 | if (ret < 0) | ||
182 | return ret; | ||
183 | |||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | int wl1251_hw_init_beacon_broadcast(struct wl1251 *wl) | ||
188 | { | ||
189 | int ret; | ||
190 | |||
191 | ret = wl1251_acx_bcn_dtim_options(wl); | ||
192 | if (ret < 0) | ||
193 | return ret; | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | int wl1251_hw_init_power_auth(struct wl1251 *wl) | ||
199 | { | ||
200 | return wl1251_acx_sleep_auth(wl, WL1251_PSM_CAM); | ||
201 | } | ||
202 | |||
203 | int wl1251_hw_init_mem_config(struct wl1251 *wl) | ||
204 | { | ||
205 | int ret; | ||
206 | |||
207 | ret = wl1251_acx_mem_cfg(wl); | ||
208 | if (ret < 0) | ||
209 | return ret; | ||
210 | |||
211 | wl->target_mem_map = kzalloc(sizeof(struct wl1251_acx_mem_map), | ||
212 | GFP_KERNEL); | ||
213 | if (!wl->target_mem_map) { | ||
214 | wl1251_error("couldn't allocate target memory map"); | ||
215 | return -ENOMEM; | ||
216 | } | ||
217 | |||
218 | /* we now ask for the firmware built memory map */ | ||
219 | ret = wl1251_acx_mem_map(wl, wl->target_mem_map, | ||
220 | sizeof(struct wl1251_acx_mem_map)); | ||
221 | if (ret < 0) { | ||
222 | wl1251_error("couldn't retrieve firmware memory map"); | ||
223 | kfree(wl->target_mem_map); | ||
224 | wl->target_mem_map = NULL; | ||
225 | return ret; | ||
226 | } | ||
227 | |||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static int wl1251_hw_init_txq_fill(u8 qid, | ||
232 | struct acx_tx_queue_qos_config *config, | ||
233 | u32 num_blocks) | ||
234 | { | ||
235 | config->qid = qid; | ||
236 | |||
237 | switch (qid) { | ||
238 | case QOS_AC_BE: | ||
239 | config->high_threshold = | ||
240 | (QOS_TX_HIGH_BE_DEF * num_blocks) / 100; | ||
241 | config->low_threshold = | ||
242 | (QOS_TX_LOW_BE_DEF * num_blocks) / 100; | ||
243 | break; | ||
244 | case QOS_AC_BK: | ||
245 | config->high_threshold = | ||
246 | (QOS_TX_HIGH_BK_DEF * num_blocks) / 100; | ||
247 | config->low_threshold = | ||
248 | (QOS_TX_LOW_BK_DEF * num_blocks) / 100; | ||
249 | break; | ||
250 | case QOS_AC_VI: | ||
251 | config->high_threshold = | ||
252 | (QOS_TX_HIGH_VI_DEF * num_blocks) / 100; | ||
253 | config->low_threshold = | ||
254 | (QOS_TX_LOW_VI_DEF * num_blocks) / 100; | ||
255 | break; | ||
256 | case QOS_AC_VO: | ||
257 | config->high_threshold = | ||
258 | (QOS_TX_HIGH_VO_DEF * num_blocks) / 100; | ||
259 | config->low_threshold = | ||
260 | (QOS_TX_LOW_VO_DEF * num_blocks) / 100; | ||
261 | break; | ||
262 | default: | ||
263 | wl1251_error("Invalid TX queue id: %d", qid); | ||
264 | return -EINVAL; | ||
265 | } | ||
266 | |||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | static int wl1251_hw_init_tx_queue_config(struct wl1251 *wl) | ||
271 | { | ||
272 | struct acx_tx_queue_qos_config *config; | ||
273 | struct wl1251_acx_mem_map *wl_mem_map = wl->target_mem_map; | ||
274 | int ret, i; | ||
275 | |||
276 | wl1251_debug(DEBUG_ACX, "acx tx queue config"); | ||
277 | |||
278 | config = kzalloc(sizeof(*config), GFP_KERNEL); | ||
279 | if (!config) { | ||
280 | ret = -ENOMEM; | ||
281 | goto out; | ||
282 | } | ||
283 | |||
284 | for (i = 0; i < MAX_NUM_OF_AC; i++) { | ||
285 | ret = wl1251_hw_init_txq_fill(i, config, | ||
286 | wl_mem_map->num_tx_mem_blocks); | ||
287 | if (ret < 0) | ||
288 | goto out; | ||
289 | |||
290 | ret = wl1251_cmd_configure(wl, ACX_TX_QUEUE_CFG, | ||
291 | config, sizeof(*config)); | ||
292 | if (ret < 0) | ||
293 | goto out; | ||
294 | } | ||
295 | |||
296 | wl1251_acx_ac_cfg(wl, AC_BE, CWMIN_BE, CWMAX_BE, AIFS_DIFS, TXOP_BE); | ||
297 | wl1251_acx_ac_cfg(wl, AC_BK, CWMIN_BK, CWMAX_BK, AIFS_DIFS, TXOP_BK); | ||
298 | wl1251_acx_ac_cfg(wl, AC_VI, CWMIN_VI, CWMAX_VI, AIFS_DIFS, TXOP_VI); | ||
299 | wl1251_acx_ac_cfg(wl, AC_VO, CWMIN_VO, CWMAX_VO, AIFS_DIFS, TXOP_VO); | ||
300 | |||
301 | out: | ||
302 | kfree(config); | ||
303 | return ret; | ||
304 | } | ||
305 | |||
306 | static int wl1251_hw_init_data_path_config(struct wl1251 *wl) | ||
307 | { | ||
308 | int ret; | ||
309 | |||
310 | /* asking for the data path parameters */ | ||
311 | wl->data_path = kzalloc(sizeof(struct acx_data_path_params_resp), | ||
312 | GFP_KERNEL); | ||
313 | if (!wl->data_path) { | ||
314 | wl1251_error("Couldnt allocate data path parameters"); | ||
315 | return -ENOMEM; | ||
316 | } | ||
317 | |||
318 | ret = wl1251_acx_data_path_params(wl, wl->data_path); | ||
319 | if (ret < 0) { | ||
320 | kfree(wl->data_path); | ||
321 | wl->data_path = NULL; | ||
322 | return ret; | ||
323 | } | ||
324 | |||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | |||
329 | int wl1251_hw_init(struct wl1251 *wl) | ||
330 | { | ||
331 | struct wl1251_acx_mem_map *wl_mem_map; | ||
332 | int ret; | ||
333 | |||
334 | ret = wl1251_hw_init_hwenc_config(wl); | ||
335 | if (ret < 0) | ||
336 | return ret; | ||
337 | |||
338 | /* Template settings */ | ||
339 | ret = wl1251_hw_init_templates_config(wl); | ||
340 | if (ret < 0) | ||
341 | return ret; | ||
342 | |||
343 | /* Default memory configuration */ | ||
344 | ret = wl1251_hw_init_mem_config(wl); | ||
345 | if (ret < 0) | ||
346 | return ret; | ||
347 | |||
348 | /* Default data path configuration */ | ||
349 | ret = wl1251_hw_init_data_path_config(wl); | ||
350 | if (ret < 0) | ||
351 | goto out_free_memmap; | ||
352 | |||
353 | /* RX config */ | ||
354 | ret = wl1251_hw_init_rx_config(wl, | ||
355 | RX_CFG_PROMISCUOUS | RX_CFG_TSF, | ||
356 | RX_FILTER_OPTION_DEF); | ||
357 | /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS, | ||
358 | RX_FILTER_OPTION_FILTER_ALL); */ | ||
359 | if (ret < 0) | ||
360 | goto out_free_data_path; | ||
361 | |||
362 | /* TX queues config */ | ||
363 | ret = wl1251_hw_init_tx_queue_config(wl); | ||
364 | if (ret < 0) | ||
365 | goto out_free_data_path; | ||
366 | |||
367 | /* PHY layer config */ | ||
368 | ret = wl1251_hw_init_phy_config(wl); | ||
369 | if (ret < 0) | ||
370 | goto out_free_data_path; | ||
371 | |||
372 | /* Initialize connection monitoring thresholds */ | ||
373 | ret = wl1251_acx_conn_monit_params(wl); | ||
374 | if (ret < 0) | ||
375 | goto out_free_data_path; | ||
376 | |||
377 | /* Beacon filtering */ | ||
378 | ret = wl1251_hw_init_beacon_filter(wl); | ||
379 | if (ret < 0) | ||
380 | goto out_free_data_path; | ||
381 | |||
382 | /* Bluetooth WLAN coexistence */ | ||
383 | ret = wl1251_hw_init_pta(wl); | ||
384 | if (ret < 0) | ||
385 | goto out_free_data_path; | ||
386 | |||
387 | /* Energy detection */ | ||
388 | ret = wl1251_hw_init_energy_detection(wl); | ||
389 | if (ret < 0) | ||
390 | goto out_free_data_path; | ||
391 | |||
392 | /* Beacons and boradcast settings */ | ||
393 | ret = wl1251_hw_init_beacon_broadcast(wl); | ||
394 | if (ret < 0) | ||
395 | goto out_free_data_path; | ||
396 | |||
397 | /* Enable data path */ | ||
398 | ret = wl1251_cmd_data_path(wl, wl->channel, 1); | ||
399 | if (ret < 0) | ||
400 | goto out_free_data_path; | ||
401 | |||
402 | /* Default power state */ | ||
403 | ret = wl1251_hw_init_power_auth(wl); | ||
404 | if (ret < 0) | ||
405 | goto out_free_data_path; | ||
406 | |||
407 | wl_mem_map = wl->target_mem_map; | ||
408 | wl1251_info("%d tx blocks at 0x%x, %d rx blocks at 0x%x", | ||
409 | wl_mem_map->num_tx_mem_blocks, | ||
410 | wl->data_path->tx_control_addr, | ||
411 | wl_mem_map->num_rx_mem_blocks, | ||
412 | wl->data_path->rx_control_addr); | ||
413 | |||
414 | return 0; | ||
415 | |||
416 | out_free_data_path: | ||
417 | kfree(wl->data_path); | ||
418 | |||
419 | out_free_memmap: | ||
420 | kfree(wl->target_mem_map); | ||
421 | |||
422 | return ret; | ||
423 | } | ||
diff --git a/drivers/net/wireless/wl1251/init.h b/drivers/net/wireless/wl1251/init.h new file mode 100644 index 000000000000..543f17582ead --- /dev/null +++ b/drivers/net/wireless/wl1251/init.h | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2009 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #ifndef __WL1251_INIT_H__ | ||
23 | #define __WL1251_INIT_H__ | ||
24 | |||
25 | #include "wl1251.h" | ||
26 | |||
27 | enum { | ||
28 | /* best effort/legacy */ | ||
29 | AC_BE = 0, | ||
30 | |||
31 | /* background */ | ||
32 | AC_BK = 1, | ||
33 | |||
34 | /* video */ | ||
35 | AC_VI = 2, | ||
36 | |||
37 | /* voice */ | ||
38 | AC_VO = 3, | ||
39 | |||
40 | /* broadcast dummy access category */ | ||
41 | AC_BCAST = 4, | ||
42 | |||
43 | NUM_ACCESS_CATEGORIES = 4 | ||
44 | }; | ||
45 | |||
46 | /* following are defult values for the IE fields*/ | ||
47 | #define CWMIN_BK 15 | ||
48 | #define CWMIN_BE 15 | ||
49 | #define CWMIN_VI 7 | ||
50 | #define CWMIN_VO 3 | ||
51 | #define CWMAX_BK 1023 | ||
52 | #define CWMAX_BE 63 | ||
53 | #define CWMAX_VI 15 | ||
54 | #define CWMAX_VO 7 | ||
55 | |||
56 | /* slot number setting to start transmission at PIFS interval */ | ||
57 | #define AIFS_PIFS 1 | ||
58 | |||
59 | /* | ||
60 | * slot number setting to start transmission at DIFS interval - normal DCF | ||
61 | * access | ||
62 | */ | ||
63 | #define AIFS_DIFS 2 | ||
64 | |||
65 | #define AIFSN_BK 7 | ||
66 | #define AIFSN_BE 3 | ||
67 | #define AIFSN_VI AIFS_PIFS | ||
68 | #define AIFSN_VO AIFS_PIFS | ||
69 | #define TXOP_BK 0 | ||
70 | #define TXOP_BE 0 | ||
71 | #define TXOP_VI 3008 | ||
72 | #define TXOP_VO 1504 | ||
73 | |||
74 | int wl1251_hw_init_hwenc_config(struct wl1251 *wl); | ||
75 | int wl1251_hw_init_templates_config(struct wl1251 *wl); | ||
76 | int wl1251_hw_init_rx_config(struct wl1251 *wl, u32 config, u32 filter); | ||
77 | int wl1251_hw_init_phy_config(struct wl1251 *wl); | ||
78 | int wl1251_hw_init_beacon_filter(struct wl1251 *wl); | ||
79 | int wl1251_hw_init_pta(struct wl1251 *wl); | ||
80 | int wl1251_hw_init_energy_detection(struct wl1251 *wl); | ||
81 | int wl1251_hw_init_beacon_broadcast(struct wl1251 *wl); | ||
82 | int wl1251_hw_init_power_auth(struct wl1251 *wl); | ||
83 | int wl1251_hw_init_mem_config(struct wl1251 *wl); | ||
84 | int wl1251_hw_init(struct wl1251 *wl); | ||
85 | |||
86 | #endif | ||
diff --git a/drivers/net/wireless/wl1251/io.c b/drivers/net/wireless/wl1251/io.c new file mode 100644 index 000000000000..cdcadbf6ac2c --- /dev/null +++ b/drivers/net/wireless/wl1251/io.c | |||
@@ -0,0 +1,194 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include "wl1251.h" | ||
23 | #include "reg.h" | ||
24 | #include "io.h" | ||
25 | |||
26 | /* FIXME: this is static data nowadays and the table can be removed */ | ||
27 | static enum wl12xx_acx_int_reg wl1251_io_reg_table[ACX_REG_TABLE_LEN] = { | ||
28 | [ACX_REG_INTERRUPT_TRIG] = (REGISTERS_BASE + 0x0474), | ||
29 | [ACX_REG_INTERRUPT_TRIG_H] = (REGISTERS_BASE + 0x0478), | ||
30 | [ACX_REG_INTERRUPT_MASK] = (REGISTERS_BASE + 0x0494), | ||
31 | [ACX_REG_HINT_MASK_SET] = (REGISTERS_BASE + 0x0498), | ||
32 | [ACX_REG_HINT_MASK_CLR] = (REGISTERS_BASE + 0x049C), | ||
33 | [ACX_REG_INTERRUPT_NO_CLEAR] = (REGISTERS_BASE + 0x04B0), | ||
34 | [ACX_REG_INTERRUPT_CLEAR] = (REGISTERS_BASE + 0x04A4), | ||
35 | [ACX_REG_INTERRUPT_ACK] = (REGISTERS_BASE + 0x04A8), | ||
36 | [ACX_REG_SLV_SOFT_RESET] = (REGISTERS_BASE + 0x0000), | ||
37 | [ACX_REG_EE_START] = (REGISTERS_BASE + 0x080C), | ||
38 | [ACX_REG_ECPU_CONTROL] = (REGISTERS_BASE + 0x0804) | ||
39 | }; | ||
40 | |||
41 | static int wl1251_translate_reg_addr(struct wl1251 *wl, int addr) | ||
42 | { | ||
43 | /* If the address is lower than REGISTERS_BASE, it means that this is | ||
44 | * a chip-specific register address, so look it up in the registers | ||
45 | * table */ | ||
46 | if (addr < REGISTERS_BASE) { | ||
47 | /* Make sure we don't go over the table */ | ||
48 | if (addr >= ACX_REG_TABLE_LEN) { | ||
49 | wl1251_error("address out of range (%d)", addr); | ||
50 | return -EINVAL; | ||
51 | } | ||
52 | addr = wl1251_io_reg_table[addr]; | ||
53 | } | ||
54 | |||
55 | return addr - wl->physical_reg_addr + wl->virtual_reg_addr; | ||
56 | } | ||
57 | |||
58 | static int wl1251_translate_mem_addr(struct wl1251 *wl, int addr) | ||
59 | { | ||
60 | return addr - wl->physical_mem_addr + wl->virtual_mem_addr; | ||
61 | } | ||
62 | |||
63 | void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len) | ||
64 | { | ||
65 | int physical; | ||
66 | |||
67 | physical = wl1251_translate_mem_addr(wl, addr); | ||
68 | |||
69 | wl->if_ops->read(wl, physical, buf, len); | ||
70 | } | ||
71 | |||
72 | void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len) | ||
73 | { | ||
74 | int physical; | ||
75 | |||
76 | physical = wl1251_translate_mem_addr(wl, addr); | ||
77 | |||
78 | wl->if_ops->write(wl, physical, buf, len); | ||
79 | } | ||
80 | |||
81 | u32 wl1251_mem_read32(struct wl1251 *wl, int addr) | ||
82 | { | ||
83 | return wl1251_read32(wl, wl1251_translate_mem_addr(wl, addr)); | ||
84 | } | ||
85 | |||
86 | void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val) | ||
87 | { | ||
88 | wl1251_write32(wl, wl1251_translate_mem_addr(wl, addr), val); | ||
89 | } | ||
90 | |||
91 | u32 wl1251_reg_read32(struct wl1251 *wl, int addr) | ||
92 | { | ||
93 | return wl1251_read32(wl, wl1251_translate_reg_addr(wl, addr)); | ||
94 | } | ||
95 | |||
96 | void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val) | ||
97 | { | ||
98 | wl1251_write32(wl, wl1251_translate_reg_addr(wl, addr), val); | ||
99 | } | ||
100 | |||
101 | /* Set the partitions to access the chip addresses. | ||
102 | * | ||
103 | * There are two VIRTUAL partitions (the memory partition and the | ||
104 | * registers partition), which are mapped to two different areas of the | ||
105 | * PHYSICAL (hardware) memory. This function also makes other checks to | ||
106 | * ensure that the partitions are not overlapping. In the diagram below, the | ||
107 | * memory partition comes before the register partition, but the opposite is | ||
108 | * also supported. | ||
109 | * | ||
110 | * PHYSICAL address | ||
111 | * space | ||
112 | * | ||
113 | * | | | ||
114 | * ...+----+--> mem_start | ||
115 | * VIRTUAL address ... | | | ||
116 | * space ... | | [PART_0] | ||
117 | * ... | | | ||
118 | * 0x00000000 <--+----+... ...+----+--> mem_start + mem_size | ||
119 | * | | ... | | | ||
120 | * |MEM | ... | | | ||
121 | * | | ... | | | ||
122 | * part_size <--+----+... | | {unused area) | ||
123 | * | | ... | | | ||
124 | * |REG | ... | | | ||
125 | * part_size | | ... | | | ||
126 | * + <--+----+... ...+----+--> reg_start | ||
127 | * reg_size ... | | | ||
128 | * ... | | [PART_1] | ||
129 | * ... | | | ||
130 | * ...+----+--> reg_start + reg_size | ||
131 | * | | | ||
132 | * | ||
133 | */ | ||
134 | void wl1251_set_partition(struct wl1251 *wl, | ||
135 | u32 mem_start, u32 mem_size, | ||
136 | u32 reg_start, u32 reg_size) | ||
137 | { | ||
138 | struct wl1251_partition partition[2]; | ||
139 | |||
140 | wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", | ||
141 | mem_start, mem_size); | ||
142 | wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", | ||
143 | reg_start, reg_size); | ||
144 | |||
145 | /* Make sure that the two partitions together don't exceed the | ||
146 | * address range */ | ||
147 | if ((mem_size + reg_size) > HW_ACCESS_MEMORY_MAX_RANGE) { | ||
148 | wl1251_debug(DEBUG_SPI, "Total size exceeds maximum virtual" | ||
149 | " address range. Truncating partition[0]."); | ||
150 | mem_size = HW_ACCESS_MEMORY_MAX_RANGE - reg_size; | ||
151 | wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", | ||
152 | mem_start, mem_size); | ||
153 | wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", | ||
154 | reg_start, reg_size); | ||
155 | } | ||
156 | |||
157 | if ((mem_start < reg_start) && | ||
158 | ((mem_start + mem_size) > reg_start)) { | ||
159 | /* Guarantee that the memory partition doesn't overlap the | ||
160 | * registers partition */ | ||
161 | wl1251_debug(DEBUG_SPI, "End of partition[0] is " | ||
162 | "overlapping partition[1]. Adjusted."); | ||
163 | mem_size = reg_start - mem_start; | ||
164 | wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", | ||
165 | mem_start, mem_size); | ||
166 | wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", | ||
167 | reg_start, reg_size); | ||
168 | } else if ((reg_start < mem_start) && | ||
169 | ((reg_start + reg_size) > mem_start)) { | ||
170 | /* Guarantee that the register partition doesn't overlap the | ||
171 | * memory partition */ | ||
172 | wl1251_debug(DEBUG_SPI, "End of partition[1] is" | ||
173 | " overlapping partition[0]. Adjusted."); | ||
174 | reg_size = mem_start - reg_start; | ||
175 | wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", | ||
176 | mem_start, mem_size); | ||
177 | wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", | ||
178 | reg_start, reg_size); | ||
179 | } | ||
180 | |||
181 | partition[0].start = mem_start; | ||
182 | partition[0].size = mem_size; | ||
183 | partition[1].start = reg_start; | ||
184 | partition[1].size = reg_size; | ||
185 | |||
186 | wl->physical_mem_addr = mem_start; | ||
187 | wl->physical_reg_addr = reg_start; | ||
188 | |||
189 | wl->virtual_mem_addr = 0; | ||
190 | wl->virtual_reg_addr = mem_size; | ||
191 | |||
192 | wl->if_ops->write(wl, HW_ACCESS_PART0_SIZE_ADDR, partition, | ||
193 | sizeof(partition)); | ||
194 | } | ||
diff --git a/drivers/net/wireless/wl1251/io.h b/drivers/net/wireless/wl1251/io.h new file mode 100644 index 000000000000..c545e9d5f512 --- /dev/null +++ b/drivers/net/wireless/wl1251/io.h | |||
@@ -0,0 +1,84 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | #ifndef __WL1251_IO_H__ | ||
22 | #define __WL1251_IO_H__ | ||
23 | |||
24 | #include "wl1251.h" | ||
25 | |||
26 | #define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0 | ||
27 | |||
28 | #define HW_ACCESS_PART0_SIZE_ADDR 0x1FFC0 | ||
29 | #define HW_ACCESS_PART0_START_ADDR 0x1FFC4 | ||
30 | #define HW_ACCESS_PART1_SIZE_ADDR 0x1FFC8 | ||
31 | #define HW_ACCESS_PART1_START_ADDR 0x1FFCC | ||
32 | |||
33 | #define HW_ACCESS_REGISTER_SIZE 4 | ||
34 | |||
35 | #define HW_ACCESS_PRAM_MAX_RANGE 0x3c000 | ||
36 | |||
37 | static inline u32 wl1251_read32(struct wl1251 *wl, int addr) | ||
38 | { | ||
39 | u32 response; | ||
40 | |||
41 | wl->if_ops->read(wl, addr, &response, sizeof(u32)); | ||
42 | |||
43 | return response; | ||
44 | } | ||
45 | |||
46 | static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val) | ||
47 | { | ||
48 | wl->if_ops->write(wl, addr, &val, sizeof(u32)); | ||
49 | } | ||
50 | |||
51 | static inline u32 wl1251_read_elp(struct wl1251 *wl, int addr) | ||
52 | { | ||
53 | u32 response; | ||
54 | |||
55 | if (wl->if_ops->read_elp) | ||
56 | wl->if_ops->read_elp(wl, addr, &response); | ||
57 | else | ||
58 | wl->if_ops->read(wl, addr, &response, sizeof(u32)); | ||
59 | |||
60 | return response; | ||
61 | } | ||
62 | |||
63 | static inline void wl1251_write_elp(struct wl1251 *wl, int addr, u32 val) | ||
64 | { | ||
65 | if (wl->if_ops->write_elp) | ||
66 | wl->if_ops->write_elp(wl, addr, val); | ||
67 | else | ||
68 | wl->if_ops->write(wl, addr, &val, sizeof(u32)); | ||
69 | } | ||
70 | |||
71 | /* Memory target IO, address is translated to partition 0 */ | ||
72 | void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
73 | void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
74 | u32 wl1251_mem_read32(struct wl1251 *wl, int addr); | ||
75 | void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val); | ||
76 | /* Registers IO */ | ||
77 | u32 wl1251_reg_read32(struct wl1251 *wl, int addr); | ||
78 | void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val); | ||
79 | |||
80 | void wl1251_set_partition(struct wl1251 *wl, | ||
81 | u32 part_start, u32 part_size, | ||
82 | u32 reg_start, u32 reg_size); | ||
83 | |||
84 | #endif | ||
diff --git a/drivers/net/wireless/wl1251/main.c b/drivers/net/wireless/wl1251/main.c new file mode 100644 index 000000000000..7a8762553cdc --- /dev/null +++ b/drivers/net/wireless/wl1251/main.c | |||
@@ -0,0 +1,1435 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2008-2009 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/module.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/firmware.h> | ||
25 | #include <linux/delay.h> | ||
26 | #include <linux/irq.h> | ||
27 | #include <linux/crc32.h> | ||
28 | #include <linux/etherdevice.h> | ||
29 | #include <linux/vmalloc.h> | ||
30 | #include <linux/slab.h> | ||
31 | |||
32 | #include "wl1251.h" | ||
33 | #include "wl12xx_80211.h" | ||
34 | #include "reg.h" | ||
35 | #include "io.h" | ||
36 | #include "cmd.h" | ||
37 | #include "event.h" | ||
38 | #include "tx.h" | ||
39 | #include "rx.h" | ||
40 | #include "ps.h" | ||
41 | #include "init.h" | ||
42 | #include "debugfs.h" | ||
43 | #include "boot.h" | ||
44 | |||
45 | void wl1251_enable_interrupts(struct wl1251 *wl) | ||
46 | { | ||
47 | wl->if_ops->enable_irq(wl); | ||
48 | } | ||
49 | |||
50 | void wl1251_disable_interrupts(struct wl1251 *wl) | ||
51 | { | ||
52 | wl->if_ops->disable_irq(wl); | ||
53 | } | ||
54 | |||
55 | static void wl1251_power_off(struct wl1251 *wl) | ||
56 | { | ||
57 | wl->set_power(false); | ||
58 | } | ||
59 | |||
60 | static void wl1251_power_on(struct wl1251 *wl) | ||
61 | { | ||
62 | wl->set_power(true); | ||
63 | } | ||
64 | |||
65 | static int wl1251_fetch_firmware(struct wl1251 *wl) | ||
66 | { | ||
67 | const struct firmware *fw; | ||
68 | struct device *dev = wiphy_dev(wl->hw->wiphy); | ||
69 | int ret; | ||
70 | |||
71 | ret = request_firmware(&fw, WL1251_FW_NAME, dev); | ||
72 | |||
73 | if (ret < 0) { | ||
74 | wl1251_error("could not get firmware: %d", ret); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | if (fw->size % 4) { | ||
79 | wl1251_error("firmware size is not multiple of 32 bits: %zu", | ||
80 | fw->size); | ||
81 | ret = -EILSEQ; | ||
82 | goto out; | ||
83 | } | ||
84 | |||
85 | wl->fw_len = fw->size; | ||
86 | wl->fw = vmalloc(wl->fw_len); | ||
87 | |||
88 | if (!wl->fw) { | ||
89 | wl1251_error("could not allocate memory for the firmware"); | ||
90 | ret = -ENOMEM; | ||
91 | goto out; | ||
92 | } | ||
93 | |||
94 | memcpy(wl->fw, fw->data, wl->fw_len); | ||
95 | |||
96 | ret = 0; | ||
97 | |||
98 | out: | ||
99 | release_firmware(fw); | ||
100 | |||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | static int wl1251_fetch_nvs(struct wl1251 *wl) | ||
105 | { | ||
106 | const struct firmware *fw; | ||
107 | struct device *dev = wiphy_dev(wl->hw->wiphy); | ||
108 | int ret; | ||
109 | |||
110 | ret = request_firmware(&fw, WL1251_NVS_NAME, dev); | ||
111 | |||
112 | if (ret < 0) { | ||
113 | wl1251_error("could not get nvs file: %d", ret); | ||
114 | return ret; | ||
115 | } | ||
116 | |||
117 | if (fw->size % 4) { | ||
118 | wl1251_error("nvs size is not multiple of 32 bits: %zu", | ||
119 | fw->size); | ||
120 | ret = -EILSEQ; | ||
121 | goto out; | ||
122 | } | ||
123 | |||
124 | wl->nvs_len = fw->size; | ||
125 | wl->nvs = kmemdup(fw->data, wl->nvs_len, GFP_KERNEL); | ||
126 | |||
127 | if (!wl->nvs) { | ||
128 | wl1251_error("could not allocate memory for the nvs file"); | ||
129 | ret = -ENOMEM; | ||
130 | goto out; | ||
131 | } | ||
132 | |||
133 | ret = 0; | ||
134 | |||
135 | out: | ||
136 | release_firmware(fw); | ||
137 | |||
138 | return ret; | ||
139 | } | ||
140 | |||
141 | static void wl1251_fw_wakeup(struct wl1251 *wl) | ||
142 | { | ||
143 | u32 elp_reg; | ||
144 | |||
145 | elp_reg = ELPCTRL_WAKE_UP; | ||
146 | wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); | ||
147 | elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); | ||
148 | |||
149 | if (!(elp_reg & ELPCTRL_WLAN_READY)) | ||
150 | wl1251_warning("WLAN not ready"); | ||
151 | } | ||
152 | |||
153 | static int wl1251_chip_wakeup(struct wl1251 *wl) | ||
154 | { | ||
155 | int ret = 0; | ||
156 | |||
157 | wl1251_power_on(wl); | ||
158 | msleep(WL1251_POWER_ON_SLEEP); | ||
159 | wl->if_ops->reset(wl); | ||
160 | |||
161 | /* We don't need a real memory partition here, because we only want | ||
162 | * to use the registers at this point. */ | ||
163 | wl1251_set_partition(wl, | ||
164 | 0x00000000, | ||
165 | 0x00000000, | ||
166 | REGISTERS_BASE, | ||
167 | REGISTERS_DOWN_SIZE); | ||
168 | |||
169 | /* ELP module wake up */ | ||
170 | wl1251_fw_wakeup(wl); | ||
171 | |||
172 | /* whal_FwCtrl_BootSm() */ | ||
173 | |||
174 | /* 0. read chip id from CHIP_ID */ | ||
175 | wl->chip_id = wl1251_reg_read32(wl, CHIP_ID_B); | ||
176 | |||
177 | /* 1. check if chip id is valid */ | ||
178 | |||
179 | switch (wl->chip_id) { | ||
180 | case CHIP_ID_1251_PG12: | ||
181 | wl1251_debug(DEBUG_BOOT, "chip id 0x%x (1251 PG12)", | ||
182 | wl->chip_id); | ||
183 | break; | ||
184 | case CHIP_ID_1251_PG11: | ||
185 | wl1251_debug(DEBUG_BOOT, "chip id 0x%x (1251 PG11)", | ||
186 | wl->chip_id); | ||
187 | break; | ||
188 | case CHIP_ID_1251_PG10: | ||
189 | default: | ||
190 | wl1251_error("unsupported chip id: 0x%x", wl->chip_id); | ||
191 | ret = -ENODEV; | ||
192 | goto out; | ||
193 | } | ||
194 | |||
195 | if (wl->fw == NULL) { | ||
196 | ret = wl1251_fetch_firmware(wl); | ||
197 | if (ret < 0) | ||
198 | goto out; | ||
199 | } | ||
200 | |||
201 | if (wl->nvs == NULL && !wl->use_eeprom) { | ||
202 | /* No NVS from netlink, try to get it from the filesystem */ | ||
203 | ret = wl1251_fetch_nvs(wl); | ||
204 | if (ret < 0) | ||
205 | goto out; | ||
206 | } | ||
207 | |||
208 | out: | ||
209 | return ret; | ||
210 | } | ||
211 | |||
212 | #define WL1251_IRQ_LOOP_COUNT 10 | ||
213 | static void wl1251_irq_work(struct work_struct *work) | ||
214 | { | ||
215 | u32 intr, ctr = WL1251_IRQ_LOOP_COUNT; | ||
216 | struct wl1251 *wl = | ||
217 | container_of(work, struct wl1251, irq_work); | ||
218 | int ret; | ||
219 | |||
220 | mutex_lock(&wl->mutex); | ||
221 | |||
222 | wl1251_debug(DEBUG_IRQ, "IRQ work"); | ||
223 | |||
224 | if (wl->state == WL1251_STATE_OFF) | ||
225 | goto out; | ||
226 | |||
227 | ret = wl1251_ps_elp_wakeup(wl); | ||
228 | if (ret < 0) | ||
229 | goto out; | ||
230 | |||
231 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, WL1251_ACX_INTR_ALL); | ||
232 | |||
233 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR); | ||
234 | wl1251_debug(DEBUG_IRQ, "intr: 0x%x", intr); | ||
235 | |||
236 | do { | ||
237 | if (wl->data_path) { | ||
238 | wl->rx_counter = wl1251_mem_read32( | ||
239 | wl, wl->data_path->rx_control_addr); | ||
240 | |||
241 | /* We handle a frmware bug here */ | ||
242 | switch ((wl->rx_counter - wl->rx_handled) & 0xf) { | ||
243 | case 0: | ||
244 | wl1251_debug(DEBUG_IRQ, | ||
245 | "RX: FW and host in sync"); | ||
246 | intr &= ~WL1251_ACX_INTR_RX0_DATA; | ||
247 | intr &= ~WL1251_ACX_INTR_RX1_DATA; | ||
248 | break; | ||
249 | case 1: | ||
250 | wl1251_debug(DEBUG_IRQ, "RX: FW +1"); | ||
251 | intr |= WL1251_ACX_INTR_RX0_DATA; | ||
252 | intr &= ~WL1251_ACX_INTR_RX1_DATA; | ||
253 | break; | ||
254 | case 2: | ||
255 | wl1251_debug(DEBUG_IRQ, "RX: FW +2"); | ||
256 | intr |= WL1251_ACX_INTR_RX0_DATA; | ||
257 | intr |= WL1251_ACX_INTR_RX1_DATA; | ||
258 | break; | ||
259 | default: | ||
260 | wl1251_warning( | ||
261 | "RX: FW and host out of sync: %d", | ||
262 | wl->rx_counter - wl->rx_handled); | ||
263 | break; | ||
264 | } | ||
265 | |||
266 | wl->rx_handled = wl->rx_counter; | ||
267 | |||
268 | wl1251_debug(DEBUG_IRQ, "RX counter: %d", | ||
269 | wl->rx_counter); | ||
270 | } | ||
271 | |||
272 | intr &= wl->intr_mask; | ||
273 | |||
274 | if (intr == 0) { | ||
275 | wl1251_debug(DEBUG_IRQ, "INTR is 0"); | ||
276 | goto out_sleep; | ||
277 | } | ||
278 | |||
279 | if (intr & WL1251_ACX_INTR_RX0_DATA) { | ||
280 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX0_DATA"); | ||
281 | wl1251_rx(wl); | ||
282 | } | ||
283 | |||
284 | if (intr & WL1251_ACX_INTR_RX1_DATA) { | ||
285 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX1_DATA"); | ||
286 | wl1251_rx(wl); | ||
287 | } | ||
288 | |||
289 | if (intr & WL1251_ACX_INTR_TX_RESULT) { | ||
290 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_TX_RESULT"); | ||
291 | wl1251_tx_complete(wl); | ||
292 | } | ||
293 | |||
294 | if (intr & WL1251_ACX_INTR_EVENT_A) { | ||
295 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT_A"); | ||
296 | wl1251_event_handle(wl, 0); | ||
297 | } | ||
298 | |||
299 | if (intr & WL1251_ACX_INTR_EVENT_B) { | ||
300 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT_B"); | ||
301 | wl1251_event_handle(wl, 1); | ||
302 | } | ||
303 | |||
304 | if (intr & WL1251_ACX_INTR_INIT_COMPLETE) | ||
305 | wl1251_debug(DEBUG_IRQ, | ||
306 | "WL1251_ACX_INTR_INIT_COMPLETE"); | ||
307 | |||
308 | if (--ctr == 0) | ||
309 | break; | ||
310 | |||
311 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR); | ||
312 | } while (intr); | ||
313 | |||
314 | out_sleep: | ||
315 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); | ||
316 | wl1251_ps_elp_sleep(wl); | ||
317 | |||
318 | out: | ||
319 | mutex_unlock(&wl->mutex); | ||
320 | } | ||
321 | |||
322 | static int wl1251_join(struct wl1251 *wl, u8 bss_type, u8 channel, | ||
323 | u16 beacon_interval, u8 dtim_period) | ||
324 | { | ||
325 | int ret; | ||
326 | |||
327 | ret = wl1251_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE, | ||
328 | DEFAULT_HW_GEN_MODULATION_TYPE, | ||
329 | wl->tx_mgmt_frm_rate, | ||
330 | wl->tx_mgmt_frm_mod); | ||
331 | if (ret < 0) | ||
332 | goto out; | ||
333 | |||
334 | |||
335 | ret = wl1251_cmd_join(wl, bss_type, channel, beacon_interval, | ||
336 | dtim_period); | ||
337 | if (ret < 0) | ||
338 | goto out; | ||
339 | |||
340 | ret = wl1251_event_wait(wl, JOIN_EVENT_COMPLETE_ID, 100); | ||
341 | if (ret < 0) | ||
342 | wl1251_warning("join timeout"); | ||
343 | |||
344 | out: | ||
345 | return ret; | ||
346 | } | ||
347 | |||
348 | static void wl1251_filter_work(struct work_struct *work) | ||
349 | { | ||
350 | struct wl1251 *wl = | ||
351 | container_of(work, struct wl1251, filter_work); | ||
352 | int ret; | ||
353 | |||
354 | mutex_lock(&wl->mutex); | ||
355 | |||
356 | if (wl->state == WL1251_STATE_OFF) | ||
357 | goto out; | ||
358 | |||
359 | ret = wl1251_ps_elp_wakeup(wl); | ||
360 | if (ret < 0) | ||
361 | goto out; | ||
362 | |||
363 | ret = wl1251_join(wl, wl->bss_type, wl->channel, wl->beacon_int, | ||
364 | wl->dtim_period); | ||
365 | if (ret < 0) | ||
366 | goto out_sleep; | ||
367 | |||
368 | out_sleep: | ||
369 | wl1251_ps_elp_sleep(wl); | ||
370 | |||
371 | out: | ||
372 | mutex_unlock(&wl->mutex); | ||
373 | } | ||
374 | |||
375 | static int wl1251_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | ||
376 | { | ||
377 | struct wl1251 *wl = hw->priv; | ||
378 | unsigned long flags; | ||
379 | |||
380 | skb_queue_tail(&wl->tx_queue, skb); | ||
381 | |||
382 | /* | ||
383 | * The chip specific setup must run before the first TX packet - | ||
384 | * before that, the tx_work will not be initialized! | ||
385 | */ | ||
386 | |||
387 | ieee80211_queue_work(wl->hw, &wl->tx_work); | ||
388 | |||
389 | /* | ||
390 | * The workqueue is slow to process the tx_queue and we need stop | ||
391 | * the queue here, otherwise the queue will get too long. | ||
392 | */ | ||
393 | if (skb_queue_len(&wl->tx_queue) >= WL1251_TX_QUEUE_HIGH_WATERMARK) { | ||
394 | wl1251_debug(DEBUG_TX, "op_tx: tx_queue full, stop queues"); | ||
395 | |||
396 | spin_lock_irqsave(&wl->wl_lock, flags); | ||
397 | ieee80211_stop_queues(wl->hw); | ||
398 | wl->tx_queue_stopped = true; | ||
399 | spin_unlock_irqrestore(&wl->wl_lock, flags); | ||
400 | } | ||
401 | |||
402 | return NETDEV_TX_OK; | ||
403 | } | ||
404 | |||
405 | static int wl1251_op_start(struct ieee80211_hw *hw) | ||
406 | { | ||
407 | struct wl1251 *wl = hw->priv; | ||
408 | struct wiphy *wiphy = hw->wiphy; | ||
409 | int ret = 0; | ||
410 | |||
411 | wl1251_debug(DEBUG_MAC80211, "mac80211 start"); | ||
412 | |||
413 | mutex_lock(&wl->mutex); | ||
414 | |||
415 | if (wl->state != WL1251_STATE_OFF) { | ||
416 | wl1251_error("cannot start because not in off state: %d", | ||
417 | wl->state); | ||
418 | ret = -EBUSY; | ||
419 | goto out; | ||
420 | } | ||
421 | |||
422 | ret = wl1251_chip_wakeup(wl); | ||
423 | if (ret < 0) | ||
424 | goto out; | ||
425 | |||
426 | ret = wl1251_boot(wl); | ||
427 | if (ret < 0) | ||
428 | goto out; | ||
429 | |||
430 | ret = wl1251_hw_init(wl); | ||
431 | if (ret < 0) | ||
432 | goto out; | ||
433 | |||
434 | ret = wl1251_acx_station_id(wl); | ||
435 | if (ret < 0) | ||
436 | goto out; | ||
437 | |||
438 | wl->state = WL1251_STATE_ON; | ||
439 | |||
440 | wl1251_info("firmware booted (%s)", wl->fw_ver); | ||
441 | |||
442 | /* update hw/fw version info in wiphy struct */ | ||
443 | wiphy->hw_version = wl->chip_id; | ||
444 | strncpy(wiphy->fw_version, wl->fw_ver, sizeof(wiphy->fw_version)); | ||
445 | |||
446 | out: | ||
447 | if (ret < 0) | ||
448 | wl1251_power_off(wl); | ||
449 | |||
450 | mutex_unlock(&wl->mutex); | ||
451 | |||
452 | return ret; | ||
453 | } | ||
454 | |||
455 | static void wl1251_op_stop(struct ieee80211_hw *hw) | ||
456 | { | ||
457 | struct wl1251 *wl = hw->priv; | ||
458 | |||
459 | wl1251_info("down"); | ||
460 | |||
461 | wl1251_debug(DEBUG_MAC80211, "mac80211 stop"); | ||
462 | |||
463 | mutex_lock(&wl->mutex); | ||
464 | |||
465 | WARN_ON(wl->state != WL1251_STATE_ON); | ||
466 | |||
467 | if (wl->scanning) { | ||
468 | ieee80211_scan_completed(wl->hw, true); | ||
469 | wl->scanning = false; | ||
470 | } | ||
471 | |||
472 | wl->state = WL1251_STATE_OFF; | ||
473 | |||
474 | wl1251_disable_interrupts(wl); | ||
475 | |||
476 | mutex_unlock(&wl->mutex); | ||
477 | |||
478 | cancel_work_sync(&wl->irq_work); | ||
479 | cancel_work_sync(&wl->tx_work); | ||
480 | cancel_work_sync(&wl->filter_work); | ||
481 | |||
482 | mutex_lock(&wl->mutex); | ||
483 | |||
484 | /* let's notify MAC80211 about the remaining pending TX frames */ | ||
485 | wl1251_tx_flush(wl); | ||
486 | wl1251_power_off(wl); | ||
487 | |||
488 | memset(wl->bssid, 0, ETH_ALEN); | ||
489 | wl->listen_int = 1; | ||
490 | wl->bss_type = MAX_BSS_TYPE; | ||
491 | |||
492 | wl->data_in_count = 0; | ||
493 | wl->rx_counter = 0; | ||
494 | wl->rx_handled = 0; | ||
495 | wl->rx_current_buffer = 0; | ||
496 | wl->rx_last_id = 0; | ||
497 | wl->next_tx_complete = 0; | ||
498 | wl->elp = false; | ||
499 | wl->psm = 0; | ||
500 | wl->tx_queue_stopped = false; | ||
501 | wl->power_level = WL1251_DEFAULT_POWER_LEVEL; | ||
502 | wl->channel = WL1251_DEFAULT_CHANNEL; | ||
503 | |||
504 | wl1251_debugfs_reset(wl); | ||
505 | |||
506 | mutex_unlock(&wl->mutex); | ||
507 | } | ||
508 | |||
509 | static int wl1251_op_add_interface(struct ieee80211_hw *hw, | ||
510 | struct ieee80211_vif *vif) | ||
511 | { | ||
512 | struct wl1251 *wl = hw->priv; | ||
513 | int ret = 0; | ||
514 | |||
515 | wl1251_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", | ||
516 | vif->type, vif->addr); | ||
517 | |||
518 | mutex_lock(&wl->mutex); | ||
519 | if (wl->vif) { | ||
520 | ret = -EBUSY; | ||
521 | goto out; | ||
522 | } | ||
523 | |||
524 | wl->vif = vif; | ||
525 | |||
526 | switch (vif->type) { | ||
527 | case NL80211_IFTYPE_STATION: | ||
528 | wl->bss_type = BSS_TYPE_STA_BSS; | ||
529 | break; | ||
530 | case NL80211_IFTYPE_ADHOC: | ||
531 | wl->bss_type = BSS_TYPE_IBSS; | ||
532 | break; | ||
533 | default: | ||
534 | ret = -EOPNOTSUPP; | ||
535 | goto out; | ||
536 | } | ||
537 | |||
538 | if (memcmp(wl->mac_addr, vif->addr, ETH_ALEN)) { | ||
539 | memcpy(wl->mac_addr, vif->addr, ETH_ALEN); | ||
540 | SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr); | ||
541 | ret = wl1251_acx_station_id(wl); | ||
542 | if (ret < 0) | ||
543 | goto out; | ||
544 | } | ||
545 | |||
546 | out: | ||
547 | mutex_unlock(&wl->mutex); | ||
548 | return ret; | ||
549 | } | ||
550 | |||
551 | static void wl1251_op_remove_interface(struct ieee80211_hw *hw, | ||
552 | struct ieee80211_vif *vif) | ||
553 | { | ||
554 | struct wl1251 *wl = hw->priv; | ||
555 | |||
556 | mutex_lock(&wl->mutex); | ||
557 | wl1251_debug(DEBUG_MAC80211, "mac80211 remove interface"); | ||
558 | wl->vif = NULL; | ||
559 | mutex_unlock(&wl->mutex); | ||
560 | } | ||
561 | |||
562 | static int wl1251_build_qos_null_data(struct wl1251 *wl) | ||
563 | { | ||
564 | struct ieee80211_qos_hdr template; | ||
565 | |||
566 | memset(&template, 0, sizeof(template)); | ||
567 | |||
568 | memcpy(template.addr1, wl->bssid, ETH_ALEN); | ||
569 | memcpy(template.addr2, wl->mac_addr, ETH_ALEN); | ||
570 | memcpy(template.addr3, wl->bssid, ETH_ALEN); | ||
571 | |||
572 | template.frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | | ||
573 | IEEE80211_STYPE_QOS_NULLFUNC | | ||
574 | IEEE80211_FCTL_TODS); | ||
575 | |||
576 | /* FIXME: not sure what priority to use here */ | ||
577 | template.qos_ctrl = cpu_to_le16(0); | ||
578 | |||
579 | return wl1251_cmd_template_set(wl, CMD_QOS_NULL_DATA, &template, | ||
580 | sizeof(template)); | ||
581 | } | ||
582 | |||
583 | static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed) | ||
584 | { | ||
585 | struct wl1251 *wl = hw->priv; | ||
586 | struct ieee80211_conf *conf = &hw->conf; | ||
587 | int channel, ret = 0; | ||
588 | |||
589 | channel = ieee80211_frequency_to_channel(conf->channel->center_freq); | ||
590 | |||
591 | wl1251_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d", | ||
592 | channel, | ||
593 | conf->flags & IEEE80211_CONF_PS ? "on" : "off", | ||
594 | conf->power_level); | ||
595 | |||
596 | mutex_lock(&wl->mutex); | ||
597 | |||
598 | ret = wl1251_ps_elp_wakeup(wl); | ||
599 | if (ret < 0) | ||
600 | goto out; | ||
601 | |||
602 | if (channel != wl->channel) { | ||
603 | wl->channel = channel; | ||
604 | |||
605 | ret = wl1251_join(wl, wl->bss_type, wl->channel, | ||
606 | wl->beacon_int, wl->dtim_period); | ||
607 | if (ret < 0) | ||
608 | goto out_sleep; | ||
609 | } | ||
610 | |||
611 | if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) { | ||
612 | wl1251_debug(DEBUG_PSM, "psm enabled"); | ||
613 | |||
614 | wl->psm_requested = true; | ||
615 | |||
616 | wl->dtim_period = conf->ps_dtim_period; | ||
617 | |||
618 | ret = wl1251_acx_wr_tbtt_and_dtim(wl, wl->beacon_int, | ||
619 | wl->dtim_period); | ||
620 | |||
621 | /* | ||
622 | * mac80211 enables PSM only if we're already associated. | ||
623 | */ | ||
624 | ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE); | ||
625 | if (ret < 0) | ||
626 | goto out_sleep; | ||
627 | } else if (!(conf->flags & IEEE80211_CONF_PS) && | ||
628 | wl->psm_requested) { | ||
629 | wl1251_debug(DEBUG_PSM, "psm disabled"); | ||
630 | |||
631 | wl->psm_requested = false; | ||
632 | |||
633 | if (wl->psm) { | ||
634 | ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE); | ||
635 | if (ret < 0) | ||
636 | goto out_sleep; | ||
637 | } | ||
638 | } | ||
639 | |||
640 | if (conf->power_level != wl->power_level) { | ||
641 | ret = wl1251_acx_tx_power(wl, conf->power_level); | ||
642 | if (ret < 0) | ||
643 | goto out_sleep; | ||
644 | |||
645 | wl->power_level = conf->power_level; | ||
646 | } | ||
647 | |||
648 | out_sleep: | ||
649 | wl1251_ps_elp_sleep(wl); | ||
650 | |||
651 | out: | ||
652 | mutex_unlock(&wl->mutex); | ||
653 | |||
654 | return ret; | ||
655 | } | ||
656 | |||
657 | #define WL1251_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \ | ||
658 | FIF_ALLMULTI | \ | ||
659 | FIF_FCSFAIL | \ | ||
660 | FIF_BCN_PRBRESP_PROMISC | \ | ||
661 | FIF_CONTROL | \ | ||
662 | FIF_OTHER_BSS) | ||
663 | |||
664 | static void wl1251_op_configure_filter(struct ieee80211_hw *hw, | ||
665 | unsigned int changed, | ||
666 | unsigned int *total,u64 multicast) | ||
667 | { | ||
668 | struct wl1251 *wl = hw->priv; | ||
669 | |||
670 | wl1251_debug(DEBUG_MAC80211, "mac80211 configure filter"); | ||
671 | |||
672 | *total &= WL1251_SUPPORTED_FILTERS; | ||
673 | changed &= WL1251_SUPPORTED_FILTERS; | ||
674 | |||
675 | if (changed == 0) | ||
676 | /* no filters which we support changed */ | ||
677 | return; | ||
678 | |||
679 | /* FIXME: wl->rx_config and wl->rx_filter are not protected */ | ||
680 | |||
681 | wl->rx_config = WL1251_DEFAULT_RX_CONFIG; | ||
682 | wl->rx_filter = WL1251_DEFAULT_RX_FILTER; | ||
683 | |||
684 | if (*total & FIF_PROMISC_IN_BSS) { | ||
685 | wl->rx_config |= CFG_BSSID_FILTER_EN; | ||
686 | wl->rx_config |= CFG_RX_ALL_GOOD; | ||
687 | } | ||
688 | if (*total & FIF_ALLMULTI) | ||
689 | /* | ||
690 | * CFG_MC_FILTER_EN in rx_config needs to be 0 to receive | ||
691 | * all multicast frames | ||
692 | */ | ||
693 | wl->rx_config &= ~CFG_MC_FILTER_EN; | ||
694 | if (*total & FIF_FCSFAIL) | ||
695 | wl->rx_filter |= CFG_RX_FCS_ERROR; | ||
696 | if (*total & FIF_BCN_PRBRESP_PROMISC) { | ||
697 | wl->rx_config &= ~CFG_BSSID_FILTER_EN; | ||
698 | wl->rx_config &= ~CFG_SSID_FILTER_EN; | ||
699 | } | ||
700 | if (*total & FIF_CONTROL) | ||
701 | wl->rx_filter |= CFG_RX_CTL_EN; | ||
702 | if (*total & FIF_OTHER_BSS) | ||
703 | wl->rx_filter &= ~CFG_BSSID_FILTER_EN; | ||
704 | |||
705 | /* | ||
706 | * FIXME: workqueues need to be properly cancelled on stop(), for | ||
707 | * now let's just disable changing the filter settings. They will | ||
708 | * be updated any on config(). | ||
709 | */ | ||
710 | /* schedule_work(&wl->filter_work); */ | ||
711 | } | ||
712 | |||
713 | /* HW encryption */ | ||
714 | static int wl1251_set_key_type(struct wl1251 *wl, | ||
715 | struct wl1251_cmd_set_keys *key, | ||
716 | enum set_key_cmd cmd, | ||
717 | struct ieee80211_key_conf *mac80211_key, | ||
718 | const u8 *addr) | ||
719 | { | ||
720 | switch (mac80211_key->cipher) { | ||
721 | case WLAN_CIPHER_SUITE_WEP40: | ||
722 | case WLAN_CIPHER_SUITE_WEP104: | ||
723 | if (is_broadcast_ether_addr(addr)) | ||
724 | key->key_type = KEY_WEP_DEFAULT; | ||
725 | else | ||
726 | key->key_type = KEY_WEP_ADDR; | ||
727 | |||
728 | mac80211_key->hw_key_idx = mac80211_key->keyidx; | ||
729 | break; | ||
730 | case WLAN_CIPHER_SUITE_TKIP: | ||
731 | if (is_broadcast_ether_addr(addr)) | ||
732 | key->key_type = KEY_TKIP_MIC_GROUP; | ||
733 | else | ||
734 | key->key_type = KEY_TKIP_MIC_PAIRWISE; | ||
735 | |||
736 | mac80211_key->hw_key_idx = mac80211_key->keyidx; | ||
737 | break; | ||
738 | case WLAN_CIPHER_SUITE_CCMP: | ||
739 | if (is_broadcast_ether_addr(addr)) | ||
740 | key->key_type = KEY_AES_GROUP; | ||
741 | else | ||
742 | key->key_type = KEY_AES_PAIRWISE; | ||
743 | mac80211_key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | ||
744 | break; | ||
745 | default: | ||
746 | wl1251_error("Unknown key cipher 0x%x", mac80211_key->cipher); | ||
747 | return -EOPNOTSUPP; | ||
748 | } | ||
749 | |||
750 | return 0; | ||
751 | } | ||
752 | |||
753 | static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | ||
754 | struct ieee80211_vif *vif, | ||
755 | struct ieee80211_sta *sta, | ||
756 | struct ieee80211_key_conf *key) | ||
757 | { | ||
758 | struct wl1251 *wl = hw->priv; | ||
759 | struct wl1251_cmd_set_keys *wl_cmd; | ||
760 | const u8 *addr; | ||
761 | int ret; | ||
762 | |||
763 | static const u8 bcast_addr[ETH_ALEN] = | ||
764 | { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | ||
765 | |||
766 | wl1251_debug(DEBUG_MAC80211, "mac80211 set key"); | ||
767 | |||
768 | wl_cmd = kzalloc(sizeof(*wl_cmd), GFP_KERNEL); | ||
769 | if (!wl_cmd) { | ||
770 | ret = -ENOMEM; | ||
771 | goto out; | ||
772 | } | ||
773 | |||
774 | addr = sta ? sta->addr : bcast_addr; | ||
775 | |||
776 | wl1251_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd); | ||
777 | wl1251_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN); | ||
778 | wl1251_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x", | ||
779 | key->cipher, key->keyidx, key->keylen, key->flags); | ||
780 | wl1251_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen); | ||
781 | |||
782 | if (is_zero_ether_addr(addr)) { | ||
783 | /* We dont support TX only encryption */ | ||
784 | ret = -EOPNOTSUPP; | ||
785 | goto out; | ||
786 | } | ||
787 | |||
788 | mutex_lock(&wl->mutex); | ||
789 | |||
790 | ret = wl1251_ps_elp_wakeup(wl); | ||
791 | if (ret < 0) | ||
792 | goto out_unlock; | ||
793 | |||
794 | switch (cmd) { | ||
795 | case SET_KEY: | ||
796 | wl_cmd->key_action = KEY_ADD_OR_REPLACE; | ||
797 | break; | ||
798 | case DISABLE_KEY: | ||
799 | wl_cmd->key_action = KEY_REMOVE; | ||
800 | break; | ||
801 | default: | ||
802 | wl1251_error("Unsupported key cmd 0x%x", cmd); | ||
803 | break; | ||
804 | } | ||
805 | |||
806 | ret = wl1251_set_key_type(wl, wl_cmd, cmd, key, addr); | ||
807 | if (ret < 0) { | ||
808 | wl1251_error("Set KEY type failed"); | ||
809 | goto out_sleep; | ||
810 | } | ||
811 | |||
812 | if (wl_cmd->key_type != KEY_WEP_DEFAULT) | ||
813 | memcpy(wl_cmd->addr, addr, ETH_ALEN); | ||
814 | |||
815 | if ((wl_cmd->key_type == KEY_TKIP_MIC_GROUP) || | ||
816 | (wl_cmd->key_type == KEY_TKIP_MIC_PAIRWISE)) { | ||
817 | /* | ||
818 | * We get the key in the following form: | ||
819 | * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes) | ||
820 | * but the target is expecting: | ||
821 | * TKIP - RX MIC - TX MIC | ||
822 | */ | ||
823 | memcpy(wl_cmd->key, key->key, 16); | ||
824 | memcpy(wl_cmd->key + 16, key->key + 24, 8); | ||
825 | memcpy(wl_cmd->key + 24, key->key + 16, 8); | ||
826 | |||
827 | } else { | ||
828 | memcpy(wl_cmd->key, key->key, key->keylen); | ||
829 | } | ||
830 | wl_cmd->key_size = key->keylen; | ||
831 | |||
832 | wl_cmd->id = key->keyidx; | ||
833 | wl_cmd->ssid_profile = 0; | ||
834 | |||
835 | wl1251_dump(DEBUG_CRYPT, "TARGET KEY: ", wl_cmd, sizeof(*wl_cmd)); | ||
836 | |||
837 | ret = wl1251_cmd_send(wl, CMD_SET_KEYS, wl_cmd, sizeof(*wl_cmd)); | ||
838 | if (ret < 0) { | ||
839 | wl1251_warning("could not set keys"); | ||
840 | goto out_sleep; | ||
841 | } | ||
842 | |||
843 | out_sleep: | ||
844 | wl1251_ps_elp_sleep(wl); | ||
845 | |||
846 | out_unlock: | ||
847 | mutex_unlock(&wl->mutex); | ||
848 | |||
849 | out: | ||
850 | kfree(wl_cmd); | ||
851 | |||
852 | return ret; | ||
853 | } | ||
854 | |||
855 | static int wl1251_op_hw_scan(struct ieee80211_hw *hw, | ||
856 | struct ieee80211_vif *vif, | ||
857 | struct cfg80211_scan_request *req) | ||
858 | { | ||
859 | struct wl1251 *wl = hw->priv; | ||
860 | struct sk_buff *skb; | ||
861 | size_t ssid_len = 0; | ||
862 | u8 *ssid = NULL; | ||
863 | int ret; | ||
864 | |||
865 | wl1251_debug(DEBUG_MAC80211, "mac80211 hw scan"); | ||
866 | |||
867 | if (req->n_ssids) { | ||
868 | ssid = req->ssids[0].ssid; | ||
869 | ssid_len = req->ssids[0].ssid_len; | ||
870 | } | ||
871 | |||
872 | mutex_lock(&wl->mutex); | ||
873 | |||
874 | if (wl->scanning) { | ||
875 | wl1251_debug(DEBUG_SCAN, "scan already in progress"); | ||
876 | ret = -EINVAL; | ||
877 | goto out; | ||
878 | } | ||
879 | |||
880 | ret = wl1251_ps_elp_wakeup(wl); | ||
881 | if (ret < 0) | ||
882 | goto out; | ||
883 | |||
884 | skb = ieee80211_probereq_get(wl->hw, wl->vif, ssid, ssid_len, | ||
885 | req->ie, req->ie_len); | ||
886 | if (!skb) { | ||
887 | ret = -ENOMEM; | ||
888 | goto out; | ||
889 | } | ||
890 | |||
891 | ret = wl1251_cmd_template_set(wl, CMD_PROBE_REQ, skb->data, | ||
892 | skb->len); | ||
893 | dev_kfree_skb(skb); | ||
894 | if (ret < 0) | ||
895 | goto out_sleep; | ||
896 | |||
897 | ret = wl1251_cmd_trigger_scan_to(wl, 0); | ||
898 | if (ret < 0) | ||
899 | goto out_sleep; | ||
900 | |||
901 | wl->scanning = true; | ||
902 | |||
903 | ret = wl1251_cmd_scan(wl, ssid, ssid_len, req->channels, | ||
904 | req->n_channels, WL1251_SCAN_NUM_PROBES); | ||
905 | if (ret < 0) { | ||
906 | wl->scanning = false; | ||
907 | goto out_sleep; | ||
908 | } | ||
909 | |||
910 | out_sleep: | ||
911 | wl1251_ps_elp_sleep(wl); | ||
912 | |||
913 | out: | ||
914 | mutex_unlock(&wl->mutex); | ||
915 | |||
916 | return ret; | ||
917 | } | ||
918 | |||
919 | static int wl1251_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) | ||
920 | { | ||
921 | struct wl1251 *wl = hw->priv; | ||
922 | int ret; | ||
923 | |||
924 | mutex_lock(&wl->mutex); | ||
925 | |||
926 | ret = wl1251_ps_elp_wakeup(wl); | ||
927 | if (ret < 0) | ||
928 | goto out; | ||
929 | |||
930 | ret = wl1251_acx_rts_threshold(wl, (u16) value); | ||
931 | if (ret < 0) | ||
932 | wl1251_warning("wl1251_op_set_rts_threshold failed: %d", ret); | ||
933 | |||
934 | wl1251_ps_elp_sleep(wl); | ||
935 | |||
936 | out: | ||
937 | mutex_unlock(&wl->mutex); | ||
938 | |||
939 | return ret; | ||
940 | } | ||
941 | |||
942 | static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw, | ||
943 | struct ieee80211_vif *vif, | ||
944 | struct ieee80211_bss_conf *bss_conf, | ||
945 | u32 changed) | ||
946 | { | ||
947 | struct wl1251 *wl = hw->priv; | ||
948 | struct sk_buff *beacon, *skb; | ||
949 | int ret; | ||
950 | |||
951 | wl1251_debug(DEBUG_MAC80211, "mac80211 bss info changed"); | ||
952 | |||
953 | mutex_lock(&wl->mutex); | ||
954 | |||
955 | ret = wl1251_ps_elp_wakeup(wl); | ||
956 | if (ret < 0) | ||
957 | goto out; | ||
958 | |||
959 | if (changed & BSS_CHANGED_BSSID) { | ||
960 | memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); | ||
961 | |||
962 | skb = ieee80211_nullfunc_get(wl->hw, wl->vif); | ||
963 | if (!skb) | ||
964 | goto out_sleep; | ||
965 | |||
966 | ret = wl1251_cmd_template_set(wl, CMD_NULL_DATA, | ||
967 | skb->data, skb->len); | ||
968 | dev_kfree_skb(skb); | ||
969 | if (ret < 0) | ||
970 | goto out_sleep; | ||
971 | |||
972 | ret = wl1251_build_qos_null_data(wl); | ||
973 | if (ret < 0) | ||
974 | goto out; | ||
975 | |||
976 | if (wl->bss_type != BSS_TYPE_IBSS) { | ||
977 | ret = wl1251_join(wl, wl->bss_type, wl->channel, | ||
978 | wl->beacon_int, wl->dtim_period); | ||
979 | if (ret < 0) | ||
980 | goto out_sleep; | ||
981 | } | ||
982 | } | ||
983 | |||
984 | if (changed & BSS_CHANGED_ASSOC) { | ||
985 | if (bss_conf->assoc) { | ||
986 | wl->beacon_int = bss_conf->beacon_int; | ||
987 | |||
988 | skb = ieee80211_pspoll_get(wl->hw, wl->vif); | ||
989 | if (!skb) | ||
990 | goto out_sleep; | ||
991 | |||
992 | ret = wl1251_cmd_template_set(wl, CMD_PS_POLL, | ||
993 | skb->data, | ||
994 | skb->len); | ||
995 | dev_kfree_skb(skb); | ||
996 | if (ret < 0) | ||
997 | goto out_sleep; | ||
998 | |||
999 | ret = wl1251_acx_aid(wl, bss_conf->aid); | ||
1000 | if (ret < 0) | ||
1001 | goto out_sleep; | ||
1002 | } else { | ||
1003 | /* use defaults when not associated */ | ||
1004 | wl->beacon_int = WL1251_DEFAULT_BEACON_INT; | ||
1005 | wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD; | ||
1006 | } | ||
1007 | } | ||
1008 | if (changed & BSS_CHANGED_ERP_SLOT) { | ||
1009 | if (bss_conf->use_short_slot) | ||
1010 | ret = wl1251_acx_slot(wl, SLOT_TIME_SHORT); | ||
1011 | else | ||
1012 | ret = wl1251_acx_slot(wl, SLOT_TIME_LONG); | ||
1013 | if (ret < 0) { | ||
1014 | wl1251_warning("Set slot time failed %d", ret); | ||
1015 | goto out_sleep; | ||
1016 | } | ||
1017 | } | ||
1018 | |||
1019 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { | ||
1020 | if (bss_conf->use_short_preamble) | ||
1021 | wl1251_acx_set_preamble(wl, ACX_PREAMBLE_SHORT); | ||
1022 | else | ||
1023 | wl1251_acx_set_preamble(wl, ACX_PREAMBLE_LONG); | ||
1024 | } | ||
1025 | |||
1026 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { | ||
1027 | if (bss_conf->use_cts_prot) | ||
1028 | ret = wl1251_acx_cts_protect(wl, CTSPROTECT_ENABLE); | ||
1029 | else | ||
1030 | ret = wl1251_acx_cts_protect(wl, CTSPROTECT_DISABLE); | ||
1031 | if (ret < 0) { | ||
1032 | wl1251_warning("Set ctsprotect failed %d", ret); | ||
1033 | goto out_sleep; | ||
1034 | } | ||
1035 | } | ||
1036 | |||
1037 | if (changed & BSS_CHANGED_BEACON) { | ||
1038 | beacon = ieee80211_beacon_get(hw, vif); | ||
1039 | ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data, | ||
1040 | beacon->len); | ||
1041 | |||
1042 | if (ret < 0) { | ||
1043 | dev_kfree_skb(beacon); | ||
1044 | goto out_sleep; | ||
1045 | } | ||
1046 | |||
1047 | ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, beacon->data, | ||
1048 | beacon->len); | ||
1049 | |||
1050 | dev_kfree_skb(beacon); | ||
1051 | |||
1052 | if (ret < 0) | ||
1053 | goto out_sleep; | ||
1054 | |||
1055 | ret = wl1251_join(wl, wl->bss_type, wl->beacon_int, | ||
1056 | wl->channel, wl->dtim_period); | ||
1057 | |||
1058 | if (ret < 0) | ||
1059 | goto out_sleep; | ||
1060 | } | ||
1061 | |||
1062 | out_sleep: | ||
1063 | wl1251_ps_elp_sleep(wl); | ||
1064 | |||
1065 | out: | ||
1066 | mutex_unlock(&wl->mutex); | ||
1067 | } | ||
1068 | |||
1069 | |||
1070 | /* can't be const, mac80211 writes to this */ | ||
1071 | static struct ieee80211_rate wl1251_rates[] = { | ||
1072 | { .bitrate = 10, | ||
1073 | .hw_value = 0x1, | ||
1074 | .hw_value_short = 0x1, }, | ||
1075 | { .bitrate = 20, | ||
1076 | .hw_value = 0x2, | ||
1077 | .hw_value_short = 0x2, | ||
1078 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
1079 | { .bitrate = 55, | ||
1080 | .hw_value = 0x4, | ||
1081 | .hw_value_short = 0x4, | ||
1082 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
1083 | { .bitrate = 110, | ||
1084 | .hw_value = 0x20, | ||
1085 | .hw_value_short = 0x20, | ||
1086 | .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
1087 | { .bitrate = 60, | ||
1088 | .hw_value = 0x8, | ||
1089 | .hw_value_short = 0x8, }, | ||
1090 | { .bitrate = 90, | ||
1091 | .hw_value = 0x10, | ||
1092 | .hw_value_short = 0x10, }, | ||
1093 | { .bitrate = 120, | ||
1094 | .hw_value = 0x40, | ||
1095 | .hw_value_short = 0x40, }, | ||
1096 | { .bitrate = 180, | ||
1097 | .hw_value = 0x80, | ||
1098 | .hw_value_short = 0x80, }, | ||
1099 | { .bitrate = 240, | ||
1100 | .hw_value = 0x200, | ||
1101 | .hw_value_short = 0x200, }, | ||
1102 | { .bitrate = 360, | ||
1103 | .hw_value = 0x400, | ||
1104 | .hw_value_short = 0x400, }, | ||
1105 | { .bitrate = 480, | ||
1106 | .hw_value = 0x800, | ||
1107 | .hw_value_short = 0x800, }, | ||
1108 | { .bitrate = 540, | ||
1109 | .hw_value = 0x1000, | ||
1110 | .hw_value_short = 0x1000, }, | ||
1111 | }; | ||
1112 | |||
1113 | /* can't be const, mac80211 writes to this */ | ||
1114 | static struct ieee80211_channel wl1251_channels[] = { | ||
1115 | { .hw_value = 1, .center_freq = 2412}, | ||
1116 | { .hw_value = 2, .center_freq = 2417}, | ||
1117 | { .hw_value = 3, .center_freq = 2422}, | ||
1118 | { .hw_value = 4, .center_freq = 2427}, | ||
1119 | { .hw_value = 5, .center_freq = 2432}, | ||
1120 | { .hw_value = 6, .center_freq = 2437}, | ||
1121 | { .hw_value = 7, .center_freq = 2442}, | ||
1122 | { .hw_value = 8, .center_freq = 2447}, | ||
1123 | { .hw_value = 9, .center_freq = 2452}, | ||
1124 | { .hw_value = 10, .center_freq = 2457}, | ||
1125 | { .hw_value = 11, .center_freq = 2462}, | ||
1126 | { .hw_value = 12, .center_freq = 2467}, | ||
1127 | { .hw_value = 13, .center_freq = 2472}, | ||
1128 | }; | ||
1129 | |||
1130 | static int wl1251_op_conf_tx(struct ieee80211_hw *hw, u16 queue, | ||
1131 | const struct ieee80211_tx_queue_params *params) | ||
1132 | { | ||
1133 | enum wl1251_acx_ps_scheme ps_scheme; | ||
1134 | struct wl1251 *wl = hw->priv; | ||
1135 | int ret; | ||
1136 | |||
1137 | mutex_lock(&wl->mutex); | ||
1138 | |||
1139 | wl1251_debug(DEBUG_MAC80211, "mac80211 conf tx %d", queue); | ||
1140 | |||
1141 | ret = wl1251_ps_elp_wakeup(wl); | ||
1142 | if (ret < 0) | ||
1143 | goto out; | ||
1144 | |||
1145 | /* mac80211 uses units of 32 usec */ | ||
1146 | ret = wl1251_acx_ac_cfg(wl, wl1251_tx_get_queue(queue), | ||
1147 | params->cw_min, params->cw_max, | ||
1148 | params->aifs, params->txop * 32); | ||
1149 | if (ret < 0) | ||
1150 | goto out_sleep; | ||
1151 | |||
1152 | if (params->uapsd) | ||
1153 | ps_scheme = WL1251_ACX_PS_SCHEME_UPSD_TRIGGER; | ||
1154 | else | ||
1155 | ps_scheme = WL1251_ACX_PS_SCHEME_LEGACY; | ||
1156 | |||
1157 | ret = wl1251_acx_tid_cfg(wl, wl1251_tx_get_queue(queue), | ||
1158 | CHANNEL_TYPE_EDCF, | ||
1159 | wl1251_tx_get_queue(queue), ps_scheme, | ||
1160 | WL1251_ACX_ACK_POLICY_LEGACY); | ||
1161 | if (ret < 0) | ||
1162 | goto out_sleep; | ||
1163 | |||
1164 | out_sleep: | ||
1165 | wl1251_ps_elp_sleep(wl); | ||
1166 | |||
1167 | out: | ||
1168 | mutex_unlock(&wl->mutex); | ||
1169 | |||
1170 | return ret; | ||
1171 | } | ||
1172 | |||
1173 | static int wl1251_op_get_survey(struct ieee80211_hw *hw, int idx, | ||
1174 | struct survey_info *survey) | ||
1175 | { | ||
1176 | struct wl1251 *wl = hw->priv; | ||
1177 | struct ieee80211_conf *conf = &hw->conf; | ||
1178 | |||
1179 | if (idx != 0) | ||
1180 | return -ENOENT; | ||
1181 | |||
1182 | survey->channel = conf->channel; | ||
1183 | survey->filled = SURVEY_INFO_NOISE_DBM; | ||
1184 | survey->noise = wl->noise; | ||
1185 | |||
1186 | return 0; | ||
1187 | } | ||
1188 | |||
1189 | /* can't be const, mac80211 writes to this */ | ||
1190 | static struct ieee80211_supported_band wl1251_band_2ghz = { | ||
1191 | .channels = wl1251_channels, | ||
1192 | .n_channels = ARRAY_SIZE(wl1251_channels), | ||
1193 | .bitrates = wl1251_rates, | ||
1194 | .n_bitrates = ARRAY_SIZE(wl1251_rates), | ||
1195 | }; | ||
1196 | |||
1197 | static const struct ieee80211_ops wl1251_ops = { | ||
1198 | .start = wl1251_op_start, | ||
1199 | .stop = wl1251_op_stop, | ||
1200 | .add_interface = wl1251_op_add_interface, | ||
1201 | .remove_interface = wl1251_op_remove_interface, | ||
1202 | .config = wl1251_op_config, | ||
1203 | .configure_filter = wl1251_op_configure_filter, | ||
1204 | .tx = wl1251_op_tx, | ||
1205 | .set_key = wl1251_op_set_key, | ||
1206 | .hw_scan = wl1251_op_hw_scan, | ||
1207 | .bss_info_changed = wl1251_op_bss_info_changed, | ||
1208 | .set_rts_threshold = wl1251_op_set_rts_threshold, | ||
1209 | .conf_tx = wl1251_op_conf_tx, | ||
1210 | .get_survey = wl1251_op_get_survey, | ||
1211 | }; | ||
1212 | |||
1213 | static int wl1251_read_eeprom_byte(struct wl1251 *wl, off_t offset, u8 *data) | ||
1214 | { | ||
1215 | unsigned long timeout; | ||
1216 | |||
1217 | wl1251_reg_write32(wl, EE_ADDR, offset); | ||
1218 | wl1251_reg_write32(wl, EE_CTL, EE_CTL_READ); | ||
1219 | |||
1220 | /* EE_CTL_READ clears when data is ready */ | ||
1221 | timeout = jiffies + msecs_to_jiffies(100); | ||
1222 | while (1) { | ||
1223 | if (!(wl1251_reg_read32(wl, EE_CTL) & EE_CTL_READ)) | ||
1224 | break; | ||
1225 | |||
1226 | if (time_after(jiffies, timeout)) | ||
1227 | return -ETIMEDOUT; | ||
1228 | |||
1229 | msleep(1); | ||
1230 | } | ||
1231 | |||
1232 | *data = wl1251_reg_read32(wl, EE_DATA); | ||
1233 | return 0; | ||
1234 | } | ||
1235 | |||
1236 | static int wl1251_read_eeprom(struct wl1251 *wl, off_t offset, | ||
1237 | u8 *data, size_t len) | ||
1238 | { | ||
1239 | size_t i; | ||
1240 | int ret; | ||
1241 | |||
1242 | wl1251_reg_write32(wl, EE_START, 0); | ||
1243 | |||
1244 | for (i = 0; i < len; i++) { | ||
1245 | ret = wl1251_read_eeprom_byte(wl, offset + i, &data[i]); | ||
1246 | if (ret < 0) | ||
1247 | return ret; | ||
1248 | } | ||
1249 | |||
1250 | return 0; | ||
1251 | } | ||
1252 | |||
1253 | static int wl1251_read_eeprom_mac(struct wl1251 *wl) | ||
1254 | { | ||
1255 | u8 mac[ETH_ALEN]; | ||
1256 | int i, ret; | ||
1257 | |||
1258 | wl1251_set_partition(wl, 0, 0, REGISTERS_BASE, REGISTERS_DOWN_SIZE); | ||
1259 | |||
1260 | ret = wl1251_read_eeprom(wl, 0x1c, mac, sizeof(mac)); | ||
1261 | if (ret < 0) { | ||
1262 | wl1251_warning("failed to read MAC address from EEPROM"); | ||
1263 | return ret; | ||
1264 | } | ||
1265 | |||
1266 | /* MAC is stored in reverse order */ | ||
1267 | for (i = 0; i < ETH_ALEN; i++) | ||
1268 | wl->mac_addr[i] = mac[ETH_ALEN - i - 1]; | ||
1269 | |||
1270 | return 0; | ||
1271 | } | ||
1272 | |||
1273 | static int wl1251_register_hw(struct wl1251 *wl) | ||
1274 | { | ||
1275 | int ret; | ||
1276 | |||
1277 | if (wl->mac80211_registered) | ||
1278 | return 0; | ||
1279 | |||
1280 | SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr); | ||
1281 | |||
1282 | ret = ieee80211_register_hw(wl->hw); | ||
1283 | if (ret < 0) { | ||
1284 | wl1251_error("unable to register mac80211 hw: %d", ret); | ||
1285 | return ret; | ||
1286 | } | ||
1287 | |||
1288 | wl->mac80211_registered = true; | ||
1289 | |||
1290 | wl1251_notice("loaded"); | ||
1291 | |||
1292 | return 0; | ||
1293 | } | ||
1294 | |||
1295 | int wl1251_init_ieee80211(struct wl1251 *wl) | ||
1296 | { | ||
1297 | int ret; | ||
1298 | |||
1299 | /* The tx descriptor buffer and the TKIP space */ | ||
1300 | wl->hw->extra_tx_headroom = sizeof(struct tx_double_buffer_desc) | ||
1301 | + WL1251_TKIP_IV_SPACE; | ||
1302 | |||
1303 | /* unit us */ | ||
1304 | /* FIXME: find a proper value */ | ||
1305 | wl->hw->channel_change_time = 10000; | ||
1306 | |||
1307 | wl->hw->flags = IEEE80211_HW_SIGNAL_DBM | | ||
1308 | IEEE80211_HW_SUPPORTS_PS | | ||
1309 | IEEE80211_HW_BEACON_FILTER | | ||
1310 | IEEE80211_HW_SUPPORTS_UAPSD; | ||
1311 | |||
1312 | wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); | ||
1313 | wl->hw->wiphy->max_scan_ssids = 1; | ||
1314 | wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl1251_band_2ghz; | ||
1315 | |||
1316 | wl->hw->queues = 4; | ||
1317 | |||
1318 | if (wl->use_eeprom) | ||
1319 | wl1251_read_eeprom_mac(wl); | ||
1320 | |||
1321 | ret = wl1251_register_hw(wl); | ||
1322 | if (ret) | ||
1323 | goto out; | ||
1324 | |||
1325 | wl1251_debugfs_init(wl); | ||
1326 | wl1251_notice("initialized"); | ||
1327 | |||
1328 | ret = 0; | ||
1329 | |||
1330 | out: | ||
1331 | return ret; | ||
1332 | } | ||
1333 | EXPORT_SYMBOL_GPL(wl1251_init_ieee80211); | ||
1334 | |||
1335 | struct ieee80211_hw *wl1251_alloc_hw(void) | ||
1336 | { | ||
1337 | struct ieee80211_hw *hw; | ||
1338 | struct wl1251 *wl; | ||
1339 | int i; | ||
1340 | static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; | ||
1341 | |||
1342 | hw = ieee80211_alloc_hw(sizeof(*wl), &wl1251_ops); | ||
1343 | if (!hw) { | ||
1344 | wl1251_error("could not alloc ieee80211_hw"); | ||
1345 | return ERR_PTR(-ENOMEM); | ||
1346 | } | ||
1347 | |||
1348 | wl = hw->priv; | ||
1349 | memset(wl, 0, sizeof(*wl)); | ||
1350 | |||
1351 | wl->hw = hw; | ||
1352 | |||
1353 | wl->data_in_count = 0; | ||
1354 | |||
1355 | skb_queue_head_init(&wl->tx_queue); | ||
1356 | |||
1357 | INIT_WORK(&wl->filter_work, wl1251_filter_work); | ||
1358 | INIT_DELAYED_WORK(&wl->elp_work, wl1251_elp_work); | ||
1359 | wl->channel = WL1251_DEFAULT_CHANNEL; | ||
1360 | wl->scanning = false; | ||
1361 | wl->default_key = 0; | ||
1362 | wl->listen_int = 1; | ||
1363 | wl->rx_counter = 0; | ||
1364 | wl->rx_handled = 0; | ||
1365 | wl->rx_current_buffer = 0; | ||
1366 | wl->rx_last_id = 0; | ||
1367 | wl->rx_config = WL1251_DEFAULT_RX_CONFIG; | ||
1368 | wl->rx_filter = WL1251_DEFAULT_RX_FILTER; | ||
1369 | wl->elp = false; | ||
1370 | wl->psm = 0; | ||
1371 | wl->psm_requested = false; | ||
1372 | wl->tx_queue_stopped = false; | ||
1373 | wl->power_level = WL1251_DEFAULT_POWER_LEVEL; | ||
1374 | wl->beacon_int = WL1251_DEFAULT_BEACON_INT; | ||
1375 | wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD; | ||
1376 | wl->vif = NULL; | ||
1377 | |||
1378 | for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++) | ||
1379 | wl->tx_frames[i] = NULL; | ||
1380 | |||
1381 | wl->next_tx_complete = 0; | ||
1382 | |||
1383 | INIT_WORK(&wl->irq_work, wl1251_irq_work); | ||
1384 | INIT_WORK(&wl->tx_work, wl1251_tx_work); | ||
1385 | |||
1386 | /* | ||
1387 | * In case our MAC address is not correctly set, | ||
1388 | * we use a random but Nokia MAC. | ||
1389 | */ | ||
1390 | memcpy(wl->mac_addr, nokia_oui, 3); | ||
1391 | get_random_bytes(wl->mac_addr + 3, 3); | ||
1392 | |||
1393 | wl->state = WL1251_STATE_OFF; | ||
1394 | mutex_init(&wl->mutex); | ||
1395 | |||
1396 | wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE; | ||
1397 | wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE; | ||
1398 | |||
1399 | wl->rx_descriptor = kmalloc(sizeof(*wl->rx_descriptor), GFP_KERNEL); | ||
1400 | if (!wl->rx_descriptor) { | ||
1401 | wl1251_error("could not allocate memory for rx descriptor"); | ||
1402 | ieee80211_free_hw(hw); | ||
1403 | return ERR_PTR(-ENOMEM); | ||
1404 | } | ||
1405 | |||
1406 | return hw; | ||
1407 | } | ||
1408 | EXPORT_SYMBOL_GPL(wl1251_alloc_hw); | ||
1409 | |||
1410 | int wl1251_free_hw(struct wl1251 *wl) | ||
1411 | { | ||
1412 | ieee80211_unregister_hw(wl->hw); | ||
1413 | |||
1414 | wl1251_debugfs_exit(wl); | ||
1415 | |||
1416 | kfree(wl->target_mem_map); | ||
1417 | kfree(wl->data_path); | ||
1418 | vfree(wl->fw); | ||
1419 | wl->fw = NULL; | ||
1420 | kfree(wl->nvs); | ||
1421 | wl->nvs = NULL; | ||
1422 | |||
1423 | kfree(wl->rx_descriptor); | ||
1424 | wl->rx_descriptor = NULL; | ||
1425 | |||
1426 | ieee80211_free_hw(wl->hw); | ||
1427 | |||
1428 | return 0; | ||
1429 | } | ||
1430 | EXPORT_SYMBOL_GPL(wl1251_free_hw); | ||
1431 | |||
1432 | MODULE_DESCRIPTION("TI wl1251 Wireles LAN Driver Core"); | ||
1433 | MODULE_LICENSE("GPL"); | ||
1434 | MODULE_AUTHOR("Kalle Valo <kvalo@adurom.com>"); | ||
1435 | MODULE_FIRMWARE(WL1251_FW_NAME); | ||
diff --git a/drivers/net/wireless/wl1251/ps.c b/drivers/net/wireless/wl1251/ps.c new file mode 100644 index 000000000000..5ed47c8373d2 --- /dev/null +++ b/drivers/net/wireless/wl1251/ps.c | |||
@@ -0,0 +1,194 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include "reg.h" | ||
23 | #include "ps.h" | ||
24 | #include "cmd.h" | ||
25 | #include "io.h" | ||
26 | |||
27 | /* in ms */ | ||
28 | #define WL1251_WAKEUP_TIMEOUT 100 | ||
29 | |||
30 | void wl1251_elp_work(struct work_struct *work) | ||
31 | { | ||
32 | struct delayed_work *dwork; | ||
33 | struct wl1251 *wl; | ||
34 | |||
35 | dwork = container_of(work, struct delayed_work, work); | ||
36 | wl = container_of(dwork, struct wl1251, elp_work); | ||
37 | |||
38 | wl1251_debug(DEBUG_PSM, "elp work"); | ||
39 | |||
40 | mutex_lock(&wl->mutex); | ||
41 | |||
42 | if (wl->elp || !wl->psm) | ||
43 | goto out; | ||
44 | |||
45 | wl1251_debug(DEBUG_PSM, "chip to elp"); | ||
46 | wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); | ||
47 | wl->elp = true; | ||
48 | |||
49 | out: | ||
50 | mutex_unlock(&wl->mutex); | ||
51 | } | ||
52 | |||
53 | #define ELP_ENTRY_DELAY 5 | ||
54 | |||
55 | /* Routines to toggle sleep mode while in ELP */ | ||
56 | void wl1251_ps_elp_sleep(struct wl1251 *wl) | ||
57 | { | ||
58 | unsigned long delay; | ||
59 | |||
60 | if (wl->psm) { | ||
61 | cancel_delayed_work(&wl->elp_work); | ||
62 | delay = msecs_to_jiffies(ELP_ENTRY_DELAY); | ||
63 | ieee80211_queue_delayed_work(wl->hw, &wl->elp_work, delay); | ||
64 | } | ||
65 | } | ||
66 | |||
67 | int wl1251_ps_elp_wakeup(struct wl1251 *wl) | ||
68 | { | ||
69 | unsigned long timeout, start; | ||
70 | u32 elp_reg; | ||
71 | |||
72 | if (!wl->elp) | ||
73 | return 0; | ||
74 | |||
75 | wl1251_debug(DEBUG_PSM, "waking up chip from elp"); | ||
76 | |||
77 | start = jiffies; | ||
78 | timeout = jiffies + msecs_to_jiffies(WL1251_WAKEUP_TIMEOUT); | ||
79 | |||
80 | wl1251_write_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP); | ||
81 | |||
82 | elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); | ||
83 | |||
84 | /* | ||
85 | * FIXME: we should wait for irq from chip but, as a temporary | ||
86 | * solution to simplify locking, let's poll instead | ||
87 | */ | ||
88 | while (!(elp_reg & ELPCTRL_WLAN_READY)) { | ||
89 | if (time_after(jiffies, timeout)) { | ||
90 | wl1251_error("elp wakeup timeout"); | ||
91 | return -ETIMEDOUT; | ||
92 | } | ||
93 | msleep(1); | ||
94 | elp_reg = wl1251_read_elp(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); | ||
95 | } | ||
96 | |||
97 | wl1251_debug(DEBUG_PSM, "wakeup time: %u ms", | ||
98 | jiffies_to_msecs(jiffies - start)); | ||
99 | |||
100 | wl->elp = false; | ||
101 | |||
102 | return 0; | ||
103 | } | ||
104 | |||
105 | static int wl1251_ps_set_elp(struct wl1251 *wl, bool enable) | ||
106 | { | ||
107 | int ret; | ||
108 | |||
109 | if (enable) { | ||
110 | wl1251_debug(DEBUG_PSM, "sleep auth psm/elp"); | ||
111 | |||
112 | ret = wl1251_acx_sleep_auth(wl, WL1251_PSM_ELP); | ||
113 | if (ret < 0) | ||
114 | return ret; | ||
115 | |||
116 | wl1251_ps_elp_sleep(wl); | ||
117 | } else { | ||
118 | wl1251_debug(DEBUG_PSM, "sleep auth cam"); | ||
119 | |||
120 | /* | ||
121 | * When the target is in ELP, we can only | ||
122 | * access the ELP control register. Thus, | ||
123 | * we have to wake the target up before | ||
124 | * changing the power authorization. | ||
125 | */ | ||
126 | |||
127 | wl1251_ps_elp_wakeup(wl); | ||
128 | |||
129 | ret = wl1251_acx_sleep_auth(wl, WL1251_PSM_CAM); | ||
130 | if (ret < 0) | ||
131 | return ret; | ||
132 | } | ||
133 | |||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode) | ||
138 | { | ||
139 | int ret; | ||
140 | |||
141 | switch (mode) { | ||
142 | case STATION_POWER_SAVE_MODE: | ||
143 | wl1251_debug(DEBUG_PSM, "entering psm"); | ||
144 | |||
145 | /* enable beacon filtering */ | ||
146 | ret = wl1251_acx_beacon_filter_opt(wl, true); | ||
147 | if (ret < 0) | ||
148 | return ret; | ||
149 | |||
150 | ret = wl1251_acx_wake_up_conditions(wl, | ||
151 | WAKE_UP_EVENT_DTIM_BITMAP, | ||
152 | wl->listen_int); | ||
153 | if (ret < 0) | ||
154 | return ret; | ||
155 | |||
156 | ret = wl1251_cmd_ps_mode(wl, STATION_POWER_SAVE_MODE); | ||
157 | if (ret < 0) | ||
158 | return ret; | ||
159 | |||
160 | ret = wl1251_ps_set_elp(wl, true); | ||
161 | if (ret < 0) | ||
162 | return ret; | ||
163 | |||
164 | wl->psm = 1; | ||
165 | break; | ||
166 | case STATION_ACTIVE_MODE: | ||
167 | default: | ||
168 | wl1251_debug(DEBUG_PSM, "leaving psm"); | ||
169 | ret = wl1251_ps_set_elp(wl, false); | ||
170 | if (ret < 0) | ||
171 | return ret; | ||
172 | |||
173 | /* disable beacon filtering */ | ||
174 | ret = wl1251_acx_beacon_filter_opt(wl, false); | ||
175 | if (ret < 0) | ||
176 | return ret; | ||
177 | |||
178 | ret = wl1251_acx_wake_up_conditions(wl, | ||
179 | WAKE_UP_EVENT_DTIM_BITMAP, | ||
180 | wl->listen_int); | ||
181 | if (ret < 0) | ||
182 | return ret; | ||
183 | |||
184 | ret = wl1251_cmd_ps_mode(wl, STATION_ACTIVE_MODE); | ||
185 | if (ret < 0) | ||
186 | return ret; | ||
187 | |||
188 | wl->psm = 0; | ||
189 | break; | ||
190 | } | ||
191 | |||
192 | return ret; | ||
193 | } | ||
194 | |||
diff --git a/drivers/net/wireless/wl1251/ps.h b/drivers/net/wireless/wl1251/ps.h new file mode 100644 index 000000000000..55c3dda75e69 --- /dev/null +++ b/drivers/net/wireless/wl1251/ps.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __WL1251_PS_H__ | ||
24 | #define __WL1251_PS_H__ | ||
25 | |||
26 | #include "wl1251.h" | ||
27 | #include "acx.h" | ||
28 | |||
29 | int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode); | ||
30 | void wl1251_ps_elp_sleep(struct wl1251 *wl); | ||
31 | int wl1251_ps_elp_wakeup(struct wl1251 *wl); | ||
32 | void wl1251_elp_work(struct work_struct *work); | ||
33 | |||
34 | |||
35 | #endif /* __WL1251_PS_H__ */ | ||
diff --git a/drivers/net/wireless/wl1251/reg.h b/drivers/net/wireless/wl1251/reg.h new file mode 100644 index 000000000000..a5809019c5c1 --- /dev/null +++ b/drivers/net/wireless/wl1251/reg.h | |||
@@ -0,0 +1,655 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __REG_H__ | ||
24 | #define __REG_H__ | ||
25 | |||
26 | #include <linux/bitops.h> | ||
27 | |||
28 | #define REGISTERS_BASE 0x00300000 | ||
29 | #define DRPW_BASE 0x00310000 | ||
30 | |||
31 | #define REGISTERS_DOWN_SIZE 0x00008800 | ||
32 | #define REGISTERS_WORK_SIZE 0x0000b000 | ||
33 | |||
34 | #define HW_ACCESS_ELP_CTRL_REG_ADDR 0x1FFFC | ||
35 | |||
36 | /* ELP register commands */ | ||
37 | #define ELPCTRL_WAKE_UP 0x1 | ||
38 | #define ELPCTRL_WAKE_UP_WLAN_READY 0x5 | ||
39 | #define ELPCTRL_SLEEP 0x0 | ||
40 | /* ELP WLAN_READY bit */ | ||
41 | #define ELPCTRL_WLAN_READY 0x2 | ||
42 | |||
43 | /* Device Configuration registers*/ | ||
44 | #define SOR_CFG (REGISTERS_BASE + 0x0800) | ||
45 | #define ECPU_CTRL (REGISTERS_BASE + 0x0804) | ||
46 | #define HI_CFG (REGISTERS_BASE + 0x0808) | ||
47 | |||
48 | /* EEPROM registers */ | ||
49 | #define EE_START (REGISTERS_BASE + 0x080C) | ||
50 | #define EE_CTL (REGISTERS_BASE + 0x2000) | ||
51 | #define EE_DATA (REGISTERS_BASE + 0x2004) | ||
52 | #define EE_ADDR (REGISTERS_BASE + 0x2008) | ||
53 | |||
54 | #define EE_CTL_READ 2 | ||
55 | |||
56 | #define CHIP_ID_B (REGISTERS_BASE + 0x5674) | ||
57 | |||
58 | #define CHIP_ID_1251_PG10 (0x7010101) | ||
59 | #define CHIP_ID_1251_PG11 (0x7020101) | ||
60 | #define CHIP_ID_1251_PG12 (0x7030101) | ||
61 | |||
62 | #define ENABLE (REGISTERS_BASE + 0x5450) | ||
63 | |||
64 | /* Power Management registers */ | ||
65 | #define ELP_CFG_MODE (REGISTERS_BASE + 0x5804) | ||
66 | #define ELP_CMD (REGISTERS_BASE + 0x5808) | ||
67 | #define PLL_CAL_TIME (REGISTERS_BASE + 0x5810) | ||
68 | #define CLK_REQ_TIME (REGISTERS_BASE + 0x5814) | ||
69 | #define CLK_BUF_TIME (REGISTERS_BASE + 0x5818) | ||
70 | |||
71 | #define CFG_PLL_SYNC_CNT (REGISTERS_BASE + 0x5820) | ||
72 | |||
73 | /* Scratch Pad registers*/ | ||
74 | #define SCR_PAD0 (REGISTERS_BASE + 0x5608) | ||
75 | #define SCR_PAD1 (REGISTERS_BASE + 0x560C) | ||
76 | #define SCR_PAD2 (REGISTERS_BASE + 0x5610) | ||
77 | #define SCR_PAD3 (REGISTERS_BASE + 0x5614) | ||
78 | #define SCR_PAD4 (REGISTERS_BASE + 0x5618) | ||
79 | #define SCR_PAD4_SET (REGISTERS_BASE + 0x561C) | ||
80 | #define SCR_PAD4_CLR (REGISTERS_BASE + 0x5620) | ||
81 | #define SCR_PAD5 (REGISTERS_BASE + 0x5624) | ||
82 | #define SCR_PAD5_SET (REGISTERS_BASE + 0x5628) | ||
83 | #define SCR_PAD5_CLR (REGISTERS_BASE + 0x562C) | ||
84 | #define SCR_PAD6 (REGISTERS_BASE + 0x5630) | ||
85 | #define SCR_PAD7 (REGISTERS_BASE + 0x5634) | ||
86 | #define SCR_PAD8 (REGISTERS_BASE + 0x5638) | ||
87 | #define SCR_PAD9 (REGISTERS_BASE + 0x563C) | ||
88 | |||
89 | /* Spare registers*/ | ||
90 | #define SPARE_A1 (REGISTERS_BASE + 0x0994) | ||
91 | #define SPARE_A2 (REGISTERS_BASE + 0x0998) | ||
92 | #define SPARE_A3 (REGISTERS_BASE + 0x099C) | ||
93 | #define SPARE_A4 (REGISTERS_BASE + 0x09A0) | ||
94 | #define SPARE_A5 (REGISTERS_BASE + 0x09A4) | ||
95 | #define SPARE_A6 (REGISTERS_BASE + 0x09A8) | ||
96 | #define SPARE_A7 (REGISTERS_BASE + 0x09AC) | ||
97 | #define SPARE_A8 (REGISTERS_BASE + 0x09B0) | ||
98 | #define SPARE_B1 (REGISTERS_BASE + 0x5420) | ||
99 | #define SPARE_B2 (REGISTERS_BASE + 0x5424) | ||
100 | #define SPARE_B3 (REGISTERS_BASE + 0x5428) | ||
101 | #define SPARE_B4 (REGISTERS_BASE + 0x542C) | ||
102 | #define SPARE_B5 (REGISTERS_BASE + 0x5430) | ||
103 | #define SPARE_B6 (REGISTERS_BASE + 0x5434) | ||
104 | #define SPARE_B7 (REGISTERS_BASE + 0x5438) | ||
105 | #define SPARE_B8 (REGISTERS_BASE + 0x543C) | ||
106 | |||
107 | enum wl12xx_acx_int_reg { | ||
108 | ACX_REG_INTERRUPT_TRIG, | ||
109 | ACX_REG_INTERRUPT_TRIG_H, | ||
110 | |||
111 | /*============================================= | ||
112 | Host Interrupt Mask Register - 32bit (RW) | ||
113 | ------------------------------------------ | ||
114 | Setting a bit in this register masks the | ||
115 | corresponding interrupt to the host. | ||
116 | 0 - RX0 - Rx first dubble buffer Data Interrupt | ||
117 | 1 - TXD - Tx Data Interrupt | ||
118 | 2 - TXXFR - Tx Transfer Interrupt | ||
119 | 3 - RX1 - Rx second dubble buffer Data Interrupt | ||
120 | 4 - RXXFR - Rx Transfer Interrupt | ||
121 | 5 - EVENT_A - Event Mailbox interrupt | ||
122 | 6 - EVENT_B - Event Mailbox interrupt | ||
123 | 7 - WNONHST - Wake On Host Interrupt | ||
124 | 8 - TRACE_A - Debug Trace interrupt | ||
125 | 9 - TRACE_B - Debug Trace interrupt | ||
126 | 10 - CDCMP - Command Complete Interrupt | ||
127 | 11 - | ||
128 | 12 - | ||
129 | 13 - | ||
130 | 14 - ICOMP - Initialization Complete Interrupt | ||
131 | 16 - SG SE - Soft Gemini - Sense enable interrupt | ||
132 | 17 - SG SD - Soft Gemini - Sense disable interrupt | ||
133 | 18 - - | ||
134 | 19 - - | ||
135 | 20 - - | ||
136 | 21- - | ||
137 | Default: 0x0001 | ||
138 | *==============================================*/ | ||
139 | ACX_REG_INTERRUPT_MASK, | ||
140 | |||
141 | /*============================================= | ||
142 | Host Interrupt Mask Set 16bit, (Write only) | ||
143 | ------------------------------------------ | ||
144 | Setting a bit in this register sets | ||
145 | the corresponding bin in ACX_HINT_MASK register | ||
146 | without effecting the mask | ||
147 | state of other bits (0 = no effect). | ||
148 | ==============================================*/ | ||
149 | ACX_REG_HINT_MASK_SET, | ||
150 | |||
151 | /*============================================= | ||
152 | Host Interrupt Mask Clear 16bit,(Write only) | ||
153 | ------------------------------------------ | ||
154 | Setting a bit in this register clears | ||
155 | the corresponding bin in ACX_HINT_MASK register | ||
156 | without effecting the mask | ||
157 | state of other bits (0 = no effect). | ||
158 | =============================================*/ | ||
159 | ACX_REG_HINT_MASK_CLR, | ||
160 | |||
161 | /*============================================= | ||
162 | Host Interrupt Status Nondestructive Read | ||
163 | 16bit,(Read only) | ||
164 | ------------------------------------------ | ||
165 | The host can read this register to determine | ||
166 | which interrupts are active. | ||
167 | Reading this register doesn't | ||
168 | effect its content. | ||
169 | =============================================*/ | ||
170 | ACX_REG_INTERRUPT_NO_CLEAR, | ||
171 | |||
172 | /*============================================= | ||
173 | Host Interrupt Status Clear on Read Register | ||
174 | 16bit,(Read only) | ||
175 | ------------------------------------------ | ||
176 | The host can read this register to determine | ||
177 | which interrupts are active. | ||
178 | Reading this register clears it, | ||
179 | thus making all interrupts inactive. | ||
180 | ==============================================*/ | ||
181 | ACX_REG_INTERRUPT_CLEAR, | ||
182 | |||
183 | /*============================================= | ||
184 | Host Interrupt Acknowledge Register | ||
185 | 16bit,(Write only) | ||
186 | ------------------------------------------ | ||
187 | The host can set individual bits in this | ||
188 | register to clear (acknowledge) the corresp. | ||
189 | interrupt status bits in the HINT_STS_CLR and | ||
190 | HINT_STS_ND registers, thus making the | ||
191 | assotiated interrupt inactive. (0-no effect) | ||
192 | ==============================================*/ | ||
193 | ACX_REG_INTERRUPT_ACK, | ||
194 | |||
195 | /*=============================================== | ||
196 | Host Software Reset - 32bit RW | ||
197 | ------------------------------------------ | ||
198 | [31:1] Reserved | ||
199 | 0 SOFT_RESET Soft Reset - When this bit is set, | ||
200 | it holds the Wlan hardware in a soft reset state. | ||
201 | This reset disables all MAC and baseband processor | ||
202 | clocks except the CardBus/PCI interface clock. | ||
203 | It also initializes all MAC state machines except | ||
204 | the host interface. It does not reload the | ||
205 | contents of the EEPROM. When this bit is cleared | ||
206 | (not self-clearing), the Wlan hardware | ||
207 | exits the software reset state. | ||
208 | ===============================================*/ | ||
209 | ACX_REG_SLV_SOFT_RESET, | ||
210 | |||
211 | /*=============================================== | ||
212 | EEPROM Burst Read Start - 32bit RW | ||
213 | ------------------------------------------ | ||
214 | [31:1] Reserved | ||
215 | 0 ACX_EE_START - EEPROM Burst Read Start 0 | ||
216 | Setting this bit starts a burst read from | ||
217 | the external EEPROM. | ||
218 | If this bit is set (after reset) before an EEPROM read/write, | ||
219 | the burst read starts at EEPROM address 0. | ||
220 | Otherwise, it starts at the address | ||
221 | following the address of the previous access. | ||
222 | TheWlan hardware hardware clears this bit automatically. | ||
223 | |||
224 | Default: 0x00000000 | ||
225 | *================================================*/ | ||
226 | ACX_REG_EE_START, | ||
227 | |||
228 | /* Embedded ARM CPU Control */ | ||
229 | |||
230 | /*=============================================== | ||
231 | Halt eCPU - 32bit RW | ||
232 | ------------------------------------------ | ||
233 | 0 HALT_ECPU Halt Embedded CPU - This bit is the | ||
234 | compliment of bit 1 (MDATA2) in the SOR_CFG register. | ||
235 | During a hardware reset, this bit holds | ||
236 | the inverse of MDATA2. | ||
237 | When downloading firmware from the host, | ||
238 | set this bit (pull down MDATA2). | ||
239 | The host clears this bit after downloading the firmware into | ||
240 | zero-wait-state SSRAM. | ||
241 | When loading firmware from Flash, clear this bit (pull up MDATA2) | ||
242 | so that the eCPU can run the bootloader code in Flash | ||
243 | HALT_ECPU eCPU State | ||
244 | -------------------- | ||
245 | 1 halt eCPU | ||
246 | 0 enable eCPU | ||
247 | ===============================================*/ | ||
248 | ACX_REG_ECPU_CONTROL, | ||
249 | |||
250 | ACX_REG_TABLE_LEN | ||
251 | }; | ||
252 | |||
253 | #define ACX_SLV_SOFT_RESET_BIT BIT(0) | ||
254 | #define ACX_REG_EEPROM_START_BIT BIT(0) | ||
255 | |||
256 | /* Command/Information Mailbox Pointers */ | ||
257 | |||
258 | /*=============================================== | ||
259 | Command Mailbox Pointer - 32bit RW | ||
260 | ------------------------------------------ | ||
261 | This register holds the start address of | ||
262 | the command mailbox located in the Wlan hardware memory. | ||
263 | The host must read this pointer after a reset to | ||
264 | find the location of the command mailbox. | ||
265 | The Wlan hardware initializes the command mailbox | ||
266 | pointer with the default address of the command mailbox. | ||
267 | The command mailbox pointer is not valid until after | ||
268 | the host receives the Init Complete interrupt from | ||
269 | the Wlan hardware. | ||
270 | ===============================================*/ | ||
271 | #define REG_COMMAND_MAILBOX_PTR (SCR_PAD0) | ||
272 | |||
273 | /*=============================================== | ||
274 | Information Mailbox Pointer - 32bit RW | ||
275 | ------------------------------------------ | ||
276 | This register holds the start address of | ||
277 | the information mailbox located in the Wlan hardware memory. | ||
278 | The host must read this pointer after a reset to find | ||
279 | the location of the information mailbox. | ||
280 | The Wlan hardware initializes the information mailbox pointer | ||
281 | with the default address of the information mailbox. | ||
282 | The information mailbox pointer is not valid | ||
283 | until after the host receives the Init Complete interrupt from | ||
284 | the Wlan hardware. | ||
285 | ===============================================*/ | ||
286 | #define REG_EVENT_MAILBOX_PTR (SCR_PAD1) | ||
287 | |||
288 | |||
289 | /* Misc */ | ||
290 | |||
291 | #define REG_ENABLE_TX_RX (ENABLE) | ||
292 | /* | ||
293 | * Rx configuration (filter) information element | ||
294 | * --------------------------------------------- | ||
295 | */ | ||
296 | #define REG_RX_CONFIG (RX_CFG) | ||
297 | #define REG_RX_FILTER (RX_FILTER_CFG) | ||
298 | |||
299 | |||
300 | #define RX_CFG_ENABLE_PHY_HEADER_PLCP 0x0002 | ||
301 | |||
302 | /* promiscuous - receives all valid frames */ | ||
303 | #define RX_CFG_PROMISCUOUS 0x0008 | ||
304 | |||
305 | /* receives frames from any BSSID */ | ||
306 | #define RX_CFG_BSSID 0x0020 | ||
307 | |||
308 | /* receives frames destined to any MAC address */ | ||
309 | #define RX_CFG_MAC 0x0010 | ||
310 | |||
311 | #define RX_CFG_ENABLE_ONLY_MY_DEST_MAC 0x0010 | ||
312 | #define RX_CFG_ENABLE_ANY_DEST_MAC 0x0000 | ||
313 | #define RX_CFG_ENABLE_ONLY_MY_BSSID 0x0020 | ||
314 | #define RX_CFG_ENABLE_ANY_BSSID 0x0000 | ||
315 | |||
316 | /* discards all broadcast frames */ | ||
317 | #define RX_CFG_DISABLE_BCAST 0x0200 | ||
318 | |||
319 | #define RX_CFG_ENABLE_ONLY_MY_SSID 0x0400 | ||
320 | #define RX_CFG_ENABLE_RX_CMPLT_FCS_ERROR 0x0800 | ||
321 | #define RX_CFG_COPY_RX_STATUS 0x2000 | ||
322 | #define RX_CFG_TSF 0x10000 | ||
323 | |||
324 | #define RX_CONFIG_OPTION_ANY_DST_MY_BSS (RX_CFG_ENABLE_ANY_DEST_MAC | \ | ||
325 | RX_CFG_ENABLE_ONLY_MY_BSSID) | ||
326 | |||
327 | #define RX_CONFIG_OPTION_MY_DST_ANY_BSS (RX_CFG_ENABLE_ONLY_MY_DEST_MAC\ | ||
328 | | RX_CFG_ENABLE_ANY_BSSID) | ||
329 | |||
330 | #define RX_CONFIG_OPTION_ANY_DST_ANY_BSS (RX_CFG_ENABLE_ANY_DEST_MAC | \ | ||
331 | RX_CFG_ENABLE_ANY_BSSID) | ||
332 | |||
333 | #define RX_CONFIG_OPTION_MY_DST_MY_BSS (RX_CFG_ENABLE_ONLY_MY_DEST_MAC\ | ||
334 | | RX_CFG_ENABLE_ONLY_MY_BSSID) | ||
335 | |||
336 | #define RX_CONFIG_OPTION_FOR_SCAN (RX_CFG_ENABLE_PHY_HEADER_PLCP \ | ||
337 | | RX_CFG_ENABLE_RX_CMPLT_FCS_ERROR \ | ||
338 | | RX_CFG_COPY_RX_STATUS | RX_CFG_TSF) | ||
339 | |||
340 | #define RX_CONFIG_OPTION_FOR_MEASUREMENT (RX_CFG_ENABLE_ANY_DEST_MAC) | ||
341 | |||
342 | #define RX_CONFIG_OPTION_FOR_JOIN (RX_CFG_ENABLE_ONLY_MY_BSSID | \ | ||
343 | RX_CFG_ENABLE_ONLY_MY_DEST_MAC) | ||
344 | |||
345 | #define RX_CONFIG_OPTION_FOR_IBSS_JOIN (RX_CFG_ENABLE_ONLY_MY_SSID | \ | ||
346 | RX_CFG_ENABLE_ONLY_MY_DEST_MAC) | ||
347 | |||
348 | #define RX_FILTER_OPTION_DEF (CFG_RX_MGMT_EN | CFG_RX_DATA_EN\ | ||
349 | | CFG_RX_CTL_EN | CFG_RX_BCN_EN\ | ||
350 | | CFG_RX_AUTH_EN | CFG_RX_ASSOC_EN) | ||
351 | |||
352 | #define RX_FILTER_OPTION_FILTER_ALL 0 | ||
353 | |||
354 | #define RX_FILTER_OPTION_DEF_PRSP_BCN (CFG_RX_PRSP_EN | CFG_RX_MGMT_EN\ | ||
355 | | CFG_RX_RCTS_ACK | CFG_RX_BCN_EN) | ||
356 | |||
357 | #define RX_FILTER_OPTION_JOIN (CFG_RX_MGMT_EN | CFG_RX_DATA_EN\ | ||
358 | | CFG_RX_BCN_EN | CFG_RX_AUTH_EN\ | ||
359 | | CFG_RX_ASSOC_EN | CFG_RX_RCTS_ACK\ | ||
360 | | CFG_RX_PRSP_EN) | ||
361 | |||
362 | |||
363 | /*=============================================== | ||
364 | EEPROM Read/Write Request 32bit RW | ||
365 | ------------------------------------------ | ||
366 | 1 EE_READ - EEPROM Read Request 1 - Setting this bit | ||
367 | loads a single byte of data into the EE_DATA | ||
368 | register from the EEPROM location specified in | ||
369 | the EE_ADDR register. | ||
370 | The Wlan hardware hardware clears this bit automatically. | ||
371 | EE_DATA is valid when this bit is cleared. | ||
372 | |||
373 | 0 EE_WRITE - EEPROM Write Request - Setting this bit | ||
374 | writes a single byte of data from the EE_DATA register into the | ||
375 | EEPROM location specified in the EE_ADDR register. | ||
376 | The Wlan hardware hardware clears this bit automatically. | ||
377 | *===============================================*/ | ||
378 | #define EE_CTL (REGISTERS_BASE + 0x2000) | ||
379 | #define ACX_EE_CTL_REG EE_CTL | ||
380 | #define EE_WRITE 0x00000001ul | ||
381 | #define EE_READ 0x00000002ul | ||
382 | |||
383 | /*=============================================== | ||
384 | EEPROM Address - 32bit RW | ||
385 | ------------------------------------------ | ||
386 | This register specifies the address | ||
387 | within the EEPROM from/to which to read/write data. | ||
388 | ===============================================*/ | ||
389 | #define EE_ADDR (REGISTERS_BASE + 0x2008) | ||
390 | #define ACX_EE_ADDR_REG EE_ADDR | ||
391 | |||
392 | /*=============================================== | ||
393 | EEPROM Data - 32bit RW | ||
394 | ------------------------------------------ | ||
395 | This register either holds the read 8 bits of | ||
396 | data from the EEPROM or the write data | ||
397 | to be written to the EEPROM. | ||
398 | ===============================================*/ | ||
399 | #define EE_DATA (REGISTERS_BASE + 0x2004) | ||
400 | #define ACX_EE_DATA_REG EE_DATA | ||
401 | |||
402 | #define EEPROM_ACCESS_TO 10000 /* timeout counter */ | ||
403 | #define START_EEPROM_MGR 0x00000001 | ||
404 | |||
405 | /*=============================================== | ||
406 | EEPROM Base Address - 32bit RW | ||
407 | ------------------------------------------ | ||
408 | This register holds the upper nine bits | ||
409 | [23:15] of the 24-bit Wlan hardware memory | ||
410 | address for burst reads from EEPROM accesses. | ||
411 | The EEPROM provides the lower 15 bits of this address. | ||
412 | The MSB of the address from the EEPROM is ignored. | ||
413 | ===============================================*/ | ||
414 | #define ACX_EE_CFG EE_CFG | ||
415 | |||
416 | /*=============================================== | ||
417 | GPIO Output Values -32bit, RW | ||
418 | ------------------------------------------ | ||
419 | [31:16] Reserved | ||
420 | [15: 0] Specify the output values (at the output driver inputs) for | ||
421 | GPIO[15:0], respectively. | ||
422 | ===============================================*/ | ||
423 | #define ACX_GPIO_OUT_REG GPIO_OUT | ||
424 | #define ACX_MAX_GPIO_LINES 15 | ||
425 | |||
426 | /*=============================================== | ||
427 | Contention window -32bit, RW | ||
428 | ------------------------------------------ | ||
429 | [31:26] Reserved | ||
430 | [25:16] Max (0x3ff) | ||
431 | [15:07] Reserved | ||
432 | [06:00] Current contention window value - default is 0x1F | ||
433 | ===============================================*/ | ||
434 | #define ACX_CONT_WIND_CFG_REG CONT_WIND_CFG | ||
435 | #define ACX_CONT_WIND_MIN_MASK 0x0000007f | ||
436 | #define ACX_CONT_WIND_MAX 0x03ff0000 | ||
437 | |||
438 | /*=============================================== | ||
439 | HI_CFG Interface Configuration Register Values | ||
440 | ------------------------------------------ | ||
441 | ===============================================*/ | ||
442 | #define HI_CFG_UART_ENABLE 0x00000004 | ||
443 | #define HI_CFG_RST232_ENABLE 0x00000008 | ||
444 | #define HI_CFG_CLOCK_REQ_SELECT 0x00000010 | ||
445 | #define HI_CFG_HOST_INT_ENABLE 0x00000020 | ||
446 | #define HI_CFG_VLYNQ_OUTPUT_ENABLE 0x00000040 | ||
447 | #define HI_CFG_HOST_INT_ACTIVE_LOW 0x00000080 | ||
448 | #define HI_CFG_UART_TX_OUT_GPIO_15 0x00000100 | ||
449 | #define HI_CFG_UART_TX_OUT_GPIO_14 0x00000200 | ||
450 | #define HI_CFG_UART_TX_OUT_GPIO_7 0x00000400 | ||
451 | |||
452 | /* | ||
453 | * NOTE: USE_ACTIVE_HIGH compilation flag should be defined in makefile | ||
454 | * for platforms using active high interrupt level | ||
455 | */ | ||
456 | #ifdef USE_ACTIVE_HIGH | ||
457 | #define HI_CFG_DEF_VAL \ | ||
458 | (HI_CFG_UART_ENABLE | \ | ||
459 | HI_CFG_RST232_ENABLE | \ | ||
460 | HI_CFG_CLOCK_REQ_SELECT | \ | ||
461 | HI_CFG_HOST_INT_ENABLE) | ||
462 | #else | ||
463 | #define HI_CFG_DEF_VAL \ | ||
464 | (HI_CFG_UART_ENABLE | \ | ||
465 | HI_CFG_RST232_ENABLE | \ | ||
466 | HI_CFG_CLOCK_REQ_SELECT | \ | ||
467 | HI_CFG_HOST_INT_ENABLE) | ||
468 | |||
469 | #endif | ||
470 | |||
471 | #define REF_FREQ_19_2 0 | ||
472 | #define REF_FREQ_26_0 1 | ||
473 | #define REF_FREQ_38_4 2 | ||
474 | #define REF_FREQ_40_0 3 | ||
475 | #define REF_FREQ_33_6 4 | ||
476 | #define REF_FREQ_NUM 5 | ||
477 | |||
478 | #define LUT_PARAM_INTEGER_DIVIDER 0 | ||
479 | #define LUT_PARAM_FRACTIONAL_DIVIDER 1 | ||
480 | #define LUT_PARAM_ATTN_BB 2 | ||
481 | #define LUT_PARAM_ALPHA_BB 3 | ||
482 | #define LUT_PARAM_STOP_TIME_BB 4 | ||
483 | #define LUT_PARAM_BB_PLL_LOOP_FILTER 5 | ||
484 | #define LUT_PARAM_NUM 6 | ||
485 | |||
486 | #define ACX_EEPROMLESS_IND_REG (SCR_PAD4) | ||
487 | #define USE_EEPROM 0 | ||
488 | #define SOFT_RESET_MAX_TIME 1000000 | ||
489 | #define SOFT_RESET_STALL_TIME 1000 | ||
490 | #define NVS_DATA_BUNDARY_ALIGNMENT 4 | ||
491 | |||
492 | |||
493 | /* Firmware image load chunk size */ | ||
494 | #define CHUNK_SIZE 512 | ||
495 | |||
496 | /* Firmware image header size */ | ||
497 | #define FW_HDR_SIZE 8 | ||
498 | |||
499 | #define ECPU_CONTROL_HALT 0x00000101 | ||
500 | |||
501 | |||
502 | /****************************************************************************** | ||
503 | |||
504 | CHANNELS, BAND & REG DOMAINS definitions | ||
505 | |||
506 | ******************************************************************************/ | ||
507 | |||
508 | |||
509 | enum { | ||
510 | RADIO_BAND_2_4GHZ = 0, /* 2.4 Ghz band */ | ||
511 | RADIO_BAND_5GHZ = 1, /* 5 Ghz band */ | ||
512 | RADIO_BAND_JAPAN_4_9_GHZ = 2, | ||
513 | DEFAULT_BAND = RADIO_BAND_2_4GHZ, | ||
514 | INVALID_BAND = 0xFE, | ||
515 | MAX_RADIO_BANDS = 0xFF | ||
516 | }; | ||
517 | |||
518 | enum { | ||
519 | NO_RATE = 0, | ||
520 | RATE_1MBPS = 0x0A, | ||
521 | RATE_2MBPS = 0x14, | ||
522 | RATE_5_5MBPS = 0x37, | ||
523 | RATE_6MBPS = 0x0B, | ||
524 | RATE_9MBPS = 0x0F, | ||
525 | RATE_11MBPS = 0x6E, | ||
526 | RATE_12MBPS = 0x0A, | ||
527 | RATE_18MBPS = 0x0E, | ||
528 | RATE_22MBPS = 0xDC, | ||
529 | RATE_24MBPS = 0x09, | ||
530 | RATE_36MBPS = 0x0D, | ||
531 | RATE_48MBPS = 0x08, | ||
532 | RATE_54MBPS = 0x0C | ||
533 | }; | ||
534 | |||
535 | enum { | ||
536 | RATE_INDEX_1MBPS = 0, | ||
537 | RATE_INDEX_2MBPS = 1, | ||
538 | RATE_INDEX_5_5MBPS = 2, | ||
539 | RATE_INDEX_6MBPS = 3, | ||
540 | RATE_INDEX_9MBPS = 4, | ||
541 | RATE_INDEX_11MBPS = 5, | ||
542 | RATE_INDEX_12MBPS = 6, | ||
543 | RATE_INDEX_18MBPS = 7, | ||
544 | RATE_INDEX_22MBPS = 8, | ||
545 | RATE_INDEX_24MBPS = 9, | ||
546 | RATE_INDEX_36MBPS = 10, | ||
547 | RATE_INDEX_48MBPS = 11, | ||
548 | RATE_INDEX_54MBPS = 12, | ||
549 | RATE_INDEX_MAX = RATE_INDEX_54MBPS, | ||
550 | MAX_RATE_INDEX, | ||
551 | INVALID_RATE_INDEX = MAX_RATE_INDEX, | ||
552 | RATE_INDEX_ENUM_MAX_SIZE = 0x7FFFFFFF | ||
553 | }; | ||
554 | |||
555 | enum { | ||
556 | RATE_MASK_1MBPS = 0x1, | ||
557 | RATE_MASK_2MBPS = 0x2, | ||
558 | RATE_MASK_5_5MBPS = 0x4, | ||
559 | RATE_MASK_11MBPS = 0x20, | ||
560 | }; | ||
561 | |||
562 | #define SHORT_PREAMBLE_BIT BIT(0) /* CCK or Barker depending on the rate */ | ||
563 | #define OFDM_RATE_BIT BIT(6) | ||
564 | #define PBCC_RATE_BIT BIT(7) | ||
565 | |||
566 | enum { | ||
567 | CCK_LONG = 0, | ||
568 | CCK_SHORT = SHORT_PREAMBLE_BIT, | ||
569 | PBCC_LONG = PBCC_RATE_BIT, | ||
570 | PBCC_SHORT = PBCC_RATE_BIT | SHORT_PREAMBLE_BIT, | ||
571 | OFDM = OFDM_RATE_BIT | ||
572 | }; | ||
573 | |||
574 | /****************************************************************************** | ||
575 | |||
576 | Transmit-Descriptor RATE-SET field definitions... | ||
577 | |||
578 | Define a new "Rate-Set" for TX path that incorporates the | ||
579 | Rate & Modulation info into a single 16-bit field. | ||
580 | |||
581 | TxdRateSet_t: | ||
582 | b15 - Indicates Preamble type (1=SHORT, 0=LONG). | ||
583 | Notes: | ||
584 | Must be LONG (0) for 1Mbps rate. | ||
585 | Does not apply (set to 0) for RevG-OFDM rates. | ||
586 | b14 - Indicates PBCC encoding (1=PBCC, 0=not). | ||
587 | Notes: | ||
588 | Does not apply (set to 0) for rates 1 and 2 Mbps. | ||
589 | Does not apply (set to 0) for RevG-OFDM rates. | ||
590 | b13 - Unused (set to 0). | ||
591 | b12-b0 - Supported Rate indicator bits as defined below. | ||
592 | |||
593 | ******************************************************************************/ | ||
594 | |||
595 | |||
596 | /************************************************************************* | ||
597 | |||
598 | Interrupt Trigger Register (Host -> WiLink) | ||
599 | |||
600 | **************************************************************************/ | ||
601 | |||
602 | /* Hardware to Embedded CPU Interrupts - first 32-bit register set */ | ||
603 | |||
604 | /* | ||
605 | * Host Command Interrupt. Setting this bit masks | ||
606 | * the interrupt that the host issues to inform | ||
607 | * the FW that it has sent a command | ||
608 | * to the Wlan hardware Command Mailbox. | ||
609 | */ | ||
610 | #define INTR_TRIG_CMD BIT(0) | ||
611 | |||
612 | /* | ||
613 | * Host Event Acknowlegde Interrupt. The host | ||
614 | * sets this bit to acknowledge that it received | ||
615 | * the unsolicited information from the event | ||
616 | * mailbox. | ||
617 | */ | ||
618 | #define INTR_TRIG_EVENT_ACK BIT(1) | ||
619 | |||
620 | /* | ||
621 | * The host sets this bit to inform the Wlan | ||
622 | * FW that a TX packet is in the XFER | ||
623 | * Buffer #0. | ||
624 | */ | ||
625 | #define INTR_TRIG_TX_PROC0 BIT(2) | ||
626 | |||
627 | /* | ||
628 | * The host sets this bit to inform the FW | ||
629 | * that it read a packet from RX XFER | ||
630 | * Buffer #0. | ||
631 | */ | ||
632 | #define INTR_TRIG_RX_PROC0 BIT(3) | ||
633 | |||
634 | #define INTR_TRIG_DEBUG_ACK BIT(4) | ||
635 | |||
636 | #define INTR_TRIG_STATE_CHANGED BIT(5) | ||
637 | |||
638 | |||
639 | /* Hardware to Embedded CPU Interrupts - second 32-bit register set */ | ||
640 | |||
641 | /* | ||
642 | * The host sets this bit to inform the FW | ||
643 | * that it read a packet from RX XFER | ||
644 | * Buffer #1. | ||
645 | */ | ||
646 | #define INTR_TRIG_RX_PROC1 BIT(17) | ||
647 | |||
648 | /* | ||
649 | * The host sets this bit to inform the Wlan | ||
650 | * hardware that a TX packet is in the XFER | ||
651 | * Buffer #1. | ||
652 | */ | ||
653 | #define INTR_TRIG_TX_PROC1 BIT(18) | ||
654 | |||
655 | #endif | ||
diff --git a/drivers/net/wireless/wl1251/rx.c b/drivers/net/wireless/wl1251/rx.c new file mode 100644 index 000000000000..efa53607d5c9 --- /dev/null +++ b/drivers/net/wireless/wl1251/rx.c | |||
@@ -0,0 +1,190 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/skbuff.h> | ||
24 | #include <linux/gfp.h> | ||
25 | #include <net/mac80211.h> | ||
26 | |||
27 | #include "wl1251.h" | ||
28 | #include "reg.h" | ||
29 | #include "io.h" | ||
30 | #include "rx.h" | ||
31 | #include "cmd.h" | ||
32 | #include "acx.h" | ||
33 | |||
34 | static void wl1251_rx_header(struct wl1251 *wl, | ||
35 | struct wl1251_rx_descriptor *desc) | ||
36 | { | ||
37 | u32 rx_packet_ring_addr; | ||
38 | |||
39 | rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr; | ||
40 | if (wl->rx_current_buffer) | ||
41 | rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; | ||
42 | |||
43 | wl1251_mem_read(wl, rx_packet_ring_addr, desc, sizeof(*desc)); | ||
44 | } | ||
45 | |||
46 | static void wl1251_rx_status(struct wl1251 *wl, | ||
47 | struct wl1251_rx_descriptor *desc, | ||
48 | struct ieee80211_rx_status *status, | ||
49 | u8 beacon) | ||
50 | { | ||
51 | u64 mactime; | ||
52 | int ret; | ||
53 | |||
54 | memset(status, 0, sizeof(struct ieee80211_rx_status)); | ||
55 | |||
56 | status->band = IEEE80211_BAND_2GHZ; | ||
57 | status->mactime = desc->timestamp; | ||
58 | |||
59 | /* | ||
60 | * The rx status timestamp is a 32 bits value while the TSF is a | ||
61 | * 64 bits one. | ||
62 | * For IBSS merging, TSF is mandatory, so we have to get it | ||
63 | * somehow, so we ask for ACX_TSF_INFO. | ||
64 | * That could be moved to the get_tsf() hook, but unfortunately, | ||
65 | * this one must be atomic, while our SPI routines can sleep. | ||
66 | */ | ||
67 | if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) { | ||
68 | ret = wl1251_acx_tsf_info(wl, &mactime); | ||
69 | if (ret == 0) | ||
70 | status->mactime = mactime; | ||
71 | } | ||
72 | |||
73 | status->signal = desc->rssi; | ||
74 | |||
75 | /* | ||
76 | * FIXME: guessing that snr needs to be divided by two, otherwise | ||
77 | * the values don't make any sense | ||
78 | */ | ||
79 | wl->noise = desc->rssi - desc->snr / 2; | ||
80 | |||
81 | status->freq = ieee80211_channel_to_frequency(desc->channel); | ||
82 | |||
83 | status->flag |= RX_FLAG_TSFT; | ||
84 | |||
85 | if (desc->flags & RX_DESC_ENCRYPTION_MASK) { | ||
86 | status->flag |= RX_FLAG_IV_STRIPPED | RX_FLAG_MMIC_STRIPPED; | ||
87 | |||
88 | if (likely(!(desc->flags & RX_DESC_DECRYPT_FAIL))) | ||
89 | status->flag |= RX_FLAG_DECRYPTED; | ||
90 | |||
91 | if (unlikely(desc->flags & RX_DESC_MIC_FAIL)) | ||
92 | status->flag |= RX_FLAG_MMIC_ERROR; | ||
93 | } | ||
94 | |||
95 | if (unlikely(!(desc->flags & RX_DESC_VALID_FCS))) | ||
96 | status->flag |= RX_FLAG_FAILED_FCS_CRC; | ||
97 | |||
98 | |||
99 | /* FIXME: set status->rate_idx */ | ||
100 | } | ||
101 | |||
102 | static void wl1251_rx_body(struct wl1251 *wl, | ||
103 | struct wl1251_rx_descriptor *desc) | ||
104 | { | ||
105 | struct sk_buff *skb; | ||
106 | struct ieee80211_rx_status status; | ||
107 | u8 *rx_buffer, beacon = 0; | ||
108 | u16 length, *fc; | ||
109 | u32 curr_id, last_id_inc, rx_packet_ring_addr; | ||
110 | |||
111 | length = WL1251_RX_ALIGN(desc->length - PLCP_HEADER_LENGTH); | ||
112 | curr_id = (desc->flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT; | ||
113 | last_id_inc = (wl->rx_last_id + 1) % (RX_MAX_PACKET_ID + 1); | ||
114 | |||
115 | if (last_id_inc != curr_id) { | ||
116 | wl1251_warning("curr ID:%d, last ID inc:%d", | ||
117 | curr_id, last_id_inc); | ||
118 | wl->rx_last_id = curr_id; | ||
119 | } else { | ||
120 | wl->rx_last_id = last_id_inc; | ||
121 | } | ||
122 | |||
123 | rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr + | ||
124 | sizeof(struct wl1251_rx_descriptor) + 20; | ||
125 | if (wl->rx_current_buffer) | ||
126 | rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; | ||
127 | |||
128 | skb = __dev_alloc_skb(length, GFP_KERNEL); | ||
129 | if (!skb) { | ||
130 | wl1251_error("Couldn't allocate RX frame"); | ||
131 | return; | ||
132 | } | ||
133 | |||
134 | rx_buffer = skb_put(skb, length); | ||
135 | wl1251_mem_read(wl, rx_packet_ring_addr, rx_buffer, length); | ||
136 | |||
137 | /* The actual lenght doesn't include the target's alignment */ | ||
138 | skb->len = desc->length - PLCP_HEADER_LENGTH; | ||
139 | |||
140 | fc = (u16 *)skb->data; | ||
141 | |||
142 | if ((*fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) | ||
143 | beacon = 1; | ||
144 | |||
145 | wl1251_rx_status(wl, desc, &status, beacon); | ||
146 | |||
147 | wl1251_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len, | ||
148 | beacon ? "beacon" : ""); | ||
149 | |||
150 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); | ||
151 | ieee80211_rx_ni(wl->hw, skb); | ||
152 | } | ||
153 | |||
154 | static void wl1251_rx_ack(struct wl1251 *wl) | ||
155 | { | ||
156 | u32 data, addr; | ||
157 | |||
158 | if (wl->rx_current_buffer) { | ||
159 | addr = ACX_REG_INTERRUPT_TRIG_H; | ||
160 | data = INTR_TRIG_RX_PROC1; | ||
161 | } else { | ||
162 | addr = ACX_REG_INTERRUPT_TRIG; | ||
163 | data = INTR_TRIG_RX_PROC0; | ||
164 | } | ||
165 | |||
166 | wl1251_reg_write32(wl, addr, data); | ||
167 | |||
168 | /* Toggle buffer ring */ | ||
169 | wl->rx_current_buffer = !wl->rx_current_buffer; | ||
170 | } | ||
171 | |||
172 | |||
173 | void wl1251_rx(struct wl1251 *wl) | ||
174 | { | ||
175 | struct wl1251_rx_descriptor *rx_desc; | ||
176 | |||
177 | if (wl->state != WL1251_STATE_ON) | ||
178 | return; | ||
179 | |||
180 | rx_desc = wl->rx_descriptor; | ||
181 | |||
182 | /* We first read the frame's header */ | ||
183 | wl1251_rx_header(wl, rx_desc); | ||
184 | |||
185 | /* Now we can read the body */ | ||
186 | wl1251_rx_body(wl, rx_desc); | ||
187 | |||
188 | /* Finally, we need to ACK the RX */ | ||
189 | wl1251_rx_ack(wl); | ||
190 | } | ||
diff --git a/drivers/net/wireless/wl1251/rx.h b/drivers/net/wireless/wl1251/rx.h new file mode 100644 index 000000000000..4448f635a4d8 --- /dev/null +++ b/drivers/net/wireless/wl1251/rx.h | |||
@@ -0,0 +1,122 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __WL1251_RX_H__ | ||
24 | #define __WL1251_RX_H__ | ||
25 | |||
26 | #include <linux/bitops.h> | ||
27 | |||
28 | #include "wl1251.h" | ||
29 | |||
30 | /* | ||
31 | * RX PATH | ||
32 | * | ||
33 | * The Rx path uses a double buffer and an rx_contro structure, each located | ||
34 | * at a fixed address in the device memory. The host keeps track of which | ||
35 | * buffer is available and alternates between them on a per packet basis. | ||
36 | * The size of each of the two buffers is large enough to hold the longest | ||
37 | * 802.3 packet. | ||
38 | * The RX path goes like that: | ||
39 | * 1) The target generates an interrupt each time a new packet is received. | ||
40 | * There are 2 RX interrupts, one for each buffer. | ||
41 | * 2) The host reads the received packet from one of the double buffers. | ||
42 | * 3) The host triggers a target interrupt. | ||
43 | * 4) The target prepares the next RX packet. | ||
44 | */ | ||
45 | |||
46 | #define WL1251_RX_MAX_RSSI -30 | ||
47 | #define WL1251_RX_MIN_RSSI -95 | ||
48 | |||
49 | #define WL1251_RX_ALIGN_TO 4 | ||
50 | #define WL1251_RX_ALIGN(len) (((len) + WL1251_RX_ALIGN_TO - 1) & \ | ||
51 | ~(WL1251_RX_ALIGN_TO - 1)) | ||
52 | |||
53 | #define SHORT_PREAMBLE_BIT BIT(0) | ||
54 | #define OFDM_RATE_BIT BIT(6) | ||
55 | #define PBCC_RATE_BIT BIT(7) | ||
56 | |||
57 | #define PLCP_HEADER_LENGTH 8 | ||
58 | #define RX_DESC_PACKETID_SHIFT 11 | ||
59 | #define RX_MAX_PACKET_ID 3 | ||
60 | |||
61 | #define RX_DESC_VALID_FCS 0x0001 | ||
62 | #define RX_DESC_MATCH_RXADDR1 0x0002 | ||
63 | #define RX_DESC_MCAST 0x0004 | ||
64 | #define RX_DESC_STAINTIM 0x0008 | ||
65 | #define RX_DESC_VIRTUAL_BM 0x0010 | ||
66 | #define RX_DESC_BCAST 0x0020 | ||
67 | #define RX_DESC_MATCH_SSID 0x0040 | ||
68 | #define RX_DESC_MATCH_BSSID 0x0080 | ||
69 | #define RX_DESC_ENCRYPTION_MASK 0x0300 | ||
70 | #define RX_DESC_MEASURMENT 0x0400 | ||
71 | #define RX_DESC_SEQNUM_MASK 0x1800 | ||
72 | #define RX_DESC_MIC_FAIL 0x2000 | ||
73 | #define RX_DESC_DECRYPT_FAIL 0x4000 | ||
74 | |||
75 | struct wl1251_rx_descriptor { | ||
76 | u32 timestamp; /* In microseconds */ | ||
77 | u16 length; /* Paylod length, including headers */ | ||
78 | u16 flags; | ||
79 | |||
80 | /* | ||
81 | * 0 - 802.11 | ||
82 | * 1 - 802.3 | ||
83 | * 2 - IP | ||
84 | * 3 - Raw Codec | ||
85 | */ | ||
86 | u8 type; | ||
87 | |||
88 | /* | ||
89 | * Received Rate: | ||
90 | * 0x0A - 1MBPS | ||
91 | * 0x14 - 2MBPS | ||
92 | * 0x37 - 5_5MBPS | ||
93 | * 0x0B - 6MBPS | ||
94 | * 0x0F - 9MBPS | ||
95 | * 0x6E - 11MBPS | ||
96 | * 0x0A - 12MBPS | ||
97 | * 0x0E - 18MBPS | ||
98 | * 0xDC - 22MBPS | ||
99 | * 0x09 - 24MBPS | ||
100 | * 0x0D - 36MBPS | ||
101 | * 0x08 - 48MBPS | ||
102 | * 0x0C - 54MBPS | ||
103 | */ | ||
104 | u8 rate; | ||
105 | |||
106 | u8 mod_pre; /* Modulation and preamble */ | ||
107 | u8 channel; | ||
108 | |||
109 | /* | ||
110 | * 0 - 2.4 Ghz | ||
111 | * 1 - 5 Ghz | ||
112 | */ | ||
113 | u8 band; | ||
114 | |||
115 | s8 rssi; /* in dB */ | ||
116 | u8 rcpi; /* in dB */ | ||
117 | u8 snr; /* in dB */ | ||
118 | } __packed; | ||
119 | |||
120 | void wl1251_rx(struct wl1251 *wl); | ||
121 | |||
122 | #endif | ||
diff --git a/drivers/net/wireless/wl1251/sdio.c b/drivers/net/wireless/wl1251/sdio.c new file mode 100644 index 000000000000..74ba9ced5393 --- /dev/null +++ b/drivers/net/wireless/wl1251/sdio.c | |||
@@ -0,0 +1,342 @@ | |||
1 | /* | ||
2 | * wl12xx SDIO routines | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, but | ||
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
11 | * General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write to the Free Software | ||
15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
16 | * 02110-1301 USA | ||
17 | * | ||
18 | * Copyright (C) 2005 Texas Instruments Incorporated | ||
19 | * Copyright (C) 2008 Google Inc | ||
20 | * Copyright (C) 2009 Bob Copeland (me@bobcopeland.com) | ||
21 | */ | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/mod_devicetable.h> | ||
24 | #include <linux/mmc/sdio_func.h> | ||
25 | #include <linux/mmc/sdio_ids.h> | ||
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/wl12xx.h> | ||
28 | #include <linux/irq.h> | ||
29 | |||
30 | #include "wl1251.h" | ||
31 | |||
32 | #ifndef SDIO_VENDOR_ID_TI | ||
33 | #define SDIO_VENDOR_ID_TI 0x104c | ||
34 | #endif | ||
35 | |||
36 | #ifndef SDIO_DEVICE_ID_TI_WL1251 | ||
37 | #define SDIO_DEVICE_ID_TI_WL1251 0x9066 | ||
38 | #endif | ||
39 | |||
40 | struct wl1251_sdio { | ||
41 | struct sdio_func *func; | ||
42 | u32 elp_val; | ||
43 | }; | ||
44 | |||
45 | static struct wl12xx_platform_data *wl12xx_board_data; | ||
46 | |||
47 | static struct sdio_func *wl_to_func(struct wl1251 *wl) | ||
48 | { | ||
49 | struct wl1251_sdio *wl_sdio = wl->if_priv; | ||
50 | return wl_sdio->func; | ||
51 | } | ||
52 | |||
53 | static void wl1251_sdio_interrupt(struct sdio_func *func) | ||
54 | { | ||
55 | struct wl1251 *wl = sdio_get_drvdata(func); | ||
56 | |||
57 | wl1251_debug(DEBUG_IRQ, "IRQ"); | ||
58 | |||
59 | /* FIXME should be synchronous for sdio */ | ||
60 | ieee80211_queue_work(wl->hw, &wl->irq_work); | ||
61 | } | ||
62 | |||
63 | static const struct sdio_device_id wl1251_devices[] = { | ||
64 | { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1251) }, | ||
65 | {} | ||
66 | }; | ||
67 | MODULE_DEVICE_TABLE(sdio, wl1251_devices); | ||
68 | |||
69 | |||
70 | static void wl1251_sdio_read(struct wl1251 *wl, int addr, | ||
71 | void *buf, size_t len) | ||
72 | { | ||
73 | int ret; | ||
74 | struct sdio_func *func = wl_to_func(wl); | ||
75 | |||
76 | sdio_claim_host(func); | ||
77 | ret = sdio_memcpy_fromio(func, buf, addr, len); | ||
78 | if (ret) | ||
79 | wl1251_error("sdio read failed (%d)", ret); | ||
80 | sdio_release_host(func); | ||
81 | } | ||
82 | |||
83 | static void wl1251_sdio_write(struct wl1251 *wl, int addr, | ||
84 | void *buf, size_t len) | ||
85 | { | ||
86 | int ret; | ||
87 | struct sdio_func *func = wl_to_func(wl); | ||
88 | |||
89 | sdio_claim_host(func); | ||
90 | ret = sdio_memcpy_toio(func, addr, buf, len); | ||
91 | if (ret) | ||
92 | wl1251_error("sdio write failed (%d)", ret); | ||
93 | sdio_release_host(func); | ||
94 | } | ||
95 | |||
96 | static void wl1251_sdio_read_elp(struct wl1251 *wl, int addr, u32 *val) | ||
97 | { | ||
98 | int ret = 0; | ||
99 | struct wl1251_sdio *wl_sdio = wl->if_priv; | ||
100 | struct sdio_func *func = wl_sdio->func; | ||
101 | |||
102 | /* | ||
103 | * The hardware only supports RAW (read after write) access for | ||
104 | * reading, regular sdio_readb won't work here (it interprets | ||
105 | * the unused bits of CMD52 as write data even if we send read | ||
106 | * request). | ||
107 | */ | ||
108 | sdio_claim_host(func); | ||
109 | *val = sdio_writeb_readb(func, wl_sdio->elp_val, addr, &ret); | ||
110 | sdio_release_host(func); | ||
111 | |||
112 | if (ret) | ||
113 | wl1251_error("sdio_readb failed (%d)", ret); | ||
114 | } | ||
115 | |||
116 | static void wl1251_sdio_write_elp(struct wl1251 *wl, int addr, u32 val) | ||
117 | { | ||
118 | int ret = 0; | ||
119 | struct wl1251_sdio *wl_sdio = wl->if_priv; | ||
120 | struct sdio_func *func = wl_sdio->func; | ||
121 | |||
122 | sdio_claim_host(func); | ||
123 | sdio_writeb(func, val, addr, &ret); | ||
124 | sdio_release_host(func); | ||
125 | |||
126 | if (ret) | ||
127 | wl1251_error("sdio_writeb failed (%d)", ret); | ||
128 | else | ||
129 | wl_sdio->elp_val = val; | ||
130 | } | ||
131 | |||
132 | static void wl1251_sdio_reset(struct wl1251 *wl) | ||
133 | { | ||
134 | } | ||
135 | |||
136 | static void wl1251_sdio_enable_irq(struct wl1251 *wl) | ||
137 | { | ||
138 | struct sdio_func *func = wl_to_func(wl); | ||
139 | |||
140 | sdio_claim_host(func); | ||
141 | sdio_claim_irq(func, wl1251_sdio_interrupt); | ||
142 | sdio_release_host(func); | ||
143 | } | ||
144 | |||
145 | static void wl1251_sdio_disable_irq(struct wl1251 *wl) | ||
146 | { | ||
147 | struct sdio_func *func = wl_to_func(wl); | ||
148 | |||
149 | sdio_claim_host(func); | ||
150 | sdio_release_irq(func); | ||
151 | sdio_release_host(func); | ||
152 | } | ||
153 | |||
154 | /* Interrupts when using dedicated WLAN_IRQ pin */ | ||
155 | static irqreturn_t wl1251_line_irq(int irq, void *cookie) | ||
156 | { | ||
157 | struct wl1251 *wl = cookie; | ||
158 | |||
159 | ieee80211_queue_work(wl->hw, &wl->irq_work); | ||
160 | |||
161 | return IRQ_HANDLED; | ||
162 | } | ||
163 | |||
164 | static void wl1251_enable_line_irq(struct wl1251 *wl) | ||
165 | { | ||
166 | return enable_irq(wl->irq); | ||
167 | } | ||
168 | |||
169 | static void wl1251_disable_line_irq(struct wl1251 *wl) | ||
170 | { | ||
171 | return disable_irq(wl->irq); | ||
172 | } | ||
173 | |||
174 | static void wl1251_sdio_set_power(bool enable) | ||
175 | { | ||
176 | } | ||
177 | |||
178 | static struct wl1251_if_operations wl1251_sdio_ops = { | ||
179 | .read = wl1251_sdio_read, | ||
180 | .write = wl1251_sdio_write, | ||
181 | .write_elp = wl1251_sdio_write_elp, | ||
182 | .read_elp = wl1251_sdio_read_elp, | ||
183 | .reset = wl1251_sdio_reset, | ||
184 | }; | ||
185 | |||
186 | static int wl1251_platform_probe(struct platform_device *pdev) | ||
187 | { | ||
188 | if (pdev->id != -1) { | ||
189 | wl1251_error("can only handle single device"); | ||
190 | return -ENODEV; | ||
191 | } | ||
192 | |||
193 | wl12xx_board_data = pdev->dev.platform_data; | ||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | /* | ||
198 | * Dummy platform_driver for passing platform_data to this driver, | ||
199 | * until we have a way to pass this through SDIO subsystem or | ||
200 | * some other way. | ||
201 | */ | ||
202 | static struct platform_driver wl1251_platform_driver = { | ||
203 | .driver = { | ||
204 | .name = "wl1251_data", | ||
205 | .owner = THIS_MODULE, | ||
206 | }, | ||
207 | .probe = wl1251_platform_probe, | ||
208 | }; | ||
209 | |||
210 | static int wl1251_sdio_probe(struct sdio_func *func, | ||
211 | const struct sdio_device_id *id) | ||
212 | { | ||
213 | int ret; | ||
214 | struct wl1251 *wl; | ||
215 | struct ieee80211_hw *hw; | ||
216 | struct wl1251_sdio *wl_sdio; | ||
217 | |||
218 | hw = wl1251_alloc_hw(); | ||
219 | if (IS_ERR(hw)) | ||
220 | return PTR_ERR(hw); | ||
221 | |||
222 | wl = hw->priv; | ||
223 | |||
224 | wl_sdio = kzalloc(sizeof(*wl_sdio), GFP_KERNEL); | ||
225 | if (wl_sdio == NULL) { | ||
226 | ret = -ENOMEM; | ||
227 | goto out_free_hw; | ||
228 | } | ||
229 | |||
230 | sdio_claim_host(func); | ||
231 | ret = sdio_enable_func(func); | ||
232 | if (ret) | ||
233 | goto release; | ||
234 | |||
235 | sdio_set_block_size(func, 512); | ||
236 | sdio_release_host(func); | ||
237 | |||
238 | SET_IEEE80211_DEV(hw, &func->dev); | ||
239 | wl_sdio->func = func; | ||
240 | wl->if_priv = wl_sdio; | ||
241 | wl->if_ops = &wl1251_sdio_ops; | ||
242 | wl->set_power = wl1251_sdio_set_power; | ||
243 | |||
244 | if (wl12xx_board_data != NULL) { | ||
245 | wl->set_power = wl12xx_board_data->set_power; | ||
246 | wl->irq = wl12xx_board_data->irq; | ||
247 | wl->use_eeprom = wl12xx_board_data->use_eeprom; | ||
248 | } | ||
249 | |||
250 | if (wl->irq) { | ||
251 | ret = request_irq(wl->irq, wl1251_line_irq, 0, "wl1251", wl); | ||
252 | if (ret < 0) { | ||
253 | wl1251_error("request_irq() failed: %d", ret); | ||
254 | goto disable; | ||
255 | } | ||
256 | |||
257 | set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); | ||
258 | disable_irq(wl->irq); | ||
259 | |||
260 | wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq; | ||
261 | wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq; | ||
262 | |||
263 | wl1251_info("using dedicated interrupt line"); | ||
264 | } else { | ||
265 | wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq; | ||
266 | wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq; | ||
267 | |||
268 | wl1251_info("using SDIO interrupt"); | ||
269 | } | ||
270 | |||
271 | ret = wl1251_init_ieee80211(wl); | ||
272 | if (ret) | ||
273 | goto out_free_irq; | ||
274 | |||
275 | sdio_set_drvdata(func, wl); | ||
276 | return ret; | ||
277 | |||
278 | out_free_irq: | ||
279 | if (wl->irq) | ||
280 | free_irq(wl->irq, wl); | ||
281 | disable: | ||
282 | sdio_claim_host(func); | ||
283 | sdio_disable_func(func); | ||
284 | release: | ||
285 | sdio_release_host(func); | ||
286 | kfree(wl_sdio); | ||
287 | out_free_hw: | ||
288 | wl1251_free_hw(wl); | ||
289 | return ret; | ||
290 | } | ||
291 | |||
292 | static void __devexit wl1251_sdio_remove(struct sdio_func *func) | ||
293 | { | ||
294 | struct wl1251 *wl = sdio_get_drvdata(func); | ||
295 | struct wl1251_sdio *wl_sdio = wl->if_priv; | ||
296 | |||
297 | if (wl->irq) | ||
298 | free_irq(wl->irq, wl); | ||
299 | kfree(wl_sdio); | ||
300 | wl1251_free_hw(wl); | ||
301 | |||
302 | sdio_claim_host(func); | ||
303 | sdio_release_irq(func); | ||
304 | sdio_disable_func(func); | ||
305 | sdio_release_host(func); | ||
306 | } | ||
307 | |||
308 | static struct sdio_driver wl1251_sdio_driver = { | ||
309 | .name = "wl1251_sdio", | ||
310 | .id_table = wl1251_devices, | ||
311 | .probe = wl1251_sdio_probe, | ||
312 | .remove = __devexit_p(wl1251_sdio_remove), | ||
313 | }; | ||
314 | |||
315 | static int __init wl1251_sdio_init(void) | ||
316 | { | ||
317 | int err; | ||
318 | |||
319 | err = platform_driver_register(&wl1251_platform_driver); | ||
320 | if (err) { | ||
321 | wl1251_error("failed to register platform driver: %d", err); | ||
322 | return err; | ||
323 | } | ||
324 | |||
325 | err = sdio_register_driver(&wl1251_sdio_driver); | ||
326 | if (err) | ||
327 | wl1251_error("failed to register sdio driver: %d", err); | ||
328 | return err; | ||
329 | } | ||
330 | |||
331 | static void __exit wl1251_sdio_exit(void) | ||
332 | { | ||
333 | sdio_unregister_driver(&wl1251_sdio_driver); | ||
334 | platform_driver_unregister(&wl1251_platform_driver); | ||
335 | wl1251_notice("unloaded"); | ||
336 | } | ||
337 | |||
338 | module_init(wl1251_sdio_init); | ||
339 | module_exit(wl1251_sdio_exit); | ||
340 | |||
341 | MODULE_LICENSE("GPL"); | ||
342 | MODULE_AUTHOR("Kalle Valo <kvalo@adurom.com>"); | ||
diff --git a/drivers/net/wireless/wl1251/spi.c b/drivers/net/wireless/wl1251/spi.c new file mode 100644 index 000000000000..88fa8e69d0d1 --- /dev/null +++ b/drivers/net/wireless/wl1251/spi.c | |||
@@ -0,0 +1,346 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #include <linux/irq.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/crc7.h> | ||
26 | #include <linux/spi/spi.h> | ||
27 | #include <linux/wl12xx.h> | ||
28 | |||
29 | #include "wl1251.h" | ||
30 | #include "reg.h" | ||
31 | #include "spi.h" | ||
32 | |||
33 | static irqreturn_t wl1251_irq(int irq, void *cookie) | ||
34 | { | ||
35 | struct wl1251 *wl; | ||
36 | |||
37 | wl1251_debug(DEBUG_IRQ, "IRQ"); | ||
38 | |||
39 | wl = cookie; | ||
40 | |||
41 | ieee80211_queue_work(wl->hw, &wl->irq_work); | ||
42 | |||
43 | return IRQ_HANDLED; | ||
44 | } | ||
45 | |||
46 | static struct spi_device *wl_to_spi(struct wl1251 *wl) | ||
47 | { | ||
48 | return wl->if_priv; | ||
49 | } | ||
50 | |||
51 | static void wl1251_spi_reset(struct wl1251 *wl) | ||
52 | { | ||
53 | u8 *cmd; | ||
54 | struct spi_transfer t; | ||
55 | struct spi_message m; | ||
56 | |||
57 | cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); | ||
58 | if (!cmd) { | ||
59 | wl1251_error("could not allocate cmd for spi reset"); | ||
60 | return; | ||
61 | } | ||
62 | |||
63 | memset(&t, 0, sizeof(t)); | ||
64 | spi_message_init(&m); | ||
65 | |||
66 | memset(cmd, 0xff, WSPI_INIT_CMD_LEN); | ||
67 | |||
68 | t.tx_buf = cmd; | ||
69 | t.len = WSPI_INIT_CMD_LEN; | ||
70 | spi_message_add_tail(&t, &m); | ||
71 | |||
72 | spi_sync(wl_to_spi(wl), &m); | ||
73 | |||
74 | wl1251_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); | ||
75 | } | ||
76 | |||
77 | static void wl1251_spi_wake(struct wl1251 *wl) | ||
78 | { | ||
79 | u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; | ||
80 | struct spi_transfer t; | ||
81 | struct spi_message m; | ||
82 | |||
83 | cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); | ||
84 | if (!cmd) { | ||
85 | wl1251_error("could not allocate cmd for spi init"); | ||
86 | return; | ||
87 | } | ||
88 | |||
89 | memset(crc, 0, sizeof(crc)); | ||
90 | memset(&t, 0, sizeof(t)); | ||
91 | spi_message_init(&m); | ||
92 | |||
93 | /* | ||
94 | * Set WSPI_INIT_COMMAND | ||
95 | * the data is being send from the MSB to LSB | ||
96 | */ | ||
97 | cmd[2] = 0xff; | ||
98 | cmd[3] = 0xff; | ||
99 | cmd[1] = WSPI_INIT_CMD_START | WSPI_INIT_CMD_TX; | ||
100 | cmd[0] = 0; | ||
101 | cmd[7] = 0; | ||
102 | cmd[6] |= HW_ACCESS_WSPI_INIT_CMD_MASK << 3; | ||
103 | cmd[6] |= HW_ACCESS_WSPI_FIXED_BUSY_LEN & WSPI_INIT_CMD_FIXEDBUSY_LEN; | ||
104 | |||
105 | if (HW_ACCESS_WSPI_FIXED_BUSY_LEN == 0) | ||
106 | cmd[5] |= WSPI_INIT_CMD_DIS_FIXEDBUSY; | ||
107 | else | ||
108 | cmd[5] |= WSPI_INIT_CMD_EN_FIXEDBUSY; | ||
109 | |||
110 | cmd[5] |= WSPI_INIT_CMD_IOD | WSPI_INIT_CMD_IP | WSPI_INIT_CMD_CS | ||
111 | | WSPI_INIT_CMD_WSPI | WSPI_INIT_CMD_WS; | ||
112 | |||
113 | crc[0] = cmd[1]; | ||
114 | crc[1] = cmd[0]; | ||
115 | crc[2] = cmd[7]; | ||
116 | crc[3] = cmd[6]; | ||
117 | crc[4] = cmd[5]; | ||
118 | |||
119 | cmd[4] |= crc7(0, crc, WSPI_INIT_CMD_CRC_LEN) << 1; | ||
120 | cmd[4] |= WSPI_INIT_CMD_END; | ||
121 | |||
122 | t.tx_buf = cmd; | ||
123 | t.len = WSPI_INIT_CMD_LEN; | ||
124 | spi_message_add_tail(&t, &m); | ||
125 | |||
126 | spi_sync(wl_to_spi(wl), &m); | ||
127 | |||
128 | wl1251_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); | ||
129 | } | ||
130 | |||
131 | static void wl1251_spi_reset_wake(struct wl1251 *wl) | ||
132 | { | ||
133 | wl1251_spi_reset(wl); | ||
134 | wl1251_spi_wake(wl); | ||
135 | } | ||
136 | |||
137 | static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, | ||
138 | size_t len) | ||
139 | { | ||
140 | struct spi_transfer t[3]; | ||
141 | struct spi_message m; | ||
142 | u8 *busy_buf; | ||
143 | u32 *cmd; | ||
144 | |||
145 | cmd = &wl->buffer_cmd; | ||
146 | busy_buf = wl->buffer_busyword; | ||
147 | |||
148 | *cmd = 0; | ||
149 | *cmd |= WSPI_CMD_READ; | ||
150 | *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; | ||
151 | *cmd |= addr & WSPI_CMD_BYTE_ADDR; | ||
152 | |||
153 | spi_message_init(&m); | ||
154 | memset(t, 0, sizeof(t)); | ||
155 | |||
156 | t[0].tx_buf = cmd; | ||
157 | t[0].len = 4; | ||
158 | spi_message_add_tail(&t[0], &m); | ||
159 | |||
160 | /* Busy and non busy words read */ | ||
161 | t[1].rx_buf = busy_buf; | ||
162 | t[1].len = WL1251_BUSY_WORD_LEN; | ||
163 | spi_message_add_tail(&t[1], &m); | ||
164 | |||
165 | t[2].rx_buf = buf; | ||
166 | t[2].len = len; | ||
167 | spi_message_add_tail(&t[2], &m); | ||
168 | |||
169 | spi_sync(wl_to_spi(wl), &m); | ||
170 | |||
171 | /* FIXME: check busy words */ | ||
172 | |||
173 | wl1251_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); | ||
174 | wl1251_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); | ||
175 | } | ||
176 | |||
177 | static void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, | ||
178 | size_t len) | ||
179 | { | ||
180 | struct spi_transfer t[2]; | ||
181 | struct spi_message m; | ||
182 | u32 *cmd; | ||
183 | |||
184 | cmd = &wl->buffer_cmd; | ||
185 | |||
186 | *cmd = 0; | ||
187 | *cmd |= WSPI_CMD_WRITE; | ||
188 | *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; | ||
189 | *cmd |= addr & WSPI_CMD_BYTE_ADDR; | ||
190 | |||
191 | spi_message_init(&m); | ||
192 | memset(t, 0, sizeof(t)); | ||
193 | |||
194 | t[0].tx_buf = cmd; | ||
195 | t[0].len = sizeof(*cmd); | ||
196 | spi_message_add_tail(&t[0], &m); | ||
197 | |||
198 | t[1].tx_buf = buf; | ||
199 | t[1].len = len; | ||
200 | spi_message_add_tail(&t[1], &m); | ||
201 | |||
202 | spi_sync(wl_to_spi(wl), &m); | ||
203 | |||
204 | wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); | ||
205 | wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); | ||
206 | } | ||
207 | |||
208 | static void wl1251_spi_enable_irq(struct wl1251 *wl) | ||
209 | { | ||
210 | return enable_irq(wl->irq); | ||
211 | } | ||
212 | |||
213 | static void wl1251_spi_disable_irq(struct wl1251 *wl) | ||
214 | { | ||
215 | return disable_irq(wl->irq); | ||
216 | } | ||
217 | |||
218 | static const struct wl1251_if_operations wl1251_spi_ops = { | ||
219 | .read = wl1251_spi_read, | ||
220 | .write = wl1251_spi_write, | ||
221 | .reset = wl1251_spi_reset_wake, | ||
222 | .enable_irq = wl1251_spi_enable_irq, | ||
223 | .disable_irq = wl1251_spi_disable_irq, | ||
224 | }; | ||
225 | |||
226 | static int __devinit wl1251_spi_probe(struct spi_device *spi) | ||
227 | { | ||
228 | struct wl12xx_platform_data *pdata; | ||
229 | struct ieee80211_hw *hw; | ||
230 | struct wl1251 *wl; | ||
231 | int ret; | ||
232 | |||
233 | pdata = spi->dev.platform_data; | ||
234 | if (!pdata) { | ||
235 | wl1251_error("no platform data"); | ||
236 | return -ENODEV; | ||
237 | } | ||
238 | |||
239 | hw = wl1251_alloc_hw(); | ||
240 | if (IS_ERR(hw)) | ||
241 | return PTR_ERR(hw); | ||
242 | |||
243 | wl = hw->priv; | ||
244 | |||
245 | SET_IEEE80211_DEV(hw, &spi->dev); | ||
246 | dev_set_drvdata(&spi->dev, wl); | ||
247 | wl->if_priv = spi; | ||
248 | wl->if_ops = &wl1251_spi_ops; | ||
249 | |||
250 | /* This is the only SPI value that we need to set here, the rest | ||
251 | * comes from the board-peripherals file */ | ||
252 | spi->bits_per_word = 32; | ||
253 | |||
254 | ret = spi_setup(spi); | ||
255 | if (ret < 0) { | ||
256 | wl1251_error("spi_setup failed"); | ||
257 | goto out_free; | ||
258 | } | ||
259 | |||
260 | wl->set_power = pdata->set_power; | ||
261 | if (!wl->set_power) { | ||
262 | wl1251_error("set power function missing in platform data"); | ||
263 | return -ENODEV; | ||
264 | } | ||
265 | |||
266 | wl->irq = spi->irq; | ||
267 | if (wl->irq < 0) { | ||
268 | wl1251_error("irq missing in platform data"); | ||
269 | return -ENODEV; | ||
270 | } | ||
271 | |||
272 | wl->use_eeprom = pdata->use_eeprom; | ||
273 | |||
274 | ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl); | ||
275 | if (ret < 0) { | ||
276 | wl1251_error("request_irq() failed: %d", ret); | ||
277 | goto out_free; | ||
278 | } | ||
279 | |||
280 | set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); | ||
281 | |||
282 | disable_irq(wl->irq); | ||
283 | |||
284 | ret = wl1251_init_ieee80211(wl); | ||
285 | if (ret) | ||
286 | goto out_irq; | ||
287 | |||
288 | return 0; | ||
289 | |||
290 | out_irq: | ||
291 | free_irq(wl->irq, wl); | ||
292 | |||
293 | out_free: | ||
294 | ieee80211_free_hw(hw); | ||
295 | |||
296 | return ret; | ||
297 | } | ||
298 | |||
299 | static int __devexit wl1251_spi_remove(struct spi_device *spi) | ||
300 | { | ||
301 | struct wl1251 *wl = dev_get_drvdata(&spi->dev); | ||
302 | |||
303 | free_irq(wl->irq, wl); | ||
304 | wl1251_free_hw(wl); | ||
305 | |||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | static struct spi_driver wl1251_spi_driver = { | ||
310 | .driver = { | ||
311 | .name = DRIVER_NAME, | ||
312 | .bus = &spi_bus_type, | ||
313 | .owner = THIS_MODULE, | ||
314 | }, | ||
315 | |||
316 | .probe = wl1251_spi_probe, | ||
317 | .remove = __devexit_p(wl1251_spi_remove), | ||
318 | }; | ||
319 | |||
320 | static int __init wl1251_spi_init(void) | ||
321 | { | ||
322 | int ret; | ||
323 | |||
324 | ret = spi_register_driver(&wl1251_spi_driver); | ||
325 | if (ret < 0) { | ||
326 | wl1251_error("failed to register spi driver: %d", ret); | ||
327 | goto out; | ||
328 | } | ||
329 | |||
330 | out: | ||
331 | return ret; | ||
332 | } | ||
333 | |||
334 | static void __exit wl1251_spi_exit(void) | ||
335 | { | ||
336 | spi_unregister_driver(&wl1251_spi_driver); | ||
337 | |||
338 | wl1251_notice("unloaded"); | ||
339 | } | ||
340 | |||
341 | module_init(wl1251_spi_init); | ||
342 | module_exit(wl1251_spi_exit); | ||
343 | |||
344 | MODULE_LICENSE("GPL"); | ||
345 | MODULE_AUTHOR("Kalle Valo <kvalo@adurom.com>"); | ||
346 | MODULE_ALIAS("spi:wl1251"); | ||
diff --git a/drivers/net/wireless/wl1251/spi.h b/drivers/net/wireless/wl1251/spi.h new file mode 100644 index 000000000000..16d506955cc0 --- /dev/null +++ b/drivers/net/wireless/wl1251/spi.h | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __WL1251_SPI_H__ | ||
24 | #define __WL1251_SPI_H__ | ||
25 | |||
26 | #include "cmd.h" | ||
27 | #include "acx.h" | ||
28 | #include "reg.h" | ||
29 | |||
30 | #define WSPI_CMD_READ 0x40000000 | ||
31 | #define WSPI_CMD_WRITE 0x00000000 | ||
32 | #define WSPI_CMD_FIXED 0x20000000 | ||
33 | #define WSPI_CMD_BYTE_LENGTH 0x1FFE0000 | ||
34 | #define WSPI_CMD_BYTE_LENGTH_OFFSET 17 | ||
35 | #define WSPI_CMD_BYTE_ADDR 0x0001FFFF | ||
36 | |||
37 | #define WSPI_INIT_CMD_CRC_LEN 5 | ||
38 | |||
39 | #define WSPI_INIT_CMD_START 0x00 | ||
40 | #define WSPI_INIT_CMD_TX 0x40 | ||
41 | /* the extra bypass bit is sampled by the TNET as '1' */ | ||
42 | #define WSPI_INIT_CMD_BYPASS_BIT 0x80 | ||
43 | #define WSPI_INIT_CMD_FIXEDBUSY_LEN 0x07 | ||
44 | #define WSPI_INIT_CMD_EN_FIXEDBUSY 0x80 | ||
45 | #define WSPI_INIT_CMD_DIS_FIXEDBUSY 0x00 | ||
46 | #define WSPI_INIT_CMD_IOD 0x40 | ||
47 | #define WSPI_INIT_CMD_IP 0x20 | ||
48 | #define WSPI_INIT_CMD_CS 0x10 | ||
49 | #define WSPI_INIT_CMD_WS 0x08 | ||
50 | #define WSPI_INIT_CMD_WSPI 0x01 | ||
51 | #define WSPI_INIT_CMD_END 0x01 | ||
52 | |||
53 | #define WSPI_INIT_CMD_LEN 8 | ||
54 | |||
55 | #define HW_ACCESS_WSPI_FIXED_BUSY_LEN \ | ||
56 | ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32)) | ||
57 | #define HW_ACCESS_WSPI_INIT_CMD_MASK 0 | ||
58 | |||
59 | #endif /* __WL1251_SPI_H__ */ | ||
diff --git a/drivers/net/wireless/wl1251/tx.c b/drivers/net/wireless/wl1251/tx.c new file mode 100644 index 000000000000..554b4f9a3d3e --- /dev/null +++ b/drivers/net/wireless/wl1251/tx.c | |||
@@ -0,0 +1,570 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/kernel.h> | ||
24 | #include <linux/module.h> | ||
25 | |||
26 | #include "wl1251.h" | ||
27 | #include "reg.h" | ||
28 | #include "tx.h" | ||
29 | #include "ps.h" | ||
30 | #include "io.h" | ||
31 | |||
32 | static bool wl1251_tx_double_buffer_busy(struct wl1251 *wl, u32 data_out_count) | ||
33 | { | ||
34 | int used, data_in_count; | ||
35 | |||
36 | data_in_count = wl->data_in_count; | ||
37 | |||
38 | if (data_in_count < data_out_count) | ||
39 | /* data_in_count has wrapped */ | ||
40 | data_in_count += TX_STATUS_DATA_OUT_COUNT_MASK + 1; | ||
41 | |||
42 | used = data_in_count - data_out_count; | ||
43 | |||
44 | WARN_ON(used < 0); | ||
45 | WARN_ON(used > DP_TX_PACKET_RING_CHUNK_NUM); | ||
46 | |||
47 | if (used >= DP_TX_PACKET_RING_CHUNK_NUM) | ||
48 | return true; | ||
49 | else | ||
50 | return false; | ||
51 | } | ||
52 | |||
53 | static int wl1251_tx_path_status(struct wl1251 *wl) | ||
54 | { | ||
55 | u32 status, addr, data_out_count; | ||
56 | bool busy; | ||
57 | |||
58 | addr = wl->data_path->tx_control_addr; | ||
59 | status = wl1251_mem_read32(wl, addr); | ||
60 | data_out_count = status & TX_STATUS_DATA_OUT_COUNT_MASK; | ||
61 | busy = wl1251_tx_double_buffer_busy(wl, data_out_count); | ||
62 | |||
63 | if (busy) | ||
64 | return -EBUSY; | ||
65 | |||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | static int wl1251_tx_id(struct wl1251 *wl, struct sk_buff *skb) | ||
70 | { | ||
71 | int i; | ||
72 | |||
73 | for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++) | ||
74 | if (wl->tx_frames[i] == NULL) { | ||
75 | wl->tx_frames[i] = skb; | ||
76 | return i; | ||
77 | } | ||
78 | |||
79 | return -EBUSY; | ||
80 | } | ||
81 | |||
82 | static void wl1251_tx_control(struct tx_double_buffer_desc *tx_hdr, | ||
83 | struct ieee80211_tx_info *control, u16 fc) | ||
84 | { | ||
85 | *(u16 *)&tx_hdr->control = 0; | ||
86 | |||
87 | tx_hdr->control.rate_policy = 0; | ||
88 | |||
89 | /* 802.11 packets */ | ||
90 | tx_hdr->control.packet_type = 0; | ||
91 | |||
92 | if (control->flags & IEEE80211_TX_CTL_NO_ACK) | ||
93 | tx_hdr->control.ack_policy = 1; | ||
94 | |||
95 | tx_hdr->control.tx_complete = 1; | ||
96 | |||
97 | if ((fc & IEEE80211_FTYPE_DATA) && | ||
98 | ((fc & IEEE80211_STYPE_QOS_DATA) || | ||
99 | (fc & IEEE80211_STYPE_QOS_NULLFUNC))) | ||
100 | tx_hdr->control.qos = 1; | ||
101 | } | ||
102 | |||
103 | /* RSN + MIC = 8 + 8 = 16 bytes (worst case - AES). */ | ||
104 | #define MAX_MSDU_SECURITY_LENGTH 16 | ||
105 | #define MAX_MPDU_SECURITY_LENGTH 16 | ||
106 | #define WLAN_QOS_HDR_LEN 26 | ||
107 | #define MAX_MPDU_HEADER_AND_SECURITY (MAX_MPDU_SECURITY_LENGTH + \ | ||
108 | WLAN_QOS_HDR_LEN) | ||
109 | #define HW_BLOCK_SIZE 252 | ||
110 | static void wl1251_tx_frag_block_num(struct tx_double_buffer_desc *tx_hdr) | ||
111 | { | ||
112 | u16 payload_len, frag_threshold, mem_blocks; | ||
113 | u16 num_mpdus, mem_blocks_per_frag; | ||
114 | |||
115 | frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD; | ||
116 | tx_hdr->frag_threshold = cpu_to_le16(frag_threshold); | ||
117 | |||
118 | payload_len = le16_to_cpu(tx_hdr->length) + MAX_MSDU_SECURITY_LENGTH; | ||
119 | |||
120 | if (payload_len > frag_threshold) { | ||
121 | mem_blocks_per_frag = | ||
122 | ((frag_threshold + MAX_MPDU_HEADER_AND_SECURITY) / | ||
123 | HW_BLOCK_SIZE) + 1; | ||
124 | num_mpdus = payload_len / frag_threshold; | ||
125 | mem_blocks = num_mpdus * mem_blocks_per_frag; | ||
126 | payload_len -= num_mpdus * frag_threshold; | ||
127 | num_mpdus++; | ||
128 | |||
129 | } else { | ||
130 | mem_blocks_per_frag = 0; | ||
131 | mem_blocks = 0; | ||
132 | num_mpdus = 1; | ||
133 | } | ||
134 | |||
135 | mem_blocks += (payload_len / HW_BLOCK_SIZE) + 1; | ||
136 | |||
137 | if (num_mpdus > 1) | ||
138 | mem_blocks += min(num_mpdus, mem_blocks_per_frag); | ||
139 | |||
140 | tx_hdr->num_mem_blocks = mem_blocks; | ||
141 | } | ||
142 | |||
143 | static int wl1251_tx_fill_hdr(struct wl1251 *wl, struct sk_buff *skb, | ||
144 | struct ieee80211_tx_info *control) | ||
145 | { | ||
146 | struct tx_double_buffer_desc *tx_hdr; | ||
147 | struct ieee80211_rate *rate; | ||
148 | int id; | ||
149 | u16 fc; | ||
150 | |||
151 | if (!skb) | ||
152 | return -EINVAL; | ||
153 | |||
154 | id = wl1251_tx_id(wl, skb); | ||
155 | if (id < 0) | ||
156 | return id; | ||
157 | |||
158 | fc = *(u16 *)skb->data; | ||
159 | tx_hdr = (struct tx_double_buffer_desc *) skb_push(skb, | ||
160 | sizeof(*tx_hdr)); | ||
161 | |||
162 | tx_hdr->length = cpu_to_le16(skb->len - sizeof(*tx_hdr)); | ||
163 | rate = ieee80211_get_tx_rate(wl->hw, control); | ||
164 | tx_hdr->rate = cpu_to_le16(rate->hw_value); | ||
165 | tx_hdr->expiry_time = cpu_to_le32(1 << 16); | ||
166 | tx_hdr->id = id; | ||
167 | |||
168 | tx_hdr->xmit_queue = wl1251_tx_get_queue(skb_get_queue_mapping(skb)); | ||
169 | |||
170 | wl1251_tx_control(tx_hdr, control, fc); | ||
171 | wl1251_tx_frag_block_num(tx_hdr); | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | /* We copy the packet to the target */ | ||
177 | static int wl1251_tx_send_packet(struct wl1251 *wl, struct sk_buff *skb, | ||
178 | struct ieee80211_tx_info *control) | ||
179 | { | ||
180 | struct tx_double_buffer_desc *tx_hdr; | ||
181 | int len; | ||
182 | u32 addr; | ||
183 | |||
184 | if (!skb) | ||
185 | return -EINVAL; | ||
186 | |||
187 | tx_hdr = (struct tx_double_buffer_desc *) skb->data; | ||
188 | |||
189 | if (control->control.hw_key && | ||
190 | control->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) { | ||
191 | int hdrlen; | ||
192 | __le16 fc; | ||
193 | u16 length; | ||
194 | u8 *pos; | ||
195 | |||
196 | fc = *(__le16 *)(skb->data + sizeof(*tx_hdr)); | ||
197 | length = le16_to_cpu(tx_hdr->length) + WL1251_TKIP_IV_SPACE; | ||
198 | tx_hdr->length = cpu_to_le16(length); | ||
199 | |||
200 | hdrlen = ieee80211_hdrlen(fc); | ||
201 | |||
202 | pos = skb_push(skb, WL1251_TKIP_IV_SPACE); | ||
203 | memmove(pos, pos + WL1251_TKIP_IV_SPACE, | ||
204 | sizeof(*tx_hdr) + hdrlen); | ||
205 | } | ||
206 | |||
207 | /* Revisit. This is a workaround for getting non-aligned packets. | ||
208 | This happens at least with EAPOL packets from the user space. | ||
209 | Our DMA requires packets to be aligned on a 4-byte boundary. | ||
210 | */ | ||
211 | if (unlikely((long)skb->data & 0x03)) { | ||
212 | int offset = (4 - (long)skb->data) & 0x03; | ||
213 | wl1251_debug(DEBUG_TX, "skb offset %d", offset); | ||
214 | |||
215 | /* check whether the current skb can be used */ | ||
216 | if (!skb_cloned(skb) && (skb_tailroom(skb) >= offset)) { | ||
217 | unsigned char *src = skb->data; | ||
218 | |||
219 | /* align the buffer on a 4-byte boundary */ | ||
220 | skb_reserve(skb, offset); | ||
221 | memmove(skb->data, src, skb->len); | ||
222 | tx_hdr = (struct tx_double_buffer_desc *) skb->data; | ||
223 | } else { | ||
224 | wl1251_info("No handler, fixme!"); | ||
225 | return -EINVAL; | ||
226 | } | ||
227 | } | ||
228 | |||
229 | /* Our skb->data at this point includes the HW header */ | ||
230 | len = WL1251_TX_ALIGN(skb->len); | ||
231 | |||
232 | if (wl->data_in_count & 0x1) | ||
233 | addr = wl->data_path->tx_packet_ring_addr + | ||
234 | wl->data_path->tx_packet_ring_chunk_size; | ||
235 | else | ||
236 | addr = wl->data_path->tx_packet_ring_addr; | ||
237 | |||
238 | wl1251_mem_write(wl, addr, skb->data, len); | ||
239 | |||
240 | wl1251_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u rate 0x%x " | ||
241 | "queue %d", tx_hdr->id, skb, tx_hdr->length, | ||
242 | tx_hdr->rate, tx_hdr->xmit_queue); | ||
243 | |||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static void wl1251_tx_trigger(struct wl1251 *wl) | ||
248 | { | ||
249 | u32 data, addr; | ||
250 | |||
251 | if (wl->data_in_count & 0x1) { | ||
252 | addr = ACX_REG_INTERRUPT_TRIG_H; | ||
253 | data = INTR_TRIG_TX_PROC1; | ||
254 | } else { | ||
255 | addr = ACX_REG_INTERRUPT_TRIG; | ||
256 | data = INTR_TRIG_TX_PROC0; | ||
257 | } | ||
258 | |||
259 | wl1251_reg_write32(wl, addr, data); | ||
260 | |||
261 | /* Bumping data in */ | ||
262 | wl->data_in_count = (wl->data_in_count + 1) & | ||
263 | TX_STATUS_DATA_OUT_COUNT_MASK; | ||
264 | } | ||
265 | |||
266 | /* caller must hold wl->mutex */ | ||
267 | static int wl1251_tx_frame(struct wl1251 *wl, struct sk_buff *skb) | ||
268 | { | ||
269 | struct ieee80211_tx_info *info; | ||
270 | int ret = 0; | ||
271 | u8 idx; | ||
272 | |||
273 | info = IEEE80211_SKB_CB(skb); | ||
274 | |||
275 | if (info->control.hw_key) { | ||
276 | idx = info->control.hw_key->hw_key_idx; | ||
277 | if (unlikely(wl->default_key != idx)) { | ||
278 | ret = wl1251_acx_default_key(wl, idx); | ||
279 | if (ret < 0) | ||
280 | return ret; | ||
281 | } | ||
282 | } | ||
283 | |||
284 | ret = wl1251_tx_path_status(wl); | ||
285 | if (ret < 0) | ||
286 | return ret; | ||
287 | |||
288 | ret = wl1251_tx_fill_hdr(wl, skb, info); | ||
289 | if (ret < 0) | ||
290 | return ret; | ||
291 | |||
292 | ret = wl1251_tx_send_packet(wl, skb, info); | ||
293 | if (ret < 0) | ||
294 | return ret; | ||
295 | |||
296 | wl1251_tx_trigger(wl); | ||
297 | |||
298 | return ret; | ||
299 | } | ||
300 | |||
301 | void wl1251_tx_work(struct work_struct *work) | ||
302 | { | ||
303 | struct wl1251 *wl = container_of(work, struct wl1251, tx_work); | ||
304 | struct sk_buff *skb; | ||
305 | bool woken_up = false; | ||
306 | int ret; | ||
307 | |||
308 | mutex_lock(&wl->mutex); | ||
309 | |||
310 | if (unlikely(wl->state == WL1251_STATE_OFF)) | ||
311 | goto out; | ||
312 | |||
313 | while ((skb = skb_dequeue(&wl->tx_queue))) { | ||
314 | if (!woken_up) { | ||
315 | ret = wl1251_ps_elp_wakeup(wl); | ||
316 | if (ret < 0) | ||
317 | goto out; | ||
318 | woken_up = true; | ||
319 | } | ||
320 | |||
321 | ret = wl1251_tx_frame(wl, skb); | ||
322 | if (ret == -EBUSY) { | ||
323 | skb_queue_head(&wl->tx_queue, skb); | ||
324 | goto out; | ||
325 | } else if (ret < 0) { | ||
326 | dev_kfree_skb(skb); | ||
327 | goto out; | ||
328 | } | ||
329 | } | ||
330 | |||
331 | out: | ||
332 | if (woken_up) | ||
333 | wl1251_ps_elp_sleep(wl); | ||
334 | |||
335 | mutex_unlock(&wl->mutex); | ||
336 | } | ||
337 | |||
338 | static const char *wl1251_tx_parse_status(u8 status) | ||
339 | { | ||
340 | /* 8 bit status field, one character per bit plus null */ | ||
341 | static char buf[9]; | ||
342 | int i = 0; | ||
343 | |||
344 | memset(buf, 0, sizeof(buf)); | ||
345 | |||
346 | if (status & TX_DMA_ERROR) | ||
347 | buf[i++] = 'm'; | ||
348 | if (status & TX_DISABLED) | ||
349 | buf[i++] = 'd'; | ||
350 | if (status & TX_RETRY_EXCEEDED) | ||
351 | buf[i++] = 'r'; | ||
352 | if (status & TX_TIMEOUT) | ||
353 | buf[i++] = 't'; | ||
354 | if (status & TX_KEY_NOT_FOUND) | ||
355 | buf[i++] = 'k'; | ||
356 | if (status & TX_ENCRYPT_FAIL) | ||
357 | buf[i++] = 'e'; | ||
358 | if (status & TX_UNAVAILABLE_PRIORITY) | ||
359 | buf[i++] = 'p'; | ||
360 | |||
361 | /* bit 0 is unused apparently */ | ||
362 | |||
363 | return buf; | ||
364 | } | ||
365 | |||
366 | static void wl1251_tx_packet_cb(struct wl1251 *wl, | ||
367 | struct tx_result *result) | ||
368 | { | ||
369 | struct ieee80211_tx_info *info; | ||
370 | struct sk_buff *skb; | ||
371 | int hdrlen, ret; | ||
372 | u8 *frame; | ||
373 | |||
374 | skb = wl->tx_frames[result->id]; | ||
375 | if (skb == NULL) { | ||
376 | wl1251_error("SKB for packet %d is NULL", result->id); | ||
377 | return; | ||
378 | } | ||
379 | |||
380 | info = IEEE80211_SKB_CB(skb); | ||
381 | |||
382 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && | ||
383 | (result->status == TX_SUCCESS)) | ||
384 | info->flags |= IEEE80211_TX_STAT_ACK; | ||
385 | |||
386 | info->status.rates[0].count = result->ack_failures + 1; | ||
387 | wl->stats.retry_count += result->ack_failures; | ||
388 | |||
389 | /* | ||
390 | * We have to remove our private TX header before pushing | ||
391 | * the skb back to mac80211. | ||
392 | */ | ||
393 | frame = skb_pull(skb, sizeof(struct tx_double_buffer_desc)); | ||
394 | if (info->control.hw_key && | ||
395 | info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) { | ||
396 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | ||
397 | memmove(frame + WL1251_TKIP_IV_SPACE, frame, hdrlen); | ||
398 | skb_pull(skb, WL1251_TKIP_IV_SPACE); | ||
399 | } | ||
400 | |||
401 | wl1251_debug(DEBUG_TX, "tx status id %u skb 0x%p failures %u rate 0x%x" | ||
402 | " status 0x%x (%s)", | ||
403 | result->id, skb, result->ack_failures, result->rate, | ||
404 | result->status, wl1251_tx_parse_status(result->status)); | ||
405 | |||
406 | |||
407 | ieee80211_tx_status(wl->hw, skb); | ||
408 | |||
409 | wl->tx_frames[result->id] = NULL; | ||
410 | |||
411 | if (wl->tx_queue_stopped) { | ||
412 | wl1251_debug(DEBUG_TX, "cb: queue was stopped"); | ||
413 | |||
414 | skb = skb_dequeue(&wl->tx_queue); | ||
415 | |||
416 | /* The skb can be NULL because tx_work might have been | ||
417 | scheduled before the queue was stopped making the | ||
418 | queue empty */ | ||
419 | |||
420 | if (skb) { | ||
421 | ret = wl1251_tx_frame(wl, skb); | ||
422 | if (ret == -EBUSY) { | ||
423 | /* firmware buffer is still full */ | ||
424 | wl1251_debug(DEBUG_TX, "cb: fw buffer " | ||
425 | "still full"); | ||
426 | skb_queue_head(&wl->tx_queue, skb); | ||
427 | return; | ||
428 | } else if (ret < 0) { | ||
429 | dev_kfree_skb(skb); | ||
430 | return; | ||
431 | } | ||
432 | } | ||
433 | |||
434 | wl1251_debug(DEBUG_TX, "cb: waking queues"); | ||
435 | ieee80211_wake_queues(wl->hw); | ||
436 | wl->tx_queue_stopped = false; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | /* Called upon reception of a TX complete interrupt */ | ||
441 | void wl1251_tx_complete(struct wl1251 *wl) | ||
442 | { | ||
443 | int i, result_index, num_complete = 0; | ||
444 | struct tx_result result[FW_TX_CMPLT_BLOCK_SIZE], *result_ptr; | ||
445 | unsigned long flags; | ||
446 | |||
447 | if (unlikely(wl->state != WL1251_STATE_ON)) | ||
448 | return; | ||
449 | |||
450 | /* First we read the result */ | ||
451 | wl1251_mem_read(wl, wl->data_path->tx_complete_addr, | ||
452 | result, sizeof(result)); | ||
453 | |||
454 | result_index = wl->next_tx_complete; | ||
455 | |||
456 | for (i = 0; i < ARRAY_SIZE(result); i++) { | ||
457 | result_ptr = &result[result_index]; | ||
458 | |||
459 | if (result_ptr->done_1 == 1 && | ||
460 | result_ptr->done_2 == 1) { | ||
461 | wl1251_tx_packet_cb(wl, result_ptr); | ||
462 | |||
463 | result_ptr->done_1 = 0; | ||
464 | result_ptr->done_2 = 0; | ||
465 | |||
466 | result_index = (result_index + 1) & | ||
467 | (FW_TX_CMPLT_BLOCK_SIZE - 1); | ||
468 | num_complete++; | ||
469 | } else { | ||
470 | break; | ||
471 | } | ||
472 | } | ||
473 | |||
474 | if (wl->tx_queue_stopped | ||
475 | && | ||
476 | skb_queue_len(&wl->tx_queue) <= WL1251_TX_QUEUE_LOW_WATERMARK){ | ||
477 | |||
478 | /* firmware buffer has space, restart queues */ | ||
479 | wl1251_debug(DEBUG_TX, "tx_complete: waking queues"); | ||
480 | spin_lock_irqsave(&wl->wl_lock, flags); | ||
481 | ieee80211_wake_queues(wl->hw); | ||
482 | wl->tx_queue_stopped = false; | ||
483 | spin_unlock_irqrestore(&wl->wl_lock, flags); | ||
484 | ieee80211_queue_work(wl->hw, &wl->tx_work); | ||
485 | |||
486 | } | ||
487 | |||
488 | /* Every completed frame needs to be acknowledged */ | ||
489 | if (num_complete) { | ||
490 | /* | ||
491 | * If we've wrapped, we have to clear | ||
492 | * the results in 2 steps. | ||
493 | */ | ||
494 | if (result_index > wl->next_tx_complete) { | ||
495 | /* Only 1 write is needed */ | ||
496 | wl1251_mem_write(wl, | ||
497 | wl->data_path->tx_complete_addr + | ||
498 | (wl->next_tx_complete * | ||
499 | sizeof(struct tx_result)), | ||
500 | &result[wl->next_tx_complete], | ||
501 | num_complete * | ||
502 | sizeof(struct tx_result)); | ||
503 | |||
504 | |||
505 | } else if (result_index < wl->next_tx_complete) { | ||
506 | /* 2 writes are needed */ | ||
507 | wl1251_mem_write(wl, | ||
508 | wl->data_path->tx_complete_addr + | ||
509 | (wl->next_tx_complete * | ||
510 | sizeof(struct tx_result)), | ||
511 | &result[wl->next_tx_complete], | ||
512 | (FW_TX_CMPLT_BLOCK_SIZE - | ||
513 | wl->next_tx_complete) * | ||
514 | sizeof(struct tx_result)); | ||
515 | |||
516 | wl1251_mem_write(wl, | ||
517 | wl->data_path->tx_complete_addr, | ||
518 | result, | ||
519 | (num_complete - | ||
520 | FW_TX_CMPLT_BLOCK_SIZE + | ||
521 | wl->next_tx_complete) * | ||
522 | sizeof(struct tx_result)); | ||
523 | |||
524 | } else { | ||
525 | /* We have to write the whole array */ | ||
526 | wl1251_mem_write(wl, | ||
527 | wl->data_path->tx_complete_addr, | ||
528 | result, | ||
529 | FW_TX_CMPLT_BLOCK_SIZE * | ||
530 | sizeof(struct tx_result)); | ||
531 | } | ||
532 | |||
533 | } | ||
534 | |||
535 | wl->next_tx_complete = result_index; | ||
536 | } | ||
537 | |||
538 | /* caller must hold wl->mutex */ | ||
539 | void wl1251_tx_flush(struct wl1251 *wl) | ||
540 | { | ||
541 | int i; | ||
542 | struct sk_buff *skb; | ||
543 | struct ieee80211_tx_info *info; | ||
544 | |||
545 | /* TX failure */ | ||
546 | /* control->flags = 0; FIXME */ | ||
547 | |||
548 | while ((skb = skb_dequeue(&wl->tx_queue))) { | ||
549 | info = IEEE80211_SKB_CB(skb); | ||
550 | |||
551 | wl1251_debug(DEBUG_TX, "flushing skb 0x%p", skb); | ||
552 | |||
553 | if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) | ||
554 | continue; | ||
555 | |||
556 | ieee80211_tx_status(wl->hw, skb); | ||
557 | } | ||
558 | |||
559 | for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++) | ||
560 | if (wl->tx_frames[i] != NULL) { | ||
561 | skb = wl->tx_frames[i]; | ||
562 | info = IEEE80211_SKB_CB(skb); | ||
563 | |||
564 | if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) | ||
565 | continue; | ||
566 | |||
567 | ieee80211_tx_status(wl->hw, skb); | ||
568 | wl->tx_frames[i] = NULL; | ||
569 | } | ||
570 | } | ||
diff --git a/drivers/net/wireless/wl1251/tx.h b/drivers/net/wireless/wl1251/tx.h new file mode 100644 index 000000000000..81338d39b43e --- /dev/null +++ b/drivers/net/wireless/wl1251/tx.h | |||
@@ -0,0 +1,231 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __WL1251_TX_H__ | ||
24 | #define __WL1251_TX_H__ | ||
25 | |||
26 | #include <linux/bitops.h> | ||
27 | #include "acx.h" | ||
28 | |||
29 | /* | ||
30 | * | ||
31 | * TX PATH | ||
32 | * | ||
33 | * The Tx path uses a double buffer and a tx_control structure, each located | ||
34 | * at a fixed address in the device's memory. On startup, the host retrieves | ||
35 | * the pointers to these addresses. A double buffer allows for continuous data | ||
36 | * flow towards the device. The host keeps track of which buffer is available | ||
37 | * and alternates between these two buffers on a per packet basis. | ||
38 | * | ||
39 | * The size of each of the two buffers is large enough to hold the longest | ||
40 | * 802.3 packet - maximum size Ethernet packet + header + descriptor. | ||
41 | * TX complete indication will be received a-synchronously in a TX done cyclic | ||
42 | * buffer which is composed of 16 tx_result descriptors structures and is used | ||
43 | * in a cyclic manner. | ||
44 | * | ||
45 | * The TX (HOST) procedure is as follows: | ||
46 | * 1. Read the Tx path status, that will give the data_out_count. | ||
47 | * 2. goto 1, if not possible. | ||
48 | * i.e. if data_in_count - data_out_count >= HwBuffer size (2 for double | ||
49 | * buffer). | ||
50 | * 3. Copy the packet (preceded by double_buffer_desc), if possible. | ||
51 | * i.e. if data_in_count - data_out_count < HwBuffer size (2 for double | ||
52 | * buffer). | ||
53 | * 4. increment data_in_count. | ||
54 | * 5. Inform the firmware by generating a firmware internal interrupt. | ||
55 | * 6. FW will increment data_out_count after it reads the buffer. | ||
56 | * | ||
57 | * The TX Complete procedure: | ||
58 | * 1. To get a TX complete indication the host enables the tx_complete flag in | ||
59 | * the TX descriptor Structure. | ||
60 | * 2. For each packet with a Tx Complete field set, the firmware adds the | ||
61 | * transmit results to the cyclic buffer (txDoneRing) and sets both done_1 | ||
62 | * and done_2 to 1 to indicate driver ownership. | ||
63 | * 3. The firmware sends a Tx Complete interrupt to the host to trigger the | ||
64 | * host to process the new data. Note: interrupt will be send per packet if | ||
65 | * TX complete indication was requested in tx_control or per crossing | ||
66 | * aggregation threshold. | ||
67 | * 4. After receiving the Tx Complete interrupt, the host reads the | ||
68 | * TxDescriptorDone information in a cyclic manner and clears both done_1 | ||
69 | * and done_2 fields. | ||
70 | * | ||
71 | */ | ||
72 | |||
73 | #define TX_COMPLETE_REQUIRED_BIT 0x80 | ||
74 | #define TX_STATUS_DATA_OUT_COUNT_MASK 0xf | ||
75 | |||
76 | #define WL1251_TX_ALIGN_TO 4 | ||
77 | #define WL1251_TX_ALIGN(len) (((len) + WL1251_TX_ALIGN_TO - 1) & \ | ||
78 | ~(WL1251_TX_ALIGN_TO - 1)) | ||
79 | #define WL1251_TKIP_IV_SPACE 4 | ||
80 | |||
81 | struct tx_control { | ||
82 | /* Rate Policy (class) index */ | ||
83 | unsigned rate_policy:3; | ||
84 | |||
85 | /* When set, no ack policy is expected */ | ||
86 | unsigned ack_policy:1; | ||
87 | |||
88 | /* | ||
89 | * Packet type: | ||
90 | * 0 -> 802.11 | ||
91 | * 1 -> 802.3 | ||
92 | * 2 -> IP | ||
93 | * 3 -> raw codec | ||
94 | */ | ||
95 | unsigned packet_type:2; | ||
96 | |||
97 | /* If set, this is a QoS-Null or QoS-Data frame */ | ||
98 | unsigned qos:1; | ||
99 | |||
100 | /* | ||
101 | * If set, the target triggers the tx complete INT | ||
102 | * upon frame sending completion. | ||
103 | */ | ||
104 | unsigned tx_complete:1; | ||
105 | |||
106 | /* 2 bytes padding before packet header */ | ||
107 | unsigned xfer_pad:1; | ||
108 | |||
109 | unsigned reserved:7; | ||
110 | } __packed; | ||
111 | |||
112 | |||
113 | struct tx_double_buffer_desc { | ||
114 | /* Length of payload, including headers. */ | ||
115 | __le16 length; | ||
116 | |||
117 | /* | ||
118 | * A bit mask that specifies the initial rate to be used | ||
119 | * Possible values are: | ||
120 | * 0x0001 - 1Mbits | ||
121 | * 0x0002 - 2Mbits | ||
122 | * 0x0004 - 5.5Mbits | ||
123 | * 0x0008 - 6Mbits | ||
124 | * 0x0010 - 9Mbits | ||
125 | * 0x0020 - 11Mbits | ||
126 | * 0x0040 - 12Mbits | ||
127 | * 0x0080 - 18Mbits | ||
128 | * 0x0100 - 22Mbits | ||
129 | * 0x0200 - 24Mbits | ||
130 | * 0x0400 - 36Mbits | ||
131 | * 0x0800 - 48Mbits | ||
132 | * 0x1000 - 54Mbits | ||
133 | */ | ||
134 | __le16 rate; | ||
135 | |||
136 | /* Time in us that a packet can spend in the target */ | ||
137 | __le32 expiry_time; | ||
138 | |||
139 | /* index of the TX queue used for this packet */ | ||
140 | u8 xmit_queue; | ||
141 | |||
142 | /* Used to identify a packet */ | ||
143 | u8 id; | ||
144 | |||
145 | struct tx_control control; | ||
146 | |||
147 | /* | ||
148 | * The FW should cut the packet into fragments | ||
149 | * of this size. | ||
150 | */ | ||
151 | __le16 frag_threshold; | ||
152 | |||
153 | /* Numbers of HW queue blocks to be allocated */ | ||
154 | u8 num_mem_blocks; | ||
155 | |||
156 | u8 reserved; | ||
157 | } __packed; | ||
158 | |||
159 | enum { | ||
160 | TX_SUCCESS = 0, | ||
161 | TX_DMA_ERROR = BIT(7), | ||
162 | TX_DISABLED = BIT(6), | ||
163 | TX_RETRY_EXCEEDED = BIT(5), | ||
164 | TX_TIMEOUT = BIT(4), | ||
165 | TX_KEY_NOT_FOUND = BIT(3), | ||
166 | TX_ENCRYPT_FAIL = BIT(2), | ||
167 | TX_UNAVAILABLE_PRIORITY = BIT(1), | ||
168 | }; | ||
169 | |||
170 | struct tx_result { | ||
171 | /* | ||
172 | * Ownership synchronization between the host and | ||
173 | * the firmware. If done_1 and done_2 are cleared, | ||
174 | * owned by the FW (no info ready). | ||
175 | */ | ||
176 | u8 done_1; | ||
177 | |||
178 | /* same as double_buffer_desc->id */ | ||
179 | u8 id; | ||
180 | |||
181 | /* | ||
182 | * Total air access duration consumed by this | ||
183 | * packet, including all retries and overheads. | ||
184 | */ | ||
185 | u16 medium_usage; | ||
186 | |||
187 | /* Total media delay (from 1st EDCA AIFS counter until TX Complete). */ | ||
188 | u32 medium_delay; | ||
189 | |||
190 | /* Time between host xfer and tx complete */ | ||
191 | u32 fw_hnadling_time; | ||
192 | |||
193 | /* The LS-byte of the last TKIP sequence number. */ | ||
194 | u8 lsb_seq_num; | ||
195 | |||
196 | /* Retry count */ | ||
197 | u8 ack_failures; | ||
198 | |||
199 | /* At which rate we got a ACK */ | ||
200 | u16 rate; | ||
201 | |||
202 | u16 reserved; | ||
203 | |||
204 | /* TX_* */ | ||
205 | u8 status; | ||
206 | |||
207 | /* See done_1 */ | ||
208 | u8 done_2; | ||
209 | } __packed; | ||
210 | |||
211 | static inline int wl1251_tx_get_queue(int queue) | ||
212 | { | ||
213 | switch (queue) { | ||
214 | case 0: | ||
215 | return QOS_AC_VO; | ||
216 | case 1: | ||
217 | return QOS_AC_VI; | ||
218 | case 2: | ||
219 | return QOS_AC_BE; | ||
220 | case 3: | ||
221 | return QOS_AC_BK; | ||
222 | default: | ||
223 | return QOS_AC_BE; | ||
224 | } | ||
225 | } | ||
226 | |||
227 | void wl1251_tx_work(struct work_struct *work); | ||
228 | void wl1251_tx_complete(struct wl1251 *wl); | ||
229 | void wl1251_tx_flush(struct wl1251 *wl); | ||
230 | |||
231 | #endif | ||
diff --git a/drivers/net/wireless/wl1251/wl1251.h b/drivers/net/wireless/wl1251/wl1251.h new file mode 100644 index 000000000000..e113d4c1fb35 --- /dev/null +++ b/drivers/net/wireless/wl1251/wl1251.h | |||
@@ -0,0 +1,433 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008-2009 Nokia Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * version 2 as published by the Free Software Foundation. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | * General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
19 | * 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #ifndef __WL1251_H__ | ||
24 | #define __WL1251_H__ | ||
25 | |||
26 | #include <linux/mutex.h> | ||
27 | #include <linux/list.h> | ||
28 | #include <linux/bitops.h> | ||
29 | #include <net/mac80211.h> | ||
30 | |||
31 | #define DRIVER_NAME "wl1251" | ||
32 | #define DRIVER_PREFIX DRIVER_NAME ": " | ||
33 | |||
34 | enum { | ||
35 | DEBUG_NONE = 0, | ||
36 | DEBUG_IRQ = BIT(0), | ||
37 | DEBUG_SPI = BIT(1), | ||
38 | DEBUG_BOOT = BIT(2), | ||
39 | DEBUG_MAILBOX = BIT(3), | ||
40 | DEBUG_NETLINK = BIT(4), | ||
41 | DEBUG_EVENT = BIT(5), | ||
42 | DEBUG_TX = BIT(6), | ||
43 | DEBUG_RX = BIT(7), | ||
44 | DEBUG_SCAN = BIT(8), | ||
45 | DEBUG_CRYPT = BIT(9), | ||
46 | DEBUG_PSM = BIT(10), | ||
47 | DEBUG_MAC80211 = BIT(11), | ||
48 | DEBUG_CMD = BIT(12), | ||
49 | DEBUG_ACX = BIT(13), | ||
50 | DEBUG_ALL = ~0, | ||
51 | }; | ||
52 | |||
53 | #define DEBUG_LEVEL (DEBUG_NONE) | ||
54 | |||
55 | #define DEBUG_DUMP_LIMIT 1024 | ||
56 | |||
57 | #define wl1251_error(fmt, arg...) \ | ||
58 | printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg) | ||
59 | |||
60 | #define wl1251_warning(fmt, arg...) \ | ||
61 | printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg) | ||
62 | |||
63 | #define wl1251_notice(fmt, arg...) \ | ||
64 | printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg) | ||
65 | |||
66 | #define wl1251_info(fmt, arg...) \ | ||
67 | printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg) | ||
68 | |||
69 | #define wl1251_debug(level, fmt, arg...) \ | ||
70 | do { \ | ||
71 | if (level & DEBUG_LEVEL) \ | ||
72 | printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \ | ||
73 | } while (0) | ||
74 | |||
75 | #define wl1251_dump(level, prefix, buf, len) \ | ||
76 | do { \ | ||
77 | if (level & DEBUG_LEVEL) \ | ||
78 | print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ | ||
79 | DUMP_PREFIX_OFFSET, 16, 1, \ | ||
80 | buf, \ | ||
81 | min_t(size_t, len, DEBUG_DUMP_LIMIT), \ | ||
82 | 0); \ | ||
83 | } while (0) | ||
84 | |||
85 | #define wl1251_dump_ascii(level, prefix, buf, len) \ | ||
86 | do { \ | ||
87 | if (level & DEBUG_LEVEL) \ | ||
88 | print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ | ||
89 | DUMP_PREFIX_OFFSET, 16, 1, \ | ||
90 | buf, \ | ||
91 | min_t(size_t, len, DEBUG_DUMP_LIMIT), \ | ||
92 | true); \ | ||
93 | } while (0) | ||
94 | |||
95 | #define WL1251_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \ | ||
96 | CFG_BSSID_FILTER_EN) | ||
97 | |||
98 | #define WL1251_DEFAULT_RX_FILTER (CFG_RX_PRSP_EN | \ | ||
99 | CFG_RX_MGMT_EN | \ | ||
100 | CFG_RX_DATA_EN | \ | ||
101 | CFG_RX_CTL_EN | \ | ||
102 | CFG_RX_BCN_EN | \ | ||
103 | CFG_RX_AUTH_EN | \ | ||
104 | CFG_RX_ASSOC_EN) | ||
105 | |||
106 | #define WL1251_BUSY_WORD_LEN 8 | ||
107 | |||
108 | struct boot_attr { | ||
109 | u32 radio_type; | ||
110 | u8 mac_clock; | ||
111 | u8 arm_clock; | ||
112 | int firmware_debug; | ||
113 | u32 minor; | ||
114 | u32 major; | ||
115 | u32 bugfix; | ||
116 | }; | ||
117 | |||
118 | enum wl1251_state { | ||
119 | WL1251_STATE_OFF, | ||
120 | WL1251_STATE_ON, | ||
121 | WL1251_STATE_PLT, | ||
122 | }; | ||
123 | |||
124 | enum wl1251_partition_type { | ||
125 | PART_DOWN, | ||
126 | PART_WORK, | ||
127 | PART_DRPW, | ||
128 | |||
129 | PART_TABLE_LEN | ||
130 | }; | ||
131 | |||
132 | struct wl1251_partition { | ||
133 | u32 size; | ||
134 | u32 start; | ||
135 | }; | ||
136 | |||
137 | struct wl1251_partition_set { | ||
138 | struct wl1251_partition mem; | ||
139 | struct wl1251_partition reg; | ||
140 | }; | ||
141 | |||
142 | struct wl1251; | ||
143 | |||
144 | struct wl1251_stats { | ||
145 | struct acx_statistics *fw_stats; | ||
146 | unsigned long fw_stats_update; | ||
147 | |||
148 | unsigned int retry_count; | ||
149 | unsigned int excessive_retries; | ||
150 | }; | ||
151 | |||
152 | struct wl1251_debugfs { | ||
153 | struct dentry *rootdir; | ||
154 | struct dentry *fw_statistics; | ||
155 | |||
156 | struct dentry *tx_internal_desc_overflow; | ||
157 | |||
158 | struct dentry *rx_out_of_mem; | ||
159 | struct dentry *rx_hdr_overflow; | ||
160 | struct dentry *rx_hw_stuck; | ||
161 | struct dentry *rx_dropped; | ||
162 | struct dentry *rx_fcs_err; | ||
163 | struct dentry *rx_xfr_hint_trig; | ||
164 | struct dentry *rx_path_reset; | ||
165 | struct dentry *rx_reset_counter; | ||
166 | |||
167 | struct dentry *dma_rx_requested; | ||
168 | struct dentry *dma_rx_errors; | ||
169 | struct dentry *dma_tx_requested; | ||
170 | struct dentry *dma_tx_errors; | ||
171 | |||
172 | struct dentry *isr_cmd_cmplt; | ||
173 | struct dentry *isr_fiqs; | ||
174 | struct dentry *isr_rx_headers; | ||
175 | struct dentry *isr_rx_mem_overflow; | ||
176 | struct dentry *isr_rx_rdys; | ||
177 | struct dentry *isr_irqs; | ||
178 | struct dentry *isr_tx_procs; | ||
179 | struct dentry *isr_decrypt_done; | ||
180 | struct dentry *isr_dma0_done; | ||
181 | struct dentry *isr_dma1_done; | ||
182 | struct dentry *isr_tx_exch_complete; | ||
183 | struct dentry *isr_commands; | ||
184 | struct dentry *isr_rx_procs; | ||
185 | struct dentry *isr_hw_pm_mode_changes; | ||
186 | struct dentry *isr_host_acknowledges; | ||
187 | struct dentry *isr_pci_pm; | ||
188 | struct dentry *isr_wakeups; | ||
189 | struct dentry *isr_low_rssi; | ||
190 | |||
191 | struct dentry *wep_addr_key_count; | ||
192 | struct dentry *wep_default_key_count; | ||
193 | /* skipping wep.reserved */ | ||
194 | struct dentry *wep_key_not_found; | ||
195 | struct dentry *wep_decrypt_fail; | ||
196 | struct dentry *wep_packets; | ||
197 | struct dentry *wep_interrupt; | ||
198 | |||
199 | struct dentry *pwr_ps_enter; | ||
200 | struct dentry *pwr_elp_enter; | ||
201 | struct dentry *pwr_missing_bcns; | ||
202 | struct dentry *pwr_wake_on_host; | ||
203 | struct dentry *pwr_wake_on_timer_exp; | ||
204 | struct dentry *pwr_tx_with_ps; | ||
205 | struct dentry *pwr_tx_without_ps; | ||
206 | struct dentry *pwr_rcvd_beacons; | ||
207 | struct dentry *pwr_power_save_off; | ||
208 | struct dentry *pwr_enable_ps; | ||
209 | struct dentry *pwr_disable_ps; | ||
210 | struct dentry *pwr_fix_tsf_ps; | ||
211 | /* skipping cont_miss_bcns_spread for now */ | ||
212 | struct dentry *pwr_rcvd_awake_beacons; | ||
213 | |||
214 | struct dentry *mic_rx_pkts; | ||
215 | struct dentry *mic_calc_failure; | ||
216 | |||
217 | struct dentry *aes_encrypt_fail; | ||
218 | struct dentry *aes_decrypt_fail; | ||
219 | struct dentry *aes_encrypt_packets; | ||
220 | struct dentry *aes_decrypt_packets; | ||
221 | struct dentry *aes_encrypt_interrupt; | ||
222 | struct dentry *aes_decrypt_interrupt; | ||
223 | |||
224 | struct dentry *event_heart_beat; | ||
225 | struct dentry *event_calibration; | ||
226 | struct dentry *event_rx_mismatch; | ||
227 | struct dentry *event_rx_mem_empty; | ||
228 | struct dentry *event_rx_pool; | ||
229 | struct dentry *event_oom_late; | ||
230 | struct dentry *event_phy_transmit_error; | ||
231 | struct dentry *event_tx_stuck; | ||
232 | |||
233 | struct dentry *ps_pspoll_timeouts; | ||
234 | struct dentry *ps_upsd_timeouts; | ||
235 | struct dentry *ps_upsd_max_sptime; | ||
236 | struct dentry *ps_upsd_max_apturn; | ||
237 | struct dentry *ps_pspoll_max_apturn; | ||
238 | struct dentry *ps_pspoll_utilization; | ||
239 | struct dentry *ps_upsd_utilization; | ||
240 | |||
241 | struct dentry *rxpipe_rx_prep_beacon_drop; | ||
242 | struct dentry *rxpipe_descr_host_int_trig_rx_data; | ||
243 | struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data; | ||
244 | struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data; | ||
245 | struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data; | ||
246 | |||
247 | struct dentry *tx_queue_len; | ||
248 | struct dentry *tx_queue_status; | ||
249 | |||
250 | struct dentry *retry_count; | ||
251 | struct dentry *excessive_retries; | ||
252 | }; | ||
253 | |||
254 | struct wl1251_if_operations { | ||
255 | void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
256 | void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
257 | void (*read_elp)(struct wl1251 *wl, int addr, u32 *val); | ||
258 | void (*write_elp)(struct wl1251 *wl, int addr, u32 val); | ||
259 | void (*reset)(struct wl1251 *wl); | ||
260 | void (*enable_irq)(struct wl1251 *wl); | ||
261 | void (*disable_irq)(struct wl1251 *wl); | ||
262 | }; | ||
263 | |||
264 | struct wl1251 { | ||
265 | struct ieee80211_hw *hw; | ||
266 | bool mac80211_registered; | ||
267 | |||
268 | void *if_priv; | ||
269 | const struct wl1251_if_operations *if_ops; | ||
270 | |||
271 | void (*set_power)(bool enable); | ||
272 | int irq; | ||
273 | bool use_eeprom; | ||
274 | |||
275 | spinlock_t wl_lock; | ||
276 | |||
277 | enum wl1251_state state; | ||
278 | struct mutex mutex; | ||
279 | |||
280 | int physical_mem_addr; | ||
281 | int physical_reg_addr; | ||
282 | int virtual_mem_addr; | ||
283 | int virtual_reg_addr; | ||
284 | |||
285 | int cmd_box_addr; | ||
286 | int event_box_addr; | ||
287 | struct boot_attr boot_attr; | ||
288 | |||
289 | u8 *fw; | ||
290 | size_t fw_len; | ||
291 | u8 *nvs; | ||
292 | size_t nvs_len; | ||
293 | |||
294 | u8 bssid[ETH_ALEN]; | ||
295 | u8 mac_addr[ETH_ALEN]; | ||
296 | u8 bss_type; | ||
297 | u8 listen_int; | ||
298 | int channel; | ||
299 | |||
300 | void *target_mem_map; | ||
301 | struct acx_data_path_params_resp *data_path; | ||
302 | |||
303 | /* Number of TX packets transferred to the FW, modulo 16 */ | ||
304 | u32 data_in_count; | ||
305 | |||
306 | /* Frames scheduled for transmission, not handled yet */ | ||
307 | struct sk_buff_head tx_queue; | ||
308 | bool tx_queue_stopped; | ||
309 | |||
310 | struct work_struct tx_work; | ||
311 | struct work_struct filter_work; | ||
312 | |||
313 | /* Pending TX frames */ | ||
314 | struct sk_buff *tx_frames[16]; | ||
315 | |||
316 | /* | ||
317 | * Index pointing to the next TX complete entry | ||
318 | * in the cyclic XT complete array we get from | ||
319 | * the FW. | ||
320 | */ | ||
321 | u32 next_tx_complete; | ||
322 | |||
323 | /* FW Rx counter */ | ||
324 | u32 rx_counter; | ||
325 | |||
326 | /* Rx frames handled */ | ||
327 | u32 rx_handled; | ||
328 | |||
329 | /* Current double buffer */ | ||
330 | u32 rx_current_buffer; | ||
331 | u32 rx_last_id; | ||
332 | |||
333 | /* The target interrupt mask */ | ||
334 | u32 intr_mask; | ||
335 | struct work_struct irq_work; | ||
336 | |||
337 | /* The mbox event mask */ | ||
338 | u32 event_mask; | ||
339 | |||
340 | /* Mailbox pointers */ | ||
341 | u32 mbox_ptr[2]; | ||
342 | |||
343 | /* Are we currently scanning */ | ||
344 | bool scanning; | ||
345 | |||
346 | /* Default key (for WEP) */ | ||
347 | u32 default_key; | ||
348 | |||
349 | unsigned int tx_mgmt_frm_rate; | ||
350 | unsigned int tx_mgmt_frm_mod; | ||
351 | |||
352 | unsigned int rx_config; | ||
353 | unsigned int rx_filter; | ||
354 | |||
355 | /* is firmware in elp mode */ | ||
356 | bool elp; | ||
357 | |||
358 | struct delayed_work elp_work; | ||
359 | |||
360 | /* we can be in psm, but not in elp, we have to differentiate */ | ||
361 | bool psm; | ||
362 | |||
363 | /* PSM mode requested */ | ||
364 | bool psm_requested; | ||
365 | |||
366 | u16 beacon_int; | ||
367 | u8 dtim_period; | ||
368 | |||
369 | /* in dBm */ | ||
370 | int power_level; | ||
371 | |||
372 | struct wl1251_stats stats; | ||
373 | struct wl1251_debugfs debugfs; | ||
374 | |||
375 | u32 buffer_32; | ||
376 | u32 buffer_cmd; | ||
377 | u8 buffer_busyword[WL1251_BUSY_WORD_LEN]; | ||
378 | struct wl1251_rx_descriptor *rx_descriptor; | ||
379 | |||
380 | struct ieee80211_vif *vif; | ||
381 | |||
382 | u32 chip_id; | ||
383 | char fw_ver[21]; | ||
384 | |||
385 | /* Most recently reported noise in dBm */ | ||
386 | s8 noise; | ||
387 | }; | ||
388 | |||
389 | int wl1251_plt_start(struct wl1251 *wl); | ||
390 | int wl1251_plt_stop(struct wl1251 *wl); | ||
391 | |||
392 | struct ieee80211_hw *wl1251_alloc_hw(void); | ||
393 | int wl1251_free_hw(struct wl1251 *wl); | ||
394 | int wl1251_init_ieee80211(struct wl1251 *wl); | ||
395 | void wl1251_enable_interrupts(struct wl1251 *wl); | ||
396 | void wl1251_disable_interrupts(struct wl1251 *wl); | ||
397 | |||
398 | #define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG /* Long Preamble */ | ||
399 | #define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS | ||
400 | #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */ | ||
401 | |||
402 | #define WL1251_DEFAULT_POWER_LEVEL 20 | ||
403 | |||
404 | #define WL1251_TX_QUEUE_LOW_WATERMARK 10 | ||
405 | #define WL1251_TX_QUEUE_HIGH_WATERMARK 25 | ||
406 | |||
407 | #define WL1251_DEFAULT_BEACON_INT 100 | ||
408 | #define WL1251_DEFAULT_DTIM_PERIOD 1 | ||
409 | |||
410 | #define WL1251_DEFAULT_CHANNEL 0 | ||
411 | |||
412 | #define CHIP_ID_1251_PG10 (0x7010101) | ||
413 | #define CHIP_ID_1251_PG11 (0x7020101) | ||
414 | #define CHIP_ID_1251_PG12 (0x7030101) | ||
415 | #define CHIP_ID_1271_PG10 (0x4030101) | ||
416 | #define CHIP_ID_1271_PG20 (0x4030111) | ||
417 | |||
418 | #define WL1251_FW_NAME "wl1251-fw.bin" | ||
419 | #define WL1251_NVS_NAME "wl1251-nvs.bin" | ||
420 | |||
421 | #define WL1251_POWER_ON_SLEEP 10 /* in miliseconds */ | ||
422 | |||
423 | #define WL1251_PART_DOWN_MEM_START 0x0 | ||
424 | #define WL1251_PART_DOWN_MEM_SIZE 0x16800 | ||
425 | #define WL1251_PART_DOWN_REG_START REGISTERS_BASE | ||
426 | #define WL1251_PART_DOWN_REG_SIZE REGISTERS_DOWN_SIZE | ||
427 | |||
428 | #define WL1251_PART_WORK_MEM_START 0x28000 | ||
429 | #define WL1251_PART_WORK_MEM_SIZE 0x14000 | ||
430 | #define WL1251_PART_WORK_REG_START REGISTERS_BASE | ||
431 | #define WL1251_PART_WORK_REG_SIZE REGISTERS_WORK_SIZE | ||
432 | |||
433 | #endif | ||