main.c 47 KB

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