cpuidle.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 "regs-sys.h"
  20. #include "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. .states = {
  39. {
  40. .enter = s3c64xx_enter_idle,
  41. .exit_latency = 1,
  42. .target_residency = 1,
  43. .flags = CPUIDLE_FLAG_TIME_VALID,
  44. .name = "IDLE",
  45. .desc = "System active, ARM gated",
  46. },
  47. },
  48. .state_count = 1,
  49. };
  50. static int __init s3c64xx_init_cpuidle(void)
  51. {
  52. int ret;
  53. cpuidle_register_driver(&s3c64xx_cpuidle_driver);
  54. ret = cpuidle_register_device(&s3c64xx_cpuidle_device);
  55. if (ret) {
  56. pr_err("Failed to register cpuidle device: %d\n", ret);
  57. return ret;
  58. }
  59. return 0;
  60. }
  61. device_initcall(s3c64xx_init_cpuidle);