main.c 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609
  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 "debugfs.h"
  39. #define WL18XX_RX_CHECKSUM_MASK 0x40
  40. static char *ht_mode_param = NULL;
  41. static char *board_type_param = NULL;
  42. static bool checksum_param = false;
  43. static int num_rx_desc_param = -1;
  44. /* phy paramters */
  45. static int dc2dc_param = -1;
  46. static int n_antennas_2_param = -1;
  47. static int n_antennas_5_param = -1;
  48. static int low_band_component_param = -1;
  49. static int low_band_component_type_param = -1;
  50. static int high_band_component_param = -1;
  51. static int high_band_component_type_param = -1;
  52. static int pwr_limit_reference_11_abg_param = -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 = 1500,
  354. .forced_ps = false,
  355. .keep_alive_interval = 55000,
  356. .max_listen_interval = 20,
  357. .sta_sleep_auth = WL1271_PSM_ILLEGAL,
  358. },
  359. .itrim = {
  360. .enable = false,
  361. .timeout = 50000,
  362. },
  363. .pm_config = {
  364. .host_clk_settling_time = 5000,
  365. .host_fast_wakeup_support = CONF_FAST_WAKEUP_DISABLE,
  366. },
  367. .roam_trigger = {
  368. .trigger_pacing = 1,
  369. .avg_weight_rssi_beacon = 20,
  370. .avg_weight_rssi_data = 10,
  371. .avg_weight_snr_beacon = 20,
  372. .avg_weight_snr_data = 10,
  373. },
  374. .scan = {
  375. .min_dwell_time_active = 7500,
  376. .max_dwell_time_active = 30000,
  377. .min_dwell_time_passive = 100000,
  378. .max_dwell_time_passive = 100000,
  379. .num_probe_reqs = 2,
  380. .split_scan_timeout = 50000,
  381. },
  382. .sched_scan = {
  383. /*
  384. * Values are in TU/1000 but since sched scan FW command
  385. * params are in TUs rounding up may occur.
  386. */
  387. .base_dwell_time = 7500,
  388. .max_dwell_time_delta = 22500,
  389. /* based on 250bits per probe @1Mbps */
  390. .dwell_time_delta_per_probe = 2000,
  391. /* based on 250bits per probe @6Mbps (plus a bit more) */
  392. .dwell_time_delta_per_probe_5 = 350,
  393. .dwell_time_passive = 100000,
  394. .dwell_time_dfs = 150000,
  395. .num_probe_reqs = 2,
  396. .rssi_threshold = -90,
  397. .snr_threshold = 0,
  398. },
  399. .ht = {
  400. .rx_ba_win_size = 32,
  401. .tx_ba_win_size = 64,
  402. .inactivity_timeout = 10000,
  403. .tx_ba_tid_bitmap = CONF_TX_BA_ENABLED_TID_BITMAP,
  404. },
  405. .mem = {
  406. .num_stations = 1,
  407. .ssid_profiles = 1,
  408. .rx_block_num = 40,
  409. .tx_min_block_num = 40,
  410. .dynamic_memory = 1,
  411. .min_req_tx_blocks = 45,
  412. .min_req_rx_blocks = 22,
  413. .tx_min = 27,
  414. },
  415. .fm_coex = {
  416. .enable = true,
  417. .swallow_period = 5,
  418. .n_divider_fref_set_1 = 0xff, /* default */
  419. .n_divider_fref_set_2 = 12,
  420. .m_divider_fref_set_1 = 0xffff,
  421. .m_divider_fref_set_2 = 148, /* default */
  422. .coex_pll_stabilization_time = 0xffffffff, /* default */
  423. .ldo_stabilization_time = 0xffff, /* default */
  424. .fm_disturbed_band_margin = 0xff, /* default */
  425. .swallow_clk_diff = 0xff, /* default */
  426. },
  427. .rx_streaming = {
  428. .duration = 150,
  429. .queues = 0x1,
  430. .interval = 20,
  431. .always = 0,
  432. },
  433. .fwlog = {
  434. .mode = WL12XX_FWLOG_ON_DEMAND,
  435. .mem_blocks = 2,
  436. .severity = 0,
  437. .timestamp = WL12XX_FWLOG_TIMESTAMP_DISABLED,
  438. .output = WL12XX_FWLOG_OUTPUT_HOST,
  439. .threshold = 0,
  440. },
  441. .rate = {
  442. .rate_retry_score = 32000,
  443. .per_add = 8192,
  444. .per_th1 = 2048,
  445. .per_th2 = 4096,
  446. .max_per = 8100,
  447. .inverse_curiosity_factor = 5,
  448. .tx_fail_low_th = 4,
  449. .tx_fail_high_th = 10,
  450. .per_alpha_shift = 4,
  451. .per_add_shift = 13,
  452. .per_beta1_shift = 10,
  453. .per_beta2_shift = 8,
  454. .rate_check_up = 2,
  455. .rate_check_down = 12,
  456. .rate_retry_policy = {
  457. 0x00, 0x00, 0x00, 0x00, 0x00,
  458. 0x00, 0x00, 0x00, 0x00, 0x00,
  459. 0x00, 0x00, 0x00,
  460. },
  461. },
  462. .hangover = {
  463. .recover_time = 0,
  464. .hangover_period = 20,
  465. .dynamic_mode = 1,
  466. .early_termination_mode = 1,
  467. .max_period = 20,
  468. .min_period = 1,
  469. .increase_delta = 1,
  470. .decrease_delta = 2,
  471. .quiet_time = 4,
  472. .increase_time = 1,
  473. .window_size = 16,
  474. },
  475. };
  476. static struct wl18xx_priv_conf wl18xx_default_priv_conf = {
  477. .ht = {
  478. .mode = HT_MODE_DEFAULT,
  479. },
  480. .phy = {
  481. .phy_standalone = 0x00,
  482. .primary_clock_setting_time = 0x05,
  483. .clock_valid_on_wake_up = 0x00,
  484. .secondary_clock_setting_time = 0x05,
  485. .board_type = BOARD_TYPE_HDK_18XX,
  486. .rdl = 0x01,
  487. .auto_detect = 0x00,
  488. .dedicated_fem = FEM_NONE,
  489. .low_band_component = COMPONENT_3_WAY_SWITCH,
  490. .low_band_component_type = 0x04,
  491. .high_band_component = COMPONENT_2_WAY_SWITCH,
  492. .high_band_component_type = 0x09,
  493. .tcxo_ldo_voltage = 0x00,
  494. .xtal_itrim_val = 0x04,
  495. .srf_state = 0x00,
  496. .io_configuration = 0x01,
  497. .sdio_configuration = 0x00,
  498. .settings = 0x00,
  499. .enable_clpc = 0x00,
  500. .enable_tx_low_pwr_on_siso_rdl = 0x00,
  501. .rx_profile = 0x00,
  502. .pwr_limit_reference_11_abg = 0xc8,
  503. .psat = 0,
  504. .low_power_val = 0x00,
  505. .med_power_val = 0x0a,
  506. .high_power_val = 0x1e,
  507. .external_pa_dc2dc = 0,
  508. .number_of_assembled_ant2_4 = 1,
  509. .number_of_assembled_ant5 = 1,
  510. },
  511. };
  512. static const struct wlcore_partition_set wl18xx_ptable[PART_TABLE_LEN] = {
  513. [PART_TOP_PRCM_ELP_SOC] = {
  514. .mem = { .start = 0x00A02000, .size = 0x00010000 },
  515. .reg = { .start = 0x00807000, .size = 0x00005000 },
  516. .mem2 = { .start = 0x00800000, .size = 0x0000B000 },
  517. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  518. },
  519. [PART_DOWN] = {
  520. .mem = { .start = 0x00000000, .size = 0x00014000 },
  521. .reg = { .start = 0x00810000, .size = 0x0000BFFF },
  522. .mem2 = { .start = 0x00000000, .size = 0x00000000 },
  523. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  524. },
  525. [PART_BOOT] = {
  526. .mem = { .start = 0x00700000, .size = 0x0000030c },
  527. .reg = { .start = 0x00802000, .size = 0x00014578 },
  528. .mem2 = { .start = 0x00B00404, .size = 0x00001000 },
  529. .mem3 = { .start = 0x00C00000, .size = 0x00000400 },
  530. },
  531. [PART_WORK] = {
  532. .mem = { .start = 0x00800000, .size = 0x000050FC },
  533. .reg = { .start = 0x00B00404, .size = 0x00001000 },
  534. .mem2 = { .start = 0x00C00000, .size = 0x00000400 },
  535. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  536. },
  537. [PART_PHY_INIT] = {
  538. .mem = { .start = 0x80926000,
  539. .size = sizeof(struct wl18xx_mac_and_phy_params) },
  540. .reg = { .start = 0x00000000, .size = 0x00000000 },
  541. .mem2 = { .start = 0x00000000, .size = 0x00000000 },
  542. .mem3 = { .start = 0x00000000, .size = 0x00000000 },
  543. },
  544. };
  545. static const int wl18xx_rtable[REG_TABLE_LEN] = {
  546. [REG_ECPU_CONTROL] = WL18XX_REG_ECPU_CONTROL,
  547. [REG_INTERRUPT_NO_CLEAR] = WL18XX_REG_INTERRUPT_NO_CLEAR,
  548. [REG_INTERRUPT_ACK] = WL18XX_REG_INTERRUPT_ACK,
  549. [REG_COMMAND_MAILBOX_PTR] = WL18XX_REG_COMMAND_MAILBOX_PTR,
  550. [REG_EVENT_MAILBOX_PTR] = WL18XX_REG_EVENT_MAILBOX_PTR,
  551. [REG_INTERRUPT_TRIG] = WL18XX_REG_INTERRUPT_TRIG_H,
  552. [REG_INTERRUPT_MASK] = WL18XX_REG_INTERRUPT_MASK,
  553. [REG_PC_ON_RECOVERY] = WL18XX_SCR_PAD4,
  554. [REG_CHIP_ID_B] = WL18XX_REG_CHIP_ID_B,
  555. [REG_CMD_MBOX_ADDRESS] = WL18XX_CMD_MBOX_ADDRESS,
  556. /* data access memory addresses, used with partition translation */
  557. [REG_SLV_MEM_DATA] = WL18XX_SLV_MEM_DATA,
  558. [REG_SLV_REG_DATA] = WL18XX_SLV_REG_DATA,
  559. /* raw data access memory addresses */
  560. [REG_RAW_FW_STATUS_ADDR] = WL18XX_FW_STATUS_ADDR,
  561. };
  562. static const struct wl18xx_clk_cfg wl18xx_clk_table[NUM_CLOCK_CONFIGS] = {
  563. [CLOCK_CONFIG_16_2_M] = { 7, 104, 801, 4, true },
  564. [CLOCK_CONFIG_16_368_M] = { 9, 132, 3751, 4, true },
  565. [CLOCK_CONFIG_16_8_M] = { 7, 100, 0, 0, false },
  566. [CLOCK_CONFIG_19_2_M] = { 8, 100, 0, 0, false },
  567. [CLOCK_CONFIG_26_M] = { 13, 120, 0, 0, false },
  568. [CLOCK_CONFIG_32_736_M] = { 9, 132, 3751, 4, true },
  569. [CLOCK_CONFIG_33_6_M] = { 7, 100, 0, 0, false },
  570. [CLOCK_CONFIG_38_468_M] = { 8, 100, 0, 0, false },
  571. [CLOCK_CONFIG_52_M] = { 13, 120, 0, 0, false },
  572. };
  573. /* TODO: maybe move to a new header file? */
  574. #define WL18XX_FW_NAME "ti-connectivity/wl18xx-fw.bin"
  575. static int wl18xx_identify_chip(struct wl1271 *wl)
  576. {
  577. int ret = 0;
  578. switch (wl->chip.id) {
  579. case CHIP_ID_185x_PG20:
  580. wl1271_debug(DEBUG_BOOT, "chip id 0x%x (185x PG20)",
  581. wl->chip.id);
  582. wl->sr_fw_name = WL18XX_FW_NAME;
  583. /* wl18xx uses the same firmware for PLT */
  584. wl->plt_fw_name = WL18XX_FW_NAME;
  585. wl->quirks |= WLCORE_QUIRK_NO_ELP |
  586. WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN |
  587. WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN |
  588. WLCORE_QUIRK_NO_SCHED_SCAN_WHILE_CONN |
  589. WLCORE_QUIRK_TX_PAD_LAST_FRAME;
  590. wlcore_set_min_fw_ver(wl, WL18XX_CHIP_VER, WL18XX_IFTYPE_VER,
  591. WL18XX_MAJOR_VER, WL18XX_SUBTYPE_VER,
  592. WL18XX_MINOR_VER);
  593. break;
  594. case CHIP_ID_185x_PG10:
  595. wl1271_warning("chip id 0x%x (185x PG10) is deprecated",
  596. wl->chip.id);
  597. ret = -ENODEV;
  598. goto out;
  599. default:
  600. wl1271_warning("unsupported chip id: 0x%x", wl->chip.id);
  601. ret = -ENODEV;
  602. goto out;
  603. }
  604. out:
  605. return ret;
  606. }
  607. static int wl18xx_set_clk(struct wl1271 *wl)
  608. {
  609. u16 clk_freq;
  610. int ret;
  611. ret = wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
  612. if (ret < 0)
  613. goto out;
  614. /* TODO: PG2: apparently we need to read the clk type */
  615. ret = wl18xx_top_reg_read(wl, PRIMARY_CLK_DETECT, &clk_freq);
  616. if (ret < 0)
  617. goto out;
  618. wl1271_debug(DEBUG_BOOT, "clock freq %d (%d, %d, %d, %d, %s)", clk_freq,
  619. wl18xx_clk_table[clk_freq].n, wl18xx_clk_table[clk_freq].m,
  620. wl18xx_clk_table[clk_freq].p, wl18xx_clk_table[clk_freq].q,
  621. wl18xx_clk_table[clk_freq].swallow ? "swallow" : "spit");
  622. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_N,
  623. wl18xx_clk_table[clk_freq].n);
  624. if (ret < 0)
  625. goto out;
  626. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_M,
  627. wl18xx_clk_table[clk_freq].m);
  628. if (ret < 0)
  629. goto out;
  630. if (wl18xx_clk_table[clk_freq].swallow) {
  631. /* first the 16 lower bits */
  632. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_1,
  633. wl18xx_clk_table[clk_freq].q &
  634. PLLSH_WCS_PLL_Q_FACTOR_CFG_1_MASK);
  635. if (ret < 0)
  636. goto out;
  637. /* then the 16 higher bits, masked out */
  638. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_Q_FACTOR_CFG_2,
  639. (wl18xx_clk_table[clk_freq].q >> 16) &
  640. PLLSH_WCS_PLL_Q_FACTOR_CFG_2_MASK);
  641. if (ret < 0)
  642. goto out;
  643. /* first the 16 lower bits */
  644. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_1,
  645. wl18xx_clk_table[clk_freq].p &
  646. PLLSH_WCS_PLL_P_FACTOR_CFG_1_MASK);
  647. if (ret < 0)
  648. goto out;
  649. /* then the 16 higher bits, masked out */
  650. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_P_FACTOR_CFG_2,
  651. (wl18xx_clk_table[clk_freq].p >> 16) &
  652. PLLSH_WCS_PLL_P_FACTOR_CFG_2_MASK);
  653. } else {
  654. ret = wl18xx_top_reg_write(wl, PLLSH_WCS_PLL_SWALLOW_EN,
  655. PLLSH_WCS_PLL_SWALLOW_EN_VAL2);
  656. }
  657. out:
  658. return ret;
  659. }
  660. static int wl18xx_boot_soft_reset(struct wl1271 *wl)
  661. {
  662. int ret;
  663. /* disable Rx/Tx */
  664. ret = wlcore_write32(wl, WL18XX_ENABLE, 0x0);
  665. if (ret < 0)
  666. goto out;
  667. /* disable auto calibration on start*/
  668. ret = wlcore_write32(wl, WL18XX_SPARE_A2, 0xffff);
  669. out:
  670. return ret;
  671. }
  672. static int wl18xx_pre_boot(struct wl1271 *wl)
  673. {
  674. int ret;
  675. ret = wl18xx_set_clk(wl);
  676. if (ret < 0)
  677. goto out;
  678. /* Continue the ELP wake up sequence */
  679. ret = wlcore_write32(wl, WL18XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
  680. if (ret < 0)
  681. goto out;
  682. udelay(500);
  683. ret = wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  684. if (ret < 0)
  685. goto out;
  686. /* Disable interrupts */
  687. ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL);
  688. if (ret < 0)
  689. goto out;
  690. ret = wl18xx_boot_soft_reset(wl);
  691. out:
  692. return ret;
  693. }
  694. static int wl18xx_pre_upload(struct wl1271 *wl)
  695. {
  696. u32 tmp;
  697. int ret;
  698. ret = wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  699. if (ret < 0)
  700. goto out;
  701. /* TODO: check if this is all needed */
  702. ret = wlcore_write32(wl, WL18XX_EEPROMLESS_IND, WL18XX_EEPROMLESS_IND);
  703. if (ret < 0)
  704. goto out;
  705. ret = wlcore_read_reg(wl, REG_CHIP_ID_B, &tmp);
  706. if (ret < 0)
  707. goto out;
  708. wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp);
  709. ret = wlcore_read32(wl, WL18XX_SCR_PAD2, &tmp);
  710. out:
  711. return ret;
  712. }
  713. static int wl18xx_set_mac_and_phy(struct wl1271 *wl)
  714. {
  715. struct wl18xx_priv *priv = wl->priv;
  716. struct wl18xx_mac_and_phy_params *params;
  717. int ret;
  718. params = kmemdup(&priv->conf.phy, sizeof(*params), GFP_KERNEL);
  719. if (!params) {
  720. ret = -ENOMEM;
  721. goto out;
  722. }
  723. ret = wlcore_set_partition(wl, &wl->ptable[PART_PHY_INIT]);
  724. if (ret < 0)
  725. goto out;
  726. ret = wlcore_write(wl, WL18XX_PHY_INIT_MEM_ADDR, params,
  727. sizeof(*params), false);
  728. out:
  729. kfree(params);
  730. return ret;
  731. }
  732. static int wl18xx_enable_interrupts(struct wl1271 *wl)
  733. {
  734. u32 event_mask, intr_mask;
  735. int ret;
  736. event_mask = WL18XX_ACX_EVENTS_VECTOR;
  737. intr_mask = WL18XX_INTR_MASK;
  738. ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK, event_mask);
  739. if (ret < 0)
  740. goto out;
  741. wlcore_enable_interrupts(wl);
  742. ret = wlcore_write_reg(wl, REG_INTERRUPT_MASK,
  743. WL1271_ACX_INTR_ALL & ~intr_mask);
  744. if (ret < 0)
  745. goto disable_interrupts;
  746. return ret;
  747. disable_interrupts:
  748. wlcore_disable_interrupts(wl);
  749. out:
  750. return ret;
  751. }
  752. static int wl18xx_boot(struct wl1271 *wl)
  753. {
  754. int ret;
  755. ret = wl18xx_pre_boot(wl);
  756. if (ret < 0)
  757. goto out;
  758. ret = wl18xx_pre_upload(wl);
  759. if (ret < 0)
  760. goto out;
  761. ret = wlcore_boot_upload_firmware(wl);
  762. if (ret < 0)
  763. goto out;
  764. ret = wl18xx_set_mac_and_phy(wl);
  765. if (ret < 0)
  766. goto out;
  767. ret = wlcore_boot_run_firmware(wl);
  768. if (ret < 0)
  769. goto out;
  770. ret = wl18xx_enable_interrupts(wl);
  771. out:
  772. return ret;
  773. }
  774. static int wl18xx_trigger_cmd(struct wl1271 *wl, int cmd_box_addr,
  775. void *buf, size_t len)
  776. {
  777. struct wl18xx_priv *priv = wl->priv;
  778. memcpy(priv->cmd_buf, buf, len);
  779. memset(priv->cmd_buf + len, 0, WL18XX_CMD_MAX_SIZE - len);
  780. return wlcore_write(wl, cmd_box_addr, priv->cmd_buf,
  781. WL18XX_CMD_MAX_SIZE, false);
  782. }
  783. static int wl18xx_ack_event(struct wl1271 *wl)
  784. {
  785. return wlcore_write_reg(wl, REG_INTERRUPT_TRIG,
  786. WL18XX_INTR_TRIG_EVENT_ACK);
  787. }
  788. static u32 wl18xx_calc_tx_blocks(struct wl1271 *wl, u32 len, u32 spare_blks)
  789. {
  790. u32 blk_size = WL18XX_TX_HW_BLOCK_SIZE;
  791. return (len + blk_size - 1) / blk_size + spare_blks;
  792. }
  793. static void
  794. wl18xx_set_tx_desc_blocks(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
  795. u32 blks, u32 spare_blks)
  796. {
  797. desc->wl18xx_mem.total_mem_blocks = blks;
  798. }
  799. static void
  800. wl18xx_set_tx_desc_data_len(struct wl1271 *wl, struct wl1271_tx_hw_descr *desc,
  801. struct sk_buff *skb)
  802. {
  803. desc->length = cpu_to_le16(skb->len);
  804. /* if only the last frame is to be padded, we unset this bit on Tx */
  805. if (wl->quirks & WLCORE_QUIRK_TX_PAD_LAST_FRAME)
  806. desc->wl18xx_mem.ctrl = WL18XX_TX_CTRL_NOT_PADDED;
  807. else
  808. desc->wl18xx_mem.ctrl = 0;
  809. wl1271_debug(DEBUG_TX, "tx_fill_hdr: hlid: %d "
  810. "len: %d life: %d mem: %d", desc->hlid,
  811. le16_to_cpu(desc->length),
  812. le16_to_cpu(desc->life_time),
  813. desc->wl18xx_mem.total_mem_blocks);
  814. }
  815. static enum wl_rx_buf_align
  816. wl18xx_get_rx_buf_align(struct wl1271 *wl, u32 rx_desc)
  817. {
  818. if (rx_desc & RX_BUF_PADDED_PAYLOAD)
  819. return WLCORE_RX_BUF_PADDED;
  820. return WLCORE_RX_BUF_ALIGNED;
  821. }
  822. static u32 wl18xx_get_rx_packet_len(struct wl1271 *wl, void *rx_data,
  823. u32 data_len)
  824. {
  825. struct wl1271_rx_descriptor *desc = rx_data;
  826. /* invalid packet */
  827. if (data_len < sizeof(*desc))
  828. return 0;
  829. return data_len - sizeof(*desc);
  830. }
  831. static void wl18xx_tx_immediate_completion(struct wl1271 *wl)
  832. {
  833. wl18xx_tx_immediate_complete(wl);
  834. }
  835. static int wl18xx_set_host_cfg_bitmap(struct wl1271 *wl, u32 extra_mem_blk)
  836. {
  837. int ret;
  838. u32 sdio_align_size = 0;
  839. u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE |
  840. HOST_IF_CFG_ADD_RX_ALIGNMENT;
  841. /* Enable Tx SDIO padding */
  842. if (wl->quirks & WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN) {
  843. host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
  844. sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
  845. }
  846. /* Enable Rx SDIO padding */
  847. if (wl->quirks & WLCORE_QUIRK_RX_BLOCKSIZE_ALIGN) {
  848. host_cfg_bitmap |= HOST_IF_CFG_RX_PAD_TO_SDIO_BLK;
  849. sdio_align_size = WL12XX_BUS_BLOCK_SIZE;
  850. }
  851. ret = wl18xx_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap,
  852. sdio_align_size, extra_mem_blk,
  853. WL18XX_HOST_IF_LEN_SIZE_FIELD);
  854. if (ret < 0)
  855. return ret;
  856. return 0;
  857. }
  858. static int wl18xx_hw_init(struct wl1271 *wl)
  859. {
  860. int ret;
  861. struct wl18xx_priv *priv = wl->priv;
  862. /* (re)init private structures. Relevant on recovery as well. */
  863. priv->last_fw_rls_idx = 0;
  864. priv->extra_spare_vif_count = 0;
  865. /* set the default amount of spare blocks in the bitmap */
  866. ret = wl18xx_set_host_cfg_bitmap(wl, WL18XX_TX_HW_BLOCK_SPARE);
  867. if (ret < 0)
  868. return ret;
  869. if (checksum_param) {
  870. ret = wl18xx_acx_set_checksum_state(wl);
  871. if (ret != 0)
  872. return ret;
  873. }
  874. return ret;
  875. }
  876. static void wl18xx_set_tx_desc_csum(struct wl1271 *wl,
  877. struct wl1271_tx_hw_descr *desc,
  878. struct sk_buff *skb)
  879. {
  880. u32 ip_hdr_offset;
  881. struct iphdr *ip_hdr;
  882. if (!checksum_param) {
  883. desc->wl18xx_checksum_data = 0;
  884. return;
  885. }
  886. if (skb->ip_summed != CHECKSUM_PARTIAL) {
  887. desc->wl18xx_checksum_data = 0;
  888. return;
  889. }
  890. ip_hdr_offset = skb_network_header(skb) - skb_mac_header(skb);
  891. if (WARN_ON(ip_hdr_offset >= (1<<7))) {
  892. desc->wl18xx_checksum_data = 0;
  893. return;
  894. }
  895. desc->wl18xx_checksum_data = ip_hdr_offset << 1;
  896. /* FW is interested only in the LSB of the protocol TCP=0 UDP=1 */
  897. ip_hdr = (void *)skb_network_header(skb);
  898. desc->wl18xx_checksum_data |= (ip_hdr->protocol & 0x01);
  899. }
  900. static void wl18xx_set_rx_csum(struct wl1271 *wl,
  901. struct wl1271_rx_descriptor *desc,
  902. struct sk_buff *skb)
  903. {
  904. if (desc->status & WL18XX_RX_CHECKSUM_MASK)
  905. skb->ip_summed = CHECKSUM_UNNECESSARY;
  906. }
  907. static bool wl18xx_is_mimo_supported(struct wl1271 *wl)
  908. {
  909. struct wl18xx_priv *priv = wl->priv;
  910. return priv->conf.phy.number_of_assembled_ant2_4 >= 2;
  911. }
  912. /*
  913. * TODO: instead of having these two functions to get the rate mask,
  914. * we should modify the wlvif->rate_set instead
  915. */
  916. static u32 wl18xx_sta_get_ap_rate_mask(struct wl1271 *wl,
  917. struct wl12xx_vif *wlvif)
  918. {
  919. u32 hw_rate_set = wlvif->rate_set;
  920. if (wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
  921. wlvif->channel_type == NL80211_CHAN_HT40PLUS) {
  922. wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
  923. hw_rate_set |= CONF_TX_RATE_USE_WIDE_CHAN;
  924. /* we don't support MIMO in wide-channel mode */
  925. hw_rate_set &= ~CONF_TX_MIMO_RATES;
  926. } else if (wl18xx_is_mimo_supported(wl)) {
  927. wl1271_debug(DEBUG_ACX, "using MIMO channel rate mask");
  928. hw_rate_set |= CONF_TX_MIMO_RATES;
  929. }
  930. return hw_rate_set;
  931. }
  932. static u32 wl18xx_ap_get_mimo_wide_rate_mask(struct wl1271 *wl,
  933. struct wl12xx_vif *wlvif)
  934. {
  935. if (wlvif->channel_type == NL80211_CHAN_HT40MINUS ||
  936. wlvif->channel_type == NL80211_CHAN_HT40PLUS) {
  937. wl1271_debug(DEBUG_ACX, "using wide channel rate mask");
  938. /* sanity check - we don't support this */
  939. if (WARN_ON(wlvif->band != IEEE80211_BAND_5GHZ))
  940. return 0;
  941. return CONF_TX_RATE_USE_WIDE_CHAN;
  942. } else if (wl18xx_is_mimo_supported(wl) &&
  943. wlvif->band == IEEE80211_BAND_2GHZ) {
  944. wl1271_debug(DEBUG_ACX, "using MIMO rate mask");
  945. /*
  946. * we don't care about HT channel here - if a peer doesn't
  947. * support MIMO, we won't enable it in its rates
  948. */
  949. return CONF_TX_MIMO_RATES;
  950. } else {
  951. return 0;
  952. }
  953. }
  954. static int wl18xx_get_pg_ver(struct wl1271 *wl, s8 *ver)
  955. {
  956. u32 fuse;
  957. int ret;
  958. ret = wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
  959. if (ret < 0)
  960. goto out;
  961. ret = wlcore_read32(wl, WL18XX_REG_FUSE_DATA_1_3, &fuse);
  962. if (ret < 0)
  963. goto out;
  964. if (ver)
  965. *ver = (fuse & WL18XX_PG_VER_MASK) >> WL18XX_PG_VER_OFFSET;
  966. ret = wlcore_set_partition(wl, &wl->ptable[PART_BOOT]);
  967. out:
  968. return ret;
  969. }
  970. #define WL18XX_CONF_FILE_NAME "ti-connectivity/wl18xx-conf.bin"
  971. static int wl18xx_conf_init(struct wl1271 *wl, struct device *dev)
  972. {
  973. struct wl18xx_priv *priv = wl->priv;
  974. struct wlcore_conf_file *conf_file;
  975. const struct firmware *fw;
  976. int ret;
  977. ret = request_firmware(&fw, WL18XX_CONF_FILE_NAME, dev);
  978. if (ret < 0) {
  979. wl1271_error("could not get configuration binary %s: %d",
  980. WL18XX_CONF_FILE_NAME, ret);
  981. goto out_fallback;
  982. }
  983. if (fw->size != WL18XX_CONF_SIZE) {
  984. wl1271_error("configuration binary file size is wrong, expected %zu got %zu",
  985. WL18XX_CONF_SIZE, fw->size);
  986. ret = -EINVAL;
  987. goto out;
  988. }
  989. conf_file = (struct wlcore_conf_file *) fw->data;
  990. if (conf_file->header.magic != cpu_to_le32(WL18XX_CONF_MAGIC)) {
  991. wl1271_error("configuration binary file magic number mismatch, "
  992. "expected 0x%0x got 0x%0x", WL18XX_CONF_MAGIC,
  993. conf_file->header.magic);
  994. ret = -EINVAL;
  995. goto out;
  996. }
  997. if (conf_file->header.version != cpu_to_le32(WL18XX_CONF_VERSION)) {
  998. wl1271_error("configuration binary file version not supported, "
  999. "expected 0x%08x got 0x%08x",
  1000. WL18XX_CONF_VERSION, conf_file->header.version);
  1001. ret = -EINVAL;
  1002. goto out;
  1003. }
  1004. memcpy(&wl->conf, &conf_file->core, sizeof(wl18xx_conf));
  1005. memcpy(&priv->conf, &conf_file->priv, sizeof(priv->conf));
  1006. goto out;
  1007. out_fallback:
  1008. wl1271_warning("falling back to default config");
  1009. /* apply driver default configuration */
  1010. memcpy(&wl->conf, &wl18xx_conf, sizeof(wl18xx_conf));
  1011. /* apply default private configuration */
  1012. memcpy(&priv->conf, &wl18xx_default_priv_conf, sizeof(priv->conf));
  1013. /* For now we just fallback */
  1014. return 0;
  1015. out:
  1016. release_firmware(fw);
  1017. return ret;
  1018. }
  1019. static int wl18xx_plt_init(struct wl1271 *wl)
  1020. {
  1021. int ret;
  1022. /* calibrator based auto/fem detect not supported for 18xx */
  1023. if (wl->plt_mode == PLT_FEM_DETECT) {
  1024. wl1271_error("wl18xx_plt_init: PLT FEM_DETECT not supported");
  1025. return -EINVAL;
  1026. }
  1027. ret = wlcore_write32(wl, WL18XX_SCR_PAD8, WL18XX_SCR_PAD8_PLT);
  1028. if (ret < 0)
  1029. return ret;
  1030. return wl->ops->boot(wl);
  1031. }
  1032. static int wl18xx_get_mac(struct wl1271 *wl)
  1033. {
  1034. u32 mac1, mac2;
  1035. int ret;
  1036. ret = wlcore_set_partition(wl, &wl->ptable[PART_TOP_PRCM_ELP_SOC]);
  1037. if (ret < 0)
  1038. goto out;
  1039. ret = wlcore_read32(wl, WL18XX_REG_FUSE_BD_ADDR_1, &mac1);
  1040. if (ret < 0)
  1041. goto out;
  1042. ret = wlcore_read32(wl, WL18XX_REG_FUSE_BD_ADDR_2, &mac2);
  1043. if (ret < 0)
  1044. goto out;
  1045. /* these are the two parts of the BD_ADDR */
  1046. wl->fuse_oui_addr = ((mac2 & 0xffff) << 8) +
  1047. ((mac1 & 0xff000000) >> 24);
  1048. wl->fuse_nic_addr = (mac1 & 0xffffff);
  1049. ret = wlcore_set_partition(wl, &wl->ptable[PART_DOWN]);
  1050. out:
  1051. return ret;
  1052. }
  1053. static int wl18xx_handle_static_data(struct wl1271 *wl,
  1054. struct wl1271_static_data *static_data)
  1055. {
  1056. struct wl18xx_static_data_priv *static_data_priv =
  1057. (struct wl18xx_static_data_priv *) static_data->priv;
  1058. strncpy(wl->chip.phy_fw_ver_str, static_data_priv->phy_version,
  1059. sizeof(wl->chip.phy_fw_ver_str));
  1060. /* make sure the string is NULL-terminated */
  1061. wl->chip.phy_fw_ver_str[sizeof(wl->chip.phy_fw_ver_str) - 1] = '\0';
  1062. wl1271_info("PHY firmware version: %s", static_data_priv->phy_version);
  1063. return 0;
  1064. }
  1065. static int wl18xx_get_spare_blocks(struct wl1271 *wl, bool is_gem)
  1066. {
  1067. struct wl18xx_priv *priv = wl->priv;
  1068. /* If we have VIFs requiring extra spare, indulge them */
  1069. if (priv->extra_spare_vif_count)
  1070. return WL18XX_TX_HW_EXTRA_BLOCK_SPARE;
  1071. return WL18XX_TX_HW_BLOCK_SPARE;
  1072. }
  1073. static int wl18xx_set_key(struct wl1271 *wl, enum set_key_cmd cmd,
  1074. struct ieee80211_vif *vif,
  1075. struct ieee80211_sta *sta,
  1076. struct ieee80211_key_conf *key_conf)
  1077. {
  1078. struct wl18xx_priv *priv = wl->priv;
  1079. bool change_spare = false;
  1080. int ret;
  1081. /*
  1082. * when adding the first or removing the last GEM/TKIP interface,
  1083. * we have to adjust the number of spare blocks.
  1084. */
  1085. change_spare = (key_conf->cipher == WL1271_CIPHER_SUITE_GEM ||
  1086. key_conf->cipher == WLAN_CIPHER_SUITE_TKIP) &&
  1087. ((priv->extra_spare_vif_count == 0 && cmd == SET_KEY) ||
  1088. (priv->extra_spare_vif_count == 1 && cmd == DISABLE_KEY));
  1089. /* no need to change spare - just regular set_key */
  1090. if (!change_spare)
  1091. return wlcore_set_key(wl, cmd, vif, sta, key_conf);
  1092. /*
  1093. * stop the queues and flush to ensure the next packets are
  1094. * in sync with FW spare block accounting
  1095. */
  1096. wlcore_stop_queues(wl, WLCORE_QUEUE_STOP_REASON_SPARE_BLK);
  1097. wl1271_tx_flush(wl);
  1098. ret = wlcore_set_key(wl, cmd, vif, sta, key_conf);
  1099. if (ret < 0)
  1100. goto out;
  1101. /* key is now set, change the spare blocks */
  1102. if (cmd == SET_KEY) {
  1103. ret = wl18xx_set_host_cfg_bitmap(wl,
  1104. WL18XX_TX_HW_EXTRA_BLOCK_SPARE);
  1105. if (ret < 0)
  1106. goto out;
  1107. priv->extra_spare_vif_count++;
  1108. } else {
  1109. ret = wl18xx_set_host_cfg_bitmap(wl,
  1110. WL18XX_TX_HW_BLOCK_SPARE);
  1111. if (ret < 0)
  1112. goto out;
  1113. priv->extra_spare_vif_count--;
  1114. }
  1115. out:
  1116. wlcore_wake_queues(wl, WLCORE_QUEUE_STOP_REASON_SPARE_BLK);
  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. .handle_static_data = wl18xx_handle_static_data,
  1158. .get_spare_blocks = wl18xx_get_spare_blocks,
  1159. .set_key = wl18xx_set_key,
  1160. .pre_pkt_send = wl18xx_pre_pkt_send,
  1161. };
  1162. /* HT cap appropriate for wide channels in 2Ghz */
  1163. static struct ieee80211_sta_ht_cap wl18xx_siso40_ht_cap_2ghz = {
  1164. .cap = IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
  1165. IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_DSSSCCK40,
  1166. .ht_supported = true,
  1167. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  1168. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  1169. .mcs = {
  1170. .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
  1171. .rx_highest = cpu_to_le16(150),
  1172. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  1173. },
  1174. };
  1175. /* HT cap appropriate for wide channels in 5Ghz */
  1176. static struct ieee80211_sta_ht_cap wl18xx_siso40_ht_cap_5ghz = {
  1177. .cap = IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 |
  1178. IEEE80211_HT_CAP_SUP_WIDTH_20_40,
  1179. .ht_supported = true,
  1180. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  1181. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  1182. .mcs = {
  1183. .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
  1184. .rx_highest = cpu_to_le16(150),
  1185. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  1186. },
  1187. };
  1188. /* HT cap appropriate for SISO 20 */
  1189. static struct ieee80211_sta_ht_cap wl18xx_siso20_ht_cap = {
  1190. .cap = IEEE80211_HT_CAP_SGI_20,
  1191. .ht_supported = true,
  1192. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  1193. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  1194. .mcs = {
  1195. .rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
  1196. .rx_highest = cpu_to_le16(72),
  1197. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  1198. },
  1199. };
  1200. /* HT cap appropriate for MIMO rates in 20mhz channel */
  1201. static struct ieee80211_sta_ht_cap wl18xx_mimo_ht_cap_2ghz = {
  1202. .cap = IEEE80211_HT_CAP_SGI_20,
  1203. .ht_supported = true,
  1204. .ampdu_factor = IEEE80211_HT_MAX_AMPDU_16K,
  1205. .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
  1206. .mcs = {
  1207. .rx_mask = { 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, },
  1208. .rx_highest = cpu_to_le16(144),
  1209. .tx_params = IEEE80211_HT_MCS_TX_DEFINED,
  1210. },
  1211. };
  1212. static int wl18xx_setup(struct wl1271 *wl)
  1213. {
  1214. struct wl18xx_priv *priv = wl->priv;
  1215. int ret;
  1216. wl->rtable = wl18xx_rtable;
  1217. wl->num_tx_desc = WL18XX_NUM_TX_DESCRIPTORS;
  1218. wl->num_rx_desc = WL18XX_NUM_TX_DESCRIPTORS;
  1219. wl->num_mac_addr = WL18XX_NUM_MAC_ADDRESSES;
  1220. wl->band_rate_to_idx = wl18xx_band_rate_to_idx;
  1221. wl->hw_tx_rate_tbl_size = WL18XX_CONF_HW_RXTX_RATE_MAX;
  1222. wl->hw_min_ht_rate = WL18XX_CONF_HW_RXTX_RATE_MCS0;
  1223. wl->fw_status_priv_len = sizeof(struct wl18xx_fw_status_priv);
  1224. wl->stats.fw_stats_len = sizeof(struct wl18xx_acx_statistics);
  1225. wl->static_data_priv_len = sizeof(struct wl18xx_static_data_priv);
  1226. if (num_rx_desc_param != -1)
  1227. wl->num_rx_desc = num_rx_desc_param;
  1228. ret = wl18xx_conf_init(wl, wl->dev);
  1229. if (ret < 0)
  1230. return ret;
  1231. /* If the module param is set, update it in conf */
  1232. if (board_type_param) {
  1233. if (!strcmp(board_type_param, "fpga")) {
  1234. priv->conf.phy.board_type = BOARD_TYPE_FPGA_18XX;
  1235. } else if (!strcmp(board_type_param, "hdk")) {
  1236. priv->conf.phy.board_type = BOARD_TYPE_HDK_18XX;
  1237. } else if (!strcmp(board_type_param, "dvp")) {
  1238. priv->conf.phy.board_type = BOARD_TYPE_DVP_18XX;
  1239. } else if (!strcmp(board_type_param, "evb")) {
  1240. priv->conf.phy.board_type = BOARD_TYPE_EVB_18XX;
  1241. } else if (!strcmp(board_type_param, "com8")) {
  1242. priv->conf.phy.board_type = BOARD_TYPE_COM8_18XX;
  1243. } else {
  1244. wl1271_error("invalid board type '%s'",
  1245. board_type_param);
  1246. return -EINVAL;
  1247. }
  1248. }
  1249. if (priv->conf.phy.board_type >= NUM_BOARD_TYPES) {
  1250. wl1271_error("invalid board type '%d'",
  1251. priv->conf.phy.board_type);
  1252. return -EINVAL;
  1253. }
  1254. if (low_band_component_param != -1)
  1255. priv->conf.phy.low_band_component = low_band_component_param;
  1256. if (low_band_component_type_param != -1)
  1257. priv->conf.phy.low_band_component_type =
  1258. low_band_component_type_param;
  1259. if (high_band_component_param != -1)
  1260. priv->conf.phy.high_band_component = high_band_component_param;
  1261. if (high_band_component_type_param != -1)
  1262. priv->conf.phy.high_band_component_type =
  1263. high_band_component_type_param;
  1264. if (pwr_limit_reference_11_abg_param != -1)
  1265. priv->conf.phy.pwr_limit_reference_11_abg =
  1266. pwr_limit_reference_11_abg_param;
  1267. if (n_antennas_2_param != -1)
  1268. priv->conf.phy.number_of_assembled_ant2_4 = n_antennas_2_param;
  1269. if (n_antennas_5_param != -1)
  1270. priv->conf.phy.number_of_assembled_ant5 = n_antennas_5_param;
  1271. if (dc2dc_param != -1)
  1272. priv->conf.phy.external_pa_dc2dc = dc2dc_param;
  1273. if (ht_mode_param) {
  1274. if (!strcmp(ht_mode_param, "default"))
  1275. priv->conf.ht.mode = HT_MODE_DEFAULT;
  1276. else if (!strcmp(ht_mode_param, "wide"))
  1277. priv->conf.ht.mode = HT_MODE_WIDE;
  1278. else if (!strcmp(ht_mode_param, "siso20"))
  1279. priv->conf.ht.mode = HT_MODE_SISO20;
  1280. else {
  1281. wl1271_error("invalid ht_mode '%s'", ht_mode_param);
  1282. return -EINVAL;
  1283. }
  1284. }
  1285. if (priv->conf.ht.mode == HT_MODE_DEFAULT) {
  1286. /*
  1287. * Only support mimo with multiple antennas. Fall back to
  1288. * siso40.
  1289. */
  1290. if (wl18xx_is_mimo_supported(wl))
  1291. wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ,
  1292. &wl18xx_mimo_ht_cap_2ghz);
  1293. else
  1294. wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ,
  1295. &wl18xx_siso40_ht_cap_2ghz);
  1296. /* 5Ghz is always wide */
  1297. wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ,
  1298. &wl18xx_siso40_ht_cap_5ghz);
  1299. } else if (priv->conf.ht.mode == HT_MODE_WIDE) {
  1300. wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ,
  1301. &wl18xx_siso40_ht_cap_2ghz);
  1302. wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ,
  1303. &wl18xx_siso40_ht_cap_5ghz);
  1304. } else if (priv->conf.ht.mode == HT_MODE_SISO20) {
  1305. wlcore_set_ht_cap(wl, IEEE80211_BAND_2GHZ,
  1306. &wl18xx_siso20_ht_cap);
  1307. wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ,
  1308. &wl18xx_siso20_ht_cap);
  1309. }
  1310. if (!checksum_param) {
  1311. wl18xx_ops.set_rx_csum = NULL;
  1312. wl18xx_ops.init_vif = NULL;
  1313. }
  1314. /* Enable 11a Band only if we have 5G antennas */
  1315. wl->enable_11a = (priv->conf.phy.number_of_assembled_ant5 != 0);
  1316. return 0;
  1317. }
  1318. static int __devinit wl18xx_probe(struct platform_device *pdev)
  1319. {
  1320. struct wl1271 *wl;
  1321. struct ieee80211_hw *hw;
  1322. int ret;
  1323. hw = wlcore_alloc_hw(sizeof(struct wl18xx_priv),
  1324. WL18XX_AGGR_BUFFER_SIZE);
  1325. if (IS_ERR(hw)) {
  1326. wl1271_error("can't allocate hw");
  1327. ret = PTR_ERR(hw);
  1328. goto out;
  1329. }
  1330. wl = hw->priv;
  1331. wl->ops = &wl18xx_ops;
  1332. wl->ptable = wl18xx_ptable;
  1333. ret = wlcore_probe(wl, pdev);
  1334. if (ret)
  1335. goto out_free;
  1336. return ret;
  1337. out_free:
  1338. wlcore_free_hw(wl);
  1339. out:
  1340. return ret;
  1341. }
  1342. static const struct platform_device_id wl18xx_id_table[] __devinitconst = {
  1343. { "wl18xx", 0 },
  1344. { } /* Terminating Entry */
  1345. };
  1346. MODULE_DEVICE_TABLE(platform, wl18xx_id_table);
  1347. static struct platform_driver wl18xx_driver = {
  1348. .probe = wl18xx_probe,
  1349. .remove = __devexit_p(wlcore_remove),
  1350. .id_table = wl18xx_id_table,
  1351. .driver = {
  1352. .name = "wl18xx_driver",
  1353. .owner = THIS_MODULE,
  1354. }
  1355. };
  1356. module_platform_driver(wl18xx_driver);
  1357. module_param_named(ht_mode, ht_mode_param, charp, S_IRUSR);
  1358. MODULE_PARM_DESC(ht_mode, "Force HT mode: wide or siso20");
  1359. module_param_named(board_type, board_type_param, charp, S_IRUSR);
  1360. MODULE_PARM_DESC(board_type, "Board type: fpga, hdk (default), evb, com8 or "
  1361. "dvp");
  1362. module_param_named(checksum, checksum_param, bool, S_IRUSR);
  1363. MODULE_PARM_DESC(checksum, "Enable TCP checksum: boolean (defaults to false)");
  1364. module_param_named(dc2dc, dc2dc_param, int, S_IRUSR);
  1365. MODULE_PARM_DESC(dc2dc, "External DC2DC: u8 (defaults to 0)");
  1366. module_param_named(n_antennas_2, n_antennas_2_param, int, S_IRUSR);
  1367. MODULE_PARM_DESC(n_antennas_2,
  1368. "Number of installed 2.4GHz antennas: 1 (default) or 2");
  1369. module_param_named(n_antennas_5, n_antennas_5_param, int, S_IRUSR);
  1370. MODULE_PARM_DESC(n_antennas_5,
  1371. "Number of installed 5GHz antennas: 1 (default) or 2");
  1372. module_param_named(low_band_component, low_band_component_param, int,
  1373. S_IRUSR);
  1374. MODULE_PARM_DESC(low_band_component, "Low band component: u8 "
  1375. "(default is 0x01)");
  1376. module_param_named(low_band_component_type, low_band_component_type_param,
  1377. int, S_IRUSR);
  1378. MODULE_PARM_DESC(low_band_component_type, "Low band component type: u8 "
  1379. "(default is 0x05 or 0x06 depending on the board_type)");
  1380. module_param_named(high_band_component, high_band_component_param, int,
  1381. S_IRUSR);
  1382. MODULE_PARM_DESC(high_band_component, "High band component: u8, "
  1383. "(default is 0x01)");
  1384. module_param_named(high_band_component_type, high_band_component_type_param,
  1385. int, S_IRUSR);
  1386. MODULE_PARM_DESC(high_band_component_type, "High band component type: u8 "
  1387. "(default is 0x09)");
  1388. module_param_named(pwr_limit_reference_11_abg,
  1389. pwr_limit_reference_11_abg_param, int, S_IRUSR);
  1390. MODULE_PARM_DESC(pwr_limit_reference_11_abg, "Power limit reference: u8 "
  1391. "(default is 0xc8)");
  1392. module_param_named(num_rx_desc,
  1393. num_rx_desc_param, int, S_IRUSR);
  1394. MODULE_PARM_DESC(num_rx_desc_param,
  1395. "Number of Rx descriptors: u8 (default is 32)");
  1396. MODULE_LICENSE("GPL v2");
  1397. MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
  1398. MODULE_FIRMWARE(WL18XX_FW_NAME);