main.c 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636
  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 <linux/firmware.h>
  25. #include "../wlcore/wlcore.h"
  26. #include "../wlcore/debug.h"
  27. #include "../wlcore/io.h"
  28. #include "../wlcore/acx.h"
  29. #include "../wlcore/tx.h"
  30. #include "../wlcore/rx.h"
  31. #include "../wlcore/boot.h"
  32. #include "reg.h"
  33. #include "conf.h"
  34. #include "cmd.h"
  35. #include "acx.h"
  36. #include "tx.h"
  37. #include "wl18xx.h"
  38. #include "io.h"
  39. #include "scan.h"
  40. #include "event.h"
  41. #include "debugfs.h"
  42. #define WL18XX_RX_CHECKSUM_MASK 0x40
  43. static char *ht_mode_param = NULL;
  44. static char *board_type_param = NULL;
  45. static bool checksum_param = false;
  46. static int num_rx_desc_param = -1;
  47. /* phy paramters */
  48. static int dc2dc_param = -1;
  49. static int n_antennas_2_param = -1;
  50. static int n_antennas_5_param = -1;
  51. static int low_band_component_param = -1;
  52. static int low_band_component_type_param = -1;
  53. static int high_band_component_param = -1;
  54. static int high_band_component_type_param = -1;
  55. static int pwr_limit_reference_11_abg_param = -1;
  56. static const u8 wl18xx_rate_to_idx_2ghz[] = {
  57. /* MCS rates are used only with 11n */
  58. 15, /* WL18XX_CONF_HW_RXTX_RATE_MCS15 */
  59. 14, /* WL18XX_CONF_HW_RXTX_RATE_MCS14 */
  60. 13, /* WL18XX_CONF_HW_RXTX_RATE_MCS13 */
  61. 12, /* WL18XX_CONF_HW_RXTX_RATE_MCS12 */
  62. 11, /* WL18XX_CONF_HW_RXTX_RATE_MCS11 */
  63. 10, /* WL18XX_CONF_HW_RXTX_RATE_MCS10 */
  64. 9, /* WL18XX_CONF_HW_RXTX_RATE_MCS9 */
  65. 8, /* WL18XX_CONF_HW_RXTX_RATE_MCS8 */
  66. 7, /* WL18XX_CONF_HW_RXTX_RATE_MCS7 */
  67. 6, /* WL18XX_CONF_HW_RXTX_RATE_MCS6 */
  68. 5, /* WL18XX_CONF_HW_RXTX_RATE_MCS5 */
  69. 4, /* WL18XX_CONF_HW_RXTX_RATE_MCS4 */
  70. 3, /* WL18XX_CONF_HW_RXTX_RATE_MCS3 */
  71. 2, /* WL18XX_CONF_HW_RXTX_RATE_MCS2 */
  72. 1, /* WL18XX_CONF_HW_RXTX_RATE_MCS1 */
  73. 0, /* WL18XX_CONF_HW_RXTX_RATE_MCS0 */
  74. 11, /* WL18XX_CONF_HW_RXTX_RATE_54 */
  75. 10, /* WL18XX_CONF_HW_RXTX_RATE_48 */
  76. 9, /* WL18XX_CONF_HW_RXTX_RATE_36 */
  77. 8, /* WL18XX_CONF_HW_RXTX_RATE_24 */
  78. /* TI-specific rate */
  79. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_22 */
  80. 7, /* WL18XX_CONF_HW_RXTX_RATE_18 */
  81. 6, /* WL18XX_CONF_HW_RXTX_RATE_12 */
  82. 3, /* WL18XX_CONF_HW_RXTX_RATE_11 */
  83. 5, /* WL18XX_CONF_HW_RXTX_RATE_9 */
  84. 4, /* WL18XX_CONF_HW_RXTX_RATE_6 */
  85. 2, /* WL18XX_CONF_HW_RXTX_RATE_5_5 */
  86. 1, /* WL18XX_CONF_HW_RXTX_RATE_2 */
  87. 0 /* WL18XX_CONF_HW_RXTX_RATE_1 */
  88. };
  89. static const u8 wl18xx_rate_to_idx_5ghz[] = {
  90. /* MCS rates are used only with 11n */
  91. 15, /* WL18XX_CONF_HW_RXTX_RATE_MCS15 */
  92. 14, /* WL18XX_CONF_HW_RXTX_RATE_MCS14 */
  93. 13, /* WL18XX_CONF_HW_RXTX_RATE_MCS13 */
  94. 12, /* WL18XX_CONF_HW_RXTX_RATE_MCS12 */
  95. 11, /* WL18XX_CONF_HW_RXTX_RATE_MCS11 */
  96. 10, /* WL18XX_CONF_HW_RXTX_RATE_MCS10 */
  97. 9, /* WL18XX_CONF_HW_RXTX_RATE_MCS9 */
  98. 8, /* WL18XX_CONF_HW_RXTX_RATE_MCS8 */
  99. 7, /* WL18XX_CONF_HW_RXTX_RATE_MCS7 */
  100. 6, /* WL18XX_CONF_HW_RXTX_RATE_MCS6 */
  101. 5, /* WL18XX_CONF_HW_RXTX_RATE_MCS5 */
  102. 4, /* WL18XX_CONF_HW_RXTX_RATE_MCS4 */
  103. 3, /* WL18XX_CONF_HW_RXTX_RATE_MCS3 */
  104. 2, /* WL18XX_CONF_HW_RXTX_RATE_MCS2 */
  105. 1, /* WL18XX_CONF_HW_RXTX_RATE_MCS1 */
  106. 0, /* WL18XX_CONF_HW_RXTX_RATE_MCS0 */
  107. 7, /* WL18XX_CONF_HW_RXTX_RATE_54 */
  108. 6, /* WL18XX_CONF_HW_RXTX_RATE_48 */
  109. 5, /* WL18XX_CONF_HW_RXTX_RATE_36 */
  110. 4, /* WL18XX_CONF_HW_RXTX_RATE_24 */
  111. /* TI-specific rate */
  112. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_22 */
  113. 3, /* WL18XX_CONF_HW_RXTX_RATE_18 */
  114. 2, /* WL18XX_CONF_HW_RXTX_RATE_12 */
  115. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_11 */
  116. 1, /* WL18XX_CONF_HW_RXTX_RATE_9 */
  117. 0, /* WL18XX_CONF_HW_RXTX_RATE_6 */
  118. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_5_5 */
  119. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_2 */
  120. CONF_HW_RXTX_RATE_UNSUPPORTED, /* WL18XX_CONF_HW_RXTX_RATE_1 */
  121. };
  122. static const u8 *wl18xx_band_rate_to_idx[] = {
  123. [IEEE80211_BAND_2GHZ] = wl18xx_rate_to_idx_2ghz,
  124. [IEEE80211_BAND_5GHZ] = wl18xx_rate_to_idx_5ghz
  125. };
  126. enum wl18xx_hw_rates {
  127. WL18XX_CONF_HW_RXTX_RATE_MCS15 = 0,
  128. WL18XX_CONF_HW_RXTX_RATE_MCS14,
  129. WL18XX_CONF_HW_RXTX_RATE_MCS13,
  130. WL18XX_CONF_HW_RXTX_RATE_MCS12,
  131. WL18XX_CONF_HW_RXTX_RATE_MCS11,
  132. WL18XX_CONF_HW_RXTX_RATE_MCS10,
  133. WL18XX_CONF_HW_RXTX_RATE_MCS9,
  134. WL18XX_CONF_HW_RXTX_RATE_MCS8,
  135. WL18XX_CONF_HW_RXTX_RATE_MCS7,
  136. WL18XX_CONF_HW_RXTX_RATE_MCS6,
  137. WL18XX_CONF_HW_RXTX_RATE_MCS5,
  138. WL18XX_CONF_HW_RXTX_RATE_MCS4,
  139. WL18XX_CONF_HW_RXTX_RATE_MCS3,
  140. WL18XX_CONF_HW_RXTX_RATE_MCS2,
  141. WL18XX_CONF_HW_RXTX_RATE_MCS1,
  142. WL18XX_CONF_HW_RXTX_RATE_MCS0,
  143. WL18XX_CONF_HW_RXTX_RATE_54,
  144. WL18XX_CONF_HW_RXTX_RATE_48,
  145. WL18XX_CONF_HW_RXTX_RATE_36,
  146. WL18XX_CONF_HW_RXTX_RATE_24,
  147. WL18XX_CONF_HW_RXTX_RATE_22,
  148. WL18XX_CONF_HW_RXTX_RATE_18,
  149. WL18XX_CONF_HW_RXTX_RATE_12,
  150. WL18XX_CONF_HW_RXTX_RATE_11,
  151. WL18XX_CONF_HW_RXTX_RATE_9,
  152. WL18XX_CONF_HW_RXTX_RATE_6,
  153. WL18XX_CONF_HW_RXTX_RATE_5_5,
  154. WL18XX_CONF_HW_RXTX_RATE_2,
  155. WL18XX_CONF_HW_RXTX_RATE_1,
  156. WL18XX_CONF_HW_RXTX_RATE_MAX,
  157. };
  158. static struct wlcore_conf wl18xx_conf = {
  159. .sg = {
  160. .params = {
  161. [CONF_SG_ACL_BT_MASTER_MIN_BR] = 10,
  162. [CONF_SG_ACL_BT_MASTER_MAX_BR] = 180,
  163. [CONF_SG_ACL_BT_SLAVE_MIN_BR] = 10,
  164. [CONF_SG_ACL_BT_SLAVE_MAX_BR] = 180,
  165. [CONF_SG_ACL_BT_MASTER_MIN_EDR] = 10,
  166. [CONF_SG_ACL_BT_MASTER_MAX_EDR] = 80,
  167. [CONF_SG_ACL_BT_SLAVE_MIN_EDR] = 10,
  168. [CONF_SG_ACL_BT_SLAVE_MAX_EDR] = 80,
  169. [CONF_SG_ACL_WLAN_PS_MASTER_BR] = 8,
  170. [CONF_SG_ACL_WLAN_PS_SLAVE_BR] = 8,
  171. [CONF_SG_ACL_WLAN_PS_MASTER_EDR] = 20,
  172. [CONF_SG_ACL_WLAN_PS_SLAVE_EDR] = 20,
  173. [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_BR] = 20,
  174. [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_BR] = 35,
  175. [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_BR] = 16,
  176. [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_BR] = 35,
  177. [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MIN_EDR] = 32,
  178. [CONF_SG_ACL_WLAN_ACTIVE_MASTER_MAX_EDR] = 50,
  179. [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MIN_EDR] = 28,
  180. [CONF_SG_ACL_WLAN_ACTIVE_SLAVE_MAX_EDR] = 50,
  181. [CONF_SG_ACL_ACTIVE_SCAN_WLAN_BR] = 10,
  182. [CONF_SG_ACL_ACTIVE_SCAN_WLAN_EDR] = 20,
  183. [CONF_SG_ACL_PASSIVE_SCAN_BT_BR] = 75,
  184. [CONF_SG_ACL_PASSIVE_SCAN_WLAN_BR] = 15,
  185. [CONF_SG_ACL_PASSIVE_SCAN_BT_EDR] = 27,
  186. [CONF_SG_ACL_PASSIVE_SCAN_WLAN_EDR] = 17,
  187. /* active scan params */
  188. [CONF_SG_AUTO_SCAN_PROBE_REQ] = 170,
  189. [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_HV3] = 50,
  190. [CONF_SG_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100,
  191. /* passive scan params */
  192. [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_BR] = 800,
  193. [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_A2DP_EDR] = 200,
  194. [CONF_SG_PASSIVE_SCAN_DURATION_FACTOR_HV3] = 200,
  195. /* passive scan in dual antenna params */
  196. [CONF_SG_CONSECUTIVE_HV3_IN_PASSIVE_SCAN] = 0,
  197. [CONF_SG_BCN_HV3_COLLISION_THRESH_IN_PASSIVE_SCAN] = 0,
  198. [CONF_SG_TX_RX_PROTECTION_BWIDTH_IN_PASSIVE_SCAN] = 0,
  199. /* general params */
  200. [CONF_SG_STA_FORCE_PS_IN_BT_SCO] = 1,
  201. [CONF_SG_ANTENNA_CONFIGURATION] = 0,
  202. [CONF_SG_BEACON_MISS_PERCENT] = 60,
  203. [CONF_SG_DHCP_TIME] = 5000,
  204. [CONF_SG_RXT] = 1200,
  205. [CONF_SG_TXT] = 1000,
  206. [CONF_SG_ADAPTIVE_RXT_TXT] = 1,
  207. [CONF_SG_GENERAL_USAGE_BIT_MAP] = 3,
  208. [CONF_SG_HV3_MAX_SERVED] = 6,
  209. [CONF_SG_PS_POLL_TIMEOUT] = 10,
  210. [CONF_SG_UPSD_TIMEOUT] = 10,
  211. [CONF_SG_CONSECUTIVE_CTS_THRESHOLD] = 2,
  212. [CONF_SG_STA_RX_WINDOW_AFTER_DTIM] = 5,
  213. [CONF_SG_STA_CONNECTION_PROTECTION_TIME] = 30,
  214. /* AP params */
  215. [CONF_AP_BEACON_MISS_TX] = 3,
  216. [CONF_AP_RX_WINDOW_AFTER_BEACON] = 10,
  217. [CONF_AP_BEACON_WINDOW_INTERVAL] = 2,
  218. [CONF_AP_CONNECTION_PROTECTION_TIME] = 0,
  219. [CONF_AP_BT_ACL_VAL_BT_SERVE_TIME] = 25,
  220. [CONF_AP_BT_ACL_VAL_WL_SERVE_TIME] = 25,
  221. /* CTS Diluting params */
  222. [CONF_SG_CTS_DILUTED_BAD_RX_PACKETS_TH] = 0,
  223. [CONF_SG_CTS_CHOP_IN_DUAL_ANT_SCO_MASTER] = 0,
  224. },
  225. .state = CONF_SG_PROTECTIVE,
  226. },
  227. .rx = {
  228. .rx_msdu_life_time = 512000,
  229. .packet_detection_threshold = 0,
  230. .ps_poll_timeout = 15,
  231. .upsd_timeout = 15,
  232. .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD,
  233. .rx_cca_threshold = 0,
  234. .irq_blk_threshold = 0xFFFF,
  235. .irq_pkt_threshold = 0,
  236. .irq_timeout = 600,
  237. .queue_type = CONF_RX_QUEUE_TYPE_LOW_PRIORITY,
  238. },
  239. .tx = {
  240. .tx_energy_detection = 0,
  241. .sta_rc_conf = {
  242. .enabled_rates = 0,
  243. .short_retry_limit = 10,
  244. .long_retry_limit = 10,
  245. .aflags = 0,
  246. },
  247. .ac_conf_count = 4,
  248. .ac_conf = {
  249. [CONF_TX_AC_BE] = {
  250. .ac = CONF_TX_AC_BE,
  251. .cw_min = 15,
  252. .cw_max = 63,
  253. .aifsn = 3,
  254. .tx_op_limit = 0,
  255. },
  256. [CONF_TX_AC_BK] = {
  257. .ac = CONF_TX_AC_BK,
  258. .cw_min = 15,
  259. .cw_max = 63,
  260. .aifsn = 7,
  261. .tx_op_limit = 0,
  262. },
  263. [CONF_TX_AC_VI] = {
  264. .ac = CONF_TX_AC_VI,
  265. .cw_min = 15,
  266. .cw_max = 63,
  267. .aifsn = CONF_TX_AIFS_PIFS,
  268. .tx_op_limit = 3008,
  269. },
  270. [CONF_TX_AC_VO] = {
  271. .ac = CONF_TX_AC_VO,
  272. .cw_min = 15,
  273. .cw_max = 63,
  274. .aifsn = CONF_TX_AIFS_PIFS,
  275. .tx_op_limit = 1504,
  276. },
  277. },
  278. .max_tx_retries = 100,
  279. .ap_aging_period = 300,
  280. .tid_conf_count = 4,
  281. .tid_conf = {
  282. [CONF_TX_AC_BE] = {
  283. .queue_id = CONF_TX_AC_BE,
  284. .channel_type = CONF_CHANNEL_TYPE_EDCF,
  285. .tsid = CONF_TX_AC_BE,
  286. .ps_scheme = CONF_PS_SCHEME_LEGACY,
  287. .ack_policy = CONF_ACK_POLICY_LEGACY,
  288. .apsd_conf = {0, 0},
  289. },
  290. [CONF_TX_AC_BK] = {
  291. .queue_id = CONF_TX_AC_BK,
  292. .channel_type = CONF_CHANNEL_TYPE_EDCF,
  293. .tsid = CONF_TX_AC_BK,
  294. .ps_scheme = CONF_PS_SCHEME_LEGACY,
  295. .ack_policy = CONF_ACK_POLICY_LEGACY,
  296. .apsd_conf = {0, 0},
  297. },
  298. [CONF_TX_AC_VI] = {
  299. .queue_id = CONF_TX_AC_VI,
  300. .channel_type = CONF_CHANNEL_TYPE_EDCF,
  301. .tsid = CONF_TX_AC_VI,
  302. .ps_scheme = CONF_PS_SCHEME_LEGACY,
  303. .ack_policy = CONF_ACK_POLICY_LEGACY,
  304. .apsd_conf = {0, 0},
  305. },
  306. [CONF_TX_AC_VO] = {
  307. .queue_id = CONF_TX_AC_VO,
  308. .channel_type = CONF_CHANNEL_TYPE_EDCF,
  309. .tsid = CONF_TX_AC_VO,
  310. .ps_scheme = CONF_PS_SCHEME_LEGACY,
  311. .ack_policy = CONF_ACK_POLICY_LEGACY,
  312. .apsd_conf = {0, 0},
  313. },
  314. },
  315. .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD,
  316. .tx_compl_timeout = 350,
  317. .tx_compl_threshold = 10,
  318. .basic_rate = CONF_HW_BIT_RATE_1MBPS,
  319. .basic_rate_5 = CONF_HW_BIT_RATE_6MBPS,
  320. .tmpl_short_retry_limit = 10,
  321. .tmpl_long_retry_limit = 10,
  322. .tx_watchdog_timeout = 5000,
  323. },
  324. .conn = {
  325. .wake_up_event = CONF_WAKE_UP_EVENT_DTIM,
  326. .listen_interval = 1,
  327. .suspend_wake_up_event = CONF_WAKE_UP_EVENT_N_DTIM,
  328. .suspend_listen_interval = 3,
  329. .bcn_filt_mode = CONF_BCN_FILT_MODE_ENABLED,
  330. .bcn_filt_ie_count = 3,
  331. .bcn_filt_ie = {
  332. [0] = {
  333. .ie = WLAN_EID_CHANNEL_SWITCH,
  334. .rule = CONF_BCN_RULE_PASS_ON_APPEARANCE,
  335. },
  336. [1] = {
  337. .ie = WLAN_EID_HT_OPERATION,
  338. .rule = CONF_BCN_RULE_PASS_ON_CHANGE,
  339. },
  340. [2] = {
  341. .ie = WLAN_EID_ERP_INFO,
  342. .rule = CONF_BCN_RULE_PASS_ON_CHANGE,
  343. },
  344. },
  345. .synch_fail_thold = 12,
  346. .bss_lose_timeout = 400,
  347. .beacon_rx_timeout = 10000,
  348. .broadcast_timeout = 20000,
  349. .rx_broadcast_in_ps = 1,
  350. .ps_poll_threshold = 10,
  351. .bet_enable = CONF_BET_MODE_ENABLE,
  352. .bet_max_consecutive = 50,
  353. .psm_entry_retries = 8,
  354. .psm_exit_retries = 16,
  355. .psm_entry_nullfunc_retries = 3,
  356. .dynamic_ps_timeout = 1500,
  357. .forced_ps = false,
  358. .keep_alive_interval = 55000,
  359. .max_listen_interval = 20,
  360. .sta_sleep_auth = WL1271_PSM_ILLEGAL,
  361. },
  362. .itrim = {
  363. .enable = false,
  364. .timeout = 50000,
  365. },
  366. .pm_config = {
  367. .host_clk_settling_time = 5000,
  368. .host_fast_wakeup_support = CONF_FAST_WAKEUP_DISABLE,
  369. },
  370. .roam_trigger = {
  371. .trigger_pacing = 1,
  372. .avg_weight_rssi_beacon = 20,
  373. .avg_weight_rssi_data = 10,
  374. .avg_weight_snr_beacon = 20,
  375. .avg_weight_snr_data = 10,
  376. },
  377. .scan = {
  378. .min_dwell_time_active = 7500,
  379. .max_dwell_time_active = 30000,
  380. .min_dwell_time_passive = 100000,
  381. .max_dwell_time_passive = 100000,
  382. .num_probe_reqs = 2,
  383. .split_scan_timeout = 50000,
  384. },
  385. .sched_scan = {
  386. /*
  387. * Values are in TU/1000 but since sched scan FW command
  388. * params are in TUs rounding up may occur.
  389. */
  390. .base_dwell_time = 7500,
  391. .max_dwell_time_delta = 22500,
  392. /* based on 250bits per probe @1Mbps */
  393. .dwell_time_delta_per_probe = 2000,
  394. /* based on 250bits per probe @6Mbps (plus a bit more) */
  395. .dwell_time_delta_per_probe_5 = 350,
  396. .dwell_time_passive = 100000,
  397. .dwell_time_dfs = 150000,
  398. .num_probe_reqs = 2,
  399. .rssi_threshold = -90,
  400. .snr_threshold = 0,
  401. },
  402. .ht = {
  403. .rx_ba_win_size = 32,
  404. .tx_ba_win_size = 64,
  405. .inactivity_timeout = 10000,
  406. .tx_ba_tid_bitmap = CONF_TX_BA_ENABLED_TID_BITMAP,
  407. },
  408. .mem = {
  409. .num_stations = 1,
  410. .ssid_profiles = 1,
  411. .rx_block_num = 40,
  412. .tx_min_block_num = 40,
  413. .dynamic_memory = 1,
  414. .min_req_tx_blocks = 45,
  415. .min_req_rx_blocks = 22,
  416. .tx_min = 27,
  417. },
  418. .fm_coex = {
  419. .enable = true,
  420. .swallow_period = 5,
  421. .n_divider_fref_set_1 = 0xff, /* default */
  422. .n_divider_fref_set_2 = 12,
  423. .m_divider_fref_set_1 = 0xffff,
  424. .m_divider_fref_set_2 = 148, /* default */
  425. .coex_pll_stabilization_time = 0xffffffff, /* default */
  426. .ldo_stabilization_time = 0xffff, /* default */
  427. .fm_disturbed_band_margin = 0xff, /* default */
  428. .swallow_clk_diff = 0xff, /* default */
  429. },
  430. .rx_streaming = {
  431. .duration = 150,
  432. .queues = 0x1,
  433. .interval = 20,
  434. .always = 0,
  435. },
  436. .fwlog = {
  437. .mode = WL12XX_FWLOG_ON_DEMAND,
  438. .mem_blocks = 2,
  439. .severity = 0,
  440. .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED,
  441. .output = WL12XX_FWLOG_OUTPUT_HOST,
  442. .threshold = 0,
  443. },
  444. .rate = {
  445. .rate_retry_score = 32000,
  446. .per_add = 8192,
  447. .per_th1 = 2048,
  448. .per_th2 = 4096,
  449. .max_per = 8100,
  450. .inverse_curiosity_factor = 5,
  451. .tx_fail_low_th = 4,
  452. .tx_fail_high_th = 10,
  453. .per_alpha_shift = 4,
  454. .per_add_shift = 13,
  455. .per_beta1_shift = 10,
  456. .per_beta2_shift = 8,
  457. .rate_check_up = 2,
  458. .rate_check_down = 12,
  459. .rate_retry_policy = {
  460. 0x00, 0x00, 0x00, 0x00, 0x00,
  461. 0x00, 0x00, 0x00, 0x00, 0x00,
  462. 0x00, 0x00, 0x00,
  463. },
  464. },
  465. .hangover = {
  466. .recover_time = 0,
  467. .hangover_period = 20,
  468. .dynamic_mode = 1,
  469. .early_termination_mode = 1,
  470. .max_period = 20,
  471. .min_period = 1,
  472. .increase_delta = 1,
  473. .decrease_delta = 2,
  474. .quiet_time = 4,
  475. .increase_time = 1,
  476. .window_size = 16,
  477. },
  478. };
  479. static struct wl18xx_priv_conf wl18xx_default_priv_conf = {
  480. .ht = {
  481. .mode = HT_MODE_DEFAULT,
  482. },
  483. .phy = {
  484. .phy_standalone = 0x00,
  485. .primary_clock_setting_time = 0x05,
  486. .clock_valid_on_wake_up = 0x00,
  487. .secondary_clock_setting_time = 0x05,
  488. .board_type = BOARD_TYPE_HDK_18XX,
  489. .rdl = 0x01,
  490. .auto_detect = 0x00,
  491. .dedicated_fem = FEM_NONE,
  492. .low_band_component = COMPONENT_3_WAY_SWITCH,
  493. .low_band_component_type = 0x04,
  494. .high_band_component = COMPONENT_2_WAY_SWITCH,
  495. .high_band_component_type = 0x09,
  496. .tcxo_ldo_voltage = 0x00,
  497. .xtal_itrim_val = 0x04,
  498. .srf_state = 0x00,
  499. .io_configuration = 0x01,
  500. .sdio_configuration = 0x00,
  501. .settings = 0x00,
  502. .enable_clpc = 0x00,
  503. .enable_tx_low_pwr_on_siso_rdl = 0x00,
  504. .rx_profile = 0x00,
  505. .pwr_limit_reference_11_abg = 0xc8,
  506. .psat = 0,
  507. .low_power_val = 0x00,
  508. .med_power_val = 0x0a,
  509. .high_power_val = 0x1e,
  510. .external_pa_dc2dc = 0,
  511. .number_of_assembled_ant2_4 = 1,
  512. .number_of_assembled_ant5 = 1,
  513. },
  514. };
  515. static const struct wlcore_partition_set wl18xx_ptable[PART_TABLE_LEN] = {
  516. [PART_TOP_PRCM_ELP_SOC] = {
  517. .mem = { .start = 0x00A02000, .size = 0x00010000 },
  518. .reg = { .start = 0x00807000, .size = 0x00005000 },
  519. .mem2 = { .start = 0x00800000, .size = 0x0000B000 },
  520. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  521. },
  522. [PART_DOWN] = {
  523. .mem = { .start = 0x00000000, .size = 0x00014000 },
  524. .reg = { .start = 0x00810000, .size = 0x0000BFFF },
  525. .mem2 = { .start = 0x00000000, .size = 0x00000000 },
  526. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  527. },
  528. [PART_BOOT] = {
  529. .mem = { .start = 0x00700000, .size = 0x0000030c },
  530. .reg = { .start = 0x00802000, .size = 0x00014578 },
  531. .mem2 = { .start = 0x00B00404, .size = 0x00001000 },
  532. .mem3 = { .start = 0x00C00000, .size = 0x00000400 },
  533. },
  534. [PART_WORK] = {
  535. .mem = { .start = 0x00800000, .size = 0x000050FC },
  536. .reg = { .start = 0x00B00404, .size = 0x00001000 },
  537. .mem2 = { .start = 0x00C00000, .size = 0x00000400 },
  538. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  539. },
  540. [PART_PHY_INIT] = {
  541. .mem = { .start = 0x80926000,
  542. .size = sizeof(struct wl18xx_mac_and_phy_params) },
  543. .reg = { .start = 0x00000000, .size = 0x00000000 },
  544. .mem2 = { .start = 0x00000000, .size = 0x00000000 },
  545. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  546. },
  547. };
  548. static const int wl18xx_rtable[REG_TABLE_LEN] = {
  549. [REG_ECPU_CONTROL] = WL18XX_REG_ECPU_CONTROL,
  550. [REG_INTERRUPT_NO_CLEAR] = WL18XX_REG_INTERRUPT_NO_CLEAR,
  551. [REG_INTERRUPT_ACK] = WL18XX_REG_INTERRUPT_ACK,
  552. [REG_COMMAND_MAILBOX_PTR] = WL18XX_REG_COMMAND_MAILBOX_PTR,
  553. [REG_EVENT_MAILBOX_PTR] = WL18XX_REG_EVENT_MAILBOX_PTR,
  554. [REG_INTERRUPT_TRIG] = WL18XX_REG_INTERRUPT_TRIG_H,
  555. [REG_INTERRUPT_MASK] = WL18XX_REG_INTERRUPT_MASK,
  556. [REG_PC_ON_RECOVERY] = WL18XX_SCR_PAD4,
  557. [REG_CHIP_ID_B] = WL18XX_REG_CHIP_ID_B,
  558. [REG_CMD_MBOX_ADDRESS] = WL18XX_CMD_MBOX_ADDRESS,
  559. /* data access memory addresses, used with partition translation */
  560. [REG_SLV_MEM_DATA] = WL18XX_SLV_MEM_DATA,
  561. [REG_SLV_REG_DATA] = WL18XX_SLV_REG_DATA,
  562. /* raw data access memory addresses */
  563. [REG_RAW_FW_STATUS_ADDR] = WL18XX_FW_STATUS_ADDR,
  564. };
  565. static const struct wl18xx_clk_cfg wl18xx_clk_table[NUM_CLOCK_CONFIGS] = {
  566. [CLOCK_CONFIG_16_2_M] = { 7, 104, 801, 4, true },
  567. [CLOCK_CONFIG_16_368_M] = { 9, 132, 3751, 4, true },
  568. [CLOCK_CONFIG_16_8_M] = { 7, 100, 0, 0, false },
  569. [CLOCK_CONFIG_19_2_M] = { 8, 100, 0, 0, false },
  570. [CLOCK_CONFIG_26_M] = { 13, 120, 0, 0, false },
  571. [CLOCK_CONFIG_32_736_M] = { 9, 132, 3751, 4, true },
  572. [CLOCK_CONFIG_33_6_M] = { 7, 100, 0, 0, false },
  573. [CLOCK_CONFIG_38_468_M] = { 8, 100, 0, 0, false },
  574. [CLOCK_CONFIG_52_M] = { 13, 120, 0, 0, false },
  575. };
  576. /* TODO: maybe move to a new header file? */
  577. #define WL18XX_FW_NAME "ti-connectivity/wl18xx-fw-2.bin"
  578. static int wl18xx_identify_chip(struct wl1271 *wl)
  579. {
  580. int ret = 0;
  581. switch (wl->chip.id) {
  582. case CHIP_ID_185x_PG20:
  583. wl1271_debug(DEBUG_BOOT, "chip id 0x%x (185x PG20)",
  584. wl->chip.id);
  585. wl->sr_fw_name = WL18XX_FW_NAME;
  586. /* wl18xx uses the same firmware for PLT */
  587. wl->plt_fw_name = WL18XX_FW_NAME;
  588. wl->quirks |= WLCORE_QUIRK_NO_ELP |
  589. WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN |
  590. WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN |
  591. WLCORE_QUIRK_NO_SCHED_SCAN_WHILE_CONN |
  592. WLCORE_QUIRK_TX_PAD_LAST_FRAME |
  593. WLCORE_QUIRK_REGDOMAIN_CONF |
  594. WLCORE_QUIRK_DUAL_PROBE_TMPL;
  595. wlcore_set_min_fw_ver(wl, WL18XX_CHIP_VER, WL18XX_IFTYPE_VER,
  596. WL18XX_MAJOR_VER, WL18XX_SUBTYPE_VER,
  597. WL18XX_MINOR_VER);
  598. break;
  599. case CHIP_ID_185x_PG10:
  600. wl1271_warning("chip id 0x%x (185x PG10) is deprecated",
  601. wl->chip.id);
  602. ret = -ENODEV;
  603. goto out;
  604. default:
  605. wl1271_warning("unsupported chip id: 0x%x", wl->chip.id);
  606. ret = -ENODEV;
  607. goto out;
  608. }
  609. wl->scan_templ_id_2_4 = CMD_TEMPL_CFG_PROBE_REQ_2_4;
  610. wl->scan_templ_id_5 = CMD_TEMPL_CFG_PROBE_REQ_5;
  611. wl->sched_scan_templ_id_2_4 = CMD_TEMPL_PROBE_REQ_2_4_PERIODIC;
  612. wl->sched_scan_templ_id_5 = CMD_TEMPL_PROBE_REQ_5_PERIODIC;
  613. wl->max_channels_5 = WL18XX_MAX_CHANNELS_5GHZ;
  614. out:
  615. return ret;
  616. }
  617. static int wl18xx_set_clk(struct wl1271 *wl)
  618. {
  619. u16 clk_freq;
  620. int ret;
  621. ret = wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
  622. if (ret < 0)
  623. goto out;
  624. /* TODO: PG2: apparently we need to read the clk type */
  625. ret = wl18xx_top_reg_read(wl, PRIMARY_CLK_DETECT, &clk_freq);
  626. if (ret < 0)
  627. goto out;
  628. wl1271_debug(DEBUG_BOOT, "clock freq %d (%d, %d, %d, %d, %s)", clk_freq,
  629. wl18xx_clk_table[clk_freq].n, wl18xx_clk_table[clk_freq].m,
  630. wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q,
  631. wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit");
  632. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N,
  633. wl18xx_clk_table[clk_freq].n);
  634. if (ret < 0)
  635. goto out;
  636. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_M,
  637. wl18xx_clk_table[clk_freq].m);
  638. if (ret < 0)
  639. goto out;
  640. if (wl18xx_clk_table[clk_freq].swallow) {
  641. /* first the 16 lower bits */
  642. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_1,
  643. wl18xx_clk_table[clk_freq].q &
  644. PLLSH_WCS_PLL_Q_FACTOR_CFG_1_MASK);
  645. if (ret < 0)
  646. goto out;
  647. /* then the 16 higher bits, masked out */
  648. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_2,
  649. (wl18xx_clk_table[clk_freq].q >> 16) &
  650. PLLSH_WCS_PLL_Q_FACTOR_CFG_2_MASK);
  651. if (ret < 0)
  652. goto out;
  653. /* first the 16 lower bits */
  654. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_1,
  655. wl18xx_clk_table[clk_freq].p &
  656. PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK);
  657. if (ret < 0)
  658. goto out;
  659. /* then the 16 higher bits, masked out */
  660. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2,
  661. (wl18xx_clk_table[clk_freq].p >> 16) &
  662. PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK);
  663. } else {
  664. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN,
  665. PLLSH_WCS_PLL_SWALLOW_EN_VAL2);
  666. }
  667. out:
  668. return ret;
  669. }
  670. static int wl18xx_boot_soft_reset(struct wl1271 *wl)
  671. {
  672. int ret;
  673. /* disable Rx/Tx */
  674. ret = wlcore_write32(wl, WL18XX_ENABLE, 0x0);
  675. if (ret < 0)
  676. goto out;
  677. /* disable auto calibration on start*/
  678. ret = wlcore_write32(wl, WL18XX_SPARE_A2, 0xffff);
  679. out:
  680. return ret;
  681. }
  682. static int wl18xx_pre_boot(struct wl1271 *wl)
  683. {
  684. int ret;
  685. ret = wl18xx_set_clk(wl);
  686. if (ret < 0)
  687. goto out;
  688. /* Continue the ELP wake up sequence */
  689. ret = wlcore_write32(wl, WL18XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
  690. if (ret < 0)
  691. goto out;
  692. udelay(500);
  693. ret = wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  694. if (ret < 0)
  695. goto out;
  696. /* Disable interrupts */
  697. ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL);
  698. if (ret < 0)
  699. goto out;
  700. ret = wl18xx_boot_soft_reset(wl);
  701. out:
  702. return ret;
  703. }
  704. static int wl18xx_pre_upload(struct wl1271 *wl)
  705. {
  706. u32 tmp;
  707. int ret;
  708. ret = wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  709. if (ret < 0)
  710. goto out;
  711. /* TODO: check if this is all needed */
  712. ret = wlcore_write32(wl, WL18XX_EEPROMLESS_IND, WL18XX_EEPROMLESS_IND);
  713. if (ret < 0)
  714. goto out;
  715. ret = wlcore_read_reg(wl, REG_CHIP_ID_B, &tmp);
  716. if (ret < 0)
  717. goto out;
  718. wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp);
  719. ret = wlcore_read32(wl, WL18XX_SCR_PAD2, &tmp);
  720. out:
  721. return ret;
  722. }
  723. static int wl18xx_set_mac_and_phy(struct wl1271 *wl)
  724. {
  725. struct wl18xx_priv *priv = wl->priv;
  726. struct wl18xx_mac_and_phy_params *params;
  727. int ret;
  728. params = kmemdup(&priv->conf.phy, sizeof(*params), GFP_KERNEL);
  729. if (!params) {
  730. ret = -ENOMEM;
  731. goto out;
  732. }
  733. ret = wlcore_set_partition(wl, &wl->ptable[PART_PHY_INIT]);
  734. if (ret < 0)
  735. goto out;
  736. ret = wlcore_write(wl, WL18XX_PHY_INIT_MEM_ADDR, params,
  737. sizeof(*params), false);
  738. out:
  739. kfree(params);
  740. return ret;
  741. }
  742. static int wl18xx_enable_interrupts(struct wl1271 *wl)
  743. {
  744. u32 event_mask, intr_mask;
  745. int ret;
  746. event_mask = WL18XX_ACX_EVENTS_VECTOR;
  747. intr_mask = WL18XX_INTR_MASK;
  748. ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK, event_mask);
  749. if (ret < 0)
  750. goto out;
  751. wlcore_enable_interrupts(wl);
  752. ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK,
  753. WL1271_ACX_INTR_ALL & ~intr_mask);
  754. if (ret < 0)
  755. goto disable_interrupts;
  756. return ret;
  757. disable_interrupts:
  758. wlcore_disable_interrupts(wl);
  759. out:
  760. return ret;
  761. }
  762. static int wl18xx_boot(struct wl1271 *wl)
  763. {
  764. int ret;
  765. ret = wl18xx_pre_boot(wl);
  766. if (ret < 0)
  767. goto out;
  768. ret = wl18xx_pre_upload(wl);
  769. if (ret < 0)
  770. goto out;
  771. ret = wlcore_boot_upload_firmware(wl);
  772. if (ret < 0)
  773. goto out;
  774. ret = wl18xx_set_mac_and_phy(wl);
  775. if (ret < 0)
  776. goto out;
  777. wl->event_mask = BSS_LOSS_EVENT_ID |
  778. SCAN_COMPLETE_EVENT_ID |
  779. RSSI_SNR_TRIGGER_0_EVENT_ID |
  780. PERIODIC_SCAN_COMPLETE_EVENT_ID |
  781. DUMMY_PACKET_EVENT_ID |
  782. PEER_REMOVE_COMPLETE_EVENT_ID |
  783. BA_SESSION_RX_CONSTRAINT_EVENT_ID |
  784. REMAIN_ON_CHANNEL_COMPLETE_EVENT_ID |
  785. INACTIVE_STA_EVENT_ID |
  786. MAX_TX_FAILURE_EVENT_ID |
  787. CHANNEL_SWITCH_COMPLETE_EVENT_ID |
  788. DFS_CHANNELS_CONFIG_COMPLETE_EVENT;
  789. ret = wlcore_boot_run_firmware(wl);
  790. if (ret < 0)
  791. goto out;
  792. ret = wl18xx_enable_interrupts(wl);
  793. out:
  794. return ret;
  795. }
  796. static int wl18xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr,
  797. void *buf, size_t len)
  798. {
  799. struct wl18xx_priv *priv = wl->priv;
  800. memcpy(priv->cmd_buf, buf, len);
  801. memset(priv->cmd_buf + len, 0, WL18XX_CMD_MAX_SIZE - len);
  802. return wlcore_write(wl, cmd_box_addr, priv->cmd_buf,
  803. WL18XX_CMD_MAX_SIZE, false);
  804. }
  805. static int wl18xx_ack_event(struct wl1271 *wl)
  806. {
  807. return wlcore_write_reg(wl, REG_INTERRUPT_TRIG,
  808. WL18XX_INTR_TRIG_EVENT_ACK);
  809. }
  810. static u32 wl18xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
  811. {
  812. u32 blk_size = WL18XX_TX_HW_BLOCK_SIZE;
  813. return (len + blk_size - 1) / blk_size + spare_blks;
  814. }
  815. static void
  816. wl18xx_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
  817. u32 blks, u32 spare_blks)
  818. {
  819. desc->wl18xx_mem.total_mem_blocks = blks;
  820. }
  821. static void
  822. wl18xx_set_tx_desc_data_len(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
  823. struct sk_buff *skb)
  824. {
  825. desc->length = cpu_to_le16(skb->len);
  826. /* if only the last frame is to be padded, we unset this bit on Tx */
  827. if (wl->quirks & WLCORE_QUIRK_TX_PAD_LAST_FRAME)
  828. desc->wl18xx_mem.ctrl = WL18XX_TX_CTRL_NOT_PADDED;
  829. else
  830. desc->wl18xx_mem.ctrl = 0;
  831. wl1271_debug(DEBUG_TX, "tx_fill_hdr: hlid: %d "
  832. "len: %d life: %d mem: %d", desc->hlid,
  833. le16_to_cpu(desc->length),
  834. le16_to_cpu(desc->life_time),
  835. desc->wl18xx_mem.total_mem_blocks);
  836. }
  837. static enum wl_rx_buf_align
  838. wl18xx_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)
  839. {
  840. if (rx_desc & RX_BUF_PADDED_PAYLOAD)
  841. return WLCORE_RX_BUF_PADDED;
  842. return WLCORE_RX_BUF_ALIGNED;
  843. }
  844. static u32 wl18xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data,
  845. u32 data_len)
  846. {
  847. struct wl1271_rx_descriptor *desc = rx_data;
  848. /* invalid packet */
  849. if (data_len < sizeof(*desc))
  850. return 0;
  851. return data_len - sizeof(*desc);
  852. }
  853. static void wl18xx_tx_immediate_completion(struct wl1271 *wl)
  854. {
  855. wl18xx_tx_immediate_complete(wl);
  856. }
  857. static int wl18xx_set_host_cfg_bitmap(struct wl1271 *wl, u32 extra_mem_blk)
  858. {
  859. int ret;
  860. u32 sdio_align_size = 0;
  861. u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE |
  862. HOST_IF_CFG_ADD_RX_ALIGNMENT;
  863. /* Enable Tx SDIO padding */
  864. if (wl->quirks & WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN) {
  865. host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
  866. sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
  867. }
  868. /* Enable Rx SDIO padding */
  869. if (wl->quirks & WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN) {
  870. host_cfg_bitmap |= HOST_IF_CFG_RX_PAD_TO_SDIO_BLK;
  871. sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
  872. }
  873. ret = wl18xx_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap,
  874. sdio_align_size, extra_mem_blk,
  875. WL18XX_HOST_IF_LEN_SIZE_FIELD);
  876. if (ret < 0)
  877. return ret;
  878. return 0;
  879. }
  880. static int wl18xx_hw_init(struct wl1271 *wl)
  881. {
  882. int ret;
  883. struct wl18xx_priv *priv = wl->priv;
  884. /* (re)init private structures. Relevant on recovery as well. */
  885. priv->last_fw_rls_idx = 0;
  886. priv->extra_spare_vif_count = 0;
  887. /* set the default amount of spare blocks in the bitmap */
  888. ret = wl18xx_set_host_cfg_bitmap(wl, WL18XX_TX_HW_BLOCK_SPARE);
  889. if (ret < 0)
  890. return ret;
  891. if (checksum_param) {
  892. ret = wl18xx_acx_set_checksum_state(wl);
  893. if (ret != 0)
  894. return ret;
  895. }
  896. return ret;
  897. }
  898. static void wl18xx_set_tx_desc_csum(struct wl1271 *wl,
  899. struct wl1271_tx_hw_descr *desc,
  900. struct sk_buff *skb)
  901. {
  902. u32 ip_hdr_offset;
  903. struct iphdr *ip_hdr;
  904. if (!checksum_param) {
  905. desc->wl18xx_checksum_data = 0;
  906. return;
  907. }
  908. if (skb->ip_summed != CHECKSUM_PARTIAL) {
  909. desc->wl18xx_checksum_data = 0;
  910. return;
  911. }
  912. ip_hdr_offset = skb_network_header(skb) - skb_mac_header(skb);
  913. if (WARN_ON(ip_hdr_offset >= (1<<7))) {
  914. desc->wl18xx_checksum_data = 0;
  915. return;
  916. }
  917. desc->wl18xx_checksum_data = ip_hdr_offset << 1;
  918. /* FW is interested only in the LSB of the protocol TCP=0 UDP=1 */
  919. ip_hdr = (void *)skb_network_header(skb);
  920. desc->wl18xx_checksum_data |= (ip_hdr->protocol & 0x01);
  921. }
  922. static void wl18xx_set_rx_csum(struct wl1271 *wl,
  923. struct wl1271_rx_descriptor *desc,
  924. struct sk_buff *skb)
  925. {
  926. if (desc->status & WL18XX_RX_CHECKSUM_MASK)
  927. skb->ip_summed = CHECKSUM_UNNECESSARY;
  928. }
  929. static bool wl18xx_is_mimo_supported(struct wl1271 *wl)
  930. {
  931. struct wl18xx_priv *priv = wl->priv;
  932. return priv->conf.phy.number_of_assembled_ant2_4 >= 2;
  933. }
  934. /*
  935. * TODO: instead of having these two functions to get the rate mask,
  936. * we should modify the wlvif->rate_set instead
  937. */
  938. static u32 wl18xx_sta_get_ap_rate_mask(struct wl1271 *wl,
  939. struct wl12xx_vif *wlvif)
  940. {
  941. u32 hw_rate_set = wlvif->rate_set;
  942. if (wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
  943. wlvif->channel_type == NL80211_CHAN_HT40PLUS) {
  944. wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
  945. hw_rate_set |= CONF_TX_RATE_USE_WIDE_CHAN;
  946. /* we don't support MIMO in wide-channel mode */
  947. hw_rate_set &= ~CONF_TX_MIMO_RATES;
  948. } else if (wl18xx_is_mimo_supported(wl)) {
  949. wl1271_debug(DEBUG_ACX, "using MIMO channel rate mask");
  950. hw_rate_set |= CONF_TX_MIMO_RATES;
  951. }
  952. return hw_rate_set;
  953. }
  954. static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
  955. struct wl12xx_vif *wlvif)
  956. {
  957. if (wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
  958. wlvif->channel_type == NL80211_CHAN_HT40PLUS) {
  959. wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
  960. /* sanity check - we don't support this */
  961. if (WARN_ON(wlvif->band != IEEE80211_BAND_5GHZ))
  962. return 0;
  963. return CONF_TX_RATE_USE_WIDE_CHAN;
  964. } else if (wl18xx_is_mimo_supported(wl) &&
  965. wlvif->band == IEEE80211_BAND_2GHZ) {
  966. wl1271_debug(DEBUG_ACX, "using MIMO rate mask");
  967. /*
  968. * we don't care about HT channel here - if a peer doesn't
  969. * support MIMO, we won't enable it in its rates
  970. */
  971. return CONF_TX_MIMO_RATES;
  972. } else {
  973. return 0;
  974. }
  975. }
  976. static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver)
  977. {
  978. u32 fuse;
  979. int ret;
  980. ret = wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
  981. if (ret < 0)
  982. goto out;
  983. ret = wlcore_read32(wl, WL18XX_REG_FUSE_DATA_1_3, &fuse);
  984. if (ret < 0)
  985. goto out;
  986. if (ver)
  987. *ver = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET;
  988. ret = wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  989. out:
  990. return ret;
  991. }
  992. #define WL18XX_CONF_FILE_NAME "ti-connectivity/wl18xx-conf.bin"
  993. static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev)
  994. {
  995. struct wl18xx_priv *priv = wl->priv;
  996. struct wlcore_conf_file *conf_file;
  997. const struct firmware *fw;
  998. int ret;
  999. ret = request_firmware(&fw, WL18XX_CONF_FILE_NAME, dev);
  1000. if (ret < 0) {
  1001. wl1271_error("could not get configuration binary %s: %d",
  1002. WL18XX_CONF_FILE_NAME, ret);
  1003. goto out_fallback;
  1004. }
  1005. if (fw->size != WL18XX_CONF_SIZE) {
  1006. wl1271_error("configuration binary file size is wrong, expected %zu got %zu",
  1007. WL18XX_CONF_SIZE, fw->size);
  1008. ret = -EINVAL;
  1009. goto out;
  1010. }
  1011. conf_file = (struct wlcore_conf_file *) fw->data;
  1012. if (conf_file->header.magic != cpu_to_le32(WL18XX_CONF_MAGIC)) {
  1013. wl1271_error("configuration binary file magic number mismatch, "
  1014. "expected 0x%0x got 0x%0x", WL18XX_CONF_MAGIC,
  1015. conf_file->header.magic);
  1016. ret = -EINVAL;
  1017. goto out;
  1018. }
  1019. if (conf_file->header.version != cpu_to_le32(WL18XX_CONF_VERSION)) {
  1020. wl1271_error("configuration binary file version not supported, "
  1021. "expected 0x%08x got 0x%08x",
  1022. WL18XX_CONF_VERSION, conf_file->header.version);
  1023. ret = -EINVAL;
  1024. goto out;
  1025. }
  1026. memcpy(&wl->conf, &conf_file->core, sizeof(wl18xx_conf));
  1027. memcpy(&priv->conf, &conf_file->priv, sizeof(priv->conf));
  1028. goto out;
  1029. out_fallback:
  1030. wl1271_warning("falling back to default config");
  1031. /* apply driver default configuration */
  1032. memcpy(&wl->conf, &wl18xx_conf, sizeof(wl18xx_conf));
  1033. /* apply default private configuration */
  1034. memcpy(&priv->conf, &wl18xx_default_priv_conf, sizeof(priv->conf));
  1035. /* For now we just fallback */
  1036. return 0;
  1037. out:
  1038. release_firmware(fw);
  1039. return ret;
  1040. }
  1041. static int wl18xx_plt_init(struct wl1271 *wl)
  1042. {
  1043. int ret;
  1044. /* calibrator based auto/fem detect not supported for 18xx */
  1045. if (wl->plt_mode == PLT_FEM_DETECT) {
  1046. wl1271_error("wl18xx_plt_init: PLT FEM_DETECT not supported");
  1047. return -EINVAL;
  1048. }
  1049. ret = wlcore_write32(wl, WL18XX_SCR_PAD8, WL18XX_SCR_PAD8_PLT);
  1050. if (ret < 0)
  1051. return ret;
  1052. return wl->ops->boot(wl);
  1053. }
  1054. static int wl18xx_get_mac(struct wl1271 *wl)
  1055. {
  1056. u32 mac1, mac2;
  1057. int ret;
  1058. ret = wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
  1059. if (ret < 0)
  1060. goto out;
  1061. ret = wlcore_read32(wl, WL18XX_REG_FUSE_BD_ADDR_1, &mac1);
  1062. if (ret < 0)
  1063. goto out;
  1064. ret = wlcore_read32(wl, WL18XX_REG_FUSE_BD_ADDR_2, &mac2);
  1065. if (ret < 0)
  1066. goto out;
  1067. /* these are the two parts of the BD_ADDR */
  1068. wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) +
  1069. ((mac1 & 0xff000000) >> 24);
  1070. wl->fuse_nic_addr = (mac1 & 0xffffff);
  1071. ret = wlcore_set_partition(wl, &wl->ptable[PART_DOWN]);
  1072. out:
  1073. return ret;
  1074. }
  1075. static int wl18xx_handle_static_data(struct wl1271 *wl,
  1076. struct wl1271_static_data *static_data)
  1077. {
  1078. struct wl18xx_static_data_priv *static_data_priv =
  1079. (struct wl18xx_static_data_priv *) static_data->priv;
  1080. strncpy(wl->chip.phy_fw_ver_str, static_data_priv->phy_version,
  1081. sizeof(wl->chip.phy_fw_ver_str));
  1082. /* make sure the string is NULL-terminated */
  1083. wl->chip.phy_fw_ver_str[sizeof(wl->chip.phy_fw_ver_str) - 1] = '\0';
  1084. wl1271_info("PHY firmware version: %s", static_data_priv->phy_version);
  1085. return 0;
  1086. }
  1087. static int wl18xx_get_spare_blocks(struct wl1271 *wl, bool is_gem)
  1088. {
  1089. struct wl18xx_priv *priv = wl->priv;
  1090. /* If we have VIFs requiring extra spare, indulge them */
  1091. if (priv->extra_spare_vif_count)
  1092. return WL18XX_TX_HW_EXTRA_BLOCK_SPARE;
  1093. return WL18XX_TX_HW_BLOCK_SPARE;
  1094. }
  1095. static int wl18xx_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
  1096. struct ieee80211_vif *vif,
  1097. struct ieee80211_sta *sta,
  1098. struct ieee80211_key_conf *key_conf)
  1099. {
  1100. struct wl18xx_priv *priv = wl->priv;
  1101. bool change_spare = false;
  1102. int ret;
  1103. /*
  1104. * when adding the first or removing the last GEM/TKIP interface,
  1105. * we have to adjust the number of spare blocks.
  1106. */
  1107. change_spare = (key_conf->cipher == WL1271_CIPHER_SUITE_GEM ||
  1108. key_conf->cipher == WLAN_CIPHER_SUITE_TKIP) &&
  1109. ((priv->extra_spare_vif_count == 0 && cmd == SET_KEY) ||
  1110. (priv->extra_spare_vif_count == 1 && cmd == DISABLE_KEY));
  1111. /* no need to change spare - just regular set_key */
  1112. if (!change_spare)
  1113. return wlcore_set_key(wl, cmd, vif, sta, key_conf);
  1114. ret = wlcore_set_key(wl, cmd, vif, sta, key_conf);
  1115. if (ret < 0)
  1116. goto out;
  1117. /* key is now set, change the spare blocks */
  1118. if (cmd == SET_KEY) {
  1119. ret = wl18xx_set_host_cfg_bitmap(wl,
  1120. WL18XX_TX_HW_EXTRA_BLOCK_SPARE);
  1121. if (ret < 0)
  1122. goto out;
  1123. priv->extra_spare_vif_count++;
  1124. } else {
  1125. ret = wl18xx_set_host_cfg_bitmap(wl,
  1126. WL18XX_TX_HW_BLOCK_SPARE);
  1127. if (ret < 0)
  1128. goto out;
  1129. priv->extra_spare_vif_count--;
  1130. }
  1131. out:
  1132. return ret;
  1133. }
  1134. static u32 wl18xx_pre_pkt_send(struct wl1271 *wl,
  1135. u32 buf_offset, u32 last_len)
  1136. {
  1137. if (wl->quirks & WLCORE_QUIRK_TX_PAD_LAST_FRAME) {
  1138. struct wl1271_tx_hw_descr *last_desc;
  1139. /* get the last TX HW descriptor written to the aggr buf */
  1140. last_desc = (struct wl1271_tx_hw_descr *)(wl->aggr_buf +
  1141. buf_offset - last_len);
  1142. /* the last frame is padded up to an SDIO block */
  1143. last_desc->wl18xx_mem.ctrl &= ~WL18XX_TX_CTRL_NOT_PADDED;
  1144. return ALIGN(buf_offset, WL12XX_BUS_BLOCK_SIZE);
  1145. }
  1146. /* no modifications */
  1147. return buf_offset;
  1148. }
  1149. static int wl18xx_setup(struct wl1271 *wl);
  1150. static struct wlcore_ops wl18xx_ops = {
  1151. .setup = wl18xx_setup,
  1152. .identify_chip = wl18xx_identify_chip,
  1153. .boot = wl18xx_boot,
  1154. .plt_init = wl18xx_plt_init,
  1155. .trigger_cmd = wl18xx_trigger_cmd,
  1156. .ack_event = wl18xx_ack_event,
  1157. .wait_for_event = wl18xx_wait_for_event,
  1158. .process_mailbox_events = wl18xx_process_mailbox_events,
  1159. .calc_tx_blocks = wl18xx_calc_tx_blocks,
  1160. .set_tx_desc_blocks = wl18xx_set_tx_desc_blocks,
  1161. .set_tx_desc_data_len = wl18xx_set_tx_desc_data_len,
  1162. .get_rx_buf_align = wl18xx_get_rx_buf_align,
  1163. .get_rx_packet_len = wl18xx_get_rx_packet_len,
  1164. .tx_immediate_compl = wl18xx_tx_immediate_completion,
  1165. .tx_delayed_compl = NULL,
  1166. .hw_init = wl18xx_hw_init,
  1167. .set_tx_desc_csum = wl18xx_set_tx_desc_csum,
  1168. .get_pg_ver = wl18xx_get_pg_ver,
  1169. .set_rx_csum = wl18xx_set_rx_csum,
  1170. .sta_get_ap_rate_mask = wl18xx_sta_get_ap_rate_mask,
  1171. .ap_get_mimo_wide_rate_mask = wl18xx_ap_get_mimo_wide_rate_mask,
  1172. .get_mac = wl18xx_get_mac,
  1173. .debugfs_init = wl18xx_debugfs_add_files,
  1174. .scan_start = wl18xx_scan_start,
  1175. .scan_stop = wl18xx_scan_stop,
  1176. .sched_scan_start = wl18xx_sched_scan_start,
  1177. .sched_scan_stop = wl18xx_scan_sched_scan_stop,
  1178. .handle_static_data = wl18xx_handle_static_data,
  1179. .get_spare_blocks = wl18xx_get_spare_blocks,
  1180. .set_key = wl18xx_set_key,
  1181. .channel_switch = wl18xx_cmd_channel_switch,
  1182. .pre_pkt_send = wl18xx_pre_pkt_send,
  1183. };
  1184. /* HT cap appropriate for wide channels in 2Ghz */
  1185. static struct ieee80211_sta_ht_cap wl18xx_siso40_ht_cap_2ghz = {
  1186. .cap = IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
  1187. IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_DSSSCCK40,
  1188. .ht_supported = true,
  1189. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  1190. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  1191. .mcs = {
  1192. .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
  1193. .rx_highest = cpu_to_le16(150),
  1194. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  1195. },
  1196. };
  1197. /* HT cap appropriate for wide channels in 5Ghz */
  1198. static struct ieee80211_sta_ht_cap wl18xx_siso40_ht_cap_5ghz = {
  1199. .cap = IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
  1200. IEEE80211_HT_CAP_SUP_WIDTH_20_40,
  1201. .ht_supported = true,
  1202. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  1203. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  1204. .mcs = {
  1205. .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
  1206. .rx_highest = cpu_to_le16(150),
  1207. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  1208. },
  1209. };
  1210. /* HT cap appropriate for SISO 20 */
  1211. static struct ieee80211_sta_ht_cap wl18xx_siso20_ht_cap = {
  1212. .cap = IEEE80211_HT_CAP_SGI_20,
  1213. .ht_supported = true,
  1214. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  1215. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  1216. .mcs = {
  1217. .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
  1218. .rx_highest = cpu_to_le16(72),
  1219. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  1220. },
  1221. };
  1222. /* HT cap appropriate for MIMO rates in 20mhz channel */
  1223. static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_2ghz = {
  1224. .cap = IEEE80211_HT_CAP_SGI_20,
  1225. .ht_supported = true,
  1226. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  1227. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  1228. .mcs = {
  1229. .rx_mask = { 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, },
  1230. .rx_highest = cpu_to_le16(144),
  1231. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  1232. },
  1233. };
  1234. static int wl18xx_setup(struct wl1271 *wl)
  1235. {
  1236. struct wl18xx_priv *priv = wl->priv;
  1237. int ret;
  1238. wl1271_error("driver is in transitional commit (due to fw api"
  1239. "change) and can't be booted!");
  1240. return -EINVAL;
  1241. wl->rtable = wl18xx_rtable;
  1242. wl->num_tx_desc = WL18XX_NUM_TX_DESCRIPTORS;
  1243. wl->num_rx_desc = WL18XX_NUM_TX_DESCRIPTORS;
  1244. wl->num_mac_addr = WL18XX_NUM_MAC_ADDRESSES;
  1245. wl->band_rate_to_idx = wl18xx_band_rate_to_idx;
  1246. wl->hw_tx_rate_tbl_size = WL18XX_CONF_HW_RXTX_RATE_MAX;
  1247. wl->hw_min_ht_rate = WL18XX_CONF_HW_RXTX_RATE_MCS0;
  1248. wl->fw_status_priv_len = sizeof(struct wl18xx_fw_status_priv);
  1249. wl->stats.fw_stats_len = sizeof(struct wl18xx_acx_statistics);
  1250. wl->static_data_priv_len = sizeof(struct wl18xx_static_data_priv);
  1251. if (num_rx_desc_param != -1)
  1252. wl->num_rx_desc = num_rx_desc_param;
  1253. ret = wl18xx_conf_init(wl, wl->dev);
  1254. if (ret < 0)
  1255. return ret;
  1256. /* If the module param is set, update it in conf */
  1257. if (board_type_param) {
  1258. if (!strcmp(board_type_param, "fpga")) {
  1259. priv->conf.phy.board_type = BOARD_TYPE_FPGA_18XX;
  1260. } else if (!strcmp(board_type_param, "hdk")) {
  1261. priv->conf.phy.board_type = BOARD_TYPE_HDK_18XX;
  1262. } else if (!strcmp(board_type_param, "dvp")) {
  1263. priv->conf.phy.board_type = BOARD_TYPE_DVP_18XX;
  1264. } else if (!strcmp(board_type_param, "evb")) {
  1265. priv->conf.phy.board_type = BOARD_TYPE_EVB_18XX;
  1266. } else if (!strcmp(board_type_param, "com8")) {
  1267. priv->conf.phy.board_type = BOARD_TYPE_COM8_18XX;
  1268. } else {
  1269. wl1271_error("invalid board type '%s'",
  1270. board_type_param);
  1271. return -EINVAL;
  1272. }
  1273. }
  1274. if (priv->conf.phy.board_type >= NUM_BOARD_TYPES) {
  1275. wl1271_error("invalid board type '%d'",
  1276. priv->conf.phy.board_type);
  1277. return -EINVAL;
  1278. }
  1279. if (low_band_component_param != -1)
  1280. priv->conf.phy.low_band_component = low_band_component_param;
  1281. if (low_band_component_type_param != -1)
  1282. priv->conf.phy.low_band_component_type =
  1283. low_band_component_type_param;
  1284. if (high_band_component_param != -1)
  1285. priv->conf.phy.high_band_component = high_band_component_param;
  1286. if (high_band_component_type_param != -1)
  1287. priv->conf.phy.high_band_component_type =
  1288. high_band_component_type_param;
  1289. if (pwr_limit_reference_11_abg_param != -1)
  1290. priv->conf.phy.pwr_limit_reference_11_abg =
  1291. pwr_limit_reference_11_abg_param;
  1292. if (n_antennas_2_param != -1)
  1293. priv->conf.phy.number_of_assembled_ant2_4 = n_antennas_2_param;
  1294. if (n_antennas_5_param != -1)
  1295. priv->conf.phy.number_of_assembled_ant5 = n_antennas_5_param;
  1296. if (dc2dc_param != -1)
  1297. priv->conf.phy.external_pa_dc2dc = dc2dc_param;
  1298. if (ht_mode_param) {
  1299. if (!strcmp(ht_mode_param, "default"))
  1300. priv->conf.ht.mode = HT_MODE_DEFAULT;
  1301. else if (!strcmp(ht_mode_param, "wide"))
  1302. priv->conf.ht.mode = HT_MODE_WIDE;
  1303. else if (!strcmp(ht_mode_param, "siso20"))
  1304. priv->conf.ht.mode = HT_MODE_SISO20;
  1305. else {
  1306. wl1271_error("invalid ht_mode '%s'", ht_mode_param);
  1307. return -EINVAL;
  1308. }
  1309. }
  1310. if (priv->conf.ht.mode == HT_MODE_DEFAULT) {
  1311. /*
  1312. * Only support mimo with multiple antennas. Fall back to
  1313. * siso40.
  1314. */
  1315. if (wl18xx_is_mimo_supported(wl))
  1316. wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ,
  1317. &wl18xx_mimo_ht_cap_2ghz);
  1318. else
  1319. wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ,
  1320. &wl18xx_siso40_ht_cap_2ghz);
  1321. /* 5Ghz is always wide */
  1322. wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ,
  1323. &wl18xx_siso40_ht_cap_5ghz);
  1324. } else if (priv->conf.ht.mode == HT_MODE_WIDE) {
  1325. wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ,
  1326. &wl18xx_siso40_ht_cap_2ghz);
  1327. wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ,
  1328. &wl18xx_siso40_ht_cap_5ghz);
  1329. } else if (priv->conf.ht.mode == HT_MODE_SISO20) {
  1330. wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ,
  1331. &wl18xx_siso20_ht_cap);
  1332. wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ,
  1333. &wl18xx_siso20_ht_cap);
  1334. }
  1335. if (!checksum_param) {
  1336. wl18xx_ops.set_rx_csum = NULL;
  1337. wl18xx_ops.init_vif = NULL;
  1338. }
  1339. /* Enable 11a Band only if we have 5G antennas */
  1340. wl->enable_11a = (priv->conf.phy.number_of_assembled_ant5 != 0);
  1341. return 0;
  1342. }
  1343. static int __devinit wl18xx_probe(struct platform_device *pdev)
  1344. {
  1345. struct wl1271 *wl;
  1346. struct ieee80211_hw *hw;
  1347. int ret;
  1348. hw = wlcore_alloc_hw(sizeof(struct wl18xx_priv),
  1349. WL18XX_AGGR_BUFFER_SIZE,
  1350. sizeof(struct wl18xx_event_mailbox));
  1351. if (IS_ERR(hw)) {
  1352. wl1271_error("can't allocate hw");
  1353. ret = PTR_ERR(hw);
  1354. goto out;
  1355. }
  1356. wl = hw->priv;
  1357. wl->ops = &wl18xx_ops;
  1358. wl->ptable = wl18xx_ptable;
  1359. ret = wlcore_probe(wl, pdev);
  1360. if (ret)
  1361. goto out_free;
  1362. return ret;
  1363. out_free:
  1364. wlcore_free_hw(wl);
  1365. out:
  1366. return ret;
  1367. }
  1368. static const struct platform_device_id wl18xx_id_table[] __devinitconst = {
  1369. { "wl18xx", 0 },
  1370. { } /* Terminating Entry */
  1371. };
  1372. MODULE_DEVICE_TABLE(platform, wl18xx_id_table);
  1373. static struct platform_driver wl18xx_driver = {
  1374. .probe = wl18xx_probe,
  1375. .remove = __devexit_p(wlcore_remove),
  1376. .id_table = wl18xx_id_table,
  1377. .driver = {
  1378. .name = "wl18xx_driver",
  1379. .owner = THIS_MODULE,
  1380. }
  1381. };
  1382. module_platform_driver(wl18xx_driver);
  1383. module_param_named(ht_mode, ht_mode_param, charp, S_IRUSR);
  1384. MODULE_PARM_DESC(ht_mode, "Force HT mode: wide or siso20");
  1385. module_param_named(board_type, board_type_param, charp, S_IRUSR);
  1386. MODULE_PARM_DESC(board_type, "Board type: fpga, hdk (default), evb, com8 or "
  1387. "dvp");
  1388. module_param_named(checksum, checksum_param, bool, S_IRUSR);
  1389. MODULE_PARM_DESC(checksum, "Enable TCP checksum: boolean (defaults to false)");
  1390. module_param_named(dc2dc, dc2dc_param, int, S_IRUSR);
  1391. MODULE_PARM_DESC(dc2dc, "External DC2DC: u8 (defaults to 0)");
  1392. module_param_named(n_antennas_2, n_antennas_2_param, int, S_IRUSR);
  1393. MODULE_PARM_DESC(n_antennas_2,
  1394. "Number of installed 2.4GHz antennas: 1 (default) or 2");
  1395. module_param_named(n_antennas_5, n_antennas_5_param, int, S_IRUSR);
  1396. MODULE_PARM_DESC(n_antennas_5,
  1397. "Number of installed 5GHz antennas: 1 (default) or 2");
  1398. module_param_named(low_band_component, low_band_component_param, int,
  1399. S_IRUSR);
  1400. MODULE_PARM_DESC(low_band_component, "Low band component: u8 "
  1401. "(default is 0x01)");
  1402. module_param_named(low_band_component_type, low_band_component_type_param,
  1403. int, S_IRUSR);
  1404. MODULE_PARM_DESC(low_band_component_type, "Low band component type: u8 "
  1405. "(default is 0x05 or 0x06 depending on the board_type)");
  1406. module_param_named(high_band_component, high_band_component_param, int,
  1407. S_IRUSR);
  1408. MODULE_PARM_DESC(high_band_component, "High band component: u8, "
  1409. "(default is 0x01)");
  1410. module_param_named(high_band_component_type, high_band_component_type_param,
  1411. int, S_IRUSR);
  1412. MODULE_PARM_DESC(high_band_component_type, "High band component type: u8 "
  1413. "(default is 0x09)");
  1414. module_param_named(pwr_limit_reference_11_abg,
  1415. pwr_limit_reference_11_abg_param, int, S_IRUSR);
  1416. MODULE_PARM_DESC(pwr_limit_reference_11_abg, "Power limit reference: u8 "
  1417. "(default is 0xc8)");
  1418. module_param_named(num_rx_desc,
  1419. num_rx_desc_param, int, S_IRUSR);
  1420. MODULE_PARM_DESC(num_rx_desc_param,
  1421. "Number of Rx descriptors: u8 (default is 32)");
  1422. MODULE_LICENSE("GPL v2");
  1423. MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
  1424. MODULE_FIRMWARE(WL18XX_FW_NAME);