162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci// 362306a36Sopenharmony_ci// Copyright (c) 2011-2015 Samsung Electronics Co., Ltd. 462306a36Sopenharmony_ci// http://www.samsung.com/ 562306a36Sopenharmony_ci// 662306a36Sopenharmony_ci// Exynos5250 - CPU PMU (Power Management Unit) support 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#include <linux/soc/samsung/exynos-regs-pmu.h> 962306a36Sopenharmony_ci#include <linux/soc/samsung/exynos-pmu.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include "exynos-pmu.h" 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_cistatic const struct exynos_pmu_conf exynos5250_pmu_config[] = { 1462306a36Sopenharmony_ci /* { .offset = offset, .val = { AFTR, LPA, SLEEP } */ 1562306a36Sopenharmony_ci { EXYNOS5_ARM_CORE0_SYS_PWR_REG, { 0x0, 0x0, 0x2} }, 1662306a36Sopenharmony_ci { EXYNOS5_DIS_IRQ_ARM_CORE0_LOCAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} }, 1762306a36Sopenharmony_ci { EXYNOS5_DIS_IRQ_ARM_CORE0_CENTRAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} }, 1862306a36Sopenharmony_ci { EXYNOS5_ARM_CORE1_SYS_PWR_REG, { 0x0, 0x0, 0x2} }, 1962306a36Sopenharmony_ci { EXYNOS5_DIS_IRQ_ARM_CORE1_LOCAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} }, 2062306a36Sopenharmony_ci { EXYNOS5_DIS_IRQ_ARM_CORE1_CENTRAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} }, 2162306a36Sopenharmony_ci { EXYNOS5_FSYS_ARM_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 2262306a36Sopenharmony_ci { EXYNOS5_DIS_IRQ_FSYS_ARM_CENTRAL_SYS_PWR_REG, { 0x1, 0x1, 0x1} }, 2362306a36Sopenharmony_ci { EXYNOS5_ISP_ARM_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 2462306a36Sopenharmony_ci { EXYNOS5_DIS_IRQ_ISP_ARM_LOCAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} }, 2562306a36Sopenharmony_ci { EXYNOS5_DIS_IRQ_ISP_ARM_CENTRAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} }, 2662306a36Sopenharmony_ci { EXYNOS5_ARM_COMMON_SYS_PWR_REG, { 0x0, 0x0, 0x2} }, 2762306a36Sopenharmony_ci { EXYNOS5_ARM_L2_SYS_PWR_REG, { 0x3, 0x3, 0x3} }, 2862306a36Sopenharmony_ci { EXYNOS_L2_OPTION(0), { 0x10, 0x10, 0x0 } }, 2962306a36Sopenharmony_ci { EXYNOS5_CMU_ACLKSTOP_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 3062306a36Sopenharmony_ci { EXYNOS5_CMU_SCLKSTOP_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 3162306a36Sopenharmony_ci { EXYNOS5_CMU_RESET_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 3262306a36Sopenharmony_ci { EXYNOS5_CMU_ACLKSTOP_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 3362306a36Sopenharmony_ci { EXYNOS5_CMU_SCLKSTOP_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 3462306a36Sopenharmony_ci { EXYNOS5_CMU_RESET_SYSMEM_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 3562306a36Sopenharmony_ci { EXYNOS5_DRAM_FREQ_DOWN_SYS_PWR_REG, { 0x1, 0x1, 0x1} }, 3662306a36Sopenharmony_ci { EXYNOS5_DDRPHY_DLLOFF_SYS_PWR_REG, { 0x1, 0x1, 0x1} }, 3762306a36Sopenharmony_ci { EXYNOS5_DDRPHY_DLLLOCK_SYS_PWR_REG, { 0x1, 0x1, 0x1} }, 3862306a36Sopenharmony_ci { EXYNOS5_APLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 3962306a36Sopenharmony_ci { EXYNOS5_MPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 4062306a36Sopenharmony_ci { EXYNOS5_VPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 4162306a36Sopenharmony_ci { EXYNOS5_EPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 4262306a36Sopenharmony_ci { EXYNOS5_BPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 4362306a36Sopenharmony_ci { EXYNOS5_CPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 4462306a36Sopenharmony_ci { EXYNOS5_MPLLUSER_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 4562306a36Sopenharmony_ci { EXYNOS5_BPLLUSER_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 4662306a36Sopenharmony_ci { EXYNOS5_TOP_BUS_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 4762306a36Sopenharmony_ci { EXYNOS5_TOP_RETENTION_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 4862306a36Sopenharmony_ci { EXYNOS5_TOP_PWR_SYS_PWR_REG, { 0x3, 0x0, 0x3} }, 4962306a36Sopenharmony_ci { EXYNOS5_TOP_BUS_SYSMEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 5062306a36Sopenharmony_ci { EXYNOS5_TOP_RETENTION_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 5162306a36Sopenharmony_ci { EXYNOS5_TOP_PWR_SYSMEM_SYS_PWR_REG, { 0x3, 0x0, 0x3} }, 5262306a36Sopenharmony_ci { EXYNOS5_LOGIC_RESET_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 5362306a36Sopenharmony_ci { EXYNOS5_OSCCLK_GATE_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 5462306a36Sopenharmony_ci { EXYNOS5_LOGIC_RESET_SYSMEM_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 5562306a36Sopenharmony_ci { EXYNOS5_OSCCLK_GATE_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 5662306a36Sopenharmony_ci { EXYNOS5_USBOTG_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 5762306a36Sopenharmony_ci { EXYNOS5_G2D_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 5862306a36Sopenharmony_ci { EXYNOS5_USBDRD_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 5962306a36Sopenharmony_ci { EXYNOS5_SDMMC_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6062306a36Sopenharmony_ci { EXYNOS5_CSSYS_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6162306a36Sopenharmony_ci { EXYNOS5_SECSS_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6262306a36Sopenharmony_ci { EXYNOS5_ROTATOR_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6362306a36Sopenharmony_ci { EXYNOS5_INTRAM_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6462306a36Sopenharmony_ci { EXYNOS5_INTROM_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6562306a36Sopenharmony_ci { EXYNOS5_JPEG_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6662306a36Sopenharmony_ci { EXYNOS5_JPEG_MEM_OPTION, { 0x10, 0x10, 0x0} }, 6762306a36Sopenharmony_ci { EXYNOS5_HSI_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6862306a36Sopenharmony_ci { EXYNOS5_MCUIOP_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 6962306a36Sopenharmony_ci { EXYNOS5_SATA_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} }, 7062306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_DRAM_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 7162306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 7262306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_GPIO_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 7362306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_UART_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 7462306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_MMCA_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 7562306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_MMCB_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 7662306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_EBIA_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 7762306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_EBIB_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 7862306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_SPI_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 7962306a36Sopenharmony_ci { EXYNOS5_PAD_RETENTION_GPIO_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 8062306a36Sopenharmony_ci { EXYNOS5_PAD_ISOLATION_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 8162306a36Sopenharmony_ci { EXYNOS5_PAD_ISOLATION_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 8262306a36Sopenharmony_ci { EXYNOS5_PAD_ALV_SEL_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 8362306a36Sopenharmony_ci { EXYNOS5_XUSBXTI_SYS_PWR_REG, { 0x1, 0x1, 0x1} }, 8462306a36Sopenharmony_ci { EXYNOS5_XXTI_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 8562306a36Sopenharmony_ci { EXYNOS5_EXT_REGULATOR_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 8662306a36Sopenharmony_ci { EXYNOS5_GPIO_MODE_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 8762306a36Sopenharmony_ci { EXYNOS5_GPIO_MODE_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 8862306a36Sopenharmony_ci { EXYNOS5_GPIO_MODE_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 8962306a36Sopenharmony_ci { EXYNOS5_TOP_ASB_RESET_SYS_PWR_REG, { 0x1, 0x1, 0x1} }, 9062306a36Sopenharmony_ci { EXYNOS5_TOP_ASB_ISOLATION_SYS_PWR_REG, { 0x1, 0x0, 0x1} }, 9162306a36Sopenharmony_ci { EXYNOS5_GSCL_SYS_PWR_REG, { 0x7, 0x0, 0x0} }, 9262306a36Sopenharmony_ci { EXYNOS5_ISP_SYS_PWR_REG, { 0x7, 0x0, 0x0} }, 9362306a36Sopenharmony_ci { EXYNOS5_MFC_SYS_PWR_REG, { 0x7, 0x0, 0x0} }, 9462306a36Sopenharmony_ci { EXYNOS5_G3D_SYS_PWR_REG, { 0x7, 0x0, 0x0} }, 9562306a36Sopenharmony_ci { EXYNOS5_DISP1_SYS_PWR_REG, { 0x7, 0x0, 0x0} }, 9662306a36Sopenharmony_ci { EXYNOS5_MAU_SYS_PWR_REG, { 0x7, 0x7, 0x0} }, 9762306a36Sopenharmony_ci { EXYNOS5_CMU_CLKSTOP_GSCL_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 9862306a36Sopenharmony_ci { EXYNOS5_CMU_CLKSTOP_ISP_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 9962306a36Sopenharmony_ci { EXYNOS5_CMU_CLKSTOP_MFC_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 10062306a36Sopenharmony_ci { EXYNOS5_CMU_CLKSTOP_G3D_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 10162306a36Sopenharmony_ci { EXYNOS5_CMU_CLKSTOP_DISP1_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 10262306a36Sopenharmony_ci { EXYNOS5_CMU_CLKSTOP_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 10362306a36Sopenharmony_ci { EXYNOS5_CMU_SYSCLK_GSCL_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 10462306a36Sopenharmony_ci { EXYNOS5_CMU_SYSCLK_ISP_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 10562306a36Sopenharmony_ci { EXYNOS5_CMU_SYSCLK_MFC_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 10662306a36Sopenharmony_ci { EXYNOS5_CMU_SYSCLK_G3D_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 10762306a36Sopenharmony_ci { EXYNOS5_CMU_SYSCLK_DISP1_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 10862306a36Sopenharmony_ci { EXYNOS5_CMU_SYSCLK_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 10962306a36Sopenharmony_ci { EXYNOS5_CMU_RESET_GSCL_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 11062306a36Sopenharmony_ci { EXYNOS5_CMU_RESET_ISP_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 11162306a36Sopenharmony_ci { EXYNOS5_CMU_RESET_MFC_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 11262306a36Sopenharmony_ci { EXYNOS5_CMU_RESET_G3D_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 11362306a36Sopenharmony_ci { EXYNOS5_CMU_RESET_DISP1_SYS_PWR_REG, { 0x1, 0x0, 0x0} }, 11462306a36Sopenharmony_ci { EXYNOS5_CMU_RESET_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} }, 11562306a36Sopenharmony_ci { PMU_TABLE_END,}, 11662306a36Sopenharmony_ci}; 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_cistatic unsigned int const exynos5_list_both_cnt_feed[] = { 11962306a36Sopenharmony_ci EXYNOS5_ARM_CORE0_OPTION, 12062306a36Sopenharmony_ci EXYNOS5_ARM_CORE1_OPTION, 12162306a36Sopenharmony_ci EXYNOS5_ARM_COMMON_OPTION, 12262306a36Sopenharmony_ci EXYNOS5_GSCL_OPTION, 12362306a36Sopenharmony_ci EXYNOS5_ISP_OPTION, 12462306a36Sopenharmony_ci EXYNOS5_MFC_OPTION, 12562306a36Sopenharmony_ci EXYNOS5_G3D_OPTION, 12662306a36Sopenharmony_ci EXYNOS5_DISP1_OPTION, 12762306a36Sopenharmony_ci EXYNOS5_MAU_OPTION, 12862306a36Sopenharmony_ci EXYNOS5_TOP_PWR_OPTION, 12962306a36Sopenharmony_ci EXYNOS5_TOP_PWR_SYSMEM_OPTION, 13062306a36Sopenharmony_ci}; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_cistatic unsigned int const exynos5_list_disable_wfi_wfe[] = { 13362306a36Sopenharmony_ci EXYNOS5_ARM_CORE1_OPTION, 13462306a36Sopenharmony_ci EXYNOS5_FSYS_ARM_OPTION, 13562306a36Sopenharmony_ci EXYNOS5_ISP_ARM_OPTION, 13662306a36Sopenharmony_ci}; 13762306a36Sopenharmony_ci 13862306a36Sopenharmony_cistatic void exynos5250_pmu_init(void) 13962306a36Sopenharmony_ci{ 14062306a36Sopenharmony_ci unsigned int value; 14162306a36Sopenharmony_ci /* 14262306a36Sopenharmony_ci * When SYS_WDTRESET is set, watchdog timer reset request 14362306a36Sopenharmony_ci * is ignored by power management unit. 14462306a36Sopenharmony_ci */ 14562306a36Sopenharmony_ci value = pmu_raw_readl(EXYNOS5_AUTO_WDTRESET_DISABLE); 14662306a36Sopenharmony_ci value &= ~EXYNOS5_SYS_WDTRESET; 14762306a36Sopenharmony_ci pmu_raw_writel(value, EXYNOS5_AUTO_WDTRESET_DISABLE); 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci value = pmu_raw_readl(EXYNOS5_MASK_WDTRESET_REQUEST); 15062306a36Sopenharmony_ci value &= ~EXYNOS5_SYS_WDTRESET; 15162306a36Sopenharmony_ci pmu_raw_writel(value, EXYNOS5_MASK_WDTRESET_REQUEST); 15262306a36Sopenharmony_ci} 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_cistatic void exynos5_powerdown_conf(enum sys_powerdown mode) 15562306a36Sopenharmony_ci{ 15662306a36Sopenharmony_ci unsigned int i; 15762306a36Sopenharmony_ci unsigned int tmp; 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci /* 16062306a36Sopenharmony_ci * Enable both SC_FEEDBACK and SC_COUNTER 16162306a36Sopenharmony_ci */ 16262306a36Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(exynos5_list_both_cnt_feed); i++) { 16362306a36Sopenharmony_ci tmp = pmu_raw_readl(exynos5_list_both_cnt_feed[i]); 16462306a36Sopenharmony_ci tmp |= (EXYNOS5_USE_SC_FEEDBACK | 16562306a36Sopenharmony_ci EXYNOS5_USE_SC_COUNTER); 16662306a36Sopenharmony_ci pmu_raw_writel(tmp, exynos5_list_both_cnt_feed[i]); 16762306a36Sopenharmony_ci } 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci /* 17062306a36Sopenharmony_ci * SKIP_DEACTIVATE_ACEACP_IN_PWDN_BITFIELD Enable 17162306a36Sopenharmony_ci */ 17262306a36Sopenharmony_ci tmp = pmu_raw_readl(EXYNOS5_ARM_COMMON_OPTION); 17362306a36Sopenharmony_ci tmp |= EXYNOS5_SKIP_DEACTIVATE_ACEACP_IN_PWDN; 17462306a36Sopenharmony_ci pmu_raw_writel(tmp, EXYNOS5_ARM_COMMON_OPTION); 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci /* 17762306a36Sopenharmony_ci * Disable WFI/WFE on XXX_OPTION 17862306a36Sopenharmony_ci */ 17962306a36Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(exynos5_list_disable_wfi_wfe); i++) { 18062306a36Sopenharmony_ci tmp = pmu_raw_readl(exynos5_list_disable_wfi_wfe[i]); 18162306a36Sopenharmony_ci tmp &= ~(EXYNOS5_OPTION_USE_STANDBYWFE | 18262306a36Sopenharmony_ci EXYNOS5_OPTION_USE_STANDBYWFI); 18362306a36Sopenharmony_ci pmu_raw_writel(tmp, exynos5_list_disable_wfi_wfe[i]); 18462306a36Sopenharmony_ci } 18562306a36Sopenharmony_ci} 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ciconst struct exynos_pmu_data exynos5250_pmu_data = { 18862306a36Sopenharmony_ci .pmu_config = exynos5250_pmu_config, 18962306a36Sopenharmony_ci .pmu_init = exynos5250_pmu_init, 19062306a36Sopenharmony_ci .powerdown_conf = exynos5_powerdown_conf, 19162306a36Sopenharmony_ci}; 192