22 #include <linux/module.h>
27 #include "../wlcore/wlcore.h"
28 #include "../wlcore/debug.h"
29 #include "../wlcore/io.h"
30 #include "../wlcore/acx.h"
31 #include "../wlcore/tx.h"
32 #include "../wlcore/rx.h"
33 #include "../wlcore/boot.h"
43 #define WL18XX_RX_CHECKSUM_MASK 0x40
45 static char *ht_mode_param =
NULL;
46 static char *board_type_param =
NULL;
47 static bool checksum_param =
false;
48 static int num_rx_desc_param = -1;
51 static int dc2dc_param = -1;
52 static int n_antennas_2_param = -1;
53 static int n_antennas_5_param = -1;
54 static int low_band_component_param = -1;
55 static int low_band_component_type_param = -1;
56 static int high_band_component_param = -1;
57 static int high_band_component_type_param = -1;
58 static int pwr_limit_reference_11_abg_param = -1;
60 static const u8 wl18xx_rate_to_idx_2ghz[] = {
97 static const u8 wl18xx_rate_to_idx_5ghz[] = {
134 static const u8 *wl18xx_band_rate_to_idx[] = {
242 .rx_msdu_life_time = 512000,
243 .packet_detection_threshold = 0,
244 .ps_poll_timeout = 15,
247 .rx_cca_threshold = 0,
248 .irq_blk_threshold = 0xFFFF,
249 .irq_pkt_threshold = 0,
254 .tx_energy_detection = 0,
257 .short_retry_limit = 10,
258 .long_retry_limit = 10,
292 .max_tx_retries = 100,
293 .ap_aging_period = 300,
330 .tx_compl_timeout = 350,
331 .tx_compl_threshold = 10,
334 .tmpl_short_retry_limit = 10,
335 .tmpl_long_retry_limit = 10,
336 .tx_watchdog_timeout = 5000,
340 .listen_interval = 1,
342 .suspend_listen_interval = 3,
344 .bcn_filt_ie_count = 3,
359 .synch_fail_thold = 12,
360 .bss_lose_timeout = 400,
361 .beacon_rx_timeout = 10000,
362 .broadcast_timeout = 20000,
363 .rx_broadcast_in_ps = 1,
364 .ps_poll_threshold = 10,
366 .bet_max_consecutive = 50,
367 .psm_entry_retries = 8,
368 .psm_exit_retries = 16,
369 .psm_entry_nullfunc_retries = 3,
370 .dynamic_ps_timeout = 1500,
372 .keep_alive_interval = 55000,
373 .max_listen_interval = 20,
381 .host_clk_settling_time = 5000,
386 .avg_weight_rssi_beacon = 20,
387 .avg_weight_rssi_data = 10,
388 .avg_weight_snr_beacon = 20,
389 .avg_weight_snr_data = 10,
392 .min_dwell_time_active = 7500,
393 .max_dwell_time_active = 30000,
394 .min_dwell_time_passive = 100000,
395 .max_dwell_time_passive = 100000,
397 .split_scan_timeout = 50000,
404 .base_dwell_time = 7500,
405 .max_dwell_time_delta = 22500,
407 .dwell_time_delta_per_probe = 2000,
409 .dwell_time_delta_per_probe_5 = 350,
410 .dwell_time_passive = 100000,
411 .dwell_time_dfs = 150000,
413 .rssi_threshold = -90,
417 .rx_ba_win_size = 32,
418 .tx_ba_win_size = 64,
419 .inactivity_timeout = 10000,
426 .tx_min_block_num = 40,
428 .min_req_tx_blocks = 45,
429 .min_req_rx_blocks = 22,
435 .n_divider_fref_set_1 = 0xff,
436 .n_divider_fref_set_2 = 12,
437 .m_divider_fref_set_1 = 0xffff,
438 .m_divider_fref_set_2 = 148,
439 .coex_pll_stabilization_time = 0xffffffff,
440 .ldo_stabilization_time = 0xffff,
441 .fm_disturbed_band_margin = 0xff,
442 .swallow_clk_diff = 0xff,
459 .rate_retry_score = 32000,
464 .inverse_curiosity_factor = 5,
466 .tx_fail_high_th = 10,
467 .per_alpha_shift = 4,
469 .per_beta1_shift = 10,
470 .per_beta2_shift = 8,
472 .rate_check_down = 12,
473 .rate_retry_policy = {
474 0x00, 0x00, 0x00, 0x00, 0x00,
475 0x00, 0x00, 0x00, 0x00, 0x00,
481 .hangover_period = 20,
483 .early_termination_mode = 1,
499 .phy_standalone = 0x00,
500 .primary_clock_setting_time = 0x05,
501 .clock_valid_on_wake_up = 0x00,
502 .secondary_clock_setting_time = 0x05,
508 .low_band_component_type = 0x04,
510 .high_band_component_type = 0x09,
511 .tcxo_ldo_voltage = 0x00,
512 .xtal_itrim_val = 0x04,
514 .io_configuration = 0x01,
515 .sdio_configuration = 0x00,
518 .enable_tx_low_pwr_on_siso_rdl = 0x00,
520 .pwr_limit_reference_11_abg = 0xc8,
522 .low_power_val = 0x00,
523 .med_power_val = 0x0a,
524 .high_power_val = 0x1e,
525 .external_pa_dc2dc = 0,
526 .number_of_assembled_ant2_4 = 1,
527 .number_of_assembled_ant5 = 1,
533 .mem = { .start = 0x00A02000, .size = 0x00010000 },
534 .reg = { .start = 0x00807000, .size = 0x00005000 },
535 .mem2 = { .start = 0x00800000, .size = 0x0000B000 },
536 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
539 .mem = { .start = 0x00000000, .size = 0x00014000 },
540 .reg = { .start = 0x00810000, .size = 0x0000BFFF },
541 .mem2 = { .start = 0x00000000, .size = 0x00000000 },
542 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
545 .mem = { .start = 0x00700000, .size = 0x0000030c },
546 .reg = { .start = 0x00802000, .size = 0x00014578 },
547 .mem2 = { .start = 0x00B00404, .size = 0x00001000 },
548 .mem3 = { .start = 0x00C00000, .size = 0x00000400 },
551 .mem = { .start = 0x00800000, .size = 0x000050FC },
552 .reg = { .start = 0x00B00404, .size = 0x00001000 },
553 .mem2 = { .start = 0x00C00000, .size = 0x00000400 },
554 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
557 .mem = { .start = 0x80926000,
559 .
reg = { .start = 0x00000000, .size = 0x00000000 },
560 .mem2 = { .start = 0x00000000, .size = 0x00000000 },
561 .mem3 = { .start = 0x00000000, .size = 0x00000000 },
598 #define WL18XX_FW_NAME "ti-connectivity/wl18xx-fw.bin"
600 static int wl18xx_identify_chip(
struct wl1271 *wl)
604 switch (wl->
chip.id) {
637 static int wl18xx_set_clk(
struct wl1271 *wl)
653 wl18xx_clk_table[clk_freq].
n, wl18xx_clk_table[clk_freq].
m,
654 wl18xx_clk_table[clk_freq].
p, wl18xx_clk_table[clk_freq].
q,
655 wl18xx_clk_table[clk_freq].
swallow ?
"swallow" :
"spit");
658 wl18xx_clk_table[clk_freq].
n);
663 wl18xx_clk_table[clk_freq].
m);
667 if (wl18xx_clk_table[clk_freq].
swallow) {
670 wl18xx_clk_table[clk_freq].
q &
677 (wl18xx_clk_table[clk_freq].
q >> 16) &
684 wl18xx_clk_table[clk_freq].
p &
691 (wl18xx_clk_table[clk_freq].
p >> 16) &
702 static int wl18xx_boot_soft_reset(
struct wl1271 *wl)
718 static int wl18xx_pre_boot(
struct wl1271 *wl)
722 ret = wl18xx_set_clk(wl);
742 ret = wl18xx_boot_soft_reset(wl);
748 static int wl18xx_pre_upload(
struct wl1271 *wl)
774 static int wl18xx_set_mac_and_phy(
struct wl1271 *wl)
791 sizeof(*params),
false);
798 static int wl18xx_enable_interrupts(
struct wl1271 *wl)
815 goto disable_interrupts;
826 static int wl18xx_boot(
struct wl1271 *wl)
830 ret = wl18xx_pre_boot(wl);
834 ret = wl18xx_pre_upload(wl);
842 ret = wl18xx_set_mac_and_phy(wl);
850 ret = wl18xx_enable_interrupts(wl);
856 static int wl18xx_trigger_cmd(
struct wl1271 *wl,
int cmd_box_addr,
857 void *
buf,
size_t len)
864 return wlcore_write(wl, cmd_box_addr, priv->
cmd_buf,
868 static int wl18xx_ack_event(
struct wl1271 *wl)
874 static u32 wl18xx_calc_tx_blocks(
struct wl1271 *wl,
u32 len,
u32 spare_blks)
877 return (len + blk_size - 1) / blk_size + spare_blks;
900 "len: %d life: %d mem: %d", desc->
hlid,
915 static u32 wl18xx_get_rx_packet_len(
struct wl1271 *wl,
void *rx_data,
921 if (data_len <
sizeof(*desc))
924 return data_len -
sizeof(*desc);
927 static void wl18xx_tx_immediate_completion(
struct wl1271 *wl)
932 static int wl18xx_set_host_cfg_bitmap(
struct wl1271 *wl,
u32 extra_mem_blk)
952 sdio_align_size, extra_mem_blk,
960 static int wl18xx_hw_init(
struct wl1271 *wl)
974 if (checksum_param) {
983 static void wl18xx_set_tx_desc_csum(
struct wl1271 *wl,
988 struct iphdr *ip_hdr;
990 if (!checksum_param) {
1000 ip_hdr_offset = skb_network_header(skb) - skb_mac_header(skb);
1001 if (
WARN_ON(ip_hdr_offset >= (1<<7))) {
1009 ip_hdr = (
void *)skb_network_header(skb);
1013 static void wl18xx_set_rx_csum(
struct wl1271 *wl,
1021 static bool wl18xx_is_mimo_supported(
struct wl1271 *wl)
1025 return priv->
conf.phy.number_of_assembled_ant2_4 >= 2;
1032 static u32 wl18xx_sta_get_ap_rate_mask(
struct wl1271 *wl,
1044 }
else if (wl18xx_is_mimo_supported(wl)) {
1052 static u32 wl18xx_ap_get_mimo_wide_rate_mask(
struct wl1271 *wl,
1064 }
else if (wl18xx_is_mimo_supported(wl) &&
1077 static int wl18xx_get_pg_ver(
struct wl1271 *wl,
s8 *
ver)
1099 #define WL18XX_CONF_FILE_NAME "ti-connectivity/wl18xx-conf.bin"
1109 wl1271_error(
"could not get configuration binary %s: %d",
1115 wl1271_error(
"configuration binary file size is wrong, expected %zu got %zu",
1124 wl1271_error(
"configuration binary file magic number mismatch, "
1126 conf_file->
header.magic);
1132 wl1271_error(
"configuration binary file version not supported, "
1133 "expected 0x%08x got 0x%08x",
1148 memcpy(&wl->
conf, &wl18xx_conf,
sizeof(wl18xx_conf));
1150 memcpy(&priv->
conf, &wl18xx_default_priv_conf,
sizeof(priv->
conf));
1160 static int wl18xx_plt_init(
struct wl1271 *wl)
1166 wl1271_error(
"wl18xx_plt_init: PLT FEM_DETECT not supported");
1174 return wl->
ops->boot(wl);
1177 static int wl18xx_get_mac(
struct wl1271 *wl)
1196 ((mac1 & 0xff000000) >> 24);
1205 static int wl18xx_handle_static_data(
struct wl1271 *wl,
1212 sizeof(wl->
chip.phy_fw_ver_str));
1215 wl->
chip.phy_fw_ver_str[
sizeof(wl->
chip.phy_fw_ver_str) - 1] =
'\0';
1222 static int wl18xx_get_spare_blocks(
struct wl1271 *wl,
bool is_gem)
1239 bool change_spare =
false;
1261 ret = wl18xx_set_host_cfg_bitmap(wl,
1268 ret = wl18xx_set_host_cfg_bitmap(wl,
1280 static u32 wl18xx_pre_pkt_send(
struct wl1271 *wl,
1281 u32 buf_offset,
u32 last_len)
1288 buf_offset - last_len);
1299 static int wl18xx_setup(
struct wl1271 *wl);
1302 .setup = wl18xx_setup,
1303 .identify_chip = wl18xx_identify_chip,
1304 .boot = wl18xx_boot,
1305 .plt_init = wl18xx_plt_init,
1306 .trigger_cmd = wl18xx_trigger_cmd,
1307 .ack_event = wl18xx_ack_event,
1308 .calc_tx_blocks = wl18xx_calc_tx_blocks,
1309 .set_tx_desc_blocks = wl18xx_set_tx_desc_blocks,
1310 .set_tx_desc_data_len = wl18xx_set_tx_desc_data_len,
1311 .get_rx_buf_align = wl18xx_get_rx_buf_align,
1312 .get_rx_packet_len = wl18xx_get_rx_packet_len,
1313 .tx_immediate_compl = wl18xx_tx_immediate_completion,
1314 .tx_delayed_compl =
NULL,
1315 .hw_init = wl18xx_hw_init,
1316 .set_tx_desc_csum = wl18xx_set_tx_desc_csum,
1317 .get_pg_ver = wl18xx_get_pg_ver,
1318 .set_rx_csum = wl18xx_set_rx_csum,
1319 .sta_get_ap_rate_mask = wl18xx_sta_get_ap_rate_mask,
1320 .ap_get_mimo_wide_rate_mask = wl18xx_ap_get_mimo_wide_rate_mask,
1321 .get_mac = wl18xx_get_mac,
1323 .handle_static_data = wl18xx_handle_static_data,
1324 .get_spare_blocks = wl18xx_get_spare_blocks,
1325 .set_key = wl18xx_set_key,
1326 .pre_pkt_send = wl18xx_pre_pkt_send,
1333 .ht_supported =
true,
1337 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1347 .ht_supported =
true,
1351 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1360 .ht_supported =
true,
1364 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1373 .ht_supported =
true,
1377 .rx_mask = { 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, },
1383 static int wl18xx_setup(
struct wl1271 *wl)
1388 wl->
rtable = wl18xx_rtable;
1399 if (num_rx_desc_param != -1)
1402 ret = wl18xx_conf_init(wl, wl->
dev);
1407 if (board_type_param) {
1408 if (!
strcmp(board_type_param,
"fpga")) {
1410 }
else if (!
strcmp(board_type_param,
"hdk")) {
1412 }
else if (!
strcmp(board_type_param,
"dvp")) {
1414 }
else if (!
strcmp(board_type_param,
"evb")) {
1416 }
else if (!
strcmp(board_type_param,
"com8")) {
1427 priv->
conf.phy.board_type);
1431 if (low_band_component_param != -1)
1432 priv->
conf.phy.low_band_component = low_band_component_param;
1433 if (low_band_component_type_param != -1)
1434 priv->
conf.phy.low_band_component_type =
1435 low_band_component_type_param;
1436 if (high_band_component_param != -1)
1437 priv->
conf.phy.high_band_component = high_band_component_param;
1438 if (high_band_component_type_param != -1)
1439 priv->
conf.phy.high_band_component_type =
1440 high_band_component_type_param;
1441 if (pwr_limit_reference_11_abg_param != -1)
1442 priv->
conf.phy.pwr_limit_reference_11_abg =
1443 pwr_limit_reference_11_abg_param;
1444 if (n_antennas_2_param != -1)
1445 priv->
conf.phy.number_of_assembled_ant2_4 = n_antennas_2_param;
1446 if (n_antennas_5_param != -1)
1447 priv->
conf.phy.number_of_assembled_ant5 = n_antennas_5_param;
1448 if (dc2dc_param != -1)
1449 priv->
conf.phy.external_pa_dc2dc = dc2dc_param;
1451 if (ht_mode_param) {
1452 if (!
strcmp(ht_mode_param,
"default"))
1454 else if (!
strcmp(ht_mode_param,
"wide"))
1456 else if (!
strcmp(ht_mode_param,
"siso20"))
1469 if (wl18xx_is_mimo_supported(wl))
1471 &wl18xx_mimo_ht_cap_2ghz);
1474 &wl18xx_siso40_ht_cap_2ghz);
1478 &wl18xx_siso40_ht_cap_5ghz);
1481 &wl18xx_siso40_ht_cap_2ghz);
1483 &wl18xx_siso40_ht_cap_5ghz);
1486 &wl18xx_siso20_ht_cap);
1488 &wl18xx_siso20_ht_cap);
1491 if (!checksum_param) {
1517 wl->
ops = &wl18xx_ops;
1518 wl->
ptable = wl18xx_ptable;
1538 .probe = wl18xx_probe,
1540 .id_table = wl18xx_id_table,
1542 .name =
"wl18xx_driver",
1563 "Number of installed 2.4GHz antennas: 1 (default) or 2");
1567 "Number of installed 5GHz antennas: 1 (default) or 2");
1572 "(default is 0x01)");
1577 "(default is 0x05 or 0x06 depending on the board_type)");
1582 "(default is 0x01)");
1587 "(default is 0x09)");
1590 pwr_limit_reference_11_abg_param,
int,
S_IRUSR);
1592 "(default is 0xc8)");
1595 num_rx_desc_param,
int,
S_IRUSR);
1597 "Number of Rx descriptors: u8 (default is 32)");