cpuidle-at91.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/cpuidle.h>
  22. #define AT91_MAX_STATES 2
  23. static void (*at91_standby)(void);
  24. /* Actual code that puts the SoC in different idle states */
  25. static int at91_enter_idle(struct cpuidle_device *dev,
  26. struct cpuidle_driver *drv,
  27. int index)
  28. {
  29. at91_standby();
  30. return index;
  31. }
  32. static struct cpuidle_driver at91_idle_driver = {
  33. .name = "at91_idle",
  34. .owner = THIS_MODULE,
  35. .states[0] = ARM_CPUIDLE_WFI_STATE,
  36. .states[1] = {
  37. .enter = at91_enter_idle,
  38. .exit_latency = 10,
  39. .target_residency = 10000,
  40. .name = "RAM_SR",
  41. .desc = "WFI and DDR Self Refresh",
  42. },
  43. .state_count = AT91_MAX_STATES,
  44. };
  45. /* Initialize CPU idle by registering the idle states */
  46. static int at91_cpuidle_probe(struct platform_device *dev)
  47. {
  48. at91_standby = (void *)(dev->dev.platform_data);
  49. return cpuidle_register(&at91_idle_driver, NULL);
  50. }
  51. static struct platform_driver at91_cpuidle_driver = {
  52. .driver = {
  53. .name = "cpuidle-at91",
  54. },
  55. .probe = at91_cpuidle_probe,
  56. };
  57. builtin_platform_driver(at91_cpuidle_driver);