blk: rq_data_dir() should not return a boolean
[cris-mirror.git] / arch / arm / mach-imx / cpuidle-imx6q.c
blob353bb8774112d8068a072d0afe8f8f32a61683ae
1 /*
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.
7 */
9 #include <linux/cpuidle.h>
10 #include <linux/module.h>
11 #include <asm/cpuidle.h>
13 #include "common.h"
14 #include "cpuidle.h"
15 #include "hardware.h"
17 static atomic_t master = ATOMIC_INIT(0);
18 static DEFINE_SPINLOCK(master_lock);
20 static int imx6q_enter_wait(struct cpuidle_device *dev,
21 struct cpuidle_driver *drv, int index)
23 if (atomic_inc_return(&master) == num_online_cpus()) {
25 * With this lock, we prevent other cpu to exit and enter
26 * this function again and become the master.
28 if (!spin_trylock(&master_lock))
29 goto idle;
30 imx6_set_lpm(WAIT_UNCLOCKED);
31 cpu_do_idle();
32 imx6_set_lpm(WAIT_CLOCKED);
33 spin_unlock(&master_lock);
34 goto done;
37 idle:
38 cpu_do_idle();
39 done:
40 atomic_dec(&master);
42 return index;
45 static struct cpuidle_driver imx6q_cpuidle_driver = {
46 .name = "imx6q_cpuidle",
47 .owner = THIS_MODULE,
48 .states = {
49 /* WFI */
50 ARM_CPUIDLE_WFI_STATE,
51 /* WAIT */
53 .exit_latency = 50,
54 .target_residency = 75,
55 .flags = CPUIDLE_FLAG_TIMER_STOP,
56 .enter = imx6q_enter_wait,
57 .name = "WAIT",
58 .desc = "Clock off",
61 .state_count = 2,
62 .safe_state_index = 0,
65 int __init imx6q_cpuidle_init(void)
67 /* Set INT_MEM_CLK_LPM bit to get a reliable WAIT mode support */
68 imx6q_set_int_mem_clk_lpm(true);
70 return cpuidle_register(&imx6q_cpuidle_driver, NULL);