1 /* 2 * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved. 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 */ 15 #ifndef __HAL_BOOTMODE_H__ 16 #define __HAL_BOOTMODE_H__ 17 18 #ifdef __cplusplus 19 extern "C" { 20 #endif 21 22 #include "stdint.h" 23 24 #define HAL_HW_BOOTMODE_MASK (0xF << 0) 25 #define HAL_SW_BOOTMODE_MASK (0x0FFFFFFF << 4) 26 27 // SW_BOOTMODE_START (1 << 4) 28 #define HAL_SW_BOOTMODE_READ_ENABLED (1 << 4) 29 #define HAL_SW_BOOTMODE_WRITE_ENABLED (1 << 5) 30 #define HAL_SW_BOOTMODE_JTAG_ENABLED (1 << 6) 31 #define HAL_SW_BOOTMODE_FORCE_USB_DLD (1 << 7) 32 #define HAL_SW_BOOTMODE_FORCE_UART_DLD (1 << 8) 33 #define HAL_SW_BOOTMODE_DLD_TRANS_UART (1 << 9) 34 #define HAL_SW_BOOTMODE_SKIP_FLASH_BOOT (1 << 10) 35 #define HAL_SW_BOOTMODE_CHIP_TEST (1 << 11) 36 #define HAL_SW_BOOTMODE_FACTORY (1 << 12) 37 #define HAL_SW_BOOTMODE_CALIB (1 << 13) 38 #define HAL_SW_BOOTMODE_RAM_BOOT (1 << 14) 39 #define HAL_SW_BOOTMODE_FLASH_BOOT (1 << 15) 40 #define HAL_SW_BOOTMODE_REBOOT (1 << 16) 41 #define HAL_SW_BOOTMODE_ROM_RESERVED_17 (1 << 17) 42 #define HAL_SW_BOOTMODE_FORCE_USB_PLUG_IN (1 << 18) 43 #define HAL_SW_BOOTMODE_POWER_DOWN_WAKEUP (1 << 19) 44 45 // APP_BOOTMODE_START (1 << 20) 46 // Add new application bootmodes here (from highest bit to lowest bit) 47 48 #define HAL_SW_BOOTMODE_TEST_MASK (7 << 20) 49 #define HAL_SW_BOOTMODE_TEST_MODE (1 << 20) 50 #define HAL_SW_BOOTMODE_TEST_SIGNALINGMODE (1 << 21) 51 #define HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE (1 << 22) 52 /* For A7 reboot */ 53 #define HAL_SW_BOOTMODE_A7_REBOOT (1 << 21) 54 55 #define HAL_SW_BOOTMODE_ENTER_HIDE_BOOT (1 << 23) 56 57 #define HAL_SW_BOOTMODE_CUSTOM_OP1_AFTER_REBOOT (1 << 24) 58 #define HAL_SW_BOOTMODE_REBOOT_FROM_CRASH (1 << 25) 59 60 #define HAL_SW_BOOTMODE_SINGLE_LINE_DOWNLOAD (1 << 26) 61 62 #define HAL_SW_BOOTMODE_CUSTOM_OP2_AFTER_REBOOT (1 << 27) 63 64 #ifdef __USB_COMM__ 65 #define HAL_SW_BOOTMODE_CDC_COMM (1 << 28) 66 #else 67 #define HAL_SW_BOOTMODE_TEST_NORMAL_MODE (1 << 28) 68 #endif 69 70 #ifdef ANC_APP 71 #define HAL_SW_BOOTMODE_REBOOT_BT_ON (1 << 29) 72 #define HAL_SW_BOOTMODE_REBOOT_ANC_ON (1 << 30) 73 #endif 74 75 #define HAL_SW_BOOTMODE_BURNIN_MODE (1 << 29) 76 #define HAL_SW_BOOTMODE_TEST_NOSIGNALINGMODE_WIFI (1 << 30) 77 #define HAL_SW_BOOTMODE_WARM_BOOT (1 << 31) 78 79 // APP_BOOTMODE_END (1 << 31) 80 // SW_BOOTMODE_END (1 << 31) 81 82 union HAL_HW_BOOTMODE_T { 83 struct { 84 uint8_t watchdog : 1; 85 uint8_t global : 1; 86 uint8_t rtc : 1; 87 uint8_t charger : 1; 88 }; 89 uint8_t reg; 90 }; 91 92 union HAL_HW_BOOTMODE_T hal_rom_hw_bootmode_get(void); 93 94 union HAL_HW_BOOTMODE_T hal_hw_bootmode_get(void); 95 96 void hal_hw_bootmode_init(void); 97 98 uint32_t hal_sw_bootmode_get(void); 99 100 void hal_sw_bootmode_set(uint32_t bm); 101 102 void hal_sw_bootmode_clear(uint32_t bm); 103 104 #ifdef __cplusplus 105 } 106 #endif 107 108 #endif 109 110