cpuidle-at91.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * based on arch/arm/mach-kirkwood/cpuidle.c
  3. *
  4. * CPU idle support for AT91 SoC
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. *
  10. * The cpu idle uses wait-for-interrupt and RAM self refresh in order
  11. * to implement two idle states -
  12. * #1 wait-for-interrupt
  13. * #2 wait-for-interrupt and RAM self refresh
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/cpuidle.h>
  19. #include <linux/io.h>
  20. #include <linux/export.h>
  21. #include <asm/proc-fns.h>
  22. #include <asm/cpuidle.h>
  23. #define AT91_MAX_STATES 2
  24. static void (*at91_standby)(void);
  25. /* Actual code that puts the SoC in different idle states */
  26. static int at91_enter_idle(struct cpuidle_device *dev,
  27. struct cpuidle_driver *drv,
  28. int index)
  29. {
  30. at91_standby();
  31. return index;
  32. }
  33. static struct cpuidle_driver at91_idle_driver = {
  34. .name = "at91_idle",
  35. .owner = THIS_MODULE,
  36. .states[0] = ARM_CPUIDLE_WFI_STATE,
  37. .states[1] = {
  38. .enter = at91_enter_idle,
  39. .exit_latency = 10,
  40. .target_residency = 10000,
  41. .flags = CPUIDLE_FLAG_TIME_VALID,
  42. .name = "RAM_SR",
  43. .desc = "WFI and DDR Self Refresh",
  44. },
  45. .state_count = AT91_MAX_STATES,
  46. };
  47. /* Initialize CPU idle by registering the idle states */
  48. static int at91_cpuidle_probe(struct platform_device *dev)
  49. {
  50. at91_standby = (void *)(dev->dev.platform_data);
  51. return cpuidle_register(&at91_idle_driver, NULL);
  52. }
  53. static struct platform_driver at91_cpuidle_driver = {
  54. .driver = {
  55. .name = "cpuidle-at91",
  56. .owner = THIS_MODULE,
  57. },
  58. .probe = at91_cpuidle_probe,
  59. };
  60. module_platform_driver(at91_cpuidle_driver);