halmac_init_88xx.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2016 - 2018 Realtek Corporation. All rights reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. ******************************************************************************/
  15. #include "halmac_init_88xx.h"
  16. #include "halmac_88xx_cfg.h"
  17. #include "halmac_fw_88xx.h"
  18. #include "halmac_common_88xx.h"
  19. #include "halmac_cfg_wmac_88xx.h"
  20. #include "halmac_efuse_88xx.h"
  21. #include "halmac_mimo_88xx.h"
  22. #include "halmac_bb_rf_88xx.h"
  23. #if HALMAC_SDIO_SUPPORT
  24. #include "halmac_sdio_88xx.h"
  25. #endif
  26. #if HALMAC_USB_SUPPORT
  27. #include "halmac_usb_88xx.h"
  28. #endif
  29. #if HALMAC_PCIE_SUPPORT
  30. #include "halmac_pcie_88xx.h"
  31. #endif
  32. #include "halmac_gpio_88xx.h"
  33. #include "halmac_flash_88xx.h"
  34. #if HALMAC_8822B_SUPPORT
  35. #include "halmac_8822b/halmac_init_8822b.h"
  36. #endif
  37. #if HALMAC_8821C_SUPPORT
  38. #include "halmac_8821c/halmac_init_8821c.h"
  39. #endif
  40. #if HALMAC_8822C_SUPPORT
  41. #include "halmac_8822c/halmac_init_8822c.h"
  42. #endif
  43. #if HALMAC_8812F_SUPPORT
  44. #include "halmac_8812f/halmac_init_8812f.h"
  45. #endif
  46. #if HALMAC_PLATFORM_TESTPROGRAM
  47. #include "halmisc_api_88xx.h"
  48. #endif
  49. #if HALMAC_88XX_SUPPORT
  50. #define PLTFM_INFO_MALLOC_MAX_SIZE 16384
  51. #define PLTFM_INFO_RSVD_PG_SIZE 16384
  52. #define DLFW_PKT_MAX_SIZE 8192 /* need multiple of 2 */
  53. #define SYS_FUNC_EN 0xD8
  54. static void
  55. init_state_machine_88xx(struct halmac_adapter *adapter);
  56. static enum halmac_ret_status
  57. verify_io_88xx(struct halmac_adapter *adapter);
  58. static enum halmac_ret_status
  59. verify_send_rsvd_page_88xx(struct halmac_adapter *adapter);
  60. void
  61. init_adapter_param_88xx(struct halmac_adapter *adapter)
  62. {
  63. adapter->api_registry.rx_exp_en = 1;
  64. adapter->api_registry.la_mode_en = 1;
  65. adapter->api_registry.cfg_drv_rsvd_pg_en = 1;
  66. adapter->api_registry.sdio_cmd53_4byte_en = 1;
  67. adapter->efuse_map = (u8 *)NULL;
  68. adapter->efuse_map_valid = 0;
  69. adapter->efuse_end = 0;
  70. adapter->dlfw_pkt_size = DLFW_PKT_MAX_SIZE;
  71. adapter->pltfm_info.malloc_size = PLTFM_INFO_MALLOC_MAX_SIZE;
  72. adapter->pltfm_info.rsvd_pg_size = PLTFM_INFO_RSVD_PG_SIZE;
  73. adapter->cfg_param_info.buf = NULL;
  74. adapter->cfg_param_info.buf_wptr = NULL;
  75. adapter->cfg_param_info.num = 0;
  76. adapter->cfg_param_info.full_fifo_mode = 0;
  77. adapter->cfg_param_info.buf_size = 0;
  78. adapter->cfg_param_info.avl_buf_size = 0;
  79. adapter->cfg_param_info.offset_accum = 0;
  80. adapter->cfg_param_info.value_accum = 0;
  81. adapter->ch_sw_info.buf = NULL;
  82. adapter->ch_sw_info.buf_wptr = NULL;
  83. adapter->ch_sw_info.extra_info_en = 0;
  84. adapter->ch_sw_info.buf_size = 0;
  85. adapter->ch_sw_info.avl_buf_size = 0;
  86. adapter->ch_sw_info.total_size = 0;
  87. adapter->ch_sw_info.ch_num = 0;
  88. adapter->drv_info_size = 0;
  89. adapter->tx_desc_transfer = 0;
  90. adapter->txff_alloc.tx_fifo_pg_num = 0;
  91. adapter->txff_alloc.acq_pg_num = 0;
  92. adapter->txff_alloc.rsvd_boundary = 0;
  93. adapter->txff_alloc.rsvd_drv_addr = 0;
  94. adapter->txff_alloc.rsvd_h2c_info_addr = 0;
  95. adapter->txff_alloc.rsvd_h2cq_addr = 0;
  96. adapter->txff_alloc.rsvd_cpu_instr_addr = 0;
  97. adapter->txff_alloc.rsvd_fw_txbuf_addr = 0;
  98. adapter->txff_alloc.pub_queue_pg_num = 0;
  99. adapter->txff_alloc.high_queue_pg_num = 0;
  100. adapter->txff_alloc.low_queue_pg_num = 0;
  101. adapter->txff_alloc.normal_queue_pg_num = 0;
  102. adapter->txff_alloc.extra_queue_pg_num = 0;
  103. adapter->txff_alloc.la_mode = HALMAC_LA_MODE_DISABLE;
  104. adapter->txff_alloc.rx_fifo_exp_mode =
  105. HALMAC_RX_FIFO_EXPANDING_MODE_DISABLE;
  106. adapter->hw_cfg_info.chk_security_keyid = 0;
  107. adapter->hw_cfg_info.acq_num = 8;
  108. adapter->hw_cfg_info.page_size = TX_PAGE_SIZE_88XX;
  109. adapter->hw_cfg_info.tx_align_size = TX_ALIGN_SIZE_88XX;
  110. adapter->hw_cfg_info.txdesc_size = TX_DESC_SIZE_88XX;
  111. adapter->hw_cfg_info.rxdesc_size = RX_DESC_SIZE_88XX;
  112. adapter->hw_cfg_info.rx_desc_fifo_size = 0;
  113. adapter->sdio_cmd53_4byte = HALMAC_SDIO_CMD53_4BYTE_MODE_DISABLE;
  114. adapter->sdio_hw_info.io_hi_speed_flag = 0;
  115. adapter->sdio_hw_info.io_indir_flag = 0;
  116. adapter->sdio_hw_info.spec_ver = HALMAC_SDIO_SPEC_VER_2_00;
  117. adapter->sdio_hw_info.clock_speed = 50;
  118. adapter->sdio_hw_info.block_size = 512;
  119. adapter->sdio_hw_info.tx_seq = 1;
  120. adapter->sdio_fs.macid_map = (u8 *)NULL;
  121. adapter->pinmux_info.wl_led = 0;
  122. adapter->pinmux_info.sdio_int = 0;
  123. adapter->pinmux_info.sw_io_0 = 0;
  124. adapter->pinmux_info.sw_io_1 = 0;
  125. adapter->pinmux_info.sw_io_2 = 0;
  126. adapter->pinmux_info.sw_io_3 = 0;
  127. adapter->pinmux_info.sw_io_4 = 0;
  128. adapter->pinmux_info.sw_io_5 = 0;
  129. adapter->pinmux_info.sw_io_6 = 0;
  130. adapter->pinmux_info.sw_io_7 = 0;
  131. adapter->pinmux_info.sw_io_8 = 0;
  132. adapter->pinmux_info.sw_io_9 = 0;
  133. adapter->pinmux_info.sw_io_10 = 0;
  134. adapter->pinmux_info.sw_io_11 = 0;
  135. adapter->pinmux_info.sw_io_12 = 0;
  136. adapter->pinmux_info.sw_io_13 = 0;
  137. adapter->pinmux_info.sw_io_14 = 0;
  138. adapter->pinmux_info.sw_io_15 = 0;
  139. adapter->pcie_refautok_en = 1;
  140. adapter->pwr_off_flow_flag = 0;
  141. adapter->rx_ignore_info.hdr_chk_mask = 1;
  142. adapter->rx_ignore_info.fcs_chk_mask = 1;
  143. adapter->rx_ignore_info.hdr_chk_en = 0;
  144. adapter->rx_ignore_info.fcs_chk_en = 0;
  145. adapter->rx_ignore_info.cck_rst_en = 0;
  146. adapter->rx_ignore_info.fcs_chk_thr = HALMAC_PSF_FCS_CHK_THR_28;
  147. init_adapter_dynamic_param_88xx(adapter);
  148. init_state_machine_88xx(adapter);
  149. }
  150. void
  151. init_adapter_dynamic_param_88xx(struct halmac_adapter *adapter)
  152. {
  153. adapter->h2c_info.seq_num = 0;
  154. adapter->h2c_info.buf_fs = 0;
  155. }
  156. enum halmac_ret_status
  157. mount_api_88xx(struct halmac_adapter *adapter)
  158. {
  159. struct halmac_api *api = NULL;
  160. adapter->halmac_api =
  161. (struct halmac_api *)PLTFM_MALLOC(sizeof(struct halmac_api));
  162. if (!adapter->halmac_api)
  163. return HALMAC_RET_MALLOC_FAIL;
  164. api = (struct halmac_api *)adapter->halmac_api;
  165. api->halmac_read_efuse = NULL;
  166. api->halmac_write_efuse = NULL;
  167. /* Mount function pointer */
  168. api->halmac_register_api = register_api_88xx;
  169. api->halmac_download_firmware = download_firmware_88xx;
  170. api->halmac_free_download_firmware = free_download_firmware_88xx;
  171. api->halmac_get_fw_version = get_fw_version_88xx;
  172. api->halmac_cfg_mac_addr = cfg_mac_addr_88xx;
  173. api->halmac_cfg_bssid = cfg_bssid_88xx;
  174. api->halmac_cfg_transmitter_addr = cfg_transmitter_addr_88xx;
  175. api->halmac_cfg_net_type = cfg_net_type_88xx;
  176. api->halmac_cfg_tsf_rst = cfg_tsf_rst_88xx;
  177. api->halmac_cfg_bcn_space = cfg_bcn_space_88xx;
  178. api->halmac_rw_bcn_ctrl = rw_bcn_ctrl_88xx;
  179. api->halmac_cfg_multicast_addr = cfg_multicast_addr_88xx;
  180. api->halmac_pre_init_system_cfg = pre_init_system_cfg_88xx;
  181. api->halmac_init_system_cfg = init_system_cfg_88xx;
  182. api->halmac_cfg_operation_mode = cfg_operation_mode_88xx;
  183. api->halmac_cfg_ch_bw = cfg_ch_bw_88xx;
  184. api->halmac_cfg_bw = cfg_bw_88xx;
  185. api->halmac_init_mac_cfg = init_mac_cfg_88xx;
  186. api->halmac_dump_efuse_map = dump_efuse_map_88xx;
  187. api->halmac_dump_efuse_map_bt = dump_efuse_map_bt_88xx;
  188. api->halmac_write_efuse_bt = write_efuse_bt_88xx;
  189. api->halmac_read_efuse_bt = read_efuse_bt_88xx;
  190. api->halmac_cfg_efuse_auto_check = cfg_efuse_auto_check_88xx;
  191. api->halmac_dump_logical_efuse_map = dump_log_efuse_map_88xx;
  192. api->halmac_pg_efuse_by_map = pg_efuse_by_map_88xx;
  193. api->halmac_mask_logical_efuse = mask_log_efuse_88xx;
  194. api->halmac_get_efuse_size = get_efuse_size_88xx;
  195. api->halmac_get_efuse_available_size = get_efuse_available_size_88xx;
  196. api->halmac_get_c2h_info = get_c2h_info_88xx;
  197. api->halmac_get_logical_efuse_size = get_log_efuse_size_88xx;
  198. api->halmac_write_logical_efuse = write_log_efuse_88xx;
  199. api->halmac_read_logical_efuse = read_logical_efuse_88xx;
  200. api->halmac_ofld_func_cfg = ofld_func_cfg_88xx;
  201. api->halmac_h2c_lb = h2c_lb_88xx;
  202. api->halmac_debug = mac_debug_88xx;
  203. api->halmac_cfg_parameter = cfg_parameter_88xx;
  204. api->halmac_update_datapack = update_datapack_88xx;
  205. api->halmac_run_datapack = run_datapack_88xx;
  206. api->halmac_send_bt_coex = send_bt_coex_88xx;
  207. api->halmac_verify_platform_api = verify_platform_api_88xx;
  208. api->halmac_update_packet = update_packet_88xx;
  209. api->halmac_bcn_ie_filter = bcn_ie_filter_88xx;
  210. api->halmac_cfg_txbf = cfg_txbf_88xx;
  211. api->halmac_cfg_mumimo = cfg_mumimo_88xx;
  212. api->halmac_cfg_sounding = cfg_sounding_88xx;
  213. api->halmac_del_sounding = del_sounding_88xx;
  214. api->halmac_su_bfer_entry_init = su_bfer_entry_init_88xx;
  215. api->halmac_su_bfee_entry_init = su_bfee_entry_init_88xx;
  216. api->halmac_mu_bfer_entry_init = mu_bfer_entry_init_88xx;
  217. api->halmac_mu_bfee_entry_init = mu_bfee_entry_init_88xx;
  218. api->halmac_su_bfer_entry_del = su_bfer_entry_del_88xx;
  219. api->halmac_su_bfee_entry_del = su_bfee_entry_del_88xx;
  220. api->halmac_mu_bfer_entry_del = mu_bfer_entry_del_88xx;
  221. api->halmac_mu_bfee_entry_del = mu_bfee_entry_del_88xx;
  222. api->halmac_add_ch_info = add_ch_info_88xx;
  223. api->halmac_add_extra_ch_info = add_extra_ch_info_88xx;
  224. api->halmac_ctrl_ch_switch = ctrl_ch_switch_88xx;
  225. api->halmac_p2pps = p2pps_88xx;
  226. api->halmac_clear_ch_info = clear_ch_info_88xx;
  227. api->halmac_send_general_info = send_general_info_88xx;
  228. api->halmac_start_iqk = start_iqk_88xx;
  229. api->halmac_ctrl_pwr_tracking = ctrl_pwr_tracking_88xx;
  230. api->halmac_psd = psd_88xx;
  231. api->halmac_cfg_la_mode = cfg_la_mode_88xx;
  232. api->halmac_cfg_rxff_expand_mode = cfg_rxfifo_expand_mode_88xx;
  233. api->halmac_config_security = config_security_88xx;
  234. api->halmac_get_used_cam_entry_num = get_used_cam_entry_num_88xx;
  235. api->halmac_read_cam_entry = read_cam_entry_88xx;
  236. api->halmac_write_cam = write_cam_88xx;
  237. api->halmac_clear_cam_entry = clear_cam_entry_88xx;
  238. api->halmac_cfg_drv_rsvd_pg_num = cfg_drv_rsvd_pg_num_88xx;
  239. api->halmac_get_chip_version = get_version_88xx;
  240. api->halmac_query_status = query_status_88xx;
  241. api->halmac_reset_feature = reset_ofld_feature_88xx;
  242. api->halmac_check_fw_status = check_fw_status_88xx;
  243. api->halmac_dump_fw_dmem = dump_fw_dmem_88xx;
  244. api->halmac_cfg_max_dl_size = cfg_max_dl_size_88xx;
  245. api->halmac_dump_fifo = dump_fifo_88xx;
  246. api->halmac_get_fifo_size = get_fifo_size_88xx;
  247. api->halmac_chk_txdesc = chk_txdesc_88xx;
  248. api->halmac_dl_drv_rsvd_page = dl_drv_rsvd_page_88xx;
  249. api->halmac_cfg_csi_rate = cfg_csi_rate_88xx;
  250. api->halmac_txfifo_is_empty = txfifo_is_empty_88xx;
  251. api->halmac_download_flash = download_flash_88xx;
  252. api->halmac_read_flash = read_flash_88xx;
  253. api->halmac_erase_flash = erase_flash_88xx;
  254. api->halmac_check_flash = check_flash_88xx;
  255. api->halmac_cfg_edca_para = cfg_edca_para_88xx;
  256. api->halmac_pinmux_wl_led_mode = pinmux_wl_led_mode_88xx;
  257. api->halmac_pinmux_wl_led_sw_ctrl = pinmux_wl_led_sw_ctrl_88xx;
  258. api->halmac_pinmux_sdio_int_polarity = pinmux_sdio_int_polarity_88xx;
  259. api->halmac_pinmux_gpio_mode = pinmux_gpio_mode_88xx;
  260. api->halmac_pinmux_gpio_output = pinmux_gpio_output_88xx;
  261. api->halmac_pinmux_pin_status = pinmux_pin_status_88xx;
  262. api->halmac_rx_cut_amsdu_cfg = rx_cut_amsdu_cfg_88xx;
  263. api->halmac_fw_snding = fw_snding_88xx;
  264. api->halmac_get_mac_addr = get_mac_addr_88xx;
  265. api->halmac_enter_cpu_sleep_mode = enter_cpu_sleep_mode_88xx;
  266. api->halmac_get_cpu_mode = get_cpu_mode_88xx;
  267. api->halmac_drv_fwctrl = drv_fwctrl_88xx;
  268. if (adapter->intf == HALMAC_INTERFACE_SDIO) {
  269. #if HALMAC_SDIO_SUPPORT
  270. api->halmac_init_sdio_cfg = init_sdio_cfg_88xx;
  271. api->halmac_deinit_sdio_cfg = deinit_sdio_cfg_88xx;
  272. api->halmac_cfg_rx_aggregation = cfg_sdio_rx_agg_88xx;
  273. api->halmac_init_interface_cfg = init_sdio_cfg_88xx;
  274. api->halmac_deinit_interface_cfg = deinit_sdio_cfg_88xx;
  275. api->halmac_cfg_tx_agg_align = cfg_txagg_sdio_align_88xx;
  276. api->halmac_set_bulkout_num = set_sdio_bulkout_num_88xx;
  277. api->halmac_get_usb_bulkout_id = get_sdio_bulkout_id_88xx;
  278. api->halmac_reg_read_indirect_32 = sdio_indirect_reg_r32_88xx;
  279. api->halmac_reg_sdio_cmd53_read_n = sdio_reg_rn_88xx;
  280. api->halmac_sdio_cmd53_4byte = sdio_cmd53_4byte_88xx;
  281. api->halmac_sdio_hw_info = sdio_hw_info_88xx;
  282. #endif
  283. } else if (adapter->intf == HALMAC_INTERFACE_USB) {
  284. #if HALMAC_USB_SUPPORT
  285. api->halmac_init_usb_cfg = init_usb_cfg_88xx;
  286. api->halmac_deinit_usb_cfg = deinit_usb_cfg_88xx;
  287. api->halmac_cfg_rx_aggregation = cfg_usb_rx_agg_88xx;
  288. api->halmac_init_interface_cfg = init_usb_cfg_88xx;
  289. api->halmac_deinit_interface_cfg = deinit_usb_cfg_88xx;
  290. api->halmac_cfg_tx_agg_align = cfg_txagg_usb_align_88xx;
  291. api->halmac_tx_allowed_sdio = tx_allowed_usb_88xx;
  292. api->halmac_set_bulkout_num = set_usb_bulkout_num_88xx;
  293. api->halmac_get_sdio_tx_addr = get_usb_tx_addr_88xx;
  294. api->halmac_get_usb_bulkout_id = get_usb_bulkout_id_88xx;
  295. api->halmac_reg_read_8 = reg_r8_usb_88xx;
  296. api->halmac_reg_write_8 = reg_w8_usb_88xx;
  297. api->halmac_reg_read_16 = reg_r16_usb_88xx;
  298. api->halmac_reg_write_16 = reg_w16_usb_88xx;
  299. api->halmac_reg_read_32 = reg_r32_usb_88xx;
  300. api->halmac_reg_write_32 = reg_w32_usb_88xx;
  301. api->halmac_reg_read_indirect_32 = usb_indirect_reg_r32_88xx;
  302. api->halmac_reg_sdio_cmd53_read_n = usb_reg_rn_88xx;
  303. #endif
  304. } else if (adapter->intf == HALMAC_INTERFACE_PCIE) {
  305. #if HALMAC_PCIE_SUPPORT
  306. api->halmac_init_pcie_cfg = init_pcie_cfg_88xx;
  307. api->halmac_deinit_pcie_cfg = deinit_pcie_cfg_88xx;
  308. api->halmac_cfg_rx_aggregation = cfg_pcie_rx_agg_88xx;
  309. api->halmac_init_interface_cfg = init_pcie_cfg_88xx;
  310. api->halmac_deinit_interface_cfg = deinit_pcie_cfg_88xx;
  311. api->halmac_cfg_tx_agg_align = cfg_txagg_pcie_align_88xx;
  312. api->halmac_tx_allowed_sdio = tx_allowed_pcie_88xx;
  313. api->halmac_set_bulkout_num = set_pcie_bulkout_num_88xx;
  314. api->halmac_get_sdio_tx_addr = get_pcie_tx_addr_88xx;
  315. api->halmac_get_usb_bulkout_id = get_pcie_bulkout_id_88xx;
  316. api->halmac_reg_read_8 = reg_r8_pcie_88xx;
  317. api->halmac_reg_write_8 = reg_w8_pcie_88xx;
  318. api->halmac_reg_read_16 = reg_r16_pcie_88xx;
  319. api->halmac_reg_write_16 = reg_w16_pcie_88xx;
  320. api->halmac_reg_read_32 = reg_r32_pcie_88xx;
  321. api->halmac_reg_write_32 = reg_w32_pcie_88xx;
  322. api->halmac_reg_read_indirect_32 = pcie_indirect_reg_r32_88xx;
  323. api->halmac_reg_sdio_cmd53_read_n = pcie_reg_rn_88xx;
  324. api->halmac_en_ref_autok_pcie = en_ref_autok_88xx;
  325. #endif
  326. } else {
  327. PLTFM_MSG_ERR("[ERR]Set halmac io function Error!!\n");
  328. }
  329. if (adapter->chip_id == HALMAC_CHIP_ID_8822B) {
  330. #if HALMAC_8822B_SUPPORT
  331. mount_api_8822b(adapter);
  332. #endif
  333. } else if (adapter->chip_id == HALMAC_CHIP_ID_8821C) {
  334. #if HALMAC_8821C_SUPPORT
  335. mount_api_8821c(adapter);
  336. #endif
  337. } else if (adapter->chip_id == HALMAC_CHIP_ID_8822C) {
  338. #if HALMAC_8822C_SUPPORT
  339. mount_api_8822c(adapter);
  340. #endif
  341. } else if (adapter->chip_id == HALMAC_CHIP_ID_8812F) {
  342. #if HALMAC_8812F_SUPPORT
  343. mount_api_8812f(adapter);
  344. #endif
  345. } else {
  346. PLTFM_MSG_ERR("[ERR]Chip ID undefine!!\n");
  347. return HALMAC_RET_CHIP_NOT_SUPPORT;
  348. }
  349. #if HALMAC_PLATFORM_TESTPROGRAM
  350. halmac_mount_misc_api_88xx(adapter);
  351. #endif
  352. return HALMAC_RET_SUCCESS;
  353. }
  354. static void
  355. init_state_machine_88xx(struct halmac_adapter *adapter)
  356. {
  357. struct halmac_state *state = &adapter->halmac_state;
  358. init_ofld_feature_state_machine_88xx(adapter);
  359. state->api_state = HALMAC_API_STATE_INIT;
  360. state->dlfw_state = HALMAC_DLFW_NONE;
  361. state->mac_pwr = HALMAC_MAC_POWER_OFF;
  362. state->gpio_cfg_state = HALMAC_GPIO_CFG_STATE_IDLE;
  363. state->rsvd_pg_state = HALMAC_RSVD_PG_STATE_IDLE;
  364. }
  365. void
  366. init_ofld_feature_state_machine_88xx(struct halmac_adapter *adapter)
  367. {
  368. struct halmac_state *state = &adapter->halmac_state;
  369. state->efuse_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  370. state->efuse_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  371. state->efuse_state.seq_num = adapter->h2c_info.seq_num;
  372. state->cfg_param_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  373. state->cfg_param_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  374. state->cfg_param_state.seq_num = adapter->h2c_info.seq_num;
  375. state->scan_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  376. state->scan_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  377. state->scan_state.seq_num = adapter->h2c_info.seq_num;
  378. state->update_pkt_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  379. state->update_pkt_state.seq_num = adapter->h2c_info.seq_num;
  380. state->iqk_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  381. state->iqk_state.seq_num = adapter->h2c_info.seq_num;
  382. state->pwr_trk_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  383. state->pwr_trk_state.seq_num = adapter->h2c_info.seq_num;
  384. state->psd_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  385. state->psd_state.seq_num = adapter->h2c_info.seq_num;
  386. state->psd_state.data_size = 0;
  387. state->psd_state.seg_size = 0;
  388. state->psd_state.data = NULL;
  389. state->fw_snding_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  390. state->fw_snding_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  391. state->fw_snding_state.seq_num = adapter->h2c_info.seq_num;
  392. state->wlcpu_mode = HALMAC_WLCPU_ACTIVE;
  393. }
  394. /**
  395. * register_api_88xx() - register feature list
  396. * @adapter
  397. * @registry : feature list, 1->enable 0->disable
  398. * Author : Ivan Lin
  399. *
  400. * Default is enable all api registry
  401. *
  402. * Return : enum halmac_ret_status
  403. * More details of status code can be found in prototype document
  404. */
  405. enum halmac_ret_status
  406. register_api_88xx(struct halmac_adapter *adapter,
  407. struct halmac_api_registry *registry)
  408. {
  409. if (!registry)
  410. return HALMAC_RET_NULL_POINTER;
  411. PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
  412. PLTFM_MEMCPY(&adapter->api_registry, registry, sizeof(*registry));
  413. PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
  414. return HALMAC_RET_SUCCESS;
  415. }
  416. /**
  417. * pre_init_system_cfg_88xx() - pre-init system config
  418. * @adapter : the adapter of halmac
  419. * Author : KaiYuan Chang/Ivan Lin
  420. * Return : enum halmac_ret_status
  421. * More details of status code can be found in prototype document
  422. */
  423. enum halmac_ret_status
  424. pre_init_system_cfg_88xx(struct halmac_adapter *adapter)
  425. {
  426. u32 value32;
  427. struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
  428. u8 enable_bb;
  429. PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
  430. HALMAC_REG_W8(REG_RSV_CTRL, 0);
  431. if (adapter->intf == HALMAC_INTERFACE_SDIO) {
  432. #if HALMAC_SDIO_SUPPORT
  433. if (leave_sdio_suspend_88xx(adapter) != HALMAC_RET_SUCCESS)
  434. return HALMAC_RET_SDIO_LEAVE_SUSPEND_FAIL;
  435. #endif
  436. } else if (adapter->intf == HALMAC_INTERFACE_USB) {
  437. #if HALMAC_USB_SUPPORT
  438. if (HALMAC_REG_R8(REG_SYS_CFG2 + 3) == 0x20)
  439. HALMAC_REG_W8(0xFE5B, HALMAC_REG_R8(0xFE5B) | BIT(4));
  440. #endif
  441. } else if (adapter->intf == HALMAC_INTERFACE_PCIE) {
  442. #if HALMAC_PCIE_SUPPORT
  443. /* For PCIE power on fail issue */
  444. HALMAC_REG_W8(REG_HCI_OPT_CTRL + 1,
  445. HALMAC_REG_R8(REG_HCI_OPT_CTRL + 1) | BIT(0));
  446. #endif
  447. }
  448. /* Config PIN Mux */
  449. value32 = HALMAC_REG_R32(REG_PAD_CTRL1);
  450. value32 = value32 & (~(BIT(28) | BIT(29)));
  451. value32 = value32 | BIT(28) | BIT(29);
  452. HALMAC_REG_W32(REG_PAD_CTRL1, value32);
  453. value32 = HALMAC_REG_R32(REG_LED_CFG);
  454. value32 = value32 & (~(BIT(25) | BIT(26)));
  455. HALMAC_REG_W32(REG_LED_CFG, value32);
  456. value32 = HALMAC_REG_R32(REG_GPIO_MUXCFG);
  457. value32 = value32 & (~(BIT(2)));
  458. value32 = value32 | BIT(2);
  459. HALMAC_REG_W32(REG_GPIO_MUXCFG, value32);
  460. enable_bb = 0;
  461. set_hw_value_88xx(adapter, HALMAC_HW_EN_BB_RF, &enable_bb);
  462. if (HALMAC_REG_R8(REG_SYS_CFG1 + 2) & BIT(4)) {
  463. PLTFM_MSG_ERR("[ERR]test mode!!\n");
  464. return HALMAC_RET_WLAN_MODE_FAIL;
  465. }
  466. PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
  467. return HALMAC_RET_SUCCESS;
  468. }
  469. /**
  470. * init_system_cfg_88xx() - init system config
  471. * @adapter : the adapter of halmac
  472. * Author : KaiYuan Chang/Ivan Lin
  473. * Return : enum halmac_ret_status
  474. * More details of status code can be found in prototype document
  475. */
  476. enum halmac_ret_status
  477. init_system_cfg_88xx(struct halmac_adapter *adapter)
  478. {
  479. struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
  480. u32 tmp = 0;
  481. u32 value32;
  482. enum halmac_ret_status status;
  483. u8 hwval;
  484. PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
  485. if (adapter->intf == HALMAC_INTERFACE_PCIE) {
  486. hwval = 1;
  487. status = api->halmac_set_hw_value(adapter,
  488. HALMAC_HW_PCIE_REF_AUTOK,
  489. &hwval);
  490. if (status != HALMAC_RET_SUCCESS)
  491. return status;
  492. }
  493. value32 = HALMAC_REG_R32(REG_CPU_DMEM_CON) | BIT_WL_PLATFORM_RST;
  494. #if HALMAC_8822C_SUPPORT
  495. if (adapter->chip_id != HALMAC_CHIP_ID_8822B &&
  496. adapter->chip_id != HALMAC_CHIP_ID_8821C)
  497. value32 |= BIT_DDMA_EN;
  498. #endif
  499. HALMAC_REG_W32(REG_CPU_DMEM_CON, value32);
  500. HALMAC_REG_W8(REG_SYS_FUNC_EN + 1, SYS_FUNC_EN);
  501. #if HALMAC_8822B_SUPPORT
  502. /* cpu_en is related to wlan tx in 8822B hw design */
  503. /* 8822B should enable cpu_en in init flow */
  504. if (adapter->chip_id == HALMAC_CHIP_ID_8822B)
  505. HALMAC_REG_W8_SET(REG_SYS_FUNC_EN + 1, BIT(2));
  506. #endif
  507. /*disable boot-from-flash for driver's DL FW*/
  508. tmp = HALMAC_REG_R32(REG_MCUFW_CTRL);
  509. if (tmp & BIT_BOOT_FSPI_EN) {
  510. HALMAC_REG_W32(REG_MCUFW_CTRL, tmp & (~BIT_BOOT_FSPI_EN));
  511. value32 = HALMAC_REG_R32(REG_GPIO_MUXCFG) & (~BIT_FSPI_EN);
  512. HALMAC_REG_W32(REG_GPIO_MUXCFG, value32);
  513. }
  514. PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
  515. return HALMAC_RET_SUCCESS;
  516. }
  517. /**
  518. * init_mac_cfg_88xx() - config page1~page7 register
  519. * @adapter : the adapter of halmac
  520. * @mode : trx mode
  521. * Author : KaiYuan Chang/Ivan Lin
  522. * Return : enum halmac_ret_status
  523. * More details of status code can be found in prototype document
  524. */
  525. enum halmac_ret_status
  526. init_mac_cfg_88xx(struct halmac_adapter *adapter, enum halmac_trx_mode mode)
  527. {
  528. struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
  529. enum halmac_ret_status status = HALMAC_RET_SUCCESS;
  530. PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
  531. status = api->halmac_init_trx_cfg(adapter, mode);
  532. if (status != HALMAC_RET_SUCCESS) {
  533. PLTFM_MSG_ERR("[ERR]init trx %x\n", status);
  534. return status;
  535. }
  536. status = api->halmac_init_protocol_cfg(adapter);
  537. if (status != HALMAC_RET_SUCCESS) {
  538. PLTFM_MSG_ERR("[ERR]init ptcl %x\n", status);
  539. return status;
  540. }
  541. status = api->halmac_init_edca_cfg(adapter);
  542. if (status != HALMAC_RET_SUCCESS) {
  543. PLTFM_MSG_ERR("[ERR]init edca %x\n", status);
  544. return status;
  545. }
  546. status = api->halmac_init_wmac_cfg(adapter);
  547. if (status != HALMAC_RET_SUCCESS) {
  548. PLTFM_MSG_ERR("[ERR]init wmac %x\n", status);
  549. return status;
  550. }
  551. PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
  552. return status;
  553. }
  554. /**
  555. * reset_ofld_feature_88xx() -reset async api cmd status
  556. * @adapter : the adapter of halmac
  557. * @feature_id : feature_id
  558. * Author : Ivan Lin/KaiYuan Chang
  559. * Return : enum halmac_ret_status.
  560. * More details of status code can be found in prototype document
  561. */
  562. enum halmac_ret_status
  563. reset_ofld_feature_88xx(struct halmac_adapter *adapter,
  564. enum halmac_feature_id feature_id)
  565. {
  566. struct halmac_state *state = &adapter->halmac_state;
  567. PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
  568. switch (feature_id) {
  569. case HALMAC_FEATURE_CFG_PARA:
  570. state->cfg_param_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  571. state->cfg_param_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  572. break;
  573. case HALMAC_FEATURE_DUMP_PHYSICAL_EFUSE:
  574. case HALMAC_FEATURE_DUMP_LOGICAL_EFUSE:
  575. state->efuse_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  576. state->efuse_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  577. break;
  578. case HALMAC_FEATURE_CHANNEL_SWITCH:
  579. state->scan_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  580. state->scan_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  581. break;
  582. case HALMAC_FEATURE_UPDATE_PACKET:
  583. state->update_pkt_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  584. break;
  585. case HALMAC_FEATURE_IQK:
  586. state->iqk_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  587. break;
  588. case HALMAC_FEATURE_POWER_TRACKING:
  589. state->pwr_trk_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  590. break;
  591. case HALMAC_FEATURE_PSD:
  592. state->psd_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  593. break;
  594. case HALMAC_FEATURE_FW_SNDING:
  595. state->fw_snding_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  596. state->fw_snding_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  597. break;
  598. case HALMAC_FEATURE_ALL:
  599. state->cfg_param_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  600. state->cfg_param_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  601. state->efuse_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  602. state->efuse_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  603. state->scan_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  604. state->scan_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  605. state->update_pkt_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  606. state->iqk_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  607. state->pwr_trk_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  608. state->psd_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  609. state->fw_snding_state.proc_status = HALMAC_CMD_PROCESS_IDLE;
  610. state->fw_snding_state.cmd_cnstr_state = HALMAC_CMD_CNSTR_IDLE;
  611. break;
  612. default:
  613. PLTFM_MSG_ERR("[ERR]invalid feature id\n");
  614. return HALMAC_RET_INVALID_FEATURE_ID;
  615. }
  616. PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
  617. return HALMAC_RET_SUCCESS;
  618. }
  619. /**
  620. * (debug API)verify_platform_api_88xx() - verify platform api
  621. * @adapter : the adapter of halmac
  622. * Author : KaiYuan Chang/Ivan Lin
  623. * Return : enum halmac_ret_status
  624. * More details of status code can be found in prototype document
  625. */
  626. enum halmac_ret_status
  627. verify_platform_api_88xx(struct halmac_adapter *adapter)
  628. {
  629. enum halmac_ret_status ret_status = HALMAC_RET_SUCCESS;
  630. PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
  631. ret_status = verify_io_88xx(adapter);
  632. if (ret_status != HALMAC_RET_SUCCESS)
  633. return ret_status;
  634. if (adapter->txff_alloc.la_mode != HALMAC_LA_MODE_FULL)
  635. ret_status = verify_send_rsvd_page_88xx(adapter);
  636. if (ret_status != HALMAC_RET_SUCCESS)
  637. return ret_status;
  638. PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
  639. return ret_status;
  640. }
  641. void
  642. tx_desc_chksum_88xx(struct halmac_adapter *adapter, u8 enable)
  643. {
  644. u16 value16;
  645. struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
  646. PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
  647. adapter->tx_desc_checksum = enable;
  648. value16 = HALMAC_REG_R16(REG_TXDMA_OFFSET_CHK);
  649. if (enable == 1)
  650. HALMAC_REG_W16(REG_TXDMA_OFFSET_CHK, value16 | BIT(13));
  651. else
  652. HALMAC_REG_W16(REG_TXDMA_OFFSET_CHK, value16 & ~BIT(13));
  653. }
  654. static enum halmac_ret_status
  655. verify_io_88xx(struct halmac_adapter *adapter)
  656. {
  657. u8 value8;
  658. u8 wvalue8;
  659. u32 value32;
  660. u32 value32_2;
  661. u32 wvalue32;
  662. u32 offset;
  663. enum halmac_ret_status ret_status = HALMAC_RET_SUCCESS;
  664. if (adapter->intf == HALMAC_INTERFACE_SDIO) {
  665. offset = REG_PAGE5_DUMMY;
  666. if (0 == (offset & 0xFFFF0000))
  667. offset |= WLAN_IOREG_OFFSET;
  668. #if HALMAC_SDIO_SUPPORT
  669. ret_status = cnv_to_sdio_bus_offset_88xx(adapter, &offset);
  670. #else
  671. return HALMAC_RET_WRONG_INTF;
  672. #endif
  673. /* Verify CMD52 R/W */
  674. wvalue8 = 0xab;
  675. PLTFM_SDIO_CMD52_W(offset, wvalue8);
  676. value8 = PLTFM_SDIO_CMD52_R(offset);
  677. if (value8 != wvalue8) {
  678. PLTFM_MSG_ERR("[ERR]cmd52 r/w\n");
  679. ret_status = HALMAC_RET_PLATFORM_API_INCORRECT;
  680. }
  681. /* Verify CMD53 R/W */
  682. PLTFM_SDIO_CMD52_W(offset, 0xaa);
  683. PLTFM_SDIO_CMD52_W(offset + 1, 0xbb);
  684. PLTFM_SDIO_CMD52_W(offset + 2, 0xcc);
  685. PLTFM_SDIO_CMD52_W(offset + 3, 0xdd);
  686. value32 = PLTFM_SDIO_CMD53_R32(offset);
  687. if (value32 != 0xddccbbaa) {
  688. PLTFM_MSG_ERR("[ERR]cmd53 r\n");
  689. ret_status = HALMAC_RET_PLATFORM_API_INCORRECT;
  690. }
  691. wvalue32 = 0x11223344;
  692. PLTFM_SDIO_CMD53_W32(offset, wvalue32);
  693. value32 = PLTFM_SDIO_CMD53_R32(offset);
  694. if (value32 != wvalue32) {
  695. PLTFM_MSG_ERR("[ERR]cmd53 w\n");
  696. ret_status = HALMAC_RET_PLATFORM_API_INCORRECT;
  697. }
  698. /* value32 should be 0x33441122 */
  699. value32 = PLTFM_SDIO_CMD53_R32(offset + 2);
  700. wvalue32 = 0x11225566;
  701. PLTFM_SDIO_CMD53_W32(offset, wvalue32);
  702. /* value32 should be 0x55661122 */
  703. value32_2 = PLTFM_SDIO_CMD53_R32(offset + 2);
  704. if (value32_2 == value32) {
  705. PLTFM_MSG_ERR("[ERR]cmd52 is used\n");
  706. ret_status = HALMAC_RET_PLATFORM_API_INCORRECT;
  707. }
  708. } else {
  709. wvalue32 = 0x77665511;
  710. PLTFM_REG_W32(REG_PAGE5_DUMMY, wvalue32);
  711. value32 = PLTFM_REG_R32(REG_PAGE5_DUMMY);
  712. if (value32 != wvalue32) {
  713. PLTFM_MSG_ERR("[ERR]reg rw\n");
  714. ret_status = HALMAC_RET_PLATFORM_API_INCORRECT;
  715. }
  716. }
  717. return ret_status;
  718. }
  719. static enum halmac_ret_status
  720. verify_send_rsvd_page_88xx(struct halmac_adapter *adapter)
  721. {
  722. u8 txdesc_size = adapter->hw_cfg_info.txdesc_size;
  723. u8 *rsvd_buf = NULL;
  724. u8 *rsvd_page = NULL;
  725. u32 i;
  726. u32 pkt_size = 64;
  727. u32 payload = 0xab;
  728. enum halmac_ret_status ret_status = HALMAC_RET_SUCCESS;
  729. rsvd_buf = (u8 *)PLTFM_MALLOC(pkt_size);
  730. if (!rsvd_buf) {
  731. PLTFM_MSG_ERR("[ERR]rsvd buf malloc!!\n");
  732. return HALMAC_RET_MALLOC_FAIL;
  733. }
  734. PLTFM_MEMSET(rsvd_buf, (u8)payload, pkt_size);
  735. ret_status = dl_rsvd_page_88xx(adapter,
  736. adapter->txff_alloc.rsvd_boundary,
  737. rsvd_buf, pkt_size);
  738. if (ret_status != HALMAC_RET_SUCCESS) {
  739. PLTFM_FREE(rsvd_buf, pkt_size);
  740. return ret_status;
  741. }
  742. rsvd_page = (u8 *)PLTFM_MALLOC(pkt_size + txdesc_size);
  743. if (!rsvd_page) {
  744. PLTFM_MSG_ERR("[ERR]rsvd page malloc!!\n");
  745. PLTFM_FREE(rsvd_buf, pkt_size);
  746. return HALMAC_RET_MALLOC_FAIL;
  747. }
  748. PLTFM_MEMSET(rsvd_page, 0x00, pkt_size + txdesc_size);
  749. ret_status = dump_fifo_88xx(adapter, HAL_FIFO_SEL_RSVD_PAGE, 0,
  750. pkt_size + txdesc_size, rsvd_page);
  751. if (ret_status != HALMAC_RET_SUCCESS) {
  752. PLTFM_FREE(rsvd_buf, pkt_size);
  753. PLTFM_FREE(rsvd_page, pkt_size + txdesc_size);
  754. return ret_status;
  755. }
  756. for (i = 0; i < pkt_size; i++) {
  757. if (*(rsvd_buf + i) != *(rsvd_page + (i + txdesc_size))) {
  758. PLTFM_MSG_ERR("[ERR]Compare RSVD page Fail\n");
  759. ret_status = HALMAC_RET_PLATFORM_API_INCORRECT;
  760. }
  761. }
  762. PLTFM_FREE(rsvd_buf, pkt_size);
  763. PLTFM_FREE(rsvd_page, pkt_size + txdesc_size);
  764. return ret_status;
  765. }
  766. enum halmac_ret_status
  767. pg_num_parser_88xx(struct halmac_adapter *adapter, enum halmac_trx_mode mode,
  768. struct halmac_pg_num *tbl)
  769. {
  770. u8 flag;
  771. u16 hpq_num = 0;
  772. u16 lpq_num = 0;
  773. u16 npq_num = 0;
  774. u16 gapq_num = 0;
  775. u16 expq_num = 0;
  776. u16 pubq_num = 0;
  777. u32 i = 0;
  778. flag = 0;
  779. for (i = 0; i < HALMAC_TRX_MODE_MAX; i++) {
  780. if (mode == tbl[i].mode) {
  781. hpq_num = tbl[i].hq_num;
  782. lpq_num = tbl[i].lq_num;
  783. npq_num = tbl[i].nq_num;
  784. expq_num = tbl[i].exq_num;
  785. gapq_num = tbl[i].gap_num;
  786. pubq_num = adapter->txff_alloc.acq_pg_num - hpq_num -
  787. lpq_num - npq_num - expq_num - gapq_num;
  788. flag = 1;
  789. PLTFM_MSG_TRACE("[TRACE]%s done\n", __func__);
  790. break;
  791. }
  792. }
  793. if (flag == 0) {
  794. PLTFM_MSG_ERR("[ERR]trx mode!!\n");
  795. return HALMAC_RET_TRX_MODE_NOT_SUPPORT;
  796. }
  797. if (adapter->txff_alloc.acq_pg_num <
  798. hpq_num + lpq_num + npq_num + expq_num + gapq_num) {
  799. PLTFM_MSG_ERR("[ERR]acqnum = %d\n",
  800. adapter->txff_alloc.acq_pg_num);
  801. PLTFM_MSG_ERR("[ERR]hpq_num = %d\n", hpq_num);
  802. PLTFM_MSG_ERR("[ERR]LPQ_num = %d\n", lpq_num);
  803. PLTFM_MSG_ERR("[ERR]npq_num = %d\n", npq_num);
  804. PLTFM_MSG_ERR("[ERR]EPQ_num = %d\n", expq_num);
  805. PLTFM_MSG_ERR("[ERR]gapq_num = %d\n", gapq_num);
  806. return HALMAC_RET_CFG_TXFIFO_PAGE_FAIL;
  807. }
  808. adapter->txff_alloc.high_queue_pg_num = hpq_num;
  809. adapter->txff_alloc.low_queue_pg_num = lpq_num;
  810. adapter->txff_alloc.normal_queue_pg_num = npq_num;
  811. adapter->txff_alloc.extra_queue_pg_num = expq_num;
  812. adapter->txff_alloc.pub_queue_pg_num = pubq_num;
  813. return HALMAC_RET_SUCCESS;
  814. }
  815. enum halmac_ret_status
  816. rqpn_parser_88xx(struct halmac_adapter *adapter, enum halmac_trx_mode mode,
  817. struct halmac_rqpn *tbl)
  818. {
  819. u8 flag;
  820. u32 i;
  821. flag = 0;
  822. for (i = 0; i < HALMAC_TRX_MODE_MAX; i++) {
  823. if (mode == tbl[i].mode) {
  824. adapter->pq_map[HALMAC_PQ_MAP_VO] = tbl[i].dma_map_vo;
  825. adapter->pq_map[HALMAC_PQ_MAP_VI] = tbl[i].dma_map_vi;
  826. adapter->pq_map[HALMAC_PQ_MAP_BE] = tbl[i].dma_map_be;
  827. adapter->pq_map[HALMAC_PQ_MAP_BK] = tbl[i].dma_map_bk;
  828. adapter->pq_map[HALMAC_PQ_MAP_MG] = tbl[i].dma_map_mg;
  829. adapter->pq_map[HALMAC_PQ_MAP_HI] = tbl[i].dma_map_hi;
  830. flag = 1;
  831. PLTFM_MSG_TRACE("[TRACE]%s done\n", __func__);
  832. break;
  833. }
  834. }
  835. if (flag == 0) {
  836. PLTFM_MSG_ERR("[ERR]trx mdoe!!\n");
  837. return HALMAC_RET_TRX_MODE_NOT_SUPPORT;
  838. }
  839. return HALMAC_RET_SUCCESS;
  840. }
  841. #endif /* HALMAC_88XX_SUPPORT */