2 * Copyright (C) 2014 Freescale Semiconductor, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
9 #include <linux/cpuidle.h>
10 #include <linux/cpu_pm.h>
11 #include <linux/module.h>
12 #include <asm/cpuidle.h>
13 #include <asm/suspend.h>
19 static int imx6sx_idle_finish(unsigned long val)
26 static int imx6sx_enter_wait(struct cpuidle_device *dev,
27 struct cpuidle_driver *drv, int index)
29 imx6_set_lpm(WAIT_UNCLOCKED);
36 imx6_enable_rbc(true);
37 imx_gpc_set_arm_power_in_lpm(true);
38 imx_set_cpu_jump(0, v7_cpu_resume);
39 /* Need to notify there is a cpu pm operation. */
41 cpu_cluster_pm_enter();
43 cpu_suspend(0, imx6sx_idle_finish);
45 cpu_cluster_pm_exit();
47 imx_gpc_set_arm_power_in_lpm(false);
48 imx6_enable_rbc(false);
54 imx6_set_lpm(WAIT_CLOCKED);
59 static struct cpuidle_driver imx6sx_cpuidle_driver = {
60 .name = "imx6sx_cpuidle",
64 ARM_CPUIDLE_WFI_STATE,
68 .target_residency = 75,
69 .flags = CPUIDLE_FLAG_TIMER_STOP,
70 .enter = imx6sx_enter_wait,
74 /* WAIT + ARM power off */
77 * ARM gating 31us * 5 + RBC clear 65us
78 * and some margin for SW execution, here set it
82 .target_residency = 500,
83 .enter = imx6sx_enter_wait,
84 .name = "LOW-POWER-IDLE",
85 .desc = "ARM power off",
89 .safe_state_index = 0,
92 int __init imx6sx_cpuidle_init(void)
94 imx6_enable_rbc(false);
96 * set ARM power up/down timing to the fastest,
97 * sw2iso and sw can be set to one 32K cycle = 31us
98 * except for power up sw2iso which need to be
99 * larger than LDO ramp up time.
101 imx_gpc_set_arm_power_up_timing(cpu_is_imx6sx() ? 0xf : 0x2, 1);
102 imx_gpc_set_arm_power_down_timing(1, 1);
104 return cpuidle_register(&imx6sx_cpuidle_driver, NULL);