halmac_cfg_wmac_8821c.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2017 - 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_cfg_wmac_8821c.h"
  16. #include "halmac_8821c_cfg.h"
  17. #if HALMAC_8821C_SUPPORT
  18. /**
  19. * cfg_drv_info_8821c() - config driver info
  20. * @adapter : the adapter of halmac
  21. * @drv_info : driver information selection
  22. * Author : KaiYuan Chang/Ivan Lin
  23. * Return : enum halmac_ret_status
  24. * More details of status code can be found in prototype document
  25. */
  26. enum halmac_ret_status
  27. cfg_drv_info_8821c(struct halmac_adapter *adapter,
  28. enum halmac_drv_info drv_info)
  29. {
  30. u8 drv_info_size = 0;
  31. u8 phy_status_en = 0;
  32. u8 sniffer_en = 0;
  33. u8 plcp_hdr_en = 0;
  34. u8 value8;
  35. u32 value32;
  36. struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
  37. PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
  38. PLTFM_MSG_TRACE("[TRACE]drv info = %d\n", drv_info);
  39. switch (drv_info) {
  40. case HALMAC_DRV_INFO_NONE:
  41. drv_info_size = 0;
  42. phy_status_en = 0;
  43. sniffer_en = 0;
  44. plcp_hdr_en = 0;
  45. break;
  46. case HALMAC_DRV_INFO_PHY_STATUS:
  47. drv_info_size = 4;
  48. phy_status_en = 1;
  49. sniffer_en = 0;
  50. plcp_hdr_en = 0;
  51. break;
  52. case HALMAC_DRV_INFO_PHY_SNIFFER:
  53. drv_info_size = 5; /* phy status 4byte, sniffer info 1byte */
  54. phy_status_en = 1;
  55. sniffer_en = 1;
  56. plcp_hdr_en = 0;
  57. break;
  58. case HALMAC_DRV_INFO_PHY_PLCP:
  59. drv_info_size = 6; /* phy status 4byte, plcp header 2byte */
  60. phy_status_en = 1;
  61. sniffer_en = 0;
  62. plcp_hdr_en = 1;
  63. break;
  64. default:
  65. return HALMAC_RET_SW_CASE_NOT_SUPPORT;
  66. }
  67. if (adapter->txff_alloc.rx_fifo_exp_mode !=
  68. HALMAC_RX_FIFO_EXPANDING_MODE_DISABLE)
  69. drv_info_size = RX_DESC_DUMMY_SIZE_8821C >> 3;
  70. HALMAC_REG_W8(REG_RX_DRVINFO_SZ, drv_info_size);
  71. value8 = HALMAC_REG_R8(REG_TRXFF_BNDY + 1);
  72. value8 &= 0xF0;
  73. /* For rxdesc len = 0 issue */
  74. value8 |= 0xF;
  75. HALMAC_REG_W8(REG_TRXFF_BNDY + 1, value8);
  76. adapter->drv_info_size = drv_info_size;
  77. value32 = HALMAC_REG_R32(REG_RCR);
  78. value32 = (value32 & (~BIT_APP_PHYSTS));
  79. if (phy_status_en == 1)
  80. value32 = value32 | BIT_APP_PHYSTS;
  81. HALMAC_REG_W32(REG_RCR, value32);
  82. value32 = HALMAC_REG_R32(REG_WMAC_OPTION_FUNCTION + 4);
  83. value32 = (value32 & (~(BIT(8) | BIT(9))));
  84. if (sniffer_en == 1)
  85. value32 = value32 | BIT(9);
  86. if (plcp_hdr_en == 1)
  87. value32 = value32 | BIT(8);
  88. HALMAC_REG_W32(REG_WMAC_OPTION_FUNCTION + 4, value32);
  89. PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
  90. return HALMAC_RET_SUCCESS;
  91. }
  92. /**
  93. * init_low_pwr_8821c() - config WMAC register
  94. * @adapter
  95. * Author : KaiYuan Chang/Ivan Lin
  96. * Return : enum halmac_ret_status
  97. * More details of status code can be found in prototype document
  98. */
  99. enum halmac_ret_status
  100. init_low_pwr_8821c(struct halmac_adapter *adapter)
  101. {
  102. return HALMAC_RET_SUCCESS;
  103. }
  104. void
  105. cfg_rx_ignore_8821c(struct halmac_adapter *adapter,
  106. struct halmac_mac_rx_ignore_cfg *cfg)
  107. {
  108. }
  109. enum halmac_ret_status
  110. cfg_ampdu_8821c(struct halmac_adapter *adapter,
  111. struct halmac_ampdu_config *cfg)
  112. {
  113. struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
  114. if (cfg->ht_max_len != cfg->vht_max_len) {
  115. PLTFM_MSG_ERR("[ERR]max len ht != vht!!\n");
  116. return HALMAC_RET_PARA_NOT_SUPPORT;
  117. }
  118. HALMAC_REG_W8(REG_PROT_MODE_CTRL + 2, cfg->max_agg_num);
  119. HALMAC_REG_W8(REG_PROT_MODE_CTRL + 3, cfg->max_agg_num);
  120. if (cfg->max_len_en == 1)
  121. HALMAC_REG_W32(REG_AMPDU_MAX_LENGTH, cfg->ht_max_len);
  122. return HALMAC_RET_SUCCESS;
  123. }
  124. #endif /* HALMAC_8821C_SUPPORT */