main.c 46 KB

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