summaryrefstree
path: root/kernel/arch/arm/mach-exynos/pmu_cal_sys_exynos5433.c
blob: 7d573e49cc8caae4b6c2693ccbce08d426d6e23f (plain)
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
/*
 * 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
#include <linux/types.h>
#include <linux/io.h>
#include <mach/pmu_cal_sys.h>
#else
/* firmware only */
#include "util.h"
#include "pmu_cal_sys_exynos5433.h"
struct exynos_pmu_conf {
	unsigned int reg;
	unsigned int val[NUM_SYS_POWERDOWN];
};
#define PMU_TABLE_END		NULL
#endif

#define	CENTRAL_LOWPWR_CFG	0x10000

#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 exynos5433_pmu_config[] = {
	/* { .addr = address, .val = { AFTR, STOP, DSTOP, DSTOP_PSR, LPD, LPA, AL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x0, 0x0, 0x0, 0x0, 0x0 } },
	{ CAM0_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ MSCL_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ G3D_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ DISP_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0xF, 0xF, 0x0, 0x0, 0x0 } },
	{ CAM1_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ AUD_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0xF, 0xF, 0x0 } },
	{ FSYS_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ BUS2_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0xF, 0x0, 0x0, 0x0 } },
	{ G2D_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ ISP_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ MFC_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ HEVC_SYS_PWR_REG,				{ 0xF, 0xF, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 } },
	{ RESET_SLEEP_FSYS_SYS_PWR_REG,			{ 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0 } },
	{ RESET_SLEEP_BUS2_SYS_PWR_REG,			{ 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0 } },
	{ PMU_TABLE_END, },
};

void set_pmu_sys_pwr_reg_conf(enum sys_powerdown mode)
{
	unsigned int i;

	for (i = 0; exynos5433_pmu_config[i].reg != PMU_TABLE_END; i++)
		__raw_writel(exynos5433_pmu_config[i].val[mode],
				exynos5433_pmu_config[i].reg);
}

void set_pmu_central_seq_mif_conf(bool enabled)
{
	unsigned long tmp;

	tmp = __raw_readl(CENTRAL_SEQ_MIF_CONFIGURATION);
	tmp = enabled ? tmp & ~CENTRAL_LOWPWR_CFG : tmp | CENTRAL_LOWPWR_CFG;
	__raw_writel(tmp, CENTRAL_SEQ_MIF_CONFIGURATION);
}

void set_pmu_central_seq_conf(bool enabled)
{
	unsigned long tmp;

	tmp = __raw_readl(CENTRAL_SEQ_CONFIGURATION);
	tmp = enabled ? tmp & ~CENTRAL_LOWPWR_CFG : tmp | CENTRAL_LOWPWR_CFG;
	__raw_writel(tmp, CENTRAL_SEQ_CONFIGURATION);

	set_pmu_central_seq_mif_conf(enabled);
}

void set_pmu_prepare_sys_powerdown(enum sys_powerdown mode)
{
	if (mode == SYS_SLEEP) {
		writebits(ATLAS_NONCPU_OPTION, 2, 1, 1);
		writebits(ATLAS_NONCPU_OPTION, 3, 1, 0);
		writebits(ATLAS_L2_OPTION, 4, 1, 0);
		writebits(APOLLO_NONCPU_OPTION, 2, 1, 1);
		writebits(APOLLO_NONCPU_OPTION, 3, 1, 0);
		writebits(APOLLO_L2_OPTION, 4, 1, 0);
	} else {
		writebits(ATLAS_NONCPU_OPTION, 2, 1, 1);
		writebits(ATLAS_NONCPU_OPTION, 3, 1, 1);
		writebits(ATLAS_L2_OPTION, 4, 1, 1);
		writebits(APOLLO_NONCPU_OPTION, 2, 1, 1);
		writebits(APOLLO_NONCPU_OPTION, 3, 1, 1);
		writebits(APOLLO_L2_OPTION, 4, 1, 1);
	}

#ifdef EVT1	/* FIXME: use vma */
	Outp32(0x105c2608, 0x10);
	Outp32(0x105c2628, 0x10);

	Outp32(0x105c2408, 0x01);
	Outp32(0x105c2428, 0x01);
#endif

	/*
	 * FIXME: use vma
	 * workaround for audio block h-prime evt0 evt1 .2014/03/15 phk
	 * SetBits(0x11820020, 7, 0x1, 0x1);	// aud_option scfeedback
	 * LPI_MASK_ATLAS_ASYNCBRIDGE ATB_AUD_CSSYS Disable LPI
	 * power mode enter LPI Mask from EVT0
	 *
	 * writebits(0x11820020, 7, 0x1, 0x1);
	 */
}

void set_pmu_early_wakeup(enum sys_powerdown mode)
{
	set_pmu_central_seq_conf(false);
}

#ifdef CONFIG_CAL_SYS_PWRDOWN
void pmu_cal_sys_init(void)
{
	exynos_sys_powerdown_conf = set_pmu_sys_pwr_reg_conf;
	exynos_central_sequencer_ctrl = set_pmu_central_seq_conf;
}
#endif