cpuidle-s3c64xx.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2011 Wolfson Microelectronics, plc
  4. // Copyright (c) 2011 Samsung Electronics Co., Ltd.
  5. // http://www.samsung.com
  6. #include <linux/kernel.h>
  7. #include <linux/init.h>
  8. #include <linux/cpuidle.h>
  9. #include <linux/io.h>
  10. #include <linux/export.h>
  11. #include <linux/time.h>
  12. #include <asm/cpuidle.h>
  13. #include "cpu.h"
  14. #include "map.h"
  15. #include "regs-sys-s3c64xx.h"
  16. #include "regs-syscon-power-s3c64xx.h"
  17. static int s3c64xx_enter_idle(struct cpuidle_device *dev,
  18. struct cpuidle_driver *drv,
  19. int index)
  20. {
  21. unsigned long tmp;
  22. /* Setup PWRCFG to enter idle mode */
  23. tmp = __raw_readl(S3C64XX_PWR_CFG);
  24. tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK;
  25. tmp |= S3C64XX_PWRCFG_CFG_WFI_IDLE;
  26. __raw_writel(tmp, S3C64XX_PWR_CFG);
  27. cpu_do_idle();
  28. return index;
  29. }
  30. static struct cpuidle_driver s3c64xx_cpuidle_driver = {
  31. .name = "s3c64xx_cpuidle",
  32. .owner = THIS_MODULE,
  33. .states = {
  34. {
  35. .enter = s3c64xx_enter_idle,
  36. .exit_latency = 1,
  37. .target_residency = 1,
  38. .name = "IDLE",
  39. .desc = "System active, ARM gated",
  40. },
  41. },
  42. .state_count = 1,
  43. };
  44. static int __init s3c64xx_init_cpuidle(void)
  45. {
  46. if (soc_is_s3c64xx())
  47. return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
  48. return 0;
  49. }
  50. device_initcall(s3c64xx_init_cpuidle);