cpuidle.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* linux/arch/arm/mach-s3c64xx/cpuidle.c
  2. *
  3. * Copyright (c) 2011 Wolfson Microelectronics, plc
  4. * Copyright (c) 2011 Samsung Electronics Co., Ltd.
  5. * http://www.samsung.com
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/cpuidle.h>
  14. #include <linux/io.h>
  15. #include <linux/export.h>
  16. #include <linux/time.h>
  17. #include <asm/proc-fns.h>
  18. #include <mach/map.h>
  19. #include <mach/regs-sys.h>
  20. #include <mach/regs-syscon-power.h>
  21. static int s3c64xx_enter_idle(struct cpuidle_device *dev,
  22. struct cpuidle_driver *drv,
  23. int index)
  24. {
  25. unsigned long tmp;
  26. /* Setup PWRCFG to enter idle mode */
  27. tmp = __raw_readl(S3C64XX_PWR_CFG);
  28. tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK;
  29. tmp |= S3C64XX_PWRCFG_CFG_WFI_IDLE;
  30. __raw_writel(tmp, S3C64XX_PWR_CFG);
  31. cpu_do_idle();
  32. return index;
  33. }
  34. static DEFINE_PER_CPU(struct cpuidle_device, s3c64xx_cpuidle_device);
  35. static struct cpuidle_driver s3c64xx_cpuidle_driver = {
  36. .name = "s3c64xx_cpuidle",
  37. .owner = THIS_MODULE,
  38. .en_core_tk_irqen = 1,
  39. .states = {
  40. {
  41. .enter = s3c64xx_enter_idle,
  42. .exit_latency = 1,
  43. .target_residency = 1,
  44. .flags = CPUIDLE_FLAG_TIME_VALID,
  45. .name = "IDLE",
  46. .desc = "System active, ARM gated",
  47. },
  48. },
  49. .state_count = 1,
  50. };
  51. static int __init s3c64xx_init_cpuidle(void)
  52. {
  53. int ret;
  54. cpuidle_register_driver(&s3c64xx_cpuidle_driver);
  55. ret = cpuidle_register_device(&s3c64xx_cpuidle_device);
  56. if (ret) {
  57. pr_err("Failed to register cpuidle device: %d\n", ret);
  58. return ret;
  59. }
  60. return 0;
  61. }
  62. device_initcall(s3c64xx_init_cpuidle);