main.c 38 KB

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