USB: serial: option: reimplement interface masking
[linux/fpc-iii.git] / arch / arm / mach-imx / cpuidle-imx6q.c
blobbfeb25aaf9a2a7a48857a3896fb682d7d94568a8
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 <soc/imx/cpuidle.h>
15 #include "common.h"
16 #include "cpuidle.h"
17 #include "hardware.h"
19 static atomic_t master = ATOMIC_INIT(0);
20 static DEFINE_SPINLOCK(master_lock);
22 static int imx6q_enter_wait(struct cpuidle_device *dev,
23 struct cpuidle_driver *drv, int index)
25 if (atomic_inc_return(&master) == num_online_cpus()) {
27 * With this lock, we prevent other cpu to exit and enter
28 * this function again and become the master.
30 if (!spin_trylock(&master_lock))
31 goto idle;
32 imx6_set_lpm(WAIT_UNCLOCKED);
33 cpu_do_idle();
34 imx6_set_lpm(WAIT_CLOCKED);
35 spin_unlock(&master_lock);
36 goto done;
39 idle:
40 cpu_do_idle();
41 done:
42 atomic_dec(&master);
44 return index;
47 static struct cpuidle_driver imx6q_cpuidle_driver = {
48 .name = "imx6q_cpuidle",
49 .owner = THIS_MODULE,
50 .states = {
51 /* WFI */
52 ARM_CPUIDLE_WFI_STATE,
53 /* WAIT */
55 .exit_latency = 50,
56 .target_residency = 75,
57 .flags = CPUIDLE_FLAG_TIMER_STOP,
58 .enter = imx6q_enter_wait,
59 .name = "WAIT",
60 .desc = "Clock off",
63 .state_count = 2,
64 .safe_state_index = 0,
68 * i.MX6 Q/DL has an erratum (ERR006687) that prevents the FEC from waking the
69 * CPUs when they are in wait(unclocked) state. As the hardware workaround isn't
70 * applicable to all boards, disable the deeper idle state when the workaround
71 * isn't present and the FEC is in use.
73 void imx6q_cpuidle_fec_irqs_used(void)
75 imx6q_cpuidle_driver.states[1].disabled = true;
77 EXPORT_SYMBOL_GPL(imx6q_cpuidle_fec_irqs_used);
79 void imx6q_cpuidle_fec_irqs_unused(void)
81 imx6q_cpuidle_driver.states[1].disabled = false;
83 EXPORT_SYMBOL_GPL(imx6q_cpuidle_fec_irqs_unused);
85 int __init imx6q_cpuidle_init(void)
87 /* Set INT_MEM_CLK_LPM bit to get a reliable WAIT mode support */
88 imx6_set_int_mem_clk_lpm(true);
90 return cpuidle_register(&imx6q_cpuidle_driver, NULL);