1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * Copyright (C) 2014 Freescale Semiconductor, Inc. 4 */ 5 6 #include <linux/cpuidle.h> 7 #include <linux/module.h> 8 #include <asm/cpuidle.h> 9 10 #include "common.h" 11 #include "cpuidle.h" 12 13 static int imx6sl_enter_wait(struct cpuidle_device *dev, 14 struct cpuidle_driver *drv, int index) 15 { 16 imx6_set_lpm(WAIT_UNCLOCKED); 17 /* 18 * Software workaround for ERR005311, see function 19 * description for details. 20 */ 21 imx6sl_set_wait_clk(true); 22 cpu_do_idle(); 23 imx6sl_set_wait_clk(false); 24 imx6_set_lpm(WAIT_CLOCKED); 25 26 return index; 27 } 28 29 static 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, 39 .flags = CPUIDLE_FLAG_TIMER_STOP, 40 .enter = imx6sl_enter_wait, 41 .name = "WAIT", 42 .desc = "Clock off", 43 }, 44 }, 45 .state_count = 2, 46 .safe_state_index = 0, 47 }; 48 49 int __init imx6sl_cpuidle_init(void) 50 { 51 return cpuidle_register(&imx6sl_cpuidle_driver, NULL); 52 } 53