0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
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
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
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);