Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  * Copyright (C) 2016 Freescale Semiconductor, Inc.
0004  * Copyright 2017-2018 NXP
0005  *   Anson Huang <Anson.Huang@nxp.com>
0006  */
0007 
0008 #include <linux/cpuidle.h>
0009 #include <linux/module.h>
0010 #include <asm/cpuidle.h>
0011 
0012 #include "common.h"
0013 #include "cpuidle.h"
0014 
0015 static int imx7ulp_enter_wait(struct cpuidle_device *dev,
0016                 struct cpuidle_driver *drv, int index)
0017 {
0018     if (index == 1)
0019         imx7ulp_set_lpm(ULP_PM_WAIT);
0020     else
0021         imx7ulp_set_lpm(ULP_PM_STOP);
0022 
0023     cpu_do_idle();
0024 
0025     imx7ulp_set_lpm(ULP_PM_RUN);
0026 
0027     return index;
0028 }
0029 
0030 static struct cpuidle_driver imx7ulp_cpuidle_driver = {
0031     .name = "imx7ulp_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             .enter = imx7ulp_enter_wait,
0041             .name = "WAIT",
0042             .desc = "PSTOP2",
0043         },
0044         /* STOP */
0045         {
0046             .exit_latency = 100,
0047             .target_residency = 150,
0048             .enter = imx7ulp_enter_wait,
0049             .name = "STOP",
0050             .desc = "PSTOP1",
0051         },
0052     },
0053     .state_count = 3,
0054     .safe_state_index = 0,
0055 };
0056 
0057 int __init imx7ulp_cpuidle_init(void)
0058 {
0059     return cpuidle_register(&imx7ulp_cpuidle_driver, NULL);
0060 }