1 /******************************************************************************
2 *
3 * Copyright(c) 2019 Realtek Corporation.
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 #define _HAL_SER_C_
16 #include "hal_headers.h"
17
rtw_hal_ser_ctrl(void * hal,bool en)18 enum rtw_hal_status rtw_hal_ser_ctrl(void *hal, bool en)
19 {
20 enum rtw_hal_status hstatus = RTW_HAL_STATUS_FAILURE;
21 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
22
23 hstatus = rtw_hal_mac_ser_ctrl(hal_info, en);
24
25 return hstatus;
26 }
27
28 u32
rtw_hal_ser_get_error_status(void * hal,u32 * err)29 rtw_hal_ser_get_error_status(void *hal, u32 *err)
30 {
31 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
32 enum RTW_PHL_SER_NOTIFY_EVENT notify = RTW_PHL_SER_L2_RESET;
33
34 rtw_hal_mac_ser_get_error_status(hal_info, err);
35
36 if ((*err == MAC_AX_ERR_L1_ERR_DMAC) || (*err == MAC_AX_ERR_L0_PROMOTE_TO_L1)) {
37 notify = RTW_PHL_SER_PAUSE_TRX;
38 } else if (*err == MAC_AX_ERR_L1_RESET_DISABLE_DMAC_DONE) {
39 notify = RTW_PHL_SER_DO_RECOVERY;
40 } else if (*err == MAC_AX_ERR_L1_RESET_RECOVERY_DONE) {
41 notify = RTW_PHL_SER_READY;
42 } else if (*err < MAC_AX_ERR_L0_PROMOTE_TO_L1) {
43 notify = RTW_PHL_SER_L0_RESET;
44 } else if (*err == MAC_AX_DUMP_SHAREBUFF_INDICATOR) {
45 notify = RTW_PHL_SER_DUMP_FW_LOG;
46 } else if (*err == MAC_AX_ERR_L2_ERR_APB_SA_TO_HCI_WCMAC) {
47 notify = RTW_PHL_SER_LOG_ONLY;
48 } else if ((*err == MAC_AX_ERR_L1_PROMOTE_TO_L2) ||
49 ((*err >= MAC_AX_ERR_L2_ERR_AH_DMA) && (*err <= MAC_AX_GET_ERR_MAX))) {
50 notify = RTW_PHL_SER_L2_RESET;
51 }
52
53 return notify;
54 }
55
rtw_hal_ser_set_error_status(void * hal,u32 err)56 enum rtw_hal_status rtw_hal_ser_set_error_status(void *hal, u32 err)
57 {
58 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
59
60 return rtw_hal_mac_ser_set_error_status(hal_info, err);
61 }
62
rtw_hal_trigger_cmac_err(void * hal)63 enum rtw_hal_status rtw_hal_trigger_cmac_err(void *hal)
64 {
65 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
66
67 return rtw_hal_mac_trigger_cmac_err(hal_info);
68 }
69
rtw_hal_trigger_dmac_err(void * hal)70 enum rtw_hal_status rtw_hal_trigger_dmac_err(void *hal)
71 {
72 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
73
74 return rtw_hal_mac_trigger_dmac_err(hal_info);
75 }
76
rtw_hal_lv1_rcvy(void * hal,u32 step)77 enum rtw_hal_status rtw_hal_lv1_rcvy(void *hal, u32 step)
78 {
79 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
80 enum rtw_hal_status status = RTW_HAL_STATUS_FAILURE;
81
82 PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "===> rtw_hal_lv1_rcvy step %d\n", step);
83 status = rtw_hal_mac_lv1_rcvy(hal_info, step);
84 PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "<=== rtw_hal_lv1_rcvy step %d, status 0x%x\n", step, status);
85
86 return status;
87 }
88
rtw_hal_dump_fw_rsvd_ple(void * hal)89 void rtw_hal_dump_fw_rsvd_ple(void *hal)
90 {
91 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
92 u32 mac_err;
93 mac_err = rtw_hal_mac_dump_fw_rsvd_ple(hal_info);
94 }
95
96 void
rtw_hal_ser_reset_wdt_intr(void * hal)97 rtw_hal_ser_reset_wdt_intr(void *hal)
98 {
99 struct hal_info_t *hal_info = (struct hal_info_t *)hal;
100 u32 mac_err;
101 mac_err = rtw_hal_mac_ser_reset_wdt_intr(hal_info);
102 PHL_TRACE(COMP_PHL_DBG, _PHL_INFO_, "rtw_hal_ser_reset_wdt_intr status 0x%x\n",mac_err);
103 }
104