init.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. *
  6. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/module.h>
  25. #include <linux/slab.h>
  26. #include "debug.h"
  27. #include "init.h"
  28. #include "wl12xx_80211.h"
  29. #include "acx.h"
  30. #include "cmd.h"
  31. #include "reg.h"
  32. #include "tx.h"
  33. #include "io.h"
  34. int wl1271_init_templates_config(struct wl1271 *wl)
  35. {
  36. int ret, i;
  37. /* send empty templates for fw memory reservation */
  38. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL,
  39. WL1271_CMD_TEMPL_DFLT_SIZE,
  40. 0, WL1271_RATE_AUTOMATIC);
  41. if (ret < 0)
  42. return ret;
  43. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
  44. NULL, WL1271_CMD_TEMPL_DFLT_SIZE, 0,
  45. WL1271_RATE_AUTOMATIC);
  46. if (ret < 0)
  47. return ret;
  48. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
  49. sizeof(struct wl12xx_null_data_template),
  50. 0, WL1271_RATE_AUTOMATIC);
  51. if (ret < 0)
  52. return ret;
  53. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
  54. sizeof(struct wl12xx_ps_poll_template),
  55. 0, WL1271_RATE_AUTOMATIC);
  56. if (ret < 0)
  57. return ret;
  58. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
  59. sizeof
  60. (struct ieee80211_qos_hdr),
  61. 0, WL1271_RATE_AUTOMATIC);
  62. if (ret < 0)
  63. return ret;
  64. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
  65. WL1271_CMD_TEMPL_DFLT_SIZE,
  66. 0, WL1271_RATE_AUTOMATIC);
  67. if (ret < 0)
  68. return ret;
  69. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
  70. WL1271_CMD_TEMPL_DFLT_SIZE,
  71. 0, WL1271_RATE_AUTOMATIC);
  72. if (ret < 0)
  73. return ret;
  74. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, NULL,
  75. sizeof
  76. (struct wl12xx_arp_rsp_template),
  77. 0, WL1271_RATE_AUTOMATIC);
  78. if (ret < 0)
  79. return ret;
  80. /*
  81. * Put very large empty placeholders for all templates. These
  82. * reserve memory for later.
  83. */
  84. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL,
  85. WL1271_CMD_TEMPL_MAX_SIZE,
  86. 0, WL1271_RATE_AUTOMATIC);
  87. if (ret < 0)
  88. return ret;
  89. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL,
  90. WL1271_CMD_TEMPL_MAX_SIZE,
  91. 0, WL1271_RATE_AUTOMATIC);
  92. if (ret < 0)
  93. return ret;
  94. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL,
  95. sizeof
  96. (struct wl12xx_disconn_template),
  97. 0, WL1271_RATE_AUTOMATIC);
  98. if (ret < 0)
  99. return ret;
  100. for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
  101. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL,
  102. sizeof(struct ieee80211_qos_hdr),
  103. i, WL1271_RATE_AUTOMATIC);
  104. if (ret < 0)
  105. return ret;
  106. }
  107. return 0;
  108. }
  109. static int wl1271_ap_init_deauth_template(struct wl1271 *wl,
  110. struct wl12xx_vif *wlvif)
  111. {
  112. struct wl12xx_disconn_template *tmpl;
  113. int ret;
  114. u32 rate;
  115. tmpl = kzalloc(sizeof(*tmpl), GFP_KERNEL);
  116. if (!tmpl) {
  117. ret = -ENOMEM;
  118. goto out;
  119. }
  120. tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
  121. IEEE80211_STYPE_DEAUTH);
  122. rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
  123. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP,
  124. tmpl, sizeof(*tmpl), 0, rate);
  125. out:
  126. kfree(tmpl);
  127. return ret;
  128. }
  129. static int wl1271_ap_init_null_template(struct wl1271 *wl,
  130. struct ieee80211_vif *vif)
  131. {
  132. struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
  133. struct ieee80211_hdr_3addr *nullfunc;
  134. int ret;
  135. u32 rate;
  136. nullfunc = kzalloc(sizeof(*nullfunc), GFP_KERNEL);
  137. if (!nullfunc) {
  138. ret = -ENOMEM;
  139. goto out;
  140. }
  141. nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
  142. IEEE80211_STYPE_NULLFUNC |
  143. IEEE80211_FCTL_FROMDS);
  144. /* nullfunc->addr1 is filled by FW */
  145. memcpy(nullfunc->addr2, vif->addr, ETH_ALEN);
  146. memcpy(nullfunc->addr3, vif->addr, ETH_ALEN);
  147. rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
  148. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc,
  149. sizeof(*nullfunc), 0, rate);
  150. out:
  151. kfree(nullfunc);
  152. return ret;
  153. }
  154. static int wl1271_ap_init_qos_null_template(struct wl1271 *wl,
  155. struct ieee80211_vif *vif)
  156. {
  157. struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
  158. struct ieee80211_qos_hdr *qosnull;
  159. int ret;
  160. u32 rate;
  161. qosnull = kzalloc(sizeof(*qosnull), GFP_KERNEL);
  162. if (!qosnull) {
  163. ret = -ENOMEM;
  164. goto out;
  165. }
  166. qosnull->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
  167. IEEE80211_STYPE_QOS_NULLFUNC |
  168. IEEE80211_FCTL_FROMDS);
  169. /* qosnull->addr1 is filled by FW */
  170. memcpy(qosnull->addr2, vif->addr, ETH_ALEN);
  171. memcpy(qosnull->addr3, vif->addr, ETH_ALEN);
  172. rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
  173. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull,
  174. sizeof(*qosnull), 0, rate);
  175. out:
  176. kfree(qosnull);
  177. return ret;
  178. }
  179. static int wl12xx_init_rx_config(struct wl1271 *wl)
  180. {
  181. int ret;
  182. ret = wl1271_acx_rx_msdu_life_time(wl);
  183. if (ret < 0)
  184. return ret;
  185. return 0;
  186. }
  187. static int wl12xx_init_phy_vif_config(struct wl1271 *wl,
  188. struct wl12xx_vif *wlvif)
  189. {
  190. int ret;
  191. ret = wl1271_acx_slot(wl, wlvif, DEFAULT_SLOT_TIME);
  192. if (ret < 0)
  193. return ret;
  194. ret = wl1271_acx_service_period_timeout(wl, wlvif);
  195. if (ret < 0)
  196. return ret;
  197. ret = wl1271_acx_rts_threshold(wl, wlvif, wl->hw->wiphy->rts_threshold);
  198. if (ret < 0)
  199. return ret;
  200. return 0;
  201. }
  202. static int wl1271_init_sta_beacon_filter(struct wl1271 *wl,
  203. struct wl12xx_vif *wlvif)
  204. {
  205. int ret;
  206. ret = wl1271_acx_beacon_filter_table(wl, wlvif);
  207. if (ret < 0)
  208. return ret;
  209. /* enable beacon filtering */
  210. ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true);
  211. if (ret < 0)
  212. return ret;
  213. return 0;
  214. }
  215. int wl1271_init_pta(struct wl1271 *wl)
  216. {
  217. int ret;
  218. ret = wl12xx_acx_sg_cfg(wl);
  219. if (ret < 0)
  220. return ret;
  221. ret = wl1271_acx_sg_enable(wl, wl->sg_enabled);
  222. if (ret < 0)
  223. return ret;
  224. return 0;
  225. }
  226. int wl1271_init_energy_detection(struct wl1271 *wl)
  227. {
  228. int ret;
  229. ret = wl1271_acx_cca_threshold(wl);
  230. if (ret < 0)
  231. return ret;
  232. return 0;
  233. }
  234. static int wl1271_init_beacon_broadcast(struct wl1271 *wl,
  235. struct wl12xx_vif *wlvif)
  236. {
  237. int ret;
  238. ret = wl1271_acx_bcn_dtim_options(wl, wlvif);
  239. if (ret < 0)
  240. return ret;
  241. return 0;
  242. }
  243. static int wl12xx_init_fwlog(struct wl1271 *wl)
  244. {
  245. int ret;
  246. if (wl->quirks & WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED)
  247. return 0;
  248. ret = wl12xx_cmd_config_fwlog(wl);
  249. if (ret < 0)
  250. return ret;
  251. return 0;
  252. }
  253. /* generic sta initialization (non vif-specific) */
  254. static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  255. {
  256. int ret;
  257. /* PS config */
  258. ret = wl12xx_acx_config_ps(wl, wlvif);
  259. if (ret < 0)
  260. return ret;
  261. /* FM WLAN coexistence */
  262. ret = wl1271_acx_fm_coex(wl);
  263. if (ret < 0)
  264. return ret;
  265. ret = wl1271_acx_sta_rate_policies(wl, wlvif);
  266. if (ret < 0)
  267. return ret;
  268. return 0;
  269. }
  270. static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl,
  271. struct ieee80211_vif *vif)
  272. {
  273. struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
  274. int ret, i;
  275. /* disable all keep-alive templates */
  276. for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) {
  277. ret = wl1271_acx_keep_alive_config(wl, wlvif, i,
  278. ACX_KEEP_ALIVE_TPL_INVALID);
  279. if (ret < 0)
  280. return ret;
  281. }
  282. /* disable the keep-alive feature */
  283. ret = wl1271_acx_keep_alive_mode(wl, wlvif, false);
  284. if (ret < 0)
  285. return ret;
  286. return 0;
  287. }
  288. /* generic ap initialization (non vif-specific) */
  289. static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  290. {
  291. int ret;
  292. ret = wl1271_init_ap_rates(wl, wlvif);
  293. if (ret < 0)
  294. return ret;
  295. return 0;
  296. }
  297. int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif)
  298. {
  299. struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
  300. int ret;
  301. ret = wl1271_ap_init_deauth_template(wl, wlvif);
  302. if (ret < 0)
  303. return ret;
  304. ret = wl1271_ap_init_null_template(wl, vif);
  305. if (ret < 0)
  306. return ret;
  307. ret = wl1271_ap_init_qos_null_template(wl, vif);
  308. if (ret < 0)
  309. return ret;
  310. /*
  311. * when operating as AP we want to receive external beacons for
  312. * configuring ERP protection.
  313. */
  314. ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false);
  315. if (ret < 0)
  316. return ret;
  317. return 0;
  318. }
  319. static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl,
  320. struct ieee80211_vif *vif)
  321. {
  322. return wl1271_ap_init_templates(wl, vif);
  323. }
  324. int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  325. {
  326. int i, ret;
  327. struct conf_tx_rate_class rc;
  328. u32 supported_rates;
  329. wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x",
  330. wlvif->basic_rate_set);
  331. if (wlvif->basic_rate_set == 0)
  332. return -EINVAL;
  333. rc.enabled_rates = wlvif->basic_rate_set;
  334. rc.long_retry_limit = 10;
  335. rc.short_retry_limit = 10;
  336. rc.aflags = 0;
  337. ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.mgmt_rate_idx);
  338. if (ret < 0)
  339. return ret;
  340. /* use the min basic rate for AP broadcast/multicast */
  341. rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
  342. rc.short_retry_limit = 10;
  343. rc.long_retry_limit = 10;
  344. rc.aflags = 0;
  345. ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.bcast_rate_idx);
  346. if (ret < 0)
  347. return ret;
  348. /*
  349. * If the basic rates contain OFDM rates, use OFDM only
  350. * rates for unicast TX as well. Else use all supported rates.
  351. */
  352. if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES))
  353. supported_rates = CONF_TX_OFDM_RATES;
  354. else
  355. supported_rates = CONF_TX_AP_ENABLED_RATES;
  356. /* unconditionally enable HT rates */
  357. supported_rates |= CONF_TX_MCS_RATES;
  358. /* configure unicast TX rate classes */
  359. for (i = 0; i < wl->conf.tx.ac_conf_count; i++) {
  360. rc.enabled_rates = supported_rates;
  361. rc.short_retry_limit = 10;
  362. rc.long_retry_limit = 10;
  363. rc.aflags = 0;
  364. ret = wl1271_acx_ap_rate_policy(wl, &rc,
  365. wlvif->ap.ucast_rate_idx[i]);
  366. if (ret < 0)
  367. return ret;
  368. }
  369. return 0;
  370. }
  371. static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  372. {
  373. /* Reset the BA RX indicators */
  374. wlvif->ba_allowed = true;
  375. wl->ba_rx_session_count = 0;
  376. /* BA is supported in STA/AP modes */
  377. if (wlvif->bss_type != BSS_TYPE_AP_BSS &&
  378. wlvif->bss_type != BSS_TYPE_STA_BSS) {
  379. wlvif->ba_support = false;
  380. return 0;
  381. }
  382. wlvif->ba_support = true;
  383. /* 802.11n initiator BA session setting */
  384. return wl12xx_acx_set_ba_initiator_policy(wl, wlvif);
  385. }
  386. int wl1271_chip_specific_init(struct wl1271 *wl)
  387. {
  388. int ret = 0;
  389. if (wl->chip.id == CHIP_ID_1283_PG20) {
  390. u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE;
  391. if (!(wl->quirks & WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT))
  392. /* Enable SDIO padding */
  393. host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK;
  394. /* Must be before wl1271_acx_init_mem_config() */
  395. ret = wl1271_acx_host_if_cfg_bitmap(wl, host_cfg_bitmap);
  396. if (ret < 0)
  397. goto out;
  398. }
  399. out:
  400. return ret;
  401. }
  402. /* vif-specifc initialization */
  403. static int wl12xx_init_sta_role(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  404. {
  405. int ret;
  406. ret = wl1271_acx_group_address_tbl(wl, wlvif, true, NULL, 0);
  407. if (ret < 0)
  408. return ret;
  409. /* Initialize connection monitoring thresholds */
  410. ret = wl1271_acx_conn_monit_params(wl, wlvif, false);
  411. if (ret < 0)
  412. return ret;
  413. /* Beacon filtering */
  414. ret = wl1271_init_sta_beacon_filter(wl, wlvif);
  415. if (ret < 0)
  416. return ret;
  417. /* Beacons and broadcast settings */
  418. ret = wl1271_init_beacon_broadcast(wl, wlvif);
  419. if (ret < 0)
  420. return ret;
  421. /* Configure rssi/snr averaging weights */
  422. ret = wl1271_acx_rssi_snr_avg_weights(wl, wlvif);
  423. if (ret < 0)
  424. return ret;
  425. return 0;
  426. }
  427. /* vif-specific intialization */
  428. static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif)
  429. {
  430. int ret;
  431. ret = wl1271_acx_ap_max_tx_retry(wl, wlvif);
  432. if (ret < 0)
  433. return ret;
  434. /* initialize Tx power */
  435. ret = wl1271_acx_tx_power(wl, wlvif, wlvif->power_level);
  436. if (ret < 0)
  437. return ret;
  438. return 0;
  439. }
  440. int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif)
  441. {
  442. struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
  443. struct conf_tx_ac_category *conf_ac;
  444. struct conf_tx_tid *conf_tid;
  445. bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
  446. int ret, i;
  447. /*
  448. * consider all existing roles before configuring psm.
  449. * TODO: reconfigure on interface removal.
  450. */
  451. if (!wl->ap_count) {
  452. if (is_ap) {
  453. /* Configure for power always on */
  454. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM);
  455. if (ret < 0)
  456. return ret;
  457. } else if (!wl->sta_count) {
  458. /* Configure for ELP power saving */
  459. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
  460. if (ret < 0)
  461. return ret;
  462. }
  463. }
  464. /* Mode specific init */
  465. if (is_ap) {
  466. ret = wl1271_ap_hw_init(wl, wlvif);
  467. if (ret < 0)
  468. return ret;
  469. ret = wl12xx_init_ap_role(wl, wlvif);
  470. if (ret < 0)
  471. return ret;
  472. } else {
  473. ret = wl1271_sta_hw_init(wl, wlvif);
  474. if (ret < 0)
  475. return ret;
  476. ret = wl12xx_init_sta_role(wl, wlvif);
  477. if (ret < 0)
  478. return ret;
  479. }
  480. wl12xx_init_phy_vif_config(wl, wlvif);
  481. /* Default TID/AC configuration */
  482. BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count);
  483. for (i = 0; i < wl->conf.tx.tid_conf_count; i++) {
  484. conf_ac = &wl->conf.tx.ac_conf[i];
  485. ret = wl1271_acx_ac_cfg(wl, wlvif, conf_ac->ac,
  486. conf_ac->cw_min, conf_ac->cw_max,
  487. conf_ac->aifsn, conf_ac->tx_op_limit);
  488. if (ret < 0)
  489. return ret;
  490. conf_tid = &wl->conf.tx.tid_conf[i];
  491. ret = wl1271_acx_tid_cfg(wl, wlvif,
  492. conf_tid->queue_id,
  493. conf_tid->channel_type,
  494. conf_tid->tsid,
  495. conf_tid->ps_scheme,
  496. conf_tid->ack_policy,
  497. conf_tid->apsd_conf[0],
  498. conf_tid->apsd_conf[1]);
  499. if (ret < 0)
  500. return ret;
  501. }
  502. /* Configure HW encryption */
  503. ret = wl1271_acx_feature_cfg(wl, wlvif);
  504. if (ret < 0)
  505. return ret;
  506. /* Mode specific init - post mem init */
  507. if (is_ap)
  508. ret = wl1271_ap_hw_init_post_mem(wl, vif);
  509. else
  510. ret = wl1271_sta_hw_init_post_mem(wl, vif);
  511. if (ret < 0)
  512. return ret;
  513. /* Configure initiator BA sessions policies */
  514. ret = wl1271_set_ba_policies(wl, wlvif);
  515. if (ret < 0)
  516. return ret;
  517. return 0;
  518. }
  519. int wl1271_hw_init(struct wl1271 *wl)
  520. {
  521. int ret;
  522. if (wl->chip.id == CHIP_ID_1283_PG20) {
  523. ret = wl128x_cmd_general_parms(wl);
  524. if (ret < 0)
  525. return ret;
  526. ret = wl128x_cmd_radio_parms(wl);
  527. if (ret < 0)
  528. return ret;
  529. } else {
  530. ret = wl1271_cmd_general_parms(wl);
  531. if (ret < 0)
  532. return ret;
  533. ret = wl1271_cmd_radio_parms(wl);
  534. if (ret < 0)
  535. return ret;
  536. ret = wl1271_cmd_ext_radio_parms(wl);
  537. if (ret < 0)
  538. return ret;
  539. }
  540. /* Chip-specific init */
  541. ret = wl1271_chip_specific_init(wl);
  542. if (ret < 0)
  543. return ret;
  544. /* Init templates */
  545. ret = wl1271_init_templates_config(wl);
  546. if (ret < 0)
  547. return ret;
  548. ret = wl12xx_acx_mem_cfg(wl);
  549. if (ret < 0)
  550. return ret;
  551. /* Configure the FW logger */
  552. ret = wl12xx_init_fwlog(wl);
  553. if (ret < 0)
  554. return ret;
  555. /* Bluetooth WLAN coexistence */
  556. ret = wl1271_init_pta(wl);
  557. if (ret < 0)
  558. return ret;
  559. /* Default memory configuration */
  560. ret = wl1271_acx_init_mem_config(wl);
  561. if (ret < 0)
  562. return ret;
  563. /* RX config */
  564. ret = wl12xx_init_rx_config(wl);
  565. if (ret < 0)
  566. goto out_free_memmap;
  567. ret = wl1271_acx_dco_itrim_params(wl);
  568. if (ret < 0)
  569. goto out_free_memmap;
  570. /* Configure TX patch complete interrupt behavior */
  571. ret = wl1271_acx_tx_config_options(wl);
  572. if (ret < 0)
  573. goto out_free_memmap;
  574. /* RX complete interrupt pacing */
  575. ret = wl1271_acx_init_rx_interrupt(wl);
  576. if (ret < 0)
  577. goto out_free_memmap;
  578. /* Energy detection */
  579. ret = wl1271_init_energy_detection(wl);
  580. if (ret < 0)
  581. goto out_free_memmap;
  582. /* Default fragmentation threshold */
  583. ret = wl1271_acx_frag_threshold(wl, wl->hw->wiphy->frag_threshold);
  584. if (ret < 0)
  585. goto out_free_memmap;
  586. /* Enable data path */
  587. ret = wl1271_cmd_data_path(wl, 1);
  588. if (ret < 0)
  589. goto out_free_memmap;
  590. /* configure PM */
  591. ret = wl1271_acx_pm_config(wl);
  592. if (ret < 0)
  593. goto out_free_memmap;
  594. ret = wl12xx_acx_set_rate_mgmt_params(wl);
  595. if (ret < 0)
  596. goto out_free_memmap;
  597. /* configure hangover */
  598. ret = wl12xx_acx_config_hangover(wl);
  599. if (ret < 0)
  600. goto out_free_memmap;
  601. return 0;
  602. out_free_memmap:
  603. kfree(wl->target_mem_map);
  604. wl->target_mem_map = NULL;
  605. return ret;
  606. }