void pm_debug_set_wakeup_timer() { u32 val = get_sys_cnt(); val = val + 2000; __raw_writel(val, SYSCNT_REG(0) ); __raw_writel(1, SYSCNT_REG(0X8) ); }
void set_ap_system_timer_expires(u32 expires_ms) { u32 val = get_sys_cnt(); val = val + expires_ms; __raw_writel(val, SYSCNT_ALARM); __raw_writel(1, SYSCNT_CTL); }
void time_statisic_begin(void) { core_time = 0; mcu_time = 0; deep_time_successed = 0; deep_time_failed = 0; sleep_time = get_sys_cnt(); hard_irq_reset(); }
static void sprd_read_persistent_clock(struct timespec *ts) { u64 delta; struct timespec *tsp = &persistent_ts; last_persistent_ms = persistent_ms; persistent_ms = get_sys_cnt(); delta = persistent_ms - last_persistent_ms; timespec_add_ns(tsp, delta * NSEC_PER_MSEC); *ts = *tsp; }
u32 wake_source_start(void) { u32 sys_count = get_sys_cnt(); u32 delay = 2 * 100; //emc_earlysuspend_early_suspend(0); sci_glb_set(REG_GLB_GEN0, (1 << 19) | (1 << 27)); __raw_writel(sys_count + delay, SPRD_SYSCNT_BASE); raw_reg_set(SPRD_SYSCNT_BASE + 8, 1 << 0); raw_reg_set(SPRD_INTC0_BASE + 8, 1 << 9); raw_reg_clr(REG_GLB_GEN0, 1 << 19); }
void __sprd_debug_task_log(int cpu, struct task_struct *task) { unsigned i; i = atomic_inc_return(&task_log_idx[cpu]) & (ARRAY_SIZE(psprd_debug_log->task[0]) - 1); psprd_debug_log->task[cpu][i].time = cpu_clock(cpu); #ifdef CP_DEBUG psprd_debug_log->task[cpu][i].sys_cnt = get_sys_cnt(); #endif strcpy(psprd_debug_log->task[cpu][i].comm, task->comm); psprd_debug_log->task[cpu][i].pid = task->pid; }
void __sprd_debug_irq_log(unsigned int irq, void *fn, int en) { int cpu = raw_smp_processor_id(); unsigned i; i = atomic_inc_return(&irq_log_idx[cpu]) & (ARRAY_SIZE(psprd_debug_log->irq[0]) - 1); psprd_debug_log->irq[cpu][i].time = cpu_clock(cpu); #ifdef CP_DEBUG psprd_debug_log->irq[cpu][i].sys_cnt = get_sys_cnt(); #endif psprd_debug_log->irq[cpu][i].irq = irq; psprd_debug_log->irq[cpu][i].fn = (void *)fn; psprd_debug_log->irq[cpu][i].en = en; }
void __sprd_debug_hrtimer_log(struct hrtimer *timer, enum hrtimer_restart (*fn) (struct hrtimer *), int en) { int cpu = raw_smp_processor_id(); unsigned i; i = atomic_inc_return(&hrtimer_log_idx[cpu]) & (ARRAY_SIZE(psprd_debug_log->hrtimers[0]) - 1); psprd_debug_log->hrtimers[cpu][i].time = cpu_clock(cpu); #ifdef CP_DEBUG psprd_debug_log->hrtimers[cpu][i].sys_cnt = get_sys_cnt(); #endif psprd_debug_log->hrtimers[cpu][i].timer = timer; psprd_debug_log->hrtimers[cpu][i].fn = fn; psprd_debug_log->hrtimers[cpu][i].en = en; }
void __sprd_debug_work_log(struct worker *worker, struct work_struct *work, work_func_t f) { int cpu = raw_smp_processor_id(); unsigned i; i = atomic_inc_return(&work_log_idx[cpu]) & (ARRAY_SIZE(psprd_debug_log->work[0]) - 1); psprd_debug_log->work[cpu][i].time = cpu_clock(cpu); #ifdef CP_DEBUG psprd_debug_log->work[cpu][i].sys_cnt = get_sys_cnt(); #endif psprd_debug_log->work[cpu][i].worker = worker; psprd_debug_log->work[cpu][i].work = work; psprd_debug_log->work[cpu][i].f = f; }
int sc8825_enter_lowpower(void) { int status, ret = 0; unsigned long flags, time; unsigned int cpu = smp_processor_id(); #ifdef CONFIG_SPRD_PM_DEBUG __raw_writel(0xfdffbfff, SPRD_INTC0_BASE + 0xc);//intc0 __raw_writel(0x02004000, SPRD_INTC0_BASE + 0x8);//intc0 __raw_writel(0xffffffff, SPRD_INTC0_BASE + 0x100c);//intc1 #endif time = get_sys_cnt(); if (!hw_irqs_disabled()) { flags = read_cpsr(); printk("##: Error(%s): IRQ is enabled(%08lx)!\n", "wakelock_suspend", flags); } /*TODO: * we need to known clock status in modem side */ #ifdef FORCE_DISABLE_DSP status = 0; #else #ifdef CONFIG_NKERNEL status = sc8825_get_clock_status(); #else /* * TODO: get clock status in native version, force deep sleep now */ status = 0; #endif #endif if (status & DEVICE_AHB) { /*printk("###### %s, DEVICE_AHB ###\n", __func__ );*/ set_sleep_mode(SLP_MODE_ARM); arm_sleep(); } else if (status & DEVICE_APB) { /*printk("###### %s, DEVICE_APB ###\n", __func__ );*/ set_sleep_mode(SLP_MODE_MCU); mcu_sleep(); } else { /*printk("###### %s, DEEP ###\n", __func__ );*/ set_sleep_mode(SLP_MODE_DEP); gic_save_context( ); scu_save_context(); ret = deep_sleep( ); scu_restore_context(); flush_cache_all(); gic_restore_context( ); gic_cpu_enable(cpu); gic_dist_enable( ); #if 1 void notrace __update_sched_clock(void); __update_sched_clock(); #endif } time_add(get_sys_cnt() - time, ret); return ret; }
void time_statisic_end(void) { sleep_time = get_sys_cnt() - sleep_time; }
static int sprd_pm_deepsleep(suspend_state_t state) { int ret_val = 0; unsigned long flags; u32 battery_time, cur_time; battery_time = cur_time = get_sys_cnt(); unsigned int cpu = smp_processor_id(); /* add for debug & statisic*/ clr_sleep_mode(); time_statisic_begin(); #if defined(CONFIG_NKERNEL) && !defined(CONFIG_NKERNEL_PM_MASTER) hw_local_irq_disable(); os_ctx->suspend_to_memory(os_ctx); hw_local_irq_enable(); #else /* * when we get here, only boot cpu still alive */ if (smp_processor_id()) { __WARN(); goto enter_exit; } while(1) { hw_local_irq_disable(); local_fiq_disable(); local_irq_save(flags); if (arch_local_irq_pending()) { /* add for debug & statisic*/ irq_wakeup_set(); local_irq_restore(flags); hw_local_irq_enable(); local_fiq_enable(); break; } else { local_irq_restore(flags); WARN_ONCE(!irqs_disabled(), "#####: Interrupts enabled in pm_enter()!\n"); #if defined(CONFIG_NKERNEL) /* * return value 0 means that other guest OS are all idle */ ret_val = os_ctx->idle(os_ctx); if (0 == ret_val) { #ifdef CONFIG_NKERNEL_PM_MASTER os_ctx->smp_cpu_stop(0); #endif sprd_cpu_deep_sleep(cpu); #ifdef CONFIG_NKERNEL_PM_MASTER os_ctx->smp_cpu_start(0, 0);/* the 2nd parameter is meaningless*/ #endif } else { printk("******** os_ctx->idle return %d ********\n", ret_val); } #else sprd_cpu_deep_sleep(cpu); #endif hw_local_irq_enable(); local_fiq_enable(); } battery_sleep(); cur_time = get_sys_cnt(); if ((cur_time - battery_time) > BATTERY_CHECK_INTERVAL) { battery_time = cur_time; if (sprd_check_battery()) { printk("###: battery low!\n"); break; } } }/*end while*/ time_statisic_end(); #endif enter_exit: return ret_val; }