hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* SPDX-License-Identifier: GPL-2.0 */
/******************************************************************************
 *
 * Copyright(c) 2017 - 2019 Realtek Corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 ******************************************************************************/
 
#include "halmac_cfg_wmac_8821c.h"
#include "halmac_8821c_cfg.h"
 
#if HALMAC_8821C_SUPPORT
 
/**
 * cfg_drv_info_8821c() - config driver info
 * @adapter : the adapter of halmac
 * @drv_info : driver information selection
 * Author : KaiYuan Chang/Ivan Lin
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
cfg_drv_info_8821c(struct halmac_adapter *adapter,
          enum halmac_drv_info drv_info)
{
   u8 drv_info_size = 0;
   u8 phy_status_en = 0;
   u8 sniffer_en = 0;
   u8 plcp_hdr_en = 0;
   u8 value8;
   u32 value32;
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   PLTFM_MSG_TRACE("[TRACE]%s ===>\n", __func__);
   PLTFM_MSG_TRACE("[TRACE]drv info = %d\n", drv_info);
 
   switch (drv_info) {
   case HALMAC_DRV_INFO_NONE:
       drv_info_size = 0;
       phy_status_en = 0;
       sniffer_en = 0;
       plcp_hdr_en = 0;
       break;
   case HALMAC_DRV_INFO_PHY_STATUS:
       drv_info_size = 4;
       phy_status_en = 1;
       sniffer_en = 0;
       plcp_hdr_en = 0;
       break;
   case HALMAC_DRV_INFO_PHY_SNIFFER:
       drv_info_size = 5; /* phy status 4byte, sniffer info 1byte */
       phy_status_en = 1;
       sniffer_en = 1;
       plcp_hdr_en = 0;
       break;
   case HALMAC_DRV_INFO_PHY_PLCP:
       drv_info_size = 6; /* phy status 4byte, plcp header 2byte */
       phy_status_en = 1;
       sniffer_en = 0;
       plcp_hdr_en = 1;
       break;
   default:
       return HALMAC_RET_SW_CASE_NOT_SUPPORT;
   }
 
   if (adapter->txff_alloc.rx_fifo_exp_mode !=
       HALMAC_RX_FIFO_EXPANDING_MODE_DISABLE)
       drv_info_size = RX_DESC_DUMMY_SIZE_8821C >> 3;
 
   HALMAC_REG_W8(REG_RX_DRVINFO_SZ, drv_info_size);
 
   value8 = HALMAC_REG_R8(REG_TRXFF_BNDY + 1);
   value8 &= 0xF0;
   /* For rxdesc len = 0 issue */
   value8 |= 0xF;
   HALMAC_REG_W8(REG_TRXFF_BNDY + 1, value8);
 
   adapter->drv_info_size = drv_info_size;
 
   value32 = HALMAC_REG_R32(REG_RCR);
   value32 = (value32 & (~BIT_APP_PHYSTS));
   if (phy_status_en == 1)
       value32 = value32 | BIT_APP_PHYSTS;
   HALMAC_REG_W32(REG_RCR, value32);
 
   value32 = HALMAC_REG_R32(REG_WMAC_OPTION_FUNCTION + 4);
   value32 = (value32 & (~(BIT(8) | BIT(9))));
   if (sniffer_en == 1)
       value32 = value32 | BIT(9);
   if (plcp_hdr_en == 1)
       value32 = value32 | BIT(8);
   HALMAC_REG_W32(REG_WMAC_OPTION_FUNCTION + 4, value32);
 
   PLTFM_MSG_TRACE("[TRACE]%s <===\n", __func__);
 
   return HALMAC_RET_SUCCESS;
}
 
/**
 * init_low_pwr_8821c() - config WMAC register
 * @adapter
 * Author : KaiYuan Chang/Ivan Lin
 * Return : enum halmac_ret_status
 * More details of status code can be found in prototype document
 */
enum halmac_ret_status
init_low_pwr_8821c(struct halmac_adapter *adapter)
{
   return HALMAC_RET_SUCCESS;
}
 
void
cfg_rx_ignore_8821c(struct halmac_adapter *adapter,
           struct halmac_mac_rx_ignore_cfg *cfg)
{
}
 
enum halmac_ret_status
cfg_ampdu_8821c(struct halmac_adapter *adapter,
       struct halmac_ampdu_config *cfg)
{
   struct halmac_api *api = (struct halmac_api *)adapter->halmac_api;
 
   if (cfg->ht_max_len != cfg->vht_max_len) {
       PLTFM_MSG_ERR("[ERR]max len ht != vht!!\n");
       return HALMAC_RET_PARA_NOT_SUPPORT;
   }
 
   HALMAC_REG_W8(REG_PROT_MODE_CTRL + 2, cfg->max_agg_num);
   HALMAC_REG_W8(REG_PROT_MODE_CTRL + 3, cfg->max_agg_num);
 
   if (cfg->max_len_en == 1)
       HALMAC_REG_W32(REG_AMPDU_MAX_LENGTH, cfg->ht_max_len);
 
   return HALMAC_RET_SUCCESS;
}
 
#endif /* HALMAC_8821C_SUPPORT */