blob: c8d45f011c63191f735615a3b3141ac19226a743 [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,
379 .host_fast_wakeup_support = false
380 },
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,
Luciano Coelho46a1d512012-05-10 12:13:12 +0300514 },
515};
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +0300516
Luciano Coelho82b890c2012-05-10 12:13:09 +0300517static const struct wlcore_partition_set wl18xx_ptable[PART_TABLE_LEN] = {
518 [PART_TOP_PRCM_ELP_SOC] = {
519 .mem = { .start = 0x00A02000, .size = 0x00010000 },
520 .reg = { .start = 0x00807000, .size = 0x00005000 },
521 .mem2 = { .start = 0x00800000, .size = 0x0000B000 },
522 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
523 },
524 [PART_DOWN] = {
525 .mem = { .start = 0x00000000, .size = 0x00014000 },
526 .reg = { .start = 0x00810000, .size = 0x0000BFFF },
527 .mem2 = { .start = 0x00000000, .size = 0x00000000 },
528 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
529 },
530 [PART_BOOT] = {
531 .mem = { .start = 0x00700000, .size = 0x0000030c },
532 .reg = { .start = 0x00802000, .size = 0x00014578 },
533 .mem2 = { .start = 0x00B00404, .size = 0x00001000 },
534 .mem3 = { .start = 0x00C00000, .size = 0x00000400 },
535 },
536 [PART_WORK] = {
537 .mem = { .start = 0x00800000, .size = 0x000050FC },
538 .reg = { .start = 0x00B00404, .size = 0x00001000 },
539 .mem2 = { .start = 0x00C00000, .size = 0x00000400 },
540 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
541 },
542 [PART_PHY_INIT] = {
543 /* TODO: use the phy_conf struct size here */
544 .mem = { .start = 0x80926000, .size = 252 },
545 .reg = { .start = 0x00000000, .size = 0x00000000 },
546 .mem2 = { .start = 0x00000000, .size = 0x00000000 },
547 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
548 },
549};
550
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +0300551static const int wl18xx_rtable[REG_TABLE_LEN] = {
552 [REG_ECPU_CONTROL] = WL18XX_REG_ECPU_CONTROL,
553 [REG_INTERRUPT_NO_CLEAR] = WL18XX_REG_INTERRUPT_NO_CLEAR,
554 [REG_INTERRUPT_ACK] = WL18XX_REG_INTERRUPT_ACK,
555 [REG_COMMAND_MAILBOX_PTR] = WL18XX_REG_COMMAND_MAILBOX_PTR,
556 [REG_EVENT_MAILBOX_PTR] = WL18XX_REG_EVENT_MAILBOX_PTR,
557 [REG_INTERRUPT_TRIG] = WL18XX_REG_INTERRUPT_TRIG_H,
558 [REG_INTERRUPT_MASK] = WL18XX_REG_INTERRUPT_MASK,
Arik Nemtsov1c351da2012-05-10 12:13:39 +0300559 [REG_PC_ON_RECOVERY] = WL18XX_SCR_PAD4,
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +0300560 [REG_CHIP_ID_B] = WL18XX_REG_CHIP_ID_B,
561 [REG_CMD_MBOX_ADDRESS] = WL18XX_CMD_MBOX_ADDRESS,
562
563 /* data access memory addresses, used with partition translation */
564 [REG_SLV_MEM_DATA] = WL18XX_SLV_MEM_DATA,
565 [REG_SLV_REG_DATA] = WL18XX_SLV_REG_DATA,
566
567 /* raw data access memory addresses */
568 [REG_RAW_FW_STATUS_ADDR] = WL18XX_FW_STATUS_ADDR,
569};
570
Luciano Coelhobe652022012-05-10 12:13:41 +0300571static const struct wl18xx_clk_cfg wl18xx_clk_table[NUM_CLOCK_CONFIGS] = {
572 [CLOCK_CONFIG_16_2_M] = { 7, 104, 801, 4, true },
573 [CLOCK_CONFIG_16_368_M] = { 9, 132, 3751, 4, true },
574 [CLOCK_CONFIG_16_8_M] = { 7, 100, 0, 0, false },
575 [CLOCK_CONFIG_19_2_M] = { 8, 100, 0, 0, false },
576 [CLOCK_CONFIG_26_M] = { 13, 120, 0, 0, false },
577 [CLOCK_CONFIG_32_736_M] = { 9, 132, 3751, 4, true },
578 [CLOCK_CONFIG_33_6_M] = { 7, 100, 0, 0, false },
579 [CLOCK_CONFIG_38_468_M] = { 8, 100, 0, 0, false },
580 [CLOCK_CONFIG_52_M] = { 13, 120, 0, 0, false },
581};
582
Luciano Coelho0cd65432012-05-10 12:13:11 +0300583/* TODO: maybe move to a new header file? */
584#define WL18XX_FW_NAME "ti-connectivity/wl18xx-fw.bin"
585
586static int wl18xx_identify_chip(struct wl1271 *wl)
587{
588 int ret = 0;
589
590 switch (wl->chip.id) {
591 case CHIP_ID_185x_PG10:
592 wl1271_debug(DEBUG_BOOT, "chip id 0x%x (185x PG10)",
593 wl->chip.id);
594 wl->sr_fw_name = WL18XX_FW_NAME;
Luciano Coelhobe42aee2012-05-10 12:13:50 +0300595 /* wl18xx uses the same firmware for PLT */
596 wl->plt_fw_name = WL18XX_FW_NAME;
Arik Nemtsov7cfefd12012-05-10 12:13:22 +0300597 wl->quirks |= WLCORE_QUIRK_NO_ELP |
Luciano Coelhob5d6d9b2012-06-05 00:02:25 +0300598 WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED |
599 WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN |
600 WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN;
Luciano Coelho0cd65432012-05-10 12:13:11 +0300601
Luciano Coelho7ae25da2012-05-10 12:14:03 +0300602 /* PG 1.0 has some problems with MCS_13, so disable it */
Eliad Pellerbfb92ca2012-05-15 17:09:00 +0300603 wl->ht_cap[IEEE80211_BAND_2GHZ].mcs.rx_mask[1] &= ~BIT(5);
Luciano Coelho7ae25da2012-05-10 12:14:03 +0300604
Luciano Coelho0cd65432012-05-10 12:13:11 +0300605 /* TODO: need to blocksize alignment for RX/TX separately? */
606 break;
607 default:
608 wl1271_warning("unsupported chip id: 0x%x", wl->chip.id);
609 ret = -ENODEV;
610 goto out;
611 }
612
613out:
614 return ret;
615}
616
Luciano Coelho46a1d512012-05-10 12:13:12 +0300617static void wl18xx_set_clk(struct wl1271 *wl)
618{
Luciano Coelhobe652022012-05-10 12:13:41 +0300619 u32 clk_freq;
Luciano Coelhod5b59272012-05-10 12:13:38 +0300620
Luciano Coelho46a1d512012-05-10 12:13:12 +0300621 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
Luciano Coelhobe652022012-05-10 12:13:41 +0300622
623 /* TODO: PG2: apparently we need to read the clk type */
624
625 clk_freq = wl18xx_top_reg_read(wl, PRIMARY_CLK_DETECT);
626 wl1271_debug(DEBUG_BOOT, "clock freq %d (%d, %d, %d, %d, %s)", clk_freq,
627 wl18xx_clk_table[clk_freq].n, wl18xx_clk_table[clk_freq].m,
628 wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q,
629 wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit");
630
631 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N, wl18xx_clk_table[clk_freq].n);
632 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_M, wl18xx_clk_table[clk_freq].m);
633
634 if (wl18xx_clk_table[clk_freq].swallow) {
635 /* first the 16 lower bits */
636 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_1,
637 wl18xx_clk_table[clk_freq].q &
638 PLLSH_WCS_PLL_Q_FACTOR_CFG_1_MASK);
639 /* then the 16 higher bits, masked out */
640 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_2,
641 (wl18xx_clk_table[clk_freq].q >> 16) &
642 PLLSH_WCS_PLL_Q_FACTOR_CFG_2_MASK);
643
644 /* first the 16 lower bits */
645 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_1,
646 wl18xx_clk_table[clk_freq].p &
647 PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK);
648 /* then the 16 higher bits, masked out */
649 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2,
650 (wl18xx_clk_table[clk_freq].p >> 16) &
651 PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK);
652 } else {
653 wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN,
654 PLLSH_WCS_PLL_SWALLOW_EN_VAL2);
655 }
Luciano Coelho46a1d512012-05-10 12:13:12 +0300656}
657
658static void wl18xx_boot_soft_reset(struct wl1271 *wl)
659{
660 /* disable Rx/Tx */
661 wl1271_write32(wl, WL18XX_ENABLE, 0x0);
662
663 /* disable auto calibration on start*/
664 wl1271_write32(wl, WL18XX_SPARE_A2, 0xffff);
665}
666
667static int wl18xx_pre_boot(struct wl1271 *wl)
668{
Luciano Coelho46a1d512012-05-10 12:13:12 +0300669 wl18xx_set_clk(wl);
670
671 /* Continue the ELP wake up sequence */
672 wl1271_write32(wl, WL18XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
673 udelay(500);
674
675 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
676
677 /* Disable interrupts */
678 wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL);
679
680 wl18xx_boot_soft_reset(wl);
681
682 return 0;
683}
684
685static void wl18xx_pre_upload(struct wl1271 *wl)
686{
687 u32 tmp;
688
689 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
690
691 /* TODO: check if this is all needed */
692 wl1271_write32(wl, WL18XX_EEPROMLESS_IND, WL18XX_EEPROMLESS_IND);
693
694 tmp = wlcore_read_reg(wl, REG_CHIP_ID_B);
695
696 wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp);
697
698 tmp = wl1271_read32(wl, WL18XX_SCR_PAD2);
699}
700
701static void wl18xx_set_mac_and_phy(struct wl1271 *wl)
702{
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300703 struct wl18xx_priv *priv = wl->priv;
704 struct wl18xx_conf_phy *phy = &priv->conf.phy;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300705 struct wl18xx_mac_and_phy_params params;
706
707 memset(&params, 0, sizeof(params));
708
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300709 params.phy_standalone = phy->phy_standalone;
710 params.rdl = phy->rdl;
711 params.enable_clpc = phy->enable_clpc;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300712 params.enable_tx_low_pwr_on_siso_rdl =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300713 phy->enable_tx_low_pwr_on_siso_rdl;
714 params.auto_detect = phy->auto_detect;
715 params.dedicated_fem = phy->dedicated_fem;
716 params.low_band_component = phy->low_band_component;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300717 params.low_band_component_type =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300718 phy->low_band_component_type;
719 params.high_band_component = phy->high_band_component;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300720 params.high_band_component_type =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300721 phy->high_band_component_type;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300722 params.number_of_assembled_ant2_4 =
Luciano Coelhoe9258812012-05-10 12:13:52 +0300723 n_antennas_2_param;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300724 params.number_of_assembled_ant5 =
Luciano Coelhoe9258812012-05-10 12:13:52 +0300725 n_antennas_5_param;
726 params.external_pa_dc2dc = dc2dc_param;
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300727 params.tcxo_ldo_voltage = phy->tcxo_ldo_voltage;
728 params.xtal_itrim_val = phy->xtal_itrim_val;
729 params.srf_state = phy->srf_state;
730 params.io_configuration = phy->io_configuration;
731 params.sdio_configuration = phy->sdio_configuration;
732 params.settings = phy->settings;
733 params.rx_profile = phy->rx_profile;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300734 params.primary_clock_setting_time =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300735 phy->primary_clock_setting_time;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300736 params.clock_valid_on_wake_up =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300737 phy->clock_valid_on_wake_up;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300738 params.secondary_clock_setting_time =
Luciano Coelho23ee9bf2012-05-10 12:13:29 +0300739 phy->secondary_clock_setting_time;
Luciano Coelho5add82e2012-05-10 12:14:16 +0300740 params.pwr_limit_reference_11_abg =
741 phy->pwr_limit_reference_11_abg;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300742
Luciano Coelhoa9c130d2012-05-10 12:13:37 +0300743 params.board_type = priv->board_type;
Luciano Coelho46a1d512012-05-10 12:13:12 +0300744
745 wlcore_set_partition(wl, &wl->ptable[PART_PHY_INIT]);
746 wl1271_write(wl, WL18XX_PHY_INIT_MEM_ADDR, (u8 *)&params,
747 sizeof(params), false);
748}
749
750static void wl18xx_enable_interrupts(struct wl1271 *wl)
751{
752 wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_ALL_EVENTS_VECTOR);
753
754 wlcore_enable_interrupts(wl);
755 wlcore_write_reg(wl, REG_INTERRUPT_MASK,
756 WL1271_ACX_INTR_ALL & ~(WL1271_INTR_MASK));
757}
758
759static int wl18xx_boot(struct wl1271 *wl)
760{
761 int ret;
762
763 ret = wl18xx_pre_boot(wl);
764 if (ret < 0)
765 goto out;
766
Luciano Coelho46a1d512012-05-10 12:13:12 +0300767 wl18xx_pre_upload(wl);
768
769 ret = wlcore_boot_upload_firmware(wl);
770 if (ret < 0)
771 goto out;
772
773 wl18xx_set_mac_and_phy(wl);
774
775 ret = wlcore_boot_run_firmware(wl);
776 if (ret < 0)
777 goto out;
778
779 wl18xx_enable_interrupts(wl);
780
781out:
782 return ret;
783}
784
Luciano Coelho274c66c2012-05-10 12:13:13 +0300785static void wl18xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr,
786 void *buf, size_t len)
787{
788 struct wl18xx_priv *priv = wl->priv;
789
790 memcpy(priv->cmd_buf, buf, len);
791 memset(priv->cmd_buf + len, 0, WL18XX_CMD_MAX_SIZE - len);
792
793 wl1271_write(wl, cmd_box_addr, priv->cmd_buf, WL18XX_CMD_MAX_SIZE,
794 false);
795}
796
797static void wl18xx_ack_event(struct wl1271 *wl)
798{
799 wlcore_write_reg(wl, REG_INTERRUPT_TRIG, WL18XX_INTR_TRIG_EVENT_ACK);
800}
801
Arik Nemtsov624845b2012-05-10 12:13:17 +0300802static u32 wl18xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
803{
804 u32 blk_size = WL18XX_TX_HW_BLOCK_SIZE;
805 return (len + blk_size - 1) / blk_size + spare_blks;
806}
807
Arik Nemtsovfb0f2e42012-05-10 12:13:18 +0300808static void
809wl18xx_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
810 u32 blks, u32 spare_blks)
811{
812 desc->wl18xx_mem.total_mem_blocks = blks;
813 desc->wl18xx_mem.reserved = 0;
814}
815
Arik Nemtsovd2361c52012-05-10 12:13:19 +0300816static void
817wl18xx_set_tx_desc_data_len(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
818 struct sk_buff *skb)
819{
820 desc->length = cpu_to_le16(skb->len);
821
822 wl1271_debug(DEBUG_TX, "tx_fill_hdr: hlid: %d "
823 "len: %d life: %d mem: %d", desc->hlid,
824 le16_to_cpu(desc->length),
825 le16_to_cpu(desc->life_time),
826 desc->wl18xx_mem.total_mem_blocks);
827}
828
Arik Nemtsov9c809f82012-05-10 12:13:23 +0300829static enum wl_rx_buf_align
830wl18xx_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)
831{
832 if (rx_desc & RX_BUF_PADDED_PAYLOAD)
833 return WLCORE_RX_BUF_PADDED;
834
835 return WLCORE_RX_BUF_ALIGNED;
836}
837
Arik Nemtsov30e2dd72012-05-10 12:13:24 +0300838static u32 wl18xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data,
839 u32 data_len)
840{
841 struct wl1271_rx_descriptor *desc = rx_data;
842
843 /* invalid packet */
844 if (data_len < sizeof(*desc))
845 return 0;
846
847 return data_len - sizeof(*desc);
848}
Arik Nemtsov9c809f82012-05-10 12:13:23 +0300849
Arik Nemtsov872b3452012-05-10 12:13:25 +0300850static void wl18xx_tx_immediate_completion(struct wl1271 *wl)
851{
852 wl18xx_tx_immediate_complete(wl);
853}
854
Arik Nemtsova1c597f2012-05-18 07:46:40 +0300855static int wl18xx_set_host_cfg_bitmap(struct wl1271 *wl, u32 extra_mem_blk)
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300856{
857 int ret;
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300858 u32 sdio_align_size = 0;
Arik Nemtsova1c597f2012-05-18 07:46:40 +0300859 u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE |
860 HOST_IF_CFG_ADD_RX_ALIGNMENT;
Arik Nemtsovf2baf072012-05-10 12:13:46 +0300861
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300862 /* Enable Tx SDIO padding */
863 if (wl->quirks & WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN) {
864 host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
865 sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
866 }
867
868 /* Enable Rx SDIO padding */
869 if (wl->quirks & WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN) {
870 host_cfg_bitmap |= HOST_IF_CFG_RX_PAD_TO_SDIO_BLK;
871 sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
872 }
873
874 ret = wl18xx_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap,
Arik Nemtsova1c597f2012-05-18 07:46:40 +0300875 sdio_align_size, extra_mem_blk,
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300876 WL18XX_HOST_IF_LEN_SIZE_FIELD);
877 if (ret < 0)
878 return ret;
879
Arik Nemtsova1c597f2012-05-18 07:46:40 +0300880 return 0;
881}
882
883static int wl18xx_hw_init(struct wl1271 *wl)
884{
885 int ret;
886 struct wl18xx_priv *priv = wl->priv;
887
888 /* (re)init private structures. Relevant on recovery as well. */
889 priv->last_fw_rls_idx = 0;
890 priv->extra_spare_vif_count = 0;
891
892 /* set the default amount of spare blocks in the bitmap */
893 ret = wl18xx_set_host_cfg_bitmap(wl, WL18XX_TX_HW_BLOCK_SPARE);
894 if (ret < 0)
895 return ret;
896
Luciano Coelho102165c2012-05-10 12:13:53 +0300897 if (checksum_param) {
898 ret = wl18xx_acx_set_checksum_state(wl);
899 if (ret != 0)
900 return ret;
901 }
Arik Nemtsov2fc28de2012-05-10 12:13:27 +0300902
Luciano Coelhob8422dc2012-05-10 12:13:26 +0300903 return ret;
904}
905
Arik Nemtsov2fc28de2012-05-10 12:13:27 +0300906static void wl18xx_set_tx_desc_csum(struct wl1271 *wl,
907 struct wl1271_tx_hw_descr *desc,
908 struct sk_buff *skb)
909{
910 u32 ip_hdr_offset;
911 struct iphdr *ip_hdr;
912
Luciano Coelho102165c2012-05-10 12:13:53 +0300913 if (!checksum_param) {
914 desc->wl18xx_checksum_data = 0;
915 return;
916 }
917
Arik Nemtsov2fc28de2012-05-10 12:13:27 +0300918 if (skb->ip_summed != CHECKSUM_PARTIAL) {
919 desc->wl18xx_checksum_data = 0;
920 return;
921 }
922
923 ip_hdr_offset = skb_network_header(skb) - skb_mac_header(skb);
924 if (WARN_ON(ip_hdr_offset >= (1<<7))) {
925 desc->wl18xx_checksum_data = 0;
926 return;
927 }
928
929 desc->wl18xx_checksum_data = ip_hdr_offset << 1;
930
931 /* FW is interested only in the LSB of the protocol TCP=0 UDP=1 */
932 ip_hdr = (void *)skb_network_header(skb);
933 desc->wl18xx_checksum_data |= (ip_hdr->protocol & 0x01);
934}
935
Arik Nemtsov169da042012-05-10 12:13:28 +0300936static void wl18xx_set_rx_csum(struct wl1271 *wl,
937 struct wl1271_rx_descriptor *desc,
938 struct sk_buff *skb)
939{
940 if (desc->status & WL18XX_RX_CHECKSUM_MASK)
941 skb->ip_summed = CHECKSUM_UNNECESSARY;
942}
943
Luciano Coelho7ae25da2012-05-10 12:14:03 +0300944/*
945 * TODO: instead of having these two functions to get the rate mask,
946 * we should modify the wlvif->rate_set instead
947 */
Arik Nemtsovf13af342012-05-10 12:13:32 +0300948static u32 wl18xx_sta_get_ap_rate_mask(struct wl1271 *wl,
949 struct wl12xx_vif *wlvif)
950{
951 u32 hw_rate_set = wlvif->rate_set;
952
953 if (wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
954 wlvif->channel_type == NL80211_CHAN_HT40PLUS) {
955 wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
956 hw_rate_set |= CONF_TX_RATE_USE_WIDE_CHAN;
957
958 /* we don't support MIMO in wide-channel mode */
959 hw_rate_set &= ~CONF_TX_MIMO_RATES;
960 }
961
962 return hw_rate_set;
963}
964
Arik Nemtsovebc7e572012-05-10 12:13:34 +0300965static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
966 struct wl12xx_vif *wlvif)
967{
Luciano Coelho174a7302012-05-10 12:14:13 +0300968 if ((wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
969 wlvif->channel_type == NL80211_CHAN_HT40PLUS) &&
970 !strcmp(ht_mode_param, "wide")) {
Arik Nemtsovebc7e572012-05-10 12:13:34 +0300971 wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
972 return CONF_TX_RATE_USE_WIDE_CHAN;
Luciano Coelho174a7302012-05-10 12:14:13 +0300973 } else if (!strcmp(ht_mode_param, "mimo")) {
Arik Nemtsovebc7e572012-05-10 12:13:34 +0300974 wl1271_debug(DEBUG_ACX, "using MIMO rate mask");
Luciano Coelho7ae25da2012-05-10 12:14:03 +0300975
976 /*
977 * PG 1.0 has some problems with MCS_13, so disable it
978 *
979 * TODO: instead of hacking this in here, we should
980 * make it more general and change a bit in the
981 * wlvif->rate_set instead.
982 */
983 if (wl->chip.id == CHIP_ID_185x_PG10)
984 return CONF_TX_MIMO_RATES & ~CONF_HW_BIT_RATE_MCS_13;
985
Arik Nemtsovebc7e572012-05-10 12:13:34 +0300986 return CONF_TX_MIMO_RATES;
Luciano Coelho174a7302012-05-10 12:14:13 +0300987 } else {
988 return 0;
Arik Nemtsovebc7e572012-05-10 12:13:34 +0300989 }
990}
991
Arik Nemtsov54956292012-05-10 12:13:44 +0300992static s8 wl18xx_get_pg_ver(struct wl1271 *wl)
993{
994 u32 fuse;
995
996 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
997
998 fuse = wl1271_read32(wl, WL18XX_REG_FUSE_DATA_1_3);
999 fuse = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET;
1000
1001 wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
1002
1003 return (s8)fuse;
1004}
1005
Luciano Coelho23ee9bf2012-05-10 12:13:29 +03001006static void wl18xx_conf_init(struct wl1271 *wl)
1007{
1008 struct wl18xx_priv *priv = wl->priv;
1009
1010 /* apply driver default configuration */
1011 memcpy(&wl->conf, &wl18xx_conf, sizeof(wl18xx_conf));
1012
1013 /* apply default private configuration */
1014 memcpy(&priv->conf, &wl18xx_default_priv_conf, sizeof(priv->conf));
1015}
1016
Luciano Coelhobe42aee2012-05-10 12:13:50 +03001017static int wl18xx_plt_init(struct wl1271 *wl)
1018{
1019 wl1271_write32(wl, WL18XX_SCR_PAD8, WL18XX_SCR_PAD8_PLT);
1020
1021 return wl->ops->boot(wl);
1022}
1023
Luciano Coelhoa5114d92012-05-10 12:13:55 +03001024static void wl18xx_get_mac(struct wl1271 *wl)
1025{
1026 u32 mac1, mac2;
1027
1028 wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
1029
1030 mac1 = wl1271_read32(wl, WL18XX_REG_FUSE_BD_ADDR_1);
1031 mac2 = wl1271_read32(wl, WL18XX_REG_FUSE_BD_ADDR_2);
1032
1033 /* these are the two parts of the BD_ADDR */
1034 wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) +
1035 ((mac1 & 0xff000000) >> 24);
1036 wl->fuse_nic_addr = (mac1 & 0xffffff);
1037
1038 wlcore_set_partition(wl, &wl->ptable[PART_DOWN]);
1039}
1040
Luciano Coelho283e8c42012-05-10 12:14:11 +03001041static int wl18xx_handle_static_data(struct wl1271 *wl,
1042 struct wl1271_static_data *static_data)
1043{
1044 struct wl18xx_static_data_priv *static_data_priv =
1045 (struct wl18xx_static_data_priv *) static_data->priv;
1046
1047 wl1271_info("PHY firmware version: %s", static_data_priv->phy_version);
1048
1049 return 0;
1050}
1051
Arik Nemtsov32bb2c02012-05-18 07:46:37 +03001052static int wl18xx_get_spare_blocks(struct wl1271 *wl, bool is_gem)
1053{
Arik Nemtsova1c597f2012-05-18 07:46:40 +03001054 struct wl18xx_priv *priv = wl->priv;
1055
1056 /* If we have VIFs requiring extra spare, indulge them */
1057 if (priv->extra_spare_vif_count)
1058 return WL18XX_TX_HW_EXTRA_BLOCK_SPARE;
1059
1060 return WL18XX_TX_HW_BLOCK_SPARE;
1061}
1062
1063static int wl18xx_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
1064 struct ieee80211_vif *vif,
1065 struct ieee80211_sta *sta,
1066 struct ieee80211_key_conf *key_conf)
1067{
1068 struct wl18xx_priv *priv = wl->priv;
1069 bool change_spare = false;
1070 int ret;
1071
1072 /*
1073 * when adding the first or removing the last GEM/TKIP interface,
1074 * we have to adjust the number of spare blocks.
1075 */
1076 change_spare = (key_conf->cipher == WL1271_CIPHER_SUITE_GEM ||
1077 key_conf->cipher == WLAN_CIPHER_SUITE_TKIP) &&
1078 ((priv->extra_spare_vif_count == 0 && cmd == SET_KEY) ||
1079 (priv->extra_spare_vif_count == 1 && cmd == DISABLE_KEY));
1080
1081 /* no need to change spare - just regular set_key */
1082 if (!change_spare)
1083 return wlcore_set_key(wl, cmd, vif, sta, key_conf);
1084
1085 /*
1086 * stop the queues and flush to ensure the next packets are
1087 * in sync with FW spare block accounting
1088 */
1089 wlcore_stop_queues(wl, WLCORE_QUEUE_STOP_REASON_SPARE_BLK);
1090 wl1271_tx_flush(wl);
1091
1092 ret = wlcore_set_key(wl, cmd, vif, sta, key_conf);
1093 if (ret < 0)
1094 goto out;
1095
1096 /* key is now set, change the spare blocks */
1097 if (cmd == SET_KEY) {
1098 ret = wl18xx_set_host_cfg_bitmap(wl,
1099 WL18XX_TX_HW_EXTRA_BLOCK_SPARE);
1100 if (ret < 0)
1101 goto out;
1102
1103 priv->extra_spare_vif_count++;
1104 } else {
1105 ret = wl18xx_set_host_cfg_bitmap(wl,
1106 WL18XX_TX_HW_BLOCK_SPARE);
1107 if (ret < 0)
1108 goto out;
1109
1110 priv->extra_spare_vif_count--;
1111 }
1112
1113out:
1114 wlcore_wake_queues(wl, WLCORE_QUEUE_STOP_REASON_SPARE_BLK);
1115 return ret;
Arik Nemtsov32bb2c02012-05-18 07:46:37 +03001116}
1117
Luciano Coelho0cd65432012-05-10 12:13:11 +03001118static struct wlcore_ops wl18xx_ops = {
Luciano Coelho46a1d512012-05-10 12:13:12 +03001119 .identify_chip = wl18xx_identify_chip,
1120 .boot = wl18xx_boot,
Luciano Coelhobe42aee2012-05-10 12:13:50 +03001121 .plt_init = wl18xx_plt_init,
Luciano Coelho274c66c2012-05-10 12:13:13 +03001122 .trigger_cmd = wl18xx_trigger_cmd,
1123 .ack_event = wl18xx_ack_event,
Arik Nemtsov624845b2012-05-10 12:13:17 +03001124 .calc_tx_blocks = wl18xx_calc_tx_blocks,
Arik Nemtsovfb0f2e42012-05-10 12:13:18 +03001125 .set_tx_desc_blocks = wl18xx_set_tx_desc_blocks,
Arik Nemtsovd2361c52012-05-10 12:13:19 +03001126 .set_tx_desc_data_len = wl18xx_set_tx_desc_data_len,
Arik Nemtsov9c809f82012-05-10 12:13:23 +03001127 .get_rx_buf_align = wl18xx_get_rx_buf_align,
Arik Nemtsov30e2dd72012-05-10 12:13:24 +03001128 .get_rx_packet_len = wl18xx_get_rx_packet_len,
Arik Nemtsov872b3452012-05-10 12:13:25 +03001129 .tx_immediate_compl = wl18xx_tx_immediate_completion,
1130 .tx_delayed_compl = NULL,
Luciano Coelhob8422dc2012-05-10 12:13:26 +03001131 .hw_init = wl18xx_hw_init,
Arik Nemtsov2fc28de2012-05-10 12:13:27 +03001132 .set_tx_desc_csum = wl18xx_set_tx_desc_csum,
Arik Nemtsov54956292012-05-10 12:13:44 +03001133 .get_pg_ver = wl18xx_get_pg_ver,
Arik Nemtsov169da042012-05-10 12:13:28 +03001134 .set_rx_csum = wl18xx_set_rx_csum,
Arik Nemtsovf13af342012-05-10 12:13:32 +03001135 .sta_get_ap_rate_mask = wl18xx_sta_get_ap_rate_mask,
Arik Nemtsovebc7e572012-05-10 12:13:34 +03001136 .ap_get_mimo_wide_rate_mask = wl18xx_ap_get_mimo_wide_rate_mask,
Luciano Coelhoa5114d92012-05-10 12:13:55 +03001137 .get_mac = wl18xx_get_mac,
Luciano Coelhoad62d812012-05-10 12:14:19 +03001138 .debugfs_init = wl18xx_debugfs_add_files,
Luciano Coelho283e8c42012-05-10 12:14:11 +03001139 .handle_static_data = wl18xx_handle_static_data,
Arik Nemtsov32bb2c02012-05-18 07:46:37 +03001140 .get_spare_blocks = wl18xx_get_spare_blocks,
Arik Nemtsova1c597f2012-05-18 07:46:40 +03001141 .set_key = wl18xx_set_key,
Luciano Coelho0cd65432012-05-10 12:13:11 +03001142};
1143
Arik Nemtsov0e0f5a32012-05-10 12:13:35 +03001144/* HT cap appropriate for wide channels */
Luciano Coelho83342712012-05-10 12:14:15 +03001145static struct ieee80211_sta_ht_cap wl18xx_siso40_ht_cap = {
Arik Nemtsov0e0f5a32012-05-10 12:13:35 +03001146 .cap = IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
1147 IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_DSSSCCK40,
1148 .ht_supported = true,
1149 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
1150 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1151 .mcs = {
1152 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1153 .rx_highest = cpu_to_le16(150),
1154 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
1155 },
1156};
1157
Luciano Coelho83342712012-05-10 12:14:15 +03001158/* HT cap appropriate for SISO 20 */
1159static struct ieee80211_sta_ht_cap wl18xx_siso20_ht_cap = {
1160 .cap = IEEE80211_HT_CAP_SGI_20,
1161 .ht_supported = true,
1162 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
1163 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1164 .mcs = {
1165 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1166 .rx_highest = cpu_to_le16(72),
1167 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
1168 },
1169};
1170
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001171/* HT cap appropriate for MIMO rates in 20mhz channel */
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001172static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_2ghz = {
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001173 .cap = IEEE80211_HT_CAP_SGI_20,
1174 .ht_supported = true,
1175 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
1176 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1177 .mcs = {
1178 .rx_mask = { 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, },
1179 .rx_highest = cpu_to_le16(144),
1180 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
1181 },
1182};
1183
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001184static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_5ghz = {
1185 .cap = IEEE80211_HT_CAP_SGI_20,
1186 .ht_supported = true,
1187 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
1188 .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1189 .mcs = {
1190 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1191 .rx_highest = cpu_to_le16(72),
1192 .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
1193 },
1194};
1195
Arik Nemtsovd35dc732012-05-15 17:08:51 +03001196static int __devinit wl18xx_probe(struct platform_device *pdev)
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001197{
1198 struct wl1271 *wl;
1199 struct ieee80211_hw *hw;
Arik Nemtsov9d1c9732012-05-10 12:13:14 +03001200 struct wl18xx_priv *priv;
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001201
Arik Nemtsov9d1c9732012-05-10 12:13:14 +03001202 hw = wlcore_alloc_hw(sizeof(*priv));
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001203 if (IS_ERR(hw)) {
1204 wl1271_error("can't allocate hw");
1205 return PTR_ERR(hw);
1206 }
1207
1208 wl = hw->priv;
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001209 priv = wl->priv;
Luciano Coelho554c36b2012-05-10 12:13:08 +03001210 wl->ops = &wl18xx_ops;
Luciano Coelho82b890c2012-05-10 12:13:09 +03001211 wl->ptable = wl18xx_ptable;
Luciano Coelho5d4a9fa2012-05-10 12:13:10 +03001212 wl->rtable = wl18xx_rtable;
Arik Nemtsovcb7b5d82012-05-10 12:13:15 +03001213 wl->num_tx_desc = 32;
Arik Nemtsov0afd04e2012-05-10 12:13:54 +03001214 wl->num_rx_desc = 16;
Arik Nemtsovf648eab2012-05-10 12:13:20 +03001215 wl->band_rate_to_idx = wl18xx_band_rate_to_idx;
1216 wl->hw_tx_rate_tbl_size = WL18XX_CONF_HW_RXTX_RATE_MAX;
1217 wl->hw_min_ht_rate = WL18XX_CONF_HW_RXTX_RATE_MCS0;
Arik Nemtsov1fab39d2012-05-10 12:13:21 +03001218 wl->fw_status_priv_len = sizeof(struct wl18xx_fw_status_priv);
Luciano Coelho8c0ea102012-05-10 12:14:09 +03001219 wl->stats.fw_stats_len = sizeof(struct wl18xx_acx_statistics);
Luciano Coelho283e8c42012-05-10 12:14:11 +03001220 wl->static_data_priv_len = sizeof(struct wl18xx_static_data_priv);
Luciano Coelho83342712012-05-10 12:14:15 +03001221
1222 if (!strcmp(ht_mode_param, "wide")) {
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001223 memcpy(&wl->ht_cap[IEEE80211_BAND_2GHZ],
1224 &wl18xx_siso40_ht_cap,
1225 sizeof(wl18xx_siso40_ht_cap));
1226 memcpy(&wl->ht_cap[IEEE80211_BAND_5GHZ],
1227 &wl18xx_siso40_ht_cap,
Luciano Coelho83342712012-05-10 12:14:15 +03001228 sizeof(wl18xx_siso40_ht_cap));
1229 } else if (!strcmp(ht_mode_param, "mimo")) {
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001230 memcpy(&wl->ht_cap[IEEE80211_BAND_2GHZ],
1231 &wl18xx_mimo_ht_cap_2ghz,
1232 sizeof(wl18xx_mimo_ht_cap_2ghz));
1233 memcpy(&wl->ht_cap[IEEE80211_BAND_5GHZ],
1234 &wl18xx_mimo_ht_cap_5ghz,
1235 sizeof(wl18xx_mimo_ht_cap_5ghz));
Luciano Coelho83342712012-05-10 12:14:15 +03001236 } else if (!strcmp(ht_mode_param, "siso20")) {
Eliad Pellerbfb92ca2012-05-15 17:09:00 +03001237 memcpy(&wl->ht_cap[IEEE80211_BAND_2GHZ],
1238 &wl18xx_siso20_ht_cap,
1239 sizeof(wl18xx_siso20_ht_cap));
1240 memcpy(&wl->ht_cap[IEEE80211_BAND_5GHZ],
1241 &wl18xx_siso20_ht_cap,
Luciano Coelho83342712012-05-10 12:14:15 +03001242 sizeof(wl18xx_siso20_ht_cap));
1243 } else {
1244 wl1271_error("invalid ht_mode '%s'", ht_mode_param);
1245 goto out_free;
1246 }
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001247
Luciano Coelho776f0302012-05-10 12:13:58 +03001248 wl18xx_conf_init(wl);
1249
Luciano Coelho4b9d2362012-05-10 12:13:59 +03001250 if (!strcmp(board_type_param, "fpga")) {
Arik Nemtsov05057c02012-05-10 12:13:48 +03001251 priv->board_type = BOARD_TYPE_FPGA_18XX;
1252 } else if (!strcmp(board_type_param, "hdk")) {
1253 priv->board_type = BOARD_TYPE_HDK_18XX;
Luciano Coelho0a1569f2012-05-10 12:13:51 +03001254 /* HACK! Just for now we hardcode HDK to 0x06 */
1255 priv->conf.phy.low_band_component_type = 0x06;
Arik Nemtsov05057c02012-05-10 12:13:48 +03001256 } else if (!strcmp(board_type_param, "dvp")) {
1257 priv->board_type = BOARD_TYPE_DVP_18XX;
1258 } else if (!strcmp(board_type_param, "evb")) {
1259 priv->board_type = BOARD_TYPE_EVB_18XX;
1260 } else if (!strcmp(board_type_param, "com8")) {
1261 priv->board_type = BOARD_TYPE_COM8_18XX;
Luciano Coelho73d8a422012-05-10 12:14:01 +03001262 /* HACK! Just for now we hardcode COM8 to 0x06 */
1263 priv->conf.phy.low_band_component_type = 0x06;
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001264 } else {
Arik Nemtsov05057c02012-05-10 12:13:48 +03001265 wl1271_error("invalid board type '%s'", board_type_param);
Luciano Coelho83342712012-05-10 12:14:15 +03001266 goto out_free;
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001267 }
1268
Luciano Coelho858403a2012-05-10 12:14:17 +03001269 /*
1270 * If the module param is not set, update it with the one from
1271 * conf. If it is set, overwrite conf with it.
1272 */
1273 if (low_band_component == -1)
1274 low_band_component = priv->conf.phy.low_band_component;
1275 else
1276 priv->conf.phy.low_band_component = low_band_component;
1277 if (low_band_component_type == -1)
1278 low_band_component_type =
1279 priv->conf.phy.low_band_component_type;
1280 else
1281 priv->conf.phy.low_band_component_type =
1282 low_band_component_type;
1283
1284 if (high_band_component == -1)
1285 high_band_component = priv->conf.phy.high_band_component;
1286 else
1287 priv->conf.phy.high_band_component = high_band_component;
1288 if (high_band_component_type == -1)
1289 high_band_component_type =
1290 priv->conf.phy.high_band_component_type;
1291 else
1292 priv->conf.phy.high_band_component_type =
1293 high_band_component_type;
1294
Luciano Coelho7b03c302012-05-10 12:14:18 +03001295 if (pwr_limit_reference_11_abg == -1)
1296 pwr_limit_reference_11_abg =
1297 priv->conf.phy.pwr_limit_reference_11_abg;
1298 else
1299 priv->conf.phy.pwr_limit_reference_11_abg =
1300 pwr_limit_reference_11_abg;
1301
Luciano Coelho102165c2012-05-10 12:13:53 +03001302 if (!checksum_param) {
1303 wl18xx_ops.set_rx_csum = NULL;
1304 wl18xx_ops.init_vif = NULL;
1305 }
1306
Luciano Coelho1ddbc7d2012-05-10 12:13:56 +03001307 wl->enable_11a = enable_11a_param;
1308
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001309 return wlcore_probe(wl, pdev);
Luciano Coelho83342712012-05-10 12:14:15 +03001310
1311out_free:
1312 wlcore_free_hw(wl);
1313 return -EINVAL;
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001314}
1315
1316static const struct platform_device_id wl18xx_id_table[] __devinitconst = {
1317 { "wl18xx", 0 },
1318 { } /* Terminating Entry */
1319};
1320MODULE_DEVICE_TABLE(platform, wl18xx_id_table);
1321
1322static struct platform_driver wl18xx_driver = {
1323 .probe = wl18xx_probe,
1324 .remove = __devexit_p(wlcore_remove),
1325 .id_table = wl18xx_id_table,
1326 .driver = {
1327 .name = "wl18xx_driver",
1328 .owner = THIS_MODULE,
1329 }
1330};
1331
1332static int __init wl18xx_init(void)
1333{
1334 return platform_driver_register(&wl18xx_driver);
1335}
1336module_init(wl18xx_init);
1337
1338static void __exit wl18xx_exit(void)
1339{
1340 platform_driver_unregister(&wl18xx_driver);
1341}
1342module_exit(wl18xx_exit);
1343
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001344module_param_named(ht_mode, ht_mode_param, charp, S_IRUSR);
Luciano Coelho83342712012-05-10 12:14:15 +03001345MODULE_PARM_DESC(ht_mode, "Force HT mode: wide (default), mimo or siso20");
Arik Nemtsov3a8ddb62012-05-10 12:13:36 +03001346
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001347module_param_named(board_type, board_type_param, charp, S_IRUSR);
Luciano Coelho4b9d2362012-05-10 12:13:59 +03001348MODULE_PARM_DESC(board_type, "Board type: fpga, hdk (default), evb, com8 or "
1349 "dvp");
Luciano Coelhoa9c130d2012-05-10 12:13:37 +03001350
Luciano Coelhoe9258812012-05-10 12:13:52 +03001351module_param_named(dc2dc, dc2dc_param, bool, S_IRUSR);
1352MODULE_PARM_DESC(dc2dc, "External DC2DC: boolean (defaults to false)");
1353
1354module_param_named(n_antennas_2, n_antennas_2_param, uint, S_IRUSR);
1355MODULE_PARM_DESC(n_antennas_2, "Number of installed 2.4GHz antennas: 1 (default) or 2");
1356
1357module_param_named(n_antennas_5, n_antennas_5_param, uint, S_IRUSR);
1358MODULE_PARM_DESC(n_antennas_5, "Number of installed 5GHz antennas: 1 (default) or 2");
1359
Luciano Coelho102165c2012-05-10 12:13:53 +03001360module_param_named(checksum, checksum_param, bool, S_IRUSR);
Assaf Azulay3d62eb52012-05-10 12:14:23 +03001361MODULE_PARM_DESC(checksum, "Enable TCP checksum: boolean (defaults to false)");
Luciano Coelho102165c2012-05-10 12:13:53 +03001362
Luciano Coelho1ddbc7d2012-05-10 12:13:56 +03001363module_param_named(enable_11a, enable_11a_param, bool, S_IRUSR);
1364MODULE_PARM_DESC(enable_11a, "Enable 11a (5GHz): boolean (defaults to true)");
1365
Luciano Coelho858403a2012-05-10 12:14:17 +03001366module_param(low_band_component, uint, S_IRUSR);
1367MODULE_PARM_DESC(low_band_component, "Low band component: u8 "
1368 "(default is 0x01)");
1369
1370module_param(low_band_component_type, uint, S_IRUSR);
1371MODULE_PARM_DESC(low_band_component_type, "Low band component type: u8 "
1372 "(default is 0x05 or 0x06 depending on the board_type)");
1373
1374module_param(high_band_component, uint, S_IRUSR);
1375MODULE_PARM_DESC(high_band_component, "High band component: u8, "
1376 "(default is 0x01)");
1377
1378module_param(high_band_component_type, uint, S_IRUSR);
1379MODULE_PARM_DESC(high_band_component_type, "High band component type: u8 "
1380 "(default is 0x09)");
1381
Luciano Coelho7b03c302012-05-10 12:14:18 +03001382module_param(pwr_limit_reference_11_abg, uint, S_IRUSR);
1383MODULE_PARM_DESC(pwr_limit_reference_11_abg, "Power limit reference: u8 "
1384 "(default is 0xc8)");
1385
Luciano Coelho9a1a6992012-05-10 12:13:06 +03001386MODULE_LICENSE("GPL v2");
1387MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
Luciano Coelho0cd65432012-05-10 12:13:11 +03001388MODULE_FIRMWARE(WL18XX_FW_NAME);