blob: b6a80cd5e9ef3f7f56d3680aa42ff527da1d23f7 [file] [log] [blame]
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001/*
2 * This file is part of wl18xx
3 *
4 * Copyright (C) 2011 Texas Instruments
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 *
20 */
21
22#include <linux/module.h>
23#include <linux/platform_device.h>
Arik Nemtsov2fc28de2012-05-10 12:13:27 +030024#include <linux/ip.h>
Luciano Coelho9a1a6992012-05-10 12:13:06 +030025
26#include "../wlcore/wlcore.h"
27#include "../wlcore/debug.h"
Luciano Coelho46a1d512012-05-10 12:13:12 +030028#include "../wlcore/io.h"
29#include "../wlcore/acx.h"
Arik Nemtsovfb0f2e42012-05-10 12:13:18 +030030#include "../wlcore/tx.h"
Arik Nemtsov9c809f82012-05-10 12:13:23 +030031#include "../wlcore/rx.h"
32#include "../wlcore/io.h"
Luciano Coelho46a1d512012-05-10 12:13:12 +030033#include "../wlcore/boot.h"
Luciano Coelho9a1a6992012-05-10 12:13:06 +030034
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +030035#include "reg.h"
Luciano Coelho46a1d512012-05-10 12:13:12 +030036#include "conf.h"
Luciano Coelhob8422dc2012-05-10 12:13:26 +030037#include "acx.h"
Arik Nemtsov872b3452012-05-10 12:13:25 +030038#include "tx.h"
Luciano Coelho274c66c2012-05-10 12:13:13 +030039#include "wl18xx.h"
Luciano Coelhobe652022012-05-10 12:13:41 +030040#include "io.h"
Luciano Coelho8c0ea102012-05-10 12:14:09 +030041#include "debugfs.h"
Arik Nemtsov1349c422012-05-10 12:13:16 +030042
Arik Nemtsov169da042012-05-10 12:13:28 +030043#define WL18XX_RX_CHECKSUM_MASK 0x40
44
Luciano Coelho174a7302012-05-10 12:14:13 +030045static char *ht_mode_param = "wide";
Luciano Coelho4b9d2362012-05-10 12:13:59 +030046static char *board_type_param = "hdk";
Luciano Coelhoe9258812012-05-10 12:13:52 +030047static bool dc2dc_param = false;
48static int n_antennas_2_param = 1;
49static int n_antennas_5_param = 1;
Assaf Azulay3d62eb52012-05-10 12:14:23 +030050static bool checksum_param = false;
Luciano Coelho1ddbc7d2012-05-10 12:13:56 +030051static bool enable_11a_param = true;
Luciano Coelho858403a2012-05-10 12:14:17 +030052static int low_band_component = -1;
53static int low_band_component_type = -1;
54static int high_band_component = -1;
55static int high_band_component_type = -1;
Luciano Coelho7b03c302012-05-10 12:14:18 +030056static int pwr_limit_reference_11_abg = -1;
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +030057
Arik Nemtsovf648eab2012-05-10 12:13:20 +030058static const u8 wl18xx_rate_to_idx_2ghz[] = {
59 /* MCS rates are used only with 11n */
60 15, /* WL18XX_CONF_HW_RXTX_RATE_MCS15 */
61 14, /* WL18XX_CONF_HW_RXTX_RATE_MCS14 */
62 13, /* WL18XX_CONF_HW_RXTX_RATE_MCS13 */
63 12, /* WL18XX_CONF_HW_RXTX_RATE_MCS12 */
64 11, /* WL18XX_CONF_HW_RXTX_RATE_MCS11 */
65 10, /* WL18XX_CONF_HW_RXTX_RATE_MCS10 */
66 9, /* WL18XX_CONF_HW_RXTX_RATE_MCS9 */
67 8, /* WL18XX_CONF_HW_RXTX_RATE_MCS8 */
68 7, /* WL18XX_CONF_HW_RXTX_RATE_MCS7 */
69 6, /* WL18XX_CONF_HW_RXTX_RATE_MCS6 */
70 5, /* WL18XX_CONF_HW_RXTX_RATE_MCS5 */
71 4, /* WL18XX_CONF_HW_RXTX_RATE_MCS4 */
72 3, /* WL18XX_CONF_HW_RXTX_RATE_MCS3 */
73 2, /* WL18XX_CONF_HW_RXTX_RATE_MCS2 */
74 1, /* WL18XX_CONF_HW_RXTX_RATE_MCS1 */
75 0, /* WL18XX_CONF_HW_RXTX_RATE_MCS0 */
76
77 11, /* WL18XX_CONF_HW_RXTX_RATE_54 */
78 10, /* WL18XX_CONF_HW_RXTX_RATE_48 */
79 9, /* WL18XX_CONF_HW_RXTX_RATE_36 */
80 8, /* WL18XX_CONF_HW_RXTX_RATE_24 */
81
82 /* TI-specific rate */
83 CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_22 */
84
85 7, /* WL18XX_CONF_HW_RXTX_RATE_18 */
86 6, /* WL18XX_CONF_HW_RXTX_RATE_12 */
87 3, /* WL18XX_CONF_HW_RXTX_RATE_11 */
88 5, /* WL18XX_CONF_HW_RXTX_RATE_9 */
89 4, /* WL18XX_CONF_HW_RXTX_RATE_6 */
90 2, /* WL18XX_CONF_HW_RXTX_RATE_5_5 */
91 1, /* WL18XX_CONF_HW_RXTX_RATE_2 */
92 0 /* WL18XX_CONF_HW_RXTX_RATE_1 */
93};
94
95static const u8 wl18xx_rate_to_idx_5ghz[] = {
96 /* MCS rates are used only with 11n */
97 15, /* WL18XX_CONF_HW_RXTX_RATE_MCS15 */
98 14, /* WL18XX_CONF_HW_RXTX_RATE_MCS14 */
99 13, /* WL18XX_CONF_HW_RXTX_RATE_MCS13 */
100 12, /* WL18XX_CONF_HW_RXTX_RATE_MCS12 */
101 11, /* WL18XX_CONF_HW_RXTX_RATE_MCS11 */
102 10, /* WL18XX_CONF_HW_RXTX_RATE_MCS10 */
103 9, /* WL18XX_CONF_HW_RXTX_RATE_MCS9 */
104 8, /* WL18XX_CONF_HW_RXTX_RATE_MCS8 */
105 7, /* WL18XX_CONF_HW_RXTX_RATE_MCS7 */
106 6, /* WL18XX_CONF_HW_RXTX_RATE_MCS6 */
107 5, /* WL18XX_CONF_HW_RXTX_RATE_MCS5 */
108 4, /* WL18XX_CONF_HW_RXTX_RATE_MCS4 */
109 3, /* WL18XX_CONF_HW_RXTX_RATE_MCS3 */
110 2, /* WL18XX_CONF_HW_RXTX_RATE_MCS2 */
111 1, /* WL18XX_CONF_HW_RXTX_RATE_MCS1 */
112 0, /* WL18XX_CONF_HW_RXTX_RATE_MCS0 */
113
114 7, /* WL18XX_CONF_HW_RXTX_RATE_54 */
115 6, /* WL18XX_CONF_HW_RXTX_RATE_48 */
116 5, /* WL18XX_CONF_HW_RXTX_RATE_36 */
117 4, /* WL18XX_CONF_HW_RXTX_RATE_24 */
118
119 /* TI-specific rate */
120 CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_22 */
121
122 3, /* WL18XX_CONF_HW_RXTX_RATE_18 */
123 2, /* WL18XX_CONF_HW_RXTX_RATE_12 */
124 CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_11 */
125 1, /* WL18XX_CONF_HW_RXTX_RATE_9 */
126 0, /* WL18XX_CONF_HW_RXTX_RATE_6 */
127 CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_5_5 */
128 CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_2 */
129 CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_1 */
130};
131
132static const u8 *wl18xx_band_rate_to_idx[] = {
133 [IEEE80211_BAND_2GHZ] = wl18xx_rate_to_idx_2ghz,
134 [IEEE80211_BAND_5GHZ] = wl18xx_rate_to_idx_5ghz
135};
136
137enum wl18xx_hw_rates {
138 WL18XX_CONF_HW_RXTX_RATE_MCS15 = 0,
139 WL18XX_CONF_HW_RXTX_RATE_MCS14,
140 WL18XX_CONF_HW_RXTX_RATE_MCS13,
141 WL18XX_CONF_HW_RXTX_RATE_MCS12,
142 WL18XX_CONF_HW_RXTX_RATE_MCS11,
143 WL18XX_CONF_HW_RXTX_RATE_MCS10,
144 WL18XX_CONF_HW_RXTX_RATE_MCS9,
145 WL18XX_CONF_HW_RXTX_RATE_MCS8,
146 WL18XX_CONF_HW_RXTX_RATE_MCS7,
147 WL18XX_CONF_HW_RXTX_RATE_MCS6,
148 WL18XX_CONF_HW_RXTX_RATE_MCS5,
149 WL18XX_CONF_HW_RXTX_RATE_MCS4,
150 WL18XX_CONF_HW_RXTX_RATE_MCS3,
151 WL18XX_CONF_HW_RXTX_RATE_MCS2,
152 WL18XX_CONF_HW_RXTX_RATE_MCS1,
153 WL18XX_CONF_HW_RXTX_RATE_MCS0,
154 WL18XX_CONF_HW_RXTX_RATE_54,
155 WL18XX_CONF_HW_RXTX_RATE_48,
156 WL18XX_CONF_HW_RXTX_RATE_36,
157 WL18XX_CONF_HW_RXTX_RATE_24,
158 WL18XX_CONF_HW_RXTX_RATE_22,
159 WL18XX_CONF_HW_RXTX_RATE_18,
160 WL18XX_CONF_HW_RXTX_RATE_12,
161 WL18XX_CONF_HW_RXTX_RATE_11,
162 WL18XX_CONF_HW_RXTX_RATE_9,
163 WL18XX_CONF_HW_RXTX_RATE_6,
164 WL18XX_CONF_HW_RXTX_RATE_5_5,
165 WL18XX_CONF_HW_RXTX_RATE_2,
166 WL18XX_CONF_HW_RXTX_RATE_1,
167 WL18XX_CONF_HW_RXTX_RATE_MAX,
168};
169
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300170static struct wlcore_conf wl18xx_conf = {
171 .sg = {
172 .params = {
173 [CONF_SG_ACL_BT_MASTER_MIN_BR] = 10,
174 [CONF_SG_ACL_BT_MASTER_MAX_BR] = 180,
175 [CONF_SG_ACL_BT_SLAVE_MIN_BR] = 10,
176 [CONF_SG_ACL_BT_SLAVE_MAX_BR] = 180,
177 [CONF_SG_ACL_BT_MASTER_MIN_EDR] = 10,
178 [CONF_SG_ACL_BT_MASTER_MAX_EDR] = 80,
179 [CONF_SG_ACL_BT_SLAVE_MIN_EDR] = 10,
180 [CONF_SG_ACL_BT_SLAVE_MAX_EDR] = 80,
181 [CONF_SG_ACL_WLAN_PS_MASTER_BR] = 8,
182 [CONF_SG_ACL_WLAN_PS_SLAVE_BR] = 8,
183 [CONF_SG_ACL_WLAN_PS_MASTER_EDR] = 20,
184 [CONF_SG_ACL_WLAN_PS_SLAVE_EDR] = 20,
185 [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_BR] = 20,
186 [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_BR] = 35,
187 [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_BR] = 16,
188 [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_BR] = 35,
189 [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_EDR] = 32,
190 [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_EDR] = 50,
191 [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_EDR] = 28,
192 [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_EDR] = 50,
193 [CONF_SG_ACL_ACTIVE_SCAN_WLAN_BR] = 10,
194 [CONF_SG_ACL_ACTIVE_SCAN_WLAN_EDR] = 20,
195 [CONF_SG_ACL_PASSIVE_SCAN_BT_BR] = 75,
196 [CONF_SG_ACL_PASSIVE_SCAN_WLAN_BR] = 15,
197 [CONF_SG_ACL_PASSIVE_SCAN_BT_EDR] = 27,
198 [CONF_SG_ACL_PASSIVE_SCAN_WLAN_EDR] = 17,
199 /* active scan params */
200 [CONF_SG_AUTO_SCAN_PROBE_REQ] = 170,
201 [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_HV3] = 50,
202 [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100,
203 /* passive scan params */
204 [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_BR] = 800,
205 [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_EDR] = 200,
206 [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_HV3] = 200,
207 /* passive scan in dual antenna params */
208 [CONF_SG_CONSECUTIVE_HV3_IN_PASSIVE_SCAN] = 0,
209 [CONF_SG_BCN_HV3_COLLISION_THRESH_IN_PASSIVE_SCAN] = 0,
210 [CONF_SG_TX_RX_PROTECTION_BWIDTH_IN_PASSIVE_SCAN] = 0,
211 /* general params */
212 [CONF_SG_STA_FORCE_PS_IN_BT_SCO] = 1,
213 [CONF_SG_ANTENNA_CONFIGURATION] = 0,
214 [CONF_SG_BEACON_MISS_PERCENT] = 60,
215 [CONF_SG_DHCP_TIME] = 5000,
216 [CONF_SG_RXT] = 1200,
217 [CONF_SG_TXT] = 1000,
218 [CONF_SG_ADAPTIVE_RXT_TXT] = 1,
219 [CONF_SG_GENERAL_USAGE_BIT_MAP] = 3,
220 [CONF_SG_HV3_MAX_SERVED] = 6,
221 [CONF_SG_PS_POLL_TIMEOUT] = 10,
222 [CONF_SG_UPSD_TIMEOUT] = 10,
223 [CONF_SG_CONSECUTIVE_CTS_THRESHOLD] = 2,
224 [CONF_SG_STA_RX_WINDOW_AFTER_DTIM] = 5,
225 [CONF_SG_STA_CONNECTION_PROTECTION_TIME] = 30,
226 /* AP params */
227 [CONF_AP_BEACON_MISS_TX] = 3,
228 [CONF_AP_RX_WINDOW_AFTER_BEACON] = 10,
229 [CONF_AP_BEACON_WINDOW_INTERVAL] = 2,
230 [CONF_AP_CONNECTION_PROTECTION_TIME] = 0,
231 [CONF_AP_BT_ACL_VAL_BT_SERVE_TIME] = 25,
232 [CONF_AP_BT_ACL_VAL_WL_SERVE_TIME] = 25,
233 /* CTS Diluting params */
234 [CONF_SG_CTS_DILUTED_BAD_RX_PACKETS_TH] = 0,
235 [CONF_SG_CTS_CHOP_IN_DUAL_ANT_SCO_MASTER] = 0,
236 },
237 .state = CONF_SG_PROTECTIVE,
238 },
239 .rx = {
240 .rx_msdu_life_time = 512000,
241 .packet_detection_threshold = 0,
242 .ps_poll_timeout = 15,
243 .upsd_timeout = 15,
244 .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD,
245 .rx_cca_threshold = 0,
246 .irq_blk_threshold = 0xFFFF,
247 .irq_pkt_threshold = 0,
248 .irq_timeout = 600,
249 .queue_type = CONF_RX_QUEUE_TYPE_LOW_PRIORITY,
250 },
251 .tx = {
252 .tx_energy_detection = 0,
253 .sta_rc_conf = {
254 .enabled_rates = 0,
255 .short_retry_limit = 10,
256 .long_retry_limit = 10,
257 .aflags = 0,
258 },
259 .ac_conf_count = 4,
260 .ac_conf = {
261 [CONF_TX_AC_BE] = {
262 .ac = CONF_TX_AC_BE,
263 .cw_min = 15,
264 .cw_max = 63,
265 .aifsn = 3,
266 .tx_op_limit = 0,
267 },
268 [CONF_TX_AC_BK] = {
269 .ac = CONF_TX_AC_BK,
270 .cw_min = 15,
271 .cw_max = 63,
272 .aifsn = 7,
273 .tx_op_limit = 0,
274 },
275 [CONF_TX_AC_VI] = {
276 .ac = CONF_TX_AC_VI,
277 .cw_min = 15,
278 .cw_max = 63,
279 .aifsn = CONF_TX_AIFS_PIFS,
280 .tx_op_limit = 3008,
281 },
282 [CONF_TX_AC_VO] = {
283 .ac = CONF_TX_AC_VO,
284 .cw_min = 15,
285 .cw_max = 63,
286 .aifsn = CONF_TX_AIFS_PIFS,
287 .tx_op_limit = 1504,
288 },
289 },
290 .max_tx_retries = 100,
291 .ap_aging_period = 300,
292 .tid_conf_count = 4,
293 .tid_conf = {
294 [CONF_TX_AC_BE] = {
295 .queue_id = CONF_TX_AC_BE,
296 .channel_type = CONF_CHANNEL_TYPE_EDCF,
297 .tsid = CONF_TX_AC_BE,
298 .ps_scheme = CONF_PS_SCHEME_LEGACY,
299 .ack_policy = CONF_ACK_POLICY_LEGACY,
300 .apsd_conf = {0, 0},
301 },
302 [CONF_TX_AC_BK] = {
303 .queue_id = CONF_TX_AC_BK,
304 .channel_type = CONF_CHANNEL_TYPE_EDCF,
305 .tsid = CONF_TX_AC_BK,
306 .ps_scheme = CONF_PS_SCHEME_LEGACY,
307 .ack_policy = CONF_ACK_POLICY_LEGACY,
308 .apsd_conf = {0, 0},
309 },
310 [CONF_TX_AC_VI] = {
311 .queue_id = CONF_TX_AC_VI,
312 .channel_type = CONF_CHANNEL_TYPE_EDCF,
313 .tsid = CONF_TX_AC_VI,
314 .ps_scheme = CONF_PS_SCHEME_LEGACY,
315 .ack_policy = CONF_ACK_POLICY_LEGACY,
316 .apsd_conf = {0, 0},
317 },
318 [CONF_TX_AC_VO] = {
319 .queue_id = CONF_TX_AC_VO,
320 .channel_type = CONF_CHANNEL_TYPE_EDCF,
321 .tsid = CONF_TX_AC_VO,
322 .ps_scheme = CONF_PS_SCHEME_LEGACY,
323 .ack_policy = CONF_ACK_POLICY_LEGACY,
324 .apsd_conf = {0, 0},
325 },
326 },
327 .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD,
328 .tx_compl_timeout = 350,
329 .tx_compl_threshold = 10,
330 .basic_rate = CONF_HW_BIT_RATE_1MBPS,
331 .basic_rate_5 = CONF_HW_BIT_RATE_6MBPS,
332 .tmpl_short_retry_limit = 10,
333 .tmpl_long_retry_limit = 10,
334 .tx_watchdog_timeout = 5000,
335 },
336 .conn = {
337 .wake_up_event = CONF_WAKE_UP_EVENT_DTIM,
338 .listen_interval = 1,
339 .suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM,
340 .suspend_listen_interval = 3,
341 .bcn_filt_mode = CONF_BCN_FILT_MODE_ENABLED,
Eliad Peller186b5a72012-05-15 16:35:20 +0300342 .bcn_filt_ie_count = 3,
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300343 .bcn_filt_ie = {
344 [0] = {
345 .ie = WLAN_EID_CHANNEL_SWITCH,
346 .rule = CONF_BCN_RULE_PASS_ON_APPEARANCE,
347 },
348 [1] = {
349 .ie = WLAN_EID_HT_OPERATION,
350 .rule = CONF_BCN_RULE_PASS_ON_CHANGE,
351 },
Eliad Peller186b5a72012-05-15 16:35:20 +0300352 [2] = {
353 .ie = WLAN_EID_ERP_INFO,
354 .rule = CONF_BCN_RULE_PASS_ON_CHANGE,
355 },
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300356 },
Igal Chernobelsky7b052212012-05-15 17:08:57 +0300357 .synch_fail_thold = 12,
358 .bss_lose_timeout = 400,
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300359 .beacon_rx_timeout = 10000,
360 .broadcast_timeout = 20000,
361 .rx_broadcast_in_ps = 1,
362 .ps_poll_threshold = 10,
363 .bet_enable = CONF_BET_MODE_ENABLE,
364 .bet_max_consecutive = 50,
365 .psm_entry_retries = 8,
366 .psm_exit_retries = 16,
367 .psm_entry_nullfunc_retries = 3,
Arik Nemtsov6e066922012-05-15 17:08:53 +0300368 .dynamic_ps_timeout = 200,
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300369 .forced_ps = false,
370 .keep_alive_interval = 55000,
371 .max_listen_interval = 20,
372 },
373 .itrim = {
374 .enable = false,
375 .timeout = 50000,
376 },
377 .pm_config = {
378 .host_clk_settling_time = 5000,
Luciano Coelho648f6ed2012-06-07 23:39:24 +0300379 .host_fast_wakeup_support = CONF_FAST_WAKEUP_DISABLE,
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300380 },
381 .roam_trigger = {
382 .trigger_pacing = 1,
383 .avg_weight_rssi_beacon = 20,
384 .avg_weight_rssi_data = 10,
385 .avg_weight_snr_beacon = 20,
386 .avg_weight_snr_data = 10,
387 },
388 .scan = {
389 .min_dwell_time_active = 7500,
390 .max_dwell_time_active = 30000,
391 .min_dwell_time_passive = 100000,
392 .max_dwell_time_passive = 100000,
393 .num_probe_reqs = 2,
394 .split_scan_timeout = 50000,
395 },
396 .sched_scan = {
397 /*
398 * Values are in TU/1000 but since sched scan FW command
399 * params are in TUs rounding up may occur.
400 */
401 .base_dwell_time = 7500,
402 .max_dwell_time_delta = 22500,
403 /* based on 250bits per probe @1Mbps */
404 .dwell_time_delta_per_probe = 2000,
405 /* based on 250bits per probe @6Mbps (plus a bit more) */
406 .dwell_time_delta_per_probe_5 = 350,
407 .dwell_time_passive = 100000,
408 .dwell_time_dfs = 150000,
409 .num_probe_reqs = 2,
410 .rssi_threshold = -90,
411 .snr_threshold = 0,
412 },
413 .ht = {
414 .rx_ba_win_size = 10,
Luciano Coelho3507efa2012-05-10 12:14:21 +0300415 .tx_ba_win_size = 64,
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300416 .inactivity_timeout = 10000,
417 .tx_ba_tid_bitmap = CONF_TX_BA_ENABLED_TID_BITMAP,
418 },
419 .mem = {
420 .num_stations = 1,
421 .ssid_profiles = 1,
422 .rx_block_num = 40,
423 .tx_min_block_num = 40,
424 .dynamic_memory = 1,
425 .min_req_tx_blocks = 45,
426 .min_req_rx_blocks = 22,
427 .tx_min = 27,
428 },
429 .fm_coex = {
430 .enable = true,
431 .swallow_period = 5,
432 .n_divider_fref_set_1 = 0xff, /* default */
433 .n_divider_fref_set_2 = 12,
Victor Goldenshtein461b9582012-05-15 17:15:40 +0300434 .m_divider_fref_set_1 = 0xffff,
435 .m_divider_fref_set_2 = 148, /* default */
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300436 .coex_pll_stabilization_time = 0xffffffff, /* default */
437 .ldo_stabilization_time = 0xffff, /* default */
438 .fm_disturbed_band_margin = 0xff, /* default */
439 .swallow_clk_diff = 0xff, /* default */
440 },
441 .rx_streaming = {
442 .duration = 150,
443 .queues = 0x1,
444 .interval = 20,
445 .always = 0,
446 },
447 .fwlog = {
448 .mode = WL12XX_FWLOG_ON_DEMAND,
449 .mem_blocks = 2,
450 .severity = 0,
451 .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED,
452 .output = WL12XX_FWLOG_OUTPUT_HOST,
453 .threshold = 0,
454 },
455 .rate = {
456 .rate_retry_score = 32000,
457 .per_add = 8192,
458 .per_th1 = 2048,
459 .per_th2 = 4096,
460 .max_per = 8100,
461 .inverse_curiosity_factor = 5,
462 .tx_fail_low_th = 4,
463 .tx_fail_high_th = 10,
464 .per_alpha_shift = 4,
465 .per_add_shift = 13,
466 .per_beta1_shift = 10,
467 .per_beta2_shift = 8,
468 .rate_check_up = 2,
469 .rate_check_down = 12,
470 .rate_retry_policy = {
471 0x00, 0x00, 0x00, 0x00, 0x00,
472 0x00, 0x00, 0x00, 0x00, 0x00,
473 0x00, 0x00, 0x00,
474 },
475 },
476 .hangover = {
477 .recover_time = 0,
478 .hangover_period = 20,
479 .dynamic_mode = 1,
480 .early_termination_mode = 1,
481 .max_period = 20,
482 .min_period = 1,
483 .increase_delta = 1,
484 .decrease_delta = 2,
485 .quiet_time = 4,
486 .increase_time = 1,
487 .window_size = 16,
488 },
489};
490
491static struct wl18xx_priv_conf wl18xx_default_priv_conf = {
Luciano Coelho46a1d512012-05-10 12:13:12 +0300492 .phy = {
493 .phy_standalone = 0x00,
494 .primary_clock_setting_time = 0x05,
495 .clock_valid_on_wake_up = 0x00,
496 .secondary_clock_setting_time = 0x05,
497 .rdl = 0x01,
498 .auto_detect = 0x00,
499 .dedicated_fem = FEM_NONE,
500 .low_band_component = COMPONENT_2_WAY_SWITCH,
501 .low_band_component_type = 0x05,
502 .high_band_component = COMPONENT_2_WAY_SWITCH,
503 .high_band_component_type = 0x09,
Luciano Coelho46a1d512012-05-10 12:13:12 +0300504 .tcxo_ldo_voltage = 0x00,
505 .xtal_itrim_val = 0x04,
506 .srf_state = 0x00,
507 .io_configuration = 0x01,
508 .sdio_configuration = 0x00,
509 .settings = 0x00,
510 .enable_clpc = 0x00,
511 .enable_tx_low_pwr_on_siso_rdl = 0x00,
512 .rx_profile = 0x00,
Luciano Coelho5add82e2012-05-10 12:14:16 +0300513 .pwr_limit_reference_11_abg = 0xc8,
Ido Reis16ea4732012-04-23 16:49:19 +0300514 .psat = 0,
515 .low_power_val = 0x00,
516 .med_power_val = 0x0a,
517 .high_power_val = 0x1e,
Luciano Coelho46a1d512012-05-10 12:13:12 +0300518 },
519};
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +0300520
Luciano Coelho82b890c2012-05-10 12:13:09 +0300521static const struct wlcore_partition_set wl18xx_ptable[PART_TABLE_LEN] = {
522 [PART_TOP_PRCM_ELP_SOC] = {
523 .mem = { .start = 0x00A02000, .size = 0x00010000 },
524 .reg = { .start = 0x00807000, .size = 0x00005000 },
525 .mem2 = { .start = 0x00800000, .size = 0x0000B000 },
526 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
527 },
528 [PART_DOWN] = {
529 .mem = { .start = 0x00000000, .size = 0x00014000 },
530 .reg = { .start = 0x00810000, .size = 0x0000BFFF },
531 .mem2 = { .start = 0x00000000, .size = 0x00000000 },
532 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
533 },
534 [PART_BOOT] = {
535 .mem = { .start = 0x00700000, .size = 0x0000030c },
536 .reg = { .start = 0x00802000, .size = 0x00014578 },
537 .mem2 = { .start = 0x00B00404, .size = 0x00001000 },
538 .mem3 = { .start = 0x00C00000, .size = 0x00000400 },
539 },
540 [PART_WORK] = {
541 .mem = { .start = 0x00800000, .size = 0x000050FC },
542 .reg = { .start = 0x00B00404, .size = 0x00001000 },
543 .mem2 = { .start = 0x00C00000, .size = 0x00000400 },
544 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
545 },
546 [PART_PHY_INIT] = {
Ido Reis4085f642012-05-13 15:27:17 +0300547 .mem = { .start = 0x80926000,
548 .size = sizeof(struct wl18xx_mac_and_phy_params) },
Luciano Coelho82b890c2012-05-10 12:13:09 +0300549 .reg = { .start = 0x00000000, .size = 0x00000000 },
550 .mem2 = { .start = 0x00000000, .size = 0x00000000 },
551 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
552 },
553};
554
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +0300555static const int wl18xx_rtable[REG_TABLE_LEN] = {
556 [REG_ECPU_CONTROL] = WL18XX_REG_ECPU_CONTROL,
557 [REG_INTERRUPT_NO_CLEAR] = WL18XX_REG_INTERRUPT_NO_CLEAR,
558 [REG_INTERRUPT_ACK] = WL18XX_REG_INTERRUPT_ACK,
559 [REG_COMMAND_MAILBOX_PTR] = WL18XX_REG_COMMAND_MAILBOX_PTR,
560 [REG_EVENT_MAILBOX_PTR] = WL18XX_REG_EVENT_MAILBOX_PTR,
561 [REG_INTERRUPT_TRIG] = WL18XX_REG_INTERRUPT_TRIG_H,
562 [REG_INTERRUPT_MASK] = WL18XX_REG_INTERRUPT_MASK,
Arik Nemtsov1c351da2012-05-10 12:13:39 +0300563 [REG_PC_ON_RECOVERY] = WL18XX_SCR_PAD4,
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +0300564 [REG_CHIP_ID_B] = WL18XX_REG_CHIP_ID_B,
565 [REG_CMD_MBOX_ADDRESS] = WL18XX_CMD_MBOX_ADDRESS,
566
567 /* data access memory addresses, used with partition translation */
568 [REG_SLV_MEM_DATA] = WL18XX_SLV_MEM_DATA,
569 [REG_SLV_REG_DATA] = WL18XX_SLV_REG_DATA,
570
571 /* raw data access memory addresses */
572 [REG_RAW_FW_STATUS_ADDR] = WL18XX_FW_STATUS_ADDR,
573};
574
Luciano Coelhobe652022012-05-10 12:13:41 +0300575static const struct wl18xx_clk_cfg wl18xx_clk_table[NUM_CLOCK_CONFIGS] = {
576 [CLOCK_CONFIG_16_2_M] = { 7, 104, 801, 4, true },
577 [CLOCK_CONFIG_16_368_M] = { 9, 132, 3751, 4, true },
578 [CLOCK_CONFIG_16_8_M] = { 7, 100, 0, 0, false },
579 [CLOCK_CONFIG_19_2_M] = { 8, 100, 0, 0, false },
580 [CLOCK_CONFIG_26_M] = { 13, 120, 0, 0, false },
581 [CLOCK_CONFIG_32_736_M] = { 9, 132, 3751, 4, true },
582 [CLOCK_CONFIG_33_6_M] = { 7, 100, 0, 0, false },
583 [CLOCK_CONFIG_38_468_M] = { 8, 100, 0, 0, false },
584 [CLOCK_CONFIG_52_M] = { 13, 120, 0, 0, false },
585};
586
Luciano Coelho0cd65432012-05-10 12:13:11 +0300587/* TODO: maybe move to a new header file? */
588#define WL18XX_FW_NAME "ti-connectivity/wl18xx-fw.bin"
589
590static int wl18xx_identify_chip(struct wl1271 *wl)
591{
592 int ret = 0;
593
594 switch (wl->chip.id) {
Ido Reis73395a72012-04-22 20:45:52 +0300595 case CHIP_ID_185x_PG20:
596 wl1271_debug(DEBUG_BOOT, "chip id 0x%x (185x PG20)",
597 wl->chip.id);
598 wl->sr_fw_name = WL18XX_FW_NAME;
599 /* wl18xx uses the same firmware for PLT */
600 wl->plt_fw_name = WL18XX_FW_NAME;
601 wl->quirks |= WLCORE_QUIRK_NO_ELP |
602 WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED |
Ido Reis9fccc822012-05-13 14:53:40 +0300603 WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN |
604 WLCORE_QUIRK_TX_PAD_LAST_FRAME;
Ido Reis73395a72012-04-22 20:45:52 +0300605
606 break;
Luciano Coelho0cd65432012-05-10 12:13:11 +0300607 case CHIP_ID_185x_PG10:
608 wl1271_debug(DEBUG_BOOT, "chip id 0x%x (185x PG10)",
609 wl->chip.id);
610 wl->sr_fw_name = WL18XX_FW_NAME;
Luciano Coelhobe42aee2012-05-10 12:13:50 +0300611 /* wl18xx uses the same firmware for PLT */
612 wl->plt_fw_name = WL18XX_FW_NAME;
Arik Nemtsov7cfefd12012-05-10 12:13:22 +0300613 wl->quirks |= WLCORE_QUIRK_NO_ELP |
Luciano Coelhob5d6d9b2012-06-05 00:02:25 +0300614 WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED |
615 WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN |
616 WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN;
Luciano Coelho0cd65432012-05-10 12:13:11 +0300617
Luciano Coelho7ae25da2012-05-10 12:14:03 +0300618 /* PG 1.0 has some problems with MCS_13, so disable it */
Eliad Pellerbfb92ca2012-05-15 17:09:00 +0300619 wl->ht_cap[IEEE80211_BAND_2GHZ].mcs.rx_mask[1] &= ~BIT(5);
Luciano Coelho7ae25da2012-05-10 12:14:03 +0300620
Luciano Coelho0cd65432012-05-10 12:13:11 +0300621 break;
622 default:
623 wl1271_warning("unsupported chip id: 0x%x", wl->chip.id);
624 ret = -ENODEV;
625 goto out;
626 }
627
628out:
629 return ret;
630}
631
Luciano Coelho46a1d512012-05-10 12:13:12 +0300632static void wl18xx_set_clk(struct wl1271 *wl)
633{
Luciano Coelhobe652022012-05-10 12:13:41 +0300634 u32 clk_freq;
Luciano Coelhod5b59272012-05-10 12:13:38 +0300635
Luciano Coelho46a1d512012-05-10 12:13:12 +0300636 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
Luciano Coelhobe652022012-05-10 12:13:41 +0300637
638 /* TODO: PG2: apparently we need to read the clk type */
639
640 clk_freq = wl18xx_top_reg_read(wl, PRIMARY_CLK_DETECT);
641 wl1271_debug(DEBUG_BOOT, "clock freq %d (%d, %d, %d, %d, %s)", clk_freq,
642 wl18xx_clk_table[clk_freq].n, wl18xx_clk_table[clk_freq].m,
643 wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q,
644 wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit");
645
646 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N, wl18xx_clk_table[clk_freq].n);
647 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_M, wl18xx_clk_table[clk_freq].m);
648
649 if (wl18xx_clk_table[clk_freq].swallow) {
650 /* first the 16 lower bits */
651 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_1,
652 wl18xx_clk_table[clk_freq].q &
653 PLLSH_WCS_PLL_Q_FACTOR_CFG_1_MASK);
654 /* then the 16 higher bits, masked out */
655 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_2,
656 (wl18xx_clk_table[clk_freq].q >> 16) &
657 PLLSH_WCS_PLL_Q_FACTOR_CFG_2_MASK);
658
659 /* first the 16 lower bits */
660 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_1,
661 wl18xx_clk_table[clk_freq].p &
662 PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK);
663 /* then the 16 higher bits, masked out */
664 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2,
665 (wl18xx_clk_table[clk_freq].p >> 16) &
666 PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK);
667 } else {
668 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN,
669 PLLSH_WCS_PLL_SWALLOW_EN_VAL2);
670 }
Luciano Coelho46a1d512012-05-10 12:13:12 +0300671}
672
673static void wl18xx_boot_soft_reset(struct wl1271 *wl)
674{
675 /* disable Rx/Tx */
676 wl1271_write32(wl, WL18XX_ENABLE, 0x0);
677
678 /* disable auto calibration on start*/
679 wl1271_write32(wl, WL18XX_SPARE_A2, 0xffff);
680}
681
682static int wl18xx_pre_boot(struct wl1271 *wl)
683{
Luciano Coelho46a1d512012-05-10 12:13:12 +0300684 wl18xx_set_clk(wl);
685
686 /* Continue the ELP wake up sequence */
687 wl1271_write32(wl, WL18XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
688 udelay(500);
689
690 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
691
692 /* Disable interrupts */
693 wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL);
694
695 wl18xx_boot_soft_reset(wl);
696
697 return 0;
698}
699
700static void wl18xx_pre_upload(struct wl1271 *wl)
701{
702 u32 tmp;
703
704 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
705
706 /* TODO: check if this is all needed */
707 wl1271_write32(wl, WL18XX_EEPROMLESS_IND, WL18XX_EEPROMLESS_IND);
708
709 tmp = wlcore_read_reg(wl, REG_CHIP_ID_B);
710
711 wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp);
712
713 tmp = wl1271_read32(wl, WL18XX_SCR_PAD2);
714}
715
716static void wl18xx_set_mac_and_phy(struct wl1271 *wl)
717{
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300718 struct wl18xx_priv *priv = wl->priv;
719 struct wl18xx_conf_phy *phy = &priv->conf.phy;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300720 struct wl18xx_mac_and_phy_params params;
Ido Reis16ea4732012-04-23 16:49:19 +0300721 size_t len;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300722
723 memset(&params, 0, sizeof(params));
724
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300725 params.phy_standalone = phy->phy_standalone;
726 params.rdl = phy->rdl;
727 params.enable_clpc = phy->enable_clpc;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300728 params.enable_tx_low_pwr_on_siso_rdl =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300729 phy->enable_tx_low_pwr_on_siso_rdl;
730 params.auto_detect = phy->auto_detect;
731 params.dedicated_fem = phy->dedicated_fem;
732 params.low_band_component = phy->low_band_component;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300733 params.low_band_component_type =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300734 phy->low_band_component_type;
735 params.high_band_component = phy->high_band_component;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300736 params.high_band_component_type =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300737 phy->high_band_component_type;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300738 params.number_of_assembled_ant2_4 =
Luciano Coelhoe9258812012-05-10 12:13:52 +0300739 n_antennas_2_param;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300740 params.number_of_assembled_ant5 =
Luciano Coelhoe9258812012-05-10 12:13:52 +0300741 n_antennas_5_param;
742 params.external_pa_dc2dc = dc2dc_param;
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300743 params.tcxo_ldo_voltage = phy->tcxo_ldo_voltage;
744 params.xtal_itrim_val = phy->xtal_itrim_val;
745 params.srf_state = phy->srf_state;
746 params.io_configuration = phy->io_configuration;
747 params.sdio_configuration = phy->sdio_configuration;
748 params.settings = phy->settings;
749 params.rx_profile = phy->rx_profile;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300750 params.primary_clock_setting_time =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300751 phy->primary_clock_setting_time;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300752 params.clock_valid_on_wake_up =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300753 phy->clock_valid_on_wake_up;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300754 params.secondary_clock_setting_time =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300755 phy->secondary_clock_setting_time;
Luciano Coelho5add82e2012-05-10 12:14:16 +0300756 params.pwr_limit_reference_11_abg =
757 phy->pwr_limit_reference_11_abg;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300758
Luciano Coelhoa9c130d2012-05-10 12:13:37 +0300759 params.board_type = priv->board_type;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300760
Ido Reis16ea4732012-04-23 16:49:19 +0300761 /* for PG2 only */
762 params.psat = phy->psat;
763 params.low_power_val = phy->low_power_val;
764 params.med_power_val = phy->med_power_val;
765 params.high_power_val = phy->high_power_val;
766
767 /* the parameters struct is smaller for PG1 */
768 if (wl->chip.id == CHIP_ID_185x_PG10)
769 len = offsetof(struct wl18xx_mac_and_phy_params, psat) + 1;
770 else
771 len = sizeof(params);
772
Luciano Coelho46a1d512012-05-10 12:13:12 +0300773 wlcore_set_partition(wl, &wl->ptable[PART_PHY_INIT]);
774 wl1271_write(wl, WL18XX_PHY_INIT_MEM_ADDR, (u8 *)&params,
Ido Reis16ea4732012-04-23 16:49:19 +0300775 len, false);
Luciano Coelho46a1d512012-05-10 12:13:12 +0300776}
777
778static void wl18xx_enable_interrupts(struct wl1271 *wl)
779{
Ido Reisf5755fe2012-04-23 17:35:25 +0300780 u32 event_mask, intr_mask;
781
782 if (wl->chip.id == CHIP_ID_185x_PG10) {
783 event_mask = WL18XX_ACX_EVENTS_VECTOR_PG1;
784 intr_mask = WL18XX_INTR_MASK_PG1;
785 } else {
786 event_mask = WL18XX_ACX_EVENTS_VECTOR_PG2;
787 intr_mask = WL18XX_INTR_MASK_PG2;
788 }
789
790 wlcore_write_reg(wl, REG_INTERRUPT_MASK, event_mask);
Luciano Coelho46a1d512012-05-10 12:13:12 +0300791
792 wlcore_enable_interrupts(wl);
793 wlcore_write_reg(wl, REG_INTERRUPT_MASK,
Ido Reisf5755fe2012-04-23 17:35:25 +0300794 WL1271_ACX_INTR_ALL & ~intr_mask);
Luciano Coelho46a1d512012-05-10 12:13:12 +0300795}
796
797static int wl18xx_boot(struct wl1271 *wl)
798{
799 int ret;
800
801 ret = wl18xx_pre_boot(wl);
802 if (ret < 0)
803 goto out;
804
Luciano Coelho46a1d512012-05-10 12:13:12 +0300805 wl18xx_pre_upload(wl);
806
807 ret = wlcore_boot_upload_firmware(wl);
808 if (ret < 0)
809 goto out;
810
811 wl18xx_set_mac_and_phy(wl);
812
813 ret = wlcore_boot_run_firmware(wl);
814 if (ret < 0)
815 goto out;
816
817 wl18xx_enable_interrupts(wl);
818
819out:
820 return ret;
821}
822
Luciano Coelho274c66c2012-05-10 12:13:13 +0300823static void wl18xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr,
824 void *buf, size_t len)
825{
826 struct wl18xx_priv *priv = wl->priv;
827
828 memcpy(priv->cmd_buf, buf, len);
829 memset(priv->cmd_buf + len, 0, WL18XX_CMD_MAX_SIZE - len);
830
831 wl1271_write(wl, cmd_box_addr, priv->cmd_buf, WL18XX_CMD_MAX_SIZE,
832 false);
833}
834
835static void wl18xx_ack_event(struct wl1271 *wl)
836{
837 wlcore_write_reg(wl, REG_INTERRUPT_TRIG, WL18XX_INTR_TRIG_EVENT_ACK);
838}
839
Arik Nemtsov624845b2012-05-10 12:13:17 +0300840static u32 wl18xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
841{
842 u32 blk_size = WL18XX_TX_HW_BLOCK_SIZE;
843 return (len + blk_size - 1) / blk_size + spare_blks;
844}
845
Arik Nemtsovfb0f2e42012-05-10 12:13:18 +0300846static void
847wl18xx_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
848 u32 blks, u32 spare_blks)
849{
850 desc->wl18xx_mem.total_mem_blocks = blks;
Arik Nemtsovfb0f2e42012-05-10 12:13:18 +0300851}
852
Arik Nemtsovd2361c52012-05-10 12:13:19 +0300853static void
854wl18xx_set_tx_desc_data_len(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
855 struct sk_buff *skb)
856{
857 desc->length = cpu_to_le16(skb->len);
858
Ido Reis9fccc822012-05-13 14:53:40 +0300859 /* if only the last frame is to be padded, we unset this bit on Tx */
860 if (wl->quirks & WLCORE_QUIRK_TX_PAD_LAST_FRAME)
861 desc->wl18xx_mem.ctrl = WL18XX_TX_CTRL_NOT_PADDED;
862 else
863 desc->wl18xx_mem.ctrl = 0;
864
Arik Nemtsovd2361c52012-05-10 12:13:19 +0300865 wl1271_debug(DEBUG_TX, "tx_fill_hdr: hlid: %d "
866 "len: %d life: %d mem: %d", desc->hlid,
867 le16_to_cpu(desc->length),
868 le16_to_cpu(desc->life_time),
869 desc->wl18xx_mem.total_mem_blocks);
870}
871
Arik Nemtsov9c809f82012-05-10 12:13:23 +0300872static enum wl_rx_buf_align
873wl18xx_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)
874{
875 if (rx_desc & RX_BUF_PADDED_PAYLOAD)
876 return WLCORE_RX_BUF_PADDED;
877
878 return WLCORE_RX_BUF_ALIGNED;
879}
880
Arik Nemtsov30e2dd72012-05-10 12:13:24 +0300881static u32 wl18xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data,
882 u32 data_len)
883{
884 struct wl1271_rx_descriptor *desc = rx_data;
885
886 /* invalid packet */
887 if (data_len < sizeof(*desc))
888 return 0;
889
890 return data_len - sizeof(*desc);
891}
Arik Nemtsov9c809f82012-05-10 12:13:23 +0300892
Arik Nemtsov872b3452012-05-10 12:13:25 +0300893static void wl18xx_tx_immediate_completion(struct wl1271 *wl)
894{
895 wl18xx_tx_immediate_complete(wl);
896}
897
Arik Nemtsova1c597f2012-05-18 07:46:40 +0300898static int wl18xx_set_host_cfg_bitmap(struct wl1271 *wl, u32 extra_mem_blk)
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300899{
900 int ret;
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300901 u32 sdio_align_size = 0;
Arik Nemtsova1c597f2012-05-18 07:46:40 +0300902 u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE |
903 HOST_IF_CFG_ADD_RX_ALIGNMENT;
Arik Nemtsovf2baf072012-05-10 12:13:46 +0300904
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300905 /* Enable Tx SDIO padding */
906 if (wl->quirks & WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN) {
907 host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
908 sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
909 }
910
911 /* Enable Rx SDIO padding */
912 if (wl->quirks & WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN) {
913 host_cfg_bitmap |= HOST_IF_CFG_RX_PAD_TO_SDIO_BLK;
914 sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
915 }
916
917 ret = wl18xx_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap,
Arik Nemtsova1c597f2012-05-18 07:46:40 +0300918 sdio_align_size, extra_mem_blk,
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300919 WL18XX_HOST_IF_LEN_SIZE_FIELD);
920 if (ret < 0)
921 return ret;
922
Arik Nemtsova1c597f2012-05-18 07:46:40 +0300923 return 0;
924}
925
926static int wl18xx_hw_init(struct wl1271 *wl)
927{
928 int ret;
929 struct wl18xx_priv *priv = wl->priv;
930
931 /* (re)init private structures. Relevant on recovery as well. */
932 priv->last_fw_rls_idx = 0;
933 priv->extra_spare_vif_count = 0;
934
935 /* set the default amount of spare blocks in the bitmap */
936 ret = wl18xx_set_host_cfg_bitmap(wl, WL18XX_TX_HW_BLOCK_SPARE);
937 if (ret < 0)
938 return ret;
939
Luciano Coelho102165c2012-05-10 12:13:53 +0300940 if (checksum_param) {
941 ret = wl18xx_acx_set_checksum_state(wl);
942 if (ret != 0)
943 return ret;
944 }
Arik Nemtsov2fc28de2012-05-10 12:13:27 +0300945
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300946 return ret;
947}
948
Arik Nemtsov2fc28de2012-05-10 12:13:27 +0300949static void wl18xx_set_tx_desc_csum(struct wl1271 *wl,
950 struct wl1271_tx_hw_descr *desc,
951 struct sk_buff *skb)
952{
953 u32 ip_hdr_offset;
954 struct iphdr *ip_hdr;
955
Luciano Coelho102165c2012-05-10 12:13:53 +0300956 if (!checksum_param) {
957 desc->wl18xx_checksum_data = 0;
958 return;
959 }
960
Arik Nemtsov2fc28de2012-05-10 12:13:27 +0300961 if (skb->ip_summed != CHECKSUM_PARTIAL) {
962 desc->wl18xx_checksum_data = 0;
963 return;
964 }
965
966 ip_hdr_offset = skb_network_header(skb) - skb_mac_header(skb);
967 if (WARN_ON(ip_hdr_offset >= (1<<7))) {
968 desc->wl18xx_checksum_data = 0;
969 return;
970 }
971
972 desc->wl18xx_checksum_data = ip_hdr_offset << 1;
973
974 /* FW is interested only in the LSB of the protocol TCP=0 UDP=1 */
975 ip_hdr = (void *)skb_network_header(skb);
976 desc->wl18xx_checksum_data |= (ip_hdr->protocol & 0x01);
977}
978
Arik Nemtsov169da042012-05-10 12:13:28 +0300979static void wl18xx_set_rx_csum(struct wl1271 *wl,
980 struct wl1271_rx_descriptor *desc,
981 struct sk_buff *skb)
982{
983 if (desc->status & WL18XX_RX_CHECKSUM_MASK)
984 skb->ip_summed = CHECKSUM_UNNECESSARY;
985}
986
Luciano Coelho7ae25da2012-05-10 12:14:03 +0300987/*
988 * TODO: instead of having these two functions to get the rate mask,
989 * we should modify the wlvif->rate_set instead
990 */
Arik Nemtsovf13af342012-05-10 12:13:32 +0300991static u32 wl18xx_sta_get_ap_rate_mask(struct wl1271 *wl,
992 struct wl12xx_vif *wlvif)
993{
994 u32 hw_rate_set = wlvif->rate_set;
995
996 if (wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
997 wlvif->channel_type == NL80211_CHAN_HT40PLUS) {
998 wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
999 hw_rate_set |= CONF_TX_RATE_USE_WIDE_CHAN;
1000
1001 /* we don't support MIMO in wide-channel mode */
1002 hw_rate_set &= ~CONF_TX_MIMO_RATES;
1003 }
1004
1005 return hw_rate_set;
1006}
1007
Arik Nemtsovebc7e572012-05-10 12:13:34 +03001008static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
1009 struct wl12xx_vif *wlvif)
1010{
Luciano Coelho174a7302012-05-10 12:14:13 +03001011 if ((wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
1012 wlvif->channel_type == NL80211_CHAN_HT40PLUS) &&
1013 !strcmp(ht_mode_param, "wide")) {
Arik Nemtsovebc7e572012-05-10 12:13:34 +03001014 wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
1015 return CONF_TX_RATE_USE_WIDE_CHAN;
Luciano Coelho174a7302012-05-10 12:14:13 +03001016 } else if (!strcmp(ht_mode_param, "mimo")) {
Arik Nemtsovebc7e572012-05-10 12:13:34 +03001017 wl1271_debug(DEBUG_ACX, "using MIMO rate mask");
Luciano Coelho7ae25da2012-05-10 12:14:03 +03001018
1019 /*
1020 * PG 1.0 has some problems with MCS_13, so disable it
1021 *
1022 * TODO: instead of hacking this in here, we should
1023 * make it more general and change a bit in the
1024 * wlvif->rate_set instead.
1025 */
1026 if (wl->chip.id == CHIP_ID_185x_PG10)
1027 return CONF_TX_MIMO_RATES & ~CONF_HW_BIT_RATE_MCS_13;
1028
Arik Nemtsovebc7e572012-05-10 12:13:34 +03001029 return CONF_TX_MIMO_RATES;
Luciano Coelho174a7302012-05-10 12:14:13 +03001030 } else {
1031 return 0;
Arik Nemtsovebc7e572012-05-10 12:13:34 +03001032 }
1033}
1034
Arik Nemtsov54956292012-05-10 12:13:44 +03001035static s8 wl18xx_get_pg_ver(struct wl1271 *wl)
1036{
1037 u32 fuse;
1038
1039 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
1040
1041 fuse = wl1271_read32(wl, WL18XX_REG_FUSE_DATA_1_3);
1042 fuse = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET;
1043
1044 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
1045
1046 return (s8)fuse;
1047}
1048
Luciano Coelho23ee9bf2012-05-10 12:13:29 +03001049static void wl18xx_conf_init(struct wl1271 *wl)
1050{
1051 struct wl18xx_priv *priv = wl->priv;
1052
1053 /* apply driver default configuration */
1054 memcpy(&wl->conf, &wl18xx_conf, sizeof(wl18xx_conf));
1055
1056 /* apply default private configuration */
1057 memcpy(&priv->conf, &wl18xx_default_priv_conf, sizeof(priv->conf));
1058}
1059
Luciano Coelhobe42aee2012-05-10 12:13:50 +03001060static int wl18xx_plt_init(struct wl1271 *wl)
1061{
1062 wl1271_write32(wl, WL18XX_SCR_PAD8, WL18XX_SCR_PAD8_PLT);
1063
1064 return wl->ops->boot(wl);
1065}
1066
Luciano Coelhoa5114d92012-05-10 12:13:55 +03001067static void wl18xx_get_mac(struct wl1271 *wl)
1068{
1069 u32 mac1, mac2;
1070
1071 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
1072
1073 mac1 = wl1271_read32(wl, WL18XX_REG_FUSE_BD_ADDR_1);
1074 mac2 = wl1271_read32(wl, WL18XX_REG_FUSE_BD_ADDR_2);
1075
1076 /* these are the two parts of the BD_ADDR */
1077 wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) +
1078 ((mac1 & 0xff000000) >> 24);
1079 wl->fuse_nic_addr = (mac1 & 0xffffff);
1080
1081 wlcore_set_partition(wl, &wl->ptable[PART_DOWN]);
1082}
1083
Luciano Coelho283e8c42012-05-10 12:14:11 +03001084static int wl18xx_handle_static_data(struct wl1271 *wl,
1085 struct wl1271_static_data *static_data)
1086{
1087 struct wl18xx_static_data_priv *static_data_priv =
1088 (struct wl18xx_static_data_priv *) static_data->priv;
1089
1090 wl1271_info("PHY firmware version: %s", static_data_priv->phy_version);
1091
1092 return 0;
1093}
1094
Arik Nemtsov32bb2c02012-05-18 07:46:37 +03001095static int wl18xx_get_spare_blocks(struct wl1271 *wl, bool is_gem)
1096{
Arik Nemtsova1c597f2012-05-18 07:46:40 +03001097 struct wl18xx_priv *priv = wl->priv;
1098
1099 /* If we have VIFs requiring extra spare, indulge them */
1100 if (priv->extra_spare_vif_count)
1101 return WL18XX_TX_HW_EXTRA_BLOCK_SPARE;
1102
1103 return WL18XX_TX_HW_BLOCK_SPARE;
1104}
1105
1106static int wl18xx_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
1107 struct ieee80211_vif *vif,
1108 struct ieee80211_sta *sta,
1109 struct ieee80211_key_conf *key_conf)
1110{
1111 struct wl18xx_priv *priv = wl->priv;
1112 bool change_spare = false;
1113 int ret;
1114
1115 /*
1116 * when adding the first or removing the last GEM/TKIP interface,
1117 * we have to adjust the number of spare blocks.
1118 */
1119 change_spare = (key_conf->cipher == WL1271_CIPHER_SUITE_GEM ||
1120 key_conf->cipher == WLAN_CIPHER_SUITE_TKIP) &&
1121 ((priv->extra_spare_vif_count == 0 && cmd == SET_KEY) ||
1122 (priv->extra_spare_vif_count == 1 && cmd == DISABLE_KEY));
1123
1124 /* no need to change spare - just regular set_key */
1125 if (!change_spare)
1126 return wlcore_set_key(wl, cmd, vif, sta, key_conf);
1127
1128 /*
1129 * stop the queues and flush to ensure the next packets are
1130 * in sync with FW spare block accounting
1131 */
1132 wlcore_stop_queues(wl, WLCORE_QUEUE_STOP_REASON_SPARE_BLK);
1133 wl1271_tx_flush(wl);
1134
1135 ret = wlcore_set_key(wl, cmd, vif, sta, key_conf);
1136 if (ret < 0)
1137 goto out;
1138
1139 /* key is now set, change the spare blocks */
1140 if (cmd == SET_KEY) {
1141 ret = wl18xx_set_host_cfg_bitmap(wl,
1142 WL18XX_TX_HW_EXTRA_BLOCK_SPARE);
1143 if (ret < 0)
1144 goto out;
1145
1146 priv->extra_spare_vif_count++;
1147 } else {
1148 ret = wl18xx_set_host_cfg_bitmap(wl,
1149 WL18XX_TX_HW_BLOCK_SPARE);
1150 if (ret < 0)
1151 goto out;
1152
1153 priv->extra_spare_vif_count--;
1154 }
1155
1156out:
1157 wlcore_wake_queues(wl, WLCORE_QUEUE_STOP_REASON_SPARE_BLK);
1158 return ret;
Arik Nemtsov32bb2c02012-05-18 07:46:37 +03001159}
1160
Ido Reis9fccc822012-05-13 14:53:40 +03001161static u32 wl18xx_pre_pkt_send(struct wl1271 *wl,
1162 u32 buf_offset, u32 last_len)
1163{
1164 if (wl->quirks & WLCORE_QUIRK_TX_PAD_LAST_FRAME) {
1165 struct wl1271_tx_hw_descr *last_desc;
1166
1167 /* get the last TX HW descriptor written to the aggr buf */
1168 last_desc = (struct wl1271_tx_hw_descr *)(wl->aggr_buf +
1169 buf_offset - last_len);
1170
1171 /* the last frame is padded up to an SDIO block */
1172 last_desc->wl18xx_mem.ctrl &= ~WL18XX_TX_CTRL_NOT_PADDED;
1173 return ALIGN(buf_offset, WL12XX_BUS_BLOCK_SIZE);
1174 }
1175
1176 /* no modifications */
1177 return buf_offset;
1178}
1179
Luciano Coelho0cd65432012-05-10 12:13:11 +03001180static struct wlcore_ops wl18xx_ops = {
Luciano Coelho46a1d512012-05-10 12:13:12 +03001181 .identify_chip = wl18xx_identify_chip,
1182 .boot = wl18xx_boot,
Luciano Coelhobe42aee2012-05-10 12:13:50 +03001183 .plt_init = wl18xx_plt_init,
Luciano Coelho274c66c2012-05-10 12:13:13 +03001184 .trigger_cmd = wl18xx_trigger_cmd,
1185 .ack_event = wl18xx_ack_event,
Arik Nemtsov624845b2012-05-10 12:13:17 +03001186 .calc_tx_blocks = wl18xx_calc_tx_blocks,
Arik Nemtsovfb0f2e42012-05-10 12:13:18 +03001187 .set_tx_desc_blocks = wl18xx_set_tx_desc_blocks,
Arik Nemtsovd2361c52012-05-10 12:13:19 +03001188 .set_tx_desc_data_len = wl18xx_set_tx_desc_data_len,
Arik Nemtsov9c809f82012-05-10 12:13:23 +03001189 .get_rx_buf_align = wl18xx_get_rx_buf_align,
Arik Nemtsov30e2dd72012-05-10 12:13:24 +03001190 .get_rx_packet_len = wl18xx_get_rx_packet_len,
Arik Nemtsov872b3452012-05-10 12:13:25 +03001191 .tx_immediate_compl = wl18xx_tx_immediate_completion,
1192 .tx_delayed_compl = NULL,
Luciano Coelhob8422dc2012-05-10 12:13:26 +03001193 .hw_init = wl18xx_hw_init,
Arik Nemtsov2fc28de2012-05-10 12:13:27 +03001194 .set_tx_desc_csum = wl18xx_set_tx_desc_csum,
Arik Nemtsov54956292012-05-10 12:13:44 +03001195 .get_pg_ver = wl18xx_get_pg_ver,
Arik Nemtsov169da042012-05-10 12:13:28 +03001196 .set_rx_csum = wl18xx_set_rx_csum,
Arik Nemtsovf13af342012-05-10 12:13:32 +03001197 .sta_get_ap_rate_mask = wl18xx_sta_get_ap_rate_mask,
Arik Nemtsovebc7e572012-05-10 12:13:34 +03001198 .ap_get_mimo_wide_rate_mask = wl18xx_ap_get_mimo_wide_rate_mask,
Luciano Coelhoa5114d92012-05-10 12:13:55 +03001199 .get_mac = wl18xx_get_mac,
Luciano Coelhoad62d812012-05-10 12:14:19 +03001200 .debugfs_init = wl18xx_debugfs_add_files,
Luciano Coelho283e8c42012-05-10 12:14:11 +03001201 .handle_static_data = wl18xx_handle_static_data,
Arik Nemtsov32bb2c02012-05-18 07:46:37 +03001202 .get_spare_blocks = wl18xx_get_spare_blocks,
Arik Nemtsova1c597f2012-05-18 07:46:40 +03001203 .set_key = wl18xx_set_key,
Ido Reis9fccc822012-05-13 14:53:40 +03001204 .pre_pkt_send = wl18xx_pre_pkt_send,
Luciano Coelho0cd65432012-05-10 12:13:11 +03001205};
1206
Arik Nemtsov0e0f5a32012-05-10 12:13:35 +03001207/* HT cap appropriate for wide channels */
Luciano Coelho83342712012-05-10 12:14:15 +03001208static struct ieee80211_sta_ht_cap wl18xx_siso40_ht_cap = {
Arik Nemtsov0e0f5a32012-05-10 12:13:35 +03001209 .cap = IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
1210 IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_DSSSCCK40,
1211 .ht_supported = true,
1212 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
1213 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1214 .mcs = {
1215 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1216 .rx_highest = cpu_to_le16(150),
1217 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
1218 },
1219};
1220
Luciano Coelho83342712012-05-10 12:14:15 +03001221/* HT cap appropriate for SISO 20 */
1222static struct ieee80211_sta_ht_cap wl18xx_siso20_ht_cap = {
1223 .cap = IEEE80211_HT_CAP_SGI_20,
1224 .ht_supported = true,
1225 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
1226 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1227 .mcs = {
1228 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1229 .rx_highest = cpu_to_le16(72),
1230 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
1231 },
1232};
1233
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001234/* HT cap appropriate for MIMO rates in 20mhz channel */
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001235static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_2ghz = {
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001236 .cap = IEEE80211_HT_CAP_SGI_20,
1237 .ht_supported = true,
1238 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
1239 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1240 .mcs = {
1241 .rx_mask = { 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, },
1242 .rx_highest = cpu_to_le16(144),
1243 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
1244 },
1245};
1246
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001247static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_5ghz = {
1248 .cap = IEEE80211_HT_CAP_SGI_20,
1249 .ht_supported = true,
1250 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
1251 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1252 .mcs = {
1253 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1254 .rx_highest = cpu_to_le16(72),
1255 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
1256 },
1257};
1258
Arik Nemtsovd35dc732012-05-15 17:08:51 +03001259static int __devinit wl18xx_probe(struct platform_device *pdev)
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001260{
1261 struct wl1271 *wl;
1262 struct ieee80211_hw *hw;
Arik Nemtsov9d1c9732012-05-10 12:13:14 +03001263 struct wl18xx_priv *priv;
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001264
Arik Nemtsov9d1c9732012-05-10 12:13:14 +03001265 hw = wlcore_alloc_hw(sizeof(*priv));
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001266 if (IS_ERR(hw)) {
1267 wl1271_error("can't allocate hw");
1268 return PTR_ERR(hw);
1269 }
1270
1271 wl = hw->priv;
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001272 priv = wl->priv;
Luciano Coelho554c36b2012-05-10 12:13:08 +03001273 wl->ops = &wl18xx_ops;
Luciano Coelho82b890c2012-05-10 12:13:09 +03001274 wl->ptable = wl18xx_ptable;
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +03001275 wl->rtable = wl18xx_rtable;
Arik Nemtsovcb7b5d82012-05-10 12:13:15 +03001276 wl->num_tx_desc = 32;
Arik Nemtsov0afd04e2012-05-10 12:13:54 +03001277 wl->num_rx_desc = 16;
Arik Nemtsovf648eab2012-05-10 12:13:20 +03001278 wl->band_rate_to_idx = wl18xx_band_rate_to_idx;
1279 wl->hw_tx_rate_tbl_size = WL18XX_CONF_HW_RXTX_RATE_MAX;
1280 wl->hw_min_ht_rate = WL18XX_CONF_HW_RXTX_RATE_MCS0;
Arik Nemtsov1fab39d2012-05-10 12:13:21 +03001281 wl->fw_status_priv_len = sizeof(struct wl18xx_fw_status_priv);
Luciano Coelho8c0ea102012-05-10 12:14:09 +03001282 wl->stats.fw_stats_len = sizeof(struct wl18xx_acx_statistics);
Luciano Coelho283e8c42012-05-10 12:14:11 +03001283 wl->static_data_priv_len = sizeof(struct wl18xx_static_data_priv);
Luciano Coelho83342712012-05-10 12:14:15 +03001284
1285 if (!strcmp(ht_mode_param, "wide")) {
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001286 memcpy(&wl->ht_cap[IEEE80211_BAND_2GHZ],
1287 &wl18xx_siso40_ht_cap,
1288 sizeof(wl18xx_siso40_ht_cap));
1289 memcpy(&wl->ht_cap[IEEE80211_BAND_5GHZ],
1290 &wl18xx_siso40_ht_cap,
Luciano Coelho83342712012-05-10 12:14:15 +03001291 sizeof(wl18xx_siso40_ht_cap));
1292 } else if (!strcmp(ht_mode_param, "mimo")) {
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001293 memcpy(&wl->ht_cap[IEEE80211_BAND_2GHZ],
1294 &wl18xx_mimo_ht_cap_2ghz,
1295 sizeof(wl18xx_mimo_ht_cap_2ghz));
1296 memcpy(&wl->ht_cap[IEEE80211_BAND_5GHZ],
1297 &wl18xx_mimo_ht_cap_5ghz,
1298 sizeof(wl18xx_mimo_ht_cap_5ghz));
Luciano Coelho83342712012-05-10 12:14:15 +03001299 } else if (!strcmp(ht_mode_param, "siso20")) {
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001300 memcpy(&wl->ht_cap[IEEE80211_BAND_2GHZ],
1301 &wl18xx_siso20_ht_cap,
1302 sizeof(wl18xx_siso20_ht_cap));
1303 memcpy(&wl->ht_cap[IEEE80211_BAND_5GHZ],
1304 &wl18xx_siso20_ht_cap,
Luciano Coelho83342712012-05-10 12:14:15 +03001305 sizeof(wl18xx_siso20_ht_cap));
1306 } else {
1307 wl1271_error("invalid ht_mode '%s'", ht_mode_param);
1308 goto out_free;
1309 }
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001310
Luciano Coelho776f0302012-05-10 12:13:58 +03001311 wl18xx_conf_init(wl);
1312
Luciano Coelho4b9d2362012-05-10 12:13:59 +03001313 if (!strcmp(board_type_param, "fpga")) {
Arik Nemtsov05057c02012-05-10 12:13:48 +03001314 priv->board_type = BOARD_TYPE_FPGA_18XX;
1315 } else if (!strcmp(board_type_param, "hdk")) {
1316 priv->board_type = BOARD_TYPE_HDK_18XX;
Luciano Coelho0a1569f2012-05-10 12:13:51 +03001317 /* HACK! Just for now we hardcode HDK to 0x06 */
1318 priv->conf.phy.low_band_component_type = 0x06;
Arik Nemtsov05057c02012-05-10 12:13:48 +03001319 } else if (!strcmp(board_type_param, "dvp")) {
1320 priv->board_type = BOARD_TYPE_DVP_18XX;
1321 } else if (!strcmp(board_type_param, "evb")) {
1322 priv->board_type = BOARD_TYPE_EVB_18XX;
1323 } else if (!strcmp(board_type_param, "com8")) {
1324 priv->board_type = BOARD_TYPE_COM8_18XX;
Luciano Coelho73d8a422012-05-10 12:14:01 +03001325 /* HACK! Just for now we hardcode COM8 to 0x06 */
1326 priv->conf.phy.low_band_component_type = 0x06;
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001327 } else {
Arik Nemtsov05057c02012-05-10 12:13:48 +03001328 wl1271_error("invalid board type '%s'", board_type_param);
Luciano Coelho83342712012-05-10 12:14:15 +03001329 goto out_free;
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001330 }
1331
Luciano Coelho858403a2012-05-10 12:14:17 +03001332 /*
1333 * If the module param is not set, update it with the one from
1334 * conf. If it is set, overwrite conf with it.
1335 */
1336 if (low_band_component == -1)
1337 low_band_component = priv->conf.phy.low_band_component;
1338 else
1339 priv->conf.phy.low_band_component = low_band_component;
1340 if (low_band_component_type == -1)
1341 low_band_component_type =
1342 priv->conf.phy.low_band_component_type;
1343 else
1344 priv->conf.phy.low_band_component_type =
1345 low_band_component_type;
1346
1347 if (high_band_component == -1)
1348 high_band_component = priv->conf.phy.high_band_component;
1349 else
1350 priv->conf.phy.high_band_component = high_band_component;
1351 if (high_band_component_type == -1)
1352 high_band_component_type =
1353 priv->conf.phy.high_band_component_type;
1354 else
1355 priv->conf.phy.high_band_component_type =
1356 high_band_component_type;
1357
Luciano Coelho7b03c302012-05-10 12:14:18 +03001358 if (pwr_limit_reference_11_abg == -1)
1359 pwr_limit_reference_11_abg =
1360 priv->conf.phy.pwr_limit_reference_11_abg;
1361 else
1362 priv->conf.phy.pwr_limit_reference_11_abg =
1363 pwr_limit_reference_11_abg;
1364
Luciano Coelho102165c2012-05-10 12:13:53 +03001365 if (!checksum_param) {
1366 wl18xx_ops.set_rx_csum = NULL;
1367 wl18xx_ops.init_vif = NULL;
1368 }
1369
Luciano Coelho1ddbc7d2012-05-10 12:13:56 +03001370 wl->enable_11a = enable_11a_param;
1371
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001372 return wlcore_probe(wl, pdev);
Luciano Coelho83342712012-05-10 12:14:15 +03001373
1374out_free:
1375 wlcore_free_hw(wl);
1376 return -EINVAL;
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001377}
1378
1379static const struct platform_device_id wl18xx_id_table[] __devinitconst = {
1380 { "wl18xx", 0 },
1381 { } /* Terminating Entry */
1382};
1383MODULE_DEVICE_TABLE(platform, wl18xx_id_table);
1384
1385static struct platform_driver wl18xx_driver = {
1386 .probe = wl18xx_probe,
1387 .remove = __devexit_p(wlcore_remove),
1388 .id_table = wl18xx_id_table,
1389 .driver = {
1390 .name = "wl18xx_driver",
1391 .owner = THIS_MODULE,
1392 }
1393};
1394
1395static int __init wl18xx_init(void)
1396{
1397 return platform_driver_register(&wl18xx_driver);
1398}
1399module_init(wl18xx_init);
1400
1401static void __exit wl18xx_exit(void)
1402{
1403 platform_driver_unregister(&wl18xx_driver);
1404}
1405module_exit(wl18xx_exit);
1406
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001407module_param_named(ht_mode, ht_mode_param, charp, S_IRUSR);
Luciano Coelho83342712012-05-10 12:14:15 +03001408MODULE_PARM_DESC(ht_mode, "Force HT mode: wide (default), mimo or siso20");
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001409
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001410module_param_named(board_type, board_type_param, charp, S_IRUSR);
Luciano Coelho4b9d2362012-05-10 12:13:59 +03001411MODULE_PARM_DESC(board_type, "Board type: fpga, hdk (default), evb, com8 or "
1412 "dvp");
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001413
Luciano Coelhoe9258812012-05-10 12:13:52 +03001414module_param_named(dc2dc, dc2dc_param, bool, S_IRUSR);
1415MODULE_PARM_DESC(dc2dc, "External DC2DC: boolean (defaults to false)");
1416
1417module_param_named(n_antennas_2, n_antennas_2_param, uint, S_IRUSR);
1418MODULE_PARM_DESC(n_antennas_2, "Number of installed 2.4GHz antennas: 1 (default) or 2");
1419
1420module_param_named(n_antennas_5, n_antennas_5_param, uint, S_IRUSR);
1421MODULE_PARM_DESC(n_antennas_5, "Number of installed 5GHz antennas: 1 (default) or 2");
1422
Luciano Coelho102165c2012-05-10 12:13:53 +03001423module_param_named(checksum, checksum_param, bool, S_IRUSR);
Assaf Azulay3d62eb52012-05-10 12:14:23 +03001424MODULE_PARM_DESC(checksum, "Enable TCP checksum: boolean (defaults to false)");
Luciano Coelho102165c2012-05-10 12:13:53 +03001425
Luciano Coelho1ddbc7d2012-05-10 12:13:56 +03001426module_param_named(enable_11a, enable_11a_param, bool, S_IRUSR);
1427MODULE_PARM_DESC(enable_11a, "Enable 11a (5GHz): boolean (defaults to true)");
1428
Luciano Coelho858403a2012-05-10 12:14:17 +03001429module_param(low_band_component, uint, S_IRUSR);
1430MODULE_PARM_DESC(low_band_component, "Low band component: u8 "
1431 "(default is 0x01)");
1432
1433module_param(low_band_component_type, uint, S_IRUSR);
1434MODULE_PARM_DESC(low_band_component_type, "Low band component type: u8 "
1435 "(default is 0x05 or 0x06 depending on the board_type)");
1436
1437module_param(high_band_component, uint, S_IRUSR);
1438MODULE_PARM_DESC(high_band_component, "High band component: u8, "
1439 "(default is 0x01)");
1440
1441module_param(high_band_component_type, uint, S_IRUSR);
1442MODULE_PARM_DESC(high_band_component_type, "High band component type: u8 "
1443 "(default is 0x09)");
1444
Luciano Coelho7b03c302012-05-10 12:14:18 +03001445module_param(pwr_limit_reference_11_abg, uint, S_IRUSR);
1446MODULE_PARM_DESC(pwr_limit_reference_11_abg, "Power limit reference: u8 "
1447 "(default is 0xc8)");
1448
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001449MODULE_LICENSE("GPL v2");
1450MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
Luciano Coelho0cd65432012-05-10 12:13:11 +03001451MODULE_FIRMWARE(WL18XX_FW_NAME);