1 /******************************************************************************
3 * Copyright(c) 2017 - 2018 Realtek Corporation. All rights reserved.
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.
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
14 ******************************************************************************/
16 #include "halmac_8821c_cfg.h"
17 #include "halmac_common_8821c.h"
18 #include "../halmac_common_88xx.h"
19 #include "halmac_cfg_wmac_8821c.h"
20 #if HALMAC_PCIE_SUPPORT
21 #include "halmac_pcie_8821c.h"
24 #if HALMAC_8821C_SUPPORT
27 cfg_ldo25_8821c(struct halmac_adapter *adapter, u8 enable);
30 * get_hw_value_8821c() -get hw config value
31 * @adapter : the adapter of halmac
32 * @hw_id : hw id for driver to query
33 * @value : hw value, reference table to get data type
34 * Author : KaiYuan Chang / Ivan Lin
35 * Return : enum halmac_ret_status
36 * More details of status code can be found in prototype document
38 enum halmac_ret_status
39 get_hw_value_8821c(struct halmac_adapter *adapter, enum halmac_hw_id hw_id,
42 PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
45 PLTFM_MSG_ERR("[ERR]null pointer\n");
46 return HALMAC_RET_NULL_POINTER;
49 if (get_hw_value_88xx(adapter, hw_id, value) == HALMAC_RET_SUCCESS)
50 return HALMAC_RET_SUCCESS;
53 case HALMAC_HW_FW_MAX_SIZE:
54 *(u32 *)value = WLAN_FW_MAX_SIZE_8821C;
56 case HALMAC_HW_SDIO_INT_LAT:
58 case HALMAC_HW_SDIO_CLK_CNT:
61 return HALMAC_RET_PARA_NOT_SUPPORT;
64 PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
66 return HALMAC_RET_SUCCESS;
70 * set_hw_value_8821c() -set hw config value
71 * @adapter : the adapter of halmac
72 * @hw_id : hw id for driver to config
73 * @value : hw value, reference table to get data type
74 * Author : KaiYuan Chang / Ivan Lin
75 * Return : enum halmac_ret_status
76 * More details of status code can be found in prototype document
78 enum halmac_ret_status
79 set_hw_value_8821c(struct halmac_adapter *adapter, enum halmac_hw_id hw_id,
82 enum halmac_ret_status status = HALMAC_RET_SUCCESS;
84 PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
87 PLTFM_MSG_ERR("[ERR]null pointer\n");
88 return HALMAC_RET_NULL_POINTER;
91 if (set_hw_value_88xx(adapter, hw_id, value) == HALMAC_RET_SUCCESS)
92 return HALMAC_RET_SUCCESS;
95 case HALMAC_HW_AMPDU_CONFIG:
96 status = cfg_ampdu_8821c(adapter,
97 (struct halmac_ampdu_config *)value);
99 case HALMAC_HW_SDIO_TX_FORMAT:
101 case HALMAC_HW_RXGCK_FIFO:
103 case HALMAC_HW_RX_IGNORE:
105 case HALMAC_HW_LDO25_EN:
106 cfg_ldo25_8821c(adapter, *(u8 *)value);
108 #if HALMAC_PCIE_SUPPORT
109 case HALMAC_HW_PCIE_REF_AUTOK:
110 if (adapter->intf != HALMAC_INTERFACE_PCIE)
111 return HALMAC_RET_WRONG_INTF;
112 status = auto_refclk_cal_8821c_pcie(adapter);
113 if (status != HALMAC_RET_SUCCESS)
117 case HALMAC_HW_SDIO_WT_EN:
119 case HALMAC_HW_SDIO_CLK_MONITOR:
122 return HALMAC_RET_PARA_NOT_SUPPORT;
125 PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
131 * halmac_fill_txdesc_check_sum_88xx() - fill in tx desc check sum
132 * @adapter : the adapter of halmac
133 * @txdesc : tx desc packet
134 * Author : KaiYuan Chang/Ivan Lin
135 * Return : enum halmac_ret_status
136 * More details of status code can be found in prototype document
138 enum halmac_ret_status
139 fill_txdesc_check_sum_8821c(struct halmac_adapter *adapter, u8 *txdesc)
146 PLTFM_MSG_ERR("[ERR]null pointer\n");
147 return HALMAC_RET_NULL_POINTER;
150 if (adapter->tx_desc_checksum != 1)
151 PLTFM_MSG_TRACE("[TRACE]chksum disable\n");
153 SET_TX_DESC_TXDESC_CHECKSUM(txdesc, 0x0000);
155 data = (__le16 *)(txdesc);
157 /* HW clculates only 32byte */
158 for (i = 0; i < 8; i++)
159 chksum ^= (*(data + 2 * i) ^ *(data + (2 * i + 1)));
161 /* *(data + 2 * i) & *(data + (2 * i + 1) have endain issue*/
162 /* Process eniadn issue after checksum calculation */
163 SET_TX_DESC_TXDESC_CHECKSUM(txdesc, rtk_le16_to_cpu(chksum));
165 return HALMAC_RET_SUCCESS;
169 cfg_ldo25_8821c(struct halmac_adapter *adapter, u8 enable)
172 struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
174 value8 = HALMAC_REG_R8(REG_LDO_EFUSE_CTRL + 3);
177 HALMAC_REG_W8(REG_LDO_EFUSE_CTRL + 3, (u8)(value8 | BIT(7)));
179 HALMAC_REG_W8(REG_LDO_EFUSE_CTRL + 3, (u8)(value8 & ~BIT(7)));
182 #endif /* HALMAC_8821C_SUPPORT */