cpuidle.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * CPUIdle support code for SH-Mobile ARM
  3. *
  4. * Copyright (C) 2011 Magnus Damm
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/pm.h>
  11. #include <linux/cpuidle.h>
  12. #include <linux/suspend.h>
  13. #include <linux/module.h>
  14. #include <linux/err.h>
  15. #include <asm/cpuidle.h>
  16. #include <asm/io.h>
  17. static void shmobile_enter_wfi(void)
  18. {
  19. cpu_do_idle();
  20. }
  21. void (*shmobile_cpuidle_modes[CPUIDLE_STATE_MAX])(void) = {
  22. shmobile_enter_wfi, /* regular sleep mode */
  23. };
  24. static int shmobile_cpuidle_enter(struct cpuidle_device *dev,
  25. struct cpuidle_driver *drv,
  26. int index)
  27. {
  28. shmobile_cpuidle_modes[index]();
  29. return index;
  30. }
  31. static struct cpuidle_device shmobile_cpuidle_dev;
  32. static struct cpuidle_driver shmobile_cpuidle_driver = {
  33. .name = "shmobile_cpuidle",
  34. .owner = THIS_MODULE,
  35. .en_core_tk_irqen = 1,
  36. .states[0] = ARM_CPUIDLE_WFI_STATE,
  37. .safe_state_index = 0, /* C1 */
  38. .state_count = 1,
  39. };
  40. void (*shmobile_cpuidle_setup)(struct cpuidle_driver *drv);
  41. static int shmobile_cpuidle_init(void)
  42. {
  43. struct cpuidle_device *dev = &shmobile_cpuidle_dev;
  44. struct cpuidle_driver *drv = &shmobile_cpuidle_driver;
  45. int i;
  46. for (i = 0; i < CPUIDLE_STATE_MAX; i++)
  47. drv->states[i].enter = shmobile_cpuidle_enter;
  48. if (shmobile_cpuidle_setup)
  49. shmobile_cpuidle_setup(drv);
  50. cpuidle_register_driver(drv);
  51. dev->state_count = drv->state_count;
  52. cpuidle_register_device(dev);
  53. return 0;
  54. }
  55. late_initcall(shmobile_cpuidle_init);