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 2271b9114dSArnd Bergmann static int s3c64xx_enter_idle(struct cpuidle_device *dev, 2371b9114dSArnd Bergmann struct cpuidle_driver *drv, 2471b9114dSArnd Bergmann int index) 2571b9114dSArnd Bergmann { 2671b9114dSArnd Bergmann unsigned long tmp; 2771b9114dSArnd Bergmann 2871b9114dSArnd Bergmann /* Setup PWRCFG to enter idle mode */ 2971b9114dSArnd Bergmann tmp = __raw_readl(S3C64XX_PWR_CFG); 3071b9114dSArnd Bergmann tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK; 3171b9114dSArnd Bergmann tmp |= S3C64XX_PWRCFG_CFG_WFI_IDLE; 3271b9114dSArnd Bergmann __raw_writel(tmp, S3C64XX_PWR_CFG); 3371b9114dSArnd Bergmann 3471b9114dSArnd Bergmann cpu_do_idle(); 3571b9114dSArnd Bergmann 3671b9114dSArnd Bergmann return index; 3771b9114dSArnd Bergmann } 3871b9114dSArnd Bergmann 3971b9114dSArnd Bergmann static struct cpuidle_driver s3c64xx_cpuidle_driver = { 4071b9114dSArnd Bergmann .name = "s3c64xx_cpuidle", 4171b9114dSArnd Bergmann .owner = THIS_MODULE, 4271b9114dSArnd Bergmann .states = { 4371b9114dSArnd Bergmann { 4471b9114dSArnd Bergmann .enter = s3c64xx_enter_idle, 4571b9114dSArnd Bergmann .exit_latency = 1, 4671b9114dSArnd Bergmann .target_residency = 1, 4771b9114dSArnd Bergmann .name = "IDLE", 4871b9114dSArnd Bergmann .desc = "System active, ARM gated", 4971b9114dSArnd Bergmann }, 5071b9114dSArnd Bergmann }, 5171b9114dSArnd Bergmann .state_count = 1, 5271b9114dSArnd Bergmann }; 5371b9114dSArnd Bergmann 5471b9114dSArnd Bergmann static int __init s3c64xx_init_cpuidle(void) 5571b9114dSArnd Bergmann { 5671b9114dSArnd Bergmann if (soc_is_s3c64xx()) 5771b9114dSArnd Bergmann return cpuidle_register(&s3c64xx_cpuidle_driver, NULL); 5871b9114dSArnd Bergmann return 0; 5971b9114dSArnd Bergmann } 6071b9114dSArnd Bergmann device_initcall(s3c64xx_init_cpuidle); 61