cpuidle.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. int shmobile_enter_wfi(struct cpuidle_device *dev, struct cpuidle_driver *drv,
  18. int index)
  19. {
  20. cpu_do_idle();
  21. return 0;
  22. }
  23. static struct cpuidle_device shmobile_cpuidle_dev;
  24. static struct cpuidle_driver shmobile_cpuidle_default_driver = {
  25. .name = "shmobile_cpuidle",
  26. .owner = THIS_MODULE,
  27. .en_core_tk_irqen = 1,
  28. .states[0] = ARM_CPUIDLE_WFI_STATE,
  29. .states[0].enter = shmobile_enter_wfi,
  30. .safe_state_index = 0, /* C1 */
  31. .state_count = 1,
  32. };
  33. static struct cpuidle_driver *cpuidle_drv = &shmobile_cpuidle_default_driver;
  34. void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv)
  35. {
  36. cpuidle_drv = drv;
  37. }
  38. int shmobile_cpuidle_init(void)
  39. {
  40. struct cpuidle_device *dev = &shmobile_cpuidle_dev;
  41. cpuidle_register_driver(cpuidle_drv);
  42. dev->state_count = cpuidle_drv->state_count;
  43. cpuidle_register_device(dev);
  44. return 0;
  45. }