Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2014 Freescale Semiconductor, Inc.
0004  */
0005 
0006 #include <linux/clk/imx.h>
0007 #include <linux/cpuidle.h>
0008 #include <linux/module.h>
0009 #include <asm/cpuidle.h>
0010 
0011 #include "common.h"
0012 #include "cpuidle.h"
0013 
0014 static int imx6sl_enter_wait(struct cpuidle_device *dev,
0015                 struct cpuidle_driver *drv, int index)
0016 {
0017     imx6_set_lpm(WAIT_UNCLOCKED);
0018     /*
0019      * Software workaround for ERR005311, see function
0020      * description for details.
0021      */
0022     imx6sl_set_wait_clk(true);
0023     cpu_do_idle();
0024     imx6sl_set_wait_clk(false);
0025     imx6_set_lpm(WAIT_CLOCKED);
0026 
0027     return index;
0028 }
0029 
0030 static struct cpuidle_driver imx6sl_cpuidle_driver = {
0031     .name = "imx6sl_cpuidle",
0032     .owner = THIS_MODULE,
0033     .states = {
0034         /* WFI */
0035         ARM_CPUIDLE_WFI_STATE,
0036         /* WAIT */
0037         {
0038             .exit_latency = 50,
0039             .target_residency = 75,
0040             .flags = CPUIDLE_FLAG_TIMER_STOP,
0041             .enter = imx6sl_enter_wait,
0042             .name = "WAIT",
0043             .desc = "Clock off",
0044         },
0045     },
0046     .state_count = 2,
0047     .safe_state_index = 0,
0048 };
0049 
0050 int __init imx6sl_cpuidle_init(void)
0051 {
0052     return cpuidle_register(&imx6sl_cpuidle_driver, NULL);
0053 }