cpuidle.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/cpuidle.h>
  18. #include <plat/cpu.h>
  19. #include <mach/map.h>
  20. #include "regs-sys.h"
  21. #include "regs-syscon-power.h"
  22. static int s3c64xx_enter_idle(struct cpuidle_device *dev,
  23. struct cpuidle_driver *drv,
  24. int index)
  25. {
  26. unsigned long tmp;
  27. /* Setup PWRCFG to enter idle mode */
  28. tmp = __raw_readl(S3C64XX_PWR_CFG);
  29. tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK;
  30. tmp |= S3C64XX_PWRCFG_CFG_WFI_IDLE;
  31. __raw_writel(tmp, S3C64XX_PWR_CFG);
  32. cpu_do_idle();
  33. return index;
  34. }
  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. .name = "IDLE",
  44. .desc = "System active, ARM gated",
  45. },
  46. },
  47. .state_count = 1,
  48. };
  49. static int __init s3c64xx_init_cpuidle(void)
  50. {
  51. if (soc_is_s3c64xx())
  52. return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
  53. return 0;
  54. }
  55. device_initcall(s3c64xx_init_cpuidle);