main.c 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108
  1. /*
  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. #include <linux/module.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/ip.h>
  24. #include "../wlcore/wlcore.h"
  25. #include "../wlcore/debug.h"
  26. #include "../wlcore/io.h"
  27. #include "../wlcore/acx.h"
  28. #include "../wlcore/tx.h"
  29. #include "../wlcore/rx.h"
  30. #include "../wlcore/io.h"
  31. #include "../wlcore/boot.h"
  32. #include "reg.h"
  33. #include "conf.h"
  34. #include "acx.h"
  35. #include "tx.h"
  36. #include "wl18xx.h"
  37. #include "io.h"
  38. #define WL18XX_RX_CHECKSUM_MASK 0x40
  39. static char *ht_mode_param;
  40. static char *board_type_param;
  41. static const u8 wl18xx_rate_to_idx_2ghz[] = {
  42. /* MCS rates are used only with 11n */
  43. 15, /* WL18XX_CONF_HW_RXTX_RATE_MCS15 */
  44. 14, /* WL18XX_CONF_HW_RXTX_RATE_MCS14 */
  45. 13, /* WL18XX_CONF_HW_RXTX_RATE_MCS13 */
  46. 12, /* WL18XX_CONF_HW_RXTX_RATE_MCS12 */
  47. 11, /* WL18XX_CONF_HW_RXTX_RATE_MCS11 */
  48. 10, /* WL18XX_CONF_HW_RXTX_RATE_MCS10 */
  49. 9, /* WL18XX_CONF_HW_RXTX_RATE_MCS9 */
  50. 8, /* WL18XX_CONF_HW_RXTX_RATE_MCS8 */
  51. 7, /* WL18XX_CONF_HW_RXTX_RATE_MCS7 */
  52. 6, /* WL18XX_CONF_HW_RXTX_RATE_MCS6 */
  53. 5, /* WL18XX_CONF_HW_RXTX_RATE_MCS5 */
  54. 4, /* WL18XX_CONF_HW_RXTX_RATE_MCS4 */
  55. 3, /* WL18XX_CONF_HW_RXTX_RATE_MCS3 */
  56. 2, /* WL18XX_CONF_HW_RXTX_RATE_MCS2 */
  57. 1, /* WL18XX_CONF_HW_RXTX_RATE_MCS1 */
  58. 0, /* WL18XX_CONF_HW_RXTX_RATE_MCS0 */
  59. 11, /* WL18XX_CONF_HW_RXTX_RATE_54 */
  60. 10, /* WL18XX_CONF_HW_RXTX_RATE_48 */
  61. 9, /* WL18XX_CONF_HW_RXTX_RATE_36 */
  62. 8, /* WL18XX_CONF_HW_RXTX_RATE_24 */
  63. /* TI-specific rate */
  64. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_22 */
  65. 7, /* WL18XX_CONF_HW_RXTX_RATE_18 */
  66. 6, /* WL18XX_CONF_HW_RXTX_RATE_12 */
  67. 3, /* WL18XX_CONF_HW_RXTX_RATE_11 */
  68. 5, /* WL18XX_CONF_HW_RXTX_RATE_9 */
  69. 4, /* WL18XX_CONF_HW_RXTX_RATE_6 */
  70. 2, /* WL18XX_CONF_HW_RXTX_RATE_5_5 */
  71. 1, /* WL18XX_CONF_HW_RXTX_RATE_2 */
  72. 0 /* WL18XX_CONF_HW_RXTX_RATE_1 */
  73. };
  74. static const u8 wl18xx_rate_to_idx_5ghz[] = {
  75. /* MCS rates are used only with 11n */
  76. 15, /* WL18XX_CONF_HW_RXTX_RATE_MCS15 */
  77. 14, /* WL18XX_CONF_HW_RXTX_RATE_MCS14 */
  78. 13, /* WL18XX_CONF_HW_RXTX_RATE_MCS13 */
  79. 12, /* WL18XX_CONF_HW_RXTX_RATE_MCS12 */
  80. 11, /* WL18XX_CONF_HW_RXTX_RATE_MCS11 */
  81. 10, /* WL18XX_CONF_HW_RXTX_RATE_MCS10 */
  82. 9, /* WL18XX_CONF_HW_RXTX_RATE_MCS9 */
  83. 8, /* WL18XX_CONF_HW_RXTX_RATE_MCS8 */
  84. 7, /* WL18XX_CONF_HW_RXTX_RATE_MCS7 */
  85. 6, /* WL18XX_CONF_HW_RXTX_RATE_MCS6 */
  86. 5, /* WL18XX_CONF_HW_RXTX_RATE_MCS5 */
  87. 4, /* WL18XX_CONF_HW_RXTX_RATE_MCS4 */
  88. 3, /* WL18XX_CONF_HW_RXTX_RATE_MCS3 */
  89. 2, /* WL18XX_CONF_HW_RXTX_RATE_MCS2 */
  90. 1, /* WL18XX_CONF_HW_RXTX_RATE_MCS1 */
  91. 0, /* WL18XX_CONF_HW_RXTX_RATE_MCS0 */
  92. 7, /* WL18XX_CONF_HW_RXTX_RATE_54 */
  93. 6, /* WL18XX_CONF_HW_RXTX_RATE_48 */
  94. 5, /* WL18XX_CONF_HW_RXTX_RATE_36 */
  95. 4, /* WL18XX_CONF_HW_RXTX_RATE_24 */
  96. /* TI-specific rate */
  97. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_22 */
  98. 3, /* WL18XX_CONF_HW_RXTX_RATE_18 */
  99. 2, /* WL18XX_CONF_HW_RXTX_RATE_12 */
  100. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_11 */
  101. 1, /* WL18XX_CONF_HW_RXTX_RATE_9 */
  102. 0, /* WL18XX_CONF_HW_RXTX_RATE_6 */
  103. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_5_5 */
  104. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_2 */
  105. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_1 */
  106. };
  107. static const u8 *wl18xx_band_rate_to_idx[] = {
  108. [IEEE80211_BAND_2GHZ] = wl18xx_rate_to_idx_2ghz,
  109. [IEEE80211_BAND_5GHZ] = wl18xx_rate_to_idx_5ghz
  110. };
  111. enum wl18xx_hw_rates {
  112. WL18XX_CONF_HW_RXTX_RATE_MCS15 = 0,
  113. WL18XX_CONF_HW_RXTX_RATE_MCS14,
  114. WL18XX_CONF_HW_RXTX_RATE_MCS13,
  115. WL18XX_CONF_HW_RXTX_RATE_MCS12,
  116. WL18XX_CONF_HW_RXTX_RATE_MCS11,
  117. WL18XX_CONF_HW_RXTX_RATE_MCS10,
  118. WL18XX_CONF_HW_RXTX_RATE_MCS9,
  119. WL18XX_CONF_HW_RXTX_RATE_MCS8,
  120. WL18XX_CONF_HW_RXTX_RATE_MCS7,
  121. WL18XX_CONF_HW_RXTX_RATE_MCS6,
  122. WL18XX_CONF_HW_RXTX_RATE_MCS5,
  123. WL18XX_CONF_HW_RXTX_RATE_MCS4,
  124. WL18XX_CONF_HW_RXTX_RATE_MCS3,
  125. WL18XX_CONF_HW_RXTX_RATE_MCS2,
  126. WL18XX_CONF_HW_RXTX_RATE_MCS1,
  127. WL18XX_CONF_HW_RXTX_RATE_MCS0,
  128. WL18XX_CONF_HW_RXTX_RATE_54,
  129. WL18XX_CONF_HW_RXTX_RATE_48,
  130. WL18XX_CONF_HW_RXTX_RATE_36,
  131. WL18XX_CONF_HW_RXTX_RATE_24,
  132. WL18XX_CONF_HW_RXTX_RATE_22,
  133. WL18XX_CONF_HW_RXTX_RATE_18,
  134. WL18XX_CONF_HW_RXTX_RATE_12,
  135. WL18XX_CONF_HW_RXTX_RATE_11,
  136. WL18XX_CONF_HW_RXTX_RATE_9,
  137. WL18XX_CONF_HW_RXTX_RATE_6,
  138. WL18XX_CONF_HW_RXTX_RATE_5_5,
  139. WL18XX_CONF_HW_RXTX_RATE_2,
  140. WL18XX_CONF_HW_RXTX_RATE_1,
  141. WL18XX_CONF_HW_RXTX_RATE_MAX,
  142. };
  143. static struct wlcore_conf wl18xx_conf = {
  144. .sg = {
  145. .params = {
  146. [CONF_SG_ACL_BT_MASTER_MIN_BR] = 10,
  147. [CONF_SG_ACL_BT_MASTER_MAX_BR] = 180,
  148. [CONF_SG_ACL_BT_SLAVE_MIN_BR] = 10,
  149. [CONF_SG_ACL_BT_SLAVE_MAX_BR] = 180,
  150. [CONF_SG_ACL_BT_MASTER_MIN_EDR] = 10,
  151. [CONF_SG_ACL_BT_MASTER_MAX_EDR] = 80,
  152. [CONF_SG_ACL_BT_SLAVE_MIN_EDR] = 10,
  153. [CONF_SG_ACL_BT_SLAVE_MAX_EDR] = 80,
  154. [CONF_SG_ACL_WLAN_PS_MASTER_BR] = 8,
  155. [CONF_SG_ACL_WLAN_PS_SLAVE_BR] = 8,
  156. [CONF_SG_ACL_WLAN_PS_MASTER_EDR] = 20,
  157. [CONF_SG_ACL_WLAN_PS_SLAVE_EDR] = 20,
  158. [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_BR] = 20,
  159. [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_BR] = 35,
  160. [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_BR] = 16,
  161. [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_BR] = 35,
  162. [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_EDR] = 32,
  163. [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_EDR] = 50,
  164. [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_EDR] = 28,
  165. [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_EDR] = 50,
  166. [CONF_SG_ACL_ACTIVE_SCAN_WLAN_BR] = 10,
  167. [CONF_SG_ACL_ACTIVE_SCAN_WLAN_EDR] = 20,
  168. [CONF_SG_ACL_PASSIVE_SCAN_BT_BR] = 75,
  169. [CONF_SG_ACL_PASSIVE_SCAN_WLAN_BR] = 15,
  170. [CONF_SG_ACL_PASSIVE_SCAN_BT_EDR] = 27,
  171. [CONF_SG_ACL_PASSIVE_SCAN_WLAN_EDR] = 17,
  172. /* active scan params */
  173. [CONF_SG_AUTO_SCAN_PROBE_REQ] = 170,
  174. [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_HV3] = 50,
  175. [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100,
  176. /* passive scan params */
  177. [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_BR] = 800,
  178. [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_EDR] = 200,
  179. [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_HV3] = 200,
  180. /* passive scan in dual antenna params */
  181. [CONF_SG_CONSECUTIVE_HV3_IN_PASSIVE_SCAN] = 0,
  182. [CONF_SG_BCN_HV3_COLLISION_THRESH_IN_PASSIVE_SCAN] = 0,
  183. [CONF_SG_TX_RX_PROTECTION_BWIDTH_IN_PASSIVE_SCAN] = 0,
  184. /* general params */
  185. [CONF_SG_STA_FORCE_PS_IN_BT_SCO] = 1,
  186. [CONF_SG_ANTENNA_CONFIGURATION] = 0,
  187. [CONF_SG_BEACON_MISS_PERCENT] = 60,
  188. [CONF_SG_DHCP_TIME] = 5000,
  189. [CONF_SG_RXT] = 1200,
  190. [CONF_SG_TXT] = 1000,
  191. [CONF_SG_ADAPTIVE_RXT_TXT] = 1,
  192. [CONF_SG_GENERAL_USAGE_BIT_MAP] = 3,
  193. [CONF_SG_HV3_MAX_SERVED] = 6,
  194. [CONF_SG_PS_POLL_TIMEOUT] = 10,
  195. [CONF_SG_UPSD_TIMEOUT] = 10,
  196. [CONF_SG_CONSECUTIVE_CTS_THRESHOLD] = 2,
  197. [CONF_SG_STA_RX_WINDOW_AFTER_DTIM] = 5,
  198. [CONF_SG_STA_CONNECTION_PROTECTION_TIME] = 30,
  199. /* AP params */
  200. [CONF_AP_BEACON_MISS_TX] = 3,
  201. [CONF_AP_RX_WINDOW_AFTER_BEACON] = 10,
  202. [CONF_AP_BEACON_WINDOW_INTERVAL] = 2,
  203. [CONF_AP_CONNECTION_PROTECTION_TIME] = 0,
  204. [CONF_AP_BT_ACL_VAL_BT_SERVE_TIME] = 25,
  205. [CONF_AP_BT_ACL_VAL_WL_SERVE_TIME] = 25,
  206. /* CTS Diluting params */
  207. [CONF_SG_CTS_DILUTED_BAD_RX_PACKETS_TH] = 0,
  208. [CONF_SG_CTS_CHOP_IN_DUAL_ANT_SCO_MASTER] = 0,
  209. },
  210. .state = CONF_SG_PROTECTIVE,
  211. },
  212. .rx = {
  213. .rx_msdu_life_time = 512000,
  214. .packet_detection_threshold = 0,
  215. .ps_poll_timeout = 15,
  216. .upsd_timeout = 15,
  217. .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD,
  218. .rx_cca_threshold = 0,
  219. .irq_blk_threshold = 0xFFFF,
  220. .irq_pkt_threshold = 0,
  221. .irq_timeout = 600,
  222. .queue_type = CONF_RX_QUEUE_TYPE_LOW_PRIORITY,
  223. },
  224. .tx = {
  225. .tx_energy_detection = 0,
  226. .sta_rc_conf = {
  227. .enabled_rates = 0,
  228. .short_retry_limit = 10,
  229. .long_retry_limit = 10,
  230. .aflags = 0,
  231. },
  232. .ac_conf_count = 4,
  233. .ac_conf = {
  234. [CONF_TX_AC_BE] = {
  235. .ac = CONF_TX_AC_BE,
  236. .cw_min = 15,
  237. .cw_max = 63,
  238. .aifsn = 3,
  239. .tx_op_limit = 0,
  240. },
  241. [CONF_TX_AC_BK] = {
  242. .ac = CONF_TX_AC_BK,
  243. .cw_min = 15,
  244. .cw_max = 63,
  245. .aifsn = 7,
  246. .tx_op_limit = 0,
  247. },
  248. [CONF_TX_AC_VI] = {
  249. .ac = CONF_TX_AC_VI,
  250. .cw_min = 15,
  251. .cw_max = 63,
  252. .aifsn = CONF_TX_AIFS_PIFS,
  253. .tx_op_limit = 3008,
  254. },
  255. [CONF_TX_AC_VO] = {
  256. .ac = CONF_TX_AC_VO,
  257. .cw_min = 15,
  258. .cw_max = 63,
  259. .aifsn = CONF_TX_AIFS_PIFS,
  260. .tx_op_limit = 1504,
  261. },
  262. },
  263. .max_tx_retries = 100,
  264. .ap_aging_period = 300,
  265. .tid_conf_count = 4,
  266. .tid_conf = {
  267. [CONF_TX_AC_BE] = {
  268. .queue_id = CONF_TX_AC_BE,
  269. .channel_type = CONF_CHANNEL_TYPE_EDCF,
  270. .tsid = CONF_TX_AC_BE,
  271. .ps_scheme = CONF_PS_SCHEME_LEGACY,
  272. .ack_policy = CONF_ACK_POLICY_LEGACY,
  273. .apsd_conf = {0, 0},
  274. },
  275. [CONF_TX_AC_BK] = {
  276. .queue_id = CONF_TX_AC_BK,
  277. .channel_type = CONF_CHANNEL_TYPE_EDCF,
  278. .tsid = CONF_TX_AC_BK,
  279. .ps_scheme = CONF_PS_SCHEME_LEGACY,
  280. .ack_policy = CONF_ACK_POLICY_LEGACY,
  281. .apsd_conf = {0, 0},
  282. },
  283. [CONF_TX_AC_VI] = {
  284. .queue_id = CONF_TX_AC_VI,
  285. .channel_type = CONF_CHANNEL_TYPE_EDCF,
  286. .tsid = CONF_TX_AC_VI,
  287. .ps_scheme = CONF_PS_SCHEME_LEGACY,
  288. .ack_policy = CONF_ACK_POLICY_LEGACY,
  289. .apsd_conf = {0, 0},
  290. },
  291. [CONF_TX_AC_VO] = {
  292. .queue_id = CONF_TX_AC_VO,
  293. .channel_type = CONF_CHANNEL_TYPE_EDCF,
  294. .tsid = CONF_TX_AC_VO,
  295. .ps_scheme = CONF_PS_SCHEME_LEGACY,
  296. .ack_policy = CONF_ACK_POLICY_LEGACY,
  297. .apsd_conf = {0, 0},
  298. },
  299. },
  300. .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD,
  301. .tx_compl_timeout = 350,
  302. .tx_compl_threshold = 10,
  303. .basic_rate = CONF_HW_BIT_RATE_1MBPS,
  304. .basic_rate_5 = CONF_HW_BIT_RATE_6MBPS,
  305. .tmpl_short_retry_limit = 10,
  306. .tmpl_long_retry_limit = 10,
  307. .tx_watchdog_timeout = 5000,
  308. },
  309. .conn = {
  310. .wake_up_event = CONF_WAKE_UP_EVENT_DTIM,
  311. .listen_interval = 1,
  312. .suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM,
  313. .suspend_listen_interval = 3,
  314. .bcn_filt_mode = CONF_BCN_FILT_MODE_ENABLED,
  315. .bcn_filt_ie_count = 2,
  316. .bcn_filt_ie = {
  317. [0] = {
  318. .ie = WLAN_EID_CHANNEL_SWITCH,
  319. .rule = CONF_BCN_RULE_PASS_ON_APPEARANCE,
  320. },
  321. [1] = {
  322. .ie = WLAN_EID_HT_OPERATION,
  323. .rule = CONF_BCN_RULE_PASS_ON_CHANGE,
  324. },
  325. },
  326. .synch_fail_thold = 10,
  327. .bss_lose_timeout = 100,
  328. .beacon_rx_timeout = 10000,
  329. .broadcast_timeout = 20000,
  330. .rx_broadcast_in_ps = 1,
  331. .ps_poll_threshold = 10,
  332. .bet_enable = CONF_BET_MODE_ENABLE,
  333. .bet_max_consecutive = 50,
  334. .psm_entry_retries = 8,
  335. .psm_exit_retries = 16,
  336. .psm_entry_nullfunc_retries = 3,
  337. .dynamic_ps_timeout = 40,
  338. .forced_ps = false,
  339. .keep_alive_interval = 55000,
  340. .max_listen_interval = 20,
  341. },
  342. .itrim = {
  343. .enable = false,
  344. .timeout = 50000,
  345. },
  346. .pm_config = {
  347. .host_clk_settling_time = 5000,
  348. .host_fast_wakeup_support = false
  349. },
  350. .roam_trigger = {
  351. .trigger_pacing = 1,
  352. .avg_weight_rssi_beacon = 20,
  353. .avg_weight_rssi_data = 10,
  354. .avg_weight_snr_beacon = 20,
  355. .avg_weight_snr_data = 10,
  356. },
  357. .scan = {
  358. .min_dwell_time_active = 7500,
  359. .max_dwell_time_active = 30000,
  360. .min_dwell_time_passive = 100000,
  361. .max_dwell_time_passive = 100000,
  362. .num_probe_reqs = 2,
  363. .split_scan_timeout = 50000,
  364. },
  365. .sched_scan = {
  366. /*
  367. * Values are in TU/1000 but since sched scan FW command
  368. * params are in TUs rounding up may occur.
  369. */
  370. .base_dwell_time = 7500,
  371. .max_dwell_time_delta = 22500,
  372. /* based on 250bits per probe @1Mbps */
  373. .dwell_time_delta_per_probe = 2000,
  374. /* based on 250bits per probe @6Mbps (plus a bit more) */
  375. .dwell_time_delta_per_probe_5 = 350,
  376. .dwell_time_passive = 100000,
  377. .dwell_time_dfs = 150000,
  378. .num_probe_reqs = 2,
  379. .rssi_threshold = -90,
  380. .snr_threshold = 0,
  381. },
  382. .ht = {
  383. .rx_ba_win_size = 10,
  384. .tx_ba_win_size = 10,
  385. .inactivity_timeout = 10000,
  386. .tx_ba_tid_bitmap = CONF_TX_BA_ENABLED_TID_BITMAP,
  387. },
  388. .mem = {
  389. .num_stations = 1,
  390. .ssid_profiles = 1,
  391. .rx_block_num = 40,
  392. .tx_min_block_num = 40,
  393. .dynamic_memory = 1,
  394. .min_req_tx_blocks = 45,
  395. .min_req_rx_blocks = 22,
  396. .tx_min = 27,
  397. },
  398. .fm_coex = {
  399. .enable = true,
  400. .swallow_period = 5,
  401. .n_divider_fref_set_1 = 0xff, /* default */
  402. .n_divider_fref_set_2 = 12,
  403. .m_divider_fref_set_1 = 148,
  404. .m_divider_fref_set_2 = 0xffff, /* default */
  405. .coex_pll_stabilization_time = 0xffffffff, /* default */
  406. .ldo_stabilization_time = 0xffff, /* default */
  407. .fm_disturbed_band_margin = 0xff, /* default */
  408. .swallow_clk_diff = 0xff, /* default */
  409. },
  410. .rx_streaming = {
  411. .duration = 150,
  412. .queues = 0x1,
  413. .interval = 20,
  414. .always = 0,
  415. },
  416. .fwlog = {
  417. .mode = WL12XX_FWLOG_ON_DEMAND,
  418. .mem_blocks = 2,
  419. .severity = 0,
  420. .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED,
  421. .output = WL12XX_FWLOG_OUTPUT_HOST,
  422. .threshold = 0,
  423. },
  424. .rate = {
  425. .rate_retry_score = 32000,
  426. .per_add = 8192,
  427. .per_th1 = 2048,
  428. .per_th2 = 4096,
  429. .max_per = 8100,
  430. .inverse_curiosity_factor = 5,
  431. .tx_fail_low_th = 4,
  432. .tx_fail_high_th = 10,
  433. .per_alpha_shift = 4,
  434. .per_add_shift = 13,
  435. .per_beta1_shift = 10,
  436. .per_beta2_shift = 8,
  437. .rate_check_up = 2,
  438. .rate_check_down = 12,
  439. .rate_retry_policy = {
  440. 0x00, 0x00, 0x00, 0x00, 0x00,
  441. 0x00, 0x00, 0x00, 0x00, 0x00,
  442. 0x00, 0x00, 0x00,
  443. },
  444. },
  445. .hangover = {
  446. .recover_time = 0,
  447. .hangover_period = 20,
  448. .dynamic_mode = 1,
  449. .early_termination_mode = 1,
  450. .max_period = 20,
  451. .min_period = 1,
  452. .increase_delta = 1,
  453. .decrease_delta = 2,
  454. .quiet_time = 4,
  455. .increase_time = 1,
  456. .window_size = 16,
  457. },
  458. };
  459. static struct wl18xx_priv_conf wl18xx_default_priv_conf = {
  460. .phy = {
  461. .phy_standalone = 0x00,
  462. .primary_clock_setting_time = 0x05,
  463. .clock_valid_on_wake_up = 0x00,
  464. .secondary_clock_setting_time = 0x05,
  465. .rdl = 0x01,
  466. .auto_detect = 0x00,
  467. .dedicated_fem = FEM_NONE,
  468. .low_band_component = COMPONENT_2_WAY_SWITCH,
  469. .low_band_component_type = 0x05,
  470. .high_band_component = COMPONENT_2_WAY_SWITCH,
  471. .high_band_component_type = 0x09,
  472. .number_of_assembled_ant2_4 = 0x01,
  473. .number_of_assembled_ant5 = 0x01,
  474. .external_pa_dc2dc = 0x00,
  475. .tcxo_ldo_voltage = 0x00,
  476. .xtal_itrim_val = 0x04,
  477. .srf_state = 0x00,
  478. .io_configuration = 0x01,
  479. .sdio_configuration = 0x00,
  480. .settings = 0x00,
  481. .enable_clpc = 0x00,
  482. .enable_tx_low_pwr_on_siso_rdl = 0x00,
  483. .rx_profile = 0x00,
  484. },
  485. };
  486. static const struct wlcore_partition_set wl18xx_ptable[PART_TABLE_LEN] = {
  487. [PART_TOP_PRCM_ELP_SOC] = {
  488. .mem = { .start = 0x00A02000, .size = 0x00010000 },
  489. .reg = { .start = 0x00807000, .size = 0x00005000 },
  490. .mem2 = { .start = 0x00800000, .size = 0x0000B000 },
  491. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  492. },
  493. [PART_DOWN] = {
  494. .mem = { .start = 0x00000000, .size = 0x00014000 },
  495. .reg = { .start = 0x00810000, .size = 0x0000BFFF },
  496. .mem2 = { .start = 0x00000000, .size = 0x00000000 },
  497. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  498. },
  499. [PART_BOOT] = {
  500. .mem = { .start = 0x00700000, .size = 0x0000030c },
  501. .reg = { .start = 0x00802000, .size = 0x00014578 },
  502. .mem2 = { .start = 0x00B00404, .size = 0x00001000 },
  503. .mem3 = { .start = 0x00C00000, .size = 0x00000400 },
  504. },
  505. [PART_WORK] = {
  506. .mem = { .start = 0x00800000, .size = 0x000050FC },
  507. .reg = { .start = 0x00B00404, .size = 0x00001000 },
  508. .mem2 = { .start = 0x00C00000, .size = 0x00000400 },
  509. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  510. },
  511. [PART_PHY_INIT] = {
  512. /* TODO: use the phy_conf struct size here */
  513. .mem = { .start = 0x80926000, .size = 252 },
  514. .reg = { .start = 0x00000000, .size = 0x00000000 },
  515. .mem2 = { .start = 0x00000000, .size = 0x00000000 },
  516. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  517. },
  518. };
  519. static const int wl18xx_rtable[REG_TABLE_LEN] = {
  520. [REG_ECPU_CONTROL] = WL18XX_REG_ECPU_CONTROL,
  521. [REG_INTERRUPT_NO_CLEAR] = WL18XX_REG_INTERRUPT_NO_CLEAR,
  522. [REG_INTERRUPT_ACK] = WL18XX_REG_INTERRUPT_ACK,
  523. [REG_COMMAND_MAILBOX_PTR] = WL18XX_REG_COMMAND_MAILBOX_PTR,
  524. [REG_EVENT_MAILBOX_PTR] = WL18XX_REG_EVENT_MAILBOX_PTR,
  525. [REG_INTERRUPT_TRIG] = WL18XX_REG_INTERRUPT_TRIG_H,
  526. [REG_INTERRUPT_MASK] = WL18XX_REG_INTERRUPT_MASK,
  527. [REG_PC_ON_RECOVERY] = WL18XX_SCR_PAD4,
  528. [REG_CHIP_ID_B] = WL18XX_REG_CHIP_ID_B,
  529. [REG_CMD_MBOX_ADDRESS] = WL18XX_CMD_MBOX_ADDRESS,
  530. /* data access memory addresses, used with partition translation */
  531. [REG_SLV_MEM_DATA] = WL18XX_SLV_MEM_DATA,
  532. [REG_SLV_REG_DATA] = WL18XX_SLV_REG_DATA,
  533. /* raw data access memory addresses */
  534. [REG_RAW_FW_STATUS_ADDR] = WL18XX_FW_STATUS_ADDR,
  535. };
  536. static const struct wl18xx_clk_cfg wl18xx_clk_table[NUM_CLOCK_CONFIGS] = {
  537. [CLOCK_CONFIG_16_2_M] = { 7, 104, 801, 4, true },
  538. [CLOCK_CONFIG_16_368_M] = { 9, 132, 3751, 4, true },
  539. [CLOCK_CONFIG_16_8_M] = { 7, 100, 0, 0, false },
  540. [CLOCK_CONFIG_19_2_M] = { 8, 100, 0, 0, false },
  541. [CLOCK_CONFIG_26_M] = { 13, 120, 0, 0, false },
  542. [CLOCK_CONFIG_32_736_M] = { 9, 132, 3751, 4, true },
  543. [CLOCK_CONFIG_33_6_M] = { 7, 100, 0, 0, false },
  544. [CLOCK_CONFIG_38_468_M] = { 8, 100, 0, 0, false },
  545. [CLOCK_CONFIG_52_M] = { 13, 120, 0, 0, false },
  546. };
  547. /* TODO: maybe move to a new header file? */
  548. #define WL18XX_FW_NAME "ti-connectivity/wl18xx-fw.bin"
  549. static int wl18xx_identify_chip(struct wl1271 *wl)
  550. {
  551. int ret = 0;
  552. switch (wl->chip.id) {
  553. case CHIP_ID_185x_PG10:
  554. wl1271_debug(DEBUG_BOOT, "chip id 0x%x (185x PG10)",
  555. wl->chip.id);
  556. wl->sr_fw_name = WL18XX_FW_NAME;
  557. /* wl18xx uses the same firmware for PLT */
  558. wl->plt_fw_name = WL18XX_FW_NAME;
  559. wl->quirks |= WLCORE_QUIRK_NO_ELP |
  560. WLCORE_QUIRK_FWLOG_NOT_IMPLEMENTED |
  561. WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN;
  562. /* TODO: need to blocksize alignment for RX/TX separately? */
  563. break;
  564. default:
  565. wl1271_warning("unsupported chip id: 0x%x", wl->chip.id);
  566. ret = -ENODEV;
  567. goto out;
  568. }
  569. out:
  570. return ret;
  571. }
  572. static void wl18xx_set_clk(struct wl1271 *wl)
  573. {
  574. u32 clk_freq;
  575. wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
  576. /* TODO: PG2: apparently we need to read the clk type */
  577. clk_freq = wl18xx_top_reg_read(wl, PRIMARY_CLK_DETECT);
  578. wl1271_debug(DEBUG_BOOT, "clock freq %d (%d, %d, %d, %d, %s)", clk_freq,
  579. wl18xx_clk_table[clk_freq].n, wl18xx_clk_table[clk_freq].m,
  580. wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q,
  581. wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit");
  582. wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N, wl18xx_clk_table[clk_freq].n);
  583. wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_M, wl18xx_clk_table[clk_freq].m);
  584. if (wl18xx_clk_table[clk_freq].swallow) {
  585. /* first the 16 lower bits */
  586. wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_1,
  587. wl18xx_clk_table[clk_freq].q &
  588. PLLSH_WCS_PLL_Q_FACTOR_CFG_1_MASK);
  589. /* then the 16 higher bits, masked out */
  590. wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_2,
  591. (wl18xx_clk_table[clk_freq].q >> 16) &
  592. PLLSH_WCS_PLL_Q_FACTOR_CFG_2_MASK);
  593. /* first the 16 lower bits */
  594. wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_1,
  595. wl18xx_clk_table[clk_freq].p &
  596. PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK);
  597. /* then the 16 higher bits, masked out */
  598. wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2,
  599. (wl18xx_clk_table[clk_freq].p >> 16) &
  600. PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK);
  601. } else {
  602. wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN,
  603. PLLSH_WCS_PLL_SWALLOW_EN_VAL2);
  604. }
  605. }
  606. static void wl18xx_boot_soft_reset(struct wl1271 *wl)
  607. {
  608. /* disable Rx/Tx */
  609. wl1271_write32(wl, WL18XX_ENABLE, 0x0);
  610. /* disable auto calibration on start*/
  611. wl1271_write32(wl, WL18XX_SPARE_A2, 0xffff);
  612. }
  613. static int wl18xx_pre_boot(struct wl1271 *wl)
  614. {
  615. wl18xx_set_clk(wl);
  616. /* Continue the ELP wake up sequence */
  617. wl1271_write32(wl, WL18XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
  618. udelay(500);
  619. wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  620. /* Disable interrupts */
  621. wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL);
  622. wl18xx_boot_soft_reset(wl);
  623. return 0;
  624. }
  625. static void wl18xx_pre_upload(struct wl1271 *wl)
  626. {
  627. u32 tmp;
  628. wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  629. /* TODO: check if this is all needed */
  630. wl1271_write32(wl, WL18XX_EEPROMLESS_IND, WL18XX_EEPROMLESS_IND);
  631. tmp = wlcore_read_reg(wl, REG_CHIP_ID_B);
  632. wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp);
  633. tmp = wl1271_read32(wl, WL18XX_SCR_PAD2);
  634. }
  635. static void wl18xx_set_mac_and_phy(struct wl1271 *wl)
  636. {
  637. struct wl18xx_priv *priv = wl->priv;
  638. struct wl18xx_conf_phy *phy = &priv->conf.phy;
  639. struct wl18xx_mac_and_phy_params params;
  640. memset(&params, 0, sizeof(params));
  641. params.phy_standalone = phy->phy_standalone;
  642. params.rdl = phy->rdl;
  643. params.enable_clpc = phy->enable_clpc;
  644. params.enable_tx_low_pwr_on_siso_rdl =
  645. phy->enable_tx_low_pwr_on_siso_rdl;
  646. params.auto_detect = phy->auto_detect;
  647. params.dedicated_fem = phy->dedicated_fem;
  648. params.low_band_component = phy->low_band_component;
  649. params.low_band_component_type =
  650. phy->low_band_component_type;
  651. params.high_band_component = phy->high_band_component;
  652. params.high_band_component_type =
  653. phy->high_band_component_type;
  654. params.number_of_assembled_ant2_4 =
  655. phy->number_of_assembled_ant2_4;
  656. params.number_of_assembled_ant5 =
  657. phy->number_of_assembled_ant5;
  658. params.external_pa_dc2dc = phy->external_pa_dc2dc;
  659. params.tcxo_ldo_voltage = phy->tcxo_ldo_voltage;
  660. params.xtal_itrim_val = phy->xtal_itrim_val;
  661. params.srf_state = phy->srf_state;
  662. params.io_configuration = phy->io_configuration;
  663. params.sdio_configuration = phy->sdio_configuration;
  664. params.settings = phy->settings;
  665. params.rx_profile = phy->rx_profile;
  666. params.primary_clock_setting_time =
  667. phy->primary_clock_setting_time;
  668. params.clock_valid_on_wake_up =
  669. phy->clock_valid_on_wake_up;
  670. params.secondary_clock_setting_time =
  671. phy->secondary_clock_setting_time;
  672. params.board_type = priv->board_type;
  673. wlcore_set_partition(wl, &wl->ptable[PART_PHY_INIT]);
  674. wl1271_write(wl, WL18XX_PHY_INIT_MEM_ADDR, (u8 *)&params,
  675. sizeof(params), false);
  676. }
  677. static void wl18xx_enable_interrupts(struct wl1271 *wl)
  678. {
  679. wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_ALL_EVENTS_VECTOR);
  680. wlcore_enable_interrupts(wl);
  681. wlcore_write_reg(wl, REG_INTERRUPT_MASK,
  682. WL1271_ACX_INTR_ALL & ~(WL1271_INTR_MASK));
  683. }
  684. static int wl18xx_boot(struct wl1271 *wl)
  685. {
  686. int ret;
  687. ret = wl18xx_pre_boot(wl);
  688. if (ret < 0)
  689. goto out;
  690. wl18xx_pre_upload(wl);
  691. ret = wlcore_boot_upload_firmware(wl);
  692. if (ret < 0)
  693. goto out;
  694. wl18xx_set_mac_and_phy(wl);
  695. ret = wlcore_boot_run_firmware(wl);
  696. if (ret < 0)
  697. goto out;
  698. wl18xx_enable_interrupts(wl);
  699. out:
  700. return ret;
  701. }
  702. static void wl18xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr,
  703. void *buf, size_t len)
  704. {
  705. struct wl18xx_priv *priv = wl->priv;
  706. memcpy(priv->cmd_buf, buf, len);
  707. memset(priv->cmd_buf + len, 0, WL18XX_CMD_MAX_SIZE - len);
  708. wl1271_write(wl, cmd_box_addr, priv->cmd_buf, WL18XX_CMD_MAX_SIZE,
  709. false);
  710. }
  711. static void wl18xx_ack_event(struct wl1271 *wl)
  712. {
  713. wlcore_write_reg(wl, REG_INTERRUPT_TRIG, WL18XX_INTR_TRIG_EVENT_ACK);
  714. }
  715. static u32 wl18xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
  716. {
  717. u32 blk_size = WL18XX_TX_HW_BLOCK_SIZE;
  718. return (len + blk_size - 1) / blk_size + spare_blks;
  719. }
  720. static void
  721. wl18xx_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
  722. u32 blks, u32 spare_blks)
  723. {
  724. desc->wl18xx_mem.total_mem_blocks = blks;
  725. desc->wl18xx_mem.reserved = 0;
  726. }
  727. static void
  728. wl18xx_set_tx_desc_data_len(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
  729. struct sk_buff *skb)
  730. {
  731. desc->length = cpu_to_le16(skb->len);
  732. wl1271_debug(DEBUG_TX, "tx_fill_hdr: hlid: %d "
  733. "len: %d life: %d mem: %d", desc->hlid,
  734. le16_to_cpu(desc->length),
  735. le16_to_cpu(desc->life_time),
  736. desc->wl18xx_mem.total_mem_blocks);
  737. }
  738. static enum wl_rx_buf_align
  739. wl18xx_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)
  740. {
  741. if (rx_desc & RX_BUF_PADDED_PAYLOAD)
  742. return WLCORE_RX_BUF_PADDED;
  743. return WLCORE_RX_BUF_ALIGNED;
  744. }
  745. static u32 wl18xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data,
  746. u32 data_len)
  747. {
  748. struct wl1271_rx_descriptor *desc = rx_data;
  749. /* invalid packet */
  750. if (data_len < sizeof(*desc))
  751. return 0;
  752. return data_len - sizeof(*desc);
  753. }
  754. static void wl18xx_tx_immediate_completion(struct wl1271 *wl)
  755. {
  756. wl18xx_tx_immediate_complete(wl);
  757. }
  758. static int wl18xx_hw_init(struct wl1271 *wl)
  759. {
  760. int ret;
  761. struct wl18xx_priv *priv = wl->priv;
  762. u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE |
  763. HOST_IF_CFG_ADD_RX_ALIGNMENT;
  764. u32 sdio_align_size = 0;
  765. /* (re)init private structures. Relevant on recovery as well. */
  766. priv->last_fw_rls_idx = 0;
  767. /* Enable Tx SDIO padding */
  768. if (wl->quirks & WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN) {
  769. host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
  770. sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
  771. }
  772. /* Enable Rx SDIO padding */
  773. if (wl->quirks & WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN) {
  774. host_cfg_bitmap |= HOST_IF_CFG_RX_PAD_TO_SDIO_BLK;
  775. sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
  776. }
  777. ret = wl18xx_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap,
  778. sdio_align_size,
  779. WL18XX_TX_HW_BLOCK_SPARE,
  780. WL18XX_HOST_IF_LEN_SIZE_FIELD);
  781. if (ret < 0)
  782. return ret;
  783. ret = wl18xx_acx_set_checksum_state(wl);
  784. if (ret != 0)
  785. return ret;
  786. return ret;
  787. }
  788. static void wl18xx_set_tx_desc_csum(struct wl1271 *wl,
  789. struct wl1271_tx_hw_descr *desc,
  790. struct sk_buff *skb)
  791. {
  792. u32 ip_hdr_offset;
  793. struct iphdr *ip_hdr;
  794. if (skb->ip_summed != CHECKSUM_PARTIAL) {
  795. desc->wl18xx_checksum_data = 0;
  796. return;
  797. }
  798. ip_hdr_offset = skb_network_header(skb) - skb_mac_header(skb);
  799. if (WARN_ON(ip_hdr_offset >= (1<<7))) {
  800. desc->wl18xx_checksum_data = 0;
  801. return;
  802. }
  803. desc->wl18xx_checksum_data = ip_hdr_offset << 1;
  804. /* FW is interested only in the LSB of the protocol TCP=0 UDP=1 */
  805. ip_hdr = (void *)skb_network_header(skb);
  806. desc->wl18xx_checksum_data |= (ip_hdr->protocol & 0x01);
  807. }
  808. static void wl18xx_set_rx_csum(struct wl1271 *wl,
  809. struct wl1271_rx_descriptor *desc,
  810. struct sk_buff *skb)
  811. {
  812. if (desc->status & WL18XX_RX_CHECKSUM_MASK)
  813. skb->ip_summed = CHECKSUM_UNNECESSARY;
  814. }
  815. static u32 wl18xx_sta_get_ap_rate_mask(struct wl1271 *wl,
  816. struct wl12xx_vif *wlvif)
  817. {
  818. u32 hw_rate_set = wlvif->rate_set;
  819. if (wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
  820. wlvif->channel_type == NL80211_CHAN_HT40PLUS) {
  821. wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
  822. hw_rate_set |= CONF_TX_RATE_USE_WIDE_CHAN;
  823. /* we don't support MIMO in wide-channel mode */
  824. hw_rate_set &= ~CONF_TX_MIMO_RATES;
  825. }
  826. return hw_rate_set;
  827. }
  828. static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
  829. struct wl12xx_vif *wlvif)
  830. {
  831. if (wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
  832. wlvif->channel_type == NL80211_CHAN_HT40PLUS) {
  833. wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
  834. return CONF_TX_RATE_USE_WIDE_CHAN;
  835. } else {
  836. wl1271_debug(DEBUG_ACX, "using MIMO rate mask");
  837. return CONF_TX_MIMO_RATES;
  838. }
  839. }
  840. static s8 wl18xx_get_pg_ver(struct wl1271 *wl)
  841. {
  842. u32 fuse;
  843. wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
  844. fuse = wl1271_read32(wl, WL18XX_REG_FUSE_DATA_1_3);
  845. fuse = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET;
  846. wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  847. return (s8)fuse;
  848. }
  849. static void wl18xx_conf_init(struct wl1271 *wl)
  850. {
  851. struct wl18xx_priv *priv = wl->priv;
  852. /* apply driver default configuration */
  853. memcpy(&wl->conf, &wl18xx_conf, sizeof(wl18xx_conf));
  854. /* apply default private configuration */
  855. memcpy(&priv->conf, &wl18xx_default_priv_conf, sizeof(priv->conf));
  856. }
  857. static int wl18xx_plt_init(struct wl1271 *wl)
  858. {
  859. wl1271_write32(wl, WL18XX_SCR_PAD8, WL18XX_SCR_PAD8_PLT);
  860. return wl->ops->boot(wl);
  861. }
  862. static struct wlcore_ops wl18xx_ops = {
  863. .identify_chip = wl18xx_identify_chip,
  864. .boot = wl18xx_boot,
  865. .plt_init = wl18xx_plt_init,
  866. .trigger_cmd = wl18xx_trigger_cmd,
  867. .ack_event = wl18xx_ack_event,
  868. .calc_tx_blocks = wl18xx_calc_tx_blocks,
  869. .set_tx_desc_blocks = wl18xx_set_tx_desc_blocks,
  870. .set_tx_desc_data_len = wl18xx_set_tx_desc_data_len,
  871. .get_rx_buf_align = wl18xx_get_rx_buf_align,
  872. .get_rx_packet_len = wl18xx_get_rx_packet_len,
  873. .tx_immediate_compl = wl18xx_tx_immediate_completion,
  874. .tx_delayed_compl = NULL,
  875. .hw_init = wl18xx_hw_init,
  876. .set_tx_desc_csum = wl18xx_set_tx_desc_csum,
  877. .get_pg_ver = wl18xx_get_pg_ver,
  878. .set_rx_csum = wl18xx_set_rx_csum,
  879. .sta_get_ap_rate_mask = wl18xx_sta_get_ap_rate_mask,
  880. .ap_get_mimo_wide_rate_mask = wl18xx_ap_get_mimo_wide_rate_mask,
  881. };
  882. /* HT cap appropriate for wide channels */
  883. static struct ieee80211_sta_ht_cap wl18xx_ht_cap = {
  884. .cap = IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
  885. IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_DSSSCCK40,
  886. .ht_supported = true,
  887. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  888. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  889. .mcs = {
  890. .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
  891. .rx_highest = cpu_to_le16(150),
  892. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  893. },
  894. };
  895. /* HT cap appropriate for MIMO rates in 20mhz channel */
  896. static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap = {
  897. .cap = IEEE80211_HT_CAP_SGI_20,
  898. .ht_supported = true,
  899. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  900. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  901. .mcs = {
  902. .rx_mask = { 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, },
  903. .rx_highest = cpu_to_le16(144),
  904. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  905. },
  906. };
  907. int __devinit wl18xx_probe(struct platform_device *pdev)
  908. {
  909. struct wl1271 *wl;
  910. struct ieee80211_hw *hw;
  911. struct wl18xx_priv *priv;
  912. hw = wlcore_alloc_hw(sizeof(*priv));
  913. if (IS_ERR(hw)) {
  914. wl1271_error("can't allocate hw");
  915. return PTR_ERR(hw);
  916. }
  917. wl = hw->priv;
  918. priv = wl->priv;
  919. wl->ops = &wl18xx_ops;
  920. wl->ptable = wl18xx_ptable;
  921. wl->rtable = wl18xx_rtable;
  922. wl->num_tx_desc = 32;
  923. wl->normal_tx_spare = WL18XX_TX_HW_BLOCK_SPARE;
  924. wl->gem_tx_spare = WL18XX_TX_HW_GEM_BLOCK_SPARE;
  925. wl->band_rate_to_idx = wl18xx_band_rate_to_idx;
  926. wl->hw_tx_rate_tbl_size = WL18XX_CONF_HW_RXTX_RATE_MAX;
  927. wl->hw_min_ht_rate = WL18XX_CONF_HW_RXTX_RATE_MCS0;
  928. wl->fw_status_priv_len = sizeof(struct wl18xx_fw_status_priv);
  929. memcpy(&wl->ht_cap, &wl18xx_ht_cap, sizeof(wl18xx_ht_cap));
  930. if (ht_mode_param && !strcmp(ht_mode_param, "mimo"))
  931. memcpy(&wl->ht_cap, &wl18xx_mimo_ht_cap,
  932. sizeof(wl18xx_mimo_ht_cap));
  933. if (!board_type_param) {
  934. board_type_param = kstrdup("dvp", GFP_KERNEL);
  935. priv->board_type = BOARD_TYPE_DVP_18XX;
  936. } else if (!strcmp(board_type_param, "fpga")) {
  937. priv->board_type = BOARD_TYPE_FPGA_18XX;
  938. } else if (!strcmp(board_type_param, "hdk")) {
  939. priv->board_type = BOARD_TYPE_HDK_18XX;
  940. } else if (!strcmp(board_type_param, "dvp")) {
  941. priv->board_type = BOARD_TYPE_DVP_18XX;
  942. } else if (!strcmp(board_type_param, "evb")) {
  943. priv->board_type = BOARD_TYPE_EVB_18XX;
  944. } else if (!strcmp(board_type_param, "com8")) {
  945. priv->board_type = BOARD_TYPE_COM8_18XX;
  946. } else {
  947. wl1271_error("invalid board type '%s'", board_type_param);
  948. wlcore_free_hw(wl);
  949. return -EINVAL;
  950. }
  951. wl18xx_conf_init(wl);
  952. return wlcore_probe(wl, pdev);
  953. }
  954. static const struct platform_device_id wl18xx_id_table[] __devinitconst = {
  955. { "wl18xx", 0 },
  956. { } /* Terminating Entry */
  957. };
  958. MODULE_DEVICE_TABLE(platform, wl18xx_id_table);
  959. static struct platform_driver wl18xx_driver = {
  960. .probe = wl18xx_probe,
  961. .remove = __devexit_p(wlcore_remove),
  962. .id_table = wl18xx_id_table,
  963. .driver = {
  964. .name = "wl18xx_driver",
  965. .owner = THIS_MODULE,
  966. }
  967. };
  968. static int __init wl18xx_init(void)
  969. {
  970. return platform_driver_register(&wl18xx_driver);
  971. }
  972. module_init(wl18xx_init);
  973. static void __exit wl18xx_exit(void)
  974. {
  975. platform_driver_unregister(&wl18xx_driver);
  976. }
  977. module_exit(wl18xx_exit);
  978. module_param_named(ht_mode, ht_mode_param, charp, S_IRUSR);
  979. MODULE_PARM_DESC(ht_mode, "Force HT mode: wide or mimo");
  980. module_param_named(board_type, board_type_param, charp, S_IRUSR);
  981. MODULE_PARM_DESC(board_type, "Board type: fpga, hdk, evb, com8 or "
  982. "dvp (default)");
  983. MODULE_LICENSE("GPL v2");
  984. MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
  985. MODULE_FIRMWARE(WL18XX_FW_NAME);