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>
10 #include <linux/gpio.h>
12 extern int hw_watchdog_rst_pending(void);
13 unsigned check_reboot_mode(void)
17 rst_mode = ANA_REG_GET(ANA_HWRST_STATUS);
18 rst_mode &= HWRST_STATUS_POWERON_MASK;
19 ANA_REG_SET(ANA_HWRST_STATUS, 0); //clear flag
21 if(hw_watchdog_rst_pending()){
22 printf("hw watchdog rst int pending\n");
23 if(rst_mode == HWRST_STATUS_RECOVERY)
25 else if(rst_mode == HWRST_STATUS_FASTBOOT)
27 else if(rst_mode == HWRST_STATUS_NORMAL)
29 else if(rst_mode == HWRST_STATUS_NORMAL2)
30 return WATCHDOG_REBOOT;
31 else if(rst_mode == HWRST_STATUS_ALARM)
33 else if(rst_mode == HWRST_STATUS_SLEEP)
35 else if(rst_mode == HWRST_STATUS_SPECIAL)
37 else if(rst_mode == HWRST_STATUS_PANIC)
40 printf(" a boot mode not supported\n");
44 printf("no hw watchdog rst int pending\n");
45 if(rst_mode == HWRST_STATUS_NORMAL2)
46 return UNKNOW_REBOOT_MODE;
52 void reboot_devices(unsigned reboot_mode)
54 unsigned rst_mode = 0;
55 if(reboot_mode == RECOVERY_MODE){
56 rst_mode = HWRST_STATUS_RECOVERY;
58 else if(reboot_mode == FASTBOOT_MODE){
59 rst_mode = HWRST_STATUS_FASTBOOT;
60 }else if(reboot_mode == NORMAL_MODE){
61 rst_mode = HWRST_STATUS_NORMAL;
66 ANA_REG_SET(ANA_HWRST_STATUS, rst_mode);
69 asm volatile("ldr r1,=0x20900218"); //remap ROM to 0x0000_0000
70 asm volatile("ldr r2,=1");
71 asm volatile("str r2,[r1]");
72 asm volatile("mov pc,#0");
75 void power_down_devices(unsigned pd_cmd)
80 int power_button_pressed(void)
83 static int init_done = 0;
85 gpio_request(EIC_KEY_POWER, "power_key");
86 gpio_direction_input(EIC_KEY_POWER);
89 return ! gpio_get_value_cansleep(EIC_KEY_POWER);
92 ANA_REG_OR(ANA_APB_CLK_EN, BIT_3|BIT_11);
93 ANA_REG_SET(ADI_EIC_MASK, 0xff);
95 int status = ANA_REG_GET(ADI_EIC_DATA);
96 //printf("eica status %x\n", status);
97 #if !(defined (CONFIG_SC8825))
98 return !!(status & (1 << 3)/*PBINT*/);//low level if pb hold
100 return !(status & (1 << 3)/*PBINT*/);
105 int charger_connected(void)
108 static int init_done = 0;
110 gpio_request(EIC_CHARGER_DETECT, "charger_key");
111 gpio_direction_input(EIC_CHARGER_DETECT);
114 return !! gpio_get_value_cansleep(EIC_CHARGER_DETECT);
116 ANA_REG_OR(ANA_APB_CLK_EN, BIT_3|BIT_11);
117 ANA_REG_SET(ADI_EIC_MASK, 0xff);
119 int status = ANA_REG_GET(ADI_EIC_DATA);
120 //printf("charger_connected eica status %x\n", status);
121 return !!(status & (1 << 2));
125 int alarm_triggered(void)
127 printf("ANA_RTC_INT_RSTS is 0x%x\n", ANA_RTC_INT_RSTS);
128 printf("value of it 0x%x\n", ANA_REG_GET(ANA_RTC_INT_RSTS));
129 return ANA_REG_GET(ANA_RTC_INT_RSTS) & BIT_4;