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 #ifndef __PLAT_PM_H__ 19 #define __PLAT_PM_H__ 20 21 /* **************************************************************************** 22 1 Include other Head file 23 **************************************************************************** */ 24 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) 25 #include <linux/mutex.h> 26 #include <linux/kernel.h> 27 #include "plat_pm_wlan.h" 28 #include "plat_board_adapt.h" 29 #endif 30 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 31 #include <linux/wakelock.h> 32 #include "plat_pm_wlan.h" 33 #include "plat_board_adapt.h" 34 #endif 35 #include "oal_task.h" 36 37 /* **************************************************************************** 38 2 Define macro 39 **************************************************************************** */ 40 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 41 #define PM_SUSPEND_PREPARE 0x0003 /* Going to suspend the system */ 42 #define PM_POST_SUSPEND 0x0004 /* Suspend finished */ 43 #define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */ 44 #define PM_SUSPEND_PREPARE 0x0003 /* Going to suspend the system */ 45 #define PM_POST_SUSPEND 0x0004 /* Suspend finished */ 46 #define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */ 47 48 #define ASYNCB_SUSPENDED 30 /* Serial port is suspended */ 49 #endif 50 51 #define SUCCESS 0 52 #define FAILURE 1 53 54 #define WAIT_DEVACK_MSEC 100 55 #define WAIT_DEVACK_TIMEOUT_MSEC 200 56 57 #define WAIT_WKUPDEV_MSEC 3400 58 59 #define SDIO_REINIT_RETRY 5 60 61 enum WLAN_DEV_STATUS_ENUM { 62 HOST_DISALLOW_TO_SLEEP = 0, 63 HOST_ALLOW_TO_SLEEP = 1, 64 HOST_EXCEPTION = 2, 65 DEV_SHUTDOWN = 3, 66 }; 67 68 enum WLAN_HOST_STATUS_ENUM { 69 HOST_NOT_SLEEP = 0, 70 HOST_SLEEPED = 1, 71 }; 72 73 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 74 /* BFGX系统上电加载异常类型 */ 75 enum BFGX_POWER_ON_EXCEPTION_ENUM { 76 BFGX_POWER_FAILED = -1, 77 BFGX_POWER_SUCCESS = 0, 78 79 BFGX_POWER_PULL_POWER_GPIO_FAIL = 1, 80 BFGX_POWER_TTY_OPEN_FAIL = 2, 81 BFGX_POWER_TTY_FLOW_ENABLE_FAIL = 3, 82 83 BFGX_POWER_WIFI_DERESET_BCPU_FAIL = 4, 84 BFGX_POWER_WIFI_ON_BOOT_UP_FAIL = 5, 85 86 BFGX_POWER_WIFI_OFF_BOOT_UP_FAIL = 6, 87 BFGX_POWER_DOWNLOAD_FIRMWARE_FAIL = 7, 88 89 BFGX_POWER_WAKEUP_FAIL = 8, 90 BFGX_POWER_OPEN_CMD_FAIL = 9, 91 92 BFGX_POWER_ENUM_BUTT, 93 }; 94 95 /* wifi系统上电加载异常类型 */ 96 enum WIFI_POWER_ON_EXCEPTION_ENUM { 97 WIFI_POWER_FAIL = -1, 98 WIFI_POWER_SUCCESS = 0, 99 WIFI_POWER_PULL_POWER_GPIO_FAIL = 1, 100 101 WIFI_POWER_BFGX_OFF_BOOT_UP_FAIL = 2, 102 WIFI_POWER_BFGX_OFF_FIRMWARE_DOWNLOAD_FAIL = 3, 103 104 WIFI_POWER_BFGX_ON_BOOT_UP_FAIL = 4, 105 WIFI_POWER_BFGX_DERESET_WCPU_FAIL = 5, 106 WIFI_POWER_BFGX_ON_FIRMWARE_DOWNLOAD_FAIL = 6, 107 108 WIFI_POWER_ENUM_BUTT, 109 }; 110 111 #elif (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) 112 /* wifi系统上电加载异常类型 */ 113 enum WIFI_POWER_ON_EXCEPTION_ENUM { 114 WIFI_POWER_FAIL = -1, 115 WIFI_POWER_SUCCESS = 0, 116 WIFI_POWER_BFGX_OFF_BOOT_UP_FAIL = 1, 117 WIFI_POWER_BFGX_OFF_FIRMWARE_DOWNLOAD_FAIL = 2, 118 119 WIFI_POWER_ENUM_BUTT, 120 }; 121 #endif 122 123 typedef enum { 124 POWER_STATE_SHUTDOWN = 0, 125 POWER_STATE_OPEN = 1, 126 POWER_STATE_BUTT = 2, 127 } power_state_enum; 128 129 /* **************************************************************************** 130 3 STRUCT DEFINE 131 **************************************************************************** */ 132 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) 133 134 #elif (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 135 136 struct notifier_block; 137 138 typedef int (*notifier_fn_t)(struct notifier_block *nb, unsigned long action, void *data); 139 140 struct notifier_block { 141 notifier_fn_t notifier_call; 142 struct notifier_block *next; 143 int priority; 144 }; 145 #endif 146 147 /* **************************************************************************** 148 4 EXTERN VARIABLE 149 **************************************************************************** */ 150 #if (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 151 extern unsigned int g_ul_wlan_resume_state; 152 extern unsigned int g_ul_wlan_resume_wifi_init_flag; 153 #endif 154 155 /* **************************************************************************** 156 5 EXTERN FUNCTION 157 **************************************************************************** */ 158 #if (_PRE_OS_VERSION_LINUX == _PRE_OS_VERSION) || (_PRE_OS_VERSION_LITEOS == _PRE_OS_VERSION) 159 extern hi_s32 wlan_power_on(void); 160 extern int firmware_download_function(hi_u32 which_cfg); 161 #endif 162 163 #endif 164