aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/wl12xx')
-rw-r--r--drivers/net/wireless/wl12xx/Kconfig17
-rw-r--r--drivers/net/wireless/wl12xx/Makefile9
-rw-r--r--drivers/net/wireless/wl12xx/acx.c689
-rw-r--r--drivers/net/wireless/wl12xx/cmd.c353
-rw-r--r--drivers/net/wireless/wl12xx/reg.h1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251.h479
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_acx.c840
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_acx.h (renamed from drivers/net/wireless/wl12xx/acx.h)199
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_boot.c (renamed from drivers/net/wireless/wl12xx/boot.c)114
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_boot.h (renamed from drivers/net/wireless/wl12xx/boot.h)12
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_cmd.c428
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_cmd.h (renamed from drivers/net/wireless/wl12xx/cmd.h)194
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_debugfs.c (renamed from drivers/net/wireless/wl12xx/debugfs.c)60
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_debugfs.h (renamed from drivers/net/wireless/wl12xx/debugfs.h)16
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_event.c (renamed from drivers/net/wireless/wl12xx/event.c)54
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_event.h (renamed from drivers/net/wireless/wl12xx/event.h)12
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_init.c (renamed from drivers/net/wireless/wl12xx/init.c)78
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_init.h (renamed from drivers/net/wireless/wl12xx/init.h)27
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_main.c (renamed from drivers/net/wireless/wl12xx/main.c)659
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_netlink.h30
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_ops.c (renamed from drivers/net/wireless/wl12xx/wl1251.c)299
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_ops.h165
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_ps.c (renamed from drivers/net/wireless/wl12xx/ps.c)64
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_ps.h (renamed from drivers/net/wireless/wl12xx/ps.h)18
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_rx.c (renamed from drivers/net/wireless/wl12xx/rx.c)90
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_rx.h (renamed from drivers/net/wireless/wl12xx/rx.h)24
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_spi.c (renamed from drivers/net/wireless/wl12xx/spi.c)179
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_spi.h (renamed from drivers/net/wireless/wl12xx/spi.h)62
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_tx.c (renamed from drivers/net/wireless/wl12xx/tx.c)124
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_tx.h (renamed from drivers/net/wireless/wl12xx/tx.h)21
-rw-r--r--drivers/net/wireless/wl12xx/wl12xx.h409
31 files changed, 3069 insertions, 2657 deletions
diff --git a/drivers/net/wireless/wl12xx/Kconfig b/drivers/net/wireless/wl12xx/Kconfig
index a82c4cd436d8..82a0f97975de 100644
--- a/drivers/net/wireless/wl12xx/Kconfig
+++ b/drivers/net/wireless/wl12xx/Kconfig
@@ -1,11 +1,18 @@
1config WL12XX 1menuconfig WL12XX
2 tristate "TI wl1251/wl1271 support" 2 boolean "TI wl12xx driver support"
3 depends on MAC80211 && WLAN_80211 && SPI_MASTER && GENERIC_HARDIRQS && EXPERIMENTAL 3 depends on MAC80211 && WLAN_80211 && EXPERIMENTAL
4 ---help---
5 This will enable TI wl12xx driver support. The drivers make
6 use of the mac80211 stack.
7
8config WL1251
9 tristate "TI wl1251 support"
10 depends on WL12XX && SPI_MASTER && GENERIC_HARDIRQS
4 select FW_LOADER 11 select FW_LOADER
5 select CRC7 12 select CRC7
6 ---help--- 13 ---help---
7 This module adds support for wireless adapters based on 14 This module adds support for wireless adapters based on
8 TI wl1251/wl1271 chipsets. 15 TI wl1251 chipset.
9 16
10 If you choose to build a module, it'll be called wl12xx. Say N if 17 If you choose to build a module, it'll be called wl1251. Say N if
11 unsure. 18 unsure.
diff --git a/drivers/net/wireless/wl12xx/Makefile b/drivers/net/wireless/wl12xx/Makefile
index d43de27dc54c..d5595a841f5f 100644
--- a/drivers/net/wireless/wl12xx/Makefile
+++ b/drivers/net/wireless/wl12xx/Makefile
@@ -1,4 +1,5 @@
1wl12xx-objs = main.o spi.o event.o tx.o rx.o \ 1wl1251-objs = wl1251_main.o wl1251_spi.o wl1251_event.o \
2 ps.o cmd.o acx.o boot.o init.o wl1251.o \ 2 wl1251_tx.o wl1251_rx.o wl1251_ps.o wl1251_cmd.o \
3 debugfs.o 3 wl1251_acx.o wl1251_boot.o wl1251_init.o \
4obj-$(CONFIG_WL12XX) += wl12xx.o 4 wl1251_ops.o wl1251_debugfs.o
5obj-$(CONFIG_WL1251) += wl1251.o
diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c
deleted file mode 100644
index 1cfd458ad5ab..000000000000
--- a/drivers/net/wireless/wl12xx/acx.c
+++ /dev/null
@@ -1,689 +0,0 @@
1#include "acx.h"
2
3#include <linux/module.h>
4#include <linux/crc7.h>
5#include <linux/spi/spi.h>
6
7#include "wl12xx.h"
8#include "wl12xx_80211.h"
9#include "reg.h"
10#include "spi.h"
11#include "ps.h"
12
13int wl12xx_acx_frame_rates(struct wl12xx *wl, u8 ctrl_rate, u8 ctrl_mod,
14 u8 mgt_rate, u8 mgt_mod)
15{
16 int ret;
17 struct acx_fw_gen_frame_rates rates;
18
19 wl12xx_debug(DEBUG_ACX, "acx frame rates");
20
21 rates.header.id = ACX_FW_GEN_FRAME_RATES;
22 rates.header.len = sizeof(struct acx_fw_gen_frame_rates) -
23 sizeof(struct acx_header);
24
25 rates.tx_ctrl_frame_rate = ctrl_rate;
26 rates.tx_ctrl_frame_mod = ctrl_mod;
27 rates.tx_mgt_frame_rate = mgt_rate;
28 rates.tx_mgt_frame_mod = mgt_mod;
29
30 ret = wl12xx_cmd_configure(wl, &rates, sizeof(rates));
31 if (ret < 0) {
32 wl12xx_error("Failed to set FW rates and modulation");
33 return ret;
34 }
35
36 return 0;
37}
38
39
40int wl12xx_acx_station_id(struct wl12xx *wl)
41{
42 int ret, i;
43 struct dot11_station_id mac;
44
45 wl12xx_debug(DEBUG_ACX, "acx dot11_station_id");
46
47 mac.header.id = DOT11_STATION_ID;
48 mac.header.len = sizeof(mac) - sizeof(struct acx_header);
49
50 for (i = 0; i < ETH_ALEN; i++)
51 mac.mac[i] = wl->mac_addr[ETH_ALEN - 1 - i];
52
53 ret = wl12xx_cmd_configure(wl, &mac, sizeof(mac));
54 if (ret < 0)
55 return ret;
56
57 return 0;
58}
59
60int wl12xx_acx_default_key(struct wl12xx *wl, u8 key_id)
61{
62 struct acx_dot11_default_key default_key;
63 int ret;
64
65 wl12xx_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id);
66
67 default_key.header.id = DOT11_DEFAULT_KEY;
68 default_key.header.len = sizeof(default_key) -
69 sizeof(struct acx_header);
70
71 default_key.id = key_id;
72
73 ret = wl12xx_cmd_configure(wl, &default_key, sizeof(default_key));
74 if (ret < 0) {
75 wl12xx_error("Couldnt set default key");
76 return ret;
77 }
78
79 wl->default_key = key_id;
80
81 return 0;
82}
83
84int wl12xx_acx_wake_up_conditions(struct wl12xx *wl, u8 listen_interval)
85{
86 struct acx_wake_up_condition wake_up;
87
88 wl12xx_debug(DEBUG_ACX, "acx wake up conditions");
89
90 wake_up.header.id = ACX_WAKE_UP_CONDITIONS;
91 wake_up.header.len = sizeof(wake_up) - sizeof(struct acx_header);
92
93 wake_up.wake_up_event = WAKE_UP_EVENT_DTIM_BITMAP;
94 wake_up.listen_interval = listen_interval;
95
96 return wl12xx_cmd_configure(wl, &wake_up, sizeof(wake_up));
97}
98
99int wl12xx_acx_sleep_auth(struct wl12xx *wl, u8 sleep_auth)
100{
101 int ret;
102 struct acx_sleep_auth auth;
103
104 wl12xx_debug(DEBUG_ACX, "acx sleep auth");
105
106 auth.header.id = ACX_SLEEP_AUTH;
107 auth.header.len = sizeof(auth) - sizeof(struct acx_header);
108
109 auth.sleep_auth = sleep_auth;
110
111 ret = wl12xx_cmd_configure(wl, &auth, sizeof(auth));
112 if (ret < 0)
113 return ret;
114
115 return 0;
116}
117
118int wl12xx_acx_fw_version(struct wl12xx *wl, char *buf, size_t len)
119{
120 struct wl12xx_command cmd;
121 struct acx_revision *rev;
122 int ret;
123
124 wl12xx_debug(DEBUG_ACX, "acx fw rev");
125
126 memset(&cmd, 0, sizeof(cmd));
127
128 ret = wl12xx_cmd_interrogate(wl, ACX_FW_REV, sizeof(*rev), &cmd);
129 if (ret < 0) {
130 wl12xx_warning("ACX_FW_REV interrogate failed");
131 return ret;
132 }
133
134 rev = (struct acx_revision *) &cmd.parameters;
135
136 /* be careful with the buffer sizes */
137 strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version)));
138
139 /*
140 * if the firmware version string is exactly
141 * sizeof(rev->fw_version) long or fw_len is less than
142 * sizeof(rev->fw_version) it won't be null terminated
143 */
144 buf[min(len, sizeof(rev->fw_version)) - 1] = '\0';
145
146 return 0;
147}
148
149int wl12xx_acx_tx_power(struct wl12xx *wl, int power)
150{
151 struct acx_current_tx_power ie;
152 int ret;
153
154 wl12xx_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr");
155
156 if (power < 0 || power > 25)
157 return -EINVAL;
158
159 memset(&ie, 0, sizeof(ie));
160
161 ie.header.id = DOT11_CUR_TX_PWR;
162 ie.header.len = sizeof(ie) - sizeof(struct acx_header);
163 ie.current_tx_power = power * 10;
164
165 ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie));
166 if (ret < 0) {
167 wl12xx_warning("configure of tx power failed: %d", ret);
168 return ret;
169 }
170
171 return 0;
172}
173
174int wl12xx_acx_feature_cfg(struct wl12xx *wl)
175{
176 struct acx_feature_config feature;
177 int ret;
178
179 wl12xx_debug(DEBUG_ACX, "acx feature cfg");
180
181 memset(&feature, 0, sizeof(feature));
182
183 feature.header.id = ACX_FEATURE_CFG;
184 feature.header.len = sizeof(feature) - sizeof(struct acx_header);
185
186 /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */
187 feature.data_flow_options = 0;
188 feature.options = 0;
189
190 ret = wl12xx_cmd_configure(wl, &feature, sizeof(feature));
191 if (ret < 0)
192 wl12xx_error("Couldnt set HW encryption");
193
194 return ret;
195}
196
197int wl12xx_acx_mem_map(struct wl12xx *wl, void *mem_map, size_t len)
198{
199 struct wl12xx_command cmd;
200 int ret;
201
202 wl12xx_debug(DEBUG_ACX, "acx mem map");
203
204 ret = wl12xx_cmd_interrogate(wl, ACX_MEM_MAP, len, &cmd);
205 if (ret < 0)
206 return ret;
207 else if (cmd.status != CMD_STATUS_SUCCESS)
208 return -EIO;
209
210 memcpy(mem_map, &cmd.parameters, len);
211
212 return 0;
213}
214
215int wl12xx_acx_data_path_params(struct wl12xx *wl,
216 struct acx_data_path_params_resp *data_path)
217{
218 struct acx_data_path_params params;
219 struct wl12xx_command cmd;
220 int ret;
221
222 wl12xx_debug(DEBUG_ACX, "acx data path params");
223
224 params.rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE;
225 params.tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE;
226
227 params.rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM;
228 params.tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM;
229
230 params.tx_complete_threshold = 1;
231
232 params.tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE;
233
234 params.tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT;
235
236 params.header.id = ACX_DATA_PATH_PARAMS;
237 params.header.len = sizeof(params) - sizeof(struct acx_header);
238
239 ret = wl12xx_cmd_configure(wl, &params, sizeof(params));
240 if (ret < 0)
241 return ret;
242
243
244 ret = wl12xx_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS,
245 sizeof(struct acx_data_path_params_resp),
246 &cmd);
247
248 if (ret < 0) {
249 wl12xx_warning("failed to read data path parameters: %d", ret);
250 return ret;
251 } else if (cmd.status != CMD_STATUS_SUCCESS) {
252 wl12xx_warning("data path parameter acx status failed");
253 return -EIO;
254 }
255
256 memcpy(data_path, &cmd.parameters, sizeof(*data_path));
257
258 return 0;
259}
260
261int wl12xx_acx_rx_msdu_life_time(struct wl12xx *wl, u32 life_time)
262{
263 struct rx_msdu_lifetime msdu_lifetime;
264 int ret;
265
266 wl12xx_debug(DEBUG_ACX, "acx rx msdu life time");
267
268 msdu_lifetime.header.id = DOT11_RX_MSDU_LIFE_TIME;
269 msdu_lifetime.header.len = sizeof(msdu_lifetime) -
270 sizeof(struct acx_header);
271 msdu_lifetime.lifetime = life_time;
272
273 ret = wl12xx_cmd_configure(wl, &msdu_lifetime, sizeof(msdu_lifetime));
274 if (ret < 0) {
275 wl12xx_warning("failed to set rx msdu life time: %d", ret);
276 return ret;
277 }
278
279 return 0;
280}
281
282int wl12xx_acx_rx_config(struct wl12xx *wl, u32 config, u32 filter)
283{
284 struct acx_rx_config rx_config;
285 int ret;
286
287 wl12xx_debug(DEBUG_ACX, "acx rx config");
288
289 rx_config.header.id = ACX_RX_CFG;
290 rx_config.header.len = sizeof(rx_config) - sizeof(struct acx_header);
291 rx_config.config_options = config;
292 rx_config.filter_options = filter;
293
294 ret = wl12xx_cmd_configure(wl, &rx_config, sizeof(rx_config));
295 if (ret < 0) {
296 wl12xx_warning("failed to set rx config: %d", ret);
297 return ret;
298 }
299
300 return 0;
301}
302
303int wl12xx_acx_pd_threshold(struct wl12xx *wl)
304{
305 struct acx_packet_detection packet_detection;
306 int ret;
307
308 wl12xx_debug(DEBUG_ACX, "acx data pd threshold");
309
310 /* FIXME: threshold value not set */
311 packet_detection.header.id = ACX_PD_THRESHOLD;
312 packet_detection.header.len = sizeof(packet_detection) -
313 sizeof(struct acx_header);
314
315 ret = wl12xx_cmd_configure(wl, &packet_detection,
316 sizeof(packet_detection));
317 if (ret < 0) {
318 wl12xx_warning("failed to set pd threshold: %d", ret);
319 return ret;
320 }
321
322 return 0;
323}
324
325int wl12xx_acx_slot(struct wl12xx *wl, enum acx_slot_type slot_time)
326{
327 struct acx_slot slot;
328 int ret;
329
330 wl12xx_debug(DEBUG_ACX, "acx slot");
331
332 slot.header.id = ACX_SLOT;
333 slot.header.len = sizeof(slot) - sizeof(struct acx_header);
334
335 slot.wone_index = STATION_WONE_INDEX;
336 slot.slot_time = slot_time;
337
338 ret = wl12xx_cmd_configure(wl, &slot, sizeof(slot));
339 if (ret < 0) {
340 wl12xx_warning("failed to set slot time: %d", ret);
341 return ret;
342 }
343
344 return 0;
345}
346
347int wl12xx_acx_group_address_tbl(struct wl12xx *wl)
348{
349 struct multicast_grp_addr_start multicast;
350 int ret;
351
352 wl12xx_debug(DEBUG_ACX, "acx group address tbl");
353
354 /* MAC filtering */
355 multicast.header.id = DOT11_GROUP_ADDRESS_TBL;
356 multicast.header.len = sizeof(multicast) - sizeof(struct acx_header);
357
358 multicast.enabled = 0;
359 multicast.num_groups = 0;
360 memset(multicast.mac_table, 0, ADDRESS_GROUP_MAX_LEN);
361
362 ret = wl12xx_cmd_configure(wl, &multicast, sizeof(multicast));
363 if (ret < 0) {
364 wl12xx_warning("failed to set group addr table: %d", ret);
365 return ret;
366 }
367
368 return 0;
369}
370
371int wl12xx_acx_service_period_timeout(struct wl12xx *wl)
372{
373 struct acx_rx_timeout rx_timeout;
374 int ret;
375
376 wl12xx_debug(DEBUG_ACX, "acx service period timeout");
377
378 /* RX timeout */
379 rx_timeout.header.id = ACX_SERVICE_PERIOD_TIMEOUT;
380 rx_timeout.header.len = sizeof(rx_timeout) - sizeof(struct acx_header);
381
382 rx_timeout.ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF;
383 rx_timeout.upsd_timeout = RX_TIMEOUT_UPSD_DEF;
384
385 ret = wl12xx_cmd_configure(wl, &rx_timeout, sizeof(rx_timeout));
386 if (ret < 0) {
387 wl12xx_warning("failed to set service period timeout: %d",
388 ret);
389 return ret;
390 }
391
392 return 0;
393}
394
395int wl12xx_acx_rts_threshold(struct wl12xx *wl, u16 rts_threshold)
396{
397 struct acx_rts_threshold rts;
398 int ret;
399
400 wl12xx_debug(DEBUG_ACX, "acx rts threshold");
401
402 rts.header.id = DOT11_RTS_THRESHOLD;
403 rts.header.len = sizeof(rts) - sizeof(struct acx_header);
404
405 rts.threshold = rts_threshold;
406
407 ret = wl12xx_cmd_configure(wl, &rts, sizeof(rts));
408 if (ret < 0) {
409 wl12xx_warning("failed to set rts threshold: %d", ret);
410 return ret;
411 }
412
413 return 0;
414}
415
416int wl12xx_acx_beacon_filter_opt(struct wl12xx *wl)
417{
418 struct acx_beacon_filter_option beacon_filter;
419 int ret;
420
421 wl12xx_debug(DEBUG_ACX, "acx beacon filter opt");
422
423 beacon_filter.header.id = ACX_BEACON_FILTER_OPT;
424 beacon_filter.header.len = sizeof(beacon_filter) -
425 sizeof(struct acx_header);
426
427 beacon_filter.enable = 0;
428 beacon_filter.max_num_beacons = 0;
429
430 ret = wl12xx_cmd_configure(wl, &beacon_filter, sizeof(beacon_filter));
431 if (ret < 0) {
432 wl12xx_warning("failed to set beacon filter opt: %d", ret);
433 return ret;
434 }
435
436 return 0;
437}
438
439int wl12xx_acx_beacon_filter_table(struct wl12xx *wl)
440{
441 struct acx_beacon_filter_ie_table ie_table;
442 int ret;
443
444 wl12xx_debug(DEBUG_ACX, "acx beacon filter table");
445
446 ie_table.header.id = ACX_BEACON_FILTER_TABLE;
447 ie_table.header.len = sizeof(ie_table) - sizeof(struct acx_header);
448
449 ie_table.num_ie = 0;
450 memset(ie_table.table, 0, BEACON_FILTER_TABLE_MAX_SIZE);
451
452 ret = wl12xx_cmd_configure(wl, &ie_table, sizeof(ie_table));
453 if (ret < 0) {
454 wl12xx_warning("failed to set beacon filter table: %d", ret);
455 return ret;
456 }
457
458 return 0;
459}
460
461int wl12xx_acx_sg_enable(struct wl12xx *wl)
462{
463 struct acx_bt_wlan_coex pta;
464 int ret;
465
466 wl12xx_debug(DEBUG_ACX, "acx sg enable");
467
468 pta.header.id = ACX_SG_ENABLE;
469 pta.header.len = sizeof(pta) - sizeof(struct acx_header);
470
471 pta.enable = SG_ENABLE;
472
473 ret = wl12xx_cmd_configure(wl, &pta, sizeof(pta));
474 if (ret < 0) {
475 wl12xx_warning("failed to set softgemini enable: %d", ret);
476 return ret;
477 }
478
479 return 0;
480}
481
482int wl12xx_acx_sg_cfg(struct wl12xx *wl)
483{
484 struct acx_bt_wlan_coex_param param;
485 int ret;
486
487 wl12xx_debug(DEBUG_ACX, "acx sg cfg");
488
489 /* BT-WLAN coext parameters */
490 param.header.id = ACX_SG_CFG;
491 param.header.len = sizeof(param) - sizeof(struct acx_header);
492
493 param.min_rate = RATE_INDEX_24MBPS;
494 param.bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF;
495 param.wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF;
496 param.sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF;
497 param.rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF;
498 param.tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF;
499 param.rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF;
500 param.tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF;
501 param.wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
502 param.bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
503 param.next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
504 param.wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
505 param.hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
506 param.next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
507 param.antenna_type = PTA_ANTENNA_TYPE_DEF;
508 param.signal_type = PTA_SIGNALING_TYPE_DEF;
509 param.afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF;
510 param.quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF;
511 param.max_cts = PTA_MAX_NUM_CTS_DEF;
512 param.wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF;
513 param.bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF;
514 param.missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF;
515 param.wlan_elp_hp = PTA_ELP_HP_DEF;
516 param.bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF;
517 param.ack_mode_dual_ant = PTA_ACK_MODE_DEF;
518 param.pa_sd_enable = PTA_ALLOW_PA_SD_DEF;
519 param.pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF;
520 param.bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF;
521
522 ret = wl12xx_cmd_configure(wl, &param, sizeof(param));
523 if (ret < 0) {
524 wl12xx_warning("failed to set sg config: %d", ret);
525 return ret;
526 }
527
528 return 0;
529}
530
531int wl12xx_acx_cca_threshold(struct wl12xx *wl)
532{
533 struct acx_energy_detection detection;
534 int ret;
535
536 wl12xx_debug(DEBUG_ACX, "acx cca threshold");
537
538 detection.header.id = ACX_CCA_THRESHOLD;
539 detection.header.len = sizeof(detection) - sizeof(struct acx_header);
540
541 detection.rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D;
542 detection.tx_energy_detection = 0;
543
544 ret = wl12xx_cmd_configure(wl, &detection, sizeof(detection));
545 if (ret < 0) {
546 wl12xx_warning("failed to set cca threshold: %d", ret);
547 return ret;
548 }
549
550 return 0;
551}
552
553int wl12xx_acx_bcn_dtim_options(struct wl12xx *wl)
554{
555 struct acx_beacon_broadcast bb;
556 int ret;
557
558 wl12xx_debug(DEBUG_ACX, "acx bcn dtim options");
559
560 bb.header.id = ACX_BCN_DTIM_OPTIONS;
561 bb.header.len = sizeof(bb) - sizeof(struct acx_header);
562
563 bb.beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE;
564 bb.broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE;
565 bb.rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE;
566 bb.ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
567
568 ret = wl12xx_cmd_configure(wl, &bb, sizeof(bb));
569 if (ret < 0) {
570 wl12xx_warning("failed to set rx config: %d", ret);
571 return ret;
572 }
573
574 return 0;
575}
576
577int wl12xx_acx_aid(struct wl12xx *wl, u16 aid)
578{
579 struct acx_aid acx_aid;
580 int ret;
581
582 wl12xx_debug(DEBUG_ACX, "acx aid");
583
584 acx_aid.header.id = ACX_AID;
585 acx_aid.header.len = sizeof(acx_aid) - sizeof(struct acx_header);
586
587 acx_aid.aid = aid;
588
589 ret = wl12xx_cmd_configure(wl, &acx_aid, sizeof(acx_aid));
590 if (ret < 0) {
591 wl12xx_warning("failed to set aid: %d", ret);
592 return ret;
593 }
594
595 return 0;
596}
597
598int wl12xx_acx_event_mbox_mask(struct wl12xx *wl, u32 event_mask)
599{
600 struct acx_event_mask mask;
601 int ret;
602
603 wl12xx_debug(DEBUG_ACX, "acx event mbox mask");
604
605 mask.header.id = ACX_EVENT_MBOX_MASK;
606 mask.header.len = sizeof(mask) - sizeof(struct acx_header);
607
608 /* high event mask is unused */
609 mask.high_event_mask = 0xffffffff;
610
611 mask.event_mask = event_mask;
612
613 ret = wl12xx_cmd_configure(wl, &mask, sizeof(mask));
614 if (ret < 0) {
615 wl12xx_warning("failed to set aid: %d", ret);
616 return ret;
617 }
618
619 return 0;
620}
621
622int wl12xx_acx_set_preamble(struct wl12xx *wl, enum acx_preamble_type preamble)
623{
624 struct acx_preamble ie;
625 int ret;
626
627 wl12xx_debug(DEBUG_ACX, "acx_set_preamble");
628
629 memset(&ie, 0, sizeof(ie));
630
631 ie.header.id = ACX_PREAMBLE_TYPE;
632 ie.header.len = sizeof(ie) - sizeof(struct acx_header);
633 ie.preamble = preamble;
634 ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie));
635 if (ret < 0) {
636 wl12xx_warning("Setting of preamble failed: %d", ret);
637 return ret;
638 }
639 return 0;
640}
641
642int wl12xx_acx_cts_protect(struct wl12xx *wl,
643 enum acx_ctsprotect_type ctsprotect)
644{
645 struct acx_ctsprotect ie;
646 int ret;
647
648 wl12xx_debug(DEBUG_ACX, "acx_set_ctsprotect");
649
650 memset(&ie, 0, sizeof(ie));
651
652 ie.header.id = ACX_CTS_PROTECTION;
653 ie.header.len = sizeof(ie) - sizeof(struct acx_header);
654 ie.ctsprotect = ctsprotect;
655 ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie));
656 if (ret < 0) {
657 wl12xx_warning("Setting of ctsprotect failed: %d", ret);
658 return ret;
659 }
660 return 0;
661}
662
663int wl12xx_acx_statistics(struct wl12xx *wl, struct acx_statistics *stats)
664{
665 struct wl12xx_command *answer;
666 int ret;
667
668 wl12xx_debug(DEBUG_ACX, "acx statistics");
669
670 answer = kmalloc(sizeof(*answer), GFP_KERNEL);
671 if (!answer) {
672 wl12xx_warning("could not allocate memory for acx statistics");
673 ret = -ENOMEM;
674 goto out;
675 }
676
677 ret = wl12xx_cmd_interrogate(wl, ACX_STATISTICS, sizeof(*answer),
678 answer);
679 if (ret < 0) {
680 wl12xx_warning("acx statistics failed: %d", ret);
681 goto out;
682 }
683
684 memcpy(stats, answer->parameters, sizeof(*stats));
685
686out:
687 kfree(answer);
688 return ret;
689}
diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c
deleted file mode 100644
index f73ab602b7ae..000000000000
--- a/drivers/net/wireless/wl12xx/cmd.c
+++ /dev/null
@@ -1,353 +0,0 @@
1#include "cmd.h"
2
3#include <linux/module.h>
4#include <linux/crc7.h>
5#include <linux/spi/spi.h>
6
7#include "wl12xx.h"
8#include "wl12xx_80211.h"
9#include "reg.h"
10#include "spi.h"
11#include "ps.h"
12
13int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len)
14{
15 struct wl12xx_command cmd;
16 unsigned long timeout;
17 size_t cmd_len;
18 u32 intr;
19 int ret = 0;
20
21 memset(&cmd, 0, sizeof(cmd));
22 cmd.id = type;
23 cmd.status = 0;
24 memcpy(cmd.parameters, buf, buf_len);
25 cmd_len = ALIGN(buf_len, 4) + CMDMBOX_HEADER_LEN;
26
27 wl12xx_ps_elp_wakeup(wl);
28
29 wl12xx_spi_mem_write(wl, wl->cmd_box_addr, &cmd, cmd_len);
30
31 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD);
32
33 timeout = jiffies + msecs_to_jiffies(WL12XX_COMMAND_TIMEOUT);
34
35 intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
36 while (!(intr & wl->chip.intr_cmd_complete)) {
37 if (time_after(jiffies, timeout)) {
38 wl12xx_error("command complete timeout");
39 ret = -ETIMEDOUT;
40 goto out;
41 }
42
43 msleep(1);
44
45 intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
46 }
47
48 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_ACK,
49 wl->chip.intr_cmd_complete);
50
51out:
52 wl12xx_ps_elp_sleep(wl);
53
54 return ret;
55}
56
57int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer)
58{
59 int ret;
60
61 wl12xx_debug(DEBUG_CMD, "cmd test");
62
63 ret = wl12xx_cmd_send(wl, CMD_TEST, buf, buf_len);
64 if (ret < 0) {
65 wl12xx_warning("TEST command failed");
66 return ret;
67 }
68
69 if (answer) {
70 struct wl12xx_command *cmd_answer;
71
72 /*
73 * The test command got in, we can read the answer.
74 * The answer would be a wl12xx_command, where the
75 * parameter array contains the actual answer.
76 */
77
78 wl12xx_ps_elp_wakeup(wl);
79
80 wl12xx_spi_mem_read(wl, wl->cmd_box_addr, buf, buf_len);
81
82 wl12xx_ps_elp_sleep(wl);
83
84 cmd_answer = buf;
85 if (cmd_answer->status != CMD_STATUS_SUCCESS)
86 wl12xx_error("TEST command answer error: %d",
87 cmd_answer->status);
88 }
89
90 return 0;
91}
92
93
94int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 ie_id, u16 ie_len,
95 void *answer)
96{
97 struct wl12xx_command *cmd;
98 struct acx_header header;
99 int ret;
100
101 wl12xx_debug(DEBUG_CMD, "cmd interrogate");
102
103 header.id = ie_id;
104 header.len = ie_len - sizeof(header);
105
106 ret = wl12xx_cmd_send(wl, CMD_INTERROGATE, &header, sizeof(header));
107 if (ret < 0) {
108 wl12xx_error("INTERROGATE command failed");
109 return ret;
110 }
111
112 wl12xx_ps_elp_wakeup(wl);
113
114 /* the interrogate command got in, we can read the answer */
115 wl12xx_spi_mem_read(wl, wl->cmd_box_addr, answer,
116 CMDMBOX_HEADER_LEN + ie_len);
117
118 wl12xx_ps_elp_sleep(wl);
119
120 cmd = answer;
121 if (cmd->status != CMD_STATUS_SUCCESS)
122 wl12xx_error("INTERROGATE command error: %d",
123 cmd->status);
124
125 return 0;
126
127}
128
129int wl12xx_cmd_configure(struct wl12xx *wl, void *ie, int ie_len)
130{
131 int ret;
132
133 wl12xx_debug(DEBUG_CMD, "cmd configure");
134
135 ret = wl12xx_cmd_send(wl, CMD_CONFIGURE, ie,
136 ie_len);
137 if (ret < 0) {
138 wl12xx_warning("CONFIGURE command NOK");
139 return ret;
140 }
141
142 return 0;
143
144}
145
146int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity,
147 void *bitmap, u16 bitmap_len, u8 bitmap_control)
148{
149 struct vbm_update_request vbm;
150 int ret;
151
152 wl12xx_debug(DEBUG_CMD, "cmd vbm");
153
154 /* Count and period will be filled by the target */
155 vbm.tim.bitmap_ctrl = bitmap_control;
156 if (bitmap_len > PARTIAL_VBM_MAX) {
157 wl12xx_warning("cmd vbm len is %d B, truncating to %d",
158 bitmap_len, PARTIAL_VBM_MAX);
159 bitmap_len = PARTIAL_VBM_MAX;
160 }
161 memcpy(vbm.tim.pvb_field, bitmap, bitmap_len);
162 vbm.tim.identity = identity;
163 vbm.tim.length = bitmap_len + 3;
164
165 vbm.len = cpu_to_le16(bitmap_len + 5);
166
167 ret = wl12xx_cmd_send(wl, CMD_VBM, &vbm, sizeof(vbm));
168 if (ret < 0) {
169 wl12xx_error("VBM command failed");
170 return ret;
171 }
172
173 return 0;
174}
175
176int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, u8 enable)
177{
178 int ret;
179 u16 cmd_rx, cmd_tx;
180
181 wl12xx_debug(DEBUG_CMD, "cmd data path");
182
183 if (enable) {
184 cmd_rx = CMD_ENABLE_RX;
185 cmd_tx = CMD_ENABLE_TX;
186 } else {
187 cmd_rx = CMD_DISABLE_RX;
188 cmd_tx = CMD_DISABLE_TX;
189 }
190
191 ret = wl12xx_cmd_send(wl, cmd_rx, &channel, sizeof(channel));
192 if (ret < 0) {
193 wl12xx_error("rx %s cmd for channel %d failed",
194 enable ? "start" : "stop", channel);
195 return ret;
196 }
197
198 wl12xx_debug(DEBUG_BOOT, "rx %s cmd channel %d",
199 enable ? "start" : "stop", channel);
200
201 ret = wl12xx_cmd_send(wl, cmd_tx, &channel, sizeof(channel));
202 if (ret < 0) {
203 wl12xx_error("tx %s cmd for channel %d failed",
204 enable ? "start" : "stop", channel);
205 return ret;
206 }
207
208 wl12xx_debug(DEBUG_BOOT, "tx %s cmd channel %d",
209 enable ? "start" : "stop", channel);
210
211 return 0;
212}
213
214int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval,
215 u16 beacon_interval, u8 wait)
216{
217 unsigned long timeout;
218 struct cmd_join join = {};
219 int ret, i;
220 u8 *bssid;
221
222 /* FIXME: this should be in main.c */
223 ret = wl12xx_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE,
224 DEFAULT_HW_GEN_MODULATION_TYPE,
225 wl->tx_mgmt_frm_rate,
226 wl->tx_mgmt_frm_mod);
227 if (ret < 0)
228 return ret;
229
230 wl12xx_debug(DEBUG_CMD, "cmd join");
231
232 /* Reverse order BSSID */
233 bssid = (u8 *)&join.bssid_lsb;
234 for (i = 0; i < ETH_ALEN; i++)
235 bssid[i] = wl->bssid[ETH_ALEN - i - 1];
236
237 join.rx_config_options = wl->rx_config;
238 join.rx_filter_options = wl->rx_filter;
239
240 join.basic_rate_set = RATE_MASK_1MBPS | RATE_MASK_2MBPS |
241 RATE_MASK_5_5MBPS | RATE_MASK_11MBPS;
242
243 join.beacon_interval = beacon_interval;
244 join.dtim_interval = dtim_interval;
245 join.bss_type = bss_type;
246 join.channel = wl->channel;
247 join.ctrl = JOIN_CMD_CTRL_TX_FLUSH;
248
249 ret = wl12xx_cmd_send(wl, CMD_START_JOIN, &join, sizeof(join));
250 if (ret < 0) {
251 wl12xx_error("failed to initiate cmd join");
252 return ret;
253 }
254
255 timeout = msecs_to_jiffies(JOIN_TIMEOUT);
256
257 /*
258 * ugly hack: we should wait for JOIN_EVENT_COMPLETE_ID but to
259 * simplify locking we just sleep instead, for now
260 */
261 if (wait)
262 msleep(10);
263
264 return 0;
265}
266
267int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode)
268{
269 int ret;
270 struct acx_ps_params ps_params;
271
272 /* FIXME: this should be in ps.c */
273 ret = wl12xx_acx_wake_up_conditions(wl, wl->listen_int);
274 if (ret < 0) {
275 wl12xx_error("Couldnt set wake up conditions");
276 return ret;
277 }
278
279 wl12xx_debug(DEBUG_CMD, "cmd set ps mode");
280
281 ps_params.ps_mode = ps_mode;
282 ps_params.send_null_data = 1;
283 ps_params.retries = 5;
284 ps_params.hang_over_period = 128;
285 ps_params.null_data_rate = 1; /* 1 Mbps */
286
287 ret = wl12xx_cmd_send(wl, CMD_SET_PS_MODE, &ps_params,
288 sizeof(ps_params));
289 if (ret < 0) {
290 wl12xx_error("cmd set_ps_mode failed");
291 return ret;
292 }
293
294 return 0;
295}
296
297int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, u32 len, void *answer)
298{
299 struct cmd_read_write_memory mem_cmd, *mem_answer;
300 struct wl12xx_command cmd;
301 int ret;
302
303 wl12xx_debug(DEBUG_CMD, "cmd read memory");
304
305 memset(&mem_cmd, 0, sizeof(mem_cmd));
306 mem_cmd.addr = addr;
307 mem_cmd.size = len;
308
309 ret = wl12xx_cmd_send(wl, CMD_READ_MEMORY, &mem_cmd, sizeof(mem_cmd));
310 if (ret < 0) {
311 wl12xx_error("read memory command failed: %d", ret);
312 return ret;
313 }
314
315 /* the read command got in, we can now read the answer */
316 wl12xx_spi_mem_read(wl, wl->cmd_box_addr, &cmd,
317 CMDMBOX_HEADER_LEN + sizeof(mem_cmd));
318
319 if (cmd.status != CMD_STATUS_SUCCESS)
320 wl12xx_error("error in read command result: %d", cmd.status);
321
322 mem_answer = (struct cmd_read_write_memory *) cmd.parameters;
323 memcpy(answer, mem_answer->value, len);
324
325 return 0;
326}
327
328int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id,
329 void *buf, size_t buf_len)
330{
331 struct wl12xx_cmd_packet_template template;
332 int ret;
333
334 wl12xx_debug(DEBUG_CMD, "cmd template %d", cmd_id);
335
336 memset(&template, 0, sizeof(template));
337
338 WARN_ON(buf_len > WL12XX_MAX_TEMPLATE_SIZE);
339 buf_len = min_t(size_t, buf_len, WL12XX_MAX_TEMPLATE_SIZE);
340 template.size = cpu_to_le16(buf_len);
341
342 if (buf)
343 memcpy(template.template, buf, buf_len);
344
345 ret = wl12xx_cmd_send(wl, cmd_id, &template,
346 sizeof(template.size) + buf_len);
347 if (ret < 0) {
348 wl12xx_warning("cmd set_template failed: %d", ret);
349 return ret;
350 }
351
352 return 0;
353}
diff --git a/drivers/net/wireless/wl12xx/reg.h b/drivers/net/wireless/wl12xx/reg.h
index e421643215cd..2de47cc32b8b 100644
--- a/drivers/net/wireless/wl12xx/reg.h
+++ b/drivers/net/wireless/wl12xx/reg.h
@@ -26,7 +26,6 @@
26#define __REG_H__ 26#define __REG_H__
27 27
28#include <linux/bitops.h> 28#include <linux/bitops.h>
29#include "wl12xx.h"
30 29
31#define REGISTERS_BASE 0x00300000 30#define REGISTERS_BASE 0x00300000
32#define DRPW_BASE 0x00310000 31#define DRPW_BASE 0x00310000
diff --git a/drivers/net/wireless/wl12xx/wl1251.h b/drivers/net/wireless/wl12xx/wl1251.h
index 1f4a44330394..665aca02bea9 100644
--- a/drivers/net/wireless/wl12xx/wl1251.h
+++ b/drivers/net/wireless/wl12xx/wl1251.h
@@ -1,7 +1,8 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008-2009 Nokia Corporation
5 * 6 *
6 * Contact: Kalle Valo <kalle.valo@nokia.com> 7 * Contact: Kalle Valo <kalle.valo@nokia.com>
7 * 8 *
@@ -24,142 +25,396 @@
24#ifndef __WL1251_H__ 25#ifndef __WL1251_H__
25#define __WL1251_H__ 26#define __WL1251_H__
26 27
28#include <linux/mutex.h>
29#include <linux/list.h>
27#include <linux/bitops.h> 30#include <linux/bitops.h>
28 31#include <net/mac80211.h>
29#include "wl12xx.h" 32
30#include "acx.h" 33#define DRIVER_NAME "wl1251"
31 34#define DRIVER_PREFIX DRIVER_NAME ": "
32#define WL1251_FW_NAME "wl1251-fw.bin" 35
33#define WL1251_NVS_NAME "wl1251-nvs.bin" 36enum {
34 37 DEBUG_NONE = 0,
35#define WL1251_POWER_ON_SLEEP 10 /* in miliseconds */ 38 DEBUG_IRQ = BIT(0),
36 39 DEBUG_SPI = BIT(1),
37void wl1251_setup(struct wl12xx *wl); 40 DEBUG_BOOT = BIT(2),
38 41 DEBUG_MAILBOX = BIT(3),
39 42 DEBUG_NETLINK = BIT(4),
40struct wl1251_acx_memory { 43 DEBUG_EVENT = BIT(5),
41 __le16 num_stations; /* number of STAs to be supported. */ 44 DEBUG_TX = BIT(6),
42 u16 reserved_1; 45 DEBUG_RX = BIT(7),
46 DEBUG_SCAN = BIT(8),
47 DEBUG_CRYPT = BIT(9),
48 DEBUG_PSM = BIT(10),
49 DEBUG_MAC80211 = BIT(11),
50 DEBUG_CMD = BIT(12),
51 DEBUG_ACX = BIT(13),
52 DEBUG_ALL = ~0,
53};
54
55#define DEBUG_LEVEL (DEBUG_NONE)
56
57#define DEBUG_DUMP_LIMIT 1024
58
59#define wl1251_error(fmt, arg...) \
60 printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
61
62#define wl1251_warning(fmt, arg...) \
63 printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
64
65#define wl1251_notice(fmt, arg...) \
66 printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg)
67
68#define wl1251_info(fmt, arg...) \
69 printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg)
70
71#define wl1251_debug(level, fmt, arg...) \
72 do { \
73 if (level & DEBUG_LEVEL) \
74 printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \
75 } while (0)
76
77#define wl1251_dump(level, prefix, buf, len) \
78 do { \
79 if (level & DEBUG_LEVEL) \
80 print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
81 DUMP_PREFIX_OFFSET, 16, 1, \
82 buf, \
83 min_t(size_t, len, DEBUG_DUMP_LIMIT), \
84 0); \
85 } while (0)
86
87#define wl1251_dump_ascii(level, prefix, buf, len) \
88 do { \
89 if (level & DEBUG_LEVEL) \
90 print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
91 DUMP_PREFIX_OFFSET, 16, 1, \
92 buf, \
93 min_t(size_t, len, DEBUG_DUMP_LIMIT), \
94 true); \
95 } while (0)
96
97#define WL1251_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \
98 CFG_BSSID_FILTER_EN)
99
100#define WL1251_DEFAULT_RX_FILTER (CFG_RX_PRSP_EN | \
101 CFG_RX_MGMT_EN | \
102 CFG_RX_DATA_EN | \
103 CFG_RX_CTL_EN | \
104 CFG_RX_BCN_EN | \
105 CFG_RX_AUTH_EN | \
106 CFG_RX_ASSOC_EN)
107
108#define WL1251_BUSY_WORD_LEN 8
109
110struct boot_attr {
111 u32 radio_type;
112 u8 mac_clock;
113 u8 arm_clock;
114 int firmware_debug;
115 u32 minor;
116 u32 major;
117 u32 bugfix;
118};
119
120enum wl1251_state {
121 WL1251_STATE_OFF,
122 WL1251_STATE_ON,
123 WL1251_STATE_PLT,
124};
125
126enum wl1251_partition_type {
127 PART_DOWN,
128 PART_WORK,
129 PART_DRPW,
130
131 PART_TABLE_LEN
132};
133
134struct wl1251_partition {
135 u32 size;
136 u32 start;
137};
138
139struct wl1251_partition_set {
140 struct wl1251_partition mem;
141 struct wl1251_partition reg;
142};
143
144struct wl1251;
145
146/* FIXME: I'm not sure about this structure name */
147struct wl1251_chip {
148 u32 id;
149
150 const char *fw_filename;
151 const char *nvs_filename;
152
153 char fw_ver[21];
154
155 unsigned int power_on_sleep;
156 int intr_cmd_complete;
157 int intr_init_complete;
158
159 int (*op_upload_fw)(struct wl1251 *wl);
160 int (*op_upload_nvs)(struct wl1251 *wl);
161 int (*op_boot)(struct wl1251 *wl);
162 void (*op_set_ecpu_ctrl)(struct wl1251 *wl, u32 flag);
163 void (*op_target_enable_interrupts)(struct wl1251 *wl);
164 int (*op_hw_init)(struct wl1251 *wl);
165 int (*op_plt_init)(struct wl1251 *wl);
166 void (*op_tx_flush)(struct wl1251 *wl);
167 void (*op_fw_version)(struct wl1251 *wl);
168 int (*op_cmd_join)(struct wl1251 *wl, u8 bss_type, u8 dtim_interval,
169 u16 beacon_interval, u8 wait);
170
171 struct wl1251_partition_set *p_table;
172 enum wl12xx_acx_int_reg *acx_reg_table;
173};
174
175struct wl1251_stats {
176 struct acx_statistics *fw_stats;
177 unsigned long fw_stats_update;
178
179 unsigned int retry_count;
180 unsigned int excessive_retries;
181};
182
183struct wl1251_debugfs {
184 struct dentry *rootdir;
185 struct dentry *fw_statistics;
186
187 struct dentry *tx_internal_desc_overflow;
188
189 struct dentry *rx_out_of_mem;
190 struct dentry *rx_hdr_overflow;
191 struct dentry *rx_hw_stuck;
192 struct dentry *rx_dropped;
193 struct dentry *rx_fcs_err;
194 struct dentry *rx_xfr_hint_trig;
195 struct dentry *rx_path_reset;
196 struct dentry *rx_reset_counter;
197
198 struct dentry *dma_rx_requested;
199 struct dentry *dma_rx_errors;
200 struct dentry *dma_tx_requested;
201 struct dentry *dma_tx_errors;
202
203 struct dentry *isr_cmd_cmplt;
204 struct dentry *isr_fiqs;
205 struct dentry *isr_rx_headers;
206 struct dentry *isr_rx_mem_overflow;
207 struct dentry *isr_rx_rdys;
208 struct dentry *isr_irqs;
209 struct dentry *isr_tx_procs;
210 struct dentry *isr_decrypt_done;
211 struct dentry *isr_dma0_done;
212 struct dentry *isr_dma1_done;
213 struct dentry *isr_tx_exch_complete;
214 struct dentry *isr_commands;
215 struct dentry *isr_rx_procs;
216 struct dentry *isr_hw_pm_mode_changes;
217 struct dentry *isr_host_acknowledges;
218 struct dentry *isr_pci_pm;
219 struct dentry *isr_wakeups;
220 struct dentry *isr_low_rssi;
221
222 struct dentry *wep_addr_key_count;
223 struct dentry *wep_default_key_count;
224 /* skipping wep.reserved */
225 struct dentry *wep_key_not_found;
226 struct dentry *wep_decrypt_fail;
227 struct dentry *wep_packets;
228 struct dentry *wep_interrupt;
229
230 struct dentry *pwr_ps_enter;
231 struct dentry *pwr_elp_enter;
232 struct dentry *pwr_missing_bcns;
233 struct dentry *pwr_wake_on_host;
234 struct dentry *pwr_wake_on_timer_exp;
235 struct dentry *pwr_tx_with_ps;
236 struct dentry *pwr_tx_without_ps;
237 struct dentry *pwr_rcvd_beacons;
238 struct dentry *pwr_power_save_off;
239 struct dentry *pwr_enable_ps;
240 struct dentry *pwr_disable_ps;
241 struct dentry *pwr_fix_tsf_ps;
242 /* skipping cont_miss_bcns_spread for now */
243 struct dentry *pwr_rcvd_awake_beacons;
244
245 struct dentry *mic_rx_pkts;
246 struct dentry *mic_calc_failure;
247
248 struct dentry *aes_encrypt_fail;
249 struct dentry *aes_decrypt_fail;
250 struct dentry *aes_encrypt_packets;
251 struct dentry *aes_decrypt_packets;
252 struct dentry *aes_encrypt_interrupt;
253 struct dentry *aes_decrypt_interrupt;
254
255 struct dentry *event_heart_beat;
256 struct dentry *event_calibration;
257 struct dentry *event_rx_mismatch;
258 struct dentry *event_rx_mem_empty;
259 struct dentry *event_rx_pool;
260 struct dentry *event_oom_late;
261 struct dentry *event_phy_transmit_error;
262 struct dentry *event_tx_stuck;
263
264 struct dentry *ps_pspoll_timeouts;
265 struct dentry *ps_upsd_timeouts;
266 struct dentry *ps_upsd_max_sptime;
267 struct dentry *ps_upsd_max_apturn;
268 struct dentry *ps_pspoll_max_apturn;
269 struct dentry *ps_pspoll_utilization;
270 struct dentry *ps_upsd_utilization;
271
272 struct dentry *rxpipe_rx_prep_beacon_drop;
273 struct dentry *rxpipe_descr_host_int_trig_rx_data;
274 struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data;
275 struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data;
276 struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data;
277
278 struct dentry *tx_queue_len;
279
280 struct dentry *retry_count;
281 struct dentry *excessive_retries;
282};
283
284struct wl1251 {
285 struct ieee80211_hw *hw;
286 bool mac80211_registered;
287
288 struct spi_device *spi;
289
290 void (*set_power)(bool enable);
291 int irq;
292
293 enum wl1251_state state;
294 struct mutex mutex;
295
296 int physical_mem_addr;
297 int physical_reg_addr;
298 int virtual_mem_addr;
299 int virtual_reg_addr;
300
301 struct wl1251_chip chip;
302
303 int cmd_box_addr;
304 int event_box_addr;
305 struct boot_attr boot_attr;
306
307 u8 *fw;
308 size_t fw_len;
309 u8 *nvs;
310 size_t nvs_len;
311
312 u8 bssid[ETH_ALEN];
313 u8 mac_addr[ETH_ALEN];
314 u8 bss_type;
315 u8 listen_int;
316 int channel;
317
318 void *target_mem_map;
319 struct acx_data_path_params_resp *data_path;
320
321 /* Number of TX packets transferred to the FW, modulo 16 */
322 u32 data_in_count;
323
324 /* Frames scheduled for transmission, not handled yet */
325 struct sk_buff_head tx_queue;
326 bool tx_queue_stopped;
327
328 struct work_struct tx_work;
329 struct work_struct filter_work;
330
331 /* Pending TX frames */
332 struct sk_buff *tx_frames[16];
43 333
44 /* 334 /*
45 * Nmber of memory buffers for the RX mem pool. 335 * Index pointing to the next TX complete entry
46 * The actual number may be less if there are 336 * in the cyclic XT complete array we get from
47 * not enough blocks left for the minimum num 337 * the FW.
48 * of TX ones.
49 */ 338 */
50 u8 rx_mem_block_num; 339 u32 next_tx_complete;
51 u8 reserved_2;
52 u8 num_tx_queues; /* From 1 to 16 */
53 u8 host_if_options; /* HOST_IF* */
54 u8 tx_min_mem_block_num;
55 u8 num_ssid_profiles;
56 __le16 debug_buffer_size;
57} __attribute__ ((packed));
58
59
60#define ACX_RX_DESC_MIN 1
61#define ACX_RX_DESC_MAX 127
62#define ACX_RX_DESC_DEF 32
63struct wl1251_acx_rx_queue_config {
64 u8 num_descs;
65 u8 pad;
66 u8 type;
67 u8 priority;
68 __le32 dma_address;
69} __attribute__ ((packed));
70
71#define ACX_TX_DESC_MIN 1
72#define ACX_TX_DESC_MAX 127
73#define ACX_TX_DESC_DEF 16
74struct wl1251_acx_tx_queue_config {
75 u8 num_descs;
76 u8 pad[2];
77 u8 attributes;
78} __attribute__ ((packed));
79
80#define MAX_TX_QUEUE_CONFIGS 5
81#define MAX_TX_QUEUES 4
82struct wl1251_acx_config_memory {
83 struct acx_header header;
84
85 struct wl1251_acx_memory mem_config;
86 struct wl1251_acx_rx_queue_config rx_queue_config;
87 struct wl1251_acx_tx_queue_config tx_queue_config[MAX_TX_QUEUE_CONFIGS];
88} __attribute__ ((packed));
89
90struct wl1251_acx_mem_map {
91 struct acx_header header;
92
93 void *code_start;
94 void *code_end;
95
96 void *wep_defkey_start;
97 void *wep_defkey_end;
98 340
99 void *sta_table_start; 341 /* FW Rx counter */
100 void *sta_table_end; 342 u32 rx_counter;
101 343
102 void *packet_template_start; 344 /* Rx frames handled */
103 void *packet_template_end; 345 u32 rx_handled;
104 346
105 void *queue_memory_start; 347 /* Current double buffer */
106 void *queue_memory_end; 348 u32 rx_current_buffer;
349 u32 rx_last_id;
107 350
108 void *packet_memory_pool_start; 351 /* The target interrupt mask */
109 void *packet_memory_pool_end; 352 u32 intr_mask;
353 struct work_struct irq_work;
110 354
111 void *debug_buffer1_start; 355 /* The mbox event mask */
112 void *debug_buffer1_end; 356 u32 event_mask;
113 357
114 void *debug_buffer2_start; 358 /* Mailbox pointers */
115 void *debug_buffer2_end; 359 u32 mbox_ptr[2];
116 360
117 /* Number of blocks FW allocated for TX packets */ 361 /* Are we currently scanning */
118 u32 num_tx_mem_blocks; 362 bool scanning;
119 363
120 /* Number of blocks FW allocated for RX packets */ 364 /* Our association ID */
121 u32 num_rx_mem_blocks; 365 u16 aid;
122} __attribute__ ((packed));
123 366
124/************************************************************************* 367 /* Default key (for WEP) */
368 u32 default_key;
125 369
126 Host Interrupt Register (WiLink -> Host) 370 unsigned int tx_mgmt_frm_rate;
371 unsigned int tx_mgmt_frm_mod;
127 372
128**************************************************************************/ 373 unsigned int rx_config;
374 unsigned int rx_filter;
129 375
130/* RX packet is ready in Xfer buffer #0 */ 376 /* is firmware in elp mode */
131#define WL1251_ACX_INTR_RX0_DATA BIT(0) 377 bool elp;
132 378
133/* TX result(s) are in the TX complete buffer */ 379 /* we can be in psm, but not in elp, we have to differentiate */
134#define WL1251_ACX_INTR_TX_RESULT BIT(1) 380 bool psm;
135 381
136/* OBSOLETE */ 382 /* PSM mode requested */
137#define WL1251_ACX_INTR_TX_XFR BIT(2) 383 bool psm_requested;
138 384
139/* RX packet is ready in Xfer buffer #1 */ 385 /* in dBm */
140#define WL1251_ACX_INTR_RX1_DATA BIT(3) 386 int power_level;
141 387
142/* Event was entered to Event MBOX #A */ 388 struct wl1251_stats stats;
143#define WL1251_ACX_INTR_EVENT_A BIT(4) 389 struct wl1251_debugfs debugfs;
144 390
145/* Event was entered to Event MBOX #B */ 391 u32 buffer_32;
146#define WL1251_ACX_INTR_EVENT_B BIT(5) 392 u32 buffer_cmd;
393 u8 buffer_busyword[WL1251_BUSY_WORD_LEN];
394 struct wl1251_rx_descriptor *rx_descriptor;
395};
147 396
148/* OBSOLETE */ 397int wl1251_plt_start(struct wl1251 *wl);
149#define WL1251_ACX_INTR_WAKE_ON_HOST BIT(6) 398int wl1251_plt_stop(struct wl1251 *wl);
150 399
151/* Trace meassge on MBOX #A */ 400#define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG /* Long Preamble */
152#define WL1251_ACX_INTR_TRACE_A BIT(7) 401#define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS
402#define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */
153 403
154/* Trace meassge on MBOX #B */ 404#define WL1251_DEFAULT_POWER_LEVEL 20
155#define WL1251_ACX_INTR_TRACE_B BIT(8)
156 405
157/* Command processing completion */ 406#define WL1251_TX_QUEUE_MAX_LENGTH 20
158#define WL1251_ACX_INTR_CMD_COMPLETE BIT(9)
159 407
160/* Init sequence is done */ 408/* Different chips need different sleep times after power on. WL1271 needs
161#define WL1251_ACX_INTR_INIT_COMPLETE BIT(14) 409 * 200ms, WL1251 needs only 10ms. By default we use 200ms, but as soon as we
410 * know the chip ID, we change the sleep value in the wl1251 chip structure,
411 * so in subsequent power ons, we don't waste more time then needed. */
412#define WL1251_DEFAULT_POWER_ON_SLEEP 200
162 413
163#define WL1251_ACX_INTR_ALL 0xFFFFFFFF 414#define CHIP_ID_1251_PG10 (0x7010101)
415#define CHIP_ID_1251_PG11 (0x7020101)
416#define CHIP_ID_1251_PG12 (0x7030101)
417#define CHIP_ID_1271_PG10 (0x4030101)
418#define CHIP_ID_1271_PG20 (0x4030111)
164 419
165#endif 420#endif
diff --git a/drivers/net/wireless/wl12xx/wl1251_acx.c b/drivers/net/wireless/wl12xx/wl1251_acx.c
new file mode 100644
index 000000000000..a46c92a29526
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl1251_acx.c
@@ -0,0 +1,840 @@
1#include "wl1251_acx.h"
2
3#include <linux/module.h>
4#include <linux/crc7.h>
5#include <linux/spi/spi.h>
6
7#include "wl1251.h"
8#include "reg.h"
9#include "wl1251_spi.h"
10#include "wl1251_ps.h"
11
12int 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
38out:
39 kfree(rates);
40 return ret;
41}
42
43
44int 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
64out:
65 kfree(mac);
66 return ret;
67}
68
69int 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
93out:
94 kfree(default_key);
95 return ret;
96}
97
98int 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
122out:
123 kfree(wake_up);
124 return ret;
125}
126
127int 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
146out:
147 kfree(auth);
148 return ret;
149}
150
151int 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
180out:
181 kfree(rev);
182 return ret;
183}
184
185int 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
209out:
210 kfree(acx);
211 return ret;
212}
213
214int 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
238out:
239 kfree(feature);
240 return ret;
241}
242
243int 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
257int 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
301out:
302 kfree(params);
303 return ret;
304}
305
306int 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
327out:
328 kfree(acx);
329 return ret;
330}
331
332int 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
355out:
356 kfree(rx_config);
357 return ret;
358}
359
360int 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
381out:
382 kfree(pd);
383 return 0;
384}
385
386int 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
408out:
409 kfree(slot);
410 return ret;
411}
412
413int 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
438out:
439 kfree(acx);
440 return ret;
441}
442
443int 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
467out:
468 kfree(rx_timeout);
469 return ret;
470}
471
472int 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
493out:
494 kfree(rts);
495 return ret;
496}
497
498int wl1251_acx_beacon_filter_opt(struct wl1251 *wl)
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 = 0;
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
521out:
522 kfree(beacon_filter);
523 return ret;
524}
525
526int wl1251_acx_beacon_filter_table(struct wl1251 *wl)
527{
528 struct acx_beacon_filter_ie_table *ie_table;
529 int ret;
530
531 wl1251_debug(DEBUG_ACX, "acx beacon filter table");
532
533 ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL);
534 if (!ie_table) {
535 ret = -ENOMEM;
536 goto out;
537 }
538
539 ie_table->num_ie = 0;
540 memset(ie_table->table, 0, BEACON_FILTER_TABLE_MAX_SIZE);
541
542 ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE,
543 ie_table, sizeof(*ie_table));
544 if (ret < 0) {
545 wl1251_warning("failed to set beacon filter table: %d", ret);
546 goto out;
547 }
548
549out:
550 kfree(ie_table);
551 return ret;
552}
553
554int wl1251_acx_sg_enable(struct wl1251 *wl)
555{
556 struct acx_bt_wlan_coex *pta;
557 int ret;
558
559 wl1251_debug(DEBUG_ACX, "acx sg enable");
560
561 pta = kzalloc(sizeof(*pta), GFP_KERNEL);
562 if (!pta) {
563 ret = -ENOMEM;
564 goto out;
565 }
566
567 pta->enable = SG_ENABLE;
568
569 ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta));
570 if (ret < 0) {
571 wl1251_warning("failed to set softgemini enable: %d", ret);
572 goto out;
573 }
574
575out:
576 kfree(pta);
577 return ret;
578}
579
580int wl1251_acx_sg_cfg(struct wl1251 *wl)
581{
582 struct acx_bt_wlan_coex_param *param;
583 int ret;
584
585 wl1251_debug(DEBUG_ACX, "acx sg cfg");
586
587 param = kzalloc(sizeof(*param), GFP_KERNEL);
588 if (!param) {
589 ret = -ENOMEM;
590 goto out;
591 }
592
593 /* BT-WLAN coext parameters */
594 param->min_rate = RATE_INDEX_24MBPS;
595 param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF;
596 param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF;
597 param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF;
598 param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF;
599 param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF;
600 param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF;
601 param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF;
602 param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF;
603 param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF;
604 param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF;
605 param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF;
606 param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF;
607 param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF;
608 param->antenna_type = PTA_ANTENNA_TYPE_DEF;
609 param->signal_type = PTA_SIGNALING_TYPE_DEF;
610 param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF;
611 param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF;
612 param->max_cts = PTA_MAX_NUM_CTS_DEF;
613 param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF;
614 param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF;
615 param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF;
616 param->wlan_elp_hp = PTA_ELP_HP_DEF;
617 param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF;
618 param->ack_mode_dual_ant = PTA_ACK_MODE_DEF;
619 param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF;
620 param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF;
621 param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF;
622
623 ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param));
624 if (ret < 0) {
625 wl1251_warning("failed to set sg config: %d", ret);
626 goto out;
627 }
628
629out:
630 kfree(param);
631 return ret;
632}
633
634int wl1251_acx_cca_threshold(struct wl1251 *wl)
635{
636 struct acx_energy_detection *detection;
637 int ret;
638
639 wl1251_debug(DEBUG_ACX, "acx cca threshold");
640
641 detection = kzalloc(sizeof(*detection), GFP_KERNEL);
642 if (!detection) {
643 ret = -ENOMEM;
644 goto out;
645 }
646
647 detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D;
648 detection->tx_energy_detection = 0;
649
650 ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD,
651 detection, sizeof(*detection));
652 if (ret < 0) {
653 wl1251_warning("failed to set cca threshold: %d", ret);
654 return ret;
655 }
656
657out:
658 kfree(detection);
659 return ret;
660}
661
662int wl1251_acx_bcn_dtim_options(struct wl1251 *wl)
663{
664 struct acx_beacon_broadcast *bb;
665 int ret;
666
667 wl1251_debug(DEBUG_ACX, "acx bcn dtim options");
668
669 bb = kzalloc(sizeof(*bb), GFP_KERNEL);
670 if (!bb) {
671 ret = -ENOMEM;
672 goto out;
673 }
674
675 bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE;
676 bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE;
677 bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE;
678 bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
679
680 ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb));
681 if (ret < 0) {
682 wl1251_warning("failed to set rx config: %d", ret);
683 goto out;
684 }
685
686out:
687 kfree(bb);
688 return ret;
689}
690
691int wl1251_acx_aid(struct wl1251 *wl, u16 aid)
692{
693 struct acx_aid *acx_aid;
694 int ret;
695
696 wl1251_debug(DEBUG_ACX, "acx aid");
697
698 acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL);
699 if (!acx_aid) {
700 ret = -ENOMEM;
701 goto out;
702 }
703
704 acx_aid->aid = aid;
705
706 ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid));
707 if (ret < 0) {
708 wl1251_warning("failed to set aid: %d", ret);
709 goto out;
710 }
711
712out:
713 kfree(acx_aid);
714 return ret;
715}
716
717int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask)
718{
719 struct acx_event_mask *mask;
720 int ret;
721
722 wl1251_debug(DEBUG_ACX, "acx event mbox mask");
723
724 mask = kzalloc(sizeof(*mask), GFP_KERNEL);
725 if (!mask) {
726 ret = -ENOMEM;
727 goto out;
728 }
729
730 /* high event mask is unused */
731 mask->high_event_mask = 0xffffffff;
732
733 mask->event_mask = event_mask;
734
735 ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK,
736 mask, sizeof(*mask));
737 if (ret < 0) {
738 wl1251_warning("failed to set acx_event_mbox_mask: %d", ret);
739 goto out;
740 }
741
742out:
743 kfree(mask);
744 return ret;
745}
746
747int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble)
748{
749 struct acx_preamble *acx;
750 int ret;
751
752 wl1251_debug(DEBUG_ACX, "acx_set_preamble");
753
754 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
755 if (!acx) {
756 ret = -ENOMEM;
757 goto out;
758 }
759
760 acx->preamble = preamble;
761
762 ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx));
763 if (ret < 0) {
764 wl1251_warning("Setting of preamble failed: %d", ret);
765 goto out;
766 }
767
768out:
769 kfree(acx);
770 return ret;
771}
772
773int wl1251_acx_cts_protect(struct wl1251 *wl,
774 enum acx_ctsprotect_type ctsprotect)
775{
776 struct acx_ctsprotect *acx;
777 int ret;
778
779 wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect");
780
781 acx = kzalloc(sizeof(*acx), GFP_KERNEL);
782 if (!acx) {
783 ret = -ENOMEM;
784 goto out;
785 }
786
787 acx->ctsprotect = ctsprotect;
788
789 ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx));
790 if (ret < 0) {
791 wl1251_warning("Setting of ctsprotect failed: %d", ret);
792 goto out;
793 }
794
795out:
796 kfree(acx);
797 return ret;
798}
799
800int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime)
801{
802 struct acx_tsf_info *tsf_info;
803 int ret;
804
805 tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL);
806 if (!tsf_info) {
807 ret = -ENOMEM;
808 goto out;
809 }
810
811 ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO,
812 tsf_info, sizeof(*tsf_info));
813 if (ret < 0) {
814 wl1251_warning("ACX_FW_REV interrogate failed");
815 goto out;
816 }
817
818 *mactime = tsf_info->current_tsf_lsb |
819 (tsf_info->current_tsf_msb << 31);
820
821out:
822 kfree(tsf_info);
823 return ret;
824}
825
826int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats)
827{
828 int ret;
829
830 wl1251_debug(DEBUG_ACX, "acx statistics");
831
832 ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats,
833 sizeof(*stats));
834 if (ret < 0) {
835 wl1251_warning("acx statistics failed: %d", ret);
836 return -ENOMEM;
837 }
838
839 return 0;
840}
diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/wl1251_acx.h
index fb2d2340993c..2e7b1933a8f9 100644
--- a/drivers/net/wireless/wl12xx/acx.h
+++ b/drivers/net/wireless/wl12xx/wl1251_acx.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -22,14 +22,20 @@
22 * 22 *
23 */ 23 */
24 24
25#ifndef __WL12XX_ACX_H__ 25#ifndef __WL1251_ACX_H__
26#define __WL12XX_ACX_H__ 26#define __WL1251_ACX_H__
27 27
28#include "wl12xx.h" 28#include "wl1251.h"
29#include "wl1251_cmd.h"
29 30
30/* Target's information element */ 31/* Target's information element */
31struct acx_header { 32struct acx_header {
33 struct wl1251_cmd_header cmd;
34
35 /* acx (or information element) header */
32 u16 id; 36 u16 id;
37
38 /* payload length (not including headers */
33 u16 len; 39 u16 len;
34}; 40};
35 41
@@ -85,15 +91,15 @@ struct acx_revision {
85 u32 hw_version; 91 u32 hw_version;
86} __attribute__ ((packed)); 92} __attribute__ ((packed));
87 93
88enum wl12xx_psm_mode { 94enum wl1251_psm_mode {
89 /* Active mode */ 95 /* Active mode */
90 WL12XX_PSM_CAM = 0, 96 WL1251_PSM_CAM = 0,
91 97
92 /* Power save mode */ 98 /* Power save mode */
93 WL12XX_PSM_PS = 1, 99 WL1251_PSM_PS = 1,
94 100
95 /* Extreme low power */ 101 /* Extreme low power */
96 WL12XX_PSM_ELP = 2, 102 WL1251_PSM_ELP = 2,
97}; 103};
98 104
99struct acx_sleep_auth { 105struct acx_sleep_auth {
@@ -107,25 +113,6 @@ struct acx_sleep_auth {
107 u8 padding[3]; 113 u8 padding[3];
108} __attribute__ ((packed)); 114} __attribute__ ((packed));
109 115
110#define TIM_ELE_ID 5
111#define PARTIAL_VBM_MAX 251
112
113struct tim {
114 u8 identity;
115 u8 length;
116 u8 dtim_count;
117 u8 dtim_period;
118 u8 bitmap_ctrl;
119 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
120} __attribute__ ((packed));
121
122/* Virtual Bit Map update */
123struct vbm_update_request {
124 __le16 len;
125 u8 padding[2];
126 struct tim tim;
127} __attribute__ ((packed));
128
129enum { 116enum {
130 HOSTIF_PCI_MASTER_HOST_INDIRECT, 117 HOSTIF_PCI_MASTER_HOST_INDIRECT,
131 HOSTIF_PCI_MASTER_HOST_DIRECT, 118 HOSTIF_PCI_MASTER_HOST_DIRECT,
@@ -202,7 +189,7 @@ struct acx_data_path_params_resp {
202#define RX_MSDU_LIFETIME_MAX 0xFFFFFFFF 189#define RX_MSDU_LIFETIME_MAX 0xFFFFFFFF
203#define RX_MSDU_LIFETIME_DEF 512000 190#define RX_MSDU_LIFETIME_DEF 512000
204 191
205struct rx_msdu_lifetime { 192struct acx_rx_msdu_lifetime {
206 struct acx_header header; 193 struct acx_header header;
207 194
208 /* 195 /*
@@ -368,7 +355,7 @@ struct acx_slot {
368#define ADDRESS_GROUP_MAX (8) 355#define ADDRESS_GROUP_MAX (8)
369#define ADDRESS_GROUP_MAX_LEN (ETH_ALEN * ADDRESS_GROUP_MAX) 356#define ADDRESS_GROUP_MAX_LEN (ETH_ALEN * ADDRESS_GROUP_MAX)
370 357
371struct multicast_grp_addr_start { 358struct acx_dot11_grp_addr_tbl {
372 struct acx_header header; 359 struct acx_header header;
373 360
374 u8 enabled; 361 u8 enabled;
@@ -730,22 +717,13 @@ struct acx_fw_gen_frame_rates {
730} __attribute__ ((packed)); 717} __attribute__ ((packed));
731 718
732/* STA MAC */ 719/* STA MAC */
733struct dot11_station_id { 720struct acx_dot11_station_id {
734 struct acx_header header; 721 struct acx_header header;
735 722
736 u8 mac[ETH_ALEN]; 723 u8 mac[ETH_ALEN];
737 u8 pad[2]; 724 u8 pad[2];
738} __attribute__ ((packed)); 725} __attribute__ ((packed));
739 726
740/* HW encryption keys */
741#define NUM_ACCESS_CATEGORIES_COPY 4
742#define MAX_KEY_SIZE 32
743
744/* When set, disable HW encryption */
745#define DF_ENCRYPTION_DISABLE 0x01
746/* When set, disable HW decryption */
747#define DF_SNIFF_MODE_ENABLE 0x80
748
749struct acx_feature_config { 727struct acx_feature_config {
750 struct acx_header header; 728 struct acx_header header;
751 729
@@ -753,67 +731,6 @@ struct acx_feature_config {
753 u32 data_flow_options; 731 u32 data_flow_options;
754} __attribute__ ((packed)); 732} __attribute__ ((packed));
755 733
756enum acx_key_action {
757 KEY_ADD_OR_REPLACE = 1,
758 KEY_REMOVE = 2,
759 KEY_SET_ID = 3,
760 MAX_KEY_ACTION = 0xffff,
761};
762
763enum acx_key_type {
764 KEY_WEP_DEFAULT = 0,
765 KEY_WEP_ADDR = 1,
766 KEY_AES_GROUP = 4,
767 KEY_AES_PAIRWISE = 5,
768 KEY_WEP_GROUP = 6,
769 KEY_TKIP_MIC_GROUP = 10,
770 KEY_TKIP_MIC_PAIRWISE = 11,
771};
772
773/*
774 *
775 * key_type_e key size key format
776 * ---------- --------- ----------
777 * 0x00 5, 13, 29 Key data
778 * 0x01 5, 13, 29 Key data
779 * 0x04 16 16 bytes of key data
780 * 0x05 16 16 bytes of key data
781 * 0x0a 32 16 bytes of TKIP key data
782 * 8 bytes of RX MIC key data
783 * 8 bytes of TX MIC key data
784 * 0x0b 32 16 bytes of TKIP key data
785 * 8 bytes of RX MIC key data
786 * 8 bytes of TX MIC key data
787 *
788 */
789
790struct acx_set_key {
791 /* Ignored for default WEP key */
792 u8 addr[ETH_ALEN];
793
794 /* key_action_e */
795 u16 key_action;
796
797 u16 reserved_1;
798
799 /* key size in bytes */
800 u8 key_size;
801
802 /* key_type_e */
803 u8 key_type;
804 u8 ssid_profile;
805
806 /*
807 * TKIP, AES: frame's key id field.
808 * For WEP default key: key id;
809 */
810 u8 id;
811 u8 reserved_2[6];
812 u8 key[MAX_KEY_SIZE];
813 u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
814 u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
815} __attribute__ ((packed));
816
817struct acx_current_tx_power { 734struct acx_current_tx_power {
818 struct acx_header header; 735 struct acx_header header;
819 736
@@ -839,26 +756,6 @@ struct acx_tsf_info {
839 u8 pad[3]; 756 u8 pad[3];
840} __attribute__ ((packed)); 757} __attribute__ ((packed));
841 758
842/* 802.11 PS */
843enum acx_ps_mode {
844 STATION_ACTIVE_MODE,
845 STATION_POWER_SAVE_MODE
846};
847
848struct acx_ps_params {
849 u8 ps_mode; /* STATION_* */
850 u8 send_null_data; /* Do we have to send NULL data packet ? */
851 u8 retries; /* Number of retires for the initial NULL data packet */
852
853 /*
854 * TUs during which the target stays awake after switching
855 * to power save mode.
856 */
857 u8 hang_over_period;
858 u16 null_data_rate;
859 u8 pad[2];
860} __attribute__ ((packed));
861
862enum acx_wake_up_event { 759enum acx_wake_up_event {
863 WAKE_UP_EVENT_BEACON_BITMAP = 0x01, /* Wake on every Beacon*/ 760 WAKE_UP_EVENT_BEACON_BITMAP = 0x01, /* Wake on every Beacon*/
864 WAKE_UP_EVENT_DTIM_BITMAP = 0x02, /* Wake on every DTIM*/ 761 WAKE_UP_EVENT_DTIM_BITMAP = 0x02, /* Wake on every DTIM*/
@@ -892,6 +789,7 @@ enum acx_preamble_type {
892 789
893struct acx_preamble { 790struct acx_preamble {
894 struct acx_header header; 791 struct acx_header header;
792
895 /* 793 /*
896 * When set, the WiLink transmits the frames with a short preamble and 794 * When set, the WiLink transmits the frames with a short preamble and
897 * when cleared, the WiLink transmits the frames with a long preamble. 795 * when cleared, the WiLink transmits the frames with a long preamble.
@@ -1210,36 +1108,39 @@ enum {
1210}; 1108};
1211 1109
1212 1110
1213int wl12xx_acx_frame_rates(struct wl12xx *wl, u8 ctrl_rate, u8 ctrl_mod, 1111int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod,
1214 u8 mgt_rate, u8 mgt_mod); 1112 u8 mgt_rate, u8 mgt_mod);
1215int wl12xx_acx_station_id(struct wl12xx *wl); 1113int wl1251_acx_station_id(struct wl1251 *wl);
1216int wl12xx_acx_default_key(struct wl12xx *wl, u8 key_id); 1114int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id);
1217int wl12xx_acx_wake_up_conditions(struct wl12xx *wl, u8 listen_interval); 1115int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event,
1218int wl12xx_acx_sleep_auth(struct wl12xx *wl, u8 sleep_auth); 1116 u8 listen_interval);
1219int wl12xx_acx_fw_version(struct wl12xx *wl, char *buf, size_t len); 1117int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth);
1220int wl12xx_acx_tx_power(struct wl12xx *wl, int power); 1118int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len);
1221int wl12xx_acx_feature_cfg(struct wl12xx *wl); 1119int wl1251_acx_tx_power(struct wl1251 *wl, int power);
1222int wl12xx_acx_mem_map(struct wl12xx *wl, void *mem_map, size_t len); 1120int wl1251_acx_feature_cfg(struct wl1251 *wl);
1223int wl12xx_acx_data_path_params(struct wl12xx *wl, 1121int wl1251_acx_mem_map(struct wl1251 *wl,
1122 struct acx_header *mem_map, size_t len);
1123int wl1251_acx_data_path_params(struct wl1251 *wl,
1224 struct acx_data_path_params_resp *data_path); 1124 struct acx_data_path_params_resp *data_path);
1225int wl12xx_acx_rx_msdu_life_time(struct wl12xx *wl, u32 life_time); 1125int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time);
1226int wl12xx_acx_rx_config(struct wl12xx *wl, u32 config, u32 filter); 1126int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter);
1227int wl12xx_acx_pd_threshold(struct wl12xx *wl); 1127int wl1251_acx_pd_threshold(struct wl1251 *wl);
1228int wl12xx_acx_slot(struct wl12xx *wl, enum acx_slot_type slot_time); 1128int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time);
1229int wl12xx_acx_group_address_tbl(struct wl12xx *wl); 1129int wl1251_acx_group_address_tbl(struct wl1251 *wl);
1230int wl12xx_acx_service_period_timeout(struct wl12xx *wl); 1130int wl1251_acx_service_period_timeout(struct wl1251 *wl);
1231int wl12xx_acx_rts_threshold(struct wl12xx *wl, u16 rts_threshold); 1131int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold);
1232int wl12xx_acx_beacon_filter_opt(struct wl12xx *wl); 1132int wl1251_acx_beacon_filter_opt(struct wl1251 *wl);
1233int wl12xx_acx_beacon_filter_table(struct wl12xx *wl); 1133int wl1251_acx_beacon_filter_table(struct wl1251 *wl);
1234int wl12xx_acx_sg_enable(struct wl12xx *wl); 1134int wl1251_acx_sg_enable(struct wl1251 *wl);
1235int wl12xx_acx_sg_cfg(struct wl12xx *wl); 1135int wl1251_acx_sg_cfg(struct wl1251 *wl);
1236int wl12xx_acx_cca_threshold(struct wl12xx *wl); 1136int wl1251_acx_cca_threshold(struct wl1251 *wl);
1237int wl12xx_acx_bcn_dtim_options(struct wl12xx *wl); 1137int wl1251_acx_bcn_dtim_options(struct wl1251 *wl);
1238int wl12xx_acx_aid(struct wl12xx *wl, u16 aid); 1138int wl1251_acx_aid(struct wl1251 *wl, u16 aid);
1239int wl12xx_acx_event_mbox_mask(struct wl12xx *wl, u32 event_mask); 1139int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask);
1240int wl12xx_acx_set_preamble(struct wl12xx *wl, enum acx_preamble_type preamble); 1140int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble);
1241int wl12xx_acx_cts_protect(struct wl12xx *wl, 1141int wl1251_acx_cts_protect(struct wl1251 *wl,
1242 enum acx_ctsprotect_type ctsprotect); 1142 enum acx_ctsprotect_type ctsprotect);
1243int wl12xx_acx_statistics(struct wl12xx *wl, struct acx_statistics *stats); 1143int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats);
1144int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime);
1244 1145
1245#endif /* __WL12XX_ACX_H__ */ 1146#endif /* __WL1251_ACX_H__ */
diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c
index 48ac08c429bd..d8a155dc2fa1 100644
--- a/drivers/net/wireless/wl12xx/boot.c
+++ b/drivers/net/wireless/wl12xx/wl1251_boot.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
@@ -24,41 +24,41 @@
24#include <linux/gpio.h> 24#include <linux/gpio.h>
25 25
26#include "reg.h" 26#include "reg.h"
27#include "boot.h" 27#include "wl1251_boot.h"
28#include "spi.h" 28#include "wl1251_spi.h"
29#include "event.h" 29#include "wl1251_event.h"
30 30
31static void wl12xx_boot_enable_interrupts(struct wl12xx *wl) 31static void wl1251_boot_enable_interrupts(struct wl1251 *wl)
32{ 32{
33 enable_irq(wl->irq); 33 enable_irq(wl->irq);
34} 34}
35 35
36void wl12xx_boot_target_enable_interrupts(struct wl12xx *wl) 36void wl1251_boot_target_enable_interrupts(struct wl1251 *wl)
37{ 37{
38 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); 38 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask));
39 wl12xx_reg_write32(wl, HI_CFG, HI_CFG_DEF_VAL); 39 wl1251_reg_write32(wl, HI_CFG, HI_CFG_DEF_VAL);
40} 40}
41 41
42int wl12xx_boot_soft_reset(struct wl12xx *wl) 42int wl1251_boot_soft_reset(struct wl1251 *wl)
43{ 43{
44 unsigned long timeout; 44 unsigned long timeout;
45 u32 boot_data; 45 u32 boot_data;
46 46
47 /* perform soft reset */ 47 /* perform soft reset */
48 wl12xx_reg_write32(wl, ACX_REG_SLV_SOFT_RESET, ACX_SLV_SOFT_RESET_BIT); 48 wl1251_reg_write32(wl, ACX_REG_SLV_SOFT_RESET, ACX_SLV_SOFT_RESET_BIT);
49 49
50 /* SOFT_RESET is self clearing */ 50 /* SOFT_RESET is self clearing */
51 timeout = jiffies + usecs_to_jiffies(SOFT_RESET_MAX_TIME); 51 timeout = jiffies + usecs_to_jiffies(SOFT_RESET_MAX_TIME);
52 while (1) { 52 while (1) {
53 boot_data = wl12xx_reg_read32(wl, ACX_REG_SLV_SOFT_RESET); 53 boot_data = wl1251_reg_read32(wl, ACX_REG_SLV_SOFT_RESET);
54 wl12xx_debug(DEBUG_BOOT, "soft reset bootdata 0x%x", boot_data); 54 wl1251_debug(DEBUG_BOOT, "soft reset bootdata 0x%x", boot_data);
55 if ((boot_data & ACX_SLV_SOFT_RESET_BIT) == 0) 55 if ((boot_data & ACX_SLV_SOFT_RESET_BIT) == 0)
56 break; 56 break;
57 57
58 if (time_after(jiffies, timeout)) { 58 if (time_after(jiffies, timeout)) {
59 /* 1.2 check pWhalBus->uSelfClearTime if the 59 /* 1.2 check pWhalBus->uSelfClearTime if the
60 * timeout was reached */ 60 * timeout was reached */
61 wl12xx_error("soft reset timeout"); 61 wl1251_error("soft reset timeout");
62 return -1; 62 return -1;
63 } 63 }
64 64
@@ -66,15 +66,15 @@ int wl12xx_boot_soft_reset(struct wl12xx *wl)
66 } 66 }
67 67
68 /* disable Rx/Tx */ 68 /* disable Rx/Tx */
69 wl12xx_reg_write32(wl, ENABLE, 0x0); 69 wl1251_reg_write32(wl, ENABLE, 0x0);
70 70
71 /* disable auto calibration on start*/ 71 /* disable auto calibration on start*/
72 wl12xx_reg_write32(wl, SPARE_A2, 0xffff); 72 wl1251_reg_write32(wl, SPARE_A2, 0xffff);
73 73
74 return 0; 74 return 0;
75} 75}
76 76
77int wl12xx_boot_init_seq(struct wl12xx *wl) 77int wl1251_boot_init_seq(struct wl1251 *wl)
78{ 78{
79 u32 scr_pad6, init_data, tmp, elp_cmd, ref_freq; 79 u32 scr_pad6, init_data, tmp, elp_cmd, ref_freq;
80 80
@@ -96,23 +96,23 @@ int wl12xx_boot_init_seq(struct wl12xx *wl)
96 }; 96 };
97 97
98 /* read NVS params */ 98 /* read NVS params */
99 scr_pad6 = wl12xx_reg_read32(wl, SCR_PAD6); 99 scr_pad6 = wl1251_reg_read32(wl, SCR_PAD6);
100 wl12xx_debug(DEBUG_BOOT, "scr_pad6 0x%x", scr_pad6); 100 wl1251_debug(DEBUG_BOOT, "scr_pad6 0x%x", scr_pad6);
101 101
102 /* read ELP_CMD */ 102 /* read ELP_CMD */
103 elp_cmd = wl12xx_reg_read32(wl, ELP_CMD); 103 elp_cmd = wl1251_reg_read32(wl, ELP_CMD);
104 wl12xx_debug(DEBUG_BOOT, "elp_cmd 0x%x", elp_cmd); 104 wl1251_debug(DEBUG_BOOT, "elp_cmd 0x%x", elp_cmd);
105 105
106 /* set the BB calibration time to be 300 usec (PLL_CAL_TIME) */ 106 /* set the BB calibration time to be 300 usec (PLL_CAL_TIME) */
107 ref_freq = scr_pad6 & 0x000000FF; 107 ref_freq = scr_pad6 & 0x000000FF;
108 wl12xx_debug(DEBUG_BOOT, "ref_freq 0x%x", ref_freq); 108 wl1251_debug(DEBUG_BOOT, "ref_freq 0x%x", ref_freq);
109 109
110 wl12xx_reg_write32(wl, PLL_CAL_TIME, 0x9); 110 wl1251_reg_write32(wl, PLL_CAL_TIME, 0x9);
111 111
112 /* 112 /*
113 * PG 1.2: set the clock buffer time to be 210 usec (CLK_BUF_TIME) 113 * PG 1.2: set the clock buffer time to be 210 usec (CLK_BUF_TIME)
114 */ 114 */
115 wl12xx_reg_write32(wl, CLK_BUF_TIME, 0x6); 115 wl1251_reg_write32(wl, CLK_BUF_TIME, 0x6);
116 116
117 /* 117 /*
118 * set the clock detect feature to work in the restart wu procedure 118 * set the clock detect feature to work in the restart wu procedure
@@ -120,18 +120,18 @@ int wl12xx_boot_init_seq(struct wl12xx *wl)
120 * (ELP_CFG_MODE[13:12]) 120 * (ELP_CFG_MODE[13:12])
121 */ 121 */
122 tmp = ((scr_pad6 & 0x0000FF00) << 4) | 0x00004000; 122 tmp = ((scr_pad6 & 0x0000FF00) << 4) | 0x00004000;
123 wl12xx_reg_write32(wl, ELP_CFG_MODE, tmp); 123 wl1251_reg_write32(wl, ELP_CFG_MODE, tmp);
124 124
125 /* PG 1.2: enable the BB PLL fix. Enable the PLL_LIMP_CLK_EN_CMD */ 125 /* PG 1.2: enable the BB PLL fix. Enable the PLL_LIMP_CLK_EN_CMD */
126 elp_cmd |= 0x00000040; 126 elp_cmd |= 0x00000040;
127 wl12xx_reg_write32(wl, ELP_CMD, elp_cmd); 127 wl1251_reg_write32(wl, ELP_CMD, elp_cmd);
128 128
129 /* PG 1.2: Set the BB PLL stable time to be 1000usec 129 /* PG 1.2: Set the BB PLL stable time to be 1000usec
130 * (PLL_STABLE_TIME) */ 130 * (PLL_STABLE_TIME) */
131 wl12xx_reg_write32(wl, CFG_PLL_SYNC_CNT, 0x20); 131 wl1251_reg_write32(wl, CFG_PLL_SYNC_CNT, 0x20);
132 132
133 /* PG 1.2: read clock request time */ 133 /* PG 1.2: read clock request time */
134 init_data = wl12xx_reg_read32(wl, CLK_REQ_TIME); 134 init_data = wl1251_reg_read32(wl, CLK_REQ_TIME);
135 135
136 /* 136 /*
137 * PG 1.2: set the clock request time to be ref_clk_settling_time - 137 * PG 1.2: set the clock request time to be ref_clk_settling_time -
@@ -141,35 +141,35 @@ int wl12xx_boot_init_seq(struct wl12xx *wl)
141 tmp = init_data - 0x21; 141 tmp = init_data - 0x21;
142 else 142 else
143 tmp = 0; 143 tmp = 0;
144 wl12xx_reg_write32(wl, CLK_REQ_TIME, tmp); 144 wl1251_reg_write32(wl, CLK_REQ_TIME, tmp);
145 145
146 /* set BB PLL configurations in RF AFE */ 146 /* set BB PLL configurations in RF AFE */
147 wl12xx_reg_write32(wl, 0x003058cc, 0x4B5); 147 wl1251_reg_write32(wl, 0x003058cc, 0x4B5);
148 148
149 /* set RF_AFE_REG_5 */ 149 /* set RF_AFE_REG_5 */
150 wl12xx_reg_write32(wl, 0x003058d4, 0x50); 150 wl1251_reg_write32(wl, 0x003058d4, 0x50);
151 151
152 /* set RF_AFE_CTRL_REG_2 */ 152 /* set RF_AFE_CTRL_REG_2 */
153 wl12xx_reg_write32(wl, 0x00305948, 0x11c001); 153 wl1251_reg_write32(wl, 0x00305948, 0x11c001);
154 154
155 /* 155 /*
156 * change RF PLL and BB PLL divider for VCO clock and adjust VCO 156 * change RF PLL and BB PLL divider for VCO clock and adjust VCO
157 * bais current(RF_AFE_REG_13) 157 * bais current(RF_AFE_REG_13)
158 */ 158 */
159 wl12xx_reg_write32(wl, 0x003058f4, 0x1e); 159 wl1251_reg_write32(wl, 0x003058f4, 0x1e);
160 160
161 /* set BB PLL configurations */ 161 /* set BB PLL configurations */
162 tmp = LUT[ref_freq][LUT_PARAM_INTEGER_DIVIDER] | 0x00017000; 162 tmp = LUT[ref_freq][LUT_PARAM_INTEGER_DIVIDER] | 0x00017000;
163 wl12xx_reg_write32(wl, 0x00305840, tmp); 163 wl1251_reg_write32(wl, 0x00305840, tmp);
164 164
165 /* set fractional divider according to Appendix C-BB PLL 165 /* set fractional divider according to Appendix C-BB PLL
166 * Calculations 166 * Calculations
167 */ 167 */
168 tmp = LUT[ref_freq][LUT_PARAM_FRACTIONAL_DIVIDER]; 168 tmp = LUT[ref_freq][LUT_PARAM_FRACTIONAL_DIVIDER];
169 wl12xx_reg_write32(wl, 0x00305844, tmp); 169 wl1251_reg_write32(wl, 0x00305844, tmp);
170 170
171 /* set the initial data for the sigma delta */ 171 /* set the initial data for the sigma delta */
172 wl12xx_reg_write32(wl, 0x00305848, 0x3039); 172 wl1251_reg_write32(wl, 0x00305848, 0x3039);
173 173
174 /* 174 /*
175 * set the accumulator attenuation value, calibration loop1 175 * set the accumulator attenuation value, calibration loop1
@@ -178,14 +178,14 @@ int wl12xx_boot_init_seq(struct wl12xx *wl)
178 */ 178 */
179 tmp = (LUT[ref_freq][LUT_PARAM_ATTN_BB] << 16) | 179 tmp = (LUT[ref_freq][LUT_PARAM_ATTN_BB] << 16) |
180 (LUT[ref_freq][LUT_PARAM_ALPHA_BB] << 12) | 0x1; 180 (LUT[ref_freq][LUT_PARAM_ALPHA_BB] << 12) | 0x1;
181 wl12xx_reg_write32(wl, 0x00305854, tmp); 181 wl1251_reg_write32(wl, 0x00305854, tmp);
182 182
183 /* 183 /*
184 * set the calibration stop time after holdoff time expires and set 184 * set the calibration stop time after holdoff time expires and set
185 * settling time HOLD_OFF_TIME_BB 185 * settling time HOLD_OFF_TIME_BB
186 */ 186 */
187 tmp = LUT[ref_freq][LUT_PARAM_STOP_TIME_BB] | 0x000A0000; 187 tmp = LUT[ref_freq][LUT_PARAM_STOP_TIME_BB] | 0x000A0000;
188 wl12xx_reg_write32(wl, 0x00305858, tmp); 188 wl1251_reg_write32(wl, 0x00305858, tmp);
189 189
190 /* 190 /*
191 * set BB PLL Loop filter capacitor3- BB_C3[2:0] and set BB PLL 191 * set BB PLL Loop filter capacitor3- BB_C3[2:0] and set BB PLL
@@ -193,7 +193,7 @@ int wl12xx_boot_init_seq(struct wl12xx *wl)
193 * BB_ILOOPF[7:3] 193 * BB_ILOOPF[7:3]
194 */ 194 */
195 tmp = LUT[ref_freq][LUT_PARAM_BB_PLL_LOOP_FILTER] | 0x00000030; 195 tmp = LUT[ref_freq][LUT_PARAM_BB_PLL_LOOP_FILTER] | 0x00000030;
196 wl12xx_reg_write32(wl, 0x003058f8, tmp); 196 wl1251_reg_write32(wl, 0x003058f8, tmp);
197 197
198 /* 198 /*
199 * set regulator output voltage for n divider to 199 * set regulator output voltage for n divider to
@@ -201,10 +201,10 @@ int wl12xx_boot_init_seq(struct wl12xx *wl)
201 * set BB PLL Loop filter capacitor2- BB_C2[7:5], set gain of BB 201 * set BB PLL Loop filter capacitor2- BB_C2[7:5], set gain of BB
202 * PLL auto-call to normal mode- BB_CALGAIN_3DB[8] 202 * PLL auto-call to normal mode- BB_CALGAIN_3DB[8]
203 */ 203 */
204 wl12xx_reg_write32(wl, 0x003058f0, 0x29); 204 wl1251_reg_write32(wl, 0x003058f0, 0x29);
205 205
206 /* enable restart wakeup sequence (ELP_CMD[0]) */ 206 /* enable restart wakeup sequence (ELP_CMD[0]) */
207 wl12xx_reg_write32(wl, ELP_CMD, elp_cmd | 0x1); 207 wl1251_reg_write32(wl, ELP_CMD, elp_cmd | 0x1);
208 208
209 /* restart sequence completed */ 209 /* restart sequence completed */
210 udelay(2000); 210 udelay(2000);
@@ -212,19 +212,19 @@ int wl12xx_boot_init_seq(struct wl12xx *wl)
212 return 0; 212 return 0;
213} 213}
214 214
215int wl12xx_boot_run_firmware(struct wl12xx *wl) 215int wl1251_boot_run_firmware(struct wl1251 *wl)
216{ 216{
217 int loop, ret; 217 int loop, ret;
218 u32 chip_id, interrupt; 218 u32 chip_id, interrupt;
219 219
220 wl->chip.op_set_ecpu_ctrl(wl, ECPU_CONTROL_HALT); 220 wl->chip.op_set_ecpu_ctrl(wl, ECPU_CONTROL_HALT);
221 221
222 chip_id = wl12xx_reg_read32(wl, CHIP_ID_B); 222 chip_id = wl1251_reg_read32(wl, CHIP_ID_B);
223 223
224 wl12xx_debug(DEBUG_BOOT, "chip id after firmware boot: 0x%x", chip_id); 224 wl1251_debug(DEBUG_BOOT, "chip id after firmware boot: 0x%x", chip_id);
225 225
226 if (chip_id != wl->chip.id) { 226 if (chip_id != wl->chip.id) {
227 wl12xx_error("chip id doesn't match after firmware boot"); 227 wl1251_error("chip id doesn't match after firmware boot");
228 return -EIO; 228 return -EIO;
229 } 229 }
230 230
@@ -232,63 +232,65 @@ int wl12xx_boot_run_firmware(struct wl12xx *wl)
232 loop = 0; 232 loop = 0;
233 while (loop++ < INIT_LOOP) { 233 while (loop++ < INIT_LOOP) {
234 udelay(INIT_LOOP_DELAY); 234 udelay(INIT_LOOP_DELAY);
235 interrupt = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); 235 interrupt = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);
236 236
237 if (interrupt == 0xffffffff) { 237 if (interrupt == 0xffffffff) {
238 wl12xx_error("error reading hardware complete " 238 wl1251_error("error reading hardware complete "
239 "init indication"); 239 "init indication");
240 return -EIO; 240 return -EIO;
241 } 241 }
242 /* check that ACX_INTR_INIT_COMPLETE is enabled */ 242 /* check that ACX_INTR_INIT_COMPLETE is enabled */
243 else if (interrupt & wl->chip.intr_init_complete) { 243 else if (interrupt & wl->chip.intr_init_complete) {
244 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_ACK, 244 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_ACK,
245 wl->chip.intr_init_complete); 245 wl->chip.intr_init_complete);
246 break; 246 break;
247 } 247 }
248 } 248 }
249 249
250 if (loop >= INIT_LOOP) { 250 if (loop >= INIT_LOOP) {
251 wl12xx_error("timeout waiting for the hardware to " 251 wl1251_error("timeout waiting for the hardware to "
252 "complete initialization"); 252 "complete initialization");
253 return -EIO; 253 return -EIO;
254 } 254 }
255 255
256 /* get hardware config command mail box */ 256 /* get hardware config command mail box */
257 wl->cmd_box_addr = wl12xx_reg_read32(wl, REG_COMMAND_MAILBOX_PTR); 257 wl->cmd_box_addr = wl1251_reg_read32(wl, REG_COMMAND_MAILBOX_PTR);
258 258
259 /* get hardware config event mail box */ 259 /* get hardware config event mail box */
260 wl->event_box_addr = wl12xx_reg_read32(wl, REG_EVENT_MAILBOX_PTR); 260 wl->event_box_addr = wl1251_reg_read32(wl, REG_EVENT_MAILBOX_PTR);
261 261
262 /* set the working partition to its "running" mode offset */ 262 /* set the working partition to its "running" mode offset */
263 wl12xx_set_partition(wl, 263 wl1251_set_partition(wl,
264 wl->chip.p_table[PART_WORK].mem.start, 264 wl->chip.p_table[PART_WORK].mem.start,
265 wl->chip.p_table[PART_WORK].mem.size, 265 wl->chip.p_table[PART_WORK].mem.size,
266 wl->chip.p_table[PART_WORK].reg.start, 266 wl->chip.p_table[PART_WORK].reg.start,
267 wl->chip.p_table[PART_WORK].reg.size); 267 wl->chip.p_table[PART_WORK].reg.size);
268 268
269 wl12xx_debug(DEBUG_MAILBOX, "cmd_box_addr 0x%x event_box_addr 0x%x", 269 wl1251_debug(DEBUG_MAILBOX, "cmd_box_addr 0x%x event_box_addr 0x%x",
270 wl->cmd_box_addr, wl->event_box_addr); 270 wl->cmd_box_addr, wl->event_box_addr);
271 271
272 wl->chip.op_fw_version(wl);
273
272 /* 274 /*
273 * in case of full asynchronous mode the firmware event must be 275 * in case of full asynchronous mode the firmware event must be
274 * ready to receive event from the command mailbox 276 * ready to receive event from the command mailbox
275 */ 277 */
276 278
277 /* enable gpio interrupts */ 279 /* enable gpio interrupts */
278 wl12xx_boot_enable_interrupts(wl); 280 wl1251_boot_enable_interrupts(wl);
279 281
280 wl->chip.op_target_enable_interrupts(wl); 282 wl->chip.op_target_enable_interrupts(wl);
281 283
282 /* unmask all mbox events */ 284 /* unmask all mbox events */
283 wl->event_mask = 0xffffffff; 285 wl->event_mask = 0xffffffff;
284 286
285 ret = wl12xx_event_unmask(wl); 287 ret = wl1251_event_unmask(wl);
286 if (ret < 0) { 288 if (ret < 0) {
287 wl12xx_error("EVENT mask setting failed"); 289 wl1251_error("EVENT mask setting failed");
288 return ret; 290 return ret;
289 } 291 }
290 292
291 wl12xx_event_mbox_config(wl); 293 wl1251_event_mbox_config(wl);
292 294
293 /* firmware startup completed */ 295 /* firmware startup completed */
294 return 0; 296 return 0;
diff --git a/drivers/net/wireless/wl12xx/boot.h b/drivers/net/wireless/wl12xx/wl1251_boot.h
index 4fa73132baae..798362d71e3f 100644
--- a/drivers/net/wireless/wl12xx/boot.h
+++ b/drivers/net/wireless/wl12xx/wl1251_boot.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
@@ -24,12 +24,12 @@
24#ifndef __BOOT_H__ 24#ifndef __BOOT_H__
25#define __BOOT_H__ 25#define __BOOT_H__
26 26
27#include "wl12xx.h" 27#include "wl1251.h"
28 28
29int wl12xx_boot_soft_reset(struct wl12xx *wl); 29int wl1251_boot_soft_reset(struct wl1251 *wl);
30int wl12xx_boot_init_seq(struct wl12xx *wl); 30int wl1251_boot_init_seq(struct wl1251 *wl);
31int wl12xx_boot_run_firmware(struct wl12xx *wl); 31int wl1251_boot_run_firmware(struct wl1251 *wl);
32void wl12xx_boot_target_enable_interrupts(struct wl12xx *wl); 32void wl1251_boot_target_enable_interrupts(struct wl1251 *wl);
33 33
34/* number of times we try to read the INIT interrupt */ 34/* number of times we try to read the INIT interrupt */
35#define INIT_LOOP 20000 35#define INIT_LOOP 20000
diff --git a/drivers/net/wireless/wl12xx/wl1251_cmd.c b/drivers/net/wireless/wl12xx/wl1251_cmd.c
new file mode 100644
index 000000000000..dc04d1fc2ee4
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl1251_cmd.c
@@ -0,0 +1,428 @@
1#include "wl1251_cmd.h"
2
3#include <linux/module.h>
4#include <linux/crc7.h>
5#include <linux/spi/spi.h>
6
7#include "wl1251.h"
8#include "reg.h"
9#include "wl1251_spi.h"
10#include "wl1251_ps.h"
11#include "wl1251_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 */
21int 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_spi_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 & wl->chip.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 wl->chip.intr_cmd_complete);
55
56out:
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 */
68int 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_spi_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 */
109int 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_spi_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
135out:
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 */
147int 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
168int 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
201out:
202 kfree(vbm);
203 return 0;
204}
205
206int 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
250out:
251 kfree(cmd);
252 return ret;
253}
254
255int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 dtim_interval,
256 u16 beacon_interval, u8 wait)
257{
258 unsigned long timeout;
259 struct cmd_join *join;
260 int ret, i;
261 u8 *bssid;
262
263 join = kzalloc(sizeof(*join), GFP_KERNEL);
264 if (!join) {
265 ret = -ENOMEM;
266 goto out;
267 }
268
269 /* FIXME: this should be in main.c */
270 ret = wl1251_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE,
271 DEFAULT_HW_GEN_MODULATION_TYPE,
272 wl->tx_mgmt_frm_rate,
273 wl->tx_mgmt_frm_mod);
274 if (ret < 0)
275 goto out;
276
277 wl1251_debug(DEBUG_CMD, "cmd join");
278
279 /* Reverse order BSSID */
280 bssid = (u8 *) &join->bssid_lsb;
281 for (i = 0; i < ETH_ALEN; i++)
282 bssid[i] = wl->bssid[ETH_ALEN - i - 1];
283
284 join->rx_config_options = wl->rx_config;
285 join->rx_filter_options = wl->rx_filter;
286
287 join->basic_rate_set = RATE_MASK_1MBPS | RATE_MASK_2MBPS |
288 RATE_MASK_5_5MBPS | RATE_MASK_11MBPS;
289
290 join->beacon_interval = beacon_interval;
291 join->dtim_interval = dtim_interval;
292 join->bss_type = bss_type;
293 join->channel = wl->channel;
294 join->ctrl = JOIN_CMD_CTRL_TX_FLUSH;
295
296 ret = wl1251_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join));
297 if (ret < 0) {
298 wl1251_error("failed to initiate cmd join");
299 goto out;
300 }
301
302 timeout = msecs_to_jiffies(JOIN_TIMEOUT);
303
304 /*
305 * ugly hack: we should wait for JOIN_EVENT_COMPLETE_ID but to
306 * simplify locking we just sleep instead, for now
307 */
308 if (wait)
309 msleep(10);
310
311out:
312 kfree(join);
313 return ret;
314}
315
316int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode)
317{
318 struct wl1251_cmd_ps_params *ps_params = NULL;
319 int ret = 0;
320
321 /* FIXME: this should be in ps.c */
322 ret = wl1251_acx_wake_up_conditions(wl, WAKE_UP_EVENT_DTIM_BITMAP,
323 wl->listen_int);
324 if (ret < 0) {
325 wl1251_error("couldn't set wake up conditions");
326 goto out;
327 }
328
329 wl1251_debug(DEBUG_CMD, "cmd set ps mode");
330
331 ps_params = kzalloc(sizeof(*ps_params), GFP_KERNEL);
332 if (!ps_params) {
333 ret = -ENOMEM;
334 goto out;
335 }
336
337 ps_params->ps_mode = ps_mode;
338 ps_params->send_null_data = 1;
339 ps_params->retries = 5;
340 ps_params->hang_over_period = 128;
341 ps_params->null_data_rate = 1; /* 1 Mbps */
342
343 ret = wl1251_cmd_send(wl, CMD_SET_PS_MODE, ps_params,
344 sizeof(*ps_params));
345 if (ret < 0) {
346 wl1251_error("cmd set_ps_mode failed");
347 goto out;
348 }
349
350out:
351 kfree(ps_params);
352 return ret;
353}
354
355int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
356 size_t len)
357{
358 struct cmd_read_write_memory *cmd;
359 int ret = 0;
360
361 wl1251_debug(DEBUG_CMD, "cmd read memory");
362
363 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
364 if (!cmd) {
365 ret = -ENOMEM;
366 goto out;
367 }
368
369 WARN_ON(len > MAX_READ_SIZE);
370 len = min_t(size_t, len, MAX_READ_SIZE);
371
372 cmd->addr = addr;
373 cmd->size = len;
374
375 ret = wl1251_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd));
376 if (ret < 0) {
377 wl1251_error("read memory command failed: %d", ret);
378 goto out;
379 }
380
381 /* the read command got in, we can now read the answer */
382 wl1251_spi_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd));
383
384 if (cmd->header.status != CMD_STATUS_SUCCESS)
385 wl1251_error("error in read command result: %d",
386 cmd->header.status);
387
388 memcpy(answer, cmd->value, len);
389
390out:
391 kfree(cmd);
392 return ret;
393}
394
395int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
396 void *buf, size_t buf_len)
397{
398 struct wl1251_cmd_packet_template *cmd;
399 size_t cmd_len;
400 int ret = 0;
401
402 wl1251_debug(DEBUG_CMD, "cmd template %d", cmd_id);
403
404 WARN_ON(buf_len > WL1251_MAX_TEMPLATE_SIZE);
405 buf_len = min_t(size_t, buf_len, WL1251_MAX_TEMPLATE_SIZE);
406 cmd_len = ALIGN(sizeof(*cmd) + buf_len, 4);
407
408 cmd = kzalloc(cmd_len, GFP_KERNEL);
409 if (!cmd) {
410 ret = -ENOMEM;
411 goto out;
412 }
413
414 cmd->size = cpu_to_le16(buf_len);
415
416 if (buf)
417 memcpy(cmd->data, buf, buf_len);
418
419 ret = wl1251_cmd_send(wl, cmd_id, cmd, cmd_len);
420 if (ret < 0) {
421 wl1251_warning("cmd set_template failed: %d", ret);
422 goto out;
423 }
424
425out:
426 kfree(cmd);
427 return ret;
428}
diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/wl1251_cmd.h
index aa307dcd081f..64f228dd9a9b 100644
--- a/drivers/net/wireless/wl12xx/cmd.h
+++ b/drivers/net/wireless/wl12xx/wl1251_cmd.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -22,37 +22,32 @@
22 * 22 *
23 */ 23 */
24 24
25#ifndef __WL12XX_CMD_H__ 25#ifndef __WL1251_CMD_H__
26#define __WL12XX_CMD_H__ 26#define __WL1251_CMD_H__
27 27
28#include "wl12xx.h" 28#include "wl1251.h"
29 29
30int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len); 30struct acx_header;
31int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer); 31
32int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 ie_id, u16 ie_len, 32int wl1251_cmd_send(struct wl1251 *wl, u16 type, void *buf, size_t buf_len);
33 void *answer); 33int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer);
34int wl12xx_cmd_configure(struct wl12xx *wl, void *ie, int ie_len); 34int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len);
35int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity, 35int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len);
36int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity,
36 void *bitmap, u16 bitmap_len, u8 bitmap_control); 37 void *bitmap, u16 bitmap_len, u8 bitmap_control);
37int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, u8 enable); 38int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable);
38int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval, 39int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 dtim_interval,
39 u16 beacon_interval, u8 wait); 40 u16 beacon_interval, u8 wait);
40int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode); 41int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode);
41int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, u32 len, void *answer); 42int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer,
42int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id, 43 size_t len);
44int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
43 void *buf, size_t buf_len); 45 void *buf, size_t buf_len);
44 46
45/* unit ms */ 47/* unit ms */
46#define WL12XX_COMMAND_TIMEOUT 2000 48#define WL1251_COMMAND_TIMEOUT 2000
47
48#define WL12XX_MAX_TEMPLATE_SIZE 300
49 49
50struct wl12xx_cmd_packet_template { 50enum wl1251_commands {
51 __le16 size;
52 u8 template[WL12XX_MAX_TEMPLATE_SIZE];
53} __attribute__ ((packed));
54
55enum wl12xx_commands {
56 CMD_RESET = 0, 51 CMD_RESET = 0,
57 CMD_INTERROGATE = 1, /*use this to read information elements*/ 52 CMD_INTERROGATE = 1, /*use this to read information elements*/
58 CMD_CONFIGURE = 2, /*use this to write information elements*/ 53 CMD_CONFIGURE = 2, /*use this to write information elements*/
@@ -100,9 +95,15 @@ enum wl12xx_commands {
100 95
101#define MAX_CMD_PARAMS 572 96#define MAX_CMD_PARAMS 572
102 97
103struct wl12xx_command { 98struct wl1251_cmd_header {
104 u16 id; 99 u16 id;
105 u16 status; 100 u16 status;
101 /* payload */
102 u8 data[0];
103} __attribute__ ((packed));
104
105struct wl1251_command {
106 struct wl1251_cmd_header header;
106 u8 parameters[MAX_CMD_PARAMS]; 107 u8 parameters[MAX_CMD_PARAMS];
107}; 108};
108 109
@@ -144,6 +145,8 @@ enum {
144#define MAX_READ_SIZE 256 145#define MAX_READ_SIZE 256
145 146
146struct cmd_read_write_memory { 147struct cmd_read_write_memory {
148 struct wl1251_cmd_header header;
149
147 /* The address of the memory to read from or write to.*/ 150 /* The address of the memory to read from or write to.*/
148 u32 addr; 151 u32 addr;
149 152
@@ -211,6 +214,8 @@ struct basic_scan_channel_parameters {
211#define SCAN_MAX_NUM_OF_CHANNELS 16 214#define SCAN_MAX_NUM_OF_CHANNELS 16
212 215
213struct cmd_scan { 216struct cmd_scan {
217 struct wl1251_cmd_header header;
218
214 struct basic_scan_parameters params; 219 struct basic_scan_parameters params;
215 struct basic_scan_channel_parameters channels[SCAN_MAX_NUM_OF_CHANNELS]; 220 struct basic_scan_channel_parameters channels[SCAN_MAX_NUM_OF_CHANNELS];
216} __attribute__ ((packed)); 221} __attribute__ ((packed));
@@ -227,6 +232,8 @@ enum {
227 232
228 233
229struct cmd_join { 234struct cmd_join {
235 struct wl1251_cmd_header header;
236
230 u32 bssid_lsb; 237 u32 bssid_lsb;
231 u16 bssid_msb; 238 u16 bssid_msb;
232 u16 beacon_interval; /* in TBTTs */ 239 u16 beacon_interval; /* in TBTTs */
@@ -261,5 +268,140 @@ struct cmd_join {
261 u8 reserved; 268 u8 reserved;
262} __attribute__ ((packed)); 269} __attribute__ ((packed));
263 270
271struct cmd_enabledisable_path {
272 struct wl1251_cmd_header header;
273
274 u8 channel;
275 u8 padding[3];
276} __attribute__ ((packed));
277
278#define WL1251_MAX_TEMPLATE_SIZE 300
279
280struct wl1251_cmd_packet_template {
281 struct wl1251_cmd_header header;
282
283 __le16 size;
284 u8 data[0];
285} __attribute__ ((packed));
286
287#define TIM_ELE_ID 5
288#define PARTIAL_VBM_MAX 251
289
290struct wl1251_tim {
291 u8 identity;
292 u8 length;
293 u8 dtim_count;
294 u8 dtim_period;
295 u8 bitmap_ctrl;
296 u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */
297} __attribute__ ((packed));
298
299/* Virtual Bit Map update */
300struct wl1251_cmd_vbm_update {
301 struct wl1251_cmd_header header;
302 __le16 len;
303 u8 padding[2];
304 struct wl1251_tim tim;
305} __attribute__ ((packed));
306
307enum wl1251_cmd_ps_mode {
308 STATION_ACTIVE_MODE,
309 STATION_POWER_SAVE_MODE
310};
311
312struct wl1251_cmd_ps_params {
313 struct wl1251_cmd_header header;
314
315 u8 ps_mode; /* STATION_* */
316 u8 send_null_data; /* Do we have to send NULL data packet ? */
317 u8 retries; /* Number of retires for the initial NULL data packet */
318
319 /*
320 * TUs during which the target stays awake after switching
321 * to power save mode.
322 */
323 u8 hang_over_period;
324 u16 null_data_rate;
325 u8 pad[2];
326} __attribute__ ((packed));
327
328struct wl1251_cmd_trigger_scan_to {
329 struct wl1251_cmd_header header;
330
331 u32 timeout;
332};
333
334/* HW encryption keys */
335#define NUM_ACCESS_CATEGORIES_COPY 4
336#define MAX_KEY_SIZE 32
337
338/* When set, disable HW encryption */
339#define DF_ENCRYPTION_DISABLE 0x01
340/* When set, disable HW decryption */
341#define DF_SNIFF_MODE_ENABLE 0x80
342
343enum wl1251_cmd_key_action {
344 KEY_ADD_OR_REPLACE = 1,
345 KEY_REMOVE = 2,
346 KEY_SET_ID = 3,
347 MAX_KEY_ACTION = 0xffff,
348};
349
350enum wl1251_cmd_key_type {
351 KEY_WEP_DEFAULT = 0,
352 KEY_WEP_ADDR = 1,
353 KEY_AES_GROUP = 4,
354 KEY_AES_PAIRWISE = 5,
355 KEY_WEP_GROUP = 6,
356 KEY_TKIP_MIC_GROUP = 10,
357 KEY_TKIP_MIC_PAIRWISE = 11,
358};
359
360/*
361 *
362 * key_type_e key size key format
363 * ---------- --------- ----------
364 * 0x00 5, 13, 29 Key data
365 * 0x01 5, 13, 29 Key data
366 * 0x04 16 16 bytes of key data
367 * 0x05 16 16 bytes of key data
368 * 0x0a 32 16 bytes of TKIP key data
369 * 8 bytes of RX MIC key data
370 * 8 bytes of TX MIC key data
371 * 0x0b 32 16 bytes of TKIP key data
372 * 8 bytes of RX MIC key data
373 * 8 bytes of TX MIC key data
374 *
375 */
376
377struct wl1251_cmd_set_keys {
378 struct wl1251_cmd_header header;
379
380 /* Ignored for default WEP key */
381 u8 addr[ETH_ALEN];
382
383 /* key_action_e */
384 u16 key_action;
385
386 u16 reserved_1;
387
388 /* key size in bytes */
389 u8 key_size;
390
391 /* key_type_e */
392 u8 key_type;
393 u8 ssid_profile;
394
395 /*
396 * TKIP, AES: frame's key id field.
397 * For WEP default key: key id;
398 */
399 u8 id;
400 u8 reserved_2[6];
401 u8 key[MAX_KEY_SIZE];
402 u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY];
403 u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY];
404} __attribute__ ((packed));
405
264 406
265#endif /* __WL12XX_CMD_H__ */ 407#endif /* __WL1251_CMD_H__ */
diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
index cdb368ce4dae..a00723059f83 100644
--- a/drivers/net/wireless/wl12xx/debugfs.c
+++ b/drivers/net/wireless/wl12xx/wl1251_debugfs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2009 Nokia Corporation
5 * 5 *
@@ -21,15 +21,16 @@
21 * 21 *
22 */ 22 */
23 23
24#include "debugfs.h" 24#include "wl1251_debugfs.h"
25 25
26#include <linux/skbuff.h> 26#include <linux/skbuff.h>
27 27
28#include "wl12xx.h" 28#include "wl1251.h"
29#include "acx.h" 29#include "wl1251_acx.h"
30#include "wl1251_ps.h"
30 31
31/* ms */ 32/* ms */
32#define WL12XX_DEBUGFS_STATS_LIFETIME 1000 33#define WL1251_DEBUGFS_STATS_LIFETIME 1000
33 34
34/* debugfs macros idea from mac80211 */ 35/* debugfs macros idea from mac80211 */
35 36
@@ -37,7 +38,7 @@
37static ssize_t name## _read(struct file *file, char __user *userbuf, \ 38static ssize_t name## _read(struct file *file, char __user *userbuf, \
38 size_t count, loff_t *ppos) \ 39 size_t count, loff_t *ppos) \
39{ \ 40{ \
40 struct wl12xx *wl = file->private_data; \ 41 struct wl1251 *wl = file->private_data; \
41 char buf[buflen]; \ 42 char buf[buflen]; \
42 int res; \ 43 int res; \
43 \ 44 \
@@ -47,7 +48,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \
47 \ 48 \
48static const struct file_operations name## _ops = { \ 49static const struct file_operations name## _ops = { \
49 .read = name## _read, \ 50 .read = name## _read, \
50 .open = wl12xx_open_file_generic, \ 51 .open = wl1251_open_file_generic, \
51}; 52};
52 53
53#define DEBUGFS_ADD(name, parent) \ 54#define DEBUGFS_ADD(name, parent) \
@@ -70,11 +71,11 @@ static ssize_t sub## _ ##name## _read(struct file *file, \
70 char __user *userbuf, \ 71 char __user *userbuf, \
71 size_t count, loff_t *ppos) \ 72 size_t count, loff_t *ppos) \
72{ \ 73{ \
73 struct wl12xx *wl = file->private_data; \ 74 struct wl1251 *wl = file->private_data; \
74 char buf[buflen]; \ 75 char buf[buflen]; \
75 int res; \ 76 int res; \
76 \ 77 \
77 wl12xx_debugfs_update_stats(wl); \ 78 wl1251_debugfs_update_stats(wl); \
78 \ 79 \
79 res = scnprintf(buf, buflen, fmt "\n", \ 80 res = scnprintf(buf, buflen, fmt "\n", \
80 wl->stats.fw_stats->sub.name); \ 81 wl->stats.fw_stats->sub.name); \
@@ -83,7 +84,7 @@ static ssize_t sub## _ ##name## _read(struct file *file, \
83 \ 84 \
84static const struct file_operations sub## _ ##name## _ops = { \ 85static const struct file_operations sub## _ ##name## _ops = { \
85 .read = sub## _ ##name## _read, \ 86 .read = sub## _ ##name## _read, \
86 .open = wl12xx_open_file_generic, \ 87 .open = wl1251_open_file_generic, \
87}; 88};
88 89
89#define DEBUGFS_FWSTATS_ADD(sub, name) \ 90#define DEBUGFS_FWSTATS_ADD(sub, name) \
@@ -92,21 +93,30 @@ static const struct file_operations sub## _ ##name## _ops = { \
92#define DEBUGFS_FWSTATS_DEL(sub, name) \ 93#define DEBUGFS_FWSTATS_DEL(sub, name) \
93 DEBUGFS_DEL(sub## _ ##name) 94 DEBUGFS_DEL(sub## _ ##name)
94 95
95static void wl12xx_debugfs_update_stats(struct wl12xx *wl) 96static void wl1251_debugfs_update_stats(struct wl1251 *wl)
96{ 97{
98 int ret;
99
97 mutex_lock(&wl->mutex); 100 mutex_lock(&wl->mutex);
98 101
99 if (wl->state == WL12XX_STATE_ON && 102 ret = wl1251_ps_elp_wakeup(wl);
103 if (ret < 0)
104 goto out;
105
106 if (wl->state == WL1251_STATE_ON &&
100 time_after(jiffies, wl->stats.fw_stats_update + 107 time_after(jiffies, wl->stats.fw_stats_update +
101 msecs_to_jiffies(WL12XX_DEBUGFS_STATS_LIFETIME))) { 108 msecs_to_jiffies(WL1251_DEBUGFS_STATS_LIFETIME))) {
102 wl12xx_acx_statistics(wl, wl->stats.fw_stats); 109 wl1251_acx_statistics(wl, wl->stats.fw_stats);
103 wl->stats.fw_stats_update = jiffies; 110 wl->stats.fw_stats_update = jiffies;
104 } 111 }
105 112
113 wl1251_ps_elp_sleep(wl);
114
115out:
106 mutex_unlock(&wl->mutex); 116 mutex_unlock(&wl->mutex);
107} 117}
108 118
109static int wl12xx_open_file_generic(struct inode *inode, struct file *file) 119static int wl1251_open_file_generic(struct inode *inode, struct file *file)
110{ 120{
111 file->private_data = inode->i_private; 121 file->private_data = inode->i_private;
112 return 0; 122 return 0;
@@ -211,7 +221,7 @@ DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u",
211static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, 221static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
212 size_t count, loff_t *ppos) 222 size_t count, loff_t *ppos)
213{ 223{
214 struct wl12xx *wl = file->private_data; 224 struct wl1251 *wl = file->private_data;
215 u32 queue_len; 225 u32 queue_len;
216 char buf[20]; 226 char buf[20];
217 int res; 227 int res;
@@ -224,10 +234,10 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
224 234
225static const struct file_operations tx_queue_len_ops = { 235static const struct file_operations tx_queue_len_ops = {
226 .read = tx_queue_len_read, 236 .read = tx_queue_len_read,
227 .open = wl12xx_open_file_generic, 237 .open = wl1251_open_file_generic,
228}; 238};
229 239
230static void wl12xx_debugfs_delete_files(struct wl12xx *wl) 240static void wl1251_debugfs_delete_files(struct wl1251 *wl)
231{ 241{
232 DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow); 242 DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow);
233 243
@@ -325,7 +335,7 @@ static void wl12xx_debugfs_delete_files(struct wl12xx *wl)
325 DEBUGFS_DEL(excessive_retries); 335 DEBUGFS_DEL(excessive_retries);
326} 336}
327 337
328static int wl12xx_debugfs_add_files(struct wl12xx *wl) 338static int wl1251_debugfs_add_files(struct wl1251 *wl)
329{ 339{
330 int ret = 0; 340 int ret = 0;
331 341
@@ -426,19 +436,19 @@ static int wl12xx_debugfs_add_files(struct wl12xx *wl)
426 436
427out: 437out:
428 if (ret < 0) 438 if (ret < 0)
429 wl12xx_debugfs_delete_files(wl); 439 wl1251_debugfs_delete_files(wl);
430 440
431 return ret; 441 return ret;
432} 442}
433 443
434void wl12xx_debugfs_reset(struct wl12xx *wl) 444void wl1251_debugfs_reset(struct wl1251 *wl)
435{ 445{
436 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); 446 memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats));
437 wl->stats.retry_count = 0; 447 wl->stats.retry_count = 0;
438 wl->stats.excessive_retries = 0; 448 wl->stats.excessive_retries = 0;
439} 449}
440 450
441int wl12xx_debugfs_init(struct wl12xx *wl) 451int wl1251_debugfs_init(struct wl1251 *wl)
442{ 452{
443 int ret; 453 int ret;
444 454
@@ -469,7 +479,7 @@ int wl12xx_debugfs_init(struct wl12xx *wl)
469 479
470 wl->stats.fw_stats_update = jiffies; 480 wl->stats.fw_stats_update = jiffies;
471 481
472 ret = wl12xx_debugfs_add_files(wl); 482 ret = wl1251_debugfs_add_files(wl);
473 483
474 if (ret < 0) 484 if (ret < 0)
475 goto err_file; 485 goto err_file;
@@ -492,9 +502,9 @@ err:
492 return ret; 502 return ret;
493} 503}
494 504
495void wl12xx_debugfs_exit(struct wl12xx *wl) 505void wl1251_debugfs_exit(struct wl1251 *wl)
496{ 506{
497 wl12xx_debugfs_delete_files(wl); 507 wl1251_debugfs_delete_files(wl);
498 508
499 kfree(wl->stats.fw_stats); 509 kfree(wl->stats.fw_stats);
500 wl->stats.fw_stats = NULL; 510 wl->stats.fw_stats = NULL;
diff --git a/drivers/net/wireless/wl12xx/debugfs.h b/drivers/net/wireless/wl12xx/wl1251_debugfs.h
index 562cdcbcc874..6dc3d080853c 100644
--- a/drivers/net/wireless/wl12xx/debugfs.h
+++ b/drivers/net/wireless/wl12xx/wl1251_debugfs.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2009 Nokia Corporation
5 * 5 *
@@ -21,13 +21,13 @@
21 * 21 *
22 */ 22 */
23 23
24#ifndef WL12XX_DEBUGFS_H 24#ifndef WL1251_DEBUGFS_H
25#define WL12XX_DEBUGFS_H 25#define WL1251_DEBUGFS_H
26 26
27#include "wl12xx.h" 27#include "wl1251.h"
28 28
29int wl12xx_debugfs_init(struct wl12xx *wl); 29int wl1251_debugfs_init(struct wl1251 *wl);
30void wl12xx_debugfs_exit(struct wl12xx *wl); 30void wl1251_debugfs_exit(struct wl1251 *wl);
31void wl12xx_debugfs_reset(struct wl12xx *wl); 31void wl1251_debugfs_reset(struct wl1251 *wl);
32 32
33#endif /* WL12XX_DEBUGFS_H */ 33#endif /* WL1251_DEBUGFS_H */
diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/wl1251_event.c
index 99529ca89a7e..1a0a0bc1a31f 100644
--- a/drivers/net/wireless/wl12xx/event.c
+++ b/drivers/net/wireless/wl12xx/wl1251_event.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -22,16 +22,16 @@
22 * 22 *
23 */ 23 */
24 24
25#include "wl12xx.h" 25#include "wl1251.h"
26#include "reg.h" 26#include "reg.h"
27#include "spi.h" 27#include "wl1251_spi.h"
28#include "event.h" 28#include "wl1251_event.h"
29#include "ps.h" 29#include "wl1251_ps.h"
30 30
31static int wl12xx_event_scan_complete(struct wl12xx *wl, 31static int wl1251_event_scan_complete(struct wl1251 *wl,
32 struct event_mailbox *mbox) 32 struct event_mailbox *mbox)
33{ 33{
34 wl12xx_debug(DEBUG_EVENT, "status: 0x%x, channels: %d", 34 wl1251_debug(DEBUG_EVENT, "status: 0x%x, channels: %d",
35 mbox->scheduled_scan_status, 35 mbox->scheduled_scan_status,
36 mbox->scheduled_scan_channels); 36 mbox->scheduled_scan_channels);
37 37
@@ -45,34 +45,34 @@ static int wl12xx_event_scan_complete(struct wl12xx *wl,
45 return 0; 45 return 0;
46} 46}
47 47
48static void wl12xx_event_mbox_dump(struct event_mailbox *mbox) 48static void wl1251_event_mbox_dump(struct event_mailbox *mbox)
49{ 49{
50 wl12xx_debug(DEBUG_EVENT, "MBOX DUMP:"); 50 wl1251_debug(DEBUG_EVENT, "MBOX DUMP:");
51 wl12xx_debug(DEBUG_EVENT, "\tvector: 0x%x", mbox->events_vector); 51 wl1251_debug(DEBUG_EVENT, "\tvector: 0x%x", mbox->events_vector);
52 wl12xx_debug(DEBUG_EVENT, "\tmask: 0x%x", mbox->events_mask); 52 wl1251_debug(DEBUG_EVENT, "\tmask: 0x%x", mbox->events_mask);
53} 53}
54 54
55static int wl12xx_event_process(struct wl12xx *wl, struct event_mailbox *mbox) 55static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox)
56{ 56{
57 int ret; 57 int ret;
58 u32 vector; 58 u32 vector;
59 59
60 wl12xx_event_mbox_dump(mbox); 60 wl1251_event_mbox_dump(mbox);
61 61
62 vector = mbox->events_vector & ~(mbox->events_mask); 62 vector = mbox->events_vector & ~(mbox->events_mask);
63 wl12xx_debug(DEBUG_EVENT, "vector: 0x%x", vector); 63 wl1251_debug(DEBUG_EVENT, "vector: 0x%x", vector);
64 64
65 if (vector & SCAN_COMPLETE_EVENT_ID) { 65 if (vector & SCAN_COMPLETE_EVENT_ID) {
66 ret = wl12xx_event_scan_complete(wl, mbox); 66 ret = wl1251_event_scan_complete(wl, mbox);
67 if (ret < 0) 67 if (ret < 0)
68 return ret; 68 return ret;
69 } 69 }
70 70
71 if (vector & BSS_LOSE_EVENT_ID) { 71 if (vector & BSS_LOSE_EVENT_ID) {
72 wl12xx_debug(DEBUG_EVENT, "BSS_LOSE_EVENT"); 72 wl1251_debug(DEBUG_EVENT, "BSS_LOSE_EVENT");
73 73
74 if (wl->psm_requested && wl->psm) { 74 if (wl->psm_requested && wl->psm) {
75 ret = wl12xx_ps_set_mode(wl, STATION_ACTIVE_MODE); 75 ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE);
76 if (ret < 0) 76 if (ret < 0)
77 return ret; 77 return ret;
78 } 78 }
@@ -81,47 +81,47 @@ static int wl12xx_event_process(struct wl12xx *wl, struct event_mailbox *mbox)
81 return 0; 81 return 0;
82} 82}
83 83
84int wl12xx_event_unmask(struct wl12xx *wl) 84int wl1251_event_unmask(struct wl1251 *wl)
85{ 85{
86 int ret; 86 int ret;
87 87
88 ret = wl12xx_acx_event_mbox_mask(wl, ~(wl->event_mask)); 88 ret = wl1251_acx_event_mbox_mask(wl, ~(wl->event_mask));
89 if (ret < 0) 89 if (ret < 0)
90 return ret; 90 return ret;
91 91
92 return 0; 92 return 0;
93} 93}
94 94
95void wl12xx_event_mbox_config(struct wl12xx *wl) 95void wl1251_event_mbox_config(struct wl1251 *wl)
96{ 96{
97 wl->mbox_ptr[0] = wl12xx_reg_read32(wl, REG_EVENT_MAILBOX_PTR); 97 wl->mbox_ptr[0] = wl1251_reg_read32(wl, REG_EVENT_MAILBOX_PTR);
98 wl->mbox_ptr[1] = wl->mbox_ptr[0] + sizeof(struct event_mailbox); 98 wl->mbox_ptr[1] = wl->mbox_ptr[0] + sizeof(struct event_mailbox);
99 99
100 wl12xx_debug(DEBUG_EVENT, "MBOX ptrs: 0x%x 0x%x", 100 wl1251_debug(DEBUG_EVENT, "MBOX ptrs: 0x%x 0x%x",
101 wl->mbox_ptr[0], wl->mbox_ptr[1]); 101 wl->mbox_ptr[0], wl->mbox_ptr[1]);
102} 102}
103 103
104int wl12xx_event_handle(struct wl12xx *wl, u8 mbox_num) 104int wl1251_event_handle(struct wl1251 *wl, u8 mbox_num)
105{ 105{
106 struct event_mailbox mbox; 106 struct event_mailbox mbox;
107 int ret; 107 int ret;
108 108
109 wl12xx_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num); 109 wl1251_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num);
110 110
111 if (mbox_num > 1) 111 if (mbox_num > 1)
112 return -EINVAL; 112 return -EINVAL;
113 113
114 /* first we read the mbox descriptor */ 114 /* first we read the mbox descriptor */
115 wl12xx_spi_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox, 115 wl1251_spi_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox,
116 sizeof(struct event_mailbox)); 116 sizeof(struct event_mailbox));
117 117
118 /* process the descriptor */ 118 /* process the descriptor */
119 ret = wl12xx_event_process(wl, &mbox); 119 ret = wl1251_event_process(wl, &mbox);
120 if (ret < 0) 120 if (ret < 0)
121 return ret; 121 return ret;
122 122
123 /* then we let the firmware know it can go on...*/ 123 /* then we let the firmware know it can go on...*/
124 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_EVENT_ACK); 124 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_EVENT_ACK);
125 125
126 return 0; 126 return 0;
127} 127}
diff --git a/drivers/net/wireless/wl12xx/event.h b/drivers/net/wireless/wl12xx/wl1251_event.h
index 1f4c2f7438a7..be0ac54d6246 100644
--- a/drivers/net/wireless/wl12xx/event.h
+++ b/drivers/net/wireless/wl12xx/wl1251_event.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -22,8 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#ifndef __WL12XX_EVENT_H__ 25#ifndef __WL1251_EVENT_H__
26#define __WL12XX_EVENT_H__ 26#define __WL1251_EVENT_H__
27 27
28/* 28/*
29 * Mbox events 29 * Mbox events
@@ -114,8 +114,8 @@ struct event_mailbox {
114 u8 padding[19]; 114 u8 padding[19];
115} __attribute__ ((packed)); 115} __attribute__ ((packed));
116 116
117int wl12xx_event_unmask(struct wl12xx *wl); 117int wl1251_event_unmask(struct wl1251 *wl);
118void wl12xx_event_mbox_config(struct wl12xx *wl); 118void wl1251_event_mbox_config(struct wl1251 *wl);
119int wl12xx_event_handle(struct wl12xx *wl, u8 mbox); 119int wl1251_event_handle(struct wl1251 *wl, u8 mbox);
120 120
121#endif 121#endif
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/wl1251_init.c
index 2a573a6010bd..df6c60f0fd66 100644
--- a/drivers/net/wireless/wl12xx/init.c
+++ b/drivers/net/wireless/wl12xx/wl1251_init.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2009 Nokia Corporation
5 * 5 *
@@ -24,64 +24,64 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26 26
27#include "init.h" 27#include "wl1251_init.h"
28#include "wl12xx_80211.h" 28#include "wl12xx_80211.h"
29#include "acx.h" 29#include "wl1251_acx.h"
30#include "cmd.h" 30#include "wl1251_cmd.h"
31 31
32int wl12xx_hw_init_hwenc_config(struct wl12xx *wl) 32int wl1251_hw_init_hwenc_config(struct wl1251 *wl)
33{ 33{
34 int ret; 34 int ret;
35 35
36 ret = wl12xx_acx_feature_cfg(wl); 36 ret = wl1251_acx_feature_cfg(wl);
37 if (ret < 0) { 37 if (ret < 0) {
38 wl12xx_warning("couldn't set feature config"); 38 wl1251_warning("couldn't set feature config");
39 return ret; 39 return ret;
40 } 40 }
41 41
42 ret = wl12xx_acx_default_key(wl, wl->default_key); 42 ret = wl1251_acx_default_key(wl, wl->default_key);
43 if (ret < 0) { 43 if (ret < 0) {
44 wl12xx_warning("couldn't set default key"); 44 wl1251_warning("couldn't set default key");
45 return ret; 45 return ret;
46 } 46 }
47 47
48 return 0; 48 return 0;
49} 49}
50 50
51int wl12xx_hw_init_templates_config(struct wl12xx *wl) 51int wl1251_hw_init_templates_config(struct wl1251 *wl)
52{ 52{
53 int ret; 53 int ret;
54 u8 partial_vbm[PARTIAL_VBM_MAX]; 54 u8 partial_vbm[PARTIAL_VBM_MAX];
55 55
56 /* send empty templates for fw memory reservation */ 56 /* send empty templates for fw memory reservation */
57 ret = wl12xx_cmd_template_set(wl, CMD_PROBE_REQ, NULL, 57 ret = wl1251_cmd_template_set(wl, CMD_PROBE_REQ, NULL,
58 sizeof(struct wl12xx_probe_req_template)); 58 sizeof(struct wl12xx_probe_req_template));
59 if (ret < 0) 59 if (ret < 0)
60 return ret; 60 return ret;
61 61
62 ret = wl12xx_cmd_template_set(wl, CMD_NULL_DATA, NULL, 62 ret = wl1251_cmd_template_set(wl, CMD_NULL_DATA, NULL,
63 sizeof(struct wl12xx_null_data_template)); 63 sizeof(struct wl12xx_null_data_template));
64 if (ret < 0) 64 if (ret < 0)
65 return ret; 65 return ret;
66 66
67 ret = wl12xx_cmd_template_set(wl, CMD_PS_POLL, NULL, 67 ret = wl1251_cmd_template_set(wl, CMD_PS_POLL, NULL,
68 sizeof(struct wl12xx_ps_poll_template)); 68 sizeof(struct wl12xx_ps_poll_template));
69 if (ret < 0) 69 if (ret < 0)
70 return ret; 70 return ret;
71 71
72 ret = wl12xx_cmd_template_set(wl, CMD_QOS_NULL_DATA, NULL, 72 ret = wl1251_cmd_template_set(wl, CMD_QOS_NULL_DATA, NULL,
73 sizeof 73 sizeof
74 (struct wl12xx_qos_null_data_template)); 74 (struct wl12xx_qos_null_data_template));
75 if (ret < 0) 75 if (ret < 0)
76 return ret; 76 return ret;
77 77
78 ret = wl12xx_cmd_template_set(wl, CMD_PROBE_RESP, NULL, 78 ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, NULL,
79 sizeof 79 sizeof
80 (struct wl12xx_probe_resp_template)); 80 (struct wl12xx_probe_resp_template));
81 if (ret < 0) 81 if (ret < 0)
82 return ret; 82 return ret;
83 83
84 ret = wl12xx_cmd_template_set(wl, CMD_BEACON, NULL, 84 ret = wl1251_cmd_template_set(wl, CMD_BEACON, NULL,
85 sizeof 85 sizeof
86 (struct wl12xx_beacon_template)); 86 (struct wl12xx_beacon_template));
87 if (ret < 0) 87 if (ret < 0)
@@ -89,112 +89,112 @@ int wl12xx_hw_init_templates_config(struct wl12xx *wl)
89 89
90 /* tim templates, first reserve space then allocate an empty one */ 90 /* tim templates, first reserve space then allocate an empty one */
91 memset(partial_vbm, 0, PARTIAL_VBM_MAX); 91 memset(partial_vbm, 0, PARTIAL_VBM_MAX);
92 ret = wl12xx_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, PARTIAL_VBM_MAX, 0); 92 ret = wl1251_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, PARTIAL_VBM_MAX, 0);
93 if (ret < 0) 93 if (ret < 0)
94 return ret; 94 return ret;
95 95
96 ret = wl12xx_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, 1, 0); 96 ret = wl1251_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, 1, 0);
97 if (ret < 0) 97 if (ret < 0)
98 return ret; 98 return ret;
99 99
100 return 0; 100 return 0;
101} 101}
102 102
103int wl12xx_hw_init_rx_config(struct wl12xx *wl, u32 config, u32 filter) 103int wl1251_hw_init_rx_config(struct wl1251 *wl, u32 config, u32 filter)
104{ 104{
105 int ret; 105 int ret;
106 106
107 ret = wl12xx_acx_rx_msdu_life_time(wl, RX_MSDU_LIFETIME_DEF); 107 ret = wl1251_acx_rx_msdu_life_time(wl, RX_MSDU_LIFETIME_DEF);
108 if (ret < 0) 108 if (ret < 0)
109 return ret; 109 return ret;
110 110
111 ret = wl12xx_acx_rx_config(wl, config, filter); 111 ret = wl1251_acx_rx_config(wl, config, filter);
112 if (ret < 0) 112 if (ret < 0)
113 return ret; 113 return ret;
114 114
115 return 0; 115 return 0;
116} 116}
117 117
118int wl12xx_hw_init_phy_config(struct wl12xx *wl) 118int wl1251_hw_init_phy_config(struct wl1251 *wl)
119{ 119{
120 int ret; 120 int ret;
121 121
122 ret = wl12xx_acx_pd_threshold(wl); 122 ret = wl1251_acx_pd_threshold(wl);
123 if (ret < 0) 123 if (ret < 0)
124 return ret; 124 return ret;
125 125
126 ret = wl12xx_acx_slot(wl, DEFAULT_SLOT_TIME); 126 ret = wl1251_acx_slot(wl, DEFAULT_SLOT_TIME);
127 if (ret < 0) 127 if (ret < 0)
128 return ret; 128 return ret;
129 129
130 ret = wl12xx_acx_group_address_tbl(wl); 130 ret = wl1251_acx_group_address_tbl(wl);
131 if (ret < 0) 131 if (ret < 0)
132 return ret; 132 return ret;
133 133
134 ret = wl12xx_acx_service_period_timeout(wl); 134 ret = wl1251_acx_service_period_timeout(wl);
135 if (ret < 0) 135 if (ret < 0)
136 return ret; 136 return ret;
137 137
138 ret = wl12xx_acx_rts_threshold(wl, RTS_THRESHOLD_DEF); 138 ret = wl1251_acx_rts_threshold(wl, RTS_THRESHOLD_DEF);
139 if (ret < 0) 139 if (ret < 0)
140 return ret; 140 return ret;
141 141
142 return 0; 142 return 0;
143} 143}
144 144
145int wl12xx_hw_init_beacon_filter(struct wl12xx *wl) 145int wl1251_hw_init_beacon_filter(struct wl1251 *wl)
146{ 146{
147 int ret; 147 int ret;
148 148
149 ret = wl12xx_acx_beacon_filter_opt(wl); 149 ret = wl1251_acx_beacon_filter_opt(wl);
150 if (ret < 0) 150 if (ret < 0)
151 return ret; 151 return ret;
152 152
153 ret = wl12xx_acx_beacon_filter_table(wl); 153 ret = wl1251_acx_beacon_filter_table(wl);
154 if (ret < 0) 154 if (ret < 0)
155 return ret; 155 return ret;
156 156
157 return 0; 157 return 0;
158} 158}
159 159
160int wl12xx_hw_init_pta(struct wl12xx *wl) 160int wl1251_hw_init_pta(struct wl1251 *wl)
161{ 161{
162 int ret; 162 int ret;
163 163
164 ret = wl12xx_acx_sg_enable(wl); 164 ret = wl1251_acx_sg_enable(wl);
165 if (ret < 0) 165 if (ret < 0)
166 return ret; 166 return ret;
167 167
168 ret = wl12xx_acx_sg_cfg(wl); 168 ret = wl1251_acx_sg_cfg(wl);
169 if (ret < 0) 169 if (ret < 0)
170 return ret; 170 return ret;
171 171
172 return 0; 172 return 0;
173} 173}
174 174
175int wl12xx_hw_init_energy_detection(struct wl12xx *wl) 175int wl1251_hw_init_energy_detection(struct wl1251 *wl)
176{ 176{
177 int ret; 177 int ret;
178 178
179 ret = wl12xx_acx_cca_threshold(wl); 179 ret = wl1251_acx_cca_threshold(wl);
180 if (ret < 0) 180 if (ret < 0)
181 return ret; 181 return ret;
182 182
183 return 0; 183 return 0;
184} 184}
185 185
186int wl12xx_hw_init_beacon_broadcast(struct wl12xx *wl) 186int wl1251_hw_init_beacon_broadcast(struct wl1251 *wl)
187{ 187{
188 int ret; 188 int ret;
189 189
190 ret = wl12xx_acx_bcn_dtim_options(wl); 190 ret = wl1251_acx_bcn_dtim_options(wl);
191 if (ret < 0) 191 if (ret < 0)
192 return ret; 192 return ret;
193 193
194 return 0; 194 return 0;
195} 195}
196 196
197int wl12xx_hw_init_power_auth(struct wl12xx *wl) 197int wl1251_hw_init_power_auth(struct wl1251 *wl)
198{ 198{
199 return wl12xx_acx_sleep_auth(wl, WL12XX_PSM_CAM); 199 return wl1251_acx_sleep_auth(wl, WL1251_PSM_CAM);
200} 200}
diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/wl1251_init.h
index c8b6cd0b7c3e..8596188e834e 100644
--- a/drivers/net/wireless/wl12xx/init.h
+++ b/drivers/net/wireless/wl12xx/wl1251_init.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2009 Nokia Corporation
5 * 5 *
@@ -21,20 +21,19 @@
21 * 21 *
22 */ 22 */
23 23
24#ifndef __WL12XX_INIT_H__ 24#ifndef __WL1251_INIT_H__
25#define __WL12XX_INIT_H__ 25#define __WL1251_INIT_H__
26 26
27#include "wl12xx.h" 27#include "wl1251.h"
28 28
29int wl12xx_hw_init_hwenc_config(struct wl12xx *wl); 29int wl1251_hw_init_hwenc_config(struct wl1251 *wl);
30int wl12xx_hw_init_templates_config(struct wl12xx *wl); 30int wl1251_hw_init_templates_config(struct wl1251 *wl);
31int wl12xx_hw_init_mem_config(struct wl12xx *wl); 31int wl1251_hw_init_rx_config(struct wl1251 *wl, u32 config, u32 filter);
32int wl12xx_hw_init_rx_config(struct wl12xx *wl, u32 config, u32 filter); 32int wl1251_hw_init_phy_config(struct wl1251 *wl);
33int wl12xx_hw_init_phy_config(struct wl12xx *wl); 33int wl1251_hw_init_beacon_filter(struct wl1251 *wl);
34int wl12xx_hw_init_beacon_filter(struct wl12xx *wl); 34int wl1251_hw_init_pta(struct wl1251 *wl);
35int wl12xx_hw_init_pta(struct wl12xx *wl); 35int wl1251_hw_init_energy_detection(struct wl1251 *wl);
36int wl12xx_hw_init_energy_detection(struct wl12xx *wl); 36int wl1251_hw_init_beacon_broadcast(struct wl1251 *wl);
37int wl12xx_hw_init_beacon_broadcast(struct wl12xx *wl); 37int wl1251_hw_init_power_auth(struct wl1251 *wl);
38int wl12xx_hw_init_power_auth(struct wl12xx *wl);
39 38
40#endif 39#endif
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/wl1251_main.c
index 603d6114882e..da4c688c46af 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2008-2009 Nokia Corporation 4 * Copyright (C) 2008-2009 Nokia Corporation
5 * 5 *
@@ -31,38 +31,38 @@
31#include <linux/etherdevice.h> 31#include <linux/etherdevice.h>
32#include <linux/spi/wl12xx.h> 32#include <linux/spi/wl12xx.h>
33 33
34#include "wl12xx.h" 34#include "wl1251.h"
35#include "wl12xx_80211.h" 35#include "wl12xx_80211.h"
36#include "reg.h" 36#include "reg.h"
37#include "wl1251.h" 37#include "wl1251_ops.h"
38#include "spi.h" 38#include "wl1251_spi.h"
39#include "event.h" 39#include "wl1251_event.h"
40#include "tx.h" 40#include "wl1251_tx.h"
41#include "rx.h" 41#include "wl1251_rx.h"
42#include "ps.h" 42#include "wl1251_ps.h"
43#include "init.h" 43#include "wl1251_init.h"
44#include "debugfs.h" 44#include "wl1251_debugfs.h"
45 45
46static void wl12xx_disable_interrupts(struct wl12xx *wl) 46static void wl1251_disable_interrupts(struct wl1251 *wl)
47{ 47{
48 disable_irq(wl->irq); 48 disable_irq(wl->irq);
49} 49}
50 50
51static void wl12xx_power_off(struct wl12xx *wl) 51static void wl1251_power_off(struct wl1251 *wl)
52{ 52{
53 wl->set_power(false); 53 wl->set_power(false);
54} 54}
55 55
56static void wl12xx_power_on(struct wl12xx *wl) 56static void wl1251_power_on(struct wl1251 *wl)
57{ 57{
58 wl->set_power(true); 58 wl->set_power(true);
59} 59}
60 60
61static irqreturn_t wl12xx_irq(int irq, void *cookie) 61static irqreturn_t wl1251_irq(int irq, void *cookie)
62{ 62{
63 struct wl12xx *wl; 63 struct wl1251 *wl;
64 64
65 wl12xx_debug(DEBUG_IRQ, "IRQ"); 65 wl1251_debug(DEBUG_IRQ, "IRQ");
66 66
67 wl = cookie; 67 wl = cookie;
68 68
@@ -71,7 +71,7 @@ static irqreturn_t wl12xx_irq(int irq, void *cookie)
71 return IRQ_HANDLED; 71 return IRQ_HANDLED;
72} 72}
73 73
74static int wl12xx_fetch_firmware(struct wl12xx *wl) 74static int wl1251_fetch_firmware(struct wl1251 *wl)
75{ 75{
76 const struct firmware *fw; 76 const struct firmware *fw;
77 int ret; 77 int ret;
@@ -79,12 +79,12 @@ static int wl12xx_fetch_firmware(struct wl12xx *wl)
79 ret = request_firmware(&fw, wl->chip.fw_filename, &wl->spi->dev); 79 ret = request_firmware(&fw, wl->chip.fw_filename, &wl->spi->dev);
80 80
81 if (ret < 0) { 81 if (ret < 0) {
82 wl12xx_error("could not get firmware: %d", ret); 82 wl1251_error("could not get firmware: %d", ret);
83 return ret; 83 return ret;
84 } 84 }
85 85
86 if (fw->size % 4) { 86 if (fw->size % 4) {
87 wl12xx_error("firmware size is not multiple of 32 bits: %zu", 87 wl1251_error("firmware size is not multiple of 32 bits: %zu",
88 fw->size); 88 fw->size);
89 ret = -EILSEQ; 89 ret = -EILSEQ;
90 goto out; 90 goto out;
@@ -94,7 +94,7 @@ static int wl12xx_fetch_firmware(struct wl12xx *wl)
94 wl->fw = kmalloc(wl->fw_len, GFP_KERNEL); 94 wl->fw = kmalloc(wl->fw_len, GFP_KERNEL);
95 95
96 if (!wl->fw) { 96 if (!wl->fw) {
97 wl12xx_error("could not allocate memory for the firmware"); 97 wl1251_error("could not allocate memory for the firmware");
98 ret = -ENOMEM; 98 ret = -ENOMEM;
99 goto out; 99 goto out;
100 } 100 }
@@ -109,7 +109,7 @@ out:
109 return ret; 109 return ret;
110} 110}
111 111
112static int wl12xx_fetch_nvs(struct wl12xx *wl) 112static int wl1251_fetch_nvs(struct wl1251 *wl)
113{ 113{
114 const struct firmware *fw; 114 const struct firmware *fw;
115 int ret; 115 int ret;
@@ -117,12 +117,12 @@ static int wl12xx_fetch_nvs(struct wl12xx *wl)
117 ret = request_firmware(&fw, wl->chip.nvs_filename, &wl->spi->dev); 117 ret = request_firmware(&fw, wl->chip.nvs_filename, &wl->spi->dev);
118 118
119 if (ret < 0) { 119 if (ret < 0) {
120 wl12xx_error("could not get nvs file: %d", ret); 120 wl1251_error("could not get nvs file: %d", ret);
121 return ret; 121 return ret;
122 } 122 }
123 123
124 if (fw->size % 4) { 124 if (fw->size % 4) {
125 wl12xx_error("nvs size is not multiple of 32 bits: %zu", 125 wl1251_error("nvs size is not multiple of 32 bits: %zu",
126 fw->size); 126 fw->size);
127 ret = -EILSEQ; 127 ret = -EILSEQ;
128 goto out; 128 goto out;
@@ -132,7 +132,7 @@ static int wl12xx_fetch_nvs(struct wl12xx *wl)
132 wl->nvs = kmalloc(wl->nvs_len, GFP_KERNEL); 132 wl->nvs = kmalloc(wl->nvs_len, GFP_KERNEL);
133 133
134 if (!wl->nvs) { 134 if (!wl->nvs) {
135 wl12xx_error("could not allocate memory for the nvs file"); 135 wl1251_error("could not allocate memory for the nvs file");
136 ret = -ENOMEM; 136 ret = -ENOMEM;
137 goto out; 137 goto out;
138 } 138 }
@@ -147,74 +147,70 @@ out:
147 return ret; 147 return ret;
148} 148}
149 149
150static void wl12xx_fw_wakeup(struct wl12xx *wl) 150static void wl1251_fw_wakeup(struct wl1251 *wl)
151{ 151{
152 u32 elp_reg; 152 u32 elp_reg;
153 153
154 elp_reg = ELPCTRL_WAKE_UP; 154 elp_reg = ELPCTRL_WAKE_UP;
155 wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); 155 wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
156 elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); 156 elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
157 157
158 if (!(elp_reg & ELPCTRL_WLAN_READY)) { 158 if (!(elp_reg & ELPCTRL_WLAN_READY))
159 wl12xx_warning("WLAN not ready"); 159 wl1251_warning("WLAN not ready");
160 elp_reg = ELPCTRL_WAKE_UP_WLAN_READY;
161 wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg);
162 }
163} 160}
164 161
165static int wl12xx_chip_wakeup(struct wl12xx *wl) 162static int wl1251_chip_wakeup(struct wl1251 *wl)
166{ 163{
167 int ret = 0; 164 int ret = 0;
168 165
169 wl12xx_power_on(wl); 166 wl1251_power_on(wl);
170 msleep(wl->chip.power_on_sleep); 167 msleep(wl->chip.power_on_sleep);
171 wl12xx_spi_reset(wl); 168 wl1251_spi_reset(wl);
172 wl12xx_spi_init(wl); 169 wl1251_spi_init(wl);
173 170
174 /* We don't need a real memory partition here, because we only want 171 /* We don't need a real memory partition here, because we only want
175 * to use the registers at this point. */ 172 * to use the registers at this point. */
176 wl12xx_set_partition(wl, 173 wl1251_set_partition(wl,
177 0x00000000, 174 0x00000000,
178 0x00000000, 175 0x00000000,
179 REGISTERS_BASE, 176 REGISTERS_BASE,
180 REGISTERS_DOWN_SIZE); 177 REGISTERS_DOWN_SIZE);
181 178
182 /* ELP module wake up */ 179 /* ELP module wake up */
183 wl12xx_fw_wakeup(wl); 180 wl1251_fw_wakeup(wl);
184 181
185 /* whal_FwCtrl_BootSm() */ 182 /* whal_FwCtrl_BootSm() */
186 183
187 /* 0. read chip id from CHIP_ID */ 184 /* 0. read chip id from CHIP_ID */
188 wl->chip.id = wl12xx_reg_read32(wl, CHIP_ID_B); 185 wl->chip.id = wl1251_reg_read32(wl, CHIP_ID_B);
189 186
190 /* 1. check if chip id is valid */ 187 /* 1. check if chip id is valid */
191 188
192 switch (wl->chip.id) { 189 switch (wl->chip.id) {
193 case CHIP_ID_1251_PG12: 190 case CHIP_ID_1251_PG12:
194 wl12xx_debug(DEBUG_BOOT, "chip id 0x%x (1251 PG12)", 191 wl1251_debug(DEBUG_BOOT, "chip id 0x%x (1251 PG12)",
195 wl->chip.id); 192 wl->chip.id);
196 193
197 wl1251_setup(wl); 194 wl1251_setup(wl);
198 195
199 break; 196 break;
200 case CHIP_ID_1271_PG10:
201 case CHIP_ID_1251_PG10: 197 case CHIP_ID_1251_PG10:
202 case CHIP_ID_1251_PG11: 198 case CHIP_ID_1251_PG11:
203 default: 199 default:
204 wl12xx_error("unsupported chip id: 0x%x", wl->chip.id); 200 wl1251_error("unsupported chip id: 0x%x", wl->chip.id);
205 ret = -ENODEV; 201 ret = -ENODEV;
206 goto out; 202 goto out;
207 } 203 }
208 204
209 if (wl->fw == NULL) { 205 if (wl->fw == NULL) {
210 ret = wl12xx_fetch_firmware(wl); 206 ret = wl1251_fetch_firmware(wl);
211 if (ret < 0) 207 if (ret < 0)
212 goto out; 208 goto out;
213 } 209 }
214 210
215 /* No NVS from netlink, try to get it from the filesystem */ 211 /* No NVS from netlink, try to get it from the filesystem */
216 if (wl->nvs == NULL) { 212 if (wl->nvs == NULL) {
217 ret = wl12xx_fetch_nvs(wl); 213 ret = wl1251_fetch_nvs(wl);
218 if (ret < 0) 214 if (ret < 0)
219 goto out; 215 goto out;
220 } 216 }
@@ -223,88 +219,51 @@ out:
223 return ret; 219 return ret;
224} 220}
225 221
226static void wl12xx_filter_work(struct work_struct *work) 222static void wl1251_filter_work(struct work_struct *work)
227{ 223{
228 struct wl12xx *wl = 224 struct wl1251 *wl =
229 container_of(work, struct wl12xx, filter_work); 225 container_of(work, struct wl1251, filter_work);
230 int ret; 226 int ret;
231 227
232 mutex_lock(&wl->mutex); 228 mutex_lock(&wl->mutex);
233 229
234 if (wl->state == WL12XX_STATE_OFF) 230 if (wl->state == WL1251_STATE_OFF)
235 goto out; 231 goto out;
236 232
237 ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0); 233 ret = wl1251_ps_elp_wakeup(wl);
238 if (ret < 0) 234 if (ret < 0)
239 goto out; 235 goto out;
240 236
241out: 237 /* FIXME: replace the magic numbers with proper definitions */
242 mutex_unlock(&wl->mutex); 238 ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0);
243}
244
245int wl12xx_plt_start(struct wl12xx *wl)
246{
247 int ret;
248
249 wl12xx_notice("power up");
250
251 if (wl->state != WL12XX_STATE_OFF) {
252 wl12xx_error("cannot go into PLT state because not "
253 "in off state: %d", wl->state);
254 return -EBUSY;
255 }
256
257 wl->state = WL12XX_STATE_PLT;
258
259 ret = wl12xx_chip_wakeup(wl);
260 if (ret < 0) 239 if (ret < 0)
261 return ret; 240 goto out_sleep;
262 241
263 ret = wl->chip.op_boot(wl); 242out_sleep:
264 if (ret < 0) 243 wl1251_ps_elp_sleep(wl);
265 return ret;
266
267 wl12xx_notice("firmware booted in PLT mode (%s)", wl->chip.fw_ver);
268 244
269 ret = wl->chip.op_plt_init(wl); 245out:
270 if (ret < 0) 246 mutex_unlock(&wl->mutex);
271 return ret;
272
273 return 0;
274}
275
276int wl12xx_plt_stop(struct wl12xx *wl)
277{
278 wl12xx_notice("power down");
279
280 if (wl->state != WL12XX_STATE_PLT) {
281 wl12xx_error("cannot power down because not in PLT "
282 "state: %d", wl->state);
283 return -EBUSY;
284 }
285
286 wl12xx_disable_interrupts(wl);
287 wl12xx_power_off(wl);
288
289 wl->state = WL12XX_STATE_OFF;
290
291 return 0;
292} 247}
293 248
294 249static int wl1251_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
295static int wl12xx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
296{ 250{
297 struct wl12xx *wl = hw->priv; 251 struct wl1251 *wl = hw->priv;
298 252
299 skb_queue_tail(&wl->tx_queue, skb); 253 skb_queue_tail(&wl->tx_queue, skb);
300 254
255 /*
256 * The chip specific setup must run before the first TX packet -
257 * before that, the tx_work will not be initialized!
258 */
259
301 schedule_work(&wl->tx_work); 260 schedule_work(&wl->tx_work);
302 261
303 /* 262 /*
304 * The workqueue is slow to process the tx_queue and we need stop 263 * The workqueue is slow to process the tx_queue and we need stop
305 * the queue here, otherwise the queue will get too long. 264 * the queue here, otherwise the queue will get too long.
306 */ 265 */
307 if (skb_queue_len(&wl->tx_queue) >= WL12XX_TX_QUEUE_MAX_LENGTH) { 266 if (skb_queue_len(&wl->tx_queue) >= WL1251_TX_QUEUE_MAX_LENGTH) {
308 ieee80211_stop_queues(wl->hw); 267 ieee80211_stop_queues(wl->hw);
309 268
310 /* 269 /*
@@ -318,25 +277,25 @@ static int wl12xx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
318 return NETDEV_TX_OK; 277 return NETDEV_TX_OK;
319} 278}
320 279
321static int wl12xx_op_start(struct ieee80211_hw *hw) 280static int wl1251_op_start(struct ieee80211_hw *hw)
322{ 281{
323 struct wl12xx *wl = hw->priv; 282 struct wl1251 *wl = hw->priv;
324 int ret = 0; 283 int ret = 0;
325 284
326 wl12xx_debug(DEBUG_MAC80211, "mac80211 start"); 285 wl1251_debug(DEBUG_MAC80211, "mac80211 start");
327 286
328 mutex_lock(&wl->mutex); 287 mutex_lock(&wl->mutex);
329 288
330 if (wl->state != WL12XX_STATE_OFF) { 289 if (wl->state != WL1251_STATE_OFF) {
331 wl12xx_error("cannot start because not in off state: %d", 290 wl1251_error("cannot start because not in off state: %d",
332 wl->state); 291 wl->state);
333 ret = -EBUSY; 292 ret = -EBUSY;
334 goto out; 293 goto out;
335 } 294 }
336 295
337 ret = wl12xx_chip_wakeup(wl); 296 ret = wl1251_chip_wakeup(wl);
338 if (ret < 0) 297 if (ret < 0)
339 return ret; 298 goto out;
340 299
341 ret = wl->chip.op_boot(wl); 300 ret = wl->chip.op_boot(wl);
342 if (ret < 0) 301 if (ret < 0)
@@ -346,34 +305,34 @@ static int wl12xx_op_start(struct ieee80211_hw *hw)
346 if (ret < 0) 305 if (ret < 0)
347 goto out; 306 goto out;
348 307
349 ret = wl12xx_acx_station_id(wl); 308 ret = wl1251_acx_station_id(wl);
350 if (ret < 0) 309 if (ret < 0)
351 goto out; 310 goto out;
352 311
353 wl->state = WL12XX_STATE_ON; 312 wl->state = WL1251_STATE_ON;
354 313
355 wl12xx_info("firmware booted (%s)", wl->chip.fw_ver); 314 wl1251_info("firmware booted (%s)", wl->chip.fw_ver);
356 315
357out: 316out:
358 if (ret < 0) 317 if (ret < 0)
359 wl12xx_power_off(wl); 318 wl1251_power_off(wl);
360 319
361 mutex_unlock(&wl->mutex); 320 mutex_unlock(&wl->mutex);
362 321
363 return ret; 322 return ret;
364} 323}
365 324
366static void wl12xx_op_stop(struct ieee80211_hw *hw) 325static void wl1251_op_stop(struct ieee80211_hw *hw)
367{ 326{
368 struct wl12xx *wl = hw->priv; 327 struct wl1251 *wl = hw->priv;
369 328
370 wl12xx_info("down"); 329 wl1251_info("down");
371 330
372 wl12xx_debug(DEBUG_MAC80211, "mac80211 stop"); 331 wl1251_debug(DEBUG_MAC80211, "mac80211 stop");
373 332
374 mutex_lock(&wl->mutex); 333 mutex_lock(&wl->mutex);
375 334
376 WARN_ON(wl->state != WL12XX_STATE_ON); 335 WARN_ON(wl->state != WL1251_STATE_ON);
377 336
378 if (wl->scanning) { 337 if (wl->scanning) {
379 mutex_unlock(&wl->mutex); 338 mutex_unlock(&wl->mutex);
@@ -382,9 +341,9 @@ static void wl12xx_op_stop(struct ieee80211_hw *hw)
382 wl->scanning = false; 341 wl->scanning = false;
383 } 342 }
384 343
385 wl->state = WL12XX_STATE_OFF; 344 wl->state = WL1251_STATE_OFF;
386 345
387 wl12xx_disable_interrupts(wl); 346 wl1251_disable_interrupts(wl);
388 347
389 mutex_unlock(&wl->mutex); 348 mutex_unlock(&wl->mutex);
390 349
@@ -395,9 +354,8 @@ static void wl12xx_op_stop(struct ieee80211_hw *hw)
395 mutex_lock(&wl->mutex); 354 mutex_lock(&wl->mutex);
396 355
397 /* let's notify MAC80211 about the remaining pending TX frames */ 356 /* let's notify MAC80211 about the remaining pending TX frames */
398 wl12xx_tx_flush(wl); 357 wl->chip.op_tx_flush(wl);
399 358 wl1251_power_off(wl);
400 wl12xx_power_off(wl);
401 359
402 memset(wl->bssid, 0, ETH_ALEN); 360 memset(wl->bssid, 0, ETH_ALEN);
403 wl->listen_int = 1; 361 wl->listen_int = 1;
@@ -412,22 +370,21 @@ static void wl12xx_op_stop(struct ieee80211_hw *hw)
412 wl->elp = false; 370 wl->elp = false;
413 wl->psm = 0; 371 wl->psm = 0;
414 wl->tx_queue_stopped = false; 372 wl->tx_queue_stopped = false;
415 wl->power_level = WL12XX_DEFAULT_POWER_LEVEL; 373 wl->power_level = WL1251_DEFAULT_POWER_LEVEL;
416 374
417 wl12xx_debugfs_reset(wl); 375 wl1251_debugfs_reset(wl);
418 376
419 mutex_unlock(&wl->mutex); 377 mutex_unlock(&wl->mutex);
420} 378}
421 379
422static int wl12xx_op_add_interface(struct ieee80211_hw *hw, 380static int wl1251_op_add_interface(struct ieee80211_hw *hw,
423 struct ieee80211_if_init_conf *conf) 381 struct ieee80211_if_init_conf *conf)
424{ 382{
425 struct wl12xx *wl = hw->priv; 383 struct wl1251 *wl = hw->priv;
426 DECLARE_MAC_BUF(mac);
427 int ret = 0; 384 int ret = 0;
428 385
429 wl12xx_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %s", 386 wl1251_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM",
430 conf->type, print_mac(mac, conf->mac_addr)); 387 conf->type, conf->mac_addr);
431 388
432 mutex_lock(&wl->mutex); 389 mutex_lock(&wl->mutex);
433 390
@@ -446,7 +403,7 @@ static int wl12xx_op_add_interface(struct ieee80211_hw *hw,
446 if (memcmp(wl->mac_addr, conf->mac_addr, ETH_ALEN)) { 403 if (memcmp(wl->mac_addr, conf->mac_addr, ETH_ALEN)) {
447 memcpy(wl->mac_addr, conf->mac_addr, ETH_ALEN); 404 memcpy(wl->mac_addr, conf->mac_addr, ETH_ALEN);
448 SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr); 405 SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr);
449 ret = wl12xx_acx_station_id(wl); 406 ret = wl1251_acx_station_id(wl);
450 if (ret < 0) 407 if (ret < 0)
451 goto out; 408 goto out;
452 } 409 }
@@ -456,13 +413,13 @@ out:
456 return ret; 413 return ret;
457} 414}
458 415
459static void wl12xx_op_remove_interface(struct ieee80211_hw *hw, 416static void wl1251_op_remove_interface(struct ieee80211_hw *hw,
460 struct ieee80211_if_init_conf *conf) 417 struct ieee80211_if_init_conf *conf)
461{ 418{
462 wl12xx_debug(DEBUG_MAC80211, "mac80211 remove interface"); 419 wl1251_debug(DEBUG_MAC80211, "mac80211 remove interface");
463} 420}
464 421
465static int wl12xx_build_null_data(struct wl12xx *wl) 422static int wl1251_build_null_data(struct wl1251 *wl)
466{ 423{
467 struct wl12xx_null_data_template template; 424 struct wl12xx_null_data_template template;
468 425
@@ -478,12 +435,12 @@ static int wl12xx_build_null_data(struct wl12xx *wl)
478 template.header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | 435 template.header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA |
479 IEEE80211_STYPE_NULLFUNC); 436 IEEE80211_STYPE_NULLFUNC);
480 437
481 return wl12xx_cmd_template_set(wl, CMD_NULL_DATA, &template, 438 return wl1251_cmd_template_set(wl, CMD_NULL_DATA, &template,
482 sizeof(template)); 439 sizeof(template));
483 440
484} 441}
485 442
486static int wl12xx_build_ps_poll(struct wl12xx *wl, u16 aid) 443static int wl1251_build_ps_poll(struct wl1251 *wl, u16 aid)
487{ 444{
488 struct wl12xx_ps_poll_template template; 445 struct wl12xx_ps_poll_template template;
489 446
@@ -492,41 +449,45 @@ static int wl12xx_build_ps_poll(struct wl12xx *wl, u16 aid)
492 template.aid = aid; 449 template.aid = aid;
493 template.fc = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); 450 template.fc = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL);
494 451
495 return wl12xx_cmd_template_set(wl, CMD_PS_POLL, &template, 452 return wl1251_cmd_template_set(wl, CMD_PS_POLL, &template,
496 sizeof(template)); 453 sizeof(template));
497 454
498} 455}
499 456
500static int wl12xx_op_config(struct ieee80211_hw *hw, u32 changed) 457static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed)
501{ 458{
502 struct wl12xx *wl = hw->priv; 459 struct wl1251 *wl = hw->priv;
503 struct ieee80211_conf *conf = &hw->conf; 460 struct ieee80211_conf *conf = &hw->conf;
504 int channel, ret = 0; 461 int channel, ret = 0;
505 462
506 channel = ieee80211_frequency_to_channel(conf->channel->center_freq); 463 channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
507 464
508 wl12xx_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d", 465 wl1251_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d",
509 channel, 466 channel,
510 conf->flags & IEEE80211_CONF_PS ? "on" : "off", 467 conf->flags & IEEE80211_CONF_PS ? "on" : "off",
511 conf->power_level); 468 conf->power_level);
512 469
513 mutex_lock(&wl->mutex); 470 mutex_lock(&wl->mutex);
514 471
472 ret = wl1251_ps_elp_wakeup(wl);
473 if (ret < 0)
474 goto out;
475
515 if (channel != wl->channel) { 476 if (channel != wl->channel) {
516 /* FIXME: use beacon interval provided by mac80211 */ 477 /* FIXME: use beacon interval provided by mac80211 */
517 ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0); 478 ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0);
518 if (ret < 0) 479 if (ret < 0)
519 goto out; 480 goto out_sleep;
520 481
521 wl->channel = channel; 482 wl->channel = channel;
522 } 483 }
523 484
524 ret = wl12xx_build_null_data(wl); 485 ret = wl1251_build_null_data(wl);
525 if (ret < 0) 486 if (ret < 0)
526 goto out; 487 goto out_sleep;
527 488
528 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) { 489 if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) {
529 wl12xx_info("psm enabled"); 490 wl1251_debug(DEBUG_PSM, "psm enabled");
530 491
531 wl->psm_requested = true; 492 wl->psm_requested = true;
532 493
@@ -535,49 +496,53 @@ static int wl12xx_op_config(struct ieee80211_hw *hw, u32 changed)
535 * If we're not, we'll enter it when joining an SSID, 496 * If we're not, we'll enter it when joining an SSID,
536 * through the bss_info_changed() hook. 497 * through the bss_info_changed() hook.
537 */ 498 */
538 ret = wl12xx_ps_set_mode(wl, STATION_POWER_SAVE_MODE); 499 ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE);
539 } else if (!(conf->flags & IEEE80211_CONF_PS) && 500 } else if (!(conf->flags & IEEE80211_CONF_PS) &&
540 wl->psm_requested) { 501 wl->psm_requested) {
541 wl12xx_info("psm disabled"); 502 wl1251_debug(DEBUG_PSM, "psm disabled");
542 503
543 wl->psm_requested = false; 504 wl->psm_requested = false;
544 505
545 if (wl->psm) 506 if (wl->psm)
546 ret = wl12xx_ps_set_mode(wl, STATION_ACTIVE_MODE); 507 ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE);
547 } 508 }
548 509
549 if (conf->power_level != wl->power_level) { 510 if (conf->power_level != wl->power_level) {
550 ret = wl12xx_acx_tx_power(wl, conf->power_level); 511 ret = wl1251_acx_tx_power(wl, conf->power_level);
551 if (ret < 0) 512 if (ret < 0)
552 goto out; 513 goto out;
553 514
554 wl->power_level = conf->power_level; 515 wl->power_level = conf->power_level;
555 } 516 }
556 517
518out_sleep:
519 wl1251_ps_elp_sleep(wl);
520
557out: 521out:
558 mutex_unlock(&wl->mutex); 522 mutex_unlock(&wl->mutex);
523
559 return ret; 524 return ret;
560} 525}
561 526
562#define WL12XX_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \ 527#define WL1251_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \
563 FIF_ALLMULTI | \ 528 FIF_ALLMULTI | \
564 FIF_FCSFAIL | \ 529 FIF_FCSFAIL | \
565 FIF_BCN_PRBRESP_PROMISC | \ 530 FIF_BCN_PRBRESP_PROMISC | \
566 FIF_CONTROL | \ 531 FIF_CONTROL | \
567 FIF_OTHER_BSS) 532 FIF_OTHER_BSS)
568 533
569static void wl12xx_op_configure_filter(struct ieee80211_hw *hw, 534static void wl1251_op_configure_filter(struct ieee80211_hw *hw,
570 unsigned int changed, 535 unsigned int changed,
571 unsigned int *total, 536 unsigned int *total,
572 int mc_count, 537 int mc_count,
573 struct dev_addr_list *mc_list) 538 struct dev_addr_list *mc_list)
574{ 539{
575 struct wl12xx *wl = hw->priv; 540 struct wl1251 *wl = hw->priv;
576 541
577 wl12xx_debug(DEBUG_MAC80211, "mac80211 configure filter"); 542 wl1251_debug(DEBUG_MAC80211, "mac80211 configure filter");
578 543
579 *total &= WL12XX_SUPPORTED_FILTERS; 544 *total &= WL1251_SUPPORTED_FILTERS;
580 changed &= WL12XX_SUPPORTED_FILTERS; 545 changed &= WL1251_SUPPORTED_FILTERS;
581 546
582 if (changed == 0) 547 if (changed == 0)
583 /* no filters which we support changed */ 548 /* no filters which we support changed */
@@ -585,8 +550,8 @@ static void wl12xx_op_configure_filter(struct ieee80211_hw *hw,
585 550
586 /* FIXME: wl->rx_config and wl->rx_filter are not protected */ 551 /* FIXME: wl->rx_config and wl->rx_filter are not protected */
587 552
588 wl->rx_config = WL12XX_DEFAULT_RX_CONFIG; 553 wl->rx_config = WL1251_DEFAULT_RX_CONFIG;
589 wl->rx_filter = WL12XX_DEFAULT_RX_FILTER; 554 wl->rx_filter = WL1251_DEFAULT_RX_FILTER;
590 555
591 if (*total & FIF_PROMISC_IN_BSS) { 556 if (*total & FIF_PROMISC_IN_BSS) {
592 wl->rx_config |= CFG_BSSID_FILTER_EN; 557 wl->rx_config |= CFG_BSSID_FILTER_EN;
@@ -618,7 +583,8 @@ static void wl12xx_op_configure_filter(struct ieee80211_hw *hw,
618} 583}
619 584
620/* HW encryption */ 585/* HW encryption */
621static int wl12xx_set_key_type(struct wl12xx *wl, struct acx_set_key *key, 586static int wl1251_set_key_type(struct wl1251 *wl,
587 struct wl1251_cmd_set_keys *key,
622 enum set_key_cmd cmd, 588 enum set_key_cmd cmd,
623 struct ieee80211_key_conf *mac80211_key, 589 struct ieee80211_key_conf *mac80211_key,
624 const u8 *addr) 590 const u8 *addr)
@@ -648,95 +614,116 @@ static int wl12xx_set_key_type(struct wl12xx *wl, struct acx_set_key *key,
648 mac80211_key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; 614 mac80211_key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;
649 break; 615 break;
650 default: 616 default:
651 wl12xx_error("Unknown key algo 0x%x", mac80211_key->alg); 617 wl1251_error("Unknown key algo 0x%x", mac80211_key->alg);
652 return -EOPNOTSUPP; 618 return -EOPNOTSUPP;
653 } 619 }
654 620
655 return 0; 621 return 0;
656} 622}
657 623
658static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 624static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
659 struct ieee80211_vif *vif, 625 struct ieee80211_vif *vif,
660 struct ieee80211_sta *sta, 626 struct ieee80211_sta *sta,
661 struct ieee80211_key_conf *key) 627 struct ieee80211_key_conf *key)
662{ 628{
663 struct wl12xx *wl = hw->priv; 629 struct wl1251 *wl = hw->priv;
664 struct acx_set_key wl_key; 630 struct wl1251_cmd_set_keys *wl_cmd;
665 const u8 *addr; 631 const u8 *addr;
666 int ret; 632 int ret;
667 633
668 static const u8 bcast_addr[ETH_ALEN] = 634 static const u8 bcast_addr[ETH_ALEN] =
669 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; 635 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
670 636
671 wl12xx_debug(DEBUG_MAC80211, "mac80211 set key"); 637 wl1251_debug(DEBUG_MAC80211, "mac80211 set key");
672 638
673 memset(&wl_key, 0, sizeof(wl_key)); 639 wl_cmd = kzalloc(sizeof(*wl_cmd), GFP_KERNEL);
640 if (!wl_cmd) {
641 ret = -ENOMEM;
642 goto out;
643 }
674 644
675 addr = sta ? sta->addr : bcast_addr; 645 addr = sta ? sta->addr : bcast_addr;
676 646
677 wl12xx_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd); 647 wl1251_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd);
678 wl12xx_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN); 648 wl1251_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN);
679 wl12xx_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x", 649 wl1251_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x",
680 key->alg, key->keyidx, key->keylen, key->flags); 650 key->alg, key->keyidx, key->keylen, key->flags);
681 wl12xx_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen); 651 wl1251_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen);
652
653 if (is_zero_ether_addr(addr)) {
654 /* We dont support TX only encryption */
655 ret = -EOPNOTSUPP;
656 goto out;
657 }
682 658
683 mutex_lock(&wl->mutex); 659 mutex_lock(&wl->mutex);
684 660
661 ret = wl1251_ps_elp_wakeup(wl);
662 if (ret < 0)
663 goto out_unlock;
664
685 switch (cmd) { 665 switch (cmd) {
686 case SET_KEY: 666 case SET_KEY:
687 wl_key.key_action = KEY_ADD_OR_REPLACE; 667 wl_cmd->key_action = KEY_ADD_OR_REPLACE;
688 break; 668 break;
689 case DISABLE_KEY: 669 case DISABLE_KEY:
690 wl_key.key_action = KEY_REMOVE; 670 wl_cmd->key_action = KEY_REMOVE;
691 break; 671 break;
692 default: 672 default:
693 wl12xx_error("Unsupported key cmd 0x%x", cmd); 673 wl1251_error("Unsupported key cmd 0x%x", cmd);
694 break; 674 break;
695 } 675 }
696 676
697 ret = wl12xx_set_key_type(wl, &wl_key, cmd, key, addr); 677 ret = wl1251_set_key_type(wl, wl_cmd, cmd, key, addr);
698 if (ret < 0) { 678 if (ret < 0) {
699 wl12xx_error("Set KEY type failed"); 679 wl1251_error("Set KEY type failed");
700 goto out; 680 goto out_sleep;
701 } 681 }
702 682
703 if (wl_key.key_type != KEY_WEP_DEFAULT) 683 if (wl_cmd->key_type != KEY_WEP_DEFAULT)
704 memcpy(wl_key.addr, addr, ETH_ALEN); 684 memcpy(wl_cmd->addr, addr, ETH_ALEN);
705 685
706 if ((wl_key.key_type == KEY_TKIP_MIC_GROUP) || 686 if ((wl_cmd->key_type == KEY_TKIP_MIC_GROUP) ||
707 (wl_key.key_type == KEY_TKIP_MIC_PAIRWISE)) { 687 (wl_cmd->key_type == KEY_TKIP_MIC_PAIRWISE)) {
708 /* 688 /*
709 * We get the key in the following form: 689 * We get the key in the following form:
710 * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes) 690 * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes)
711 * but the target is expecting: 691 * but the target is expecting:
712 * TKIP - RX MIC - TX MIC 692 * TKIP - RX MIC - TX MIC
713 */ 693 */
714 memcpy(wl_key.key, key->key, 16); 694 memcpy(wl_cmd->key, key->key, 16);
715 memcpy(wl_key.key + 16, key->key + 24, 8); 695 memcpy(wl_cmd->key + 16, key->key + 24, 8);
716 memcpy(wl_key.key + 24, key->key + 16, 8); 696 memcpy(wl_cmd->key + 24, key->key + 16, 8);
717 697
718 } else { 698 } else {
719 memcpy(wl_key.key, key->key, key->keylen); 699 memcpy(wl_cmd->key, key->key, key->keylen);
720 } 700 }
721 wl_key.key_size = key->keylen; 701 wl_cmd->key_size = key->keylen;
722 702
723 wl_key.id = key->keyidx; 703 wl_cmd->id = key->keyidx;
724 wl_key.ssid_profile = 0; 704 wl_cmd->ssid_profile = 0;
725 705
726 wl12xx_dump(DEBUG_CRYPT, "TARGET KEY: ", &wl_key, sizeof(wl_key)); 706 wl1251_dump(DEBUG_CRYPT, "TARGET KEY: ", wl_cmd, sizeof(*wl_cmd));
727 707
728 if (wl12xx_cmd_send(wl, CMD_SET_KEYS, &wl_key, sizeof(wl_key)) < 0) { 708 ret = wl1251_cmd_send(wl, CMD_SET_KEYS, wl_cmd, sizeof(*wl_cmd));
729 wl12xx_error("Set KEY failed"); 709 if (ret < 0) {
730 ret = -EOPNOTSUPP; 710 wl1251_warning("could not set keys");
731 goto out; 711 goto out_sleep;
732 } 712 }
733 713
734out: 714out_sleep:
715 wl1251_ps_elp_sleep(wl);
716
717out_unlock:
735 mutex_unlock(&wl->mutex); 718 mutex_unlock(&wl->mutex);
719
720out:
721 kfree(wl_cmd);
722
736 return ret; 723 return ret;
737} 724}
738 725
739static int wl12xx_build_basic_rates(char *rates) 726static int wl1251_build_basic_rates(char *rates)
740{ 727{
741 u8 index = 0; 728 u8 index = 0;
742 729
@@ -748,7 +735,7 @@ static int wl12xx_build_basic_rates(char *rates)
748 return index; 735 return index;
749} 736}
750 737
751static int wl12xx_build_extended_rates(char *rates) 738static int wl1251_build_extended_rates(char *rates)
752{ 739{
753 u8 index = 0; 740 u8 index = 0;
754 741
@@ -765,7 +752,7 @@ static int wl12xx_build_extended_rates(char *rates)
765} 752}
766 753
767 754
768static int wl12xx_build_probe_req(struct wl12xx *wl, u8 *ssid, size_t ssid_len) 755static int wl1251_build_probe_req(struct wl1251 *wl, u8 *ssid, size_t ssid_len)
769{ 756{
770 struct wl12xx_probe_req_template template; 757 struct wl12xx_probe_req_template template;
771 struct wl12xx_ie_rates *rates; 758 struct wl12xx_ie_rates *rates;
@@ -792,31 +779,30 @@ static int wl12xx_build_probe_req(struct wl12xx *wl, u8 *ssid, size_t ssid_len)
792 /* Basic Rates */ 779 /* Basic Rates */
793 rates = (struct wl12xx_ie_rates *)ptr; 780 rates = (struct wl12xx_ie_rates *)ptr;
794 rates->header.id = WLAN_EID_SUPP_RATES; 781 rates->header.id = WLAN_EID_SUPP_RATES;
795 rates->header.len = wl12xx_build_basic_rates(rates->rates); 782 rates->header.len = wl1251_build_basic_rates(rates->rates);
796 size += sizeof(struct wl12xx_ie_header) + rates->header.len; 783 size += sizeof(struct wl12xx_ie_header) + rates->header.len;
797 ptr += sizeof(struct wl12xx_ie_header) + rates->header.len; 784 ptr += sizeof(struct wl12xx_ie_header) + rates->header.len;
798 785
799 /* Extended rates */ 786 /* Extended rates */
800 rates = (struct wl12xx_ie_rates *)ptr; 787 rates = (struct wl12xx_ie_rates *)ptr;
801 rates->header.id = WLAN_EID_EXT_SUPP_RATES; 788 rates->header.id = WLAN_EID_EXT_SUPP_RATES;
802 rates->header.len = wl12xx_build_extended_rates(rates->rates); 789 rates->header.len = wl1251_build_extended_rates(rates->rates);
803 size += sizeof(struct wl12xx_ie_header) + rates->header.len; 790 size += sizeof(struct wl12xx_ie_header) + rates->header.len;
804 791
805 wl12xx_dump(DEBUG_SCAN, "PROBE REQ: ", &template, size); 792 wl1251_dump(DEBUG_SCAN, "PROBE REQ: ", &template, size);
806 793
807 return wl12xx_cmd_template_set(wl, CMD_PROBE_REQ, &template, 794 return wl1251_cmd_template_set(wl, CMD_PROBE_REQ, &template,
808 size); 795 size);
809} 796}
810 797
811static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len, 798static int wl1251_hw_scan(struct wl1251 *wl, u8 *ssid, size_t len,
812 u8 active_scan, u8 high_prio, u8 num_channels, 799 u8 active_scan, u8 high_prio, u8 num_channels,
813 u8 probe_requests) 800 u8 probe_requests)
814{ 801{
802 struct wl1251_cmd_trigger_scan_to *trigger = NULL;
803 struct cmd_scan *params = NULL;
815 int i, ret; 804 int i, ret;
816 u32 split_scan = 0;
817 u16 scan_options = 0; 805 u16 scan_options = 0;
818 struct cmd_scan *params;
819 struct wl12xx_command *cmd_answer;
820 806
821 if (wl->scanning) 807 if (wl->scanning)
822 return -EINVAL; 808 return -EINVAL;
@@ -864,33 +850,38 @@ static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len,
864 memset(params->params.ssid, 0, 32); 850 memset(params->params.ssid, 0, 32);
865 } 851 }
866 852
867 ret = wl12xx_build_probe_req(wl, ssid, len); 853 ret = wl1251_build_probe_req(wl, ssid, len);
868 if (ret < 0) { 854 if (ret < 0) {
869 wl12xx_error("PROBE request template failed"); 855 wl1251_error("PROBE request template failed");
870 goto out; 856 goto out;
871 } 857 }
872 858
873 ret = wl12xx_cmd_send(wl, CMD_TRIGGER_SCAN_TO, &split_scan, 859 trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
874 sizeof(u32)); 860 if (!trigger)
861 goto out;
862
863 trigger->timeout = 0;
864
865 ret = wl1251_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
866 sizeof(*trigger));
875 if (ret < 0) { 867 if (ret < 0) {
876 wl12xx_error("Split SCAN failed"); 868 wl1251_error("trigger scan to failed for hw scan");
877 goto out; 869 goto out;
878 } 870 }
879 871
880 wl12xx_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params)); 872 wl1251_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params));
881 873
882 wl->scanning = true; 874 wl->scanning = true;
883 875
884 ret = wl12xx_cmd_send(wl, CMD_SCAN, params, sizeof(*params)); 876 ret = wl1251_cmd_send(wl, CMD_SCAN, params, sizeof(*params));
885 if (ret < 0) 877 if (ret < 0)
886 wl12xx_error("SCAN failed"); 878 wl1251_error("SCAN failed");
887 879
888 wl12xx_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params)); 880 wl1251_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params));
889 881
890 cmd_answer = (struct wl12xx_command *) params; 882 if (params->header.status != CMD_STATUS_SUCCESS) {
891 if (cmd_answer->status != CMD_STATUS_SUCCESS) { 883 wl1251_error("TEST command answer error: %d",
892 wl12xx_error("TEST command answer error: %d", 884 params->header.status);
893 cmd_answer->status);
894 wl->scanning = false; 885 wl->scanning = false;
895 ret = -EIO; 886 ret = -EIO;
896 goto out; 887 goto out;
@@ -902,15 +893,15 @@ out:
902 893
903} 894}
904 895
905static int wl12xx_op_hw_scan(struct ieee80211_hw *hw, 896static int wl1251_op_hw_scan(struct ieee80211_hw *hw,
906 struct cfg80211_scan_request *req) 897 struct cfg80211_scan_request *req)
907{ 898{
908 struct wl12xx *wl = hw->priv; 899 struct wl1251 *wl = hw->priv;
909 int ret; 900 int ret;
910 u8 *ssid = NULL; 901 u8 *ssid = NULL;
911 size_t ssid_len = 0; 902 size_t ssid_len = 0;
912 903
913 wl12xx_debug(DEBUG_MAC80211, "mac80211 hw scan"); 904 wl1251_debug(DEBUG_MAC80211, "mac80211 hw scan");
914 905
915 if (req->n_ssids) { 906 if (req->n_ssids) {
916 ssid = req->ssids[0].ssid; 907 ssid = req->ssids[0].ssid;
@@ -918,85 +909,108 @@ static int wl12xx_op_hw_scan(struct ieee80211_hw *hw,
918 } 909 }
919 910
920 mutex_lock(&wl->mutex); 911 mutex_lock(&wl->mutex);
921 ret = wl12xx_hw_scan(hw->priv, ssid, ssid_len, 1, 0, 13, 3); 912
913 ret = wl1251_ps_elp_wakeup(wl);
914 if (ret < 0)
915 goto out;
916
917 ret = wl1251_hw_scan(hw->priv, ssid, ssid_len, 1, 0, 13, 3);
918
919 wl1251_ps_elp_sleep(wl);
920
921out:
922 mutex_unlock(&wl->mutex); 922 mutex_unlock(&wl->mutex);
923 923
924 return ret; 924 return ret;
925} 925}
926 926
927static int wl12xx_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) 927static int wl1251_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
928{ 928{
929 struct wl12xx *wl = hw->priv; 929 struct wl1251 *wl = hw->priv;
930 int ret; 930 int ret;
931 931
932 ret = wl12xx_acx_rts_threshold(wl, (u16) value); 932 mutex_lock(&wl->mutex);
933 933
934 ret = wl1251_ps_elp_wakeup(wl);
934 if (ret < 0) 935 if (ret < 0)
935 wl12xx_warning("wl12xx_op_set_rts_threshold failed: %d", ret); 936 goto out;
937
938 ret = wl1251_acx_rts_threshold(wl, (u16) value);
939 if (ret < 0)
940 wl1251_warning("wl1251_op_set_rts_threshold failed: %d", ret);
941
942 wl1251_ps_elp_sleep(wl);
943
944out:
945 mutex_unlock(&wl->mutex);
936 946
937 return ret; 947 return ret;
938} 948}
939 949
940static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw, 950static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw,
941 struct ieee80211_vif *vif, 951 struct ieee80211_vif *vif,
942 struct ieee80211_bss_conf *bss_conf, 952 struct ieee80211_bss_conf *bss_conf,
943 u32 changed) 953 u32 changed)
944{ 954{
945 enum acx_ps_mode mode; 955 enum wl1251_cmd_ps_mode mode;
946 struct wl12xx *wl = hw->priv; 956 struct wl1251 *wl = hw->priv;
947 struct sk_buff *beacon; 957 struct sk_buff *beacon;
948 int ret; 958 int ret;
949 959
950 wl12xx_debug(DEBUG_MAC80211, "mac80211 bss info changed"); 960 wl1251_debug(DEBUG_MAC80211, "mac80211 bss info changed");
951 961
952 mutex_lock(&wl->mutex); 962 mutex_lock(&wl->mutex);
953 963
964 ret = wl1251_ps_elp_wakeup(wl);
965 if (ret < 0)
966 goto out;
967
954 if (changed & BSS_CHANGED_ASSOC) { 968 if (changed & BSS_CHANGED_ASSOC) {
955 if (bss_conf->assoc) { 969 if (bss_conf->assoc) {
956 wl->aid = bss_conf->aid; 970 wl->aid = bss_conf->aid;
957 971
958 ret = wl12xx_build_ps_poll(wl, wl->aid); 972 ret = wl1251_build_ps_poll(wl, wl->aid);
959 if (ret < 0) 973 if (ret < 0)
960 goto out; 974 goto out_sleep;
961 975
962 ret = wl12xx_acx_aid(wl, wl->aid); 976 ret = wl1251_acx_aid(wl, wl->aid);
963 if (ret < 0) 977 if (ret < 0)
964 goto out; 978 goto out_sleep;
965 979
966 /* If we want to go in PSM but we're not there yet */ 980 /* If we want to go in PSM but we're not there yet */
967 if (wl->psm_requested && !wl->psm) { 981 if (wl->psm_requested && !wl->psm) {
968 mode = STATION_POWER_SAVE_MODE; 982 mode = STATION_POWER_SAVE_MODE;
969 ret = wl12xx_ps_set_mode(wl, mode); 983 ret = wl1251_ps_set_mode(wl, mode);
970 if (ret < 0) 984 if (ret < 0)
971 goto out; 985 goto out_sleep;
972 } 986 }
973 } 987 }
974 } 988 }
975 if (changed & BSS_CHANGED_ERP_SLOT) { 989 if (changed & BSS_CHANGED_ERP_SLOT) {
976 if (bss_conf->use_short_slot) 990 if (bss_conf->use_short_slot)
977 ret = wl12xx_acx_slot(wl, SLOT_TIME_SHORT); 991 ret = wl1251_acx_slot(wl, SLOT_TIME_SHORT);
978 else 992 else
979 ret = wl12xx_acx_slot(wl, SLOT_TIME_LONG); 993 ret = wl1251_acx_slot(wl, SLOT_TIME_LONG);
980 if (ret < 0) { 994 if (ret < 0) {
981 wl12xx_warning("Set slot time failed %d", ret); 995 wl1251_warning("Set slot time failed %d", ret);
982 goto out; 996 goto out_sleep;
983 } 997 }
984 } 998 }
985 999
986 if (changed & BSS_CHANGED_ERP_PREAMBLE) { 1000 if (changed & BSS_CHANGED_ERP_PREAMBLE) {
987 if (bss_conf->use_short_preamble) 1001 if (bss_conf->use_short_preamble)
988 wl12xx_acx_set_preamble(wl, ACX_PREAMBLE_SHORT); 1002 wl1251_acx_set_preamble(wl, ACX_PREAMBLE_SHORT);
989 else 1003 else
990 wl12xx_acx_set_preamble(wl, ACX_PREAMBLE_LONG); 1004 wl1251_acx_set_preamble(wl, ACX_PREAMBLE_LONG);
991 } 1005 }
992 1006
993 if (changed & BSS_CHANGED_ERP_CTS_PROT) { 1007 if (changed & BSS_CHANGED_ERP_CTS_PROT) {
994 if (bss_conf->use_cts_prot) 1008 if (bss_conf->use_cts_prot)
995 ret = wl12xx_acx_cts_protect(wl, CTSPROTECT_ENABLE); 1009 ret = wl1251_acx_cts_protect(wl, CTSPROTECT_ENABLE);
996 else 1010 else
997 ret = wl12xx_acx_cts_protect(wl, CTSPROTECT_DISABLE); 1011 ret = wl1251_acx_cts_protect(wl, CTSPROTECT_DISABLE);
998 if (ret < 0) { 1012 if (ret < 0) {
999 wl12xx_warning("Set ctsprotect failed %d", ret); 1013 wl1251_warning("Set ctsprotect failed %d", ret);
1000 goto out; 1014 goto out;
1001 } 1015 }
1002 } 1016 }
@@ -1004,20 +1018,22 @@ static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw,
1004 if (changed & BSS_CHANGED_BSSID) { 1018 if (changed & BSS_CHANGED_BSSID) {
1005 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); 1019 memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN);
1006 1020
1007 ret = wl12xx_build_null_data(wl); 1021 ret = wl1251_build_null_data(wl);
1008 if (ret < 0) 1022 if (ret < 0)
1009 goto out; 1023 goto out;
1010 1024
1011 if (wl->bss_type != BSS_TYPE_IBSS) { 1025 if (wl->bss_type != BSS_TYPE_IBSS) {
1012 ret = wl12xx_cmd_join(wl, wl->bss_type, 5, 100, 1); 1026 ret = wl1251_cmd_join(wl, wl->bss_type, 5, 100, 1);
1013 if (ret < 0) 1027 if (ret < 0)
1014 goto out; 1028 goto out_sleep;
1029 wl1251_warning("Set ctsprotect failed %d", ret);
1030 goto out_sleep;
1015 } 1031 }
1016 } 1032 }
1017 1033
1018 if (changed & BSS_CHANGED_BEACON) { 1034 if (changed & BSS_CHANGED_BEACON) {
1019 beacon = ieee80211_beacon_get(hw, vif); 1035 beacon = ieee80211_beacon_get(hw, vif);
1020 ret = wl12xx_cmd_template_set(wl, CMD_BEACON, beacon->data, 1036 ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data,
1021 beacon->len); 1037 beacon->len);
1022 1038
1023 if (ret < 0) { 1039 if (ret < 0) {
@@ -1025,7 +1041,7 @@ static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw,
1025 goto out; 1041 goto out;
1026 } 1042 }
1027 1043
1028 ret = wl12xx_cmd_template_set(wl, CMD_PROBE_RESP, beacon->data, 1044 ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, beacon->data,
1029 beacon->len); 1045 beacon->len);
1030 1046
1031 dev_kfree_skb(beacon); 1047 dev_kfree_skb(beacon);
@@ -1033,19 +1049,22 @@ static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw,
1033 if (ret < 0) 1049 if (ret < 0)
1034 goto out; 1050 goto out;
1035 1051
1036 ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0); 1052 ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0);
1037 1053
1038 if (ret < 0) 1054 if (ret < 0)
1039 goto out; 1055 goto out;
1040 } 1056 }
1041 1057
1058out_sleep:
1059 wl1251_ps_elp_sleep(wl);
1060
1042out: 1061out:
1043 mutex_unlock(&wl->mutex); 1062 mutex_unlock(&wl->mutex);
1044} 1063}
1045 1064
1046 1065
1047/* can't be const, mac80211 writes to this */ 1066/* can't be const, mac80211 writes to this */
1048static struct ieee80211_rate wl12xx_rates[] = { 1067static struct ieee80211_rate wl1251_rates[] = {
1049 { .bitrate = 10, 1068 { .bitrate = 10,
1050 .hw_value = 0x1, 1069 .hw_value = 0x1,
1051 .hw_value_short = 0x1, }, 1070 .hw_value_short = 0x1, },
@@ -1088,7 +1107,7 @@ static struct ieee80211_rate wl12xx_rates[] = {
1088}; 1107};
1089 1108
1090/* can't be const, mac80211 writes to this */ 1109/* can't be const, mac80211 writes to this */
1091static struct ieee80211_channel wl12xx_channels[] = { 1110static struct ieee80211_channel wl1251_channels[] = {
1092 { .hw_value = 1, .center_freq = 2412}, 1111 { .hw_value = 1, .center_freq = 2412},
1093 { .hw_value = 2, .center_freq = 2417}, 1112 { .hw_value = 2, .center_freq = 2417},
1094 { .hw_value = 3, .center_freq = 2422}, 1113 { .hw_value = 3, .center_freq = 2422},
@@ -1105,28 +1124,28 @@ static struct ieee80211_channel wl12xx_channels[] = {
1105}; 1124};
1106 1125
1107/* can't be const, mac80211 writes to this */ 1126/* can't be const, mac80211 writes to this */
1108static struct ieee80211_supported_band wl12xx_band_2ghz = { 1127static struct ieee80211_supported_band wl1251_band_2ghz = {
1109 .channels = wl12xx_channels, 1128 .channels = wl1251_channels,
1110 .n_channels = ARRAY_SIZE(wl12xx_channels), 1129 .n_channels = ARRAY_SIZE(wl1251_channels),
1111 .bitrates = wl12xx_rates, 1130 .bitrates = wl1251_rates,
1112 .n_bitrates = ARRAY_SIZE(wl12xx_rates), 1131 .n_bitrates = ARRAY_SIZE(wl1251_rates),
1113}; 1132};
1114 1133
1115static const struct ieee80211_ops wl12xx_ops = { 1134static const struct ieee80211_ops wl1251_ops = {
1116 .start = wl12xx_op_start, 1135 .start = wl1251_op_start,
1117 .stop = wl12xx_op_stop, 1136 .stop = wl1251_op_stop,
1118 .add_interface = wl12xx_op_add_interface, 1137 .add_interface = wl1251_op_add_interface,
1119 .remove_interface = wl12xx_op_remove_interface, 1138 .remove_interface = wl1251_op_remove_interface,
1120 .config = wl12xx_op_config, 1139 .config = wl1251_op_config,
1121 .configure_filter = wl12xx_op_configure_filter, 1140 .configure_filter = wl1251_op_configure_filter,
1122 .tx = wl12xx_op_tx, 1141 .tx = wl1251_op_tx,
1123 .set_key = wl12xx_op_set_key, 1142 .set_key = wl1251_op_set_key,
1124 .hw_scan = wl12xx_op_hw_scan, 1143 .hw_scan = wl1251_op_hw_scan,
1125 .bss_info_changed = wl12xx_op_bss_info_changed, 1144 .bss_info_changed = wl1251_op_bss_info_changed,
1126 .set_rts_threshold = wl12xx_op_set_rts_threshold, 1145 .set_rts_threshold = wl1251_op_set_rts_threshold,
1127}; 1146};
1128 1147
1129static int wl12xx_register_hw(struct wl12xx *wl) 1148static int wl1251_register_hw(struct wl1251 *wl)
1130{ 1149{
1131 int ret; 1150 int ret;
1132 1151
@@ -1137,22 +1156,22 @@ static int wl12xx_register_hw(struct wl12xx *wl)
1137 1156
1138 ret = ieee80211_register_hw(wl->hw); 1157 ret = ieee80211_register_hw(wl->hw);
1139 if (ret < 0) { 1158 if (ret < 0) {
1140 wl12xx_error("unable to register mac80211 hw: %d", ret); 1159 wl1251_error("unable to register mac80211 hw: %d", ret);
1141 return ret; 1160 return ret;
1142 } 1161 }
1143 1162
1144 wl->mac80211_registered = true; 1163 wl->mac80211_registered = true;
1145 1164
1146 wl12xx_notice("loaded"); 1165 wl1251_notice("loaded");
1147 1166
1148 return 0; 1167 return 0;
1149} 1168}
1150 1169
1151static int wl12xx_init_ieee80211(struct wl12xx *wl) 1170static int wl1251_init_ieee80211(struct wl1251 *wl)
1152{ 1171{
1153 /* The tx descriptor buffer and the TKIP space */ 1172 /* The tx descriptor buffer and the TKIP space */
1154 wl->hw->extra_tx_headroom = sizeof(struct tx_double_buffer_desc) 1173 wl->hw->extra_tx_headroom = sizeof(struct tx_double_buffer_desc)
1155 + WL12XX_TKIP_IV_SPACE; 1174 + WL1251_TKIP_IV_SPACE;
1156 1175
1157 /* unit us */ 1176 /* unit us */
1158 /* FIXME: find a proper value */ 1177 /* FIXME: find a proper value */
@@ -1163,31 +1182,31 @@ static int wl12xx_init_ieee80211(struct wl12xx *wl)
1163 1182
1164 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 1183 wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
1165 wl->hw->wiphy->max_scan_ssids = 1; 1184 wl->hw->wiphy->max_scan_ssids = 1;
1166 wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl12xx_band_2ghz; 1185 wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl1251_band_2ghz;
1167 1186
1168 SET_IEEE80211_DEV(wl->hw, &wl->spi->dev); 1187 SET_IEEE80211_DEV(wl->hw, &wl->spi->dev);
1169 1188
1170 return 0; 1189 return 0;
1171} 1190}
1172 1191
1173#define WL12XX_DEFAULT_CHANNEL 1 1192#define WL1251_DEFAULT_CHANNEL 1
1174static int __devinit wl12xx_probe(struct spi_device *spi) 1193static int __devinit wl1251_probe(struct spi_device *spi)
1175{ 1194{
1176 struct wl12xx_platform_data *pdata; 1195 struct wl12xx_platform_data *pdata;
1177 struct ieee80211_hw *hw; 1196 struct ieee80211_hw *hw;
1178 struct wl12xx *wl; 1197 struct wl1251 *wl;
1179 int ret, i; 1198 int ret, i;
1180 static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; 1199 static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf};
1181 1200
1182 pdata = spi->dev.platform_data; 1201 pdata = spi->dev.platform_data;
1183 if (!pdata) { 1202 if (!pdata) {
1184 wl12xx_error("no platform data"); 1203 wl1251_error("no platform data");
1185 return -ENODEV; 1204 return -ENODEV;
1186 } 1205 }
1187 1206
1188 hw = ieee80211_alloc_hw(sizeof(*wl), &wl12xx_ops); 1207 hw = ieee80211_alloc_hw(sizeof(*wl), &wl1251_ops);
1189 if (!hw) { 1208 if (!hw) {
1190 wl12xx_error("could not alloc ieee80211_hw"); 1209 wl1251_error("could not alloc ieee80211_hw");
1191 return -ENOMEM; 1210 return -ENOMEM;
1192 } 1211 }
1193 1212
@@ -1202,9 +1221,8 @@ static int __devinit wl12xx_probe(struct spi_device *spi)
1202 1221
1203 skb_queue_head_init(&wl->tx_queue); 1222 skb_queue_head_init(&wl->tx_queue);
1204 1223
1205 INIT_WORK(&wl->tx_work, wl12xx_tx_work); 1224 INIT_WORK(&wl->filter_work, wl1251_filter_work);
1206 INIT_WORK(&wl->filter_work, wl12xx_filter_work); 1225 wl->channel = WL1251_DEFAULT_CHANNEL;
1207 wl->channel = WL12XX_DEFAULT_CHANNEL;
1208 wl->scanning = false; 1226 wl->scanning = false;
1209 wl->default_key = 0; 1227 wl->default_key = 0;
1210 wl->listen_int = 1; 1228 wl->listen_int = 1;
@@ -1212,17 +1230,17 @@ static int __devinit wl12xx_probe(struct spi_device *spi)
1212 wl->rx_handled = 0; 1230 wl->rx_handled = 0;
1213 wl->rx_current_buffer = 0; 1231 wl->rx_current_buffer = 0;
1214 wl->rx_last_id = 0; 1232 wl->rx_last_id = 0;
1215 wl->rx_config = WL12XX_DEFAULT_RX_CONFIG; 1233 wl->rx_config = WL1251_DEFAULT_RX_CONFIG;
1216 wl->rx_filter = WL12XX_DEFAULT_RX_FILTER; 1234 wl->rx_filter = WL1251_DEFAULT_RX_FILTER;
1217 wl->elp = false; 1235 wl->elp = false;
1218 wl->psm = 0; 1236 wl->psm = 0;
1219 wl->psm_requested = false; 1237 wl->psm_requested = false;
1220 wl->tx_queue_stopped = false; 1238 wl->tx_queue_stopped = false;
1221 wl->power_level = WL12XX_DEFAULT_POWER_LEVEL; 1239 wl->power_level = WL1251_DEFAULT_POWER_LEVEL;
1222 1240
1223 /* We use the default power on sleep time until we know which chip 1241 /* We use the default power on sleep time until we know which chip
1224 * we're using */ 1242 * we're using */
1225 wl->chip.power_on_sleep = WL12XX_DEFAULT_POWER_ON_SLEEP; 1243 wl->chip.power_on_sleep = WL1251_DEFAULT_POWER_ON_SLEEP;
1226 1244
1227 for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++) 1245 for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
1228 wl->tx_frames[i] = NULL; 1246 wl->tx_frames[i] = NULL;
@@ -1236,37 +1254,46 @@ static int __devinit wl12xx_probe(struct spi_device *spi)
1236 memcpy(wl->mac_addr, nokia_oui, 3); 1254 memcpy(wl->mac_addr, nokia_oui, 3);
1237 get_random_bytes(wl->mac_addr + 3, 3); 1255 get_random_bytes(wl->mac_addr + 3, 3);
1238 1256
1239 wl->state = WL12XX_STATE_OFF; 1257 wl->state = WL1251_STATE_OFF;
1240 mutex_init(&wl->mutex); 1258 mutex_init(&wl->mutex);
1241 1259
1242 wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE; 1260 wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE;
1243 wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE; 1261 wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE;
1244 1262
1263 wl->rx_descriptor = kmalloc(sizeof(*wl->rx_descriptor), GFP_KERNEL);
1264 if (!wl->rx_descriptor) {
1265 wl1251_error("could not allocate memory for rx descriptor");
1266 ret = -ENOMEM;
1267 goto out_free;
1268 }
1269
1245 /* This is the only SPI value that we need to set here, the rest 1270 /* This is the only SPI value that we need to set here, the rest
1246 * comes from the board-peripherals file */ 1271 * comes from the board-peripherals file */
1247 spi->bits_per_word = 32; 1272 spi->bits_per_word = 32;
1248 1273
1249 ret = spi_setup(spi); 1274 ret = spi_setup(spi);
1250 if (ret < 0) { 1275 if (ret < 0) {
1251 wl12xx_error("spi_setup failed"); 1276 wl1251_error("spi_setup failed");
1252 goto out_free; 1277 goto out_free;
1253 } 1278 }
1254 1279
1255 wl->set_power = pdata->set_power; 1280 wl->set_power = pdata->set_power;
1256 if (!wl->set_power) { 1281 if (!wl->set_power) {
1257 wl12xx_error("set power function missing in platform data"); 1282 wl1251_error("set power function missing in platform data");
1258 return -ENODEV; 1283 ret = -ENODEV;
1284 goto out_free;
1259 } 1285 }
1260 1286
1261 wl->irq = spi->irq; 1287 wl->irq = spi->irq;
1262 if (wl->irq < 0) { 1288 if (wl->irq < 0) {
1263 wl12xx_error("irq missing in platform data"); 1289 wl1251_error("irq missing in platform data");
1264 return -ENODEV; 1290 ret = -ENODEV;
1291 goto out_free;
1265 } 1292 }
1266 1293
1267 ret = request_irq(wl->irq, wl12xx_irq, 0, DRIVER_NAME, wl); 1294 ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl);
1268 if (ret < 0) { 1295 if (ret < 0) {
1269 wl12xx_error("request_irq() failed: %d", ret); 1296 wl1251_error("request_irq() failed: %d", ret);
1270 goto out_free; 1297 goto out_free;
1271 } 1298 }
1272 1299
@@ -1274,17 +1301,17 @@ static int __devinit wl12xx_probe(struct spi_device *spi)
1274 1301
1275 disable_irq(wl->irq); 1302 disable_irq(wl->irq);
1276 1303
1277 ret = wl12xx_init_ieee80211(wl); 1304 ret = wl1251_init_ieee80211(wl);
1278 if (ret) 1305 if (ret)
1279 goto out_irq; 1306 goto out_irq;
1280 1307
1281 ret = wl12xx_register_hw(wl); 1308 ret = wl1251_register_hw(wl);
1282 if (ret) 1309 if (ret)
1283 goto out_irq; 1310 goto out_irq;
1284 1311
1285 wl12xx_debugfs_init(wl); 1312 wl1251_debugfs_init(wl);
1286 1313
1287 wl12xx_notice("initialized"); 1314 wl1251_notice("initialized");
1288 1315
1289 return 0; 1316 return 0;
1290 1317
@@ -1292,18 +1319,21 @@ static int __devinit wl12xx_probe(struct spi_device *spi)
1292 free_irq(wl->irq, wl); 1319 free_irq(wl->irq, wl);
1293 1320
1294 out_free: 1321 out_free:
1322 kfree(wl->rx_descriptor);
1323 wl->rx_descriptor = NULL;
1324
1295 ieee80211_free_hw(hw); 1325 ieee80211_free_hw(hw);
1296 1326
1297 return ret; 1327 return ret;
1298} 1328}
1299 1329
1300static int __devexit wl12xx_remove(struct spi_device *spi) 1330static int __devexit wl1251_remove(struct spi_device *spi)
1301{ 1331{
1302 struct wl12xx *wl = dev_get_drvdata(&spi->dev); 1332 struct wl1251 *wl = dev_get_drvdata(&spi->dev);
1303 1333
1304 ieee80211_unregister_hw(wl->hw); 1334 ieee80211_unregister_hw(wl->hw);
1305 1335
1306 wl12xx_debugfs_exit(wl); 1336 wl1251_debugfs_exit(wl);
1307 1337
1308 free_irq(wl->irq, wl); 1338 free_irq(wl->irq, wl);
1309 kfree(wl->target_mem_map); 1339 kfree(wl->target_mem_map);
@@ -1312,30 +1342,35 @@ static int __devexit wl12xx_remove(struct spi_device *spi)
1312 wl->fw = NULL; 1342 wl->fw = NULL;
1313 kfree(wl->nvs); 1343 kfree(wl->nvs);
1314 wl->nvs = NULL; 1344 wl->nvs = NULL;
1345
1346 kfree(wl->rx_descriptor);
1347 wl->rx_descriptor = NULL;
1348
1315 ieee80211_free_hw(wl->hw); 1349 ieee80211_free_hw(wl->hw);
1316 1350
1317 return 0; 1351 return 0;
1318} 1352}
1319 1353
1320 1354
1321static struct spi_driver wl12xx_spi_driver = { 1355static struct spi_driver wl1251_spi_driver = {
1322 .driver = { 1356 .driver = {
1357 /* FIXME: use wl12xx name to not break the user space */
1323 .name = "wl12xx", 1358 .name = "wl12xx",
1324 .bus = &spi_bus_type, 1359 .bus = &spi_bus_type,
1325 .owner = THIS_MODULE, 1360 .owner = THIS_MODULE,
1326 }, 1361 },
1327 1362
1328 .probe = wl12xx_probe, 1363 .probe = wl1251_probe,
1329 .remove = __devexit_p(wl12xx_remove), 1364 .remove = __devexit_p(wl1251_remove),
1330}; 1365};
1331 1366
1332static int __init wl12xx_init(void) 1367static int __init wl1251_init(void)
1333{ 1368{
1334 int ret; 1369 int ret;
1335 1370
1336 ret = spi_register_driver(&wl12xx_spi_driver); 1371 ret = spi_register_driver(&wl1251_spi_driver);
1337 if (ret < 0) { 1372 if (ret < 0) {
1338 wl12xx_error("failed to register spi driver: %d", ret); 1373 wl1251_error("failed to register spi driver: %d", ret);
1339 goto out; 1374 goto out;
1340 } 1375 }
1341 1376
@@ -1343,15 +1378,15 @@ out:
1343 return ret; 1378 return ret;
1344} 1379}
1345 1380
1346static void __exit wl12xx_exit(void) 1381static void __exit wl1251_exit(void)
1347{ 1382{
1348 spi_unregister_driver(&wl12xx_spi_driver); 1383 spi_unregister_driver(&wl1251_spi_driver);
1349 1384
1350 wl12xx_notice("unloaded"); 1385 wl1251_notice("unloaded");
1351} 1386}
1352 1387
1353module_init(wl12xx_init); 1388module_init(wl1251_init);
1354module_exit(wl12xx_exit); 1389module_exit(wl1251_exit);
1355 1390
1356MODULE_LICENSE("GPL"); 1391MODULE_LICENSE("GPL");
1357MODULE_AUTHOR("Kalle Valo <Kalle.Valo@nokia.com>, " 1392MODULE_AUTHOR("Kalle Valo <Kalle.Valo@nokia.com>, "
diff --git a/drivers/net/wireless/wl12xx/wl1251_netlink.h b/drivers/net/wireless/wl12xx/wl1251_netlink.h
new file mode 100644
index 000000000000..ee36695e134e
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl1251_netlink.h
@@ -0,0 +1,30 @@
1/*
2 * This file is part of wl1251
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 *
6 * Contact: Kalle Valo <kalle.valo@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef __WL1251_NETLINK_H__
25#define __WL1251_NETLINK_H__
26
27int wl1251_nl_register(void);
28void wl1251_nl_unregister(void);
29
30#endif /* __WL1251_NETLINK_H__ */
diff --git a/drivers/net/wireless/wl12xx/wl1251.c b/drivers/net/wireless/wl12xx/wl1251_ops.c
index ce1561a41fa4..e7b9aab3682f 100644
--- a/drivers/net/wireless/wl12xx/wl1251.c
+++ b/drivers/net/wireless/wl12xx/wl1251_ops.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2008-2009 Nokia Corporation 4 * Copyright (C) 2008-2009 Nokia Corporation
5 * 5 *
@@ -24,18 +24,18 @@
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/module.h> 25#include <linux/module.h>
26 26
27#include "wl1251.h" 27#include "wl1251_ops.h"
28#include "reg.h" 28#include "reg.h"
29#include "spi.h" 29#include "wl1251_spi.h"
30#include "boot.h" 30#include "wl1251_boot.h"
31#include "event.h" 31#include "wl1251_event.h"
32#include "acx.h" 32#include "wl1251_acx.h"
33#include "tx.h" 33#include "wl1251_tx.h"
34#include "rx.h" 34#include "wl1251_rx.h"
35#include "ps.h" 35#include "wl1251_ps.h"
36#include "init.h" 36#include "wl1251_init.h"
37 37
38static struct wl12xx_partition_set wl1251_part_table[PART_TABLE_LEN] = { 38static struct wl1251_partition_set wl1251_part_table[PART_TABLE_LEN] = {
39 [PART_DOWN] = { 39 [PART_DOWN] = {
40 .mem = { 40 .mem = {
41 .start = 0x00000000, 41 .start = 0x00000000,
@@ -75,31 +75,31 @@ static enum wl12xx_acx_int_reg wl1251_acx_reg_table[ACX_REG_TABLE_LEN] = {
75 [ACX_REG_ECPU_CONTROL] = (REGISTERS_BASE + 0x0804) 75 [ACX_REG_ECPU_CONTROL] = (REGISTERS_BASE + 0x0804)
76}; 76};
77 77
78static int wl1251_upload_firmware(struct wl12xx *wl) 78static int wl1251_upload_firmware(struct wl1251 *wl)
79{ 79{
80 struct wl12xx_partition_set *p_table = wl->chip.p_table; 80 struct wl1251_partition_set *p_table = wl->chip.p_table;
81 int addr, chunk_num, partition_limit; 81 int addr, chunk_num, partition_limit;
82 size_t fw_data_len; 82 size_t fw_data_len;
83 u8 *p; 83 u8 *p;
84 84
85 /* whal_FwCtrl_LoadFwImageSm() */ 85 /* whal_FwCtrl_LoadFwImageSm() */
86 86
87 wl12xx_debug(DEBUG_BOOT, "chip id before fw upload: 0x%x", 87 wl1251_debug(DEBUG_BOOT, "chip id before fw upload: 0x%x",
88 wl12xx_reg_read32(wl, CHIP_ID_B)); 88 wl1251_reg_read32(wl, CHIP_ID_B));
89 89
90 /* 10.0 check firmware length and set partition */ 90 /* 10.0 check firmware length and set partition */
91 fw_data_len = (wl->fw[4] << 24) | (wl->fw[5] << 16) | 91 fw_data_len = (wl->fw[4] << 24) | (wl->fw[5] << 16) |
92 (wl->fw[6] << 8) | (wl->fw[7]); 92 (wl->fw[6] << 8) | (wl->fw[7]);
93 93
94 wl12xx_debug(DEBUG_BOOT, "fw_data_len %zu chunk_size %d", fw_data_len, 94 wl1251_debug(DEBUG_BOOT, "fw_data_len %zu chunk_size %d", fw_data_len,
95 CHUNK_SIZE); 95 CHUNK_SIZE);
96 96
97 if ((fw_data_len % 4) != 0) { 97 if ((fw_data_len % 4) != 0) {
98 wl12xx_error("firmware length not multiple of four"); 98 wl1251_error("firmware length not multiple of four");
99 return -EIO; 99 return -EIO;
100 } 100 }
101 101
102 wl12xx_set_partition(wl, 102 wl1251_set_partition(wl,
103 p_table[PART_DOWN].mem.start, 103 p_table[PART_DOWN].mem.start,
104 p_table[PART_DOWN].mem.size, 104 p_table[PART_DOWN].mem.size,
105 p_table[PART_DOWN].reg.start, 105 p_table[PART_DOWN].reg.start,
@@ -118,7 +118,7 @@ static int wl1251_upload_firmware(struct wl12xx *wl)
118 chunk_num * CHUNK_SIZE; 118 chunk_num * CHUNK_SIZE;
119 partition_limit = chunk_num * CHUNK_SIZE + 119 partition_limit = chunk_num * CHUNK_SIZE +
120 p_table[PART_DOWN].mem.size; 120 p_table[PART_DOWN].mem.size;
121 wl12xx_set_partition(wl, 121 wl1251_set_partition(wl,
122 addr, 122 addr,
123 p_table[PART_DOWN].mem.size, 123 p_table[PART_DOWN].mem.size,
124 p_table[PART_DOWN].reg.start, 124 p_table[PART_DOWN].reg.start,
@@ -128,9 +128,9 @@ static int wl1251_upload_firmware(struct wl12xx *wl)
128 /* 10.3 upload the chunk */ 128 /* 10.3 upload the chunk */
129 addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE; 129 addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE;
130 p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; 130 p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE;
131 wl12xx_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x", 131 wl1251_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x",
132 p, addr); 132 p, addr);
133 wl12xx_spi_mem_write(wl, addr, p, CHUNK_SIZE); 133 wl1251_spi_mem_write(wl, addr, p, CHUNK_SIZE);
134 134
135 chunk_num++; 135 chunk_num++;
136 } 136 }
@@ -138,14 +138,14 @@ static int wl1251_upload_firmware(struct wl12xx *wl)
138 /* 10.4 upload the last chunk */ 138 /* 10.4 upload the last chunk */
139 addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE; 139 addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE;
140 p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; 140 p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE;
141 wl12xx_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x", 141 wl1251_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x",
142 fw_data_len % CHUNK_SIZE, p, addr); 142 fw_data_len % CHUNK_SIZE, p, addr);
143 wl12xx_spi_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE); 143 wl1251_spi_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE);
144 144
145 return 0; 145 return 0;
146} 146}
147 147
148static int wl1251_upload_nvs(struct wl12xx *wl) 148static int wl1251_upload_nvs(struct wl1251 *wl)
149{ 149{
150 size_t nvs_len, nvs_bytes_written, burst_len; 150 size_t nvs_len, nvs_bytes_written, burst_len;
151 int nvs_start, i; 151 int nvs_start, i;
@@ -181,10 +181,10 @@ static int wl1251_upload_nvs(struct wl12xx *wl)
181 val = (nvs_ptr[0] | (nvs_ptr[1] << 8) 181 val = (nvs_ptr[0] | (nvs_ptr[1] << 8)
182 | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); 182 | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24));
183 183
184 wl12xx_debug(DEBUG_BOOT, 184 wl1251_debug(DEBUG_BOOT,
185 "nvs burst write 0x%x: 0x%x", 185 "nvs burst write 0x%x: 0x%x",
186 dest_addr, val); 186 dest_addr, val);
187 wl12xx_mem_write32(wl, dest_addr, val); 187 wl1251_mem_write32(wl, dest_addr, val);
188 188
189 nvs_ptr += 4; 189 nvs_ptr += 4;
190 dest_addr += 4; 190 dest_addr += 4;
@@ -200,7 +200,7 @@ static int wl1251_upload_nvs(struct wl12xx *wl)
200 nvs_len = ALIGN(nvs_len, 4); 200 nvs_len = ALIGN(nvs_len, 4);
201 201
202 /* Now we must set the partition correctly */ 202 /* Now we must set the partition correctly */
203 wl12xx_set_partition(wl, nvs_start, 203 wl1251_set_partition(wl, nvs_start,
204 wl->chip.p_table[PART_DOWN].mem.size, 204 wl->chip.p_table[PART_DOWN].mem.size,
205 wl->chip.p_table[PART_DOWN].reg.start, 205 wl->chip.p_table[PART_DOWN].reg.start,
206 wl->chip.p_table[PART_DOWN].reg.size); 206 wl->chip.p_table[PART_DOWN].reg.size);
@@ -213,10 +213,10 @@ static int wl1251_upload_nvs(struct wl12xx *wl)
213 213
214 val = cpu_to_le32(val); 214 val = cpu_to_le32(val);
215 215
216 wl12xx_debug(DEBUG_BOOT, 216 wl1251_debug(DEBUG_BOOT,
217 "nvs write table 0x%x: 0x%x", 217 "nvs write table 0x%x: 0x%x",
218 nvs_start, val); 218 nvs_start, val);
219 wl12xx_mem_write32(wl, nvs_start, val); 219 wl1251_mem_write32(wl, nvs_start, val);
220 220
221 nvs_ptr += 4; 221 nvs_ptr += 4;
222 nvs_bytes_written += 4; 222 nvs_bytes_written += 4;
@@ -226,12 +226,12 @@ static int wl1251_upload_nvs(struct wl12xx *wl)
226 return 0; 226 return 0;
227} 227}
228 228
229static int wl1251_boot(struct wl12xx *wl) 229static int wl1251_boot(struct wl1251 *wl)
230{ 230{
231 int ret = 0, minor_minor_e2_ver; 231 int ret = 0, minor_minor_e2_ver;
232 u32 tmp, boot_data; 232 u32 tmp, boot_data;
233 233
234 ret = wl12xx_boot_soft_reset(wl); 234 ret = wl1251_boot_soft_reset(wl);
235 if (ret < 0) 235 if (ret < 0)
236 goto out; 236 goto out;
237 237
@@ -242,39 +242,39 @@ static int wl1251_boot(struct wl12xx *wl)
242 242
243 /* write firmware's last address (ie. it's length) to 243 /* write firmware's last address (ie. it's length) to
244 * ACX_EEPROMLESS_IND_REG */ 244 * ACX_EEPROMLESS_IND_REG */
245 wl12xx_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len); 245 wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len);
246 246
247 /* 6. read the EEPROM parameters */ 247 /* 6. read the EEPROM parameters */
248 tmp = wl12xx_reg_read32(wl, SCR_PAD2); 248 tmp = wl1251_reg_read32(wl, SCR_PAD2);
249 249
250 /* 7. read bootdata */ 250 /* 7. read bootdata */
251 wl->boot_attr.radio_type = (tmp & 0x0000FF00) >> 8; 251 wl->boot_attr.radio_type = (tmp & 0x0000FF00) >> 8;
252 wl->boot_attr.major = (tmp & 0x00FF0000) >> 16; 252 wl->boot_attr.major = (tmp & 0x00FF0000) >> 16;
253 tmp = wl12xx_reg_read32(wl, SCR_PAD3); 253 tmp = wl1251_reg_read32(wl, SCR_PAD3);
254 254
255 /* 8. check bootdata and call restart sequence */ 255 /* 8. check bootdata and call restart sequence */
256 wl->boot_attr.minor = (tmp & 0x00FF0000) >> 16; 256 wl->boot_attr.minor = (tmp & 0x00FF0000) >> 16;
257 minor_minor_e2_ver = (tmp & 0xFF000000) >> 24; 257 minor_minor_e2_ver = (tmp & 0xFF000000) >> 24;
258 258
259 wl12xx_debug(DEBUG_BOOT, "radioType 0x%x majorE2Ver 0x%x " 259 wl1251_debug(DEBUG_BOOT, "radioType 0x%x majorE2Ver 0x%x "
260 "minorE2Ver 0x%x minor_minor_e2_ver 0x%x", 260 "minorE2Ver 0x%x minor_minor_e2_ver 0x%x",
261 wl->boot_attr.radio_type, wl->boot_attr.major, 261 wl->boot_attr.radio_type, wl->boot_attr.major,
262 wl->boot_attr.minor, minor_minor_e2_ver); 262 wl->boot_attr.minor, minor_minor_e2_ver);
263 263
264 ret = wl12xx_boot_init_seq(wl); 264 ret = wl1251_boot_init_seq(wl);
265 if (ret < 0) 265 if (ret < 0)
266 goto out; 266 goto out;
267 267
268 /* 9. NVS processing done */ 268 /* 9. NVS processing done */
269 boot_data = wl12xx_reg_read32(wl, ACX_REG_ECPU_CONTROL); 269 boot_data = wl1251_reg_read32(wl, ACX_REG_ECPU_CONTROL);
270 270
271 wl12xx_debug(DEBUG_BOOT, "halt boot_data 0x%x", boot_data); 271 wl1251_debug(DEBUG_BOOT, "halt boot_data 0x%x", boot_data);
272 272
273 /* 10. check that ECPU_CONTROL_HALT bits are set in 273 /* 10. check that ECPU_CONTROL_HALT bits are set in
274 * pWhalBus->uBootData and start uploading firmware 274 * pWhalBus->uBootData and start uploading firmware
275 */ 275 */
276 if ((boot_data & ECPU_CONTROL_HALT) == 0) { 276 if ((boot_data & ECPU_CONTROL_HALT) == 0) {
277 wl12xx_error("boot failed, ECPU_CONTROL_HALT not set"); 277 wl1251_error("boot failed, ECPU_CONTROL_HALT not set");
278 ret = -EIO; 278 ret = -EIO;
279 goto out; 279 goto out;
280 } 280 }
@@ -284,62 +284,62 @@ static int wl1251_boot(struct wl12xx *wl)
284 goto out; 284 goto out;
285 285
286 /* 10.5 start firmware */ 286 /* 10.5 start firmware */
287 ret = wl12xx_boot_run_firmware(wl); 287 ret = wl1251_boot_run_firmware(wl);
288 if (ret < 0) 288 if (ret < 0)
289 goto out; 289 goto out;
290 290
291 /* Get and save the firmware version */
292 wl12xx_acx_fw_version(wl, wl->chip.fw_ver, sizeof(wl->chip.fw_ver));
293
294out: 291out:
295 return ret; 292 return ret;
296} 293}
297 294
298static int wl1251_mem_cfg(struct wl12xx *wl) 295static int wl1251_mem_cfg(struct wl1251 *wl)
299{ 296{
300 struct wl1251_acx_config_memory mem_conf; 297 struct wl1251_acx_config_memory *mem_conf;
301 int ret, i; 298 int ret, i;
302 299
303 wl12xx_debug(DEBUG_ACX, "wl1251 mem cfg"); 300 wl1251_debug(DEBUG_ACX, "wl1251 mem cfg");
301
302 mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL);
303 if (!mem_conf) {
304 ret = -ENOMEM;
305 goto out;
306 }
304 307
305 /* memory config */ 308 /* memory config */
306 mem_conf.mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS); 309 mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS);
307 mem_conf.mem_config.rx_mem_block_num = 35; 310 mem_conf->mem_config.rx_mem_block_num = 35;
308 mem_conf.mem_config.tx_min_mem_block_num = 64; 311 mem_conf->mem_config.tx_min_mem_block_num = 64;
309 mem_conf.mem_config.num_tx_queues = MAX_TX_QUEUES; 312 mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES;
310 mem_conf.mem_config.host_if_options = HOSTIF_PKT_RING; 313 mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING;
311 mem_conf.mem_config.num_ssid_profiles = 1; 314 mem_conf->mem_config.num_ssid_profiles = 1;
312 mem_conf.mem_config.debug_buffer_size = 315 mem_conf->mem_config.debug_buffer_size =
313 cpu_to_le16(TRACE_BUFFER_MAX_SIZE); 316 cpu_to_le16(TRACE_BUFFER_MAX_SIZE);
314 317
315 /* RX queue config */ 318 /* RX queue config */
316 mem_conf.rx_queue_config.dma_address = 0; 319 mem_conf->rx_queue_config.dma_address = 0;
317 mem_conf.rx_queue_config.num_descs = ACX_RX_DESC_DEF; 320 mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF;
318 mem_conf.rx_queue_config.priority = DEFAULT_RXQ_PRIORITY; 321 mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY;
319 mem_conf.rx_queue_config.type = DEFAULT_RXQ_TYPE; 322 mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE;
320 323
321 /* TX queue config */ 324 /* TX queue config */
322 for (i = 0; i < MAX_TX_QUEUES; i++) { 325 for (i = 0; i < MAX_TX_QUEUES; i++) {
323 mem_conf.tx_queue_config[i].num_descs = ACX_TX_DESC_DEF; 326 mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF;
324 mem_conf.tx_queue_config[i].attributes = i; 327 mem_conf->tx_queue_config[i].attributes = i;
325 } 328 }
326 329
327 mem_conf.header.id = ACX_MEM_CFG; 330 ret = wl1251_cmd_configure(wl, ACX_MEM_CFG, mem_conf,
328 mem_conf.header.len = sizeof(struct wl1251_acx_config_memory) - 331 sizeof(*mem_conf));
329 sizeof(struct acx_header); 332 if (ret < 0) {
330 mem_conf.header.len -= 333 wl1251_warning("wl1251 mem config failed: %d", ret);
331 (MAX_TX_QUEUE_CONFIGS - mem_conf.mem_config.num_tx_queues) * 334 goto out;
332 sizeof(struct wl1251_acx_tx_queue_config); 335 }
333
334 ret = wl12xx_cmd_configure(wl, &mem_conf,
335 sizeof(struct wl1251_acx_config_memory));
336 if (ret < 0)
337 wl12xx_warning("wl1251 mem config failed: %d", ret);
338 336
337out:
338 kfree(mem_conf);
339 return ret; 339 return ret;
340} 340}
341 341
342static int wl1251_hw_init_mem_config(struct wl12xx *wl) 342static int wl1251_hw_init_mem_config(struct wl1251 *wl)
343{ 343{
344 int ret; 344 int ret;
345 345
@@ -350,15 +350,15 @@ static int wl1251_hw_init_mem_config(struct wl12xx *wl)
350 wl->target_mem_map = kzalloc(sizeof(struct wl1251_acx_mem_map), 350 wl->target_mem_map = kzalloc(sizeof(struct wl1251_acx_mem_map),
351 GFP_KERNEL); 351 GFP_KERNEL);
352 if (!wl->target_mem_map) { 352 if (!wl->target_mem_map) {
353 wl12xx_error("couldn't allocate target memory map"); 353 wl1251_error("couldn't allocate target memory map");
354 return -ENOMEM; 354 return -ENOMEM;
355 } 355 }
356 356
357 /* we now ask for the firmware built memory map */ 357 /* we now ask for the firmware built memory map */
358 ret = wl12xx_acx_mem_map(wl, wl->target_mem_map, 358 ret = wl1251_acx_mem_map(wl, wl->target_mem_map,
359 sizeof(struct wl1251_acx_mem_map)); 359 sizeof(struct wl1251_acx_mem_map));
360 if (ret < 0) { 360 if (ret < 0) {
361 wl12xx_error("couldn't retrieve firmware memory map"); 361 wl1251_error("couldn't retrieve firmware memory map");
362 kfree(wl->target_mem_map); 362 kfree(wl->target_mem_map);
363 wl->target_mem_map = NULL; 363 wl->target_mem_map = NULL;
364 return ret; 364 return ret;
@@ -367,19 +367,19 @@ static int wl1251_hw_init_mem_config(struct wl12xx *wl)
367 return 0; 367 return 0;
368} 368}
369 369
370static void wl1251_set_ecpu_ctrl(struct wl12xx *wl, u32 flag) 370static void wl1251_set_ecpu_ctrl(struct wl1251 *wl, u32 flag)
371{ 371{
372 u32 cpu_ctrl; 372 u32 cpu_ctrl;
373 373
374 /* 10.5.0 run the firmware (I) */ 374 /* 10.5.0 run the firmware (I) */
375 cpu_ctrl = wl12xx_reg_read32(wl, ACX_REG_ECPU_CONTROL); 375 cpu_ctrl = wl1251_reg_read32(wl, ACX_REG_ECPU_CONTROL);
376 376
377 /* 10.5.1 run the firmware (II) */ 377 /* 10.5.1 run the firmware (II) */
378 cpu_ctrl &= ~flag; 378 cpu_ctrl &= ~flag;
379 wl12xx_reg_write32(wl, ACX_REG_ECPU_CONTROL, cpu_ctrl); 379 wl1251_reg_write32(wl, ACX_REG_ECPU_CONTROL, cpu_ctrl);
380} 380}
381 381
382static void wl1251_target_enable_interrupts(struct wl12xx *wl) 382static void wl1251_target_enable_interrupts(struct wl1251 *wl)
383{ 383{
384 /* Enable target's interrupts */ 384 /* Enable target's interrupts */
385 wl->intr_mask = WL1251_ACX_INTR_RX0_DATA | 385 wl->intr_mask = WL1251_ACX_INTR_RX0_DATA |
@@ -388,52 +388,60 @@ static void wl1251_target_enable_interrupts(struct wl12xx *wl)
388 WL1251_ACX_INTR_EVENT_A | 388 WL1251_ACX_INTR_EVENT_A |
389 WL1251_ACX_INTR_EVENT_B | 389 WL1251_ACX_INTR_EVENT_B |
390 WL1251_ACX_INTR_INIT_COMPLETE; 390 WL1251_ACX_INTR_INIT_COMPLETE;
391 wl12xx_boot_target_enable_interrupts(wl); 391 wl1251_boot_target_enable_interrupts(wl);
392}
393
394static void wl1251_fw_version(struct wl1251 *wl)
395{
396 wl1251_acx_fw_version(wl, wl->chip.fw_ver, sizeof(wl->chip.fw_ver));
392} 397}
393 398
394static void wl1251_irq_work(struct work_struct *work) 399static void wl1251_irq_work(struct work_struct *work)
395{ 400{
396 u32 intr; 401 u32 intr;
397 struct wl12xx *wl = 402 struct wl1251 *wl =
398 container_of(work, struct wl12xx, irq_work); 403 container_of(work, struct wl1251, irq_work);
404 int ret;
399 405
400 mutex_lock(&wl->mutex); 406 mutex_lock(&wl->mutex);
401 407
402 wl12xx_debug(DEBUG_IRQ, "IRQ work"); 408 wl1251_debug(DEBUG_IRQ, "IRQ work");
403 409
404 if (wl->state == WL12XX_STATE_OFF) 410 if (wl->state == WL1251_STATE_OFF)
405 goto out; 411 goto out;
406 412
407 wl12xx_ps_elp_wakeup(wl); 413 ret = wl1251_ps_elp_wakeup(wl);
414 if (ret < 0)
415 goto out;
408 416
409 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, WL1251_ACX_INTR_ALL); 417 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, WL1251_ACX_INTR_ALL);
410 418
411 intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR); 419 intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR);
412 wl12xx_debug(DEBUG_IRQ, "intr: 0x%x", intr); 420 wl1251_debug(DEBUG_IRQ, "intr: 0x%x", intr);
413 421
414 if (wl->data_path) { 422 if (wl->data_path) {
415 wl12xx_spi_mem_read(wl, wl->data_path->rx_control_addr, 423 wl->rx_counter =
416 &wl->rx_counter, sizeof(u32)); 424 wl1251_mem_read32(wl, wl->data_path->rx_control_addr);
417 425
418 /* We handle a frmware bug here */ 426 /* We handle a firmware bug here */
419 switch ((wl->rx_counter - wl->rx_handled) & 0xf) { 427 switch ((wl->rx_counter - wl->rx_handled) & 0xf) {
420 case 0: 428 case 0:
421 wl12xx_debug(DEBUG_IRQ, "RX: FW and host in sync"); 429 wl1251_debug(DEBUG_IRQ, "RX: FW and host in sync");
422 intr &= ~WL1251_ACX_INTR_RX0_DATA; 430 intr &= ~WL1251_ACX_INTR_RX0_DATA;
423 intr &= ~WL1251_ACX_INTR_RX1_DATA; 431 intr &= ~WL1251_ACX_INTR_RX1_DATA;
424 break; 432 break;
425 case 1: 433 case 1:
426 wl12xx_debug(DEBUG_IRQ, "RX: FW +1"); 434 wl1251_debug(DEBUG_IRQ, "RX: FW +1");
427 intr |= WL1251_ACX_INTR_RX0_DATA; 435 intr |= WL1251_ACX_INTR_RX0_DATA;
428 intr &= ~WL1251_ACX_INTR_RX1_DATA; 436 intr &= ~WL1251_ACX_INTR_RX1_DATA;
429 break; 437 break;
430 case 2: 438 case 2:
431 wl12xx_debug(DEBUG_IRQ, "RX: FW +2"); 439 wl1251_debug(DEBUG_IRQ, "RX: FW +2");
432 intr |= WL1251_ACX_INTR_RX0_DATA; 440 intr |= WL1251_ACX_INTR_RX0_DATA;
433 intr |= WL1251_ACX_INTR_RX1_DATA; 441 intr |= WL1251_ACX_INTR_RX1_DATA;
434 break; 442 break;
435 default: 443 default:
436 wl12xx_warning("RX: FW and host out of sync: %d", 444 wl1251_warning("RX: FW and host out of sync: %d",
437 wl->rx_counter - wl->rx_handled); 445 wl->rx_counter - wl->rx_handled);
438 break; 446 break;
439 } 447 }
@@ -441,49 +449,50 @@ static void wl1251_irq_work(struct work_struct *work)
441 wl->rx_handled = wl->rx_counter; 449 wl->rx_handled = wl->rx_counter;
442 450
443 451
444 wl12xx_debug(DEBUG_IRQ, "RX counter: %d", wl->rx_counter); 452 wl1251_debug(DEBUG_IRQ, "RX counter: %d", wl->rx_counter);
445 } 453 }
446 454
447 intr &= wl->intr_mask; 455 intr &= wl->intr_mask;
448 456
449 if (intr == 0) { 457 if (intr == 0) {
450 wl12xx_debug(DEBUG_IRQ, "INTR is 0"); 458 wl1251_debug(DEBUG_IRQ, "INTR is 0");
451 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, 459 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK,
452 ~(wl->intr_mask)); 460 ~(wl->intr_mask));
453 461
454 goto out_sleep; 462 goto out_sleep;
455 } 463 }
456 464
457 if (intr & WL1251_ACX_INTR_RX0_DATA) { 465 if (intr & WL1251_ACX_INTR_RX0_DATA) {
458 wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX0_DATA"); 466 wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX0_DATA");
459 wl12xx_rx(wl); 467 wl1251_rx(wl);
460 } 468 }
461 469
462 if (intr & WL1251_ACX_INTR_RX1_DATA) { 470 if (intr & WL1251_ACX_INTR_RX1_DATA) {
463 wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX1_DATA"); 471 wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX1_DATA");
464 wl12xx_rx(wl); 472 wl1251_rx(wl);
465 } 473 }
466 474
467 if (intr & WL1251_ACX_INTR_TX_RESULT) { 475 if (intr & WL1251_ACX_INTR_TX_RESULT) {
468 wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_TX_RESULT"); 476 wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_TX_RESULT");
469 wl12xx_tx_complete(wl); 477 wl1251_tx_complete(wl);
470 } 478 }
471 479
472 if (intr & (WL1251_ACX_INTR_EVENT_A | WL1251_ACX_INTR_EVENT_B)) { 480 if (intr & (WL1251_ACX_INTR_EVENT_A | WL1251_ACX_INTR_EVENT_B)) {
473 wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT (0x%x)", intr); 481 wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT (0x%x)", intr);
474 if (intr & WL1251_ACX_INTR_EVENT_A) 482 if (intr & WL1251_ACX_INTR_EVENT_A)
475 wl12xx_event_handle(wl, 0); 483 wl1251_event_handle(wl, 0);
476 else 484 else
477 wl12xx_event_handle(wl, 1); 485 wl1251_event_handle(wl, 1);
478 } 486 }
479 487
480 if (intr & WL1251_ACX_INTR_INIT_COMPLETE) 488 if (intr & WL1251_ACX_INTR_INIT_COMPLETE)
481 wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_INIT_COMPLETE"); 489 wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_INIT_COMPLETE");
482 490
483 wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); 491 wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask));
484 492
485out_sleep: 493out_sleep:
486 wl12xx_ps_elp_sleep(wl); 494 wl1251_ps_elp_sleep(wl);
495
487out: 496out:
488 mutex_unlock(&wl->mutex); 497 mutex_unlock(&wl->mutex);
489} 498}
@@ -520,40 +529,45 @@ static int wl1251_hw_init_txq_fill(u8 qid,
520 (QOS_TX_LOW_VO_DEF * num_blocks) / 100; 529 (QOS_TX_LOW_VO_DEF * num_blocks) / 100;
521 break; 530 break;
522 default: 531 default:
523 wl12xx_error("Invalid TX queue id: %d", qid); 532 wl1251_error("Invalid TX queue id: %d", qid);
524 return -EINVAL; 533 return -EINVAL;
525 } 534 }
526 535
527 return 0; 536 return 0;
528} 537}
529 538
530static int wl1251_hw_init_tx_queue_config(struct wl12xx *wl) 539static int wl1251_hw_init_tx_queue_config(struct wl1251 *wl)
531{ 540{
532 struct acx_tx_queue_qos_config config; 541 struct acx_tx_queue_qos_config *config;
533 struct wl1251_acx_mem_map *wl_mem_map = wl->target_mem_map; 542 struct wl1251_acx_mem_map *wl_mem_map = wl->target_mem_map;
534 int ret, i; 543 int ret, i;
535 544
536 wl12xx_debug(DEBUG_ACX, "acx tx queue config"); 545 wl1251_debug(DEBUG_ACX, "acx tx queue config");
537 546
538 config.header.id = ACX_TX_QUEUE_CFG; 547 config = kzalloc(sizeof(*config), GFP_KERNEL);
539 config.header.len = sizeof(struct acx_tx_queue_qos_config) - 548 if (!config) {
540 sizeof(struct acx_header); 549 ret = -ENOMEM;
550 goto out;
551 }
541 552
542 for (i = 0; i < MAX_NUM_OF_AC; i++) { 553 for (i = 0; i < MAX_NUM_OF_AC; i++) {
543 ret = wl1251_hw_init_txq_fill(i, &config, 554 ret = wl1251_hw_init_txq_fill(i, config,
544 wl_mem_map->num_tx_mem_blocks); 555 wl_mem_map->num_tx_mem_blocks);
545 if (ret < 0) 556 if (ret < 0)
546 return ret; 557 goto out;
547 558
548 ret = wl12xx_cmd_configure(wl, &config, sizeof(config)); 559 ret = wl1251_cmd_configure(wl, ACX_TX_QUEUE_CFG,
560 config, sizeof(*config));
549 if (ret < 0) 561 if (ret < 0)
550 return ret; 562 goto out;
551 } 563 }
552 564
553 return 0; 565out:
566 kfree(config);
567 return ret;
554} 568}
555 569
556static int wl1251_hw_init_data_path_config(struct wl12xx *wl) 570static int wl1251_hw_init_data_path_config(struct wl1251 *wl)
557{ 571{
558 int ret; 572 int ret;
559 573
@@ -561,11 +575,11 @@ static int wl1251_hw_init_data_path_config(struct wl12xx *wl)
561 wl->data_path = kzalloc(sizeof(struct acx_data_path_params_resp), 575 wl->data_path = kzalloc(sizeof(struct acx_data_path_params_resp),
562 GFP_KERNEL); 576 GFP_KERNEL);
563 if (!wl->data_path) { 577 if (!wl->data_path) {
564 wl12xx_error("Couldnt allocate data path parameters"); 578 wl1251_error("Couldn't allocate data path parameters");
565 return -ENOMEM; 579 return -ENOMEM;
566 } 580 }
567 581
568 ret = wl12xx_acx_data_path_params(wl, wl->data_path); 582 ret = wl1251_acx_data_path_params(wl, wl->data_path);
569 if (ret < 0) { 583 if (ret < 0) {
570 kfree(wl->data_path); 584 kfree(wl->data_path);
571 wl->data_path = NULL; 585 wl->data_path = NULL;
@@ -575,17 +589,17 @@ static int wl1251_hw_init_data_path_config(struct wl12xx *wl)
575 return 0; 589 return 0;
576} 590}
577 591
578static int wl1251_hw_init(struct wl12xx *wl) 592static int wl1251_hw_init(struct wl1251 *wl)
579{ 593{
580 struct wl1251_acx_mem_map *wl_mem_map; 594 struct wl1251_acx_mem_map *wl_mem_map;
581 int ret; 595 int ret;
582 596
583 ret = wl12xx_hw_init_hwenc_config(wl); 597 ret = wl1251_hw_init_hwenc_config(wl);
584 if (ret < 0) 598 if (ret < 0)
585 return ret; 599 return ret;
586 600
587 /* Template settings */ 601 /* Template settings */
588 ret = wl12xx_hw_init_templates_config(wl); 602 ret = wl1251_hw_init_templates_config(wl);
589 if (ret < 0) 603 if (ret < 0)
590 return ret; 604 return ret;
591 605
@@ -600,7 +614,7 @@ static int wl1251_hw_init(struct wl12xx *wl)
600 goto out_free_memmap; 614 goto out_free_memmap;
601 615
602 /* RX config */ 616 /* RX config */
603 ret = wl12xx_hw_init_rx_config(wl, 617 ret = wl1251_hw_init_rx_config(wl,
604 RX_CFG_PROMISCUOUS | RX_CFG_TSF, 618 RX_CFG_PROMISCUOUS | RX_CFG_TSF,
605 RX_FILTER_OPTION_DEF); 619 RX_FILTER_OPTION_DEF);
606 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS, 620 /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
@@ -614,42 +628,42 @@ static int wl1251_hw_init(struct wl12xx *wl)
614 goto out_free_data_path; 628 goto out_free_data_path;
615 629
616 /* PHY layer config */ 630 /* PHY layer config */
617 ret = wl12xx_hw_init_phy_config(wl); 631 ret = wl1251_hw_init_phy_config(wl);
618 if (ret < 0) 632 if (ret < 0)
619 goto out_free_data_path; 633 goto out_free_data_path;
620 634
621 /* Beacon filtering */ 635 /* Beacon filtering */
622 ret = wl12xx_hw_init_beacon_filter(wl); 636 ret = wl1251_hw_init_beacon_filter(wl);
623 if (ret < 0) 637 if (ret < 0)
624 goto out_free_data_path; 638 goto out_free_data_path;
625 639
626 /* Bluetooth WLAN coexistence */ 640 /* Bluetooth WLAN coexistence */
627 ret = wl12xx_hw_init_pta(wl); 641 ret = wl1251_hw_init_pta(wl);
628 if (ret < 0) 642 if (ret < 0)
629 goto out_free_data_path; 643 goto out_free_data_path;
630 644
631 /* Energy detection */ 645 /* Energy detection */
632 ret = wl12xx_hw_init_energy_detection(wl); 646 ret = wl1251_hw_init_energy_detection(wl);
633 if (ret < 0) 647 if (ret < 0)
634 goto out_free_data_path; 648 goto out_free_data_path;
635 649
636 /* Beacons and boradcast settings */ 650 /* Beacons and boradcast settings */
637 ret = wl12xx_hw_init_beacon_broadcast(wl); 651 ret = wl1251_hw_init_beacon_broadcast(wl);
638 if (ret < 0) 652 if (ret < 0)
639 goto out_free_data_path; 653 goto out_free_data_path;
640 654
641 /* Enable data path */ 655 /* Enable data path */
642 ret = wl12xx_cmd_data_path(wl, wl->channel, 1); 656 ret = wl1251_cmd_data_path(wl, wl->channel, 1);
643 if (ret < 0) 657 if (ret < 0)
644 goto out_free_data_path; 658 goto out_free_data_path;
645 659
646 /* Default power state */ 660 /* Default power state */
647 ret = wl12xx_hw_init_power_auth(wl); 661 ret = wl1251_hw_init_power_auth(wl);
648 if (ret < 0) 662 if (ret < 0)
649 goto out_free_data_path; 663 goto out_free_data_path;
650 664
651 wl_mem_map = wl->target_mem_map; 665 wl_mem_map = wl->target_mem_map;
652 wl12xx_info("%d tx blocks at 0x%x, %d rx blocks at 0x%x", 666 wl1251_info("%d tx blocks at 0x%x, %d rx blocks at 0x%x",
653 wl_mem_map->num_tx_mem_blocks, 667 wl_mem_map->num_tx_mem_blocks,
654 wl->data_path->tx_control_addr, 668 wl->data_path->tx_control_addr,
655 wl_mem_map->num_rx_mem_blocks, 669 wl_mem_map->num_rx_mem_blocks,
@@ -666,7 +680,7 @@ static int wl1251_hw_init(struct wl12xx *wl)
666 return ret; 680 return ret;
667} 681}
668 682
669static int wl1251_plt_init(struct wl12xx *wl) 683static int wl1251_plt_init(struct wl1251 *wl)
670{ 684{
671 int ret; 685 int ret;
672 686
@@ -674,14 +688,14 @@ static int wl1251_plt_init(struct wl12xx *wl)
674 if (ret < 0) 688 if (ret < 0)
675 return ret; 689 return ret;
676 690
677 ret = wl12xx_cmd_data_path(wl, wl->channel, 1); 691 ret = wl1251_cmd_data_path(wl, wl->channel, 1);
678 if (ret < 0) 692 if (ret < 0)
679 return ret; 693 return ret;
680 694
681 return 0; 695 return 0;
682} 696}
683 697
684void wl1251_setup(struct wl12xx *wl) 698void wl1251_setup(struct wl1251 *wl)
685{ 699{
686 /* FIXME: Is it better to use strncpy here or is this ok? */ 700 /* FIXME: Is it better to use strncpy here or is this ok? */
687 wl->chip.fw_filename = WL1251_FW_NAME; 701 wl->chip.fw_filename = WL1251_FW_NAME;
@@ -701,9 +715,14 @@ void wl1251_setup(struct wl12xx *wl)
701 wl->chip.op_target_enable_interrupts = wl1251_target_enable_interrupts; 715 wl->chip.op_target_enable_interrupts = wl1251_target_enable_interrupts;
702 wl->chip.op_hw_init = wl1251_hw_init; 716 wl->chip.op_hw_init = wl1251_hw_init;
703 wl->chip.op_plt_init = wl1251_plt_init; 717 wl->chip.op_plt_init = wl1251_plt_init;
718 wl->chip.op_fw_version = wl1251_fw_version;
719 wl->chip.op_tx_flush = wl1251_tx_flush;
720 wl->chip.op_cmd_join = wl1251_cmd_join;
704 721
705 wl->chip.p_table = wl1251_part_table; 722 wl->chip.p_table = wl1251_part_table;
706 wl->chip.acx_reg_table = wl1251_acx_reg_table; 723 wl->chip.acx_reg_table = wl1251_acx_reg_table;
707 724
708 INIT_WORK(&wl->irq_work, wl1251_irq_work); 725 INIT_WORK(&wl->irq_work, wl1251_irq_work);
726 INIT_WORK(&wl->tx_work, wl1251_tx_work);
727
709} 728}
diff --git a/drivers/net/wireless/wl12xx/wl1251_ops.h b/drivers/net/wireless/wl12xx/wl1251_ops.h
new file mode 100644
index 000000000000..68183c472e43
--- /dev/null
+++ b/drivers/net/wireless/wl12xx/wl1251_ops.h
@@ -0,0 +1,165 @@
1/*
2 * This file is part of wl1251
3 *
4 * Copyright (C) 2008 Nokia Corporation
5 *
6 * Contact: Kalle Valo <kalle.valo@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * version 2 as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23
24#ifndef __WL1251_OPS_H__
25#define __WL1251_OPS_H__
26
27#include <linux/bitops.h>
28
29#include "wl1251.h"
30#include "wl1251_acx.h"
31
32#define WL1251_FW_NAME "wl1251-fw.bin"
33#define WL1251_NVS_NAME "wl1251-nvs.bin"
34
35#define WL1251_POWER_ON_SLEEP 10 /* in miliseconds */
36
37void wl1251_setup(struct wl1251 *wl);
38
39
40struct wl1251_acx_memory {
41 __le16 num_stations; /* number of STAs to be supported. */
42 u16 reserved_1;
43
44 /*
45 * Nmber of memory buffers for the RX mem pool.
46 * The actual number may be less if there are
47 * not enough blocks left for the minimum num
48 * of TX ones.
49 */
50 u8 rx_mem_block_num;
51 u8 reserved_2;
52 u8 num_tx_queues; /* From 1 to 16 */
53 u8 host_if_options; /* HOST_IF* */
54 u8 tx_min_mem_block_num;
55 u8 num_ssid_profiles;
56 __le16 debug_buffer_size;
57} __attribute__ ((packed));
58
59
60#define ACX_RX_DESC_MIN 1
61#define ACX_RX_DESC_MAX 127
62#define ACX_RX_DESC_DEF 32
63struct wl1251_acx_rx_queue_config {
64 u8 num_descs;
65 u8 pad;
66 u8 type;
67 u8 priority;
68 __le32 dma_address;
69} __attribute__ ((packed));
70
71#define ACX_TX_DESC_MIN 1
72#define ACX_TX_DESC_MAX 127
73#define ACX_TX_DESC_DEF 16
74struct wl1251_acx_tx_queue_config {
75 u8 num_descs;
76 u8 pad[2];
77 u8 attributes;
78} __attribute__ ((packed));
79
80#define MAX_TX_QUEUE_CONFIGS 5
81#define MAX_TX_QUEUES 4
82struct wl1251_acx_config_memory {
83 struct acx_header header;
84
85 struct wl1251_acx_memory mem_config;
86 struct wl1251_acx_rx_queue_config rx_queue_config;
87 struct wl1251_acx_tx_queue_config tx_queue_config[MAX_TX_QUEUE_CONFIGS];
88} __attribute__ ((packed));
89
90struct wl1251_acx_mem_map {
91 struct acx_header header;
92
93 void *code_start;
94 void *code_end;
95
96 void *wep_defkey_start;
97 void *wep_defkey_end;
98
99 void *sta_table_start;
100 void *sta_table_end;
101
102 void *packet_template_start;
103 void *packet_template_end;
104
105 void *queue_memory_start;
106 void *queue_memory_end;
107
108 void *packet_memory_pool_start;
109 void *packet_memory_pool_end;
110
111 void *debug_buffer1_start;
112 void *debug_buffer1_end;
113
114 void *debug_buffer2_start;
115 void *debug_buffer2_end;
116
117 /* Number of blocks FW allocated for TX packets */
118 u32 num_tx_mem_blocks;
119
120 /* Number of blocks FW allocated for RX packets */
121 u32 num_rx_mem_blocks;
122} __attribute__ ((packed));
123
124/*************************************************************************
125
126 Host Interrupt Register (WiLink -> Host)
127
128**************************************************************************/
129
130/* RX packet is ready in Xfer buffer #0 */
131#define WL1251_ACX_INTR_RX0_DATA BIT(0)
132
133/* TX result(s) are in the TX complete buffer */
134#define WL1251_ACX_INTR_TX_RESULT BIT(1)
135
136/* OBSOLETE */
137#define WL1251_ACX_INTR_TX_XFR BIT(2)
138
139/* RX packet is ready in Xfer buffer #1 */
140#define WL1251_ACX_INTR_RX1_DATA BIT(3)
141
142/* Event was entered to Event MBOX #A */
143#define WL1251_ACX_INTR_EVENT_A BIT(4)
144
145/* Event was entered to Event MBOX #B */
146#define WL1251_ACX_INTR_EVENT_B BIT(5)
147
148/* OBSOLETE */
149#define WL1251_ACX_INTR_WAKE_ON_HOST BIT(6)
150
151/* Trace meassge on MBOX #A */
152#define WL1251_ACX_INTR_TRACE_A BIT(7)
153
154/* Trace meassge on MBOX #B */
155#define WL1251_ACX_INTR_TRACE_B BIT(8)
156
157/* Command processing completion */
158#define WL1251_ACX_INTR_CMD_COMPLETE BIT(9)
159
160/* Init sequence is done */
161#define WL1251_ACX_INTR_INIT_COMPLETE BIT(14)
162
163#define WL1251_ACX_INTR_ALL 0xFFFFFFFF
164
165#endif
diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/wl1251_ps.c
index 83a10117330b..68ff7f1900ed 100644
--- a/drivers/net/wireless/wl12xx/ps.c
+++ b/drivers/net/wireless/wl12xx/wl1251_ps.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
@@ -22,25 +22,25 @@
22 */ 22 */
23 23
24#include "reg.h" 24#include "reg.h"
25#include "ps.h" 25#include "wl1251_ps.h"
26#include "spi.h" 26#include "wl1251_spi.h"
27 27
28#define WL12XX_WAKEUP_TIMEOUT 2000 28#define WL1251_WAKEUP_TIMEOUT 2000
29 29
30/* Routines to toggle sleep mode while in ELP */ 30/* Routines to toggle sleep mode while in ELP */
31void wl12xx_ps_elp_sleep(struct wl12xx *wl) 31void wl1251_ps_elp_sleep(struct wl1251 *wl)
32{ 32{
33 if (wl->elp || !wl->psm) 33 if (wl->elp || !wl->psm)
34 return; 34 return;
35 35
36 wl12xx_debug(DEBUG_PSM, "chip to elp"); 36 wl1251_debug(DEBUG_PSM, "chip to elp");
37 37
38 wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); 38 wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP);
39 39
40 wl->elp = true; 40 wl->elp = true;
41} 41}
42 42
43int wl12xx_ps_elp_wakeup(struct wl12xx *wl) 43int wl1251_ps_elp_wakeup(struct wl1251 *wl)
44{ 44{
45 unsigned long timeout; 45 unsigned long timeout;
46 u32 elp_reg; 46 u32 elp_reg;
@@ -48,13 +48,13 @@ int wl12xx_ps_elp_wakeup(struct wl12xx *wl)
48 if (!wl->elp) 48 if (!wl->elp)
49 return 0; 49 return 0;
50 50
51 wl12xx_debug(DEBUG_PSM, "waking up chip from elp"); 51 wl1251_debug(DEBUG_PSM, "waking up chip from elp");
52 52
53 timeout = jiffies + msecs_to_jiffies(WL12XX_WAKEUP_TIMEOUT); 53 timeout = jiffies + msecs_to_jiffies(WL1251_WAKEUP_TIMEOUT);
54 54
55 wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP); 55 wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP);
56 56
57 elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); 57 elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
58 58
59 /* 59 /*
60 * FIXME: we should wait for irq from chip but, as a temporary 60 * FIXME: we should wait for irq from chip but, as a temporary
@@ -62,40 +62,36 @@ int wl12xx_ps_elp_wakeup(struct wl12xx *wl)
62 */ 62 */
63 while (!(elp_reg & ELPCTRL_WLAN_READY)) { 63 while (!(elp_reg & ELPCTRL_WLAN_READY)) {
64 if (time_after(jiffies, timeout)) { 64 if (time_after(jiffies, timeout)) {
65 wl12xx_error("elp wakeup timeout"); 65 wl1251_error("elp wakeup timeout");
66 return -ETIMEDOUT; 66 return -ETIMEDOUT;
67 } 67 }
68 msleep(1); 68 msleep(1);
69 elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); 69 elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR);
70 } 70 }
71 71
72 wl12xx_debug(DEBUG_PSM, "wakeup time: %u ms", 72 wl1251_debug(DEBUG_PSM, "wakeup time: %u ms",
73 jiffies_to_msecs(jiffies) - 73 jiffies_to_msecs(jiffies) -
74 (jiffies_to_msecs(timeout) - WL12XX_WAKEUP_TIMEOUT)); 74 (jiffies_to_msecs(timeout) - WL1251_WAKEUP_TIMEOUT));
75 75
76 wl->elp = false; 76 wl->elp = false;
77 77
78 return 0; 78 return 0;
79} 79}
80 80
81static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable) 81static int wl1251_ps_set_elp(struct wl1251 *wl, bool enable)
82{ 82{
83 int ret; 83 int ret;
84 84
85 if (enable) { 85 if (enable) {
86 wl12xx_debug(DEBUG_PSM, "sleep auth psm/elp"); 86 wl1251_debug(DEBUG_PSM, "sleep auth psm/elp");
87 87
88 /* 88 ret = wl1251_acx_sleep_auth(wl, WL1251_PSM_ELP);
89 * FIXME: we should PSM_ELP, but because of firmware wakeup
90 * problems let's use only PSM_PS
91 */
92 ret = wl12xx_acx_sleep_auth(wl, WL12XX_PSM_PS);
93 if (ret < 0) 89 if (ret < 0)
94 return ret; 90 return ret;
95 91
96 wl12xx_ps_elp_sleep(wl); 92 wl1251_ps_elp_sleep(wl);
97 } else { 93 } else {
98 wl12xx_debug(DEBUG_PSM, "sleep auth cam"); 94 wl1251_debug(DEBUG_PSM, "sleep auth cam");
99 95
100 /* 96 /*
101 * When the target is in ELP, we can only 97 * When the target is in ELP, we can only
@@ -104,9 +100,9 @@ static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable)
104 * changing the power authorization. 100 * changing the power authorization.
105 */ 101 */
106 102
107 wl12xx_ps_elp_wakeup(wl); 103 wl1251_ps_elp_wakeup(wl);
108 104
109 ret = wl12xx_acx_sleep_auth(wl, WL12XX_PSM_CAM); 105 ret = wl1251_acx_sleep_auth(wl, WL1251_PSM_CAM);
110 if (ret < 0) 106 if (ret < 0)
111 return ret; 107 return ret;
112 } 108 }
@@ -114,18 +110,18 @@ static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable)
114 return 0; 110 return 0;
115} 111}
116 112
117int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode) 113int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode)
118{ 114{
119 int ret; 115 int ret;
120 116
121 switch (mode) { 117 switch (mode) {
122 case STATION_POWER_SAVE_MODE: 118 case STATION_POWER_SAVE_MODE:
123 wl12xx_debug(DEBUG_PSM, "entering psm"); 119 wl1251_debug(DEBUG_PSM, "entering psm");
124 ret = wl12xx_cmd_ps_mode(wl, STATION_POWER_SAVE_MODE); 120 ret = wl1251_cmd_ps_mode(wl, STATION_POWER_SAVE_MODE);
125 if (ret < 0) 121 if (ret < 0)
126 return ret; 122 return ret;
127 123
128 ret = wl12xx_ps_set_elp(wl, true); 124 ret = wl1251_ps_set_elp(wl, true);
129 if (ret < 0) 125 if (ret < 0)
130 return ret; 126 return ret;
131 127
@@ -133,12 +129,12 @@ int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode)
133 break; 129 break;
134 case STATION_ACTIVE_MODE: 130 case STATION_ACTIVE_MODE:
135 default: 131 default:
136 wl12xx_debug(DEBUG_PSM, "leaving psm"); 132 wl1251_debug(DEBUG_PSM, "leaving psm");
137 ret = wl12xx_ps_set_elp(wl, false); 133 ret = wl1251_ps_set_elp(wl, false);
138 if (ret < 0) 134 if (ret < 0)
139 return ret; 135 return ret;
140 136
141 ret = wl12xx_cmd_ps_mode(wl, STATION_ACTIVE_MODE); 137 ret = wl1251_cmd_ps_mode(wl, STATION_ACTIVE_MODE);
142 if (ret < 0) 138 if (ret < 0)
143 return ret; 139 return ret;
144 140
diff --git a/drivers/net/wireless/wl12xx/ps.h b/drivers/net/wireless/wl12xx/wl1251_ps.h
index 5d7c52553830..db036fe12f25 100644
--- a/drivers/net/wireless/wl12xx/ps.h
+++ b/drivers/net/wireless/wl12xx/wl1251_ps.h
@@ -1,8 +1,8 @@
1#ifndef __WL12XX_PS_H__ 1#ifndef __WL1251_PS_H__
2#define __WL12XX_PS_H__ 2#define __WL1251_PS_H__
3 3
4/* 4/*
5 * This file is part of wl12xx 5 * This file is part of wl1251
6 * 6 *
7 * Copyright (c) 1998-2007 Texas Instruments Incorporated 7 * Copyright (c) 1998-2007 Texas Instruments Incorporated
8 * Copyright (C) 2008 Nokia Corporation 8 * Copyright (C) 2008 Nokia Corporation
@@ -25,12 +25,12 @@
25 * 25 *
26 */ 26 */
27 27
28#include "wl12xx.h" 28#include "wl1251.h"
29#include "acx.h" 29#include "wl1251_acx.h"
30 30
31int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode); 31int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode);
32void wl12xx_ps_elp_sleep(struct wl12xx *wl); 32void wl1251_ps_elp_sleep(struct wl1251 *wl);
33int wl12xx_ps_elp_wakeup(struct wl12xx *wl); 33int wl1251_ps_elp_wakeup(struct wl1251 *wl);
34 34
35 35
36#endif /* __WL12XX_PS_H__ */ 36#endif /* __WL1251_PS_H__ */
diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/wl1251_rx.c
index 981ea259eb89..0dbb483a0973 100644
--- a/drivers/net/wireless/wl12xx/rx.c
+++ b/drivers/net/wireless/wl12xx/wl1251_rx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -25,13 +25,14 @@
25#include <linux/skbuff.h> 25#include <linux/skbuff.h>
26#include <net/mac80211.h> 26#include <net/mac80211.h>
27 27
28#include "wl12xx.h" 28#include "wl1251.h"
29#include "reg.h" 29#include "reg.h"
30#include "spi.h" 30#include "wl1251_spi.h"
31#include "rx.h" 31#include "wl1251_rx.h"
32#include "wl1251_acx.h"
32 33
33static void wl12xx_rx_header(struct wl12xx *wl, 34static void wl1251_rx_header(struct wl1251 *wl,
34 struct wl12xx_rx_descriptor *desc) 35 struct wl1251_rx_descriptor *desc)
35{ 36{
36 u32 rx_packet_ring_addr; 37 u32 rx_packet_ring_addr;
37 38
@@ -39,15 +40,17 @@ static void wl12xx_rx_header(struct wl12xx *wl,
39 if (wl->rx_current_buffer) 40 if (wl->rx_current_buffer)
40 rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; 41 rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size;
41 42
42 wl12xx_spi_mem_read(wl, rx_packet_ring_addr, desc, 43 wl1251_spi_mem_read(wl, rx_packet_ring_addr, desc, sizeof(*desc));
43 sizeof(struct wl12xx_rx_descriptor));
44} 44}
45 45
46static void wl12xx_rx_status(struct wl12xx *wl, 46static void wl1251_rx_status(struct wl1251 *wl,
47 struct wl12xx_rx_descriptor *desc, 47 struct wl1251_rx_descriptor *desc,
48 struct ieee80211_rx_status *status, 48 struct ieee80211_rx_status *status,
49 u8 beacon) 49 u8 beacon)
50{ 50{
51 u64 mactime;
52 int ret;
53
51 memset(status, 0, sizeof(struct ieee80211_rx_status)); 54 memset(status, 0, sizeof(struct ieee80211_rx_status));
52 55
53 status->band = IEEE80211_BAND_2GHZ; 56 status->band = IEEE80211_BAND_2GHZ;
@@ -62,32 +65,14 @@ static void wl12xx_rx_status(struct wl12xx *wl,
62 * this one must be atomic, while our SPI routines can sleep. 65 * this one must be atomic, while our SPI routines can sleep.
63 */ 66 */
64 if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) { 67 if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) {
65 u64 mactime; 68 ret = wl1251_acx_tsf_info(wl, &mactime);
66 int ret; 69 if (ret == 0)
67 struct wl12xx_command cmd; 70 status->mactime = mactime;
68 struct acx_tsf_info *tsf_info;
69
70 memset(&cmd, 0, sizeof(cmd));
71
72 ret = wl12xx_cmd_interrogate(wl, ACX_TSF_INFO,
73 sizeof(struct acx_tsf_info),
74 &cmd);
75 if (ret < 0) {
76 wl12xx_warning("ACX_FW_REV interrogate failed");
77 return;
78 }
79
80 tsf_info = (struct acx_tsf_info *)&(cmd.parameters);
81
82 mactime = tsf_info->current_tsf_lsb |
83 (tsf_info->current_tsf_msb << 31);
84
85 status->mactime = mactime;
86 } 71 }
87 72
88 status->signal = desc->rssi; 73 status->signal = desc->rssi;
89 status->qual = (desc->rssi - WL12XX_RX_MIN_RSSI) * 100 / 74 status->qual = (desc->rssi - WL1251_RX_MIN_RSSI) * 100 /
90 (WL12XX_RX_MAX_RSSI - WL12XX_RX_MIN_RSSI); 75 (WL1251_RX_MAX_RSSI - WL1251_RX_MIN_RSSI);
91 status->qual = min(status->qual, 100); 76 status->qual = min(status->qual, 100);
92 status->qual = max(status->qual, 0); 77 status->qual = max(status->qual, 0);
93 78
@@ -118,8 +103,8 @@ static void wl12xx_rx_status(struct wl12xx *wl,
118 /* FIXME: set status->rate_idx */ 103 /* FIXME: set status->rate_idx */
119} 104}
120 105
121static void wl12xx_rx_body(struct wl12xx *wl, 106static void wl1251_rx_body(struct wl1251 *wl,
122 struct wl12xx_rx_descriptor *desc) 107 struct wl1251_rx_descriptor *desc)
123{ 108{
124 struct sk_buff *skb; 109 struct sk_buff *skb;
125 struct ieee80211_rx_status status; 110 struct ieee80211_rx_status status;
@@ -127,12 +112,12 @@ static void wl12xx_rx_body(struct wl12xx *wl,
127 u16 length, *fc; 112 u16 length, *fc;
128 u32 curr_id, last_id_inc, rx_packet_ring_addr; 113 u32 curr_id, last_id_inc, rx_packet_ring_addr;
129 114
130 length = WL12XX_RX_ALIGN(desc->length - PLCP_HEADER_LENGTH); 115 length = WL1251_RX_ALIGN(desc->length - PLCP_HEADER_LENGTH);
131 curr_id = (desc->flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT; 116 curr_id = (desc->flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT;
132 last_id_inc = (wl->rx_last_id + 1) % (RX_MAX_PACKET_ID + 1); 117 last_id_inc = (wl->rx_last_id + 1) % (RX_MAX_PACKET_ID + 1);
133 118
134 if (last_id_inc != curr_id) { 119 if (last_id_inc != curr_id) {
135 wl12xx_warning("curr ID:%d, last ID inc:%d", 120 wl1251_warning("curr ID:%d, last ID inc:%d",
136 curr_id, last_id_inc); 121 curr_id, last_id_inc);
137 wl->rx_last_id = curr_id; 122 wl->rx_last_id = curr_id;
138 } else { 123 } else {
@@ -140,18 +125,18 @@ static void wl12xx_rx_body(struct wl12xx *wl,
140 } 125 }
141 126
142 rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr + 127 rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr +
143 sizeof(struct wl12xx_rx_descriptor) + 20; 128 sizeof(struct wl1251_rx_descriptor) + 20;
144 if (wl->rx_current_buffer) 129 if (wl->rx_current_buffer)
145 rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; 130 rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size;
146 131
147 skb = dev_alloc_skb(length); 132 skb = dev_alloc_skb(length);
148 if (!skb) { 133 if (!skb) {
149 wl12xx_error("Couldn't allocate RX frame"); 134 wl1251_error("Couldn't allocate RX frame");
150 return; 135 return;
151 } 136 }
152 137
153 rx_buffer = skb_put(skb, length); 138 rx_buffer = skb_put(skb, length);
154 wl12xx_spi_mem_read(wl, rx_packet_ring_addr, rx_buffer, length); 139 wl1251_spi_mem_read(wl, rx_packet_ring_addr, rx_buffer, length);
155 140
156 /* The actual lenght doesn't include the target's alignment */ 141 /* The actual lenght doesn't include the target's alignment */
157 skb->len = desc->length - PLCP_HEADER_LENGTH; 142 skb->len = desc->length - PLCP_HEADER_LENGTH;
@@ -161,15 +146,16 @@ static void wl12xx_rx_body(struct wl12xx *wl,
161 if ((*fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) 146 if ((*fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON)
162 beacon = 1; 147 beacon = 1;
163 148
164 wl12xx_rx_status(wl, desc, &status, beacon); 149 wl1251_rx_status(wl, desc, &status, beacon);
165 150
166 wl12xx_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len, 151 wl1251_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len,
167 beacon ? "beacon" : ""); 152 beacon ? "beacon" : "");
168 153
169 ieee80211_rx(wl->hw, skb, &status); 154 memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
155 ieee80211_rx(wl->hw, skb);
170} 156}
171 157
172static void wl12xx_rx_ack(struct wl12xx *wl) 158static void wl1251_rx_ack(struct wl1251 *wl)
173{ 159{
174 u32 data, addr; 160 u32 data, addr;
175 161
@@ -181,28 +167,30 @@ static void wl12xx_rx_ack(struct wl12xx *wl)
181 data = INTR_TRIG_RX_PROC0; 167 data = INTR_TRIG_RX_PROC0;
182 } 168 }
183 169
184 wl12xx_reg_write32(wl, addr, data); 170 wl1251_reg_write32(wl, addr, data);
185 171
186 /* Toggle buffer ring */ 172 /* Toggle buffer ring */
187 wl->rx_current_buffer = !wl->rx_current_buffer; 173 wl->rx_current_buffer = !wl->rx_current_buffer;
188} 174}
189 175
190 176
191void wl12xx_rx(struct wl12xx *wl) 177void wl1251_rx(struct wl1251 *wl)
192{ 178{
193 struct wl12xx_rx_descriptor rx_desc; 179 struct wl1251_rx_descriptor *rx_desc;
194 180
195 if (wl->state != WL12XX_STATE_ON) 181 if (wl->state != WL1251_STATE_ON)
196 return; 182 return;
197 183
184 rx_desc = wl->rx_descriptor;
185
198 /* We first read the frame's header */ 186 /* We first read the frame's header */
199 wl12xx_rx_header(wl, &rx_desc); 187 wl1251_rx_header(wl, rx_desc);
200 188
201 /* Now we can read the body */ 189 /* Now we can read the body */
202 wl12xx_rx_body(wl, &rx_desc); 190 wl1251_rx_body(wl, rx_desc);
203 191
204 /* Finally, we need to ACK the RX */ 192 /* Finally, we need to ACK the RX */
205 wl12xx_rx_ack(wl); 193 wl1251_rx_ack(wl);
206 194
207 return; 195 return;
208} 196}
diff --git a/drivers/net/wireless/wl12xx/rx.h b/drivers/net/wireless/wl12xx/wl1251_rx.h
index 8a23fdea5016..563a3fde40fb 100644
--- a/drivers/net/wireless/wl12xx/rx.h
+++ b/drivers/net/wireless/wl12xx/wl1251_rx.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -22,11 +22,13 @@
22 * 22 *
23 */ 23 */
24 24
25#ifndef __WL12XX_RX_H__ 25#ifndef __WL1251_RX_H__
26#define __WL12XX_RX_H__ 26#define __WL1251_RX_H__
27 27
28#include <linux/bitops.h> 28#include <linux/bitops.h>
29 29
30#include "wl1251.h"
31
30/* 32/*
31 * RX PATH 33 * RX PATH
32 * 34 *
@@ -43,12 +45,12 @@
43 * 4) The target prepares the next RX packet. 45 * 4) The target prepares the next RX packet.
44 */ 46 */
45 47
46#define WL12XX_RX_MAX_RSSI -30 48#define WL1251_RX_MAX_RSSI -30
47#define WL12XX_RX_MIN_RSSI -95 49#define WL1251_RX_MIN_RSSI -95
48 50
49#define WL12XX_RX_ALIGN_TO 4 51#define WL1251_RX_ALIGN_TO 4
50#define WL12XX_RX_ALIGN(len) (((len) + WL12XX_RX_ALIGN_TO - 1) & \ 52#define WL1251_RX_ALIGN(len) (((len) + WL1251_RX_ALIGN_TO - 1) & \
51 ~(WL12XX_RX_ALIGN_TO - 1)) 53 ~(WL1251_RX_ALIGN_TO - 1))
52 54
53#define SHORT_PREAMBLE_BIT BIT(0) 55#define SHORT_PREAMBLE_BIT BIT(0)
54#define OFDM_RATE_BIT BIT(6) 56#define OFDM_RATE_BIT BIT(6)
@@ -72,7 +74,7 @@
72#define RX_DESC_MIC_FAIL 0x2000 74#define RX_DESC_MIC_FAIL 0x2000
73#define RX_DESC_DECRYPT_FAIL 0x4000 75#define RX_DESC_DECRYPT_FAIL 0x4000
74 76
75struct wl12xx_rx_descriptor { 77struct wl1251_rx_descriptor {
76 u32 timestamp; /* In microseconds */ 78 u32 timestamp; /* In microseconds */
77 u16 length; /* Paylod length, including headers */ 79 u16 length; /* Paylod length, including headers */
78 u16 flags; 80 u16 flags;
@@ -86,7 +88,7 @@ struct wl12xx_rx_descriptor {
86 u8 type; 88 u8 type;
87 89
88 /* 90 /*
89 * Recevied Rate: 91 * Received Rate:
90 * 0x0A - 1MBPS 92 * 0x0A - 1MBPS
91 * 0x14 - 2MBPS 93 * 0x14 - 2MBPS
92 * 0x37 - 5_5MBPS 94 * 0x37 - 5_5MBPS
@@ -117,6 +119,6 @@ struct wl12xx_rx_descriptor {
117 u8 snr; /* in dB */ 119 u8 snr; /* in dB */
118} __attribute__ ((packed)); 120} __attribute__ ((packed));
119 121
120void wl12xx_rx(struct wl12xx *wl); 122void wl1251_rx(struct wl1251 *wl);
121 123
122#endif 124#endif
diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/wl1251_spi.c
index abdf171a47e7..c5da79dbc49c 100644
--- a/drivers/net/wireless/wl12xx/spi.c
+++ b/drivers/net/wireless/wl12xx/wl1251_spi.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (C) 2008 Nokia Corporation 4 * Copyright (C) 2008 Nokia Corporation
5 * 5 *
@@ -25,13 +25,11 @@
25#include <linux/crc7.h> 25#include <linux/crc7.h>
26#include <linux/spi/spi.h> 26#include <linux/spi/spi.h>
27 27
28#include "wl12xx.h" 28#include "wl1251.h"
29#include "wl12xx_80211.h"
30#include "reg.h" 29#include "reg.h"
31#include "spi.h" 30#include "wl1251_spi.h"
32#include "ps.h"
33 31
34static int wl12xx_translate_reg_addr(struct wl12xx *wl, int addr) 32static int wl1251_translate_reg_addr(struct wl1251 *wl, int addr)
35{ 33{
36 /* If the address is lower than REGISTERS_BASE, it means that this is 34 /* If the address is lower than REGISTERS_BASE, it means that this is
37 * a chip-specific register address, so look it up in the registers 35 * a chip-specific register address, so look it up in the registers
@@ -39,7 +37,7 @@ static int wl12xx_translate_reg_addr(struct wl12xx *wl, int addr)
39 if (addr < REGISTERS_BASE) { 37 if (addr < REGISTERS_BASE) {
40 /* Make sure we don't go over the table */ 38 /* Make sure we don't go over the table */
41 if (addr >= ACX_REG_TABLE_LEN) { 39 if (addr >= ACX_REG_TABLE_LEN) {
42 wl12xx_error("address out of range (%d)", addr); 40 wl1251_error("address out of range (%d)", addr);
43 return -EINVAL; 41 return -EINVAL;
44 } 42 }
45 addr = wl->chip.acx_reg_table[addr]; 43 addr = wl->chip.acx_reg_table[addr];
@@ -48,13 +46,13 @@ static int wl12xx_translate_reg_addr(struct wl12xx *wl, int addr)
48 return addr - wl->physical_reg_addr + wl->virtual_reg_addr; 46 return addr - wl->physical_reg_addr + wl->virtual_reg_addr;
49} 47}
50 48
51static int wl12xx_translate_mem_addr(struct wl12xx *wl, int addr) 49static int wl1251_translate_mem_addr(struct wl1251 *wl, int addr)
52{ 50{
53 return addr - wl->physical_mem_addr + wl->virtual_mem_addr; 51 return addr - wl->physical_mem_addr + wl->virtual_mem_addr;
54} 52}
55 53
56 54
57void wl12xx_spi_reset(struct wl12xx *wl) 55void wl1251_spi_reset(struct wl1251 *wl)
58{ 56{
59 u8 *cmd; 57 u8 *cmd;
60 struct spi_transfer t; 58 struct spi_transfer t;
@@ -62,7 +60,7 @@ void wl12xx_spi_reset(struct wl12xx *wl)
62 60
63 cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); 61 cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
64 if (!cmd) { 62 if (!cmd) {
65 wl12xx_error("could not allocate cmd for spi reset"); 63 wl1251_error("could not allocate cmd for spi reset");
66 return; 64 return;
67 } 65 }
68 66
@@ -77,10 +75,10 @@ void wl12xx_spi_reset(struct wl12xx *wl)
77 75
78 spi_sync(wl->spi, &m); 76 spi_sync(wl->spi, &m);
79 77
80 wl12xx_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); 78 wl1251_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
81} 79}
82 80
83void wl12xx_spi_init(struct wl12xx *wl) 81void wl1251_spi_init(struct wl1251 *wl)
84{ 82{
85 u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; 83 u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd;
86 struct spi_transfer t; 84 struct spi_transfer t;
@@ -88,7 +86,7 @@ void wl12xx_spi_init(struct wl12xx *wl)
88 86
89 cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); 87 cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL);
90 if (!cmd) { 88 if (!cmd) {
91 wl12xx_error("could not allocate cmd for spi init"); 89 wl1251_error("could not allocate cmd for spi init");
92 return; 90 return;
93 } 91 }
94 92
@@ -131,7 +129,7 @@ void wl12xx_spi_init(struct wl12xx *wl)
131 129
132 spi_sync(wl->spi, &m); 130 spi_sync(wl->spi, &m);
133 131
134 wl12xx_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); 132 wl1251_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
135} 133}
136 134
137/* Set the SPI partitions to access the chip addresses 135/* Set the SPI partitions to access the chip addresses
@@ -167,45 +165,47 @@ void wl12xx_spi_init(struct wl12xx *wl)
167 * | | 165 * | |
168 * 166 *
169 */ 167 */
170void wl12xx_set_partition(struct wl12xx *wl, 168int wl1251_set_partition(struct wl1251 *wl,
171 u32 mem_start, u32 mem_size, 169 u32 mem_start, u32 mem_size,
172 u32 reg_start, u32 reg_size) 170 u32 reg_start, u32 reg_size)
173{ 171{
174 u8 tx_buf[sizeof(u32) + 2 * sizeof(struct wl12xx_partition)]; 172 struct wl1251_partition *partition;
175 struct wl12xx_partition *partition;
176 struct spi_transfer t; 173 struct spi_transfer t;
177 struct spi_message m; 174 struct spi_message m;
175 size_t len, cmd_len;
178 u32 *cmd; 176 u32 *cmd;
179 size_t len;
180 int addr; 177 int addr;
181 178
179 cmd_len = sizeof(u32) + 2 * sizeof(struct wl1251_partition);
180 cmd = kzalloc(cmd_len, GFP_KERNEL);
181 if (!cmd)
182 return -ENOMEM;
183
182 spi_message_init(&m); 184 spi_message_init(&m);
183 memset(&t, 0, sizeof(t)); 185 memset(&t, 0, sizeof(t));
184 memset(tx_buf, 0, sizeof(tx_buf));
185 186
186 cmd = (u32 *) tx_buf; 187 partition = (struct wl1251_partition *) (cmd + 1);
187 partition = (struct wl12xx_partition *) (tx_buf + sizeof(u32));
188 addr = HW_ACCESS_PART0_SIZE_ADDR; 188 addr = HW_ACCESS_PART0_SIZE_ADDR;
189 len = 2 * sizeof(struct wl12xx_partition); 189 len = 2 * sizeof(struct wl1251_partition);
190 190
191 *cmd |= WSPI_CMD_WRITE; 191 *cmd |= WSPI_CMD_WRITE;
192 *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; 192 *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
193 *cmd |= addr & WSPI_CMD_BYTE_ADDR; 193 *cmd |= addr & WSPI_CMD_BYTE_ADDR;
194 194
195 wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", 195 wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
196 mem_start, mem_size); 196 mem_start, mem_size);
197 wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", 197 wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
198 reg_start, reg_size); 198 reg_start, reg_size);
199 199
200 /* Make sure that the two partitions together don't exceed the 200 /* Make sure that the two partitions together don't exceed the
201 * address range */ 201 * address range */
202 if ((mem_size + reg_size) > HW_ACCESS_MEMORY_MAX_RANGE) { 202 if ((mem_size + reg_size) > HW_ACCESS_MEMORY_MAX_RANGE) {
203 wl12xx_debug(DEBUG_SPI, "Total size exceeds maximum virtual" 203 wl1251_debug(DEBUG_SPI, "Total size exceeds maximum virtual"
204 " address range. Truncating partition[0]."); 204 " address range. Truncating partition[0].");
205 mem_size = HW_ACCESS_MEMORY_MAX_RANGE - reg_size; 205 mem_size = HW_ACCESS_MEMORY_MAX_RANGE - reg_size;
206 wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", 206 wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
207 mem_start, mem_size); 207 mem_start, mem_size);
208 wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", 208 wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
209 reg_start, reg_size); 209 reg_start, reg_size);
210 } 210 }
211 211
@@ -213,23 +213,23 @@ void wl12xx_set_partition(struct wl12xx *wl,
213 ((mem_start + mem_size) > reg_start)) { 213 ((mem_start + mem_size) > reg_start)) {
214 /* Guarantee that the memory partition doesn't overlap the 214 /* Guarantee that the memory partition doesn't overlap the
215 * registers partition */ 215 * registers partition */
216 wl12xx_debug(DEBUG_SPI, "End of partition[0] is " 216 wl1251_debug(DEBUG_SPI, "End of partition[0] is "
217 "overlapping partition[1]. Adjusted."); 217 "overlapping partition[1]. Adjusted.");
218 mem_size = reg_start - mem_start; 218 mem_size = reg_start - mem_start;
219 wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", 219 wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
220 mem_start, mem_size); 220 mem_start, mem_size);
221 wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", 221 wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
222 reg_start, reg_size); 222 reg_start, reg_size);
223 } else if ((reg_start < mem_start) && 223 } else if ((reg_start < mem_start) &&
224 ((reg_start + reg_size) > mem_start)) { 224 ((reg_start + reg_size) > mem_start)) {
225 /* Guarantee that the register partition doesn't overlap the 225 /* Guarantee that the register partition doesn't overlap the
226 * memory partition */ 226 * memory partition */
227 wl12xx_debug(DEBUG_SPI, "End of partition[1] is" 227 wl1251_debug(DEBUG_SPI, "End of partition[1] is"
228 " overlapping partition[0]. Adjusted."); 228 " overlapping partition[0]. Adjusted.");
229 reg_size = mem_start - reg_start; 229 reg_size = mem_start - reg_start;
230 wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", 230 wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X",
231 mem_start, mem_size); 231 mem_start, mem_size);
232 wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", 232 wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X",
233 reg_start, reg_size); 233 reg_start, reg_size);
234 } 234 }
235 235
@@ -244,36 +244,46 @@ void wl12xx_set_partition(struct wl12xx *wl,
244 wl->virtual_mem_addr = 0; 244 wl->virtual_mem_addr = 0;
245 wl->virtual_reg_addr = mem_size; 245 wl->virtual_reg_addr = mem_size;
246 246
247 t.tx_buf = tx_buf; 247 t.tx_buf = cmd;
248 t.len = sizeof(tx_buf); 248 t.len = cmd_len;
249 spi_message_add_tail(&t, &m); 249 spi_message_add_tail(&t, &m);
250 250
251 spi_sync(wl->spi, &m); 251 spi_sync(wl->spi, &m);
252
253 kfree(cmd);
254
255 return 0;
252} 256}
253 257
254void wl12xx_spi_read(struct wl12xx *wl, int addr, void *buf, 258void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf,
255 size_t len) 259 size_t len, bool fixed)
256{ 260{
257 struct spi_transfer t[3]; 261 struct spi_transfer t[3];
258 struct spi_message m; 262 struct spi_message m;
259 char busy_buf[TNETWIF_READ_OFFSET_BYTES]; 263 u8 *busy_buf;
260 u32 cmd; 264 u32 *cmd;
265
266 cmd = &wl->buffer_cmd;
267 busy_buf = wl->buffer_busyword;
268
269 *cmd = 0;
270 *cmd |= WSPI_CMD_READ;
271 *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
272 *cmd |= addr & WSPI_CMD_BYTE_ADDR;
261 273
262 cmd = 0; 274 if (fixed)
263 cmd |= WSPI_CMD_READ; 275 *cmd |= WSPI_CMD_FIXED;
264 cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
265 cmd |= addr & WSPI_CMD_BYTE_ADDR;
266 276
267 spi_message_init(&m); 277 spi_message_init(&m);
268 memset(t, 0, sizeof(t)); 278 memset(t, 0, sizeof(t));
269 279
270 t[0].tx_buf = &cmd; 280 t[0].tx_buf = cmd;
271 t[0].len = 4; 281 t[0].len = 4;
272 spi_message_add_tail(&t[0], &m); 282 spi_message_add_tail(&t[0], &m);
273 283
274 /* Busy and non busy words read */ 284 /* Busy and non busy words read */
275 t[1].rx_buf = busy_buf; 285 t[1].rx_buf = busy_buf;
276 t[1].len = TNETWIF_READ_OFFSET_BYTES; 286 t[1].len = WL1251_BUSY_WORD_LEN;
277 spi_message_add_tail(&t[1], &m); 287 spi_message_add_tail(&t[1], &m);
278 288
279 t[2].rx_buf = buf; 289 t[2].rx_buf = buf;
@@ -284,27 +294,32 @@ void wl12xx_spi_read(struct wl12xx *wl, int addr, void *buf,
284 294
285 /* FIXME: check busy words */ 295 /* FIXME: check busy words */
286 296
287 wl12xx_dump(DEBUG_SPI, "spi_read cmd -> ", &cmd, sizeof(cmd)); 297 wl1251_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd));
288 wl12xx_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); 298 wl1251_dump(DEBUG_SPI, "spi_read buf <- ", buf, len);
289} 299}
290 300
291void wl12xx_spi_write(struct wl12xx *wl, int addr, void *buf, 301void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf,
292 size_t len) 302 size_t len, bool fixed)
293{ 303{
294 struct spi_transfer t[2]; 304 struct spi_transfer t[2];
295 struct spi_message m; 305 struct spi_message m;
296 u32 cmd; 306 u32 *cmd;
307
308 cmd = &wl->buffer_cmd;
297 309
298 cmd = 0; 310 *cmd = 0;
299 cmd |= WSPI_CMD_WRITE; 311 *cmd |= WSPI_CMD_WRITE;
300 cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; 312 *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH;
301 cmd |= addr & WSPI_CMD_BYTE_ADDR; 313 *cmd |= addr & WSPI_CMD_BYTE_ADDR;
314
315 if (fixed)
316 *cmd |= WSPI_CMD_FIXED;
302 317
303 spi_message_init(&m); 318 spi_message_init(&m);
304 memset(t, 0, sizeof(t)); 319 memset(t, 0, sizeof(t));
305 320
306 t[0].tx_buf = &cmd; 321 t[0].tx_buf = cmd;
307 t[0].len = sizeof(cmd); 322 t[0].len = sizeof(*cmd);
308 spi_message_add_tail(&t[0], &m); 323 spi_message_add_tail(&t[0], &m);
309 324
310 t[1].tx_buf = buf; 325 t[1].tx_buf = buf;
@@ -313,46 +328,66 @@ void wl12xx_spi_write(struct wl12xx *wl, int addr, void *buf,
313 328
314 spi_sync(wl->spi, &m); 329 spi_sync(wl->spi, &m);
315 330
316 wl12xx_dump(DEBUG_SPI, "spi_write cmd -> ", &cmd, sizeof(cmd)); 331 wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd));
317 wl12xx_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); 332 wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len);
318} 333}
319 334
320void wl12xx_spi_mem_read(struct wl12xx *wl, int addr, void *buf, 335void wl1251_spi_mem_read(struct wl1251 *wl, int addr, void *buf,
321 size_t len) 336 size_t len)
322{ 337{
323 int physical; 338 int physical;
324 339
325 physical = wl12xx_translate_mem_addr(wl, addr); 340 physical = wl1251_translate_mem_addr(wl, addr);
326 341
327 wl12xx_spi_read(wl, physical, buf, len); 342 wl1251_spi_read(wl, physical, buf, len, false);
328} 343}
329 344
330void wl12xx_spi_mem_write(struct wl12xx *wl, int addr, void *buf, 345void wl1251_spi_mem_write(struct wl1251 *wl, int addr, void *buf,
331 size_t len) 346 size_t len)
332{ 347{
333 int physical; 348 int physical;
334 349
335 physical = wl12xx_translate_mem_addr(wl, addr); 350 physical = wl1251_translate_mem_addr(wl, addr);
351
352 wl1251_spi_write(wl, physical, buf, len, false);
353}
354
355void wl1251_spi_reg_read(struct wl1251 *wl, int addr, void *buf, size_t len,
356 bool fixed)
357{
358 int physical;
359
360 physical = wl1251_translate_reg_addr(wl, addr);
361
362 wl1251_spi_read(wl, physical, buf, len, fixed);
363}
364
365void wl1251_spi_reg_write(struct wl1251 *wl, int addr, void *buf, size_t len,
366 bool fixed)
367{
368 int physical;
369
370 physical = wl1251_translate_reg_addr(wl, addr);
336 371
337 wl12xx_spi_write(wl, physical, buf, len); 372 wl1251_spi_write(wl, physical, buf, len, fixed);
338} 373}
339 374
340u32 wl12xx_mem_read32(struct wl12xx *wl, int addr) 375u32 wl1251_mem_read32(struct wl1251 *wl, int addr)
341{ 376{
342 return wl12xx_read32(wl, wl12xx_translate_mem_addr(wl, addr)); 377 return wl1251_read32(wl, wl1251_translate_mem_addr(wl, addr));
343} 378}
344 379
345void wl12xx_mem_write32(struct wl12xx *wl, int addr, u32 val) 380void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val)
346{ 381{
347 wl12xx_write32(wl, wl12xx_translate_mem_addr(wl, addr), val); 382 wl1251_write32(wl, wl1251_translate_mem_addr(wl, addr), val);
348} 383}
349 384
350u32 wl12xx_reg_read32(struct wl12xx *wl, int addr) 385u32 wl1251_reg_read32(struct wl1251 *wl, int addr)
351{ 386{
352 return wl12xx_read32(wl, wl12xx_translate_reg_addr(wl, addr)); 387 return wl1251_read32(wl, wl1251_translate_reg_addr(wl, addr));
353} 388}
354 389
355void wl12xx_reg_write32(struct wl12xx *wl, int addr, u32 val) 390void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val)
356{ 391{
357 wl12xx_write32(wl, wl12xx_translate_reg_addr(wl, addr), val); 392 wl1251_write32(wl, wl1251_translate_reg_addr(wl, addr), val);
358} 393}
diff --git a/drivers/net/wireless/wl12xx/spi.h b/drivers/net/wireless/wl12xx/wl1251_spi.h
index fd3227e904a8..6e8daf4e1085 100644
--- a/drivers/net/wireless/wl12xx/spi.h
+++ b/drivers/net/wireless/wl12xx/wl1251_spi.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -22,11 +22,11 @@
22 * 22 *
23 */ 23 */
24 24
25#ifndef __WL12XX_SPI_H__ 25#ifndef __WL1251_SPI_H__
26#define __WL12XX_SPI_H__ 26#define __WL1251_SPI_H__
27 27
28#include "cmd.h" 28#include "wl1251_cmd.h"
29#include "acx.h" 29#include "wl1251_acx.h"
30#include "reg.h" 30#include "reg.h"
31 31
32#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0 32#define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0
@@ -65,45 +65,51 @@
65 65
66#define WSPI_INIT_CMD_LEN 8 66#define WSPI_INIT_CMD_LEN 8
67 67
68#define TNETWIF_READ_OFFSET_BYTES 8
69#define HW_ACCESS_WSPI_FIXED_BUSY_LEN \ 68#define HW_ACCESS_WSPI_FIXED_BUSY_LEN \
70 ((TNETWIF_READ_OFFSET_BYTES - 4) / sizeof(u32)) 69 ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32))
71#define HW_ACCESS_WSPI_INIT_CMD_MASK 0 70#define HW_ACCESS_WSPI_INIT_CMD_MASK 0
72 71
73 72
74/* Raw target IO, address is not translated */ 73/* Raw target IO, address is not translated */
75void wl12xx_spi_read(struct wl12xx *wl, int addr, void *buf, size_t len); 74void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf,
76void wl12xx_spi_write(struct wl12xx *wl, int addr, void *buf, size_t len); 75 size_t len, bool fixed);
76void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf,
77 size_t len, bool fixed);
77 78
78/* Memory target IO, address is tranlated to partition 0 */ 79/* Memory target IO, address is tranlated to partition 0 */
79void wl12xx_spi_mem_read(struct wl12xx *wl, int addr, void *buf, size_t len); 80void wl1251_spi_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len);
80void wl12xx_spi_mem_write(struct wl12xx *wl, int addr, void *buf, size_t len); 81void wl1251_spi_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len);
81u32 wl12xx_mem_read32(struct wl12xx *wl, int addr); 82u32 wl1251_mem_read32(struct wl1251 *wl, int addr);
82void wl12xx_mem_write32(struct wl12xx *wl, int addr, u32 val); 83void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val);
83 84
84/* Registers IO */ 85/* Registers IO */
85u32 wl12xx_reg_read32(struct wl12xx *wl, int addr); 86void wl1251_spi_reg_read(struct wl1251 *wl, int addr, void *buf, size_t len,
86void wl12xx_reg_write32(struct wl12xx *wl, int addr, u32 val); 87 bool fixed);
88void wl1251_spi_reg_write(struct wl1251 *wl, int addr, void *buf, size_t len,
89 bool fixed);
90u32 wl1251_reg_read32(struct wl1251 *wl, int addr);
91void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val);
87 92
88/* INIT and RESET words */ 93/* INIT and RESET words */
89void wl12xx_spi_reset(struct wl12xx *wl); 94void wl1251_spi_reset(struct wl1251 *wl);
90void wl12xx_spi_init(struct wl12xx *wl); 95void wl1251_spi_init(struct wl1251 *wl);
91void wl12xx_set_partition(struct wl12xx *wl, 96int wl1251_set_partition(struct wl1251 *wl,
92 u32 part_start, u32 part_size, 97 u32 part_start, u32 part_size,
93 u32 reg_start, u32 reg_size); 98 u32 reg_start, u32 reg_size);
94 99
95static inline u32 wl12xx_read32(struct wl12xx *wl, int addr) 100static inline u32 wl1251_read32(struct wl1251 *wl, int addr)
96{ 101{
97 u32 response; 102 wl1251_spi_read(wl, addr, &wl->buffer_32,
103 sizeof(wl->buffer_32), false);
98 104
99 wl12xx_spi_read(wl, addr, &response, sizeof(u32)); 105 return wl->buffer_32;
100
101 return response;
102} 106}
103 107
104static inline void wl12xx_write32(struct wl12xx *wl, int addr, u32 val) 108static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val)
105{ 109{
106 wl12xx_spi_write(wl, addr, &val, sizeof(u32)); 110 wl->buffer_32 = val;
111 wl1251_spi_write(wl, addr, &wl->buffer_32,
112 sizeof(wl->buffer_32), false);
107} 113}
108 114
109#endif /* __WL12XX_SPI_H__ */ 115#endif /* __WL1251_SPI_H__ */
diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/wl1251_tx.c
index 62145e205a8c..2652a222383a 100644
--- a/drivers/net/wireless/wl12xx/tx.c
+++ b/drivers/net/wireless/wl12xx/wl1251_tx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -25,13 +25,13 @@
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/module.h> 26#include <linux/module.h>
27 27
28#include "wl12xx.h" 28#include "wl1251.h"
29#include "reg.h" 29#include "reg.h"
30#include "spi.h" 30#include "wl1251_spi.h"
31#include "tx.h" 31#include "wl1251_tx.h"
32#include "ps.h" 32#include "wl1251_ps.h"
33 33
34static bool wl12xx_tx_double_buffer_busy(struct wl12xx *wl, u32 data_out_count) 34static bool wl1251_tx_double_buffer_busy(struct wl1251 *wl, u32 data_out_count)
35{ 35{
36 int used, data_in_count; 36 int used, data_in_count;
37 37
@@ -52,15 +52,15 @@ static bool wl12xx_tx_double_buffer_busy(struct wl12xx *wl, u32 data_out_count)
52 return false; 52 return false;
53} 53}
54 54
55static int wl12xx_tx_path_status(struct wl12xx *wl) 55static int wl1251_tx_path_status(struct wl1251 *wl)
56{ 56{
57 u32 status, addr, data_out_count; 57 u32 status, addr, data_out_count;
58 bool busy; 58 bool busy;
59 59
60 addr = wl->data_path->tx_control_addr; 60 addr = wl->data_path->tx_control_addr;
61 status = wl12xx_mem_read32(wl, addr); 61 status = wl1251_mem_read32(wl, addr);
62 data_out_count = status & TX_STATUS_DATA_OUT_COUNT_MASK; 62 data_out_count = status & TX_STATUS_DATA_OUT_COUNT_MASK;
63 busy = wl12xx_tx_double_buffer_busy(wl, data_out_count); 63 busy = wl1251_tx_double_buffer_busy(wl, data_out_count);
64 64
65 if (busy) 65 if (busy)
66 return -EBUSY; 66 return -EBUSY;
@@ -68,7 +68,7 @@ static int wl12xx_tx_path_status(struct wl12xx *wl)
68 return 0; 68 return 0;
69} 69}
70 70
71static int wl12xx_tx_id(struct wl12xx *wl, struct sk_buff *skb) 71static int wl1251_tx_id(struct wl1251 *wl, struct sk_buff *skb)
72{ 72{
73 int i; 73 int i;
74 74
@@ -81,7 +81,7 @@ static int wl12xx_tx_id(struct wl12xx *wl, struct sk_buff *skb)
81 return -EBUSY; 81 return -EBUSY;
82} 82}
83 83
84static void wl12xx_tx_control(struct tx_double_buffer_desc *tx_hdr, 84static void wl1251_tx_control(struct tx_double_buffer_desc *tx_hdr,
85 struct ieee80211_tx_info *control, u16 fc) 85 struct ieee80211_tx_info *control, u16 fc)
86{ 86{
87 *(u16 *)&tx_hdr->control = 0; 87 *(u16 *)&tx_hdr->control = 0;
@@ -109,7 +109,7 @@ static void wl12xx_tx_control(struct tx_double_buffer_desc *tx_hdr,
109#define MAX_MPDU_HEADER_AND_SECURITY (MAX_MPDU_SECURITY_LENGTH + \ 109#define MAX_MPDU_HEADER_AND_SECURITY (MAX_MPDU_SECURITY_LENGTH + \
110 WLAN_QOS_HDR_LEN) 110 WLAN_QOS_HDR_LEN)
111#define HW_BLOCK_SIZE 252 111#define HW_BLOCK_SIZE 252
112static void wl12xx_tx_frag_block_num(struct tx_double_buffer_desc *tx_hdr) 112static void wl1251_tx_frag_block_num(struct tx_double_buffer_desc *tx_hdr)
113{ 113{
114 u16 payload_len, frag_threshold, mem_blocks; 114 u16 payload_len, frag_threshold, mem_blocks;
115 u16 num_mpdus, mem_blocks_per_frag; 115 u16 num_mpdus, mem_blocks_per_frag;
@@ -142,7 +142,7 @@ static void wl12xx_tx_frag_block_num(struct tx_double_buffer_desc *tx_hdr)
142 tx_hdr->num_mem_blocks = mem_blocks; 142 tx_hdr->num_mem_blocks = mem_blocks;
143} 143}
144 144
145static int wl12xx_tx_fill_hdr(struct wl12xx *wl, struct sk_buff *skb, 145static int wl1251_tx_fill_hdr(struct wl1251 *wl, struct sk_buff *skb,
146 struct ieee80211_tx_info *control) 146 struct ieee80211_tx_info *control)
147{ 147{
148 struct tx_double_buffer_desc *tx_hdr; 148 struct tx_double_buffer_desc *tx_hdr;
@@ -153,7 +153,7 @@ static int wl12xx_tx_fill_hdr(struct wl12xx *wl, struct sk_buff *skb,
153 if (!skb) 153 if (!skb)
154 return -EINVAL; 154 return -EINVAL;
155 155
156 id = wl12xx_tx_id(wl, skb); 156 id = wl1251_tx_id(wl, skb);
157 if (id < 0) 157 if (id < 0)
158 return id; 158 return id;
159 159
@@ -170,14 +170,14 @@ static int wl12xx_tx_fill_hdr(struct wl12xx *wl, struct sk_buff *skb,
170 /* FIXME: how to get the correct queue id? */ 170 /* FIXME: how to get the correct queue id? */
171 tx_hdr->xmit_queue = 0; 171 tx_hdr->xmit_queue = 0;
172 172
173 wl12xx_tx_control(tx_hdr, control, fc); 173 wl1251_tx_control(tx_hdr, control, fc);
174 wl12xx_tx_frag_block_num(tx_hdr); 174 wl1251_tx_frag_block_num(tx_hdr);
175 175
176 return 0; 176 return 0;
177} 177}
178 178
179/* We copy the packet to the target */ 179/* We copy the packet to the target */
180static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb, 180static int wl1251_tx_send_packet(struct wl1251 *wl, struct sk_buff *skb,
181 struct ieee80211_tx_info *control) 181 struct ieee80211_tx_info *control)
182{ 182{
183 struct tx_double_buffer_desc *tx_hdr; 183 struct tx_double_buffer_desc *tx_hdr;
@@ -196,12 +196,12 @@ static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb,
196 u8 *pos; 196 u8 *pos;
197 197
198 fc = *(u16 *)(skb->data + sizeof(*tx_hdr)); 198 fc = *(u16 *)(skb->data + sizeof(*tx_hdr));
199 tx_hdr->length += WL12XX_TKIP_IV_SPACE; 199 tx_hdr->length += WL1251_TKIP_IV_SPACE;
200 200
201 hdrlen = ieee80211_hdrlen(fc); 201 hdrlen = ieee80211_hdrlen(fc);
202 202
203 pos = skb_push(skb, WL12XX_TKIP_IV_SPACE); 203 pos = skb_push(skb, WL1251_TKIP_IV_SPACE);
204 memmove(pos, pos + WL12XX_TKIP_IV_SPACE, 204 memmove(pos, pos + WL1251_TKIP_IV_SPACE,
205 sizeof(*tx_hdr) + hdrlen); 205 sizeof(*tx_hdr) + hdrlen);
206 } 206 }
207 207
@@ -211,7 +211,7 @@ static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb,
211 */ 211 */
212 if (unlikely((long)skb->data & 0x03)) { 212 if (unlikely((long)skb->data & 0x03)) {
213 int offset = (4 - (long)skb->data) & 0x03; 213 int offset = (4 - (long)skb->data) & 0x03;
214 wl12xx_debug(DEBUG_TX, "skb offset %d", offset); 214 wl1251_debug(DEBUG_TX, "skb offset %d", offset);
215 215
216 /* check whether the current skb can be used */ 216 /* check whether the current skb can be used */
217 if (!skb_cloned(skb) && (skb_tailroom(skb) >= offset)) { 217 if (!skb_cloned(skb) && (skb_tailroom(skb) >= offset)) {
@@ -221,13 +221,13 @@ static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb,
221 skb_reserve(skb, offset); 221 skb_reserve(skb, offset);
222 memmove(skb->data, src, skb->len); 222 memmove(skb->data, src, skb->len);
223 } else { 223 } else {
224 wl12xx_info("No handler, fixme!"); 224 wl1251_info("No handler, fixme!");
225 return -EINVAL; 225 return -EINVAL;
226 } 226 }
227 } 227 }
228 228
229 /* Our skb->data at this point includes the HW header */ 229 /* Our skb->data at this point includes the HW header */
230 len = WL12XX_TX_ALIGN(skb->len); 230 len = WL1251_TX_ALIGN(skb->len);
231 231
232 if (wl->data_in_count & 0x1) 232 if (wl->data_in_count & 0x1)
233 addr = wl->data_path->tx_packet_ring_addr + 233 addr = wl->data_path->tx_packet_ring_addr +
@@ -235,15 +235,15 @@ static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb,
235 else 235 else
236 addr = wl->data_path->tx_packet_ring_addr; 236 addr = wl->data_path->tx_packet_ring_addr;
237 237
238 wl12xx_spi_mem_write(wl, addr, skb->data, len); 238 wl1251_spi_mem_write(wl, addr, skb->data, len);
239 239
240 wl12xx_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u rate 0x%x", 240 wl1251_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u rate 0x%x",
241 tx_hdr->id, skb, tx_hdr->length, tx_hdr->rate); 241 tx_hdr->id, skb, tx_hdr->length, tx_hdr->rate);
242 242
243 return 0; 243 return 0;
244} 244}
245 245
246static void wl12xx_tx_trigger(struct wl12xx *wl) 246static void wl1251_tx_trigger(struct wl1251 *wl)
247{ 247{
248 u32 data, addr; 248 u32 data, addr;
249 249
@@ -255,7 +255,7 @@ static void wl12xx_tx_trigger(struct wl12xx *wl)
255 data = INTR_TRIG_TX_PROC0; 255 data = INTR_TRIG_TX_PROC0;
256 } 256 }
257 257
258 wl12xx_reg_write32(wl, addr, data); 258 wl1251_reg_write32(wl, addr, data);
259 259
260 /* Bumping data in */ 260 /* Bumping data in */
261 wl->data_in_count = (wl->data_in_count + 1) & 261 wl->data_in_count = (wl->data_in_count + 1) &
@@ -263,7 +263,7 @@ static void wl12xx_tx_trigger(struct wl12xx *wl)
263} 263}
264 264
265/* caller must hold wl->mutex */ 265/* caller must hold wl->mutex */
266static int wl12xx_tx_frame(struct wl12xx *wl, struct sk_buff *skb) 266static int wl1251_tx_frame(struct wl1251 *wl, struct sk_buff *skb)
267{ 267{
268 struct ieee80211_tx_info *info; 268 struct ieee80211_tx_info *info;
269 int ret = 0; 269 int ret = 0;
@@ -274,51 +274,53 @@ static int wl12xx_tx_frame(struct wl12xx *wl, struct sk_buff *skb)
274 if (info->control.hw_key) { 274 if (info->control.hw_key) {
275 idx = info->control.hw_key->hw_key_idx; 275 idx = info->control.hw_key->hw_key_idx;
276 if (unlikely(wl->default_key != idx)) { 276 if (unlikely(wl->default_key != idx)) {
277 ret = wl12xx_acx_default_key(wl, idx); 277 ret = wl1251_acx_default_key(wl, idx);
278 if (ret < 0) 278 if (ret < 0)
279 return ret; 279 return ret;
280 } 280 }
281 } 281 }
282 282
283 ret = wl12xx_tx_path_status(wl); 283 ret = wl1251_tx_path_status(wl);
284 if (ret < 0) 284 if (ret < 0)
285 return ret; 285 return ret;
286 286
287 ret = wl12xx_tx_fill_hdr(wl, skb, info); 287 ret = wl1251_tx_fill_hdr(wl, skb, info);
288 if (ret < 0) 288 if (ret < 0)
289 return ret; 289 return ret;
290 290
291 ret = wl12xx_tx_send_packet(wl, skb, info); 291 ret = wl1251_tx_send_packet(wl, skb, info);
292 if (ret < 0) 292 if (ret < 0)
293 return ret; 293 return ret;
294 294
295 wl12xx_tx_trigger(wl); 295 wl1251_tx_trigger(wl);
296 296
297 return ret; 297 return ret;
298} 298}
299 299
300void wl12xx_tx_work(struct work_struct *work) 300void wl1251_tx_work(struct work_struct *work)
301{ 301{
302 struct wl12xx *wl = container_of(work, struct wl12xx, tx_work); 302 struct wl1251 *wl = container_of(work, struct wl1251, tx_work);
303 struct sk_buff *skb; 303 struct sk_buff *skb;
304 bool woken_up = false; 304 bool woken_up = false;
305 int ret; 305 int ret;
306 306
307 mutex_lock(&wl->mutex); 307 mutex_lock(&wl->mutex);
308 308
309 if (unlikely(wl->state == WL12XX_STATE_OFF)) 309 if (unlikely(wl->state == WL1251_STATE_OFF))
310 goto out; 310 goto out;
311 311
312 while ((skb = skb_dequeue(&wl->tx_queue))) { 312 while ((skb = skb_dequeue(&wl->tx_queue))) {
313 if (!woken_up) { 313 if (!woken_up) {
314 wl12xx_ps_elp_wakeup(wl); 314 ret = wl1251_ps_elp_wakeup(wl);
315 if (ret < 0)
316 goto out;
315 woken_up = true; 317 woken_up = true;
316 } 318 }
317 319
318 ret = wl12xx_tx_frame(wl, skb); 320 ret = wl1251_tx_frame(wl, skb);
319 if (ret == -EBUSY) { 321 if (ret == -EBUSY) {
320 /* firmware buffer is full, stop queues */ 322 /* firmware buffer is full, stop queues */
321 wl12xx_debug(DEBUG_TX, "tx_work: fw buffer full, " 323 wl1251_debug(DEBUG_TX, "tx_work: fw buffer full, "
322 "stop queues"); 324 "stop queues");
323 ieee80211_stop_queues(wl->hw); 325 ieee80211_stop_queues(wl->hw);
324 wl->tx_queue_stopped = true; 326 wl->tx_queue_stopped = true;
@@ -332,12 +334,12 @@ void wl12xx_tx_work(struct work_struct *work)
332 334
333out: 335out:
334 if (woken_up) 336 if (woken_up)
335 wl12xx_ps_elp_sleep(wl); 337 wl1251_ps_elp_sleep(wl);
336 338
337 mutex_unlock(&wl->mutex); 339 mutex_unlock(&wl->mutex);
338} 340}
339 341
340static const char *wl12xx_tx_parse_status(u8 status) 342static const char *wl1251_tx_parse_status(u8 status)
341{ 343{
342 /* 8 bit status field, one character per bit plus null */ 344 /* 8 bit status field, one character per bit plus null */
343 static char buf[9]; 345 static char buf[9];
@@ -365,7 +367,7 @@ static const char *wl12xx_tx_parse_status(u8 status)
365 return buf; 367 return buf;
366} 368}
367 369
368static void wl12xx_tx_packet_cb(struct wl12xx *wl, 370static void wl1251_tx_packet_cb(struct wl1251 *wl,
369 struct tx_result *result) 371 struct tx_result *result)
370{ 372{
371 struct ieee80211_tx_info *info; 373 struct ieee80211_tx_info *info;
@@ -375,7 +377,7 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl,
375 377
376 skb = wl->tx_frames[result->id]; 378 skb = wl->tx_frames[result->id];
377 if (skb == NULL) { 379 if (skb == NULL) {
378 wl12xx_error("SKB for packet %d is NULL", result->id); 380 wl1251_error("SKB for packet %d is NULL", result->id);
379 return; 381 return;
380 } 382 }
381 383
@@ -396,14 +398,14 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl,
396 if (info->control.hw_key && 398 if (info->control.hw_key &&
397 info->control.hw_key->alg == ALG_TKIP) { 399 info->control.hw_key->alg == ALG_TKIP) {
398 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 400 hdrlen = ieee80211_get_hdrlen_from_skb(skb);
399 memmove(frame + WL12XX_TKIP_IV_SPACE, frame, hdrlen); 401 memmove(frame + WL1251_TKIP_IV_SPACE, frame, hdrlen);
400 skb_pull(skb, WL12XX_TKIP_IV_SPACE); 402 skb_pull(skb, WL1251_TKIP_IV_SPACE);
401 } 403 }
402 404
403 wl12xx_debug(DEBUG_TX, "tx status id %u skb 0x%p failures %u rate 0x%x" 405 wl1251_debug(DEBUG_TX, "tx status id %u skb 0x%p failures %u rate 0x%x"
404 " status 0x%x (%s)", 406 " status 0x%x (%s)",
405 result->id, skb, result->ack_failures, result->rate, 407 result->id, skb, result->ack_failures, result->rate,
406 result->status, wl12xx_tx_parse_status(result->status)); 408 result->status, wl1251_tx_parse_status(result->status));
407 409
408 410
409 ieee80211_tx_status(wl->hw, skb); 411 ieee80211_tx_status(wl->hw, skb);
@@ -411,7 +413,7 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl,
411 wl->tx_frames[result->id] = NULL; 413 wl->tx_frames[result->id] = NULL;
412 414
413 if (wl->tx_queue_stopped) { 415 if (wl->tx_queue_stopped) {
414 wl12xx_debug(DEBUG_TX, "cb: queue was stopped"); 416 wl1251_debug(DEBUG_TX, "cb: queue was stopped");
415 417
416 skb = skb_dequeue(&wl->tx_queue); 418 skb = skb_dequeue(&wl->tx_queue);
417 419
@@ -420,10 +422,10 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl,
420 queue empty */ 422 queue empty */
421 423
422 if (skb) { 424 if (skb) {
423 ret = wl12xx_tx_frame(wl, skb); 425 ret = wl1251_tx_frame(wl, skb);
424 if (ret == -EBUSY) { 426 if (ret == -EBUSY) {
425 /* firmware buffer is still full */ 427 /* firmware buffer is still full */
426 wl12xx_debug(DEBUG_TX, "cb: fw buffer " 428 wl1251_debug(DEBUG_TX, "cb: fw buffer "
427 "still full"); 429 "still full");
428 skb_queue_head(&wl->tx_queue, skb); 430 skb_queue_head(&wl->tx_queue, skb);
429 return; 431 return;
@@ -433,23 +435,23 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl,
433 } 435 }
434 } 436 }
435 437
436 wl12xx_debug(DEBUG_TX, "cb: waking queues"); 438 wl1251_debug(DEBUG_TX, "cb: waking queues");
437 ieee80211_wake_queues(wl->hw); 439 ieee80211_wake_queues(wl->hw);
438 wl->tx_queue_stopped = false; 440 wl->tx_queue_stopped = false;
439 } 441 }
440} 442}
441 443
442/* Called upon reception of a TX complete interrupt */ 444/* Called upon reception of a TX complete interrupt */
443void wl12xx_tx_complete(struct wl12xx *wl) 445void wl1251_tx_complete(struct wl1251 *wl)
444{ 446{
445 int i, result_index, num_complete = 0; 447 int i, result_index, num_complete = 0;
446 struct tx_result result[FW_TX_CMPLT_BLOCK_SIZE], *result_ptr; 448 struct tx_result result[FW_TX_CMPLT_BLOCK_SIZE], *result_ptr;
447 449
448 if (unlikely(wl->state != WL12XX_STATE_ON)) 450 if (unlikely(wl->state != WL1251_STATE_ON))
449 return; 451 return;
450 452
451 /* First we read the result */ 453 /* First we read the result */
452 wl12xx_spi_mem_read(wl, wl->data_path->tx_complete_addr, 454 wl1251_spi_mem_read(wl, wl->data_path->tx_complete_addr,
453 result, sizeof(result)); 455 result, sizeof(result));
454 456
455 result_index = wl->next_tx_complete; 457 result_index = wl->next_tx_complete;
@@ -459,7 +461,7 @@ void wl12xx_tx_complete(struct wl12xx *wl)
459 461
460 if (result_ptr->done_1 == 1 && 462 if (result_ptr->done_1 == 1 &&
461 result_ptr->done_2 == 1) { 463 result_ptr->done_2 == 1) {
462 wl12xx_tx_packet_cb(wl, result_ptr); 464 wl1251_tx_packet_cb(wl, result_ptr);
463 465
464 result_ptr->done_1 = 0; 466 result_ptr->done_1 = 0;
465 result_ptr->done_2 = 0; 467 result_ptr->done_2 = 0;
@@ -480,7 +482,7 @@ void wl12xx_tx_complete(struct wl12xx *wl)
480 */ 482 */
481 if (result_index > wl->next_tx_complete) { 483 if (result_index > wl->next_tx_complete) {
482 /* Only 1 write is needed */ 484 /* Only 1 write is needed */
483 wl12xx_spi_mem_write(wl, 485 wl1251_spi_mem_write(wl,
484 wl->data_path->tx_complete_addr + 486 wl->data_path->tx_complete_addr +
485 (wl->next_tx_complete * 487 (wl->next_tx_complete *
486 sizeof(struct tx_result)), 488 sizeof(struct tx_result)),
@@ -491,7 +493,7 @@ void wl12xx_tx_complete(struct wl12xx *wl)
491 493
492 } else if (result_index < wl->next_tx_complete) { 494 } else if (result_index < wl->next_tx_complete) {
493 /* 2 writes are needed */ 495 /* 2 writes are needed */
494 wl12xx_spi_mem_write(wl, 496 wl1251_spi_mem_write(wl,
495 wl->data_path->tx_complete_addr + 497 wl->data_path->tx_complete_addr +
496 (wl->next_tx_complete * 498 (wl->next_tx_complete *
497 sizeof(struct tx_result)), 499 sizeof(struct tx_result)),
@@ -500,7 +502,7 @@ void wl12xx_tx_complete(struct wl12xx *wl)
500 wl->next_tx_complete) * 502 wl->next_tx_complete) *
501 sizeof(struct tx_result)); 503 sizeof(struct tx_result));
502 504
503 wl12xx_spi_mem_write(wl, 505 wl1251_spi_mem_write(wl,
504 wl->data_path->tx_complete_addr, 506 wl->data_path->tx_complete_addr,
505 result, 507 result,
506 (num_complete - 508 (num_complete -
@@ -510,7 +512,7 @@ void wl12xx_tx_complete(struct wl12xx *wl)
510 512
511 } else { 513 } else {
512 /* We have to write the whole array */ 514 /* We have to write the whole array */
513 wl12xx_spi_mem_write(wl, 515 wl1251_spi_mem_write(wl,
514 wl->data_path->tx_complete_addr, 516 wl->data_path->tx_complete_addr,
515 result, 517 result,
516 FW_TX_CMPLT_BLOCK_SIZE * 518 FW_TX_CMPLT_BLOCK_SIZE *
@@ -523,7 +525,7 @@ void wl12xx_tx_complete(struct wl12xx *wl)
523} 525}
524 526
525/* caller must hold wl->mutex */ 527/* caller must hold wl->mutex */
526void wl12xx_tx_flush(struct wl12xx *wl) 528void wl1251_tx_flush(struct wl1251 *wl)
527{ 529{
528 int i; 530 int i;
529 struct sk_buff *skb; 531 struct sk_buff *skb;
@@ -535,7 +537,7 @@ void wl12xx_tx_flush(struct wl12xx *wl)
535 while ((skb = skb_dequeue(&wl->tx_queue))) { 537 while ((skb = skb_dequeue(&wl->tx_queue))) {
536 info = IEEE80211_SKB_CB(skb); 538 info = IEEE80211_SKB_CB(skb);
537 539
538 wl12xx_debug(DEBUG_TX, "flushing skb 0x%p", skb); 540 wl1251_debug(DEBUG_TX, "flushing skb 0x%p", skb);
539 541
540 if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) 542 if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS))
541 continue; 543 continue;
diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/wl1251_tx.h
index dc82691f4c14..7c1c1665c810 100644
--- a/drivers/net/wireless/wl12xx/tx.h
+++ b/drivers/net/wireless/wl12xx/wl1251_tx.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * This file is part of wl12xx 2 * This file is part of wl1251
3 * 3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated 4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008 Nokia Corporation 5 * Copyright (C) 2008 Nokia Corporation
@@ -22,8 +22,8 @@
22 * 22 *
23 */ 23 */
24 24
25#ifndef __WL12XX_TX_H__ 25#ifndef __WL1251_TX_H__
26#define __WL12XX_TX_H__ 26#define __WL1251_TX_H__
27 27
28#include <linux/bitops.h> 28#include <linux/bitops.h>
29 29
@@ -73,10 +73,11 @@
73 73
74#define TX_COMPLETE_REQUIRED_BIT 0x80 74#define TX_COMPLETE_REQUIRED_BIT 0x80
75#define TX_STATUS_DATA_OUT_COUNT_MASK 0xf 75#define TX_STATUS_DATA_OUT_COUNT_MASK 0xf
76#define WL12XX_TX_ALIGN_TO 4 76
77#define WL12XX_TX_ALIGN(len) (((len) + WL12XX_TX_ALIGN_TO - 1) & \ 77#define WL1251_TX_ALIGN_TO 4
78 ~(WL12XX_TX_ALIGN_TO - 1)) 78#define WL1251_TX_ALIGN(len) (((len) + WL1251_TX_ALIGN_TO - 1) & \
79#define WL12XX_TKIP_IV_SPACE 4 79 ~(WL1251_TX_ALIGN_TO - 1))
80#define WL1251_TKIP_IV_SPACE 4
80 81
81struct tx_control { 82struct tx_control {
82 /* Rate Policy (class) index */ 83 /* Rate Policy (class) index */
@@ -208,8 +209,8 @@ struct tx_result {
208 u8 done_2; 209 u8 done_2;
209} __attribute__ ((packed)); 210} __attribute__ ((packed));
210 211
211void wl12xx_tx_work(struct work_struct *work); 212void wl1251_tx_work(struct work_struct *work);
212void wl12xx_tx_complete(struct wl12xx *wl); 213void wl1251_tx_complete(struct wl1251 *wl);
213void wl12xx_tx_flush(struct wl12xx *wl); 214void wl1251_tx_flush(struct wl1251 *wl);
214 215
215#endif 216#endif
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
deleted file mode 100644
index 48641437414b..000000000000
--- a/drivers/net/wireless/wl12xx/wl12xx.h
+++ /dev/null
@@ -1,409 +0,0 @@
1/*
2 * This file is part of wl12xx
3 *
4 * Copyright (c) 1998-2007 Texas Instruments Incorporated
5 * Copyright (C) 2008-2009 Nokia Corporation
6 *
7 * Contact: Kalle Valo <kalle.valo@nokia.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * version 2 as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef __WL12XX_H__
26#define __WL12XX_H__
27
28#include <linux/mutex.h>
29#include <linux/list.h>
30#include <linux/bitops.h>
31#include <net/mac80211.h>
32
33#define DRIVER_NAME "wl12xx"
34#define DRIVER_PREFIX DRIVER_NAME ": "
35
36enum {
37 DEBUG_NONE = 0,
38 DEBUG_IRQ = BIT(0),
39 DEBUG_SPI = BIT(1),
40 DEBUG_BOOT = BIT(2),
41 DEBUG_MAILBOX = BIT(3),
42 DEBUG_NETLINK = BIT(4),
43 DEBUG_EVENT = BIT(5),
44 DEBUG_TX = BIT(6),
45 DEBUG_RX = BIT(7),
46 DEBUG_SCAN = BIT(8),
47 DEBUG_CRYPT = BIT(9),
48 DEBUG_PSM = BIT(10),
49 DEBUG_MAC80211 = BIT(11),
50 DEBUG_CMD = BIT(12),
51 DEBUG_ACX = BIT(13),
52 DEBUG_ALL = ~0,
53};
54
55#define DEBUG_LEVEL (DEBUG_NONE)
56
57#define DEBUG_DUMP_LIMIT 1024
58
59#define wl12xx_error(fmt, arg...) \
60 printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg)
61
62#define wl12xx_warning(fmt, arg...) \
63 printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg)
64
65#define wl12xx_notice(fmt, arg...) \
66 printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg)
67
68#define wl12xx_info(fmt, arg...) \
69 printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg)
70
71#define wl12xx_debug(level, fmt, arg...) \
72 do { \
73 if (level & DEBUG_LEVEL) \
74 printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \
75 } while (0)
76
77#define wl12xx_dump(level, prefix, buf, len) \
78 do { \
79 if (level & DEBUG_LEVEL) \
80 print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
81 DUMP_PREFIX_OFFSET, 16, 1, \
82 buf, \
83 min_t(size_t, len, DEBUG_DUMP_LIMIT), \
84 0); \
85 } while (0)
86
87#define wl12xx_dump_ascii(level, prefix, buf, len) \
88 do { \
89 if (level & DEBUG_LEVEL) \
90 print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \
91 DUMP_PREFIX_OFFSET, 16, 1, \
92 buf, \
93 min_t(size_t, len, DEBUG_DUMP_LIMIT), \
94 true); \
95 } while (0)
96
97#define WL12XX_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \
98 CFG_BSSID_FILTER_EN)
99
100#define WL12XX_DEFAULT_RX_FILTER (CFG_RX_PRSP_EN | \
101 CFG_RX_MGMT_EN | \
102 CFG_RX_DATA_EN | \
103 CFG_RX_CTL_EN | \
104 CFG_RX_BCN_EN | \
105 CFG_RX_AUTH_EN | \
106 CFG_RX_ASSOC_EN)
107
108
109struct boot_attr {
110 u32 radio_type;
111 u8 mac_clock;
112 u8 arm_clock;
113 int firmware_debug;
114 u32 minor;
115 u32 major;
116 u32 bugfix;
117};
118
119enum wl12xx_state {
120 WL12XX_STATE_OFF,
121 WL12XX_STATE_ON,
122 WL12XX_STATE_PLT,
123};
124
125enum wl12xx_partition_type {
126 PART_DOWN,
127 PART_WORK,
128 PART_DRPW,
129
130 PART_TABLE_LEN
131};
132
133struct wl12xx_partition {
134 u32 size;
135 u32 start;
136};
137
138struct wl12xx_partition_set {
139 struct wl12xx_partition mem;
140 struct wl12xx_partition reg;
141};
142
143struct wl12xx;
144
145/* FIXME: I'm not sure about this structure name */
146struct wl12xx_chip {
147 u32 id;
148
149 const char *fw_filename;
150 const char *nvs_filename;
151
152 char fw_ver[21];
153
154 unsigned int power_on_sleep;
155 int intr_cmd_complete;
156 int intr_init_complete;
157
158 int (*op_upload_fw)(struct wl12xx *wl);
159 int (*op_upload_nvs)(struct wl12xx *wl);
160 int (*op_boot)(struct wl12xx *wl);
161 void (*op_set_ecpu_ctrl)(struct wl12xx *wl, u32 flag);
162 void (*op_target_enable_interrupts)(struct wl12xx *wl);
163 int (*op_hw_init)(struct wl12xx *wl);
164 int (*op_plt_init)(struct wl12xx *wl);
165
166 struct wl12xx_partition_set *p_table;
167 enum wl12xx_acx_int_reg *acx_reg_table;
168};
169
170struct wl12xx_stats {
171 struct acx_statistics *fw_stats;
172 unsigned long fw_stats_update;
173
174 unsigned int retry_count;
175 unsigned int excessive_retries;
176};
177
178struct wl12xx_debugfs {
179 struct dentry *rootdir;
180 struct dentry *fw_statistics;
181
182 struct dentry *tx_internal_desc_overflow;
183
184 struct dentry *rx_out_of_mem;
185 struct dentry *rx_hdr_overflow;
186 struct dentry *rx_hw_stuck;
187 struct dentry *rx_dropped;
188 struct dentry *rx_fcs_err;
189 struct dentry *rx_xfr_hint_trig;
190 struct dentry *rx_path_reset;
191 struct dentry *rx_reset_counter;
192
193 struct dentry *dma_rx_requested;
194 struct dentry *dma_rx_errors;
195 struct dentry *dma_tx_requested;
196 struct dentry *dma_tx_errors;
197
198 struct dentry *isr_cmd_cmplt;
199 struct dentry *isr_fiqs;
200 struct dentry *isr_rx_headers;
201 struct dentry *isr_rx_mem_overflow;
202 struct dentry *isr_rx_rdys;
203 struct dentry *isr_irqs;
204 struct dentry *isr_tx_procs;
205 struct dentry *isr_decrypt_done;
206 struct dentry *isr_dma0_done;
207 struct dentry *isr_dma1_done;
208 struct dentry *isr_tx_exch_complete;
209 struct dentry *isr_commands;
210 struct dentry *isr_rx_procs;
211 struct dentry *isr_hw_pm_mode_changes;
212 struct dentry *isr_host_acknowledges;
213 struct dentry *isr_pci_pm;
214 struct dentry *isr_wakeups;
215 struct dentry *isr_low_rssi;
216
217 struct dentry *wep_addr_key_count;
218 struct dentry *wep_default_key_count;
219 /* skipping wep.reserved */
220 struct dentry *wep_key_not_found;
221 struct dentry *wep_decrypt_fail;
222 struct dentry *wep_packets;
223 struct dentry *wep_interrupt;
224
225 struct dentry *pwr_ps_enter;
226 struct dentry *pwr_elp_enter;
227 struct dentry *pwr_missing_bcns;
228 struct dentry *pwr_wake_on_host;
229 struct dentry *pwr_wake_on_timer_exp;
230 struct dentry *pwr_tx_with_ps;
231 struct dentry *pwr_tx_without_ps;
232 struct dentry *pwr_rcvd_beacons;
233 struct dentry *pwr_power_save_off;
234 struct dentry *pwr_enable_ps;
235 struct dentry *pwr_disable_ps;
236 struct dentry *pwr_fix_tsf_ps;
237 /* skipping cont_miss_bcns_spread for now */
238 struct dentry *pwr_rcvd_awake_beacons;
239
240 struct dentry *mic_rx_pkts;
241 struct dentry *mic_calc_failure;
242
243 struct dentry *aes_encrypt_fail;
244 struct dentry *aes_decrypt_fail;
245 struct dentry *aes_encrypt_packets;
246 struct dentry *aes_decrypt_packets;
247 struct dentry *aes_encrypt_interrupt;
248 struct dentry *aes_decrypt_interrupt;
249
250 struct dentry *event_heart_beat;
251 struct dentry *event_calibration;
252 struct dentry *event_rx_mismatch;
253 struct dentry *event_rx_mem_empty;
254 struct dentry *event_rx_pool;
255 struct dentry *event_oom_late;
256 struct dentry *event_phy_transmit_error;
257 struct dentry *event_tx_stuck;
258
259 struct dentry *ps_pspoll_timeouts;
260 struct dentry *ps_upsd_timeouts;
261 struct dentry *ps_upsd_max_sptime;
262 struct dentry *ps_upsd_max_apturn;
263 struct dentry *ps_pspoll_max_apturn;
264 struct dentry *ps_pspoll_utilization;
265 struct dentry *ps_upsd_utilization;
266
267 struct dentry *rxpipe_rx_prep_beacon_drop;
268 struct dentry *rxpipe_descr_host_int_trig_rx_data;
269 struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data;
270 struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data;
271 struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data;
272
273 struct dentry *tx_queue_len;
274
275 struct dentry *retry_count;
276 struct dentry *excessive_retries;
277};
278
279struct wl12xx {
280 struct ieee80211_hw *hw;
281 bool mac80211_registered;
282
283 struct spi_device *spi;
284
285 void (*set_power)(bool enable);
286 int irq;
287
288 enum wl12xx_state state;
289 struct mutex mutex;
290
291 int physical_mem_addr;
292 int physical_reg_addr;
293 int virtual_mem_addr;
294 int virtual_reg_addr;
295
296 struct wl12xx_chip chip;
297
298 int cmd_box_addr;
299 int event_box_addr;
300 struct boot_attr boot_attr;
301
302 u8 *fw;
303 size_t fw_len;
304 u8 *nvs;
305 size_t nvs_len;
306
307 u8 bssid[ETH_ALEN];
308 u8 mac_addr[ETH_ALEN];
309 u8 bss_type;
310 u8 listen_int;
311 int channel;
312
313 void *target_mem_map;
314 struct acx_data_path_params_resp *data_path;
315
316 /* Number of TX packets transferred to the FW, modulo 16 */
317 u32 data_in_count;
318
319 /* Frames scheduled for transmission, not handled yet */
320 struct sk_buff_head tx_queue;
321 bool tx_queue_stopped;
322
323 struct work_struct tx_work;
324 struct work_struct filter_work;
325
326 /* Pending TX frames */
327 struct sk_buff *tx_frames[16];
328
329 /*
330 * Index pointing to the next TX complete entry
331 * in the cyclic XT complete array we get from
332 * the FW.
333 */
334 u32 next_tx_complete;
335
336 /* FW Rx counter */
337 u32 rx_counter;
338
339 /* Rx frames handled */
340 u32 rx_handled;
341
342 /* Current double buffer */
343 u32 rx_current_buffer;
344 u32 rx_last_id;
345
346 /* The target interrupt mask */
347 u32 intr_mask;
348 struct work_struct irq_work;
349
350 /* The mbox event mask */
351 u32 event_mask;
352
353 /* Mailbox pointers */
354 u32 mbox_ptr[2];
355
356 /* Are we currently scanning */
357 bool scanning;
358
359 /* Our association ID */
360 u16 aid;
361
362 /* Default key (for WEP) */
363 u32 default_key;
364
365 unsigned int tx_mgmt_frm_rate;
366 unsigned int tx_mgmt_frm_mod;
367
368 unsigned int rx_config;
369 unsigned int rx_filter;
370
371 /* is firmware in elp mode */
372 bool elp;
373
374 /* we can be in psm, but not in elp, we have to differentiate */
375 bool psm;
376
377 /* PSM mode requested */
378 bool psm_requested;
379
380 /* in dBm */
381 int power_level;
382
383 struct wl12xx_stats stats;
384 struct wl12xx_debugfs debugfs;
385};
386
387int wl12xx_plt_start(struct wl12xx *wl);
388int wl12xx_plt_stop(struct wl12xx *wl);
389
390#define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG /* Long Preamble */
391#define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS
392#define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */
393
394#define WL12XX_DEFAULT_POWER_LEVEL 20
395
396#define WL12XX_TX_QUEUE_MAX_LENGTH 20
397
398/* Different chips need different sleep times after power on. WL1271 needs
399 * 200ms, WL1251 needs only 10ms. By default we use 200ms, but as soon as we
400 * know the chip ID, we change the sleep value in the wl12xx chip structure,
401 * so in subsequent power ons, we don't waste more time then needed. */
402#define WL12XX_DEFAULT_POWER_ON_SLEEP 200
403
404#define CHIP_ID_1251_PG10 (0x7010101)
405#define CHIP_ID_1251_PG11 (0x7020101)
406#define CHIP_ID_1251_PG12 (0x7030101)
407#define CHIP_ID_1271_PG10 (0x4030101)
408
409#endif