wl1271_init.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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 "wl1271_init.h"
  26. #include "wl12xx_80211.h"
  27. #include "wl1271_acx.h"
  28. #include "wl1271_cmd.h"
  29. #include "wl1271_reg.h"
  30. static int wl1271_init_hwenc_config(struct wl1271 *wl)
  31. {
  32. int ret;
  33. ret = wl1271_acx_feature_cfg(wl);
  34. if (ret < 0) {
  35. wl1271_warning("couldn't set feature config");
  36. return ret;
  37. }
  38. ret = wl1271_cmd_set_default_wep_key(wl, wl->default_key);
  39. if (ret < 0) {
  40. wl1271_warning("couldn't set default key");
  41. return ret;
  42. }
  43. return 0;
  44. }
  45. static int wl1271_init_templates_config(struct wl1271 *wl)
  46. {
  47. int ret;
  48. /* send empty templates for fw memory reservation */
  49. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, NULL,
  50. sizeof(struct wl12xx_probe_req_template));
  51. if (ret < 0)
  52. return ret;
  53. if (wl1271_11a_enabled()) {
  54. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
  55. NULL,
  56. sizeof(struct wl12xx_probe_req_template));
  57. if (ret < 0)
  58. return ret;
  59. }
  60. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL,
  61. sizeof(struct wl12xx_null_data_template));
  62. if (ret < 0)
  63. return ret;
  64. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, NULL,
  65. sizeof(struct wl12xx_ps_poll_template));
  66. if (ret < 0)
  67. return ret;
  68. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL,
  69. sizeof
  70. (struct wl12xx_qos_null_data_template));
  71. if (ret < 0)
  72. return ret;
  73. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PROBE_RESPONSE, NULL,
  74. sizeof
  75. (struct wl12xx_probe_resp_template));
  76. if (ret < 0)
  77. return ret;
  78. ret = wl1271_cmd_template_set(wl, CMD_TEMPL_BEACON, NULL,
  79. sizeof
  80. (struct wl12xx_beacon_template));
  81. if (ret < 0)
  82. return ret;
  83. return 0;
  84. }
  85. static int wl1271_init_rx_config(struct wl1271 *wl, u32 config, u32 filter)
  86. {
  87. int ret;
  88. ret = wl1271_acx_rx_msdu_life_time(wl);
  89. if (ret < 0)
  90. return ret;
  91. ret = wl1271_acx_rx_config(wl, config, filter);
  92. if (ret < 0)
  93. return ret;
  94. return 0;
  95. }
  96. static int wl1271_init_phy_config(struct wl1271 *wl)
  97. {
  98. int ret;
  99. ret = wl1271_acx_pd_threshold(wl);
  100. if (ret < 0)
  101. return ret;
  102. ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME);
  103. if (ret < 0)
  104. return ret;
  105. ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0);
  106. if (ret < 0)
  107. return ret;
  108. ret = wl1271_acx_service_period_timeout(wl);
  109. if (ret < 0)
  110. return ret;
  111. ret = wl1271_acx_rts_threshold(wl, wl->conf.rx.rts_threshold);
  112. if (ret < 0)
  113. return ret;
  114. return 0;
  115. }
  116. static int wl1271_init_beacon_filter(struct wl1271 *wl)
  117. {
  118. int ret;
  119. /* disable beacon filtering at this stage */
  120. ret = wl1271_acx_beacon_filter_opt(wl, false);
  121. if (ret < 0)
  122. return ret;
  123. ret = wl1271_acx_beacon_filter_table(wl);
  124. if (ret < 0)
  125. return ret;
  126. return 0;
  127. }
  128. static int wl1271_init_pta(struct wl1271 *wl)
  129. {
  130. int ret;
  131. ret = wl1271_acx_sg_enable(wl);
  132. if (ret < 0)
  133. return ret;
  134. ret = wl1271_acx_sg_cfg(wl);
  135. if (ret < 0)
  136. return ret;
  137. return 0;
  138. }
  139. static int wl1271_init_energy_detection(struct wl1271 *wl)
  140. {
  141. int ret;
  142. ret = wl1271_acx_cca_threshold(wl);
  143. if (ret < 0)
  144. return ret;
  145. return 0;
  146. }
  147. static int wl1271_init_beacon_broadcast(struct wl1271 *wl)
  148. {
  149. int ret;
  150. ret = wl1271_acx_bcn_dtim_options(wl);
  151. if (ret < 0)
  152. return ret;
  153. return 0;
  154. }
  155. int wl1271_hw_init(struct wl1271 *wl)
  156. {
  157. int ret;
  158. ret = wl1271_cmd_general_parms(wl);
  159. if (ret < 0)
  160. return ret;
  161. ret = wl1271_cmd_radio_parms(wl);
  162. if (ret < 0)
  163. return ret;
  164. /* Template settings */
  165. ret = wl1271_init_templates_config(wl);
  166. if (ret < 0)
  167. return ret;
  168. /* Default memory configuration */
  169. ret = wl1271_acx_init_mem_config(wl);
  170. if (ret < 0)
  171. return ret;
  172. /* RX config */
  173. ret = wl1271_init_rx_config(wl,
  174. RX_CFG_PROMISCUOUS | RX_CFG_TSF,
  175. RX_FILTER_OPTION_DEF);
  176. /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS,
  177. RX_FILTER_OPTION_FILTER_ALL); */
  178. if (ret < 0)
  179. goto out_free_memmap;
  180. /* PHY layer config */
  181. ret = wl1271_init_phy_config(wl);
  182. if (ret < 0)
  183. goto out_free_memmap;
  184. /* Initialize connection monitoring thresholds */
  185. ret = wl1271_acx_conn_monit_params(wl);
  186. if (ret < 0)
  187. goto out_free_memmap;
  188. /* Beacon filtering */
  189. ret = wl1271_init_beacon_filter(wl);
  190. if (ret < 0)
  191. goto out_free_memmap;
  192. /* Configure TX patch complete interrupt behavior */
  193. ret = wl1271_acx_tx_config_options(wl);
  194. if (ret < 0)
  195. goto out_free_memmap;
  196. /* RX complete interrupt pacing */
  197. ret = wl1271_acx_init_rx_interrupt(wl);
  198. if (ret < 0)
  199. goto out_free_memmap;
  200. /* Bluetooth WLAN coexistence */
  201. ret = wl1271_init_pta(wl);
  202. if (ret < 0)
  203. goto out_free_memmap;
  204. /* Energy detection */
  205. ret = wl1271_init_energy_detection(wl);
  206. if (ret < 0)
  207. goto out_free_memmap;
  208. /* Beacons and boradcast settings */
  209. ret = wl1271_init_beacon_broadcast(wl);
  210. if (ret < 0)
  211. goto out_free_memmap;
  212. /* Default fragmentation threshold */
  213. ret = wl1271_acx_frag_threshold(wl);
  214. if (ret < 0)
  215. goto out_free_memmap;
  216. /* Default TID configuration */
  217. ret = wl1271_acx_tid_cfg(wl);
  218. if (ret < 0)
  219. goto out_free_memmap;
  220. /* Default AC configuration */
  221. ret = wl1271_acx_ac_cfg(wl);
  222. if (ret < 0)
  223. goto out_free_memmap;
  224. /* Configure TX rate classes */
  225. ret = wl1271_acx_rate_policies(wl, CONF_TX_RATE_MASK_ALL);
  226. if (ret < 0)
  227. goto out_free_memmap;
  228. /* Enable data path */
  229. ret = wl1271_cmd_data_path(wl, wl->channel, 1);
  230. if (ret < 0)
  231. goto out_free_memmap;
  232. /* Configure for ELP power saving */
  233. ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP);
  234. if (ret < 0)
  235. goto out_free_memmap;
  236. /* Configure HW encryption */
  237. ret = wl1271_init_hwenc_config(wl);
  238. if (ret < 0)
  239. goto out_free_memmap;
  240. /* Configure smart reflex */
  241. ret = wl1271_acx_smart_reflex(wl);
  242. if (ret < 0)
  243. goto out_free_memmap;
  244. return 0;
  245. out_free_memmap:
  246. kfree(wl->target_mem_map);
  247. wl->target_mem_map = NULL;
  248. return ret;
  249. }