hong.liu | cd37079 | 2025-05-28 06:29:19 -0700 | [diff] [blame] | 1 | /** |
| 2 | * @file : gsw_hwpin_interface.h |
| 3 | * @brief : Gpio and mcu ctrl |
| 4 | * @date : 2022-07-05 |
| 5 | * @author : Wind |
| 6 | * @version : v1.0 |
| 7 | * @copyright Copyright(C) 2022,Geely |
| 8 | */ |
| 9 | #ifndef __GSW_HW_PIN_INTERFACE__H__ |
| 10 | #define __GSW_HW_PIN_INTERFACE__H__ |
| 11 | #include "gsw_hal_errcode.h" |
| 12 | #include <stdbool.h> |
| 13 | |
| 14 | #define GSW_HAL_USB_SUCCESS (0x0001) |
| 15 | |
| 16 | /** |
| 17 | * @brief hardware reset mcu only |
| 18 | * @param |
| 19 | * @retval 0: success |
| 20 | * @retval other: fail |
| 21 | */ |
| 22 | int gsw_hwpin_mcu_reset(void); |
| 23 | |
| 24 | /** |
| 25 | * @brief hold mcu boot pin then reset to bootmode |
| 26 | * @param |
| 27 | * @retval 0: success |
| 28 | * @retval other: fail |
| 29 | */ |
| 30 | int gsw_hwpin_mcu_enter_bootmode(void); |
| 31 | |
| 32 | /** |
| 33 | * @brief release mcu boot pin then reset to normalMode |
| 34 | * @param |
| 35 | * @retval 0: success |
| 36 | * @retval other: fail |
| 37 | */ |
| 38 | int gsw_hwpin_mcu_exit_bootmode(void); |
| 39 | |
| 40 | /** |
| 41 | * @brief hardware reset soc and mcu |
| 42 | * @param |
| 43 | * @retval 0: success |
| 44 | * @retval other: fail |
| 45 | */ |
| 46 | int gsw_hwpin_tcam_reset(void); |
| 47 | |
| 48 | /** |
| 49 | * @brief keep soc power |
| 50 | * @param |
| 51 | * @retval 0: success |
| 52 | * @retval other: fail |
| 53 | */ |
| 54 | int gsw_hwpin_soc_power_keep(void); |
| 55 | |
| 56 | /** |
| 57 | * @brief release soc power |
| 58 | * @param |
| 59 | * @retval 0: success |
| 60 | * @retval other: fail |
| 61 | */ |
| 62 | int gsw_hwpin_soc_power_release(void); |
| 63 | |
| 64 | /** |
| 65 | * @brief wakeup mcu through gpio |
| 66 | * @param |
| 67 | * @retval 0: success |
| 68 | * @retval other: fail |
| 69 | */ |
| 70 | int gsw_hwpin_soc_wakeup_mcu(void); |
| 71 | |
| 72 | /** |
| 73 | * @brief soc wakeup mcu gpio output low |
| 74 | * @param |
| 75 | * @retval 0: success |
| 76 | * @retval other: fail |
| 77 | */ |
| 78 | int gsw_hwpin_soc_wakeup_mcu_gpio_set_low(void); |
| 79 | |
| 80 | /** |
| 81 | * @brief get usb is connected or not |
| 82 | * @param |
| 83 | * @retval 1: connected |
| 84 | * @retval 0: disconnected |
| 85 | * @retval other: failed |
| 86 | */ |
| 87 | int gsw_hwpin_is_usb_connected(void); |
| 88 | |
| 89 | /** |
| 90 | * @brief set red led ON |
| 91 | * @param |
| 92 | * @retval 0: success |
| 93 | * @retval other: fail |
| 94 | */ |
| 95 | int gsw_hwpin_led_red_on(void); |
| 96 | |
| 97 | /** |
| 98 | * @brief set red led OFF |
| 99 | * @param |
| 100 | * @retval 0: success |
| 101 | * @retval other: fail |
| 102 | */ |
| 103 | int gsw_hwpin_led_red_off(void); |
| 104 | |
| 105 | /** |
| 106 | * @brief set red led blink |
| 107 | * @param [in] delay_on: on time ms |
| 108 | * @param [in] delay_off: off time ms |
| 109 | * @retval 0: success |
| 110 | * @retval other: fail |
| 111 | */ |
| 112 | int gsw_hwpin_led_red_blink(int delay_on, int delay_off); |
| 113 | |
| 114 | /** |
| 115 | * @brief set green led ON |
| 116 | * @param |
| 117 | * @retval 0: success |
| 118 | * @retval other: fail |
| 119 | */ |
| 120 | int gsw_hwpin_led_green_on(void); |
| 121 | |
| 122 | /** |
| 123 | * @brief set green led OFF |
| 124 | * @param |
| 125 | * @retval 0: success |
| 126 | * @retval other: fail |
| 127 | */ |
| 128 | int gsw_hwpin_led_green_off(void); |
| 129 | |
| 130 | /** |
| 131 | * @brief set green led blink |
| 132 | * @param [in] delay_on: on time ms |
| 133 | * @param [in] delay_off: off time ms |
| 134 | * @retval 0: success |
| 135 | * @retval other: fail |
| 136 | */ |
| 137 | int gsw_hwpin_led_green_blink(int delay_on, int delay_off); |
| 138 | |
| 139 | /** |
| 140 | * @brief Get health status of EMMC. |
| 141 | * @param [out] written_mbytes: Mega-Bytes have been written. |
| 142 | * @param [out] health: value of EMMC health. |
| 143 | * @retval 0: success |
| 144 | * @retval other: fail |
| 145 | */ |
| 146 | int gsw_hwpin_get_emmc_health(int* written_mbytes, int* health); |
| 147 | |
| 148 | /** |
| 149 | * @brief Get readonly status of EMMC. |
| 150 | * @param |
| 151 | * @retval true: readonly happened; false: normal |
| 152 | * @retval other: fail |
| 153 | */ |
| 154 | bool gsw_hwpin_check_emmc_readonly(void); |
| 155 | |
| 156 | /** |
| 157 | * @brief factory test control led |
| 158 | * @param [in] aging_flag: ture/false |
| 159 | * @param [in] delay_on: on time ms |
| 160 | * @param [in] delay_off: off time ms |
| 161 | * @retval 0: success |
| 162 | * @retval other: fail |
| 163 | */ |
| 164 | int gsw_hwpin_factorytest_ctrl_led(bool aging_flag, int delay_on, int delay_off); |
| 165 | |
| 166 | /** |
| 167 | * @brief MUTE test. |
| 168 | * @param [in] value: TRUE or FALSE. |
| 169 | * @retval 0: success |
| 170 | * @retval other: fail |
| 171 | */ |
| 172 | int gsw_hwpin_mute_test(int value); |
| 173 | |
| 174 | /** |
| 175 | * @brief fstrim emmc. |
| 176 | * @param [in] emmc_path: example "/media" |
hong.liu | d241707 | 2025-06-27 07:10:37 -0700 | [diff] [blame] | 177 | * @retval 0: no need fstrim, 1: need fstrim(Currently only AN758 is required) |
hong.liu | cd37079 | 2025-05-28 06:29:19 -0700 | [diff] [blame] | 178 | * @retval other: fail |
| 179 | */ |
| 180 | |
| 181 | int gsw_hwpin_fstrim_emmc(const char *emmc_path); |
| 182 | |
hong.liu | cd37079 | 2025-05-28 06:29:19 -0700 | [diff] [blame] | 183 | #endif |