void bs_set_timestamp(enum bs_entry bs_id) { addr_t bs_imem = get_bs_info_addr(); uint32_t clk_count = 0; if(bs_imem) { if (bs_id >= BS_MAX) { dprintf(CRITICAL, "bad bs id: %u, max: %u\n", bs_id, BS_MAX); ASSERT(0); } if (bs_id == BS_KERNEL_LOAD_START) { kernel_load_start = platform_get_sclk_count(); return; } if(bs_id == BS_KERNEL_LOAD_DONE){ clk_count = platform_get_sclk_count(); if(clk_count){ writel(clk_count - kernel_load_start, bs_imem + (sizeof(uint32_t) * BS_KERNEL_LOAD_TIME)); } } else{ clk_count = platform_get_sclk_count(); if(clk_count){ writel(clk_count, bs_imem + (sizeof(uint32_t) * bs_id)); } } } }
/* * Main timer handle: check every PWRKEY_DETECT_FREQUENCY to see * if power key is pressed. * Shutdown the device if power key is release before * (PWRKEY_LONG_PRESS_COUNT/MPM_SLEEP_TIMETICK_COUNT) seconds. */ static enum handler_return long_press_pwrkey_timer_func(struct timer *p_timer, void *arg) { uint32_t sclk_count = platform_get_sclk_count(); /* * The following condition is treated as the power key * is pressed long enough. * 1. if the power key is pressed last for PWRKEY_LONG_PRESS_COUNT. */ if (sclk_count > PWRKEY_LONG_PRESS_COUNT) { timer_cancel(p_timer); pon_timer_complete = 1; } else { if (pm8x41_get_pwrkey_is_pressed()) { /* * For normal man response is > 0.1 secs, so we use 0.05 secs default * for software to be safely detect if there is a key release action. */ timer_set_oneshot(p_timer, PWRKEY_DETECT_FREQUENCY, long_press_pwrkey_timer_func, NULL); } else { shutdown_device(); } } return INT_RESCHEDULE; }
/* * Function to check if the the power key is pressed long enough. * Return 0 if boot time more than PWRKEY_LONG_PRESS_COUNT. * Return 1 if boot time less than PWRKEY_LONG_PRESS_COUNT. */ static uint32_t is_pwrkey_time_expired() { /* power on button tied in with PMIC KPDPWR. */ uint32_t sclk_count = platform_get_sclk_count(); /* Here check if the long press power-key lasts for 1.5s */ if (sclk_count > PWRKEY_LONG_PRESS_COUNT) return 0; else return 1; }
/* * Function to wait until the power key is pressed long enough */ static void wait_for_long_pwrkey_pressed() { uint32_t sclk_count = 0; while (!pon_timer_complete) { sclk_count = platform_get_sclk_count(); if (sclk_count > PWRKEY_LONG_PRESS_COUNT) { timer_cancel(&pon_timer); break; } } }