static unsigned int detect_key(unsigned int suspend_from) { int exit_reason = 0; unsigned int time_out = readl(AO_DEBUG_REG2); unsigned time_out_ms = time_out*100; unsigned *irq = (unsigned *)SECURE_TASK_SHARE_IRQ; /* unsigned *wakeup_en = (unsigned *)SECURE_TASK_RESPONSE_WAKEUP_EN; */ /* setup wakeup resources*/ /*auto suspend: timerA 10ms resolution*/ if (time_out_ms != 0) wakeup_timer_setup(); init_remote(); #ifdef CONFIG_CEC_WAKEUP if (hdmi_cec_func_config & 0x1) { remote_cec_hw_reset(); cec_node_init(); } #endif /* *wakeup_en = 1;*/ do { switch (*irq) { #ifdef CONFIG_CEC_WAKEUP case IRQ_AO_CEC_NUM: if (suspend_from == SYS_POWEROFF) break; if (cec_msg.log_addr) { if (hdmi_cec_func_config & 0x1) { cec_handler(); if (cec_msg.cec_power == 0x1) { /*cec power key*/ exit_reason = CEC_WAKEUP; break; } } } else if (hdmi_cec_func_config & 0x1) cec_node_init(); break; #endif case IRQ_TIMERA_NUM: if (time_out_ms != 0) time_out_ms--; if (time_out_ms == 0) { wakeup_timer_clear(); exit_reason = AUTO_WAKEUP; } break; case IRQ_AO_IR_DEC_NUM: if (remote_detect_key()) exit_reason = REMOTE_WAKEUP; break; default: break; } *irq = 0xffffffff; if (exit_reason) break; else asm volatile("wfi"); } while (1); return exit_reason; }
unsigned int g9tv_ref_wakeup(unsigned int flags) { int delay_cnt = 0; int power_status = 1; int prev_status; int battery_voltage; int ret = FLAG_WAKEUP_PWRKEY; int low_bat_cnt = 0; #ifdef CONFIG_IR_REMOTE_WAKEUP //backup the remote config (on arm) backup_remote_register(); //set the ir_remote to 32k mode at ARC init_custom_trigger(); #endif #ifdef CONFIG_SARADC_WAKEUP_FOR_ARC saradc_init(); adc_start_sample(0); #endif do { if ((flags == 0x87654321) && (!power_status)) { // suspend from uboot ret = FLAG_WAKEUP_PWROFF; exit_reason = -1; break; } #ifdef CONFIG_IR_REMOTE_WAKEUP if(readl(P_AO_RTI_STATUS_REG2) == 0x4853ffff){ break; } if(remote_detect_key()){ exit_reason = 6; break; } #endif #ifdef CONFIG_SARADC_WAKEUP_FOR_ARC if (is_adc_finished()) { if(1 == adc_detect_key()){ exit_reason = 6; break; } adc_start_sample(0); } #endif if((readl(P_AO_RTC_ADDR1) >> 12) & 0x1) { exit_reason = 7; ret = FLAG_WAKEUP_ALARM; break; } #ifdef CONFIG_BT_WAKEUP if(readl(P_PREG_PAD_GPIO0_I)&(0x1<<16)){ exit_reason = 8; ret = FLAG_WAKEUP_BT; break; } #endif #ifdef CONFIG_WIFI_WAKEUP if ((flags != 0x87654321) &&(readl(P_AO_GPIO_O_EN_N)&(0x1<<22))) if(readl(P_PREG_PAD_GPIO0_I)&(0x1<<21)){ exit_reason = 9; ret = FLAG_WAKEUP_WIFI; break; } #endif } while (!(readl(0xc8100088) & (1<<8))); // power key writel(1<<8,0xc810008c); writel(gpio_sel0, 0xc8100084); writel(gpio_mask,0xc8100080); #ifdef CONFIG_IR_REMOTE_WAKEUP resume_remote_register(); #endif return ret; }
static unsigned int detect_key(unsigned int suspend_from) { int exit_reason = 0; unsigned int time_out = readl(AO_DEBUG_REG2); unsigned time_out_ms = time_out*100; unsigned char adc_key_cnt = 0; unsigned *irq = (unsigned *)WAKEUP_SRC_IRQ_ADDR_BASE; /* unsigned *wakeup_en = (unsigned *)SECURE_TASK_RESPONSE_WAKEUP_EN; */ /* start timer and enable adc*/ reset_ao_timera(); saradc_enable(); /* setup wakeup resources*/ /*auto suspend: timerA 10ms resolution*/ if (time_out_ms != 0) wakeup_timer_setup(); saradc_enable(); reset_ao_timera(); init_remote(); #ifdef CONFIG_CEC_WAKEUP if (hdmi_cec_func_config & 0x1) { remote_cec_hw_reset(); cec_node_init(); } #endif /* *wakeup_en = 1;*/ do { #ifdef CONFIG_CEC_WAKEUP if (irq[IRQ_AO_CEC] == IRQ_AO_CEC_NUM) { irq[IRQ_AO_CEC] = 0xFFFFFFFF; // if (suspend_from == SYS_POWEROFF) // continue; if (cec_msg.log_addr) { if (hdmi_cec_func_config & 0x1) { cec_handler(); if (cec_msg.cec_power == 0x1) { /*cec power key*/ exit_reason = CEC_WAKEUP; break; } } } else if (hdmi_cec_func_config & 0x1) cec_node_init(); } #endif if (irq[IRQ_TIMERA] == IRQ_TIMERA_NUM) { irq[IRQ_TIMERA] = 0xFFFFFFFF; /*uart_puts("timera ...\n");*/ if (time_out_ms != 0) time_out_ms--; if (time_out_ms == 0) { wakeup_timer_clear(); exit_reason = AUTO_WAKEUP; } } if (irq[IRQ_AO_TIMERA] == IRQ_AO_TIMERA_NUM) { irq[IRQ_AO_TIMERA] = 0xFFFFFFFF; if (check_adc_key_resume()) { adc_key_cnt++; /*using variable 'adc_key_cnt' to eliminate the dithering of the key*/ if (2 == adc_key_cnt) exit_reason = POWER_KEY_WAKEUP; } else { adc_key_cnt = 0; } } if (irq[IRQ_AO_IR_DEC] == IRQ_AO_IR_DEC_NUM) { irq[IRQ_AO_IR_DEC] = 0xFFFFFFFF; if (remote_detect_key()) exit_reason = REMOTE_WAKEUP; } if (irq[IRQ_ETH_PHY] == IRQ_ETH_PHY_NUM) { irq[IRQ_ETH_PHY] = 0xFFFFFFFF; exit_reason = ETH_PHY_WAKEUP; } if (exit_reason) break; else asm volatile("wfi"); } while (1); restore_ao_timer(); saradc_disable(); return exit_reason; }