blob: 4521e5352bf64825043254da51664e1d8970351e [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Anson Huang751f7e92014-01-09 16:03:16 +08002/*
3 * Copyright (C) 2014 Freescale Semiconductor, Inc.
Anson Huang751f7e92014-01-09 16:03:16 +08004 */
5
6#include <linux/cpuidle.h>
7#include <linux/module.h>
8#include <asm/cpuidle.h>
Anson Huang751f7e92014-01-09 16:03:16 +08009
10#include "common.h"
11#include "cpuidle.h"
12
13static int imx6sl_enter_wait(struct cpuidle_device *dev,
14 struct cpuidle_driver *drv, int index)
15{
Shawn Guo8fb76a02015-04-25 22:59:19 +080016 imx6_set_lpm(WAIT_UNCLOCKED);
Anson Huang751f7e92014-01-09 16:03:16 +080017 /*
18 * Software workaround for ERR005311, see function
19 * description for details.
20 */
Anson Huang83ef5da2018-06-03 10:33:46 +080021 imx6sl_set_wait_clk(true);
Anson Huang751f7e92014-01-09 16:03:16 +080022 cpu_do_idle();
Anson Huang83ef5da2018-06-03 10:33:46 +080023 imx6sl_set_wait_clk(false);
Shawn Guo8fb76a02015-04-25 22:59:19 +080024 imx6_set_lpm(WAIT_CLOCKED);
Anson Huang751f7e92014-01-09 16:03:16 +080025
26 return index;
27}
28
29static struct cpuidle_driver imx6sl_cpuidle_driver = {
30 .name = "imx6sl_cpuidle",
31 .owner = THIS_MODULE,
32 .states = {
33 /* WFI */
34 ARM_CPUIDLE_WFI_STATE,
35 /* WAIT */
36 {
37 .exit_latency = 50,
38 .target_residency = 75,
Daniel Lezcanob82b6cc2014-11-12 16:03:50 +010039 .flags = CPUIDLE_FLAG_TIMER_STOP,
Anson Huang751f7e92014-01-09 16:03:16 +080040 .enter = imx6sl_enter_wait,
41 .name = "WAIT",
42 .desc = "Clock off",
43 },
44 },
45 .state_count = 2,
46 .safe_state_index = 0,
47};
48
49int __init imx6sl_cpuidle_init(void)
50{
51 return cpuidle_register(&imx6sl_cpuidle_driver, NULL);
52}