xref: /linux/arch/arm/mach-s3c/cpuidle-s3c64xx.c (revision 9a87ffc99ec8eb8d35eed7c4f816d75f5cc9662e)
171b9114dSArnd Bergmann // SPDX-License-Identifier: GPL-2.0
271b9114dSArnd Bergmann //
371b9114dSArnd Bergmann // Copyright (c) 2011 Wolfson Microelectronics, plc
471b9114dSArnd Bergmann // Copyright (c) 2011 Samsung Electronics Co., Ltd.
571b9114dSArnd Bergmann //		http://www.samsung.com
671b9114dSArnd Bergmann 
771b9114dSArnd Bergmann #include <linux/kernel.h>
871b9114dSArnd Bergmann #include <linux/init.h>
971b9114dSArnd Bergmann #include <linux/cpuidle.h>
1071b9114dSArnd Bergmann #include <linux/io.h>
1171b9114dSArnd Bergmann #include <linux/export.h>
1271b9114dSArnd Bergmann #include <linux/time.h>
1371b9114dSArnd Bergmann 
1471b9114dSArnd Bergmann #include <asm/cpuidle.h>
1571b9114dSArnd Bergmann 
16c6ff132dSArnd Bergmann #include "cpu.h"
17c6ff132dSArnd Bergmann #include "map.h"
1871b9114dSArnd Bergmann 
1971b9114dSArnd Bergmann #include "regs-sys-s3c64xx.h"
2071b9114dSArnd Bergmann #include "regs-syscon-power-s3c64xx.h"
2171b9114dSArnd Bergmann 
s3c64xx_enter_idle(struct cpuidle_device * dev,struct cpuidle_driver * drv,int index)22*26388a7cSPeter Zijlstra static __cpuidle int s3c64xx_enter_idle(struct cpuidle_device *dev,
23*26388a7cSPeter Zijlstra 					struct cpuidle_driver *drv, int index)
2471b9114dSArnd Bergmann {
2571b9114dSArnd Bergmann 	unsigned long tmp;
2671b9114dSArnd Bergmann 
2771b9114dSArnd Bergmann 	/* Setup PWRCFG to enter idle mode */
2871b9114dSArnd Bergmann 	tmp = __raw_readl(S3C64XX_PWR_CFG);
2971b9114dSArnd Bergmann 	tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK;
3071b9114dSArnd Bergmann 	tmp |= S3C64XX_PWRCFG_CFG_WFI_IDLE;
3171b9114dSArnd Bergmann 	__raw_writel(tmp, S3C64XX_PWR_CFG);
3271b9114dSArnd Bergmann 
3371b9114dSArnd Bergmann 	cpu_do_idle();
3471b9114dSArnd Bergmann 
3571b9114dSArnd Bergmann 	return index;
3671b9114dSArnd Bergmann }
3771b9114dSArnd Bergmann 
3871b9114dSArnd Bergmann static struct cpuidle_driver s3c64xx_cpuidle_driver = {
3971b9114dSArnd Bergmann 	.name	= "s3c64xx_cpuidle",
4071b9114dSArnd Bergmann 	.owner  = THIS_MODULE,
4171b9114dSArnd Bergmann 	.states = {
4271b9114dSArnd Bergmann 		{
4371b9114dSArnd Bergmann 			.enter            = s3c64xx_enter_idle,
4471b9114dSArnd Bergmann 			.exit_latency     = 1,
4571b9114dSArnd Bergmann 			.target_residency = 1,
4671b9114dSArnd Bergmann 			.name             = "IDLE",
4771b9114dSArnd Bergmann 			.desc             = "System active, ARM gated",
4871b9114dSArnd Bergmann 		},
4971b9114dSArnd Bergmann 	},
5071b9114dSArnd Bergmann 	.state_count = 1,
5171b9114dSArnd Bergmann };
5271b9114dSArnd Bergmann 
s3c64xx_init_cpuidle(void)5371b9114dSArnd Bergmann static int __init s3c64xx_init_cpuidle(void)
5471b9114dSArnd Bergmann {
5571b9114dSArnd Bergmann 	if (soc_is_s3c64xx())
5671b9114dSArnd Bergmann 		return cpuidle_register(&s3c64xx_cpuidle_driver, NULL);
5771b9114dSArnd Bergmann 	return 0;
5871b9114dSArnd Bergmann }
5971b9114dSArnd Bergmann device_initcall(s3c64xx_init_cpuidle);
60