summaryrefslogtreecommitdiff
path: root/arch/arm/include/asm/arch-rockchip/cru_rk3188.h
blob: eec4815bbc06a3a279a2e174ed6a7a752d80cf92 (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
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * (C) Copyright 2016 Heiko Stuebner <heiko@sntech.de>
 */
#ifndef _ASM_ARCH_CRU_RK3188_H
#define _ASM_ARCH_CRU_RK3188_H

#define OSC_HZ		(24 * 1000 * 1000)

#define APLL_HZ		(1608 * 1000000)
#define APLL_SAFE_HZ	(600 * 1000000)
#define GPLL_HZ		(594 * 1000000)
#define CPLL_HZ		(384 * 1000000)

/* The SRAM is clocked off aclk_cpu, so we want to max it out for boot speed */
#define CPU_ACLK_HZ	297000000
#define CPU_HCLK_HZ	148500000
#define CPU_PCLK_HZ	74250000
#define CPU_H2P_HZ	74250000

#define PERI_ACLK_HZ	148500000
#define PERI_HCLK_HZ	148500000
#define PERI_PCLK_HZ	74250000

/* Private data for the clock driver - used by rockchip_get_cru() */
struct rk3188_clk_priv {
	struct rk3188_grf *grf;
	struct rk3188_cru *cru;
	ulong rate;
	bool has_bwadj;
};

struct rk3188_cru {
	struct rk3188_pll {
		u32 con0;
		u32 con1;
		u32 con2;
		u32 con3;
	} pll[4];
	u32 cru_mode_con;
	u32 cru_clksel_con[35];
	u32 cru_clkgate_con[10];
	u32 reserved1[2];
	u32 cru_glb_srst_fst_value;
	u32 cru_glb_srst_snd_value;
	u32 reserved2[2];
	u32 cru_softrst_con[9];
	u32 cru_misc_con;
	u32 reserved3[2];
	u32 cru_glb_cnt_th;
};
check_member(rk3188_cru, cru_glb_cnt_th, 0x0140);

/* CRU_CLKSEL0_CON */
enum {
	/* a9_core_div: core = core_src / (a9_core_div + 1) */
	A9_CORE_DIV_SHIFT	= 9,
	A9_CORE_DIV_MASK	= 0x1f,
	CORE_PLL_SHIFT		= 8,
	CORE_PLL_MASK		= 1,
	CORE_PLL_SELECT_APLL	= 0,
	CORE_PLL_SELECT_GPLL,

	/* core peri div: core:core_peri = 2:1, 4:1, 8:1 or 16:1 */
	CORE_PERI_DIV_SHIFT	= 6,
	CORE_PERI_DIV_MASK	= 3,

	/* aclk_cpu pll selection */
	CPU_ACLK_PLL_SHIFT	= 5,
	CPU_ACLK_PLL_MASK	= 1,
	CPU_ACLK_PLL_SELECT_APLL	= 0,
	CPU_ACLK_PLL_SELECT_GPLL,

	/* a9_cpu_div: aclk_cpu = cpu_src / (a9_cpu_div + 1) */
	A9_CPU_DIV_SHIFT	= 0,
	A9_CPU_DIV_MASK		= 0x1f,
};

/* CRU_CLKSEL1_CON */
enum {
	/* ahb2apb_pclk_div: hclk_cpu:pclk_cpu = 1:1, 2:1 or 4:1 */
	AHB2APB_DIV_SHIFT	= 14,
	AHB2APB_DIV_MASK	= 3,

	/* cpu_pclk_div: aclk_cpu:pclk_cpu = 1:1, 2:1, 4:1 or 8:1 */
	CPU_PCLK_DIV_SHIFT	= 12,
	CPU_PCLK_DIV_MASK	= 3,

	/* cpu_hclk_div: aclk_cpu:hclk_cpu = 1:1, 2:1 or 4:1 */
	CPU_HCLK_DIV_SHIFT	= 8,
	CPU_HCLK_DIV_MASK	= 3,

	/* core_aclk_div: cire:aclk_core = 1:1, 2:1, 3:1, 4:1 or 8:1 */
	CORE_ACLK_DIV_SHIFT	= 3,
	CORE_ACLK_DIV_MASK	= 7,
};

/* CRU_CLKSEL10_CON */
enum {
	PERI_SEL_PLL_MASK	= 1,
	PERI_SEL_PLL_SHIFT	= 15,
	PERI_SEL_CPLL		= 0,
	PERI_SEL_GPLL,

	/* peri pclk div: aclk_bus:pclk_bus = 1:1, 2:1, 4:1 or 8:1 */
	PERI_PCLK_DIV_SHIFT	= 12,
	PERI_PCLK_DIV_MASK	= 3,

	/* peripheral bus hclk div:aclk_bus: hclk_bus = 1:1, 2:1 or 4:1 */
	PERI_HCLK_DIV_SHIFT	= 8,
	PERI_HCLK_DIV_MASK	= 3,

	/* peri aclk div: aclk_peri = periph_src / (peri_aclk_div + 1) */
	PERI_ACLK_DIV_SHIFT	= 0,
	PERI_ACLK_DIV_MASK	= 0x1f,
};
/* CRU_CLKSEL11_CON */
enum {
	HSICPHY_DIV_SHIFT	= 8,
	HSICPHY_DIV_MASK	= 0x3f,

	MMC0_DIV_SHIFT		= 0,
	MMC0_DIV_MASK		= 0x3f,
};

/* CRU_CLKSEL12_CON */
enum {
	UART_PLL_SHIFT		= 15,
	UART_PLL_MASK		= 1,
	UART_PLL_SELECT_GENERAL	= 0,
	UART_PLL_SELECT_CODEC,

	EMMC_DIV_SHIFT		= 8,
	EMMC_DIV_MASK		= 0x3f,

	SDIO_DIV_SHIFT		= 0,
	SDIO_DIV_MASK		= 0x3f,
};

/* CRU_CLKSEL25_CON */
enum {
	SPI1_DIV_SHIFT		= 8,
	SPI1_DIV_MASK		= 0x7f,

	SPI0_DIV_SHIFT		= 0,
	SPI0_DIV_MASK		= 0x7f,
};

/* CRU_MODE_CON */
enum {
	GPLL_MODE_SHIFT		= 12,
	GPLL_MODE_MASK		= 3,
	GPLL_MODE_SLOW		= 0,
	GPLL_MODE_NORMAL,
	GPLL_MODE_DEEP,

	CPLL_MODE_SHIFT		= 8,
	CPLL_MODE_MASK		= 3,
	CPLL_MODE_SLOW		= 0,
	CPLL_MODE_NORMAL,
	CPLL_MODE_DEEP,

	DPLL_MODE_SHIFT		= 4,
	DPLL_MODE_MASK		= 3,
	DPLL_MODE_SLOW		= 0,
	DPLL_MODE_NORMAL,
	DPLL_MODE_DEEP,

	APLL_MODE_SHIFT		= 0,
	APLL_MODE_MASK		= 3,
	APLL_MODE_SLOW		= 0,
	APLL_MODE_NORMAL,
	APLL_MODE_DEEP,
};

/* CRU_APLL_CON0 */
enum {
	CLKR_SHIFT		= 8,
	CLKR_MASK		= 0x3f,

	CLKOD_SHIFT		= 0,
	CLKOD_MASK		= 0x3f,
};

/* CRU_APLL_CON1 */
enum {
	CLKF_SHIFT		= 0,
	CLKF_MASK		= 0x1fff,
};

#endif