1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: Host board config header file. 15 * Author: 16 * Create: 2021-06-01 17 */ 18 19 #ifndef __BOARD_H__ 20 #define __BOARD_H__ 21 /***************************************************************************** 22 1 Include other Head file 23 *****************************************************************************/ 24 #include <linux/platform_device.h> 25 #include <linux/regulator/consumer.h> 26 #include <linux/regulator/driver.h> 27 #include <linux/regulator/machine.h> 28 29 #include "oal_plat_type.h" 30 #include "hcc_bus.h" 31 32 /***************************************************************************** 33 2 Define macro 34 *****************************************************************************/ 35 36 #define BOARD_SUCC (0) 37 #define BOARD_FAIL (-1) 38 39 #define VERSION_FPGA (0) 40 #define VERSION_ASIC (1) 41 42 #define WIFI_TAS_DISABLE (0) 43 #define WIFI_TAS_ENABLE (1) 44 45 #define PMU_CLK_REQ_DISABLE (0) 46 #define PMU_CLK_REQ_ENABLE (1) 47 48 #define GPIO_LOWLEVEL (0) 49 #define GPIO_HIGHLEVEL (1) 50 51 #define NO_NEED_POWER_PREPARE (0) 52 #define NEED_POWER_PREPARE (1) 53 54 #define PINMUX_SET_INIT (0) 55 #define PINMUX_SET_SUCC (1) 56 57 /* ini cfg */ 58 #define INI_BT_BUS "board_info.bt_bus" 59 #define INI_WIFI_BUS "board_info.wlan_bus" 60 61 #define DOWNLOAD_MODE_SDIO "sdio" 62 #define DOWNLOAD_MODE_PCIE "pcie" 63 #define DOWNLOAD_MODE_UART "uart" 64 #define DOWNLOAD_MODE_USB "usb" 65 66 #define BOARD_VERSION_LEN (128) 67 #define DOWNLOAD_CHANNEL_LEN (64) 68 #define BT_BUS_NAME_LEN 5 69 70 #define INI_SSI_DUMP_EN "ssi_dump_enable" 71 72 /***************************************************************************** 73 3 STRUCT DEFINE 74 *****************************************************************************/ 75 typedef struct bd_init_s { 76 osal_s32 (*wlan_power_off_etc)(void); 77 osal_s32 (*wlan_power_on_etc)(void); 78 osal_s32 (*board_power_on_etc)(osal_u32 subsystem); 79 osal_s32 (*board_power_off_etc)(osal_u32 subsystem); 80 osal_s32 (*board_power_reset)(osal_u32 subsystem); 81 } bd_init_t; 82 83 /* private data for pm driver */ 84 typedef struct { 85 /* board init ops */ 86 struct bd_init_s bd_ops; 87 88 /* power */ 89 osal_s32 power_gpio; 90 91 /* wakeup gpio */ 92 osal_s32 wkup_gpio_support; 93 osal_s32 wlan_wakeup_host; 94 osal_s32 bt_wakeup_host; 95 osal_s32 host_wakeup_wlan; 96 97 /* how to download firmware */ 98 osal_s32 wlan_bus; 99 osal_s32 bt_bus; 100 101 /* irq info */ 102 osal_u32 wlan_irq; 103 osal_u32 bt_irq; 104 105 /* uart info */ 106 const char *uart_port; 107 osal_s32 uart_pclk; 108 109 /* ini cfg */ 110 char* ini_file_name; 111 } board_info; 112 113 typedef struct { 114 osal_u32 index; 115 osal_u8 name[DOWNLOAD_CHANNEL_LEN + 1]; 116 } bus_table; 117 118 enum board_power { 119 WLAN_POWER = 0x0, 120 BFGX_POWER = 0x1, 121 POWER_BUTT, 122 }; 123 enum board_power_state { 124 BOARD_POWER_OFF = 0x0, 125 BOARD_POWER_ON = 0x1, 126 }; 127 128 board_info *get_board_info(void); 129 osal_s32 get_wlan_bus_type(void); 130 osal_s32 get_bt_bus_type(void); 131 osal_s32 hh503_board_init(void); 132 void hh503_board_exit(void); 133 extern osal_s32 board_host_wakeup_dev_set(int value); 134 extern osal_s32 board_get_host_wakeup_dev_stat(void); 135 extern osal_s32 board_wifi_tas_set(int value); 136 extern osal_s32 board_power_on_etc(osal_u32 subsystem); 137 extern osal_s32 board_power_off_etc(osal_u32 subsystem); 138 extern osal_s32 board_power_reset(osal_u32 subsystem); 139 extern osal_s32 board_wlan_gpio_power_on(void); 140 extern osal_s32 board_wlan_gpio_power_off(void); 141 extern int board_get_bwkup_gpio_val_etc(void); 142 extern int board_get_wlan_wkup_gpio_val_etc(void); 143 extern osal_s32 get_board_gpio_etc(const char *gpio_node, const char *gpio_prop, osal_s32 *physical_gpio); 144 extern void boart_power_state_change(osal_s32 flag); 145 extern osal_s32 get_board_custmize_etc(const char *cust_node, const char *cust_prop, const char **cust_prop_val); 146 extern osal_s32 get_board_dts_node_etc(struct device_node **np, const char *node_prop); 147 int board_is_support_wkup_gpio(void); 148 #endif 149 150