22 #include <linux/module.h>
29 #include "../wlcore/wlcore.h"
30 #include "../wlcore/debug.h"
31 #include "../wlcore/io.h"
32 #include "../wlcore/acx.h"
33 #include "../wlcore/tx.h"
34 #include "../wlcore/rx.h"
35 #include "../wlcore/boot.h"
43 static char *fref_param;
44 static char *tcxo_param;
116 .rx_msdu_life_time = 512000,
117 .packet_detection_threshold = 0,
118 .ps_poll_timeout = 15,
121 .rx_cca_threshold = 0,
122 .irq_blk_threshold = 0xFFFF,
123 .irq_pkt_threshold = 0,
128 .tx_energy_detection = 0,
131 .short_retry_limit = 10,
132 .long_retry_limit = 10,
166 .max_tx_retries = 100,
167 .ap_aging_period = 300,
204 .tx_compl_timeout = 700,
205 .tx_compl_threshold = 4,
208 .tmpl_short_retry_limit = 10,
209 .tmpl_long_retry_limit = 10,
210 .tx_watchdog_timeout = 5000,
214 .listen_interval = 1,
216 .suspend_listen_interval = 3,
218 .bcn_filt_ie_count = 3,
233 .synch_fail_thold = 12,
234 .bss_lose_timeout = 400,
235 .beacon_rx_timeout = 10000,
236 .broadcast_timeout = 20000,
237 .rx_broadcast_in_ps = 1,
238 .ps_poll_threshold = 10,
240 .bet_max_consecutive = 50,
241 .psm_entry_retries = 8,
242 .psm_exit_retries = 16,
243 .psm_entry_nullfunc_retries = 3,
244 .dynamic_ps_timeout = 1500,
246 .keep_alive_interval = 55000,
247 .max_listen_interval = 20,
255 .host_clk_settling_time = 5000,
260 .avg_weight_rssi_beacon = 20,
261 .avg_weight_rssi_data = 10,
262 .avg_weight_snr_beacon = 20,
263 .avg_weight_snr_data = 10,
266 .min_dwell_time_active = 7500,
267 .max_dwell_time_active = 30000,
268 .min_dwell_time_passive = 100000,
269 .max_dwell_time_passive = 100000,
271 .split_scan_timeout = 50000,
278 .base_dwell_time = 7500,
279 .max_dwell_time_delta = 22500,
281 .dwell_time_delta_per_probe = 2000,
283 .dwell_time_delta_per_probe_5 = 350,
284 .dwell_time_passive = 100000,
285 .dwell_time_dfs = 150000,
287 .rssi_threshold = -90,
292 .tx_ba_win_size = 64,
293 .inactivity_timeout = 10000,
305 .tx_min_block_num = 40,
307 .min_req_tx_blocks = 45,
308 .min_req_rx_blocks = 22,
314 .n_divider_fref_set_1 = 0xff,
315 .n_divider_fref_set_2 = 12,
316 .m_divider_fref_set_1 = 0xffff,
317 .m_divider_fref_set_2 = 148,
318 .coex_pll_stabilization_time = 0xffffffff,
319 .ldo_stabilization_time = 0xffff,
320 .fm_disturbed_band_margin = 0xff,
321 .swallow_clk_diff = 0xff,
338 .rate_retry_score = 32000,
343 .inverse_curiosity_factor = 5,
345 .tx_fail_high_th = 10,
346 .per_alpha_shift = 4,
348 .per_beta1_shift = 10,
349 .per_beta2_shift = 8,
351 .rate_check_down = 12,
352 .rate_retry_policy = {
353 0x00, 0x00, 0x00, 0x00, 0x00,
354 0x00, 0x00, 0x00, 0x00, 0x00,
360 .hangover_period = 20,
362 .early_termination_mode = 1,
375 .tx_per_channel_power_compensation_2 = {
376 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
378 .tx_per_channel_power_compensation_5 = {
379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
380 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
381 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
388 .tx_min_block_num = 40,
390 .min_req_tx_blocks = 100,
391 .min_req_rx_blocks = 22,
397 #define WL12XX_TX_HW_BLOCK_SPARE_DEFAULT 1
398 #define WL12XX_TX_HW_BLOCK_GEM_SPARE 2
399 #define WL12XX_TX_HW_BLOCK_SIZE 252
401 static const u8 wl12xx_rate_to_idx_2ghz[] = {
431 static const u8 wl12xx_rate_to_idx_5ghz[] = {
458 CONF_HW_RXTX_RATE_UNSUPPORTED
461 static const u8 *wl12xx_band_rate_to_idx[] = {
592 #define WL127X_FW_NAME_MULTI "ti-connectivity/wl127x-fw-5-mr.bin"
593 #define WL127X_FW_NAME_SINGLE "ti-connectivity/wl127x-fw-5-sr.bin"
594 #define WL127X_PLT_FW_NAME "ti-connectivity/wl127x-fw-5-plt.bin"
596 #define WL128X_FW_NAME_MULTI "ti-connectivity/wl128x-fw-5-mr.bin"
597 #define WL128X_FW_NAME_SINGLE "ti-connectivity/wl128x-fw-5-sr.bin"
598 #define WL128X_PLT_FW_NAME "ti-connectivity/wl128x-fw-5-plt.bin"
615 rx_mem_addr.
addr = (mem_block << 8) +
621 sizeof(rx_mem_addr),
false);
629 static int wl12xx_identify_chip(
struct wl1271 *wl)
633 switch (wl->
chip.id) {
644 sizeof(wl->
conf.mem));
647 wl->
ops->prepare_read = wl127x_prepare_read;
665 sizeof(wl->
conf.mem));
668 wl->
ops->prepare_read = wl127x_prepare_read;
708 addr = (addr >> 1) + 0x30000;
735 addr = (addr >> 1) + 0x30000;
769 static int wl128x_switch_tcxo_to_fref(
struct wl1271 *wl)
775 ret = wl12xx_top_reg_read(wl,
WL_SPARE_REG, &spare_reg);
779 if (spare_reg == 0xFFFF)
782 ret = wl12xx_top_reg_write(wl,
WL_SPARE_REG, spare_reg);
798 static bool wl128x_is_tcxo_valid(
struct wl1271 *wl)
813 static bool wl128x_is_fref_valid(
struct wl1271 *wl)
828 static int wl128x_manually_configure_mcs_pll(
struct wl1271 *wl)
847 static int wl128x_configure_mcs_pll(
struct wl1271 *wl,
int clk)
856 ret = wl12xx_top_reg_read(wl,
WL_SPARE_REG, &spare_reg);
860 if (spare_reg == 0xFFFF)
863 ret = wl12xx_top_reg_write(wl,
WL_SPARE_REG, spare_reg);
870 return wl128x_manually_configure_mcs_pll(wl);
873 input_freq = (clk & 1) + 1;
879 if (pll_config == 0xFFFF)
895 static int wl128x_boot_clk(
struct wl1271 *wl,
int *selected_clock)
904 if (!wl128x_switch_tcxo_to_fref(wl))
914 if (sys_clk_cfg == 0xFFFF)
922 if (!wl128x_switch_tcxo_to_fref(wl))
928 if (!wl128x_is_tcxo_valid(wl))
935 if (!wl128x_is_fref_valid(wl))
940 return wl128x_configure_mcs_pll(wl, *selected_clock);
943 static int wl127x_boot_clk(
struct wl1271 *wl)
1019 static int wl1271_boot_soft_reset(
struct wl1271 *wl)
1021 unsigned long timeout;
1063 static int wl12xx_pre_boot(
struct wl1271 *wl)
1068 int selected_clock = -1;
1071 ret = wl128x_boot_clk(wl, &selected_clock);
1075 ret = wl127x_boot_clk(wl);
1102 clk |= ((selected_clock & 0x3) << 1) << 4;
1119 ret = wl1271_boot_soft_reset(wl);
1127 static int wl12xx_pre_upload(
struct wl1271 *wl)
1174 static int wl12xx_enable_interrupts(
struct wl1271 *wl)
1187 goto disable_interrupts;
1191 goto disable_interrupts;
1202 static int wl12xx_boot(
struct wl1271 *wl)
1206 ret = wl12xx_pre_boot(wl);
1214 ret = wl12xx_pre_upload(wl);
1226 ret = wl12xx_enable_interrupts(wl);
1232 static int wl12xx_trigger_cmd(
struct wl1271 *wl,
int cmd_box_addr,
1233 void *
buf,
size_t len)
1237 ret = wlcore_write(wl, cmd_box_addr, buf, len,
false);
1246 static int wl12xx_ack_event(
struct wl1271 *wl)
1252 static u32 wl12xx_calc_tx_blocks(
struct wl1271 *wl,
u32 len,
u32 spare_blks)
1257 return (align_len + blk_size - 1) / blk_size + spare_blks;
1262 u32 blks,
u32 spare_blks)
1283 "tx_fill_hdr: hlid: %d len: %d life: %d mem: %d extra: %d",
1291 int pad = aligned_len - skb->
len;
1299 "tx_fill_hdr: pad: %d hlid: %d len: %d life: %d mem: %d",
1316 static u32 wl12xx_get_rx_packet_len(
struct wl1271 *wl,
void *rx_data,
1322 if (data_len <
sizeof(*desc) ||
1323 data_len <
sizeof(*desc) + desc->
pad_len)
1326 return data_len -
sizeof(*desc) - desc->
pad_len;
1329 static int wl12xx_tx_delayed_compl(
struct wl1271 *wl)
1338 static int wl12xx_hw_init(
struct wl1271 *wl)
1391 static u32 wl12xx_sta_get_ap_rate_mask(
struct wl1271 *wl,
1397 static int wl12xx_identify_fw(
struct wl1271 *wl)
1399 unsigned int *fw_ver = wl->
chip.fw_ver;
1413 static void wl12xx_conf_init(
struct wl1271 *wl)
1418 memcpy(&wl->
conf, &wl12xx_conf,
sizeof(wl12xx_conf));
1421 memcpy(&priv->
conf, &wl12xx_default_priv_conf,
sizeof(priv->
conf));
1424 static bool wl12xx_mac_in_fuse(
struct wl1271 *wl)
1426 bool supported =
false;
1434 if (major > 2 || (major == 2 && minor >= 1))
1441 if (major == 3 && minor >= 1)
1446 "PG Ver major = %d minor = %d, MAC %s present",
1447 major, minor, supported ?
"is" :
"is not");
1452 static int wl12xx_get_fuse_mac(
struct wl1271 *wl)
1471 ((mac1 & 0xff000000) >> 24);
1480 static int wl12xx_get_pg_ver(
struct wl1271 *wl,
s8 *
ver)
1492 if (ret >= 0 && ver)
1498 static int wl12xx_get_mac(
struct wl1271 *wl)
1500 if (wl12xx_mac_in_fuse(wl))
1501 return wl12xx_get_fuse_mac(wl);
1506 static void wl12xx_set_tx_desc_csum(
struct wl1271 *wl,
1513 static int wl12xx_plt_init(
struct wl1271 *wl)
1517 ret = wl->
ops->boot(wl);
1521 ret = wl->
ops->hw_init(wl);
1523 goto out_irq_disable;
1534 goto out_irq_disable;
1538 goto out_free_memmap;
1543 goto out_free_memmap;
1548 goto out_free_memmap;
1553 goto out_free_memmap;
1576 static int wl12xx_get_spare_blocks(
struct wl1271 *wl,
bool is_gem)
1592 static int wl12xx_setup(
struct wl1271 *wl);
1595 .setup = wl12xx_setup,
1596 .identify_chip = wl12xx_identify_chip,
1597 .identify_fw = wl12xx_identify_fw,
1598 .boot = wl12xx_boot,
1599 .plt_init = wl12xx_plt_init,
1600 .trigger_cmd = wl12xx_trigger_cmd,
1601 .ack_event = wl12xx_ack_event,
1602 .calc_tx_blocks = wl12xx_calc_tx_blocks,
1603 .set_tx_desc_blocks = wl12xx_set_tx_desc_blocks,
1604 .set_tx_desc_data_len = wl12xx_set_tx_desc_data_len,
1605 .get_rx_buf_align = wl12xx_get_rx_buf_align,
1606 .get_rx_packet_len = wl12xx_get_rx_packet_len,
1607 .tx_immediate_compl =
NULL,
1608 .tx_delayed_compl = wl12xx_tx_delayed_compl,
1609 .hw_init = wl12xx_hw_init,
1611 .sta_get_ap_rate_mask = wl12xx_sta_get_ap_rate_mask,
1612 .get_pg_ver = wl12xx_get_pg_ver,
1613 .get_mac = wl12xx_get_mac,
1614 .set_tx_desc_csum = wl12xx_set_tx_desc_csum,
1615 .set_rx_csum =
NULL,
1616 .ap_get_mimo_wide_rate_mask =
NULL,
1618 .get_spare_blocks = wl12xx_get_spare_blocks,
1619 .set_key = wl12xx_set_key,
1620 .pre_pkt_send =
NULL,
1630 .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
1636 static int wl12xx_setup(
struct wl1271 *wl)
1641 wl->
rtable = wl12xx_rtable;
1652 wl12xx_conf_init(wl);
1657 if (!
strcmp(fref_param,
"19.2"))
1659 else if (!
strcmp(fref_param,
"26"))
1661 else if (!
strcmp(fref_param,
"26x"))
1663 else if (!
strcmp(fref_param,
"38.4"))
1665 else if (!
strcmp(fref_param,
"38.4x"))
1667 else if (!
strcmp(fref_param,
"52"))
1676 if (!
strcmp(tcxo_param,
"19.2"))
1678 else if (!
strcmp(tcxo_param,
"26"))
1680 else if (!
strcmp(tcxo_param,
"38.4"))
1682 else if (!
strcmp(tcxo_param,
"52"))
1684 else if (!
strcmp(tcxo_param,
"16.368"))
1686 else if (!
strcmp(tcxo_param,
"32.736"))
1688 else if (!
strcmp(tcxo_param,
"16.8"))
1690 else if (!
strcmp(tcxo_param,
"33.6"))
1714 wl->
ops = &wl12xx_ops;
1715 wl->
ptable = wl12xx_ptable;
1735 .probe = wl12xx_probe,
1737 .id_table = wl12xx_id_table,
1739 .name =
"wl12xx_driver",
1751 "TCXO clock: 19.2, 26, 38.4, 52, 16.368, 32.736, 16.8, 33.6");