cpuidle.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <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. .name = "IDLE",
  43. .desc = "System active, ARM gated",
  44. },
  45. },
  46. .state_count = 1,
  47. };
  48. static int __init s3c64xx_init_cpuidle(void)
  49. {
  50. return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
  51. }
  52. device_initcall(s3c64xx_init_cpuidle);