1 #include <asm/arch/sci_types.h>
2 #include <asm/arch/sc_reg.h>
3 #include <asm/arch/adi_hal_internal.h>
5 #include <asm/arch/gpio.h>
6 #include <asm/arch/asm_generic_gpio.h>
7 #include <asm/arch/gpio_phy.h>
8 #include <asm/arch/rtc_reg_v3.h>
9 #include <asm/arch/mfp.h>
11 unsigned check_reboot_mode(void)
15 rst_mode = ANA_REG_GET(ANA_HWRST_STATUS);
16 rst_mode &= HWRST_STATUS_POWERON_MASK;
17 ANA_REG_SET(ANA_HWRST_STATUS, 0); //clear flag
18 if(rst_mode == HWRST_STATUS_RECOVERY)
20 else if(rst_mode == HWRST_STATUS_FASTBOOT)
22 else if(rst_mode == HWRST_STATUS_NORMAL)
24 else if(rst_mode == HWRST_STATUS_ALARM)
26 else if(rst_mode == HWRST_STATUS_SLEEP)
32 void reboot_devices(unsigned reboot_mode)
34 unsigned rst_mode = 0;
35 if(reboot_mode == RECOVERY_MODE){
36 rst_mode = HWRST_STATUS_RECOVERY;
38 else if(reboot_mode == FASTBOOT_MODE){
39 rst_mode = HWRST_STATUS_FASTBOOT;
40 }else if(reboot_mode == NORMAL_MODE){
41 rst_mode = HWRST_STATUS_NORMAL;
46 ANA_REG_SET(ANA_HWRST_STATUS, rst_mode);
49 asm volatile("ldr r1,=0x20900218"); //remap ROM to 0x0000_0000
50 asm volatile("ldr r2,=1");
51 asm volatile("str r2,[r1]");
52 asm volatile("mov pc,#0");
55 void power_down_devices(unsigned pd_cmd)
60 int power_button_pressed(void)
62 return sprd_gpio_get(NULL, POWER_BUTTON_GPIO_NUM);
65 int charger_connected(void)
67 return sprd_gpio_get(NULL, CHG_GPIO_NUM);
70 int alarm_triggered(void)
72 //printf("ANA_RTC_INT_RSTS is 0x%x\n", ANA_RTC_INT_RSTS);
73 //printf("value of it 0x%x\n", ANA_REG_GET(ANA_RTC_INT_RSTS));
74 return ANA_REG_GET(ANA_RTC_INT_RSTS) & BIT_4;