2 * Copyright (C) 2012 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/module.h>
11 #include <asm/cpuidle.h>
17 static int num_idle_cpus = 0;
18 static DEFINE_SPINLOCK(cpuidle_lock);
20 static int imx6q_enter_wait(struct cpuidle_device *dev,
21 struct cpuidle_driver *drv, int index)
23 spin_lock(&cpuidle_lock);
24 if (++num_idle_cpus == num_online_cpus())
25 imx6_set_lpm(WAIT_UNCLOCKED);
26 spin_unlock(&cpuidle_lock);
30 spin_lock(&cpuidle_lock);
31 if (num_idle_cpus-- == num_online_cpus())
32 imx6_set_lpm(WAIT_CLOCKED);
33 spin_unlock(&cpuidle_lock);
38 static struct cpuidle_driver imx6q_cpuidle_driver = {
39 .name = "imx6q_cpuidle",
43 ARM_CPUIDLE_WFI_STATE,
47 .target_residency = 75,
48 .flags = CPUIDLE_FLAG_TIMER_STOP,
49 .enter = imx6q_enter_wait,
55 .safe_state_index = 0,
58 int __init imx6q_cpuidle_init(void)
60 /* Set INT_MEM_CLK_LPM bit to get a reliable WAIT mode support */
61 imx6q_set_int_mem_clk_lpm(true);
63 return cpuidle_register(&imx6q_cpuidle_driver, NULL);