hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/******************************************************************************
 *
 * Copyright(c) 2019 Realtek Corporation.
 *
 * 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.
 *
 *****************************************************************************/
#define _HAL_SER_C_
#include "hal_headers.h"
 
enum rtw_hal_status rtw_hal_ser_ctrl(void *hal, enum rtw_hal_ser_rsn rsn, bool en)
{
   enum rtw_hal_status hstatus = RTW_HAL_STATUS_FAILURE;
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
 
   hstatus = rtw_hal_mac_ser_ctrl(hal_info, rsn, en);
 
   return hstatus;
}
 
u32
rtw_hal_ser_get_error_status(void *hal, u32 *err)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
   enum RTW_PHL_SER_NOTIFY_EVENT notify = RTW_PHL_SER_L2_RESET;
 
   rtw_hal_mac_ser_get_error_status(hal_info, err);
 
   if ((*err == MAC_AX_ERR_L1_ERR_DMAC) || (*err == MAC_AX_ERR_L0_PROMOTE_TO_L1)) {
       notify = RTW_PHL_SER_PAUSE_TRX;
   } else if (*err == MAC_AX_ERR_L1_RESET_DISABLE_DMAC_DONE) {
       notify = RTW_PHL_SER_DO_RECOVERY;
   } else if (*err == MAC_AX_ERR_L1_RESET_RECOVERY_DONE) {
       notify = RTW_PHL_SER_READY;
   } else if (*err < MAC_AX_ERR_L0_PROMOTE_TO_L1) {
       notify = RTW_PHL_SER_L0_RESET;
   } else if (*err == MAC_AX_DUMP_SHAREBUFF_INDICATOR) {
       notify = RTW_PHL_SER_DUMP_FW_LOG;
   } else if (*err == MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_WCMAC) {
       notify = RTW_PHL_SER_LOG_ONLY;
   } else if ((*err == MAC_AX_ERR_L1_PROMOTE_TO_L2) ||
             ((*err >= MAC_AX_ERR_L2_ERR_AH_DMA) && (*err <= MAC_AX_GET_ERR_MAX))) {
       notify = RTW_PHL_SER_L2_RESET;
   }
 
   return notify;
}
 
enum rtw_hal_status rtw_hal_ser_set_error_status(void *hal, u32 err)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
 
   return rtw_hal_mac_ser_set_error_status(hal_info, err);
}
 
bool rtw_hal_ser_chk_ser_l1(void *hal)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
 
   return rtw_hal_mac_ser_chk_ser_l1(hal_info);
}
 
enum rtw_hal_status rtw_hal_trigger_cmac_err(void *hal)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
 
   return rtw_hal_mac_trigger_cmac_err(hal_info);
}
 
enum rtw_hal_status rtw_hal_trigger_dmac_err(void *hal)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
 
   return rtw_hal_mac_trigger_dmac_err(hal_info);
}
 
enum rtw_hal_status rtw_hal_lv1_rcvy(void *hal, u32 step)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
   enum rtw_hal_status status = RTW_HAL_STATUS_FAILURE;
 
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "===> rtw_hal_lv1_rcvy step %d\n", step);
   status = rtw_hal_mac_lv1_rcvy(hal_info, step);
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "<=== rtw_hal_lv1_rcvy step %d, status 0x%x\n", step, status);
 
   return status;
}
 
void rtw_hal_dump_fw_rsvd_ple(void *hal)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
   u32 mac_err;
   mac_err = rtw_hal_mac_dump_fw_rsvd_ple(hal_info);
}
 
void
rtw_hal_ser_reset_wdt_intr(void *hal)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
   u32 mac_err;
   mac_err = rtw_hal_mac_ser_reset_wdt_intr(hal_info);
   PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "rtw_hal_ser_reset_wdt_intr status 0x%x\n",mac_err);
}
 
void rtw_hal_ser_int_cfg(void *hal, struct rtw_phl_com_t *phl_com,
                        enum RTW_PHL_SER_CFG_STEP step)
{
   struct hal_info_t *hal_info = (struct hal_info_t *)hal;
#ifdef CONFIG_SYNC_INTERRUPT
   struct rtw_phl_evt_ops *evt_ops = &phl_com->evt_ops;
#endif /* CONFIG_SYNC_INTERRUPT */
   struct hal_ops_t *hal_ops = hal_get_ops(hal_info);
   struct hal_spec_t *hal_spec = phl_get_ic_spec(phl_com);
 
   /* check whether to config imr during ser */
   if (!hal_spec->ser_cfg_int)
       return;
 
   switch (step) {
   case RTW_PHL_SER_M1_PRE_CFG:
       /**
        * 1. disable imr
        * 2. set imr used during ser
        */
       #ifdef CONFIG_SYNC_INTERRUPT
       evt_ops->set_interrupt_caps(phlcom_to_drvpriv(phl_com), false);
       #else
       if (hal_ops->disable_interrupt)
           hal_ops->disable_interrupt(hal);
       #endif /* CONFIG_SYNC_INTERRUPT */
 
       if (hal_ops->init_int_default_value)
           hal_ops->init_int_default_value(hal, INT_SET_OPT_SER_START);
       break;
   case RTW_PHL_SER_M1_POST_CFG:
       /**
        * 1. enable interrupt
        */
       #ifdef CONFIG_SYNC_INTERRUPT
       evt_ops->set_interrupt_caps(phlcom_to_drvpriv(phl_com), true);
       #else
       if (hal_ops->enable_interrupt)
           hal_ops->enable_interrupt(hal);
       #endif /* CONFIG_SYNC_INTERRUPT */
       break;
   case RTW_PHL_SER_M5_CFG:
       /**
        * 1. disable interrupt
        * 2. set imr used after ser
        * 3. enable interrupt
        */
       #ifdef CONFIG_SYNC_INTERRUPT
       evt_ops->set_interrupt_caps(phlcom_to_drvpriv(phl_com), false);
       #else
       if (hal_ops->disable_interrupt)
           hal_ops->disable_interrupt(hal);
       #endif /* CONFIG_SYNC_INTERRUPT */
 
       if (hal_ops->init_int_default_value)
           hal_ops->init_int_default_value(hal, INT_SET_OPT_SER_DONE);
 
       #ifdef CONFIG_SYNC_INTERRUPT
       evt_ops->set_interrupt_caps(phlcom_to_drvpriv(phl_com), true);
       #else
       if (hal_ops->enable_interrupt)
           hal_ops->enable_interrupt(hal);
       #endif /* CONFIG_SYNC_INTERRUPT */
       break;
   default:
       PHL_ERR("%s(): unknown step!\n", __func__);
   }
}