hal_wbm.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Copyright (c) 2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #include "wcss_seq_hwiobase.h"
  19. #include "wcss_seq_hwioreg.h"
  20. #include "sw_xml_headers.h"
  21. #include "reo_destination_ring.h"
  22. #include "tcl_data_cmd.h"
  23. #include "tlv_hdr.h"
  24. #include "hal_api.h"
  25. /**
  26. * hal_setup_link_idle_list - Setup scattered idle list using the
  27. * buffer list provided
  28. *
  29. * @hal_soc: Opaque HAL SOC handle
  30. * @scatter_bufs_base_paddr: Array of physical base addresses
  31. * @scatter_bufs_base_vaddr: Array of virtual base addresses
  32. * @num_scatter_bufs: Number of scatter buffers in the above lists
  33. * @scatter_buf_size: Size of each scatter buffer
  34. *
  35. */
  36. void hal_setup_link_idle_list(void *hal_soc,
  37. qdf_dma_addr_t scatter_bufs_base_paddr[],
  38. void *scatter_bufs_base_vaddr[], uint32_t num_scatter_bufs,
  39. uint32_t scatter_buf_size, uint32_t last_buf_end_offset)
  40. {
  41. int i;
  42. uint32_t *prev_buf_link_ptr = NULL;
  43. struct hal_soc *soc = (struct hal_soc *)hal_soc;
  44. /* Link the scatter buffers */
  45. for (i = 0; i < num_scatter_bufs; i++) {
  46. if (i > 0) {
  47. prev_buf_link_ptr[0] =
  48. scatter_bufs_base_paddr[i] & 0xffffffff;
  49. prev_buf_link_ptr[1] =
  50. ((uint64_t)(scatter_bufs_base_paddr[i]) >> 32) &
  51. HWIO_WBM_R0_SCATTERED_LINK_DESC_LIST_BASE_MSB_BASE_ADDRESS_39_32_BMSK;
  52. }
  53. prev_buf_link_ptr = (uint32_t *)(scatter_bufs_base_vaddr[i] +
  54. scatter_buf_size - WBM_IDLE_SCATTER_BUF_NEXT_PTR_SIZE);
  55. }
  56. /* TBD: Setup IDLE_LIST_CTRL and IDLE_LIST_SIZE registers - current
  57. * definitions in HW headers doesn't match those in WBM MLD document
  58. * pending confirmation from HW team
  59. */
  60. HAL_REG_WRITE(soc,
  61. HWIO_WBM_R0_SCATTERED_LINK_DESC_LIST_BASE_LSB_ADDR(
  62. SEQ_WCSS_UMAC_WBM_REG_OFFSET),
  63. scatter_bufs_base_paddr[0] & 0xffffffff);
  64. HAL_REG_WRITE(soc,
  65. HWIO_WBM_R0_SCATTERED_LINK_DESC_LIST_BASE_MSB_ADDR(
  66. SEQ_WCSS_UMAC_WBM_REG_OFFSET),
  67. ((uint64_t)(scatter_bufs_base_paddr[0]) >> 32) &
  68. HWIO_WBM_R0_SCATTERED_LINK_DESC_LIST_BASE_MSB_BASE_ADDRESS_39_32_BMSK);
  69. /* ADDRESS_MATCH_TAG field in the above register is expected to match
  70. * with the upper bits of link pointer. The above write sets this field
  71. * to zero and we are also setting the upper bits of link pointers to
  72. * zero while setting up the link list of scatter buffers above
  73. */
  74. /* Setup head and tail pointers for the idle list */
  75. HAL_REG_WRITE(soc,
  76. HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_HEAD_INFO_IX0_ADDR(
  77. SEQ_WCSS_UMAC_WBM_REG_OFFSET),
  78. scatter_bufs_base_paddr[0] & 0xffffffff);
  79. HAL_REG_WRITE(soc,
  80. HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_HEAD_INFO_IX1_ADDR(
  81. SEQ_WCSS_UMAC_WBM_REG_OFFSET),
  82. HAL_SM(HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_HEAD_INFO_IX1,
  83. BUFFER_ADDRESS_39_32,
  84. ((uint64_t)(scatter_bufs_base_paddr[0]) >> 32)) |
  85. HAL_SM(HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_HEAD_INFO_IX1,
  86. HEAD_POINTER_OFFSET, 0));
  87. HAL_REG_WRITE(soc,
  88. HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_HEAD_INFO_IX0_ADDR(
  89. SEQ_WCSS_UMAC_WBM_REG_OFFSET),
  90. scatter_bufs_base_paddr[0] & 0xffffffff);
  91. HAL_REG_WRITE(soc,
  92. HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_TAIL_INFO_IX0_ADDR(
  93. SEQ_WCSS_UMAC_WBM_REG_OFFSET),
  94. scatter_bufs_base_paddr[num_scatter_bufs - 1] & 0xffffffff);
  95. HAL_REG_WRITE(soc,
  96. HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_TAIL_INFO_IX1_ADDR(
  97. SEQ_WCSS_UMAC_WBM_REG_OFFSET),
  98. HAL_SM(HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_TAIL_INFO_IX1,
  99. BUFFER_ADDRESS_39_32,
  100. ((uint64_t)(scatter_bufs_base_paddr[num_scatter_bufs - 1]) >>
  101. 32)) | HAL_SM(HWIO_WBM_R0_SCATTERED_LINK_DESC_PTR_TAIL_INFO_IX1,
  102. TAIL_POINTER_OFFSET, last_buf_end_offset << 2));
  103. }