cpuidle-at91.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * based on arch/arm/mach-kirkwood/cpuidle.c
  4. *
  5. * CPU idle support for AT91 SoC
  6. *
  7. * The cpu idle uses wait-for-interrupt and RAM self refresh in order
  8. * to implement two idle states -
  9. * #1 wait-for-interrupt
  10. * #2 wait-for-interrupt and RAM self refresh
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/cpuidle.h>
  16. #include <linux/io.h>
  17. #include <linux/export.h>
  18. #include <asm/cpuidle.h>
  19. #define AT91_MAX_STATES 2
  20. static void (*at91_standby)(void);
  21. /* Actual code that puts the SoC in different idle states */
  22. static int at91_enter_idle(struct cpuidle_device *dev,
  23. struct cpuidle_driver *drv,
  24. int index)
  25. {
  26. at91_standby();
  27. return index;
  28. }
  29. static struct cpuidle_driver at91_idle_driver = {
  30. .name = "at91_idle",
  31. .owner = THIS_MODULE,
  32. .states[0] = ARM_CPUIDLE_WFI_STATE,
  33. .states[1] = {
  34. .enter = at91_enter_idle,
  35. .exit_latency = 10,
  36. .target_residency = 10000,
  37. .name = "RAM_SR",
  38. .desc = "WFI and DDR Self Refresh",
  39. },
  40. .state_count = AT91_MAX_STATES,
  41. };
  42. /* Initialize CPU idle by registering the idle states */
  43. static int at91_cpuidle_probe(struct platform_device *dev)
  44. {
  45. at91_standby = (void *)(dev->dev.platform_data);
  46. return cpuidle_register(&at91_idle_driver, NULL);
  47. }
  48. static struct platform_driver at91_cpuidle_driver = {
  49. .driver = {
  50. .name = "cpuidle-at91",
  51. },
  52. .probe = at91_cpuidle_probe,
  53. };
  54. builtin_platform_driver(at91_cpuidle_driver);