blob: 7d92e658455162bcb6ce25d84f6b9894895d3834 [file] [log] [blame]
Anson Huang751f7e92014-01-09 16:03:16 +08001/*
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#include <asm/proc-fns.h>
13
14#include "common.h"
15#include "cpuidle.h"
16
17static int imx6sl_enter_wait(struct cpuidle_device *dev,
18 struct cpuidle_driver *drv, int index)
19{
20 imx6q_set_lpm(WAIT_UNCLOCKED);
21 /*
22 * Software workaround for ERR005311, see function
23 * description for details.
24 */
25 imx6sl_set_wait_clk(true);
26 cpu_do_idle();
27 imx6sl_set_wait_clk(false);
28 imx6q_set_lpm(WAIT_CLOCKED);
29
30 return index;
31}
32
33static struct cpuidle_driver imx6sl_cpuidle_driver = {
34 .name = "imx6sl_cpuidle",
35 .owner = THIS_MODULE,
36 .states = {
37 /* WFI */
38 ARM_CPUIDLE_WFI_STATE,
39 /* WAIT */
40 {
41 .exit_latency = 50,
42 .target_residency = 75,
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +010043 .flags = CPUIDLE_FLAG_TIMER_STOP,
Anson Huang751f7e92014-01-09 16:03:16 +080044 .enter = imx6sl_enter_wait,
45 .name = "WAIT",
46 .desc = "Clock off",
47 },
48 },
49 .state_count = 2,
50 .safe_state_index = 0,
51};
52
53int __init imx6sl_cpuidle_init(void)
54{
55 return cpuidle_register(&imx6sl_cpuidle_driver, NULL);
56}