1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
/*
* Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved.
* http://www.samsung.com
*
* Chip Abstraction Layer for System power down support
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifdef CONFIG_CAL_SYS_PWRDOWN
/* for OS */
#include <linux/types.h>
#include <linux/io.h>
#include <mach/pmu_cal_sys.h>
#else
/* for firmware */
#include "util.h"
#include "pmu_cal_sys_exynos7580.h"
struct exynos_pmu_conf {
unsigned long reg;
unsigned int val[NUM_SYS_POWERDOWN];
};
#endif
#define writebits(addr, base, mask, val) \
__raw_writel((__raw_readl(addr) & ~((mask) << (base))) | \
(((mask) & (val)) << (base)), addr)
#define readbits(addr, base, mask) \
((__raw_readl(addr) >> (base)) & (mask))
static struct exynos_pmu_conf exynos7580_pmu_config[] = {
/* { .addr = address, .val = { AFTR, DSTOP, DSTOP_PSR, LPD, LPA, CP_Call, SLEEP } } */
{ CPU_CPU0_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ DIS_IRQ_CPU_CPU0_LOCAL_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ DIS_IRQ_CPU_CPU0_CENTRAL_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ DIS_IRQ_CPU_CPU0_CPUSEQUENCER_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ CPU_CPU1_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ DIS_IRQ_CPU_CPU1_LOCAL_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ DIS_IRQ_CPU_CPU1_CENTRAL_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ DIS_IRQ_CPU_CPU1_CPUSEQUENCER_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ CPU_CPU2_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ DIS_IRQ_CPU_CPU2_LOCAL_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 ,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 RESET_CMU_ISP_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ RESET_CMU_MFCMSCL_SYS_PWR_REG, { 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 } },
{ NULL, },
};
static struct exynos_pmu_conf exynos7580_pmu_option[] = {
/* { .addr = address, .val = { AFTR, DSTOP, DSTOP_PSR, LPD, LPA, CP_Call, SLEEP } } */
{ PMU_SYNC_CTRL, { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 } },
{ WAKEUP_MASK_MIF, { 0x100013, 0x100013, 0x100013, 0x100013, 0x100013, 0x100013, 0x100013 } },
{ MEMORY_TOP_OPTION, { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 } },
{ MEMORY_IMEM_OPTION, { 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 } },
{ NULL, },
};
static void set_pmu_sys_pwr_reg(enum sys_powerdown mode)
{
int i;
for (i = 0; exynos7580_pmu_config[i].reg != NULL; i++)
__raw_writel(exynos7580_pmu_config[i].val[mode],
exynos7580_pmu_config[i].reg);
for (i = 0; exynos7580_pmu_option[i].reg != NULL; i++)
__raw_writel(exynos7580_pmu_option[i].val[mode],
exynos7580_pmu_option[i].reg);
}
static void set_pmu_central_seq(bool enable)
{
unsigned int tmp;
#define CENTRALSEQ_PWR_CFG 0x10000
/* central sequencer */
tmp = __raw_readl(CENTRAL_SEQ_CONFIGURATION);
if (enable)
tmp &= ~CENTRALSEQ_PWR_CFG;
else
tmp |= CENTRALSEQ_PWR_CFG;
__raw_writel(tmp, CENTRAL_SEQ_CONFIGURATION);
/* central sequencer MIF */
tmp = __raw_readl(CENTRAL_SEQ_MIF_CONFIGURATION);
if (enable)
tmp &= ~CENTRALSEQ_PWR_CFG;
else
tmp |= CENTRALSEQ_PWR_CFG;
__raw_writel(tmp, CENTRAL_SEQ_MIF_CONFIGURATION);
}
static void set_pmu_pad_retention_release(void)
{
#define PAD_INITIATE_WAKEUP (0x1 << 28)
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_MMC2_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_TOP_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_UART_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_MMC0_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_MMC1_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_EBIA_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_EBIB_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_SPI_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_MIF_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_USBXTI_OPTION);
__raw_writel(PAD_INITIATE_WAKEUP, PAD_RETENTION_BOOTLDO_OPTION);
}
static void init_pmu_l2_option(void)
{
int cluster;
unsigned int tmp;
#define L2_OPTION(_nr) (CPU_L2_OPTION + (_nr) * 0x20)
#define USE_AUTOMATIC_L2FLUSHREQ (0x1 << 17)
#define USE_STANDBYWFIL2 (0x1 << 16)
#define USE_RETENTION (0x1 << 4)
/* disable automatic L2 flush */
/* disable L2 retention */
/* eanble STANDBYWFIL2 ATLAS only */
for (cluster = 0; cluster < 2; cluster++) {
tmp = __raw_readl(L2_OPTION(cluster));
tmp &= ~(USE_AUTOMATIC_L2FLUSHREQ | USE_RETENTION);
tmp |= USE_STANDBYWFIL2;
__raw_writel(tmp, L2_OPTION(cluster));
}
}
static void init_pmu_cpu_option(void)
{
int cpu;
unsigned int tmp;
#define CPU_OPTION(_nr) (CPU_CPU0_OPTION + (_nr) * 0x80)
#define USE_SMPEN (0x1 << 28)
#define USE_STANDBYWFE (0x1 << 24)
#define USE_STANDBYWFI (0x1 << 16)
#define USE_SC_FEEDBACK (0x1 << 1)
#define USE_SC_COUNTER (0x1 << 0)
/* use both sc_counter and sc_feedback */
/* enable to wait for low SMP-bit at sys power down */
for (cpu = 0; cpu < 8; cpu++) {
tmp = __raw_readl(CPU_OPTION(cpu));
tmp |= (USE_SC_FEEDBACK | USE_SC_COUNTER);
tmp |= USE_SMPEN;
tmp |= USE_STANDBYWFI;
tmp &= ~USE_STANDBYWFE;
__raw_writel(tmp, CPU_OPTION(cpu));
}
#define CPU_DURATION(_nr) (CPU_CPU0_DURATION0 + (_nr) * 0x80)
#define DUR_WAIT_RESET (0xF << 20)
#define DUR_SCALL (0xF << 4)
#define DUR_SCALL_VALUE (0x1 << 4)
for (cpu = 0; cpu < 8; cpu++) {
tmp = __raw_readl(CPU_DURATION(cpu));
tmp |= DUR_WAIT_RESET;
tmp &= ~DUR_SCALL;
tmp |= DUR_SCALL_VALUE;
__raw_writel(tmp, CPU_DURATION(cpu));
}
}
static void init_pmu_up_scheduler(void)
{
unsigned int tmp;
#define ENABLE_APL_CPU (0x1 << 1)
#define ENABLE_CPU_CPU (0x1 << 0)
tmp = __raw_readl(UP_SCHEDULER);
tmp |= ENABLE_CPU_CPU;
tmp |= ENABLE_APL_CPU;
__raw_writel(tmp, UP_SCHEDULER);
}
static void __iomem *feed_list[] = {
CPU_NONCPU_OPTION,
APL_NONCPU_OPTION,
TOP_PWR_OPTION,
TOP_PWR_MIF_OPTION,
DISP_OPTION,
ISP_OPTION,
MFCMSCL_OPTION,
AUD_OPTION,
};
static void init_pmu_feedback(void)
{
int i;
unsigned int tmp;
#define ARR_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
for (i = 0; i < ARR_SIZE(feed_list); i++) {
tmp = __raw_readl(feed_list[i]);
tmp &= ~USE_SC_COUNTER;
tmp |= USE_SC_FEEDBACK;
__raw_writel(tmp, feed_list);
}
}
static void init_pmu_G3D_option(void)
{
unsigned int tmp1;
unsigned int tmp2;
#define DUR_SCPRE_G3D (0xF << 8)
#define DUR_SCPRE_VALUE_G3D (0x4FF << 4)
#define DUR_SCALL_G3D (0xF << 4)
#define DUR_SCALL_VALUE_G3D (0x4FF << 4)
tmp1 = __raw_readl(G3D_OPTION);
tmp1 &= ~USE_SC_FEEDBACK;
tmp1 |= USE_SC_COUNTER;
__raw_writel(tmp1, G3D_OPTION);
tmp2 = __raw_readl(G3D_DURATION0);
tmp2 &= ~DUR_SCPRE_G3D;
tmp2 |= DUR_SCPRE_VALUE_G3D;
tmp2 &= ~DUR_SCALL_G3D;
tmp2 |= DUR_SCALL_VALUE_G3D;
__raw_writel(tmp2, G3D_DURATION0);
}
/*
* CAL 1.0 API
* function: pmu_cal_sys_init
* description: default settings at boot time
*/
void pmu_cal_sys_init(void)
{
init_pmu_feedback();
init_pmu_up_scheduler();
init_pmu_cpu_option();
init_pmu_l2_option();
init_pmu_G3D_option();
pr_info("EXYNOS7580 PMU CAL Initialize\n");
}
/*
* CAL 1.0 API
* function: pmu_cal_sys_prepare
* description: settings before going to system power down
*/
void pmu_cal_sys_prepare(enum sys_powerdown mode)
{
set_pmu_sys_pwr_reg(mode);
set_pmu_central_seq(true);
}
/*
* CAL 1.0 API
* function: pmu_cal_sys_post
* description: settings after normal wakeup
*/
void pmu_cal_sys_post(enum sys_powerdown mode)
{
set_pmu_pad_retention_release();
}
/*
* CAL 1.0 API
* function: pmu_cal_sys_post
* description: settings after early wakeup
*/
void pmu_cal_sys_earlywake(enum sys_powerdown mode)
{
set_pmu_central_seq(false);
}
#ifdef CONFIG_CAL_SYS_PWRDOWN
static const struct pmu_cal_sys_ops sys_ops = {
.sys_init = pmu_cal_sys_init,
.sys_prepare = pmu_cal_sys_prepare,
.sys_post = pmu_cal_sys_post,
.sys_earlywake = pmu_cal_sys_earlywake,
};
void register_pmu_cal_sys_ops(const struct pmu_cal_sys_ops **cal)
{
*cal = &sys_ops;
}
#endif
|