1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __EXCEPTION_RST_H__ 20 #define __EXCEPTION_RST_H__ 21 22 /* **************************************************************************** 23 1 Include other Head file 24 **************************************************************************** */ 25 #include "oal_spinlock.h" 26 #include "oal_workqueue.h" 27 28 /* **************************************************************************** 29 2 Define macro 30 **************************************************************************** */ 31 #define WIFI_DUMP_TIMEOUT 1000 /* wifi dump bcpu数据等待时间 */ 32 33 #define PLAT_EXCEPTION_RESET_IDLE 0 /* plat 没有在处理异常 */ 34 #define PLAT_EXCEPTION_RESET_BUSY 1 /* plat 正在处理异常 */ 35 36 #define EXCEPTION_SUCCESS 0 37 #define EXCEPTION_FAIL 1 38 39 /* plat cfg cmd */ 40 #define PLAT_CFG_IOC_MAGIC 'z' 41 #define PLAT_DFR_CFG_CMD _IOW(PLAT_CFG_IOC_MAGIC, PLAT_DFR_CFG, int) 42 #define PLAT_BEATTIMER_TIMEOUT_RESET_CFG_CMD _IOW(PLAT_CFG_IOC_MAGIC, PLAT_BEATTIMER_TIMEOUT_RESET_CFG, int) 43 44 #define PLAT_EXCEPTION_ENABLE 1 45 #define PLAT_EXCEPTION_DISABLE 0 46 47 /* **************************************************************************** 48 3 STRUCT DEFINE 49 **************************************************************************** */ 50 enum EXCEPTION_TYPE_ENUM { 51 DEVICE_PANIC = 0, /* arm exception */ 52 TRANS_FAIL = 1, /* read or write failed */ 53 HOST_EXCP = 2, /* sdio host controller exception */ 54 EXCEPTION_TYPE_BUTT, 55 }; 56 57 typedef struct wifi_dump_mem_info_stru { 58 unsigned long mem_addr; 59 hi_u32 size; 60 hi_u8 *file_name; 61 } wifi_dump_mem_info_stru; 62 63 #define NOT_DUMP_MEM 0 64 65 struct st_exception_info { 66 hi_u32 exception_reset_enable; 67 hi_u32 excetion_type; 68 69 hi_u32 wifi_exception_cnt; 70 71 /* when recv error data from device, dump device mem */ 72 hi_u32 dump_mem_flag; 73 74 oal_work_stru excp_worker; 75 oal_spin_lock_stru excp_lock; 76 77 void (*wifi_dfr_func)(void); 78 }; 79 80 /* **************************************************************************** 81 4 EXTERN VARIABLE 82 **************************************************************************** */ 83 extern wifi_dump_mem_info_stru g_apst_panic_dump_mem[]; 84 extern wifi_dump_mem_info_stru g_apst_trans_fail_dump_mem[]; 85 86 /* **************************************************************************** 87 5 全局变量定义 88 **************************************************************************** */ 89 enum PLAT_CFG { 90 PLAT_DFR_CFG = 0, 91 PLAT_BEATTIMER_TIMEOUT_RESET_CFG, 92 PLAT_TRIGGER_EXCEPTION, 93 PLAT_POWER_RESET, 94 PLAT_CHANNEL_DISABLE, 95 96 PLAT_CFG_BUFF, 97 }; 98 99 /* **************************************************************************** 100 6 EXTERN FUNCTION 101 **************************************************************************** */ 102 void plat_dfr_cfg_set(unsigned long arg); 103 hi_s32 get_exception_info_reference(struct st_exception_info **exception_data); 104 hi_s32 plat_exception_handler(hi_u32 exception_type); 105 hi_s32 wifi_exception_mem_dump(wifi_dump_mem_info_stru *mem_dump_info); 106 hi_s32 plat_exception_reset_init(void); 107 hi_s32 plat_exception_reset_exit(void); 108 hi_s32 wifi_system_reset(void); 109 void oal_exception_submit(hi_s32 excep_type); 110 void oal_wakeup_exception(void); 111 hi_s32 oal_device_panic_callback(void *data); 112 hi_s32 oal_trigger_exception(hi_s32 is_sync); 113 hi_s32 oal_exception_is_busy(void); 114 void oal_try_to_dump_device_mem(hi_s32 is_sync); 115 hi_void oal_set_dev_panic(hi_void); 116 hi_void oal_clear_dev_panic(hi_void); 117 hi_u8 oal_dev_is_panic(hi_void); 118 hi_void oal_frw_exception_report(hi_void); 119 #endif 120