blob: 88d3f793e2677a627bfc87767cea01c7c02a8cef [file] [log] [blame]
Jongpill Lee7d44d2b2012-02-17 09:51:31 +09001/*
Pankaj Dubey14fc8b92014-11-07 09:26:40 +09002 * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd.
Jaecheol Leee28e3012011-07-18 19:21:23 +09003 * http://www.samsung.com/
4 *
Jongpill Lee7d44d2b2012-02-17 09:51:31 +09005 * EXYNOS - CPU PMU(Power Management Unit) support
Jaecheol Leee28e3012011-07-18 19:21:23 +09006 *
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
12#include <linux/io.h>
Pankaj Dubey14fc8b92014-11-07 09:26:40 +090013#include <linux/of.h>
14#include <linux/platform_device.h>
Jaecheol Leee28e3012011-07-18 19:21:23 +090015
Pankaj Dubey6b7bfd82014-11-07 09:26:47 +090016#include "exynos-pmu.h"
Kukjin Kim65c9a852013-12-19 04:06:56 +090017#include "regs-pmu.h"
Jaecheol Leee28e3012011-07-18 19:21:23 +090018
Pankaj Dubey6b7bfd82014-11-07 09:26:47 +090019#define PMU_TABLE_END (-1U)
20
21struct exynos_pmu_conf {
22 unsigned int offset;
23 unsigned int val[NUM_SYS_POWERDOWN];
24};
25
Pankaj Dubey14fc8b92014-11-07 09:26:40 +090026struct exynos_pmu_data {
27 const struct exynos_pmu_conf *pmu_config;
28 const struct exynos_pmu_conf *pmu_config_extra;
29
30 void (*pmu_init)(void);
31 void (*powerdown_conf)(enum sys_powerdown);
32};
33
34struct exynos_pmu_context {
35 struct device *dev;
36 const struct exynos_pmu_data *pmu_data;
37};
38
Pankaj Dubey6b7bfd82014-11-07 09:26:47 +090039static void __iomem *pmu_base_addr;
Pankaj Dubey14fc8b92014-11-07 09:26:40 +090040static struct exynos_pmu_context *pmu_context;
Jaecheol Leee28e3012011-07-18 19:21:23 +090041
Pankaj Dubey6b7bfd82014-11-07 09:26:47 +090042static inline void pmu_raw_writel(u32 val, u32 offset)
43{
44 writel_relaxed(val, pmu_base_addr + offset);
45}
46
47static inline u32 pmu_raw_readl(u32 offset)
48{
49 return readl_relaxed(pmu_base_addr + offset);
50}
51
Daniel Kurtz53302222013-12-12 07:07:23 +090052static const struct exynos_pmu_conf exynos4210_pmu_config[] = {
Pankaj Dubey2e94ac42014-07-19 03:43:22 +090053 /* { .offset = offset, .val = { AFTR, LPA, SLEEP } */
Jongpill Lee0dba4dc2011-09-27 07:22:11 +090054 { S5P_ARM_CORE0_LOWPWR, { 0x0, 0x0, 0x2 } },
55 { S5P_DIS_IRQ_CORE0, { 0x0, 0x0, 0x0 } },
56 { S5P_DIS_IRQ_CENTRAL0, { 0x0, 0x0, 0x0 } },
57 { S5P_ARM_CORE1_LOWPWR, { 0x0, 0x0, 0x2 } },
58 { S5P_DIS_IRQ_CORE1, { 0x0, 0x0, 0x0 } },
59 { S5P_DIS_IRQ_CENTRAL1, { 0x0, 0x0, 0x0 } },
60 { S5P_ARM_COMMON_LOWPWR, { 0x0, 0x0, 0x2 } },
61 { S5P_L2_0_LOWPWR, { 0x2, 0x2, 0x3 } },
62 { S5P_L2_1_LOWPWR, { 0x2, 0x2, 0x3 } },
63 { S5P_CMU_ACLKSTOP_LOWPWR, { 0x1, 0x0, 0x0 } },
64 { S5P_CMU_SCLKSTOP_LOWPWR, { 0x1, 0x0, 0x0 } },
65 { S5P_CMU_RESET_LOWPWR, { 0x1, 0x1, 0x0 } },
66 { S5P_APLL_SYSCLK_LOWPWR, { 0x1, 0x0, 0x0 } },
67 { S5P_MPLL_SYSCLK_LOWPWR, { 0x1, 0x0, 0x0 } },
68 { S5P_VPLL_SYSCLK_LOWPWR, { 0x1, 0x0, 0x0 } },
69 { S5P_EPLL_SYSCLK_LOWPWR, { 0x1, 0x1, 0x0 } },
70 { S5P_CMU_CLKSTOP_GPS_ALIVE_LOWPWR, { 0x1, 0x1, 0x0 } },
71 { S5P_CMU_RESET_GPSALIVE_LOWPWR, { 0x1, 0x1, 0x0 } },
72 { S5P_CMU_CLKSTOP_CAM_LOWPWR, { 0x1, 0x1, 0x0 } },
73 { S5P_CMU_CLKSTOP_TV_LOWPWR, { 0x1, 0x1, 0x0 } },
74 { S5P_CMU_CLKSTOP_MFC_LOWPWR, { 0x1, 0x1, 0x0 } },
75 { S5P_CMU_CLKSTOP_G3D_LOWPWR, { 0x1, 0x1, 0x0 } },
76 { S5P_CMU_CLKSTOP_LCD0_LOWPWR, { 0x1, 0x1, 0x0 } },
77 { S5P_CMU_CLKSTOP_LCD1_LOWPWR, { 0x1, 0x1, 0x0 } },
78 { S5P_CMU_CLKSTOP_MAUDIO_LOWPWR, { 0x1, 0x1, 0x0 } },
79 { S5P_CMU_CLKSTOP_GPS_LOWPWR, { 0x1, 0x1, 0x0 } },
80 { S5P_CMU_RESET_CAM_LOWPWR, { 0x1, 0x1, 0x0 } },
81 { S5P_CMU_RESET_TV_LOWPWR, { 0x1, 0x1, 0x0 } },
82 { S5P_CMU_RESET_MFC_LOWPWR, { 0x1, 0x1, 0x0 } },
83 { S5P_CMU_RESET_G3D_LOWPWR, { 0x1, 0x1, 0x0 } },
84 { S5P_CMU_RESET_LCD0_LOWPWR, { 0x1, 0x1, 0x0 } },
85 { S5P_CMU_RESET_LCD1_LOWPWR, { 0x1, 0x1, 0x0 } },
86 { S5P_CMU_RESET_MAUDIO_LOWPWR, { 0x1, 0x1, 0x0 } },
87 { S5P_CMU_RESET_GPS_LOWPWR, { 0x1, 0x1, 0x0 } },
88 { S5P_TOP_BUS_LOWPWR, { 0x3, 0x0, 0x0 } },
89 { S5P_TOP_RETENTION_LOWPWR, { 0x1, 0x0, 0x1 } },
90 { S5P_TOP_PWR_LOWPWR, { 0x3, 0x0, 0x3 } },
91 { S5P_LOGIC_RESET_LOWPWR, { 0x1, 0x1, 0x0 } },
92 { S5P_ONENAND_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
93 { S5P_MODIMIF_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
94 { S5P_G2D_ACP_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
95 { S5P_USBOTG_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
96 { S5P_HSMMC_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
97 { S5P_CSSYS_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
98 { S5P_SECSS_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
99 { S5P_PCIE_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
100 { S5P_SATA_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
101 { S5P_PAD_RETENTION_DRAM_LOWPWR, { 0x1, 0x0, 0x0 } },
102 { S5P_PAD_RETENTION_MAUDIO_LOWPWR, { 0x1, 0x1, 0x0 } },
103 { S5P_PAD_RETENTION_GPIO_LOWPWR, { 0x1, 0x0, 0x0 } },
104 { S5P_PAD_RETENTION_UART_LOWPWR, { 0x1, 0x0, 0x0 } },
105 { S5P_PAD_RETENTION_MMCA_LOWPWR, { 0x1, 0x0, 0x0 } },
106 { S5P_PAD_RETENTION_MMCB_LOWPWR, { 0x1, 0x0, 0x0 } },
107 { S5P_PAD_RETENTION_EBIA_LOWPWR, { 0x1, 0x0, 0x0 } },
108 { S5P_PAD_RETENTION_EBIB_LOWPWR, { 0x1, 0x0, 0x0 } },
109 { S5P_PAD_RETENTION_ISOLATION_LOWPWR, { 0x1, 0x0, 0x0 } },
110 { S5P_PAD_RETENTION_ALV_SEL_LOWPWR, { 0x1, 0x0, 0x0 } },
111 { S5P_XUSBXTI_LOWPWR, { 0x1, 0x1, 0x0 } },
112 { S5P_XXTI_LOWPWR, { 0x1, 0x1, 0x0 } },
113 { S5P_EXT_REGULATOR_LOWPWR, { 0x1, 0x1, 0x0 } },
114 { S5P_GPIO_MODE_LOWPWR, { 0x1, 0x0, 0x0 } },
115 { S5P_GPIO_MODE_MAUDIO_LOWPWR, { 0x1, 0x1, 0x0 } },
116 { S5P_CAM_LOWPWR, { 0x7, 0x0, 0x0 } },
117 { S5P_TV_LOWPWR, { 0x7, 0x0, 0x0 } },
118 { S5P_MFC_LOWPWR, { 0x7, 0x0, 0x0 } },
119 { S5P_G3D_LOWPWR, { 0x7, 0x0, 0x0 } },
120 { S5P_LCD0_LOWPWR, { 0x7, 0x0, 0x0 } },
121 { S5P_LCD1_LOWPWR, { 0x7, 0x0, 0x0 } },
122 { S5P_MAUDIO_LOWPWR, { 0x7, 0x7, 0x0 } },
123 { S5P_GPS_LOWPWR, { 0x7, 0x0, 0x0 } },
124 { S5P_GPS_ALIVE_LOWPWR, { 0x7, 0x0, 0x0 } },
125 { PMU_TABLE_END,},
Jaecheol Leee28e3012011-07-18 19:21:23 +0900126};
127
Daniel Kurtz53302222013-12-12 07:07:23 +0900128static const struct exynos_pmu_conf exynos4x12_pmu_config[] = {
Jongpill Lee00a351f2011-09-27 07:26:04 +0900129 { S5P_ARM_CORE0_LOWPWR, { 0x0, 0x0, 0x2 } },
130 { S5P_DIS_IRQ_CORE0, { 0x0, 0x0, 0x0 } },
131 { S5P_DIS_IRQ_CENTRAL0, { 0x0, 0x0, 0x0 } },
132 { S5P_ARM_CORE1_LOWPWR, { 0x0, 0x0, 0x2 } },
133 { S5P_DIS_IRQ_CORE1, { 0x0, 0x0, 0x0 } },
134 { S5P_DIS_IRQ_CENTRAL1, { 0x0, 0x0, 0x0 } },
135 { S5P_ISP_ARM_LOWPWR, { 0x1, 0x0, 0x0 } },
136 { S5P_DIS_IRQ_ISP_ARM_LOCAL_LOWPWR, { 0x0, 0x0, 0x0 } },
137 { S5P_DIS_IRQ_ISP_ARM_CENTRAL_LOWPWR, { 0x0, 0x0, 0x0 } },
138 { S5P_ARM_COMMON_LOWPWR, { 0x0, 0x0, 0x2 } },
139 { S5P_L2_0_LOWPWR, { 0x0, 0x0, 0x3 } },
140 /* XXX_OPTION register should be set other field */
141 { S5P_ARM_L2_0_OPTION, { 0x10, 0x10, 0x0 } },
142 { S5P_L2_1_LOWPWR, { 0x0, 0x0, 0x3 } },
143 { S5P_ARM_L2_1_OPTION, { 0x10, 0x10, 0x0 } },
144 { S5P_CMU_ACLKSTOP_LOWPWR, { 0x1, 0x0, 0x0 } },
145 { S5P_CMU_SCLKSTOP_LOWPWR, { 0x1, 0x0, 0x0 } },
146 { S5P_CMU_RESET_LOWPWR, { 0x1, 0x1, 0x0 } },
147 { S5P_DRAM_FREQ_DOWN_LOWPWR, { 0x1, 0x1, 0x1 } },
148 { S5P_DDRPHY_DLLOFF_LOWPWR, { 0x1, 0x1, 0x1 } },
149 { S5P_LPDDR_PHY_DLL_LOCK_LOWPWR, { 0x1, 0x1, 0x1 } },
150 { S5P_CMU_ACLKSTOP_COREBLK_LOWPWR, { 0x1, 0x0, 0x0 } },
151 { S5P_CMU_SCLKSTOP_COREBLK_LOWPWR, { 0x1, 0x0, 0x0 } },
152 { S5P_CMU_RESET_COREBLK_LOWPWR, { 0x1, 0x1, 0x0 } },
153 { S5P_APLL_SYSCLK_LOWPWR, { 0x1, 0x0, 0x0 } },
154 { S5P_MPLL_SYSCLK_LOWPWR, { 0x1, 0x0, 0x0 } },
155 { S5P_VPLL_SYSCLK_LOWPWR, { 0x1, 0x0, 0x0 } },
156 { S5P_EPLL_SYSCLK_LOWPWR, { 0x1, 0x1, 0x0 } },
157 { S5P_MPLLUSER_SYSCLK_LOWPWR, { 0x1, 0x0, 0x0 } },
158 { S5P_CMU_CLKSTOP_GPS_ALIVE_LOWPWR, { 0x1, 0x0, 0x0 } },
159 { S5P_CMU_RESET_GPSALIVE_LOWPWR, { 0x1, 0x0, 0x0 } },
160 { S5P_CMU_CLKSTOP_CAM_LOWPWR, { 0x1, 0x0, 0x0 } },
161 { S5P_CMU_CLKSTOP_TV_LOWPWR, { 0x1, 0x0, 0x0 } },
162 { S5P_CMU_CLKSTOP_MFC_LOWPWR, { 0x1, 0x0, 0x0 } },
163 { S5P_CMU_CLKSTOP_G3D_LOWPWR, { 0x1, 0x0, 0x0 } },
164 { S5P_CMU_CLKSTOP_LCD0_LOWPWR, { 0x1, 0x0, 0x0 } },
165 { S5P_CMU_CLKSTOP_ISP_LOWPWR, { 0x1, 0x0, 0x0 } },
166 { S5P_CMU_CLKSTOP_MAUDIO_LOWPWR, { 0x1, 0x0, 0x0 } },
167 { S5P_CMU_CLKSTOP_GPS_LOWPWR, { 0x1, 0x0, 0x0 } },
168 { S5P_CMU_RESET_CAM_LOWPWR, { 0x1, 0x0, 0x0 } },
169 { S5P_CMU_RESET_TV_LOWPWR, { 0x1, 0x0, 0x0 } },
170 { S5P_CMU_RESET_MFC_LOWPWR, { 0x1, 0x0, 0x0 } },
171 { S5P_CMU_RESET_G3D_LOWPWR, { 0x1, 0x0, 0x0 } },
172 { S5P_CMU_RESET_LCD0_LOWPWR, { 0x1, 0x0, 0x0 } },
173 { S5P_CMU_RESET_ISP_LOWPWR, { 0x1, 0x0, 0x0 } },
174 { S5P_CMU_RESET_MAUDIO_LOWPWR, { 0x1, 0x1, 0x0 } },
175 { S5P_CMU_RESET_GPS_LOWPWR, { 0x1, 0x0, 0x0 } },
176 { S5P_TOP_BUS_LOWPWR, { 0x3, 0x0, 0x0 } },
177 { S5P_TOP_RETENTION_LOWPWR, { 0x1, 0x0, 0x1 } },
178 { S5P_TOP_PWR_LOWPWR, { 0x3, 0x0, 0x3 } },
179 { S5P_TOP_BUS_COREBLK_LOWPWR, { 0x3, 0x0, 0x0 } },
180 { S5P_TOP_RETENTION_COREBLK_LOWPWR, { 0x1, 0x0, 0x1 } },
181 { S5P_TOP_PWR_COREBLK_LOWPWR, { 0x3, 0x0, 0x3 } },
182 { S5P_LOGIC_RESET_LOWPWR, { 0x1, 0x1, 0x0 } },
183 { S5P_OSCCLK_GATE_LOWPWR, { 0x1, 0x0, 0x1 } },
184 { S5P_LOGIC_RESET_COREBLK_LOWPWR, { 0x1, 0x1, 0x0 } },
185 { S5P_OSCCLK_GATE_COREBLK_LOWPWR, { 0x1, 0x0, 0x1 } },
186 { S5P_ONENAND_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
187 { S5P_ONENAND_MEM_OPTION, { 0x10, 0x10, 0x0 } },
188 { S5P_HSI_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
189 { S5P_HSI_MEM_OPTION, { 0x10, 0x10, 0x0 } },
190 { S5P_G2D_ACP_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
191 { S5P_G2D_ACP_MEM_OPTION, { 0x10, 0x10, 0x0 } },
192 { S5P_USBOTG_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
193 { S5P_USBOTG_MEM_OPTION, { 0x10, 0x10, 0x0 } },
194 { S5P_HSMMC_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
195 { S5P_HSMMC_MEM_OPTION, { 0x10, 0x10, 0x0 } },
196 { S5P_CSSYS_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
197 { S5P_CSSYS_MEM_OPTION, { 0x10, 0x10, 0x0 } },
198 { S5P_SECSS_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
199 { S5P_SECSS_MEM_OPTION, { 0x10, 0x10, 0x0 } },
200 { S5P_ROTATOR_MEM_LOWPWR, { 0x3, 0x0, 0x0 } },
201 { S5P_ROTATOR_MEM_OPTION, { 0x10, 0x10, 0x0 } },
202 { S5P_PAD_RETENTION_DRAM_LOWPWR, { 0x1, 0x0, 0x0 } },
203 { S5P_PAD_RETENTION_MAUDIO_LOWPWR, { 0x1, 0x1, 0x0 } },
204 { S5P_PAD_RETENTION_GPIO_LOWPWR, { 0x1, 0x0, 0x0 } },
205 { S5P_PAD_RETENTION_UART_LOWPWR, { 0x1, 0x0, 0x0 } },
206 { S5P_PAD_RETENTION_MMCA_LOWPWR, { 0x1, 0x0, 0x0 } },
207 { S5P_PAD_RETENTION_MMCB_LOWPWR, { 0x1, 0x0, 0x0 } },
208 { S5P_PAD_RETENTION_EBIA_LOWPWR, { 0x1, 0x0, 0x0 } },
209 { S5P_PAD_RETENTION_EBIB_LOWPWR, { 0x1, 0x0, 0x0 } },
210 { S5P_PAD_RETENTION_GPIO_COREBLK_LOWPWR,{ 0x1, 0x0, 0x0 } },
211 { S5P_PAD_RETENTION_ISOLATION_LOWPWR, { 0x1, 0x0, 0x0 } },
212 { S5P_PAD_ISOLATION_COREBLK_LOWPWR, { 0x1, 0x0, 0x0 } },
213 { S5P_PAD_RETENTION_ALV_SEL_LOWPWR, { 0x1, 0x0, 0x0 } },
214 { S5P_XUSBXTI_LOWPWR, { 0x1, 0x1, 0x0 } },
215 { S5P_XXTI_LOWPWR, { 0x1, 0x1, 0x0 } },
216 { S5P_EXT_REGULATOR_LOWPWR, { 0x1, 0x1, 0x0 } },
217 { S5P_GPIO_MODE_LOWPWR, { 0x1, 0x0, 0x0 } },
218 { S5P_GPIO_MODE_COREBLK_LOWPWR, { 0x1, 0x0, 0x0 } },
219 { S5P_GPIO_MODE_MAUDIO_LOWPWR, { 0x1, 0x1, 0x0 } },
220 { S5P_TOP_ASB_RESET_LOWPWR, { 0x1, 0x1, 0x1 } },
221 { S5P_TOP_ASB_ISOLATION_LOWPWR, { 0x1, 0x0, 0x1 } },
222 { S5P_CAM_LOWPWR, { 0x7, 0x0, 0x0 } },
223 { S5P_TV_LOWPWR, { 0x7, 0x0, 0x0 } },
224 { S5P_MFC_LOWPWR, { 0x7, 0x0, 0x0 } },
225 { S5P_G3D_LOWPWR, { 0x7, 0x0, 0x0 } },
226 { S5P_LCD0_LOWPWR, { 0x7, 0x0, 0x0 } },
227 { S5P_ISP_LOWPWR, { 0x7, 0x0, 0x0 } },
228 { S5P_MAUDIO_LOWPWR, { 0x7, 0x7, 0x0 } },
229 { S5P_GPS_LOWPWR, { 0x7, 0x0, 0x0 } },
230 { S5P_GPS_ALIVE_LOWPWR, { 0x7, 0x0, 0x0 } },
231 { S5P_CMU_SYSCLK_ISP_LOWPWR, { 0x1, 0x0, 0x0 } },
232 { S5P_CMU_SYSCLK_GPS_LOWPWR, { 0x1, 0x0, 0x0 } },
233 { PMU_TABLE_END,},
234};
235
Daniel Kurtz53302222013-12-12 07:07:23 +0900236static const struct exynos_pmu_conf exynos4412_pmu_config[] = {
Inderpal Singh5ddfa842012-05-15 00:20:09 +0900237 { S5P_ARM_CORE2_LOWPWR, { 0x0, 0x0, 0x2 } },
238 { S5P_DIS_IRQ_CORE2, { 0x0, 0x0, 0x0 } },
239 { S5P_DIS_IRQ_CENTRAL2, { 0x0, 0x0, 0x0 } },
240 { S5P_ARM_CORE3_LOWPWR, { 0x0, 0x0, 0x2 } },
241 { S5P_DIS_IRQ_CORE3, { 0x0, 0x0, 0x0 } },
242 { S5P_DIS_IRQ_CENTRAL3, { 0x0, 0x0, 0x0 } },
243 { PMU_TABLE_END,},
244};
245
Daniel Kurtz53302222013-12-12 07:07:23 +0900246static const struct exynos_pmu_conf exynos5250_pmu_config[] = {
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900247 /* { .offset = offset, .val = { AFTR, LPA, SLEEP } */
Jongpill Lee7d44d2b2012-02-17 09:51:31 +0900248 { EXYNOS5_ARM_CORE0_SYS_PWR_REG, { 0x0, 0x0, 0x2} },
249 { EXYNOS5_DIS_IRQ_ARM_CORE0_LOCAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} },
250 { EXYNOS5_DIS_IRQ_ARM_CORE0_CENTRAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} },
251 { EXYNOS5_ARM_CORE1_SYS_PWR_REG, { 0x0, 0x0, 0x2} },
252 { EXYNOS5_DIS_IRQ_ARM_CORE1_LOCAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} },
253 { EXYNOS5_DIS_IRQ_ARM_CORE1_CENTRAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} },
254 { EXYNOS5_FSYS_ARM_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
255 { EXYNOS5_DIS_IRQ_FSYS_ARM_CENTRAL_SYS_PWR_REG, { 0x1, 0x1, 0x1} },
256 { EXYNOS5_ISP_ARM_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
257 { EXYNOS5_DIS_IRQ_ISP_ARM_LOCAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} },
258 { EXYNOS5_DIS_IRQ_ISP_ARM_CENTRAL_SYS_PWR_REG, { 0x0, 0x0, 0x0} },
259 { EXYNOS5_ARM_COMMON_SYS_PWR_REG, { 0x0, 0x0, 0x2} },
260 { EXYNOS5_ARM_L2_SYS_PWR_REG, { 0x3, 0x3, 0x3} },
Inderpal Singh088584612013-04-29 17:01:47 +0530261 { EXYNOS5_ARM_L2_OPTION, { 0x10, 0x10, 0x0 } },
Jongpill Lee7d44d2b2012-02-17 09:51:31 +0900262 { EXYNOS5_CMU_ACLKSTOP_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
263 { EXYNOS5_CMU_SCLKSTOP_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
264 { EXYNOS5_CMU_RESET_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
265 { EXYNOS5_CMU_ACLKSTOP_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
266 { EXYNOS5_CMU_SCLKSTOP_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
267 { EXYNOS5_CMU_RESET_SYSMEM_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
268 { EXYNOS5_DRAM_FREQ_DOWN_SYS_PWR_REG, { 0x1, 0x1, 0x1} },
269 { EXYNOS5_DDRPHY_DLLOFF_SYS_PWR_REG, { 0x1, 0x1, 0x1} },
270 { EXYNOS5_DDRPHY_DLLLOCK_SYS_PWR_REG, { 0x1, 0x1, 0x1} },
271 { EXYNOS5_APLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
272 { EXYNOS5_MPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
273 { EXYNOS5_VPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
274 { EXYNOS5_EPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
275 { EXYNOS5_BPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
276 { EXYNOS5_CPLL_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
277 { EXYNOS5_MPLLUSER_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
278 { EXYNOS5_BPLLUSER_SYSCLK_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
279 { EXYNOS5_TOP_BUS_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
280 { EXYNOS5_TOP_RETENTION_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
281 { EXYNOS5_TOP_PWR_SYS_PWR_REG, { 0x3, 0x0, 0x3} },
282 { EXYNOS5_TOP_BUS_SYSMEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
283 { EXYNOS5_TOP_RETENTION_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
284 { EXYNOS5_TOP_PWR_SYSMEM_SYS_PWR_REG, { 0x3, 0x0, 0x3} },
285 { EXYNOS5_LOGIC_RESET_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
286 { EXYNOS5_OSCCLK_GATE_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
287 { EXYNOS5_LOGIC_RESET_SYSMEM_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
288 { EXYNOS5_OSCCLK_GATE_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
289 { EXYNOS5_USBOTG_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
290 { EXYNOS5_G2D_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
291 { EXYNOS5_USBDRD_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
292 { EXYNOS5_SDMMC_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
293 { EXYNOS5_CSSYS_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
294 { EXYNOS5_SECSS_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
295 { EXYNOS5_ROTATOR_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
296 { EXYNOS5_INTRAM_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
297 { EXYNOS5_INTROM_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
298 { EXYNOS5_JPEG_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
Vikas Sajjan32ed35f2014-09-24 16:45:13 +0900299 { EXYNOS5_JPEG_MEM_OPTION, { 0x10, 0x10, 0x0} },
Jongpill Lee7d44d2b2012-02-17 09:51:31 +0900300 { EXYNOS5_HSI_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
301 { EXYNOS5_MCUIOP_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
302 { EXYNOS5_SATA_MEM_SYS_PWR_REG, { 0x3, 0x0, 0x0} },
303 { EXYNOS5_PAD_RETENTION_DRAM_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
304 { EXYNOS5_PAD_RETENTION_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
305 { EXYNOS5_PAD_RETENTION_GPIO_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
306 { EXYNOS5_PAD_RETENTION_UART_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
307 { EXYNOS5_PAD_RETENTION_MMCA_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
308 { EXYNOS5_PAD_RETENTION_MMCB_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
309 { EXYNOS5_PAD_RETENTION_EBIA_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
310 { EXYNOS5_PAD_RETENTION_EBIB_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
311 { EXYNOS5_PAD_RETENTION_SPI_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
312 { EXYNOS5_PAD_RETENTION_GPIO_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
313 { EXYNOS5_PAD_ISOLATION_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
314 { EXYNOS5_PAD_ISOLATION_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
315 { EXYNOS5_PAD_ALV_SEL_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
316 { EXYNOS5_XUSBXTI_SYS_PWR_REG, { 0x1, 0x1, 0x1} },
317 { EXYNOS5_XXTI_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
318 { EXYNOS5_EXT_REGULATOR_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
319 { EXYNOS5_GPIO_MODE_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
320 { EXYNOS5_GPIO_MODE_SYSMEM_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
321 { EXYNOS5_GPIO_MODE_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
322 { EXYNOS5_TOP_ASB_RESET_SYS_PWR_REG, { 0x1, 0x1, 0x1} },
323 { EXYNOS5_TOP_ASB_ISOLATION_SYS_PWR_REG, { 0x1, 0x0, 0x1} },
324 { EXYNOS5_GSCL_SYS_PWR_REG, { 0x7, 0x0, 0x0} },
325 { EXYNOS5_ISP_SYS_PWR_REG, { 0x7, 0x0, 0x0} },
326 { EXYNOS5_MFC_SYS_PWR_REG, { 0x7, 0x0, 0x0} },
327 { EXYNOS5_G3D_SYS_PWR_REG, { 0x7, 0x0, 0x0} },
328 { EXYNOS5_DISP1_SYS_PWR_REG, { 0x7, 0x0, 0x0} },
329 { EXYNOS5_MAU_SYS_PWR_REG, { 0x7, 0x7, 0x0} },
330 { EXYNOS5_CMU_CLKSTOP_GSCL_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
331 { EXYNOS5_CMU_CLKSTOP_ISP_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
332 { EXYNOS5_CMU_CLKSTOP_MFC_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
333 { EXYNOS5_CMU_CLKSTOP_G3D_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
334 { EXYNOS5_CMU_CLKSTOP_DISP1_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
335 { EXYNOS5_CMU_CLKSTOP_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
336 { EXYNOS5_CMU_SYSCLK_GSCL_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
337 { EXYNOS5_CMU_SYSCLK_ISP_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
338 { EXYNOS5_CMU_SYSCLK_MFC_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
339 { EXYNOS5_CMU_SYSCLK_G3D_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
340 { EXYNOS5_CMU_SYSCLK_DISP1_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
341 { EXYNOS5_CMU_SYSCLK_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
342 { EXYNOS5_CMU_RESET_GSCL_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
343 { EXYNOS5_CMU_RESET_ISP_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
344 { EXYNOS5_CMU_RESET_MFC_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
345 { EXYNOS5_CMU_RESET_G3D_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
346 { EXYNOS5_CMU_RESET_DISP1_SYS_PWR_REG, { 0x1, 0x0, 0x0} },
347 { EXYNOS5_CMU_RESET_MAU_SYS_PWR_REG, { 0x1, 0x1, 0x0} },
348 { PMU_TABLE_END,},
349};
350
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900351static unsigned int const exynos5_list_both_cnt_feed[] = {
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900352 EXYNOS5_ARM_CORE0_OPTION,
353 EXYNOS5_ARM_CORE1_OPTION,
354 EXYNOS5_ARM_COMMON_OPTION,
355 EXYNOS5_GSCL_OPTION,
356 EXYNOS5_ISP_OPTION,
357 EXYNOS5_MFC_OPTION,
358 EXYNOS5_G3D_OPTION,
359 EXYNOS5_DISP1_OPTION,
360 EXYNOS5_MAU_OPTION,
361 EXYNOS5_TOP_PWR_OPTION,
362 EXYNOS5_TOP_PWR_SYSMEM_OPTION,
363};
364
Pankaj Dubeyd4c6c6c2014-11-07 08:30:33 +0900365static unsigned int const exynos5_list_disable_wfi_wfe[] = {
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900366 EXYNOS5_ARM_CORE1_OPTION,
367 EXYNOS5_FSYS_ARM_OPTION,
368 EXYNOS5_ISP_ARM_OPTION,
369};
370
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900371static void exynos5_powerdown_conf(enum sys_powerdown mode)
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900372{
373 unsigned int i;
374 unsigned int tmp;
375
376 /*
377 * Enable both SC_FEEDBACK and SC_COUNTER
378 */
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900379 for (i = 0; i < ARRAY_SIZE(exynos5_list_both_cnt_feed); i++) {
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900380 tmp = pmu_raw_readl(exynos5_list_both_cnt_feed[i]);
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900381 tmp |= (EXYNOS5_USE_SC_FEEDBACK |
382 EXYNOS5_USE_SC_COUNTER);
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900383 pmu_raw_writel(tmp, exynos5_list_both_cnt_feed[i]);
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900384 }
385
386 /*
387 * SKIP_DEACTIVATE_ACEACP_IN_PWDN_BITFIELD Enable
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900388 */
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900389 tmp = pmu_raw_readl(EXYNOS5_ARM_COMMON_OPTION);
Inderpal Singh088584612013-04-29 17:01:47 +0530390 tmp |= EXYNOS5_SKIP_DEACTIVATE_ACEACP_IN_PWDN;
Pankaj Dubey2e94ac42014-07-19 03:43:22 +0900391 pmu_raw_writel(tmp, EXYNOS5_ARM_COMMON_OPTION);
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900392
393 /*
394 * Disable WFI/WFE on XXX_OPTION
395 */
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900396 for (i = 0; i < ARRAY_SIZE(exynos5_list_disable_wfi_wfe); i++) {
Pankaj Dubeyd4c6c6c2014-11-07 08:30:33 +0900397 tmp = pmu_raw_readl(exynos5_list_disable_wfi_wfe[i]);
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900398 tmp &= ~(EXYNOS5_OPTION_USE_STANDBYWFE |
399 EXYNOS5_OPTION_USE_STANDBYWFI);
Pankaj Dubeyd4c6c6c2014-11-07 08:30:33 +0900400 pmu_raw_writel(tmp, exynos5_list_disable_wfi_wfe[i]);
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900401 }
402}
403
Jongpill Lee7d44d2b2012-02-17 09:51:31 +0900404void exynos_sys_powerdown_conf(enum sys_powerdown mode)
Jaecheol Leee28e3012011-07-18 19:21:23 +0900405{
Jongpill Lee0dba4dc2011-09-27 07:22:11 +0900406 unsigned int i;
Jaecheol Leee28e3012011-07-18 19:21:23 +0900407
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900408 const struct exynos_pmu_data *pmu_data = pmu_context->pmu_data;
Jongpill Lee60e49ca2012-02-17 12:23:51 +0900409
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900410 if (pmu_data->powerdown_conf)
411 pmu_data->powerdown_conf(mode);
Inderpal Singh5ddfa842012-05-15 00:20:09 +0900412
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900413 if (pmu_data->pmu_config) {
414 for (i = 0; (pmu_data->pmu_config[i].offset != PMU_TABLE_END); i++)
415 pmu_raw_writel(pmu_data->pmu_config[i].val[mode],
416 pmu_data->pmu_config[i].offset);
417 }
418
419 if (pmu_data->pmu_config_extra) {
420 for (i = 0; pmu_data->pmu_config_extra[i].offset != PMU_TABLE_END; i++)
421 pmu_raw_writel(pmu_data->pmu_config_extra[i].val[mode],
422 pmu_data->pmu_config_extra[i].offset);
Inderpal Singh5ddfa842012-05-15 00:20:09 +0900423 }
Jaecheol Leee28e3012011-07-18 19:21:23 +0900424}
Jongpill Lee0dba4dc2011-09-27 07:22:11 +0900425
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900426static void exynos5250_pmu_init(void)
427{
428 unsigned int value;
429 /*
430 * When SYS_WDTRESET is set, watchdog timer reset request
431 * is ignored by power management unit.
432 */
433 value = pmu_raw_readl(EXYNOS5_AUTO_WDTRESET_DISABLE);
434 value &= ~EXYNOS5_SYS_WDTRESET;
435 pmu_raw_writel(value, EXYNOS5_AUTO_WDTRESET_DISABLE);
436
437 value = pmu_raw_readl(EXYNOS5_MASK_WDTRESET_REQUEST);
438 value &= ~EXYNOS5_SYS_WDTRESET;
439 pmu_raw_writel(value, EXYNOS5_MASK_WDTRESET_REQUEST);
440}
441
442static const struct exynos_pmu_data exynos4210_pmu_data = {
443 .pmu_config = exynos4210_pmu_config,
444};
445
446static const struct exynos_pmu_data exynos4212_pmu_data = {
447 .pmu_config = exynos4x12_pmu_config,
448};
449
450static const struct exynos_pmu_data exynos4412_pmu_data = {
451 .pmu_config = exynos4x12_pmu_config,
452 .pmu_config_extra = exynos4412_pmu_config,
453};
454
455static const struct exynos_pmu_data exynos5250_pmu_data = {
456 .pmu_config = exynos5250_pmu_config,
457 .pmu_init = exynos5250_pmu_init,
458 .powerdown_conf = exynos5_powerdown_conf,
459};
460
461/*
462 * PMU platform driver and devicetree bindings.
463 */
464static const struct of_device_id exynos_pmu_of_device_ids[] = {
465 {
466 .compatible = "samsung,exynos4210-pmu",
467 .data = &exynos4210_pmu_data,
468 }, {
469 .compatible = "samsung,exynos4212-pmu",
470 .data = &exynos4212_pmu_data,
471 }, {
472 .compatible = "samsung,exynos4412-pmu",
473 .data = &exynos4412_pmu_data,
474 }, {
475 .compatible = "samsung,exynos5250-pmu",
476 .data = &exynos5250_pmu_data,
477 },
478 { /*sentinel*/ },
479};
480
481static int exynos_pmu_probe(struct platform_device *pdev)
482{
483 const struct of_device_id *match;
484 struct device *dev = &pdev->dev;
485 struct resource *res;
486
487 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
488 pmu_base_addr = devm_ioremap_resource(dev, res);
489 if (IS_ERR(pmu_base_addr))
490 return PTR_ERR(pmu_base_addr);
491
492 pmu_context = devm_kzalloc(&pdev->dev,
493 sizeof(struct exynos_pmu_context),
494 GFP_KERNEL);
495 if (!pmu_context) {
496 dev_err(dev, "Cannot allocate memory.\n");
497 return -ENOMEM;
498 }
499 pmu_context->dev = dev;
500
501 match = of_match_node(exynos_pmu_of_device_ids, dev->of_node);
502
503 pmu_context->pmu_data = match->data;
504
505 if (pmu_context->pmu_data->pmu_init)
506 pmu_context->pmu_data->pmu_init();
507
508 platform_set_drvdata(pdev, pmu_context);
509
510 dev_dbg(dev, "Exynos PMU Driver probe done\n");
511 return 0;
512}
513
514static struct platform_driver exynos_pmu_driver = {
515 .driver = {
516 .name = "exynos-pmu",
517 .owner = THIS_MODULE,
518 .of_match_table = exynos_pmu_of_device_ids,
519 },
520 .probe = exynos_pmu_probe,
521};
522
Jongpill Lee7d44d2b2012-02-17 09:51:31 +0900523static int __init exynos_pmu_init(void)
Jongpill Lee0dba4dc2011-09-27 07:22:11 +0900524{
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900525 return platform_driver_register(&exynos_pmu_driver);
Jonghwan Choi7d896aa2012-06-27 09:47:35 +0900526
Jongpill Lee0dba4dc2011-09-27 07:22:11 +0900527}
Pankaj Dubey14fc8b92014-11-07 09:26:40 +0900528postcore_initcall(exynos_pmu_init);