blob: 696b386759afc437222870548ebcfd81526c33f8 [file] [log] [blame]
Chander Kashyaped2e25a2012-02-05 23:01:47 +00001/*
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +00002 * Machine Specific Values for SMDK5250 board based on EXYNOS5
Chander Kashyaped2e25a2012-02-05 23:01:47 +00003 *
4 * Copyright (C) 2012 Samsung Electronics
5 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Chander Kashyaped2e25a2012-02-05 23:01:47 +00007 */
8
9#ifndef _SMDK5250_SETUP_H
10#define _SMDK5250_SETUP_H
11
12#include <config.h>
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000013#include <asm/arch/dmc.h>
Chander Kashyaped2e25a2012-02-05 23:01:47 +000014
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000015/* APLL_CON1 */
Chander Kashyaped2e25a2012-02-05 23:01:47 +000016#define APLL_CON1_VAL (0x00203800)
17
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000018/* MPLL_CON1 */
19#define MPLL_CON1_VAL (0x00203800)
Chander Kashyaped2e25a2012-02-05 23:01:47 +000020
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000021/* CPLL_CON1 */
Chander Kashyaped2e25a2012-02-05 23:01:47 +000022#define CPLL_CON1_VAL (0x00203800)
23
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000024/* GPLL_CON1 */
25#define GPLL_CON1_VAL (0x00203800)
Chander Kashyaped2e25a2012-02-05 23:01:47 +000026
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000027/* EPLL_CON1, CON2 */
Chander Kashyaped2e25a2012-02-05 23:01:47 +000028#define EPLL_CON1_VAL 0x00000000
29#define EPLL_CON2_VAL 0x00000080
30
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000031/* VPLL_CON1, CON2 */
Chander Kashyaped2e25a2012-02-05 23:01:47 +000032#define VPLL_CON1_VAL 0x00000000
33#define VPLL_CON2_VAL 0x00000080
34
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000035/* BPLL_CON1 */
Chander Kashyaped2e25a2012-02-05 23:01:47 +000036#define BPLL_CON1_VAL 0x00203800
37
38/* Set PLL */
39#define set_pll(mdiv, pdiv, sdiv) (1<<31 | mdiv<<16 | pdiv<<8 | sdiv)
40
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000041/* CLK_SRC_CPU */
42/* 0 = MOUTAPLL, 1 = SCLKMPLL */
43#define MUX_HPM_SEL 0
44#define MUX_CPU_SEL 0
45#define MUX_APLL_SEL 1
46
47#define CLK_SRC_CPU_VAL ((MUX_HPM_SEL << 20) \
48 | (MUX_CPU_SEL << 16) \
49 | (MUX_APLL_SEL))
50
51/* MEMCONTROL register bit fields */
52#define DMC_MEMCONTROL_CLK_STOP_DISABLE (0 << 0)
53#define DMC_MEMCONTROL_DPWRDN_DISABLE (0 << 1)
54#define DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE (0 << 2)
55#define DMC_MEMCONTROL_TP_DISABLE (0 << 4)
56#define DMC_MEMCONTROL_DSREF_DISABLE (0 << 5)
57#define DMC_MEMCONTROL_DSREF_ENABLE (1 << 5)
58#define DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(x) (x << 6)
59
60#define DMC_MEMCONTROL_MEM_TYPE_LPDDR3 (7 << 8)
61#define DMC_MEMCONTROL_MEM_TYPE_DDR3 (6 << 8)
62#define DMC_MEMCONTROL_MEM_TYPE_LPDDR2 (5 << 8)
63
64#define DMC_MEMCONTROL_MEM_WIDTH_32BIT (2 << 12)
65
66#define DMC_MEMCONTROL_NUM_CHIP_1 (0 << 16)
67#define DMC_MEMCONTROL_NUM_CHIP_2 (1 << 16)
68
69#define DMC_MEMCONTROL_BL_8 (3 << 20)
70#define DMC_MEMCONTROL_BL_4 (2 << 20)
71
72#define DMC_MEMCONTROL_PZQ_DISABLE (0 << 24)
73
74#define DMC_MEMCONTROL_MRR_BYTE_7_0 (0 << 25)
75#define DMC_MEMCONTROL_MRR_BYTE_15_8 (1 << 25)
76#define DMC_MEMCONTROL_MRR_BYTE_23_16 (2 << 25)
77#define DMC_MEMCONTROL_MRR_BYTE_31_24 (3 << 25)
78
79/* MEMCONFIG0 register bit fields */
Rajeshwari Shindebed24422013-07-04 12:29:17 +053080#define DMC_MEMCONFIGX_CHIP_MAP_INTERLEAVED (1 << 12)
81#define DMC_MEMCONFIGX_CHIP_COL_10 (3 << 8)
82#define DMC_MEMCONFIGX_CHIP_ROW_14 (2 << 4)
83#define DMC_MEMCONFIGX_CHIP_ROW_15 (3 << 4)
84#define DMC_MEMCONFIGX_CHIP_BANK_8 (3 << 0)
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000085
Rajeshwari Shindebed24422013-07-04 12:29:17 +053086#define DMC_MEMBASECONFIGX_CHIP_BASE(x) (x << 16)
87#define DMC_MEMBASECONFIGX_CHIP_MASK(x) (x << 0)
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000088#define DMC_MEMBASECONFIG_VAL(x) ( \
Rajeshwari Shindebed24422013-07-04 12:29:17 +053089 DMC_MEMBASECONFIGX_CHIP_BASE(x) | \
90 DMC_MEMBASECONFIGX_CHIP_MASK(0x780) \
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +000091)
92
93#define DMC_MEMBASECONFIG0_VAL DMC_MEMBASECONFIG_VAL(0x40)
94#define DMC_MEMBASECONFIG1_VAL DMC_MEMBASECONFIG_VAL(0x80)
95
96#define DMC_PRECHCONFIG_VAL 0xFF000000
97#define DMC_PWRDNCONFIG_VAL 0xFFFF00FF
98
99#define DMC_CONCONTROL_RESET_VAL 0x0FFF0000
100#define DFI_INIT_START (1 << 28)
101#define EMPTY (1 << 8)
102#define AREF_EN (1 << 5)
103
104#define DFI_INIT_COMPLETE_CHO (1 << 2)
105#define DFI_INIT_COMPLETE_CH1 (1 << 3)
106
107#define RDLVL_COMPLETE_CHO (1 << 14)
108#define RDLVL_COMPLETE_CH1 (1 << 15)
109
110#define CLK_STOP_EN (1 << 0)
111#define DPWRDN_EN (1 << 1)
112#define DSREF_EN (1 << 5)
113
114/* COJCONTROL register bit fields */
115#define DMC_CONCONTROL_IO_PD_CON_DISABLE (0 << 3)
116#define DMC_CONCONTROL_AREF_EN_DISABLE (0 << 5)
117#define DMC_CONCONTROL_EMPTY_DISABLE (0 << 8)
118#define DMC_CONCONTROL_EMPTY_ENABLE (1 << 8)
119#define DMC_CONCONTROL_RD_FETCH_DISABLE (0x0 << 12)
120#define DMC_CONCONTROL_TIMEOUT_LEVEL0 (0xFFF << 16)
121#define DMC_CONCONTROL_DFI_INIT_START_DISABLE (0 << 28)
122
123/* CLK_DIV_CPU0_VAL */
124#define CLK_DIV_CPU0_VAL ((ARM2_RATIO << 28) \
125 | (APLL_RATIO << 24) \
126 | (PCLK_DBG_RATIO << 20) \
127 | (ATB_RATIO << 16) \
128 | (PERIPH_RATIO << 12) \
129 | (ACP_RATIO << 8) \
130 | (CPUD_RATIO << 4) \
131 | (ARM_RATIO))
132
133
134/* CLK_FSYS */
135#define CLK_SRC_FSYS0_VAL 0x66666
136#define CLK_DIV_FSYS0_VAL 0x0BB00000
137
138/* CLK_DIV_CPU1 */
139#define HPM_RATIO 0x2
140#define COPY_RATIO 0x0
141
142/* CLK_DIV_CPU1 = 0x00000003 */
143#define CLK_DIV_CPU1_VAL ((HPM_RATIO << 4) \
144 | (COPY_RATIO))
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000145
146/* CLK_SRC_CORE0 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000147#define CLK_SRC_CORE0_VAL 0x00000000
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000148
149/* CLK_SRC_CORE1 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000150#define CLK_SRC_CORE1_VAL 0x100
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000151
152/* CLK_DIV_CORE0 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000153#define CLK_DIV_CORE0_VAL 0x00120000
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000154
155/* CLK_DIV_CORE1 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000156#define CLK_DIV_CORE1_VAL 0x07070700
157
158/* CLK_DIV_SYSRGT */
159#define CLK_DIV_SYSRGT_VAL 0x00000111
160
161/* CLK_DIV_ACP */
162#define CLK_DIV_ACP_VAL 0x12
163
164/* CLK_DIV_SYSLFT */
165#define CLK_DIV_SYSLFT_VAL 0x00000311
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000166
167/* CLK_SRC_CDREX */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000168#define CLK_SRC_CDREX_VAL 0x1
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000169
170/* CLK_DIV_CDREX */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000171#define MCLK_CDREX2_RATIO 0x0
172#define ACLK_EFCON_RATIO 0x1
173#define MCLK_DPHY_RATIO 0x1
174#define MCLK_CDREX_RATIO 0x1
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000175#define ACLK_C2C_200_RATIO 0x1
176#define C2C_CLK_400_RATIO 0x1
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000177#define PCLK_CDREX_RATIO 0x1
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000178#define ACLK_CDREX_RATIO 0x1
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000179
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000180#define CLK_DIV_CDREX_VAL ((MCLK_DPHY_RATIO << 24) \
181 | (C2C_CLK_400_RATIO << 6) \
182 | (PCLK_CDREX_RATIO << 4) \
183 | (ACLK_CDREX_RATIO))
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000184
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000185/* CLK_SRC_TOP0 */
186#define MUX_ACLK_300_GSCL_SEL 0x0
187#define MUX_ACLK_300_GSCL_MID_SEL 0x0
188#define MUX_ACLK_400_G3D_MID_SEL 0x0
189#define MUX_ACLK_333_SEL 0x0
190#define MUX_ACLK_300_DISP1_SEL 0x0
191#define MUX_ACLK_300_DISP1_MID_SEL 0x0
192#define MUX_ACLK_200_SEL 0x0
193#define MUX_ACLK_166_SEL 0x0
194#define CLK_SRC_TOP0_VAL ((MUX_ACLK_300_GSCL_SEL << 25) \
195 | (MUX_ACLK_300_GSCL_MID_SEL << 24) \
196 | (MUX_ACLK_400_G3D_MID_SEL << 20) \
197 | (MUX_ACLK_333_SEL << 16) \
198 | (MUX_ACLK_300_DISP1_SEL << 15) \
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000199 | (MUX_ACLK_300_DISP1_MID_SEL << 14) \
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000200 | (MUX_ACLK_200_SEL << 12) \
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000201 | (MUX_ACLK_166_SEL << 8))
202
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000203/* CLK_SRC_TOP1 */
204#define MUX_ACLK_400_G3D_SEL 0x1
205#define MUX_ACLK_400_ISP_SEL 0x0
206#define MUX_ACLK_400_IOP_SEL 0x0
207#define MUX_ACLK_MIPI_HSI_TXBASE_SEL 0x0
208#define MUX_ACLK_300_GSCL_MID1_SEL 0x0
209#define MUX_ACLK_300_DISP1_MID1_SEL 0x0
210#define CLK_SRC_TOP1_VAL ((MUX_ACLK_400_G3D_SEL << 28) \
211 |(MUX_ACLK_400_ISP_SEL << 24) \
212 |(MUX_ACLK_400_IOP_SEL << 20) \
213 |(MUX_ACLK_MIPI_HSI_TXBASE_SEL << 16) \
214 |(MUX_ACLK_300_GSCL_MID1_SEL << 12) \
215 |(MUX_ACLK_300_DISP1_MID1_SEL << 8))
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000216
217/* CLK_SRC_TOP2 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000218#define MUX_GPLL_SEL 0x1
219#define MUX_BPLL_USER_SEL 0x0
220#define MUX_MPLL_USER_SEL 0x0
221#define MUX_VPLL_SEL 0x1
222#define MUX_EPLL_SEL 0x1
223#define MUX_CPLL_SEL 0x1
224#define VPLLSRC_SEL 0x0
225#define CLK_SRC_TOP2_VAL ((MUX_GPLL_SEL << 28) \
226 | (MUX_BPLL_USER_SEL << 24) \
227 | (MUX_MPLL_USER_SEL << 20) \
228 | (MUX_VPLL_SEL << 16) \
229 | (MUX_EPLL_SEL << 12) \
230 | (MUX_CPLL_SEL << 8) \
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000231 | (VPLLSRC_SEL))
232/* CLK_SRC_TOP3 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000233#define MUX_ACLK_333_SUB_SEL 0x1
234#define MUX_ACLK_400_SUB_SEL 0x1
235#define MUX_ACLK_266_ISP_SUB_SEL 0x1
236#define MUX_ACLK_266_GPS_SUB_SEL 0x0
237#define MUX_ACLK_300_GSCL_SUB_SEL 0x1
238#define MUX_ACLK_266_GSCL_SUB_SEL 0x1
239#define MUX_ACLK_300_DISP1_SUB_SEL 0x1
240#define MUX_ACLK_200_DISP1_SUB_SEL 0x1
241#define CLK_SRC_TOP3_VAL ((MUX_ACLK_333_SUB_SEL << 24) \
242 | (MUX_ACLK_400_SUB_SEL << 20) \
243 | (MUX_ACLK_266_ISP_SUB_SEL << 16) \
244 | (MUX_ACLK_266_GPS_SUB_SEL << 12) \
245 | (MUX_ACLK_300_GSCL_SUB_SEL << 10) \
246 | (MUX_ACLK_266_GSCL_SUB_SEL << 8) \
247 | (MUX_ACLK_300_DISP1_SUB_SEL << 6) \
248 | (MUX_ACLK_200_DISP1_SUB_SEL << 4))
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000249
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000250/* CLK_DIV_TOP0 */
251#define ACLK_300_DISP1_RATIO 0x2
252#define ACLK_400_G3D_RATIO 0x0
253#define ACLK_333_RATIO 0x0
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000254#define ACLK_266_RATIO 0x2
255#define ACLK_200_RATIO 0x3
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000256#define ACLK_166_RATIO 0x1
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000257#define ACLK_133_RATIO 0x1
258#define ACLK_66_RATIO 0x5
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000259
260#define CLK_DIV_TOP0_VAL ((ACLK_300_DISP1_RATIO << 28) \
261 | (ACLK_400_G3D_RATIO << 24) \
262 | (ACLK_333_RATIO << 20) \
263 | (ACLK_266_RATIO << 16) \
264 | (ACLK_200_RATIO << 12) \
265 | (ACLK_166_RATIO << 8) \
266 | (ACLK_133_RATIO << 4) \
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000267 | (ACLK_66_RATIO))
268
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000269/* CLK_DIV_TOP1 */
270#define ACLK_MIPI_HSI_TX_BASE_RATIO 0x3
271#define ACLK_66_PRE_RATIO 0x1
272#define ACLK_400_ISP_RATIO 0x1
273#define ACLK_400_IOP_RATIO 0x1
274#define ACLK_300_GSCL_RATIO 0x2
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000275
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000276#define CLK_DIV_TOP1_VAL ((ACLK_MIPI_HSI_TX_BASE_RATIO << 28) \
277 | (ACLK_66_PRE_RATIO << 24) \
278 | (ACLK_400_ISP_RATIO << 20) \
279 | (ACLK_400_IOP_RATIO << 16) \
280 | (ACLK_300_GSCL_RATIO << 12))
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000281
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000282/* APLL_LOCK */
283#define APLL_LOCK_VAL (0x546)
284/* MPLL_LOCK */
285#define MPLL_LOCK_VAL (0x546)
286/* CPLL_LOCK */
287#define CPLL_LOCK_VAL (0x546)
288/* GPLL_LOCK */
289#define GPLL_LOCK_VAL (0x546)
290/* EPLL_LOCK */
291#define EPLL_LOCK_VAL (0x3A98)
292/* VPLL_LOCK */
293#define VPLL_LOCK_VAL (0x3A98)
294/* BPLL_LOCK */
295#define BPLL_LOCK_VAL (0x546)
296
297#define MUX_APLL_SEL_MASK (1 << 0)
298#define MUX_MPLL_SEL_MASK (1 << 8)
299#define MPLL_SEL_MOUT_MPLLFOUT (2 << 8)
300#define MUX_CPLL_SEL_MASK (1 << 8)
301#define MUX_EPLL_SEL_MASK (1 << 12)
302#define MUX_VPLL_SEL_MASK (1 << 16)
303#define MUX_GPLL_SEL_MASK (1 << 28)
304#define MUX_BPLL_SEL_MASK (1 << 0)
305#define MUX_HPM_SEL_MASK (1 << 20)
306#define HPM_SEL_SCLK_MPLL (1 << 21)
307#define APLL_CON0_LOCKED (1 << 29)
308#define MPLL_CON0_LOCKED (1 << 29)
309#define BPLL_CON0_LOCKED (1 << 29)
310#define CPLL_CON0_LOCKED (1 << 29)
311#define EPLL_CON0_LOCKED (1 << 29)
312#define GPLL_CON0_LOCKED (1 << 29)
313#define VPLL_CON0_LOCKED (1 << 29)
314#define CLK_REG_DISABLE 0x0
315#define TOP2_VAL 0x0110000
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000316
317/* CLK_SRC_PERIC0 */
Padmavathi Venna6fe023b2013-03-28 04:32:22 +0000318#define PWM_SEL 6
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000319#define UART3_SEL 6
320#define UART2_SEL 6
321#define UART1_SEL 6
322#define UART0_SEL 6
323/* SRC_CLOCK = SCLK_MPLL */
324#define CLK_SRC_PERIC0_VAL ((PWM_SEL << 24) \
325 | (UART3_SEL << 12) \
326 | (UART2_SEL << 8) \
327 | (UART1_SEL << 4) \
328 | (UART0_SEL))
329
330/* CLK_SRC_PERIC1 */
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000331/* SRC_CLOCK = SCLK_MPLL */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000332#define SPI0_SEL 6
333#define SPI1_SEL 6
334#define SPI2_SEL 6
335#define CLK_SRC_PERIC1_VAL ((SPI2_SEL << 24) \
336 | (SPI1_SEL << 20) \
337 | (SPI0_SEL << 16))
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000338
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000339/* SCLK_SRC_ISP - set SPI0/1 to 6 = SCLK_MPLL_USER */
340#define SPI0_ISP_SEL 6
341#define SPI1_ISP_SEL 6
342#define SCLK_SRC_ISP_VAL (SPI1_ISP_SEL << 4) \
343 | (SPI0_ISP_SEL << 0)
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000344
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000345/* SCLK_DIV_ISP - set SPI0/1 to 0xf = divide by 16 */
346#define SPI0_ISP_RATIO 0xf
347#define SPI1_ISP_RATIO 0xf
348#define SCLK_DIV_ISP_VAL (SPI1_ISP_RATIO << 12) \
349 | (SPI0_ISP_RATIO << 0)
350
351/* CLK_DIV_PERIL0 */
352#define UART5_RATIO 7
353#define UART4_RATIO 7
354#define UART3_RATIO 7
355#define UART2_RATIO 7
356#define UART1_RATIO 7
357#define UART0_RATIO 7
358
359#define CLK_DIV_PERIC0_VAL ((UART3_RATIO << 12) \
360 | (UART2_RATIO << 8) \
361 | (UART1_RATIO << 4) \
362 | (UART0_RATIO))
363/* CLK_DIV_PERIC1 */
364#define SPI1_RATIO 0x7
365#define SPI0_RATIO 0xf
366#define SPI1_SUB_RATIO 0x0
367#define SPI0_SUB_RATIO 0x0
368#define CLK_DIV_PERIC1_VAL ((SPI1_SUB_RATIO << 24) \
369 | ((SPI1_RATIO << 16) \
370 | (SPI0_SUB_RATIO << 8) \
371 | (SPI0_RATIO << 0)))
372
373/* CLK_DIV_PERIC2 */
374#define SPI2_RATIO 0xf
375#define SPI2_SUB_RATIO 0x0
376#define CLK_DIV_PERIC2_VAL ((SPI2_SUB_RATIO << 8) \
377 | (SPI2_RATIO << 0))
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000378
379/* CLK_DIV_PERIC3 */
380#define PWM_RATIO 8
381#define CLK_DIV_PERIC3_VAL (PWM_RATIO << 0)
382
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000383/* CLK_DIV_FSYS2 */
384#define MMC2_RATIO_MASK 0xf
385#define MMC2_RATIO_VAL 0x3
386#define MMC2_RATIO_OFFSET 0
387
388#define MMC2_PRE_RATIO_MASK 0xff
389#define MMC2_PRE_RATIO_VAL 0x9
390#define MMC2_PRE_RATIO_OFFSET 8
391
392#define MMC3_RATIO_MASK 0xf
393#define MMC3_RATIO_VAL 0x1
394#define MMC3_RATIO_OFFSET 16
395
396#define MMC3_PRE_RATIO_MASK 0xff
397#define MMC3_PRE_RATIO_VAL 0x0
398#define MMC3_PRE_RATIO_OFFSET 24
399
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000400/* CLK_SRC_LEX */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000401#define CLK_SRC_LEX_VAL 0x0
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000402
403/* CLK_DIV_LEX */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000404#define CLK_DIV_LEX_VAL 0x10
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000405
406/* CLK_DIV_R0X */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000407#define CLK_DIV_R0X_VAL 0x10
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000408
409/* CLK_DIV_L0X */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000410#define CLK_DIV_R1X_VAL 0x10
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000411
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000412/* CLK_DIV_ISP0 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000413#define CLK_DIV_ISP0_VAL 0x31
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000414
415/* CLK_DIV_ISP1 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000416#define CLK_DIV_ISP1_VAL 0x0
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000417
418/* CLK_DIV_ISP2 */
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000419#define CLK_DIV_ISP2_VAL 0x1
420
421/* CLK_SRC_DISP1_0 */
422#define CLK_SRC_DISP1_0_VAL 0x6
423
424/*
425 * DIV_DISP1_0
426 * For DP, divisor should be 2
427 */
428#define CLK_DIV_DISP1_0_FIMD1 (2 << 0)
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000429
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000430/* CLK_GATE_IP_DISP1 */
431#define CLK_GATE_DP1_ALLOW (1 << 4)
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000432
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000433#define DDR3PHY_CTRL_PHY_RESET (1 << 0)
434#define DDR3PHY_CTRL_PHY_RESET_OFF (0 << 0)
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000435
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000436#define PHY_CON0_RESET_VAL 0x17020a40
437#define P0_CMD_EN (1 << 14)
438#define BYTE_RDLVL_EN (1 << 13)
439#define CTRL_SHGATE (1 << 8)
440
441#define PHY_CON1_RESET_VAL 0x09210100
442#define CTRL_GATEDURADJ_MASK (0xf << 20)
443
444#define PHY_CON2_RESET_VAL 0x00010004
445#define INIT_DESKEW_EN (1 << 6)
446#define RDLVL_GATE_EN (1 << 24)
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000447
448/*ZQ Configurations */
449#define PHY_CON16_RESET_VAL 0x08000304
450
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000451#define ZQ_CLK_DIV_EN (1 << 18)
452#define ZQ_MANUAL_STR (1 << 1)
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000453#define ZQ_DONE (1 << 0)
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000454
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000455#define CTRL_RDLVL_GATE_ENABLE 1
456#define CTRL_RDLVL_GATE_DISABLE 1
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000457
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000458/* Direct Command */
459#define DIRECT_CMD_NOP 0x07000000
460#define DIRECT_CMD_PALL 0x01000000
461#define DIRECT_CMD_ZQINIT 0x0a000000
462#define DIRECT_CMD_CHANNEL_SHIFT 28
463#define DIRECT_CMD_CHIP_SHIFT 20
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000464
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000465/* DMC PHY Control0 register */
466#define PHY_CONTROL0_RESET_VAL 0x0
467#define MEM_TERM_EN (1 << 31) /* Termination enable for memory */
468#define PHY_TERM_EN (1 << 30) /* Termination enable for PHY */
469#define DMC_CTRL_SHGATE (1 << 29) /* Duration of DQS gating signal */
470#define FP_RSYNC (1 << 3) /* Force DLL resyncronization */
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000471
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000472/* Driver strength for CK, CKE, CS & CA */
473#define IMP_OUTPUT_DRV_40_OHM 0x5
474#define IMP_OUTPUT_DRV_30_OHM 0x7
475#define CA_CK_DRVR_DS_OFFSET 9
476#define CA_CKE_DRVR_DS_OFFSET 6
477#define CA_CS_DRVR_DS_OFFSET 3
478#define CA_ADR_DRVR_DS_OFFSET 0
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000479
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000480#define PHY_CON42_CTRL_BSTLEN_SHIFT 8
481#define PHY_CON42_CTRL_RDLAT_SHIFT 0
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000482
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000483struct mem_timings;
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000484
Rajeshwari Shinde5f90a4c2012-07-03 20:02:55 +0000485/* Errors that we can encourter in low-level setup */
486enum {
487 SETUP_ERR_OK,
488 SETUP_ERR_RDLV_COMPLETE_TIMEOUT = -1,
489 SETUP_ERR_ZQ_CALIBRATION_FAILURE = -2,
490};
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000491
Rajeshwari Shinde6558d272012-07-03 20:02:56 +0000492/*
493 * Memory variant specific initialization code
494 *
495 * @param mem Memory timings for this memory type.
496 * @param mem_iv_size Memory interleaving size is a configurable parameter
497 * which the DMC uses to decide how to split a memory
498 * chunk into smaller chunks to support concurrent
499 * accesses; may vary across boards.
Rajeshwari Shindebed24422013-07-04 12:29:17 +0530500 * @param reset Reset DDR PHY during initialization.
Rajeshwari Shinde6558d272012-07-03 20:02:56 +0000501 * @return 0 if ok, SETUP_ERR_... if there is a problem
502 */
Rajeshwari Shindebed24422013-07-04 12:29:17 +0530503int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size,
504 int reset);
Rajeshwari Shinde6558d272012-07-03 20:02:56 +0000505
506/*
507 * Configure ZQ I/O interface
508 *
509 * @param mem Memory timings for this memory type.
510 * @param phy0_ctrl Pointer to struct containing PHY0 control reg
511 * @param phy1_ctrl Pointer to struct containing PHY1 control reg
512 * @return 0 if ok, -1 on error
513 */
514int dmc_config_zq(struct mem_timings *mem,
515 struct exynos5_phy_control *phy0_ctrl,
516 struct exynos5_phy_control *phy1_ctrl);
517
518/*
519 * Send NOP and MRS/EMRS Direct commands
520 *
521 * @param mem Memory timings for this memory type.
522 * @param dmc Pointer to struct of DMC registers
523 */
524void dmc_config_mrs(struct mem_timings *mem, struct exynos5_dmc *dmc);
525
526/*
527 * Send PALL Direct commands
528 *
529 * @param mem Memory timings for this memory type.
530 * @param dmc Pointer to struct of DMC registers
531 */
532void dmc_config_prech(struct mem_timings *mem, struct exynos5_dmc *dmc);
533
534/*
535 * Configure the memconfig and membaseconfig registers
536 *
537 * @param mem Memory timings for this memory type.
538 * @param exynos5_dmc Pointer to struct of DMC registers
539 */
540void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc);
541
542/*
543 * Reset the DLL. This function is common between DDR3 and LPDDR2.
544 * However, the reset value is different. So we are passing a flag
545 * ddr_mode to distinguish between LPDDR2 and DDR3.
546 *
547 * @param exynos5_dmc Pointer to struct of DMC registers
548 * @param ddr_mode Type of DDR memory
549 */
550void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
Chander Kashyaped2e25a2012-02-05 23:01:47 +0000551#endif