hal_generic_api.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. /*
  2. * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #ifndef _HAL_GENERIC_API_H_
  20. #define _HAL_GENERIC_API_H_
  21. #include <hal_rx.h>
  22. #define SRNG_ENABLE_BIT 0x40
  23. #define SRNG_IDLE_STATE_BIT 0x80
  24. /**
  25. * hal_get_radiotap_he_gi_ltf() - Convert HE ltf and GI value
  26. * from stats enum to radiotap enum
  27. * @he_gi: HE GI value used in stats
  28. * @he_ltf: HE LTF value used in stats
  29. *
  30. * Return: void
  31. */
  32. static inline void hal_get_radiotap_he_gi_ltf(uint16_t *he_gi, uint16_t *he_ltf)
  33. {
  34. switch (*he_gi) {
  35. case HE_GI_0_8:
  36. *he_gi = HE_GI_RADIOTAP_0_8;
  37. break;
  38. case HE_GI_1_6:
  39. *he_gi = HE_GI_RADIOTAP_1_6;
  40. break;
  41. case HE_GI_3_2:
  42. *he_gi = HE_GI_RADIOTAP_3_2;
  43. break;
  44. default:
  45. *he_gi = HE_GI_RADIOTAP_RESERVED;
  46. }
  47. switch (*he_ltf) {
  48. case HE_LTF_1_X:
  49. *he_ltf = HE_LTF_RADIOTAP_1_X;
  50. break;
  51. case HE_LTF_2_X:
  52. *he_ltf = HE_LTF_RADIOTAP_2_X;
  53. break;
  54. case HE_LTF_4_X:
  55. *he_ltf = HE_LTF_RADIOTAP_4_X;
  56. break;
  57. default:
  58. *he_ltf = HE_LTF_RADIOTAP_UNKNOWN;
  59. }
  60. }
  61. /* channel number to freq conversion */
  62. #define CHANNEL_NUM_14 14
  63. #define CHANNEL_NUM_15 15
  64. #define CHANNEL_NUM_27 27
  65. #define CHANNEL_NUM_35 35
  66. #define CHANNEL_NUM_182 182
  67. #define CHANNEL_NUM_197 197
  68. #define CHANNEL_FREQ_2484 2484
  69. #define CHANNEL_FREQ_2407 2407
  70. #define CHANNEL_FREQ_2512 2512
  71. #define CHANNEL_FREQ_5000 5000
  72. #define CHANNEL_FREQ_5950 5950
  73. #define CHANNEL_FREQ_4000 4000
  74. #define CHANNEL_FREQ_5150 5150
  75. #define CHANNEL_FREQ_5920 5920
  76. #define CHANNEL_FREQ_5935 5935
  77. #define FREQ_MULTIPLIER_CONST_5MHZ 5
  78. #define FREQ_MULTIPLIER_CONST_20MHZ 20
  79. /**
  80. * hal_rx_radiotap_num_to_freq() - Get frequency from chan number
  81. * @chan_num - Input channel number
  82. * @center_freq - Input Channel Center frequency
  83. *
  84. * Return - Channel frequency in Mhz
  85. */
  86. static inline uint16_t
  87. hal_rx_radiotap_num_to_freq(uint16_t chan_num, qdf_freq_t center_freq)
  88. {
  89. if (center_freq > CHANNEL_FREQ_5920 && center_freq < CHANNEL_FREQ_5950)
  90. return CHANNEL_FREQ_5935;
  91. if (center_freq < CHANNEL_FREQ_5950) {
  92. if (chan_num == CHANNEL_NUM_14)
  93. return CHANNEL_FREQ_2484;
  94. if (chan_num < CHANNEL_NUM_14)
  95. return CHANNEL_FREQ_2407 +
  96. (chan_num * FREQ_MULTIPLIER_CONST_5MHZ);
  97. if (chan_num < CHANNEL_NUM_27)
  98. return CHANNEL_FREQ_2512 +
  99. ((chan_num - CHANNEL_NUM_15) *
  100. FREQ_MULTIPLIER_CONST_20MHZ);
  101. if (chan_num > CHANNEL_NUM_182 &&
  102. chan_num < CHANNEL_NUM_197)
  103. return ((chan_num * FREQ_MULTIPLIER_CONST_5MHZ) +
  104. CHANNEL_FREQ_4000);
  105. return CHANNEL_FREQ_5000 +
  106. (chan_num * FREQ_MULTIPLIER_CONST_5MHZ);
  107. } else {
  108. return CHANNEL_FREQ_5950 +
  109. (chan_num * FREQ_MULTIPLIER_CONST_5MHZ);
  110. }
  111. }
  112. /**
  113. * hal_get_hw_hptp_generic() - Get HW head and tail pointer value for any ring
  114. * @hal_soc: Opaque HAL SOC handle
  115. * @hal_ring: Source ring pointer
  116. * @headp: Head Pointer
  117. * @tailp: Tail Pointer
  118. * @ring: Ring type
  119. *
  120. * Return: Update tail pointer and head pointer in arguments.
  121. */
  122. static inline
  123. void hal_get_hw_hptp_generic(struct hal_soc *hal_soc,
  124. hal_ring_handle_t hal_ring_hdl,
  125. uint32_t *headp, uint32_t *tailp,
  126. uint8_t ring)
  127. {
  128. struct hal_srng *srng = (struct hal_srng *)hal_ring_hdl;
  129. struct hal_hw_srng_config *ring_config;
  130. enum hal_ring_type ring_type = (enum hal_ring_type)ring;
  131. if (!hal_soc || !srng) {
  132. QDF_TRACE(QDF_MODULE_ID_HAL, QDF_TRACE_LEVEL_ERROR,
  133. "%s: Context is Null", __func__);
  134. return;
  135. }
  136. ring_config = HAL_SRNG_CONFIG(hal_soc, ring_type);
  137. if (!ring_config->lmac_ring) {
  138. if (srng->ring_dir == HAL_SRNG_SRC_RING) {
  139. *headp = SRNG_SRC_REG_READ(srng, HP);
  140. *tailp = SRNG_SRC_REG_READ(srng, TP);
  141. } else {
  142. *headp = SRNG_DST_REG_READ(srng, HP);
  143. *tailp = SRNG_DST_REG_READ(srng, TP);
  144. }
  145. }
  146. }
  147. #if defined(WBM_IDLE_LSB_WRITE_CONFIRM_WAR)
  148. /**
  149. * hal_wbm_idle_lsb_write_confirm() - Check and update WBM_IDLE_LINK ring LSB
  150. * @srng: srng handle
  151. *
  152. * Return: None
  153. */
  154. static void hal_wbm_idle_lsb_write_confirm(struct hal_srng *srng)
  155. {
  156. if (srng->ring_id == HAL_SRNG_WBM_IDLE_LINK) {
  157. while (SRNG_SRC_REG_READ(srng, BASE_LSB) !=
  158. ((unsigned int)srng->ring_base_paddr & 0xffffffff))
  159. SRNG_SRC_REG_WRITE(srng, BASE_LSB,
  160. srng->ring_base_paddr &
  161. 0xffffffff);
  162. }
  163. }
  164. #else
  165. static void hal_wbm_idle_lsb_write_confirm(struct hal_srng *srng)
  166. {
  167. }
  168. #endif
  169. #ifdef DP_UMAC_HW_RESET_SUPPORT
  170. /**
  171. * hal_srng_src_hw_write_cons_prefetch_timer() - Write cons prefetch timer reg
  172. * @srng: srng handle
  173. * @value: value to set
  174. *
  175. * Return: None
  176. */
  177. static inline
  178. void hal_srng_src_hw_write_cons_prefetch_timer(struct hal_srng *srng,
  179. uint32_t value)
  180. {
  181. SRNG_SRC_REG_WRITE(srng, CONSUMER_PREFETCH_TIMER, value);
  182. }
  183. /**
  184. * hal_srng_hw_disable_generic - Private function to disable SRNG
  185. * source ring HW
  186. * @hal_soc: HAL SOC handle
  187. * @srng: SRNG ring pointer
  188. */
  189. static inline
  190. void hal_srng_hw_disable_generic(struct hal_soc *hal, struct hal_srng *srng)
  191. {
  192. uint32_t reg_val = 0;
  193. if (srng->ring_dir == HAL_SRNG_DST_RING) {
  194. reg_val = SRNG_DST_REG_READ(srng, MISC) & ~(SRNG_ENABLE_BIT);
  195. SRNG_DST_REG_WRITE(srng, MISC, reg_val);
  196. } else {
  197. reg_val = SRNG_SRC_REG_READ(srng, MISC) & ~(SRNG_ENABLE_BIT);
  198. SRNG_SRC_REG_WRITE(srng, MISC, reg_val);
  199. srng->prefetch_timer =
  200. SRNG_SRC_REG_READ(srng, CONSUMER_PREFETCH_TIMER);
  201. hal_srng_src_hw_write_cons_prefetch_timer(srng, 0);
  202. }
  203. }
  204. #else
  205. static inline
  206. void hal_srng_hw_disable_generic(struct hal_soc *hal, struct hal_srng *srng)
  207. {
  208. }
  209. static inline
  210. void hal_srng_src_hw_write_cons_prefetch_timer(struct hal_srng *srng,
  211. uint32_t value)
  212. {
  213. }
  214. #endif
  215. /**
  216. * hal_srng_src_hw_init - Private function to initialize SRNG
  217. * source ring HW
  218. * @hal_soc: HAL SOC handle
  219. * @srng: SRNG ring pointer
  220. * @idle_check: Check if ring is idle
  221. */
  222. static inline
  223. void hal_srng_src_hw_init_generic(struct hal_soc *hal,
  224. struct hal_srng *srng, bool idle_check)
  225. {
  226. uint32_t reg_val = 0;
  227. uint64_t tp_addr = 0;
  228. if (idle_check) {
  229. reg_val = SRNG_SRC_REG_READ(srng, MISC);
  230. if (!(reg_val & SRNG_IDLE_STATE_BIT)) {
  231. hal_err("ring_id %d not in idle state", srng->ring_id);
  232. qdf_assert_always(0);
  233. }
  234. hal_srng_src_hw_write_cons_prefetch_timer(srng,
  235. srng->prefetch_timer);
  236. }
  237. hal_debug("hw_init srng %d", srng->ring_id);
  238. if (srng->flags & HAL_SRNG_MSI_INTR) {
  239. SRNG_SRC_REG_WRITE(srng, MSI1_BASE_LSB,
  240. srng->msi_addr & 0xffffffff);
  241. reg_val = SRNG_SM(SRNG_SRC_FLD(MSI1_BASE_MSB, ADDR),
  242. (uint64_t)(srng->msi_addr) >> 32) |
  243. SRNG_SM(SRNG_SRC_FLD(MSI1_BASE_MSB,
  244. MSI1_ENABLE), 1);
  245. SRNG_SRC_REG_WRITE(srng, MSI1_BASE_MSB, reg_val);
  246. SRNG_SRC_REG_WRITE(srng, MSI1_DATA,
  247. qdf_cpu_to_le32(srng->msi_data));
  248. }
  249. SRNG_SRC_REG_WRITE(srng, BASE_LSB, srng->ring_base_paddr & 0xffffffff);
  250. hal_wbm_idle_lsb_write_confirm(srng);
  251. reg_val = SRNG_SM(SRNG_SRC_FLD(BASE_MSB, RING_BASE_ADDR_MSB),
  252. ((uint64_t)(srng->ring_base_paddr) >> 32)) |
  253. SRNG_SM(SRNG_SRC_FLD(BASE_MSB, RING_SIZE),
  254. srng->entry_size * srng->num_entries);
  255. SRNG_SRC_REG_WRITE(srng, BASE_MSB, reg_val);
  256. reg_val = SRNG_SM(SRNG_SRC_FLD(ID, ENTRY_SIZE), srng->entry_size);
  257. SRNG_SRC_REG_WRITE(srng, ID, reg_val);
  258. /**
  259. * Interrupt setup:
  260. * Default interrupt mode is 'pulse'. Need to setup SW_INTERRUPT_MODE
  261. * if level mode is required
  262. */
  263. reg_val = 0;
  264. /*
  265. * WAR - Hawkeye v1 has a hardware bug which requires timer value to be
  266. * programmed in terms of 1us resolution instead of 8us resolution as
  267. * given in MLD.
  268. */
  269. if (srng->intr_timer_thres_us) {
  270. reg_val |= SRNG_SM(SRNG_SRC_FLD(CONSUMER_INT_SETUP_IX0,
  271. INTERRUPT_TIMER_THRESHOLD),
  272. srng->intr_timer_thres_us);
  273. /* For HK v2 this should be (srng->intr_timer_thres_us >> 3) */
  274. }
  275. if (srng->intr_batch_cntr_thres_entries) {
  276. reg_val |= SRNG_SM(SRNG_SRC_FLD(CONSUMER_INT_SETUP_IX0,
  277. BATCH_COUNTER_THRESHOLD),
  278. srng->intr_batch_cntr_thres_entries *
  279. srng->entry_size);
  280. }
  281. SRNG_SRC_REG_WRITE(srng, CONSUMER_INT_SETUP_IX0, reg_val);
  282. reg_val = 0;
  283. if (srng->flags & HAL_SRNG_LOW_THRES_INTR_ENABLE) {
  284. reg_val |= SRNG_SM(SRNG_SRC_FLD(CONSUMER_INT_SETUP_IX1,
  285. LOW_THRESHOLD), srng->u.src_ring.low_threshold);
  286. }
  287. SRNG_SRC_REG_WRITE(srng, CONSUMER_INT_SETUP_IX1, reg_val);
  288. /* As per HW team, TP_ADDR and HP_ADDR for Idle link ring should
  289. * remain 0 to avoid some WBM stability issues. Remote head/tail
  290. * pointers are not required since this ring is completely managed
  291. * by WBM HW
  292. */
  293. reg_val = 0;
  294. if (srng->ring_id != HAL_SRNG_WBM_IDLE_LINK) {
  295. tp_addr = (uint64_t)(hal->shadow_rdptr_mem_paddr +
  296. ((unsigned long)(srng->u.src_ring.tp_addr) -
  297. (unsigned long)(hal->shadow_rdptr_mem_vaddr)));
  298. SRNG_SRC_REG_WRITE(srng, TP_ADDR_LSB, tp_addr & 0xffffffff);
  299. SRNG_SRC_REG_WRITE(srng, TP_ADDR_MSB, tp_addr >> 32);
  300. } else {
  301. reg_val |= SRNG_SM(SRNG_SRC_FLD(MISC, RING_ID_DISABLE), 1);
  302. }
  303. /* Initilaize head and tail pointers to indicate ring is empty */
  304. SRNG_SRC_REG_WRITE(srng, HP, 0);
  305. SRNG_SRC_REG_WRITE(srng, TP, 0);
  306. *(srng->u.src_ring.tp_addr) = 0;
  307. reg_val |= ((srng->flags & HAL_SRNG_DATA_TLV_SWAP) ?
  308. SRNG_SM(SRNG_SRC_FLD(MISC, DATA_TLV_SWAP_BIT), 1) : 0) |
  309. ((srng->flags & HAL_SRNG_RING_PTR_SWAP) ?
  310. SRNG_SM(SRNG_SRC_FLD(MISC, HOST_FW_SWAP_BIT), 1) : 0) |
  311. ((srng->flags & HAL_SRNG_MSI_SWAP) ?
  312. SRNG_SM(SRNG_SRC_FLD(MISC, MSI_SWAP_BIT), 1) : 0);
  313. /* Loop count is not used for SRC rings */
  314. reg_val |= SRNG_SM(SRNG_SRC_FLD(MISC, LOOPCNT_DISABLE), 1);
  315. /*
  316. * reg_val |= SRNG_SM(SRNG_SRC_FLD(MISC, SRNG_ENABLE), 1);
  317. * todo: update fw_api and replace with above line
  318. * (when SRNG_ENABLE field for the MISC register is available in fw_api)
  319. * (WCSS_UMAC_CE_0_SRC_WFSS_CE_CHANNEL_SRC_R0_SRC_RING_MISC)
  320. */
  321. reg_val |= SRNG_ENABLE_BIT;
  322. SRNG_SRC_REG_WRITE(srng, MISC, reg_val);
  323. }
  324. #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
  325. /**
  326. * hal_srng_dst_msi2_setup() - Configure MSI2 register for a SRNG
  327. * @srng: SRNG handle
  328. *
  329. * Return: None
  330. */
  331. static inline void hal_srng_dst_msi2_setup(struct hal_srng *srng)
  332. {
  333. uint32_t reg_val = 0;
  334. if (srng->u.dst_ring.nf_irq_support) {
  335. SRNG_DST_REG_WRITE(srng, MSI2_BASE_LSB,
  336. srng->msi2_addr & 0xffffffff);
  337. reg_val = SRNG_SM(SRNG_DST_FLD(MSI2_BASE_MSB, ADDR),
  338. (uint64_t)(srng->msi2_addr) >> 32) |
  339. SRNG_SM(SRNG_DST_FLD(MSI2_BASE_MSB,
  340. MSI2_ENABLE), 1);
  341. SRNG_DST_REG_WRITE(srng, MSI2_BASE_MSB, reg_val);
  342. SRNG_DST_REG_WRITE(srng, MSI2_DATA,
  343. qdf_cpu_to_le32(srng->msi2_data));
  344. }
  345. }
  346. /**
  347. * hal_srng_dst_near_full_int_setup() - Configure near-full params for SRNG
  348. * @srng: SRNG handle
  349. *
  350. * Return: None
  351. */
  352. static inline void hal_srng_dst_near_full_int_setup(struct hal_srng *srng)
  353. {
  354. uint32_t reg_val = 0;
  355. if (srng->u.dst_ring.nf_irq_support) {
  356. if (srng->intr_timer_thres_us) {
  357. reg_val |= SRNG_SM(SRNG_DST_FLD(PRODUCER_INT2_SETUP,
  358. INTERRUPT2_TIMER_THRESHOLD),
  359. srng->intr_timer_thres_us >> 3);
  360. }
  361. reg_val |= SRNG_SM(SRNG_DST_FLD(PRODUCER_INT2_SETUP,
  362. HIGH_THRESHOLD),
  363. srng->u.dst_ring.high_thresh *
  364. srng->entry_size);
  365. }
  366. SRNG_DST_REG_WRITE(srng, PRODUCER_INT2_SETUP, reg_val);
  367. }
  368. #else
  369. static inline void hal_srng_dst_msi2_setup(struct hal_srng *srng)
  370. {
  371. }
  372. static inline void hal_srng_dst_near_full_int_setup(struct hal_srng *srng)
  373. {
  374. }
  375. #endif
  376. /**
  377. * hal_srng_dst_hw_init - Private function to initialize SRNG
  378. * destination ring HW
  379. * @hal_soc: HAL SOC handle
  380. * @srng: SRNG ring pointer
  381. * @idle_check: Check if ring is idle
  382. */
  383. static inline
  384. void hal_srng_dst_hw_init_generic(struct hal_soc *hal,
  385. struct hal_srng *srng, bool idle_check)
  386. {
  387. uint32_t reg_val = 0;
  388. uint64_t hp_addr = 0;
  389. if (idle_check) {
  390. reg_val = SRNG_DST_REG_READ(srng, MISC);
  391. if (!(reg_val & SRNG_IDLE_STATE_BIT)) {
  392. hal_err("ring_id %d not in idle state", srng->ring_id);
  393. qdf_assert_always(0);
  394. }
  395. }
  396. hal_debug("hw_init srng %d", srng->ring_id);
  397. if (srng->flags & HAL_SRNG_MSI_INTR) {
  398. SRNG_DST_REG_WRITE(srng, MSI1_BASE_LSB,
  399. srng->msi_addr & 0xffffffff);
  400. reg_val = SRNG_SM(SRNG_DST_FLD(MSI1_BASE_MSB, ADDR),
  401. (uint64_t)(srng->msi_addr) >> 32) |
  402. SRNG_SM(SRNG_DST_FLD(MSI1_BASE_MSB,
  403. MSI1_ENABLE), 1);
  404. SRNG_DST_REG_WRITE(srng, MSI1_BASE_MSB, reg_val);
  405. SRNG_DST_REG_WRITE(srng, MSI1_DATA,
  406. qdf_cpu_to_le32(srng->msi_data));
  407. hal_srng_dst_msi2_setup(srng);
  408. }
  409. SRNG_DST_REG_WRITE(srng, BASE_LSB, srng->ring_base_paddr & 0xffffffff);
  410. reg_val = SRNG_SM(SRNG_DST_FLD(BASE_MSB, RING_BASE_ADDR_MSB),
  411. ((uint64_t)(srng->ring_base_paddr) >> 32)) |
  412. SRNG_SM(SRNG_DST_FLD(BASE_MSB, RING_SIZE),
  413. srng->entry_size * srng->num_entries);
  414. SRNG_DST_REG_WRITE(srng, BASE_MSB, reg_val);
  415. reg_val = SRNG_SM(SRNG_DST_FLD(ID, RING_ID), srng->ring_id) |
  416. SRNG_SM(SRNG_DST_FLD(ID, ENTRY_SIZE), srng->entry_size);
  417. SRNG_DST_REG_WRITE(srng, ID, reg_val);
  418. /**
  419. * Interrupt setup:
  420. * Default interrupt mode is 'pulse'. Need to setup SW_INTERRUPT_MODE
  421. * if level mode is required
  422. */
  423. reg_val = 0;
  424. if (srng->intr_timer_thres_us) {
  425. reg_val |= SRNG_SM(SRNG_DST_FLD(PRODUCER_INT_SETUP,
  426. INTERRUPT_TIMER_THRESHOLD),
  427. srng->intr_timer_thres_us >> 3);
  428. }
  429. if (srng->intr_batch_cntr_thres_entries) {
  430. reg_val |= SRNG_SM(SRNG_DST_FLD(PRODUCER_INT_SETUP,
  431. BATCH_COUNTER_THRESHOLD),
  432. srng->intr_batch_cntr_thres_entries *
  433. srng->entry_size);
  434. }
  435. SRNG_DST_REG_WRITE(srng, PRODUCER_INT_SETUP, reg_val);
  436. /**
  437. * Near-Full Interrupt setup:
  438. * Default interrupt mode is 'pulse'. Need to setup SW_INTERRUPT_MODE
  439. * if level mode is required
  440. */
  441. hal_srng_dst_near_full_int_setup(srng);
  442. hp_addr = (uint64_t)(hal->shadow_rdptr_mem_paddr +
  443. ((unsigned long)(srng->u.dst_ring.hp_addr) -
  444. (unsigned long)(hal->shadow_rdptr_mem_vaddr)));
  445. SRNG_DST_REG_WRITE(srng, HP_ADDR_LSB, hp_addr & 0xffffffff);
  446. SRNG_DST_REG_WRITE(srng, HP_ADDR_MSB, hp_addr >> 32);
  447. /* Initilaize head and tail pointers to indicate ring is empty */
  448. SRNG_DST_REG_WRITE(srng, HP, 0);
  449. SRNG_DST_REG_WRITE(srng, TP, 0);
  450. *(srng->u.dst_ring.hp_addr) = 0;
  451. reg_val = ((srng->flags & HAL_SRNG_DATA_TLV_SWAP) ?
  452. SRNG_SM(SRNG_DST_FLD(MISC, DATA_TLV_SWAP_BIT), 1) : 0) |
  453. ((srng->flags & HAL_SRNG_RING_PTR_SWAP) ?
  454. SRNG_SM(SRNG_DST_FLD(MISC, HOST_FW_SWAP_BIT), 1) : 0) |
  455. ((srng->flags & HAL_SRNG_MSI_SWAP) ?
  456. SRNG_SM(SRNG_DST_FLD(MISC, MSI_SWAP_BIT), 1) : 0);
  457. /*
  458. * reg_val |= SRNG_SM(SRNG_SRC_FLD(MISC, SRNG_ENABLE), 1);
  459. * todo: update fw_api and replace with above line
  460. * (when SRNG_ENABLE field for the MISC register is available in fw_api)
  461. * (WCSS_UMAC_CE_0_SRC_WFSS_CE_CHANNEL_SRC_R0_SRC_RING_MISC)
  462. */
  463. reg_val |= 0x40;
  464. SRNG_DST_REG_WRITE(srng, MISC, reg_val);
  465. }
  466. /**
  467. * hal_srng_hw_reg_offset_init_generic() - Initialize the HW srng reg offset
  468. * @hal_soc: HAL Soc handle
  469. *
  470. * Return: None
  471. */
  472. static inline void hal_srng_hw_reg_offset_init_generic(struct hal_soc *hal_soc)
  473. {
  474. int32_t *hw_reg_offset = hal_soc->hal_hw_reg_offset;
  475. /* dst */
  476. hw_reg_offset[DST_HP] = REG_OFFSET(DST, HP);
  477. hw_reg_offset[DST_TP] = REG_OFFSET(DST, TP);
  478. hw_reg_offset[DST_ID] = REG_OFFSET(DST, ID);
  479. hw_reg_offset[DST_MISC] = REG_OFFSET(DST, MISC);
  480. hw_reg_offset[DST_HP_ADDR_LSB] = REG_OFFSET(DST, HP_ADDR_LSB);
  481. hw_reg_offset[DST_HP_ADDR_MSB] = REG_OFFSET(DST, HP_ADDR_MSB);
  482. hw_reg_offset[DST_MSI1_BASE_LSB] = REG_OFFSET(DST, MSI1_BASE_LSB);
  483. hw_reg_offset[DST_MSI1_BASE_MSB] = REG_OFFSET(DST, MSI1_BASE_MSB);
  484. hw_reg_offset[DST_MSI1_DATA] = REG_OFFSET(DST, MSI1_DATA);
  485. hw_reg_offset[DST_BASE_LSB] = REG_OFFSET(DST, BASE_LSB);
  486. hw_reg_offset[DST_BASE_MSB] = REG_OFFSET(DST, BASE_MSB);
  487. hw_reg_offset[DST_PRODUCER_INT_SETUP] =
  488. REG_OFFSET(DST, PRODUCER_INT_SETUP);
  489. /* src */
  490. hw_reg_offset[SRC_HP] = REG_OFFSET(SRC, HP);
  491. hw_reg_offset[SRC_TP] = REG_OFFSET(SRC, TP);
  492. hw_reg_offset[SRC_ID] = REG_OFFSET(SRC, ID);
  493. hw_reg_offset[SRC_MISC] = REG_OFFSET(SRC, MISC);
  494. hw_reg_offset[SRC_TP_ADDR_LSB] = REG_OFFSET(SRC, TP_ADDR_LSB);
  495. hw_reg_offset[SRC_TP_ADDR_MSB] = REG_OFFSET(SRC, TP_ADDR_MSB);
  496. hw_reg_offset[SRC_MSI1_BASE_LSB] = REG_OFFSET(SRC, MSI1_BASE_LSB);
  497. hw_reg_offset[SRC_MSI1_BASE_MSB] = REG_OFFSET(SRC, MSI1_BASE_MSB);
  498. hw_reg_offset[SRC_MSI1_DATA] = REG_OFFSET(SRC, MSI1_DATA);
  499. hw_reg_offset[SRC_BASE_LSB] = REG_OFFSET(SRC, BASE_LSB);
  500. hw_reg_offset[SRC_BASE_MSB] = REG_OFFSET(SRC, BASE_MSB);
  501. hw_reg_offset[SRC_CONSUMER_INT_SETUP_IX0] =
  502. REG_OFFSET(SRC, CONSUMER_INT_SETUP_IX0);
  503. hw_reg_offset[SRC_CONSUMER_INT_SETUP_IX1] =
  504. REG_OFFSET(SRC, CONSUMER_INT_SETUP_IX1);
  505. #ifdef DP_UMAC_HW_RESET_SUPPORT
  506. hw_reg_offset[SRC_CONSUMER_PREFETCH_TIMER] =
  507. REG_OFFSET(SRC, CONSUMER_PREFETCH_TIMER);
  508. #endif
  509. }
  510. #endif /* HAL_GENERIC_API_H_ */