static int dbx500_cpuidle_probe(struct platform_device *pdev) { /* Configure wake up reasons */ prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) | PRCMU_WAKEUP(ABB)); return cpuidle_register(&ux500_idle_driver, NULL); }
static __init int ux500_suspend_init(void) { suspend_wakeups = PRCMU_WAKEUP(ABB) | PRCMU_WAKEUP(RTC); running_wakeups = (PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) | PRCMU_WAKEUP(ABB)); ux500_suspend_dbg_init(); prcmu_qos_add_requirement(PRCMU_QOS_ARM_KHZ, "suspend", PRCMU_QOS_DEFAULT_VALUE); suspend_set_ops(&ux500_suspend_ops); return 0; }
static int suspend(bool do_deepsleep) { bool pins_force = pins_suspend_force_mux && pins_suspend_force; int ret = 0; if (sleep_is_blocked()) { pr_info("suspend/resume: interrupted by modem(%d) or event(%d)\n", atomic_read(&block_sleep_modem), atomic_read(&block_sleep_event)); return -EBUSY; } if (has_wake_lock(WAKE_LOCK_SUSPEND)) { pr_info("suspend/resume: wakelock has been locked!\n"); return -EBUSY; } nmk_gpio_clocks_enable(); ux500_suspend_dbg_add_wake_on_uart(); nmk_gpio_wakeups_suspend(); /* configure the prcm for a sleep wakeup */ prcmu_enable_wakeups(PRCMU_WAKEUP(ABB) | PRCMU_WAKEUP(RTC)); ux500_rtcrtt_next_seconds(alarm_sec); context_vape_save(); if (pins_force) { /* * Save GPIO settings before applying power save * settings */ context_gpio_save(); /* Apply GPIO power save mux settings */ context_gpio_mux_safe_switch(true); pins_suspend_force_mux(); context_gpio_mux_safe_switch(false); /* Apply GPIO power save settings */ pins_suspend_force(); } ux500_pm_gic_decouple(); if (ux500_pm_gic_pending_interrupt()) { pr_info("suspend/resume: pending interrupt\n"); /* Recouple GIC with the interrupt bus */ ux500_pm_gic_recouple(); ret = -EBUSY; goto exit; } ux500_pm_prcmu_set_ioforce(true); if (do_deepsleep) { context_varm_save_common(); context_varm_save_core(); context_gic_dist_disable_unneeded_irqs(); context_save_cpu_registers(); /* * Due to we have only 100us between requesting a powerstate * and wfi, we clean the cache before as well to assure the * final cache clean before wfi has as little as possible to * do. */ context_clean_l1_cache_all(); (void) prcmu_set_power_state(PRCMU_AP_DEEP_SLEEP, false, false); context_save_to_sram_and_wfi(true); context_restore_cpu_registers(); context_varm_restore_core(); context_varm_restore_common(); } else { context_clean_l1_cache_all(); (void) prcmu_set_power_state(APEXECUTE_TO_APSLEEP, false, false); dsb(); __asm__ __volatile__("wfi\n\t" : : : "memory"); } context_vape_restore(); /* If GPIO woke us up then save the pins that caused the wake up */ ux500_pm_gpio_save_wake_up_status(); ux500_suspend_dbg_sleep_status(do_deepsleep); /* APE was turned off, restore IO ring */ ux500_pm_prcmu_set_ioforce(false); exit: if (pins_force) { /* Restore gpio settings */ context_gpio_mux_safe_switch(true); context_gpio_restore_mux(); context_gpio_mux_safe_switch(false); context_gpio_restore(); } ux500_rtcrtt_off(); /* This is what cpuidle wants */ prcmu_enable_wakeups(PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) | PRCMU_WAKEUP(ABB)); nmk_gpio_wakeups_resume(); ux500_suspend_dbg_remove_wake_on_uart(); nmk_gpio_clocks_disable(); return ret; }
.exit_latency = DEEP_SLEEP_WAKE_UP_LATENCY + 420, .threshold = DEEP_SLEEP_WAKE_UP_LATENCY + 410 + 420, .power_usage = 1, .APE = APE_OFF, .ARM = ARM_OFF, .UL_PLL = UL_PLL_OFF, .ESRAM = ESRAM_RET, .pwrst = PRCMU_AP_DEEP_SLEEP, .flags = CPUIDLE_FLAG_TIME_VALID, .state = CI_DEEP_SLEEP, .desc = "ApDeepsleep, UL PLL off", }, }; static struct dbx500_cpuidle_platform_data db8500_cpuidle_platform_data= { .wakeups = PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) | PRCMU_WAKEUP(ABB), .cstates = cpuidle_cstates, .cstates_len = ARRAY_SIZE(cpuidle_cstates), .min_sleep_wake_up_latency = MIN_SLEEP_WAKE_UP_LATENCY, .ul_pll_start_up_latency = UL_PLL_START_UP_LATENCY, .prcmu_interrupt = IRQ_DB8500_PRCMU1, }; struct platform_device db8500_cpuidle_device = { .name = "dbx500-cpuidle", .id = -1, .dev = { .platform_data = &db8500_cpuidle_platform_data, }, };