cpuidle.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #include <mach/cpu.h>
  24. #include "pm.h"
  25. #define AT91_MAX_STATES 2
  26. /* Actual code that puts the SoC in different idle states */
  27. static int at91_enter_idle(struct cpuidle_device *dev,
  28. struct cpuidle_driver *drv,
  29. int index)
  30. {
  31. if (cpu_is_at91rm9200())
  32. at91rm9200_standby();
  33. else if (cpu_is_at91sam9g45())
  34. at91sam9g45_standby();
  35. else if (cpu_is_at91sam9263())
  36. at91sam9263_standby();
  37. else
  38. at91sam9_standby();
  39. return index;
  40. }
  41. static struct cpuidle_driver at91_idle_driver = {
  42. .name = "at91_idle",
  43. .owner = THIS_MODULE,
  44. .states[0] = ARM_CPUIDLE_WFI_STATE,
  45. .states[1] = {
  46. .enter = at91_enter_idle,
  47. .exit_latency = 10,
  48. .target_residency = 10000,
  49. .flags = CPUIDLE_FLAG_TIME_VALID,
  50. .name = "RAM_SR",
  51. .desc = "WFI and DDR Self Refresh",
  52. },
  53. .state_count = AT91_MAX_STATES,
  54. };
  55. /* Initialize CPU idle by registering the idle states */
  56. static int __init at91_init_cpuidle(void)
  57. {
  58. return cpuidle_register(&at91_idle_driver, NULL);
  59. }
  60. device_initcall(at91_init_cpuidle);