Merge branch 'for-4.19/fixes' into for-linus
[linux-2.6-block.git] / arch / arm / mach-imx / cpuidle-imx6sl.c
1 /*
2  * Copyright (C) 2014 Freescale Semiconductor, Inc.
3  *
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  */
8
9 #include <linux/cpuidle.h>
10 #include <linux/module.h>
11 #include <asm/cpuidle.h>
12
13 #include "common.h"
14 #include "cpuidle.h"
15 #include "hardware.h"
16
17 static int imx6sl_enter_wait(struct cpuidle_device *dev,
18                             struct cpuidle_driver *drv, int index)
19 {
20         imx6_set_lpm(WAIT_UNCLOCKED);
21         /*
22          * Software workaround for ERR005311, see function
23          * description for details.
24          */
25         if (cpu_is_imx6sl())
26                 imx6sl_set_wait_clk(true);
27         cpu_do_idle();
28         if (cpu_is_imx6sl())
29                 imx6sl_set_wait_clk(false);
30         imx6_set_lpm(WAIT_CLOCKED);
31
32         return index;
33 }
34
35 static struct cpuidle_driver imx6sl_cpuidle_driver = {
36         .name = "imx6sl_cpuidle",
37         .owner = THIS_MODULE,
38         .states = {
39                 /* WFI */
40                 ARM_CPUIDLE_WFI_STATE,
41                 /* WAIT */
42                 {
43                         .exit_latency = 50,
44                         .target_residency = 75,
45                         .flags = CPUIDLE_FLAG_TIMER_STOP,
46                         .enter = imx6sl_enter_wait,
47                         .name = "WAIT",
48                         .desc = "Clock off",
49                 },
50         },
51         .state_count = 2,
52         .safe_state_index = 0,
53 };
54
55 int __init imx6sl_cpuidle_init(void)
56 {
57         return cpuidle_register(&imx6sl_cpuidle_driver, NULL);
58 }