Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * based on arch/arm/mach-kirkwood/cpuidle.c
0004  *
0005  * CPU idle support for AT91 SoC
0006  *
0007  * The cpu idle uses wait-for-interrupt and RAM self refresh in order
0008  * to implement two idle states -
0009  * #1 wait-for-interrupt
0010  * #2 wait-for-interrupt and RAM self refresh
0011  */
0012 
0013 #include <linux/kernel.h>
0014 #include <linux/init.h>
0015 #include <linux/platform_device.h>
0016 #include <linux/cpuidle.h>
0017 #include <linux/io.h>
0018 #include <linux/export.h>
0019 #include <asm/cpuidle.h>
0020 
0021 #define AT91_MAX_STATES 2
0022 
0023 static void (*at91_standby)(void);
0024 
0025 /* Actual code that puts the SoC in different idle states */
0026 static int at91_enter_idle(struct cpuidle_device *dev,
0027             struct cpuidle_driver *drv,
0028                    int index)
0029 {
0030     at91_standby();
0031     return index;
0032 }
0033 
0034 static struct cpuidle_driver at91_idle_driver = {
0035     .name           = "at91_idle",
0036     .owner          = THIS_MODULE,
0037     .states[0]      = ARM_CPUIDLE_WFI_STATE,
0038     .states[1]      = {
0039         .enter          = at91_enter_idle,
0040         .exit_latency       = 10,
0041         .target_residency   = 10000,
0042         .name           = "RAM_SR",
0043         .desc           = "WFI and DDR Self Refresh",
0044     },
0045     .state_count = AT91_MAX_STATES,
0046 };
0047 
0048 /* Initialize CPU idle by registering the idle states */
0049 static int at91_cpuidle_probe(struct platform_device *dev)
0050 {
0051     at91_standby = (void *)(dev->dev.platform_data);
0052     
0053     return cpuidle_register(&at91_idle_driver, NULL);
0054 }
0055 
0056 static struct platform_driver at91_cpuidle_driver = {
0057     .driver = {
0058         .name = "cpuidle-at91",
0059     },
0060     .probe = at91_cpuidle_probe,
0061 };
0062 builtin_platform_driver(at91_cpuidle_driver);