blob: eb91d131092526a7af038ee29611775b9f8b39ab [file] [log] [blame]
Chander Kashyap0aee53b2012-02-05 23:01:47 +00001/*
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +00002 * Machine Specific Values for SMDK5250 board based on EXYNOS5
Chander Kashyap0aee53b2012-02-05 23:01:47 +00003 *
4 * Copyright (C) 2012 Samsung Electronics
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#ifndef _SMDK5250_SETUP_H
26#define _SMDK5250_SETUP_H
27
28#include <config.h>
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000029#include <asm/arch/dmc.h>
Chander Kashyap0aee53b2012-02-05 23:01:47 +000030
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000031/* APLL_CON1 */
Chander Kashyap0aee53b2012-02-05 23:01:47 +000032#define APLL_CON1_VAL (0x00203800)
33
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000034/* MPLL_CON1 */
35#define MPLL_CON1_VAL (0x00203800)
Chander Kashyap0aee53b2012-02-05 23:01:47 +000036
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000037/* CPLL_CON1 */
Chander Kashyap0aee53b2012-02-05 23:01:47 +000038#define CPLL_CON1_VAL (0x00203800)
39
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000040/* GPLL_CON1 */
41#define GPLL_CON1_VAL (0x00203800)
Chander Kashyap0aee53b2012-02-05 23:01:47 +000042
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000043/* EPLL_CON1, CON2 */
Chander Kashyap0aee53b2012-02-05 23:01:47 +000044#define EPLL_CON1_VAL 0x00000000
45#define EPLL_CON2_VAL 0x00000080
46
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000047/* VPLL_CON1, CON2 */
Chander Kashyap0aee53b2012-02-05 23:01:47 +000048#define VPLL_CON1_VAL 0x00000000
49#define VPLL_CON2_VAL 0x00000080
50
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000051/* BPLL_CON1 */
Chander Kashyap0aee53b2012-02-05 23:01:47 +000052#define BPLL_CON1_VAL 0x00203800
53
54/* Set PLL */
55#define set_pll(mdiv, pdiv, sdiv) (1<<31 | mdiv<<16 | pdiv<<8 | sdiv)
56
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +000057/* CLK_SRC_CPU */
58/* 0 = MOUTAPLL, 1 = SCLKMPLL */
59#define MUX_HPM_SEL 0
60#define MUX_CPU_SEL 0
61#define MUX_APLL_SEL 1
62
63#define CLK_SRC_CPU_VAL ((MUX_HPM_SEL << 20) \
64 | (MUX_CPU_SEL << 16) \
65 | (MUX_APLL_SEL))
66
67/* MEMCONTROL register bit fields */
68#define DMC_MEMCONTROL_CLK_STOP_DISABLE (0 << 0)
69#define DMC_MEMCONTROL_DPWRDN_DISABLE (0 << 1)
70#define DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE (0 << 2)
71#define DMC_MEMCONTROL_TP_DISABLE (0 << 4)
72#define DMC_MEMCONTROL_DSREF_DISABLE (0 << 5)
73#define DMC_MEMCONTROL_DSREF_ENABLE (1 << 5)
74#define DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(x) (x << 6)
75
76#define DMC_MEMCONTROL_MEM_TYPE_LPDDR3 (7 << 8)
77#define DMC_MEMCONTROL_MEM_TYPE_DDR3 (6 << 8)
78#define DMC_MEMCONTROL_MEM_TYPE_LPDDR2 (5 << 8)
79
80#define DMC_MEMCONTROL_MEM_WIDTH_32BIT (2 << 12)
81
82#define DMC_MEMCONTROL_NUM_CHIP_1 (0 << 16)
83#define DMC_MEMCONTROL_NUM_CHIP_2 (1 << 16)
84
85#define DMC_MEMCONTROL_BL_8 (3 << 20)
86#define DMC_MEMCONTROL_BL_4 (2 << 20)
87
88#define DMC_MEMCONTROL_PZQ_DISABLE (0 << 24)
89
90#define DMC_MEMCONTROL_MRR_BYTE_7_0 (0 << 25)
91#define DMC_MEMCONTROL_MRR_BYTE_15_8 (1 << 25)
92#define DMC_MEMCONTROL_MRR_BYTE_23_16 (2 << 25)
93#define DMC_MEMCONTROL_MRR_BYTE_31_24 (3 << 25)
94
95/* MEMCONFIG0 register bit fields */
96#define DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED (1 << 12)
97#define DMC_MEMCONFIGx_CHIP_COL_10 (3 << 8)
98#define DMC_MEMCONFIGx_CHIP_ROW_14 (2 << 4)
99#define DMC_MEMCONFIGx_CHIP_ROW_15 (3 << 4)
100#define DMC_MEMCONFIGx_CHIP_BANK_8 (3 << 0)
101
102#define DMC_MEMBASECONFIGx_CHIP_BASE(x) (x << 16)
103#define DMC_MEMBASECONFIGx_CHIP_MASK(x) (x << 0)
104#define DMC_MEMBASECONFIG_VAL(x) ( \
105 DMC_MEMBASECONFIGx_CHIP_BASE(x) | \
106 DMC_MEMBASECONFIGx_CHIP_MASK(0x780) \
107)
108
109#define DMC_MEMBASECONFIG0_VAL DMC_MEMBASECONFIG_VAL(0x40)
110#define DMC_MEMBASECONFIG1_VAL DMC_MEMBASECONFIG_VAL(0x80)
111
112#define DMC_PRECHCONFIG_VAL 0xFF000000
113#define DMC_PWRDNCONFIG_VAL 0xFFFF00FF
114
115#define DMC_CONCONTROL_RESET_VAL 0x0FFF0000
116#define DFI_INIT_START (1 << 28)
117#define EMPTY (1 << 8)
118#define AREF_EN (1 << 5)
119
120#define DFI_INIT_COMPLETE_CHO (1 << 2)
121#define DFI_INIT_COMPLETE_CH1 (1 << 3)
122
123#define RDLVL_COMPLETE_CHO (1 << 14)
124#define RDLVL_COMPLETE_CH1 (1 << 15)
125
126#define CLK_STOP_EN (1 << 0)
127#define DPWRDN_EN (1 << 1)
128#define DSREF_EN (1 << 5)
129
130/* COJCONTROL register bit fields */
131#define DMC_CONCONTROL_IO_PD_CON_DISABLE (0 << 3)
132#define DMC_CONCONTROL_AREF_EN_DISABLE (0 << 5)
133#define DMC_CONCONTROL_EMPTY_DISABLE (0 << 8)
134#define DMC_CONCONTROL_EMPTY_ENABLE (1 << 8)
135#define DMC_CONCONTROL_RD_FETCH_DISABLE (0x0 << 12)
136#define DMC_CONCONTROL_TIMEOUT_LEVEL0 (0xFFF << 16)
137#define DMC_CONCONTROL_DFI_INIT_START_DISABLE (0 << 28)
138
139/* CLK_DIV_CPU0_VAL */
140#define CLK_DIV_CPU0_VAL ((ARM2_RATIO << 28) \
141 | (APLL_RATIO << 24) \
142 | (PCLK_DBG_RATIO << 20) \
143 | (ATB_RATIO << 16) \
144 | (PERIPH_RATIO << 12) \
145 | (ACP_RATIO << 8) \
146 | (CPUD_RATIO << 4) \
147 | (ARM_RATIO))
148
149
150/* CLK_FSYS */
151#define CLK_SRC_FSYS0_VAL 0x66666
152#define CLK_DIV_FSYS0_VAL 0x0BB00000
153
154/* CLK_DIV_CPU1 */
155#define HPM_RATIO 0x2
156#define COPY_RATIO 0x0
157
158/* CLK_DIV_CPU1 = 0x00000003 */
159#define CLK_DIV_CPU1_VAL ((HPM_RATIO << 4) \
160 | (COPY_RATIO))
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000161
162/* CLK_SRC_CORE0 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000163#define CLK_SRC_CORE0_VAL 0x00000000
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000164
165/* CLK_SRC_CORE1 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000166#define CLK_SRC_CORE1_VAL 0x100
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000167
168/* CLK_DIV_CORE0 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000169#define CLK_DIV_CORE0_VAL 0x00120000
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000170
171/* CLK_DIV_CORE1 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000172#define CLK_DIV_CORE1_VAL 0x07070700
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000173
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000174/* CLK_DIV_SYSRGT */
175#define CLK_DIV_SYSRGT_VAL 0x00000111
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000176
177/* CLK_DIV_ACP */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000178#define CLK_DIV_ACP_VAL 0x12
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000179
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000180/* CLK_DIV_SYSLFT */
181#define CLK_DIV_SYSLFT_VAL 0x00000311
182
183/* CLK_SRC_CDREX */
184#define CLK_SRC_CDREX_VAL 0x1
185
186/* CLK_DIV_CDREX */
187#define MCLK_CDREX2_RATIO 0x0
188#define ACLK_EFCON_RATIO 0x1
189#define MCLK_DPHY_RATIO 0x1
190#define MCLK_CDREX_RATIO 0x1
191#define ACLK_C2C_200_RATIO 0x1
192#define C2C_CLK_400_RATIO 0x1
193#define PCLK_CDREX_RATIO 0x1
194#define ACLK_CDREX_RATIO 0x1
195
196#define CLK_DIV_CDREX_VAL ((MCLK_DPHY_RATIO << 24) \
197 | (C2C_CLK_400_RATIO << 6) \
198 | (PCLK_CDREX_RATIO << 4) \
199 | (ACLK_CDREX_RATIO))
200
201/* CLK_SRC_TOP0 */
202#define MUX_ACLK_300_GSCL_SEL 0x0
203#define MUX_ACLK_300_GSCL_MID_SEL 0x0
204#define MUX_ACLK_400_G3D_MID_SEL 0x0
205#define MUX_ACLK_333_SEL 0x0
206#define MUX_ACLK_300_DISP1_SEL 0x0
207#define MUX_ACLK_300_DISP1_MID_SEL 0x0
208#define MUX_ACLK_200_SEL 0x0
209#define MUX_ACLK_166_SEL 0x0
210#define CLK_SRC_TOP0_VAL ((MUX_ACLK_300_GSCL_SEL << 25) \
211 | (MUX_ACLK_300_GSCL_MID_SEL << 24) \
212 | (MUX_ACLK_400_G3D_MID_SEL << 20) \
213 | (MUX_ACLK_333_SEL << 16) \
214 | (MUX_ACLK_300_DISP1_SEL << 15) \
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000215 | (MUX_ACLK_300_DISP1_MID_SEL << 14) \
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000216 | (MUX_ACLK_200_SEL << 12) \
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000217 | (MUX_ACLK_166_SEL << 8))
218
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000219/* CLK_SRC_TOP1 */
220#define MUX_ACLK_400_G3D_SEL 0x1
221#define MUX_ACLK_400_ISP_SEL 0x0
222#define MUX_ACLK_400_IOP_SEL 0x0
223#define MUX_ACLK_MIPI_HSI_TXBASE_SEL 0x0
224#define MUX_ACLK_300_GSCL_MID1_SEL 0x0
225#define MUX_ACLK_300_DISP1_MID1_SEL 0x0
226#define CLK_SRC_TOP1_VAL ((MUX_ACLK_400_G3D_SEL << 28) \
227 |(MUX_ACLK_400_ISP_SEL << 24) \
228 |(MUX_ACLK_400_IOP_SEL << 20) \
229 |(MUX_ACLK_MIPI_HSI_TXBASE_SEL << 16) \
230 |(MUX_ACLK_300_GSCL_MID1_SEL << 12) \
231 |(MUX_ACLK_300_DISP1_MID1_SEL << 8))
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000232
233/* CLK_SRC_TOP2 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000234#define MUX_GPLL_SEL 0x1
235#define MUX_BPLL_USER_SEL 0x0
236#define MUX_MPLL_USER_SEL 0x0
237#define MUX_VPLL_SEL 0x1
238#define MUX_EPLL_SEL 0x1
239#define MUX_CPLL_SEL 0x1
240#define VPLLSRC_SEL 0x0
241#define CLK_SRC_TOP2_VAL ((MUX_GPLL_SEL << 28) \
242 | (MUX_BPLL_USER_SEL << 24) \
243 | (MUX_MPLL_USER_SEL << 20) \
244 | (MUX_VPLL_SEL << 16) \
245 | (MUX_EPLL_SEL << 12) \
246 | (MUX_CPLL_SEL << 8) \
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000247 | (VPLLSRC_SEL))
248/* CLK_SRC_TOP3 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000249#define MUX_ACLK_333_SUB_SEL 0x1
250#define MUX_ACLK_400_SUB_SEL 0x1
251#define MUX_ACLK_266_ISP_SUB_SEL 0x1
252#define MUX_ACLK_266_GPS_SUB_SEL 0x0
253#define MUX_ACLK_300_GSCL_SUB_SEL 0x1
254#define MUX_ACLK_266_GSCL_SUB_SEL 0x1
255#define MUX_ACLK_300_DISP1_SUB_SEL 0x1
256#define MUX_ACLK_200_DISP1_SUB_SEL 0x1
257#define CLK_SRC_TOP3_VAL ((MUX_ACLK_333_SUB_SEL << 24) \
258 | (MUX_ACLK_400_SUB_SEL << 20) \
259 | (MUX_ACLK_266_ISP_SUB_SEL << 16) \
260 | (MUX_ACLK_266_GPS_SUB_SEL << 12) \
261 | (MUX_ACLK_300_GSCL_SUB_SEL << 10) \
262 | (MUX_ACLK_266_GSCL_SUB_SEL << 8) \
263 | (MUX_ACLK_300_DISP1_SUB_SEL << 6) \
264 | (MUX_ACLK_200_DISP1_SUB_SEL << 4))
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000265
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000266/* CLK_DIV_TOP0 */
267#define ACLK_300_DISP1_RATIO 0x2
268#define ACLK_400_G3D_RATIO 0x0
269#define ACLK_333_RATIO 0x0
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000270#define ACLK_266_RATIO 0x2
271#define ACLK_200_RATIO 0x3
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000272#define ACLK_166_RATIO 0x1
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000273#define ACLK_133_RATIO 0x1
274#define ACLK_66_RATIO 0x5
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000275
276#define CLK_DIV_TOP0_VAL ((ACLK_300_DISP1_RATIO << 28) \
277 | (ACLK_400_G3D_RATIO << 24) \
278 | (ACLK_333_RATIO << 20) \
279 | (ACLK_266_RATIO << 16) \
280 | (ACLK_200_RATIO << 12) \
281 | (ACLK_166_RATIO << 8) \
282 | (ACLK_133_RATIO << 4) \
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000283 | (ACLK_66_RATIO))
284
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000285/* CLK_DIV_TOP1 */
286#define ACLK_MIPI_HSI_TX_BASE_RATIO 0x3
287#define ACLK_66_PRE_RATIO 0x1
288#define ACLK_400_ISP_RATIO 0x1
289#define ACLK_400_IOP_RATIO 0x1
290#define ACLK_300_GSCL_RATIO 0x2
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000291
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000292#define CLK_DIV_TOP1_VAL ((ACLK_MIPI_HSI_TX_BASE_RATIO << 28) \
293 | (ACLK_66_PRE_RATIO << 24) \
294 | (ACLK_400_ISP_RATIO << 20) \
295 | (ACLK_400_IOP_RATIO << 16) \
296 | (ACLK_300_GSCL_RATIO << 12))
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000297
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000298/* APLL_LOCK */
299#define APLL_LOCK_VAL (0x546)
300/* MPLL_LOCK */
301#define MPLL_LOCK_VAL (0x546)
302/* CPLL_LOCK */
303#define CPLL_LOCK_VAL (0x546)
304/* GPLL_LOCK */
305#define GPLL_LOCK_VAL (0x546)
306/* EPLL_LOCK */
307#define EPLL_LOCK_VAL (0x3A98)
308/* VPLL_LOCK */
309#define VPLL_LOCK_VAL (0x3A98)
310/* BPLL_LOCK */
311#define BPLL_LOCK_VAL (0x546)
312
313#define MUX_APLL_SEL_MASK (1 << 0)
314#define MUX_MPLL_SEL_MASK (1 << 8)
315#define MPLL_SEL_MOUT_MPLLFOUT (2 << 8)
316#define MUX_CPLL_SEL_MASK (1 << 8)
317#define MUX_EPLL_SEL_MASK (1 << 12)
318#define MUX_VPLL_SEL_MASK (1 << 16)
319#define MUX_GPLL_SEL_MASK (1 << 28)
320#define MUX_BPLL_SEL_MASK (1 << 0)
321#define MUX_HPM_SEL_MASK (1 << 20)
322#define HPM_SEL_SCLK_MPLL (1 << 21)
323#define APLL_CON0_LOCKED (1 << 29)
324#define MPLL_CON0_LOCKED (1 << 29)
325#define BPLL_CON0_LOCKED (1 << 29)
326#define CPLL_CON0_LOCKED (1 << 29)
327#define EPLL_CON0_LOCKED (1 << 29)
328#define GPLL_CON0_LOCKED (1 << 29)
329#define VPLL_CON0_LOCKED (1 << 29)
330#define CLK_REG_DISABLE 0x0
331#define TOP2_VAL 0x0110000
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000332
333/* CLK_SRC_PERIC0 */
Padmavathi Vennaf9e4d042013-03-28 04:32:22 +0000334#define PWM_SEL 6
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000335#define UART3_SEL 6
336#define UART2_SEL 6
337#define UART1_SEL 6
338#define UART0_SEL 6
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000339/* SRC_CLOCK = SCLK_MPLL */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000340#define CLK_SRC_PERIC0_VAL ((PWM_SEL << 24) \
341 | (UART3_SEL << 12) \
342 | (UART2_SEL << 8) \
343 | (UART1_SEL << 4) \
344 | (UART0_SEL))
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000345
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000346/* CLK_SRC_PERIC1 */
347/* SRC_CLOCK = SCLK_MPLL */
348#define SPI0_SEL 6
349#define SPI1_SEL 6
350#define SPI2_SEL 6
351#define CLK_SRC_PERIC1_VAL ((SPI2_SEL << 24) \
352 | (SPI1_SEL << 20) \
353 | (SPI0_SEL << 16))
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000354
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000355/* SCLK_SRC_ISP - set SPI0/1 to 6 = SCLK_MPLL_USER */
356#define SPI0_ISP_SEL 6
357#define SPI1_ISP_SEL 6
358#define SCLK_SRC_ISP_VAL (SPI1_ISP_SEL << 4) \
359 | (SPI0_ISP_SEL << 0)
360
361/* SCLK_DIV_ISP - set SPI0/1 to 0xf = divide by 16 */
362#define SPI0_ISP_RATIO 0xf
363#define SPI1_ISP_RATIO 0xf
364#define SCLK_DIV_ISP_VAL (SPI1_ISP_RATIO << 12) \
365 | (SPI0_ISP_RATIO << 0)
366
367/* CLK_DIV_PERIL0 */
368#define UART5_RATIO 7
369#define UART4_RATIO 7
370#define UART3_RATIO 7
371#define UART2_RATIO 7
372#define UART1_RATIO 7
373#define UART0_RATIO 7
374
375#define CLK_DIV_PERIC0_VAL ((UART3_RATIO << 12) \
376 | (UART2_RATIO << 8) \
377 | (UART1_RATIO << 4) \
378 | (UART0_RATIO))
379/* CLK_DIV_PERIC1 */
380#define SPI1_RATIO 0x7
381#define SPI0_RATIO 0xf
382#define SPI1_SUB_RATIO 0x0
383#define SPI0_SUB_RATIO 0x0
384#define CLK_DIV_PERIC1_VAL ((SPI1_SUB_RATIO << 24) \
385 | ((SPI1_RATIO << 16) \
386 | (SPI0_SUB_RATIO << 8) \
387 | (SPI0_RATIO << 0)))
388
389/* CLK_DIV_PERIC2 */
390#define SPI2_RATIO 0xf
391#define SPI2_SUB_RATIO 0x0
392#define CLK_DIV_PERIC2_VAL ((SPI2_SUB_RATIO << 8) \
393 | (SPI2_RATIO << 0))
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000394
395/* CLK_DIV_PERIC3 */
396#define PWM_RATIO 8
397#define CLK_DIV_PERIC3_VAL (PWM_RATIO << 0)
398
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000399/* CLK_DIV_FSYS2 */
400#define MMC2_RATIO_MASK 0xf
401#define MMC2_RATIO_VAL 0x3
402#define MMC2_RATIO_OFFSET 0
403
404#define MMC2_PRE_RATIO_MASK 0xff
405#define MMC2_PRE_RATIO_VAL 0x9
406#define MMC2_PRE_RATIO_OFFSET 8
407
408#define MMC3_RATIO_MASK 0xf
409#define MMC3_RATIO_VAL 0x1
410#define MMC3_RATIO_OFFSET 16
411
412#define MMC3_PRE_RATIO_MASK 0xff
413#define MMC3_PRE_RATIO_VAL 0x0
414#define MMC3_PRE_RATIO_OFFSET 24
415
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000416/* CLK_SRC_LEX */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000417#define CLK_SRC_LEX_VAL 0x0
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000418
419/* CLK_DIV_LEX */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000420#define CLK_DIV_LEX_VAL 0x10
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000421
422/* CLK_DIV_R0X */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000423#define CLK_DIV_R0X_VAL 0x10
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000424
425/* CLK_DIV_L0X */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000426#define CLK_DIV_R1X_VAL 0x10
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000427
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000428/* CLK_DIV_ISP0 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000429#define CLK_DIV_ISP0_VAL 0x31
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000430
431/* CLK_DIV_ISP1 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000432#define CLK_DIV_ISP1_VAL 0x0
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000433
434/* CLK_DIV_ISP2 */
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000435#define CLK_DIV_ISP2_VAL 0x1
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000436
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000437/* CLK_SRC_DISP1_0 */
438#define CLK_SRC_DISP1_0_VAL 0x6
439
440/*
441 * DIV_DISP1_0
442 * For DP, divisor should be 2
443 */
444#define CLK_DIV_DISP1_0_FIMD1 (2 << 0)
445
446/* CLK_GATE_IP_DISP1 */
447#define CLK_GATE_DP1_ALLOW (1 << 4)
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000448
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000449#define DDR3PHY_CTRL_PHY_RESET (1 << 0)
450#define DDR3PHY_CTRL_PHY_RESET_OFF (0 << 0)
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000451
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000452#define PHY_CON0_RESET_VAL 0x17020a40
453#define P0_CMD_EN (1 << 14)
454#define BYTE_RDLVL_EN (1 << 13)
455#define CTRL_SHGATE (1 << 8)
456
457#define PHY_CON1_RESET_VAL 0x09210100
458#define CTRL_GATEDURADJ_MASK (0xf << 20)
459
460#define PHY_CON2_RESET_VAL 0x00010004
461#define INIT_DESKEW_EN (1 << 6)
462#define RDLVL_GATE_EN (1 << 24)
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000463
464/*ZQ Configurations */
465#define PHY_CON16_RESET_VAL 0x08000304
466
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000467#define ZQ_CLK_DIV_EN (1 << 18)
468#define ZQ_MANUAL_STR (1 << 1)
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000469#define ZQ_DONE (1 << 0)
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000470
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000471#define CTRL_RDLVL_GATE_ENABLE 1
472#define CTRL_RDLVL_GATE_DISABLE 1
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000473
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000474/* Direct Command */
475#define DIRECT_CMD_NOP 0x07000000
476#define DIRECT_CMD_PALL 0x01000000
477#define DIRECT_CMD_ZQINIT 0x0a000000
478#define DIRECT_CMD_CHANNEL_SHIFT 28
479#define DIRECT_CMD_CHIP_SHIFT 20
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000480
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000481/* DMC PHY Control0 register */
482#define PHY_CONTROL0_RESET_VAL 0x0
483#define MEM_TERM_EN (1 << 31) /* Termination enable for memory */
484#define PHY_TERM_EN (1 << 30) /* Termination enable for PHY */
485#define DMC_CTRL_SHGATE (1 << 29) /* Duration of DQS gating signal */
486#define FP_RSYNC (1 << 3) /* Force DLL resyncronization */
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000487
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000488/* Driver strength for CK, CKE, CS & CA */
489#define IMP_OUTPUT_DRV_40_OHM 0x5
490#define IMP_OUTPUT_DRV_30_OHM 0x7
491#define CA_CK_DRVR_DS_OFFSET 9
492#define CA_CKE_DRVR_DS_OFFSET 6
493#define CA_CS_DRVR_DS_OFFSET 3
494#define CA_ADR_DRVR_DS_OFFSET 0
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000495
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000496#define PHY_CON42_CTRL_BSTLEN_SHIFT 8
497#define PHY_CON42_CTRL_RDLAT_SHIFT 0
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000498
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000499struct mem_timings;
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000500
Rajeshwari Shinde998e5d32012-07-03 20:02:55 +0000501/* Errors that we can encourter in low-level setup */
502enum {
503 SETUP_ERR_OK,
504 SETUP_ERR_RDLV_COMPLETE_TIMEOUT = -1,
505 SETUP_ERR_ZQ_CALIBRATION_FAILURE = -2,
506};
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000507
Rajeshwari Shinde87f2e072012-07-03 20:02:56 +0000508/*
509 * Memory variant specific initialization code
510 *
511 * @param mem Memory timings for this memory type.
512 * @param mem_iv_size Memory interleaving size is a configurable parameter
513 * which the DMC uses to decide how to split a memory
514 * chunk into smaller chunks to support concurrent
515 * accesses; may vary across boards.
516 * @return 0 if ok, SETUP_ERR_... if there is a problem
517 */
518int ddr3_mem_ctrl_init(struct mem_timings *mem, unsigned long mem_iv_size);
519
520/*
521 * Configure ZQ I/O interface
522 *
523 * @param mem Memory timings for this memory type.
524 * @param phy0_ctrl Pointer to struct containing PHY0 control reg
525 * @param phy1_ctrl Pointer to struct containing PHY1 control reg
526 * @return 0 if ok, -1 on error
527 */
528int dmc_config_zq(struct mem_timings *mem,
529 struct exynos5_phy_control *phy0_ctrl,
530 struct exynos5_phy_control *phy1_ctrl);
531
532/*
533 * Send NOP and MRS/EMRS Direct commands
534 *
535 * @param mem Memory timings for this memory type.
536 * @param dmc Pointer to struct of DMC registers
537 */
538void dmc_config_mrs(struct mem_timings *mem, struct exynos5_dmc *dmc);
539
540/*
541 * Send PALL Direct commands
542 *
543 * @param mem Memory timings for this memory type.
544 * @param dmc Pointer to struct of DMC registers
545 */
546void dmc_config_prech(struct mem_timings *mem, struct exynos5_dmc *dmc);
547
548/*
549 * Configure the memconfig and membaseconfig registers
550 *
551 * @param mem Memory timings for this memory type.
552 * @param exynos5_dmc Pointer to struct of DMC registers
553 */
554void dmc_config_memory(struct mem_timings *mem, struct exynos5_dmc *dmc);
555
556/*
557 * Reset the DLL. This function is common between DDR3 and LPDDR2.
558 * However, the reset value is different. So we are passing a flag
559 * ddr_mode to distinguish between LPDDR2 and DDR3.
560 *
561 * @param exynos5_dmc Pointer to struct of DMC registers
562 * @param ddr_mode Type of DDR memory
563 */
564void update_reset_dll(struct exynos5_dmc *, enum ddr_mode);
565
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000566void sdelay(unsigned long);
567void mem_ctrl_init(void);
568void system_clock_init(void);
Chander Kashyap0aee53b2012-02-05 23:01:47 +0000569#endif