cpuidle.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 struct cpuidle_driver s3c64xx_cpuidle_driver = {
  35. .name = "s3c64xx_cpuidle",
  36. .owner = THIS_MODULE,
  37. .states = {
  38. {
  39. .enter = s3c64xx_enter_idle,
  40. .exit_latency = 1,
  41. .target_residency = 1,
  42. .flags = CPUIDLE_FLAG_TIME_VALID,
  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. return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
  52. }
  53. device_initcall(s3c64xx_init_cpuidle);