xref: /openbmc/u-boot/arch/arm/include/asm/emif.h (revision e05a4f1f54f2b5a0c46de978672199e375ba0c00)
1bb772a59SSricharan /*
2bb772a59SSricharan  * OMAP44xx EMIF header
3bb772a59SSricharan  *
4bb772a59SSricharan  * Copyright (C) 2009-2010 Texas Instruments, Inc.
5bb772a59SSricharan  *
6bb772a59SSricharan  * Aneesh V <aneesh@ti.com>
7bb772a59SSricharan  *
8bb772a59SSricharan  * This program is free software; you can redistribute it and/or modify
9bb772a59SSricharan  * it under the terms of the GNU General Public License version 2 as
10bb772a59SSricharan  * published by the Free Software Foundation.
11bb772a59SSricharan  */
12bb772a59SSricharan 
13bb772a59SSricharan #ifndef _EMIF_H_
14bb772a59SSricharan #define _EMIF_H_
15bb772a59SSricharan #include <asm/types.h>
16bb772a59SSricharan #include <common.h>
17bb772a59SSricharan 
18bb772a59SSricharan /* Base address */
19bb772a59SSricharan #define EMIF1_BASE				0x4c000000
20bb772a59SSricharan #define EMIF2_BASE				0x4d000000
21bb772a59SSricharan 
22fda35eb9STom Rini /* Registers shifts, masks and values */
23bb772a59SSricharan 
24bb772a59SSricharan /* EMIF_MOD_ID_REV */
25bb772a59SSricharan #define EMIF_REG_SCHEME_SHIFT			30
26bb772a59SSricharan #define EMIF_REG_SCHEME_MASK			(0x3 << 30)
27bb772a59SSricharan #define EMIF_REG_MODULE_ID_SHIFT			16
28bb772a59SSricharan #define EMIF_REG_MODULE_ID_MASK			(0xfff << 16)
29bb772a59SSricharan #define EMIF_REG_RTL_VERSION_SHIFT			11
30bb772a59SSricharan #define EMIF_REG_RTL_VERSION_MASK			(0x1f << 11)
31bb772a59SSricharan #define EMIF_REG_MAJOR_REVISION_SHIFT		8
32bb772a59SSricharan #define EMIF_REG_MAJOR_REVISION_MASK		(0x7 << 8)
33bb772a59SSricharan #define EMIF_REG_MINOR_REVISION_SHIFT		0
34bb772a59SSricharan #define EMIF_REG_MINOR_REVISION_MASK		(0x3f << 0)
35bb772a59SSricharan 
36bb772a59SSricharan /* STATUS */
37bb772a59SSricharan #define EMIF_REG_BE_SHIFT				31
38bb772a59SSricharan #define EMIF_REG_BE_MASK				(1 << 31)
39bb772a59SSricharan #define EMIF_REG_DUAL_CLK_MODE_SHIFT		30
40bb772a59SSricharan #define EMIF_REG_DUAL_CLK_MODE_MASK			(1 << 30)
41bb772a59SSricharan #define EMIF_REG_FAST_INIT_SHIFT			29
42bb772a59SSricharan #define EMIF_REG_FAST_INIT_MASK			(1 << 29)
43bb772a59SSricharan #define EMIF_REG_PHY_DLL_READY_SHIFT		2
44bb772a59SSricharan #define EMIF_REG_PHY_DLL_READY_MASK			(1 << 2)
45bb772a59SSricharan 
46bb772a59SSricharan /* SDRAM_CONFIG */
47bb772a59SSricharan #define EMIF_REG_SDRAM_TYPE_SHIFT			29
48bb772a59SSricharan #define EMIF_REG_SDRAM_TYPE_MASK			(0x7 << 29)
49fda35eb9STom Rini #define EMIF_REG_SDRAM_TYPE_DDR1			0
50fda35eb9STom Rini #define EMIF_REG_SDRAM_TYPE_LPDDR1			1
51fda35eb9STom Rini #define EMIF_REG_SDRAM_TYPE_DDR2			2
52fda35eb9STom Rini #define EMIF_REG_SDRAM_TYPE_DDR3			3
53fda35eb9STom Rini #define EMIF_REG_SDRAM_TYPE_LPDDR2_S4			4
54fda35eb9STom Rini #define EMIF_REG_SDRAM_TYPE_LPDDR2_S2			5
55bb772a59SSricharan #define EMIF_REG_IBANK_POS_SHIFT			27
56bb772a59SSricharan #define EMIF_REG_IBANK_POS_MASK			(0x3 << 27)
57bb772a59SSricharan #define EMIF_REG_DDR_TERM_SHIFT			24
58bb772a59SSricharan #define EMIF_REG_DDR_TERM_MASK			(0x7 << 24)
59bb772a59SSricharan #define EMIF_REG_DDR2_DDQS_SHIFT			23
60bb772a59SSricharan #define EMIF_REG_DDR2_DDQS_MASK			(1 << 23)
61bb772a59SSricharan #define EMIF_REG_DYN_ODT_SHIFT			21
62bb772a59SSricharan #define EMIF_REG_DYN_ODT_MASK			(0x3 << 21)
63bb772a59SSricharan #define EMIF_REG_DDR_DISABLE_DLL_SHIFT		20
64bb772a59SSricharan #define EMIF_REG_DDR_DISABLE_DLL_MASK		(1 << 20)
65bb772a59SSricharan #define EMIF_REG_SDRAM_DRIVE_SHIFT			18
66bb772a59SSricharan #define EMIF_REG_SDRAM_DRIVE_MASK			(0x3 << 18)
67bb772a59SSricharan #define EMIF_REG_CWL_SHIFT				16
68bb772a59SSricharan #define EMIF_REG_CWL_MASK				(0x3 << 16)
69bb772a59SSricharan #define EMIF_REG_NARROW_MODE_SHIFT			14
70bb772a59SSricharan #define EMIF_REG_NARROW_MODE_MASK			(0x3 << 14)
71bb772a59SSricharan #define EMIF_REG_CL_SHIFT				10
72bb772a59SSricharan #define EMIF_REG_CL_MASK				(0xf << 10)
73bb772a59SSricharan #define EMIF_REG_ROWSIZE_SHIFT			7
74bb772a59SSricharan #define EMIF_REG_ROWSIZE_MASK			(0x7 << 7)
75bb772a59SSricharan #define EMIF_REG_IBANK_SHIFT			4
76bb772a59SSricharan #define EMIF_REG_IBANK_MASK				(0x7 << 4)
77bb772a59SSricharan #define EMIF_REG_EBANK_SHIFT			3
78bb772a59SSricharan #define EMIF_REG_EBANK_MASK				(1 << 3)
79bb772a59SSricharan #define EMIF_REG_PAGESIZE_SHIFT			0
80bb772a59SSricharan #define EMIF_REG_PAGESIZE_MASK			(0x7 << 0)
81bb772a59SSricharan 
82bb772a59SSricharan /* SDRAM_CONFIG_2 */
83bb772a59SSricharan #define EMIF_REG_CS1NVMEN_SHIFT			30
84bb772a59SSricharan #define EMIF_REG_CS1NVMEN_MASK			(1 << 30)
85bb772a59SSricharan #define EMIF_REG_EBANK_POS_SHIFT			27
86bb772a59SSricharan #define EMIF_REG_EBANK_POS_MASK			(1 << 27)
87bb772a59SSricharan #define EMIF_REG_RDBNUM_SHIFT			4
88bb772a59SSricharan #define EMIF_REG_RDBNUM_MASK			(0x3 << 4)
89bb772a59SSricharan #define EMIF_REG_RDBSIZE_SHIFT			0
90bb772a59SSricharan #define EMIF_REG_RDBSIZE_MASK			(0x7 << 0)
91bb772a59SSricharan 
92bb772a59SSricharan /* SDRAM_REF_CTRL */
93bb772a59SSricharan #define EMIF_REG_INITREF_DIS_SHIFT			31
94bb772a59SSricharan #define EMIF_REG_INITREF_DIS_MASK			(1 << 31)
95bb772a59SSricharan #define EMIF_REG_SRT_SHIFT				29
96bb772a59SSricharan #define EMIF_REG_SRT_MASK				(1 << 29)
97bb772a59SSricharan #define EMIF_REG_ASR_SHIFT				28
98bb772a59SSricharan #define EMIF_REG_ASR_MASK				(1 << 28)
99bb772a59SSricharan #define EMIF_REG_PASR_SHIFT				24
100bb772a59SSricharan #define EMIF_REG_PASR_MASK				(0x7 << 24)
101bb772a59SSricharan #define EMIF_REG_REFRESH_RATE_SHIFT			0
102bb772a59SSricharan #define EMIF_REG_REFRESH_RATE_MASK			(0xffff << 0)
103bb772a59SSricharan 
104bb772a59SSricharan /* SDRAM_REF_CTRL_SHDW */
105bb772a59SSricharan #define EMIF_REG_REFRESH_RATE_SHDW_SHIFT		0
106bb772a59SSricharan #define EMIF_REG_REFRESH_RATE_SHDW_MASK		(0xffff << 0)
107bb772a59SSricharan 
108bb772a59SSricharan /* SDRAM_TIM_1 */
109bb772a59SSricharan #define EMIF_REG_T_RP_SHIFT				25
110bb772a59SSricharan #define EMIF_REG_T_RP_MASK				(0xf << 25)
111bb772a59SSricharan #define EMIF_REG_T_RCD_SHIFT			21
112bb772a59SSricharan #define EMIF_REG_T_RCD_MASK				(0xf << 21)
113bb772a59SSricharan #define EMIF_REG_T_WR_SHIFT				17
114bb772a59SSricharan #define EMIF_REG_T_WR_MASK				(0xf << 17)
115bb772a59SSricharan #define EMIF_REG_T_RAS_SHIFT			12
116bb772a59SSricharan #define EMIF_REG_T_RAS_MASK				(0x1f << 12)
117bb772a59SSricharan #define EMIF_REG_T_RC_SHIFT				6
118bb772a59SSricharan #define EMIF_REG_T_RC_MASK				(0x3f << 6)
119bb772a59SSricharan #define EMIF_REG_T_RRD_SHIFT			3
120bb772a59SSricharan #define EMIF_REG_T_RRD_MASK				(0x7 << 3)
121bb772a59SSricharan #define EMIF_REG_T_WTR_SHIFT			0
122bb772a59SSricharan #define EMIF_REG_T_WTR_MASK				(0x7 << 0)
123bb772a59SSricharan 
124bb772a59SSricharan /* SDRAM_TIM_1_SHDW */
125bb772a59SSricharan #define EMIF_REG_T_RP_SHDW_SHIFT			25
126bb772a59SSricharan #define EMIF_REG_T_RP_SHDW_MASK			(0xf << 25)
127bb772a59SSricharan #define EMIF_REG_T_RCD_SHDW_SHIFT			21
128bb772a59SSricharan #define EMIF_REG_T_RCD_SHDW_MASK			(0xf << 21)
129bb772a59SSricharan #define EMIF_REG_T_WR_SHDW_SHIFT			17
130bb772a59SSricharan #define EMIF_REG_T_WR_SHDW_MASK			(0xf << 17)
131bb772a59SSricharan #define EMIF_REG_T_RAS_SHDW_SHIFT			12
132bb772a59SSricharan #define EMIF_REG_T_RAS_SHDW_MASK			(0x1f << 12)
133bb772a59SSricharan #define EMIF_REG_T_RC_SHDW_SHIFT			6
134bb772a59SSricharan #define EMIF_REG_T_RC_SHDW_MASK			(0x3f << 6)
135bb772a59SSricharan #define EMIF_REG_T_RRD_SHDW_SHIFT			3
136bb772a59SSricharan #define EMIF_REG_T_RRD_SHDW_MASK			(0x7 << 3)
137bb772a59SSricharan #define EMIF_REG_T_WTR_SHDW_SHIFT			0
138bb772a59SSricharan #define EMIF_REG_T_WTR_SHDW_MASK			(0x7 << 0)
139bb772a59SSricharan 
140bb772a59SSricharan /* SDRAM_TIM_2 */
141bb772a59SSricharan #define EMIF_REG_T_XP_SHIFT				28
142bb772a59SSricharan #define EMIF_REG_T_XP_MASK				(0x7 << 28)
143bb772a59SSricharan #define EMIF_REG_T_ODT_SHIFT			25
144bb772a59SSricharan #define EMIF_REG_T_ODT_MASK				(0x7 << 25)
145bb772a59SSricharan #define EMIF_REG_T_XSNR_SHIFT			16
146bb772a59SSricharan #define EMIF_REG_T_XSNR_MASK			(0x1ff << 16)
147bb772a59SSricharan #define EMIF_REG_T_XSRD_SHIFT			6
148bb772a59SSricharan #define EMIF_REG_T_XSRD_MASK			(0x3ff << 6)
149bb772a59SSricharan #define EMIF_REG_T_RTP_SHIFT			3
150bb772a59SSricharan #define EMIF_REG_T_RTP_MASK				(0x7 << 3)
151bb772a59SSricharan #define EMIF_REG_T_CKE_SHIFT			0
152bb772a59SSricharan #define EMIF_REG_T_CKE_MASK				(0x7 << 0)
153bb772a59SSricharan 
154bb772a59SSricharan /* SDRAM_TIM_2_SHDW */
155bb772a59SSricharan #define EMIF_REG_T_XP_SHDW_SHIFT			28
156bb772a59SSricharan #define EMIF_REG_T_XP_SHDW_MASK			(0x7 << 28)
157bb772a59SSricharan #define EMIF_REG_T_ODT_SHDW_SHIFT			25
158bb772a59SSricharan #define EMIF_REG_T_ODT_SHDW_MASK			(0x7 << 25)
159bb772a59SSricharan #define EMIF_REG_T_XSNR_SHDW_SHIFT			16
160bb772a59SSricharan #define EMIF_REG_T_XSNR_SHDW_MASK			(0x1ff << 16)
161bb772a59SSricharan #define EMIF_REG_T_XSRD_SHDW_SHIFT			6
162bb772a59SSricharan #define EMIF_REG_T_XSRD_SHDW_MASK			(0x3ff << 6)
163bb772a59SSricharan #define EMIF_REG_T_RTP_SHDW_SHIFT			3
164bb772a59SSricharan #define EMIF_REG_T_RTP_SHDW_MASK			(0x7 << 3)
165bb772a59SSricharan #define EMIF_REG_T_CKE_SHDW_SHIFT			0
166bb772a59SSricharan #define EMIF_REG_T_CKE_SHDW_MASK			(0x7 << 0)
167bb772a59SSricharan 
168bb772a59SSricharan /* SDRAM_TIM_3 */
169bb772a59SSricharan #define EMIF_REG_T_CKESR_SHIFT			21
170bb772a59SSricharan #define EMIF_REG_T_CKESR_MASK			(0x7 << 21)
171bb772a59SSricharan #define EMIF_REG_ZQ_ZQCS_SHIFT			15
172bb772a59SSricharan #define EMIF_REG_ZQ_ZQCS_MASK			(0x3f << 15)
173bb772a59SSricharan #define EMIF_REG_T_TDQSCKMAX_SHIFT			13
174bb772a59SSricharan #define EMIF_REG_T_TDQSCKMAX_MASK			(0x3 << 13)
175bb772a59SSricharan #define EMIF_REG_T_RFC_SHIFT			4
176bb772a59SSricharan #define EMIF_REG_T_RFC_MASK				(0x1ff << 4)
177bb772a59SSricharan #define EMIF_REG_T_RAS_MAX_SHIFT			0
178bb772a59SSricharan #define EMIF_REG_T_RAS_MAX_MASK			(0xf << 0)
179bb772a59SSricharan 
180bb772a59SSricharan /* SDRAM_TIM_3_SHDW */
181bb772a59SSricharan #define EMIF_REG_T_CKESR_SHDW_SHIFT			21
182bb772a59SSricharan #define EMIF_REG_T_CKESR_SHDW_MASK			(0x7 << 21)
183bb772a59SSricharan #define EMIF_REG_ZQ_ZQCS_SHDW_SHIFT			15
184bb772a59SSricharan #define EMIF_REG_ZQ_ZQCS_SHDW_MASK			(0x3f << 15)
185bb772a59SSricharan #define EMIF_REG_T_TDQSCKMAX_SHDW_SHIFT		13
186bb772a59SSricharan #define EMIF_REG_T_TDQSCKMAX_SHDW_MASK		(0x3 << 13)
187bb772a59SSricharan #define EMIF_REG_T_RFC_SHDW_SHIFT			4
188bb772a59SSricharan #define EMIF_REG_T_RFC_SHDW_MASK			(0x1ff << 4)
189bb772a59SSricharan #define EMIF_REG_T_RAS_MAX_SHDW_SHIFT		0
190bb772a59SSricharan #define EMIF_REG_T_RAS_MAX_SHDW_MASK		(0xf << 0)
191bb772a59SSricharan 
192bb772a59SSricharan /* LPDDR2_NVM_TIM */
193bb772a59SSricharan #define EMIF_REG_NVM_T_XP_SHIFT			28
194bb772a59SSricharan #define EMIF_REG_NVM_T_XP_MASK			(0x7 << 28)
195bb772a59SSricharan #define EMIF_REG_NVM_T_WTR_SHIFT			24
196bb772a59SSricharan #define EMIF_REG_NVM_T_WTR_MASK			(0x7 << 24)
197bb772a59SSricharan #define EMIF_REG_NVM_T_RP_SHIFT			20
198bb772a59SSricharan #define EMIF_REG_NVM_T_RP_MASK			(0xf << 20)
199bb772a59SSricharan #define EMIF_REG_NVM_T_WRA_SHIFT			16
200bb772a59SSricharan #define EMIF_REG_NVM_T_WRA_MASK			(0xf << 16)
201bb772a59SSricharan #define EMIF_REG_NVM_T_RRD_SHIFT			8
202bb772a59SSricharan #define EMIF_REG_NVM_T_RRD_MASK			(0xff << 8)
203bb772a59SSricharan #define EMIF_REG_NVM_T_RCDMIN_SHIFT			0
204bb772a59SSricharan #define EMIF_REG_NVM_T_RCDMIN_MASK			(0xff << 0)
205bb772a59SSricharan 
206bb772a59SSricharan /* LPDDR2_NVM_TIM_SHDW */
207bb772a59SSricharan #define EMIF_REG_NVM_T_XP_SHDW_SHIFT		28
208bb772a59SSricharan #define EMIF_REG_NVM_T_XP_SHDW_MASK			(0x7 << 28)
209bb772a59SSricharan #define EMIF_REG_NVM_T_WTR_SHDW_SHIFT		24
210bb772a59SSricharan #define EMIF_REG_NVM_T_WTR_SHDW_MASK		(0x7 << 24)
211bb772a59SSricharan #define EMIF_REG_NVM_T_RP_SHDW_SHIFT		20
212bb772a59SSricharan #define EMIF_REG_NVM_T_RP_SHDW_MASK			(0xf << 20)
213bb772a59SSricharan #define EMIF_REG_NVM_T_WRA_SHDW_SHIFT		16
214bb772a59SSricharan #define EMIF_REG_NVM_T_WRA_SHDW_MASK		(0xf << 16)
215bb772a59SSricharan #define EMIF_REG_NVM_T_RRD_SHDW_SHIFT		8
216bb772a59SSricharan #define EMIF_REG_NVM_T_RRD_SHDW_MASK		(0xff << 8)
217bb772a59SSricharan #define EMIF_REG_NVM_T_RCDMIN_SHDW_SHIFT		0
218bb772a59SSricharan #define EMIF_REG_NVM_T_RCDMIN_SHDW_MASK		(0xff << 0)
219bb772a59SSricharan 
220bb772a59SSricharan /* PWR_MGMT_CTRL */
221bb772a59SSricharan #define EMIF_REG_IDLEMODE_SHIFT			30
222bb772a59SSricharan #define EMIF_REG_IDLEMODE_MASK			(0x3 << 30)
223bb772a59SSricharan #define EMIF_REG_PD_TIM_SHIFT			12
224bb772a59SSricharan #define EMIF_REG_PD_TIM_MASK			(0xf << 12)
225bb772a59SSricharan #define EMIF_REG_DPD_EN_SHIFT			11
226bb772a59SSricharan #define EMIF_REG_DPD_EN_MASK			(1 << 11)
227bb772a59SSricharan #define EMIF_REG_LP_MODE_SHIFT			8
228bb772a59SSricharan #define EMIF_REG_LP_MODE_MASK			(0x7 << 8)
229bb772a59SSricharan #define EMIF_REG_SR_TIM_SHIFT			4
230bb772a59SSricharan #define EMIF_REG_SR_TIM_MASK			(0xf << 4)
231bb772a59SSricharan #define EMIF_REG_CS_TIM_SHIFT			0
232bb772a59SSricharan #define EMIF_REG_CS_TIM_MASK			(0xf << 0)
233bb772a59SSricharan 
234bb772a59SSricharan /* PWR_MGMT_CTRL_SHDW */
235aaec4487SSRICHARAN R #define EMIF_REG_PD_TIM_SHDW_SHIFT			12
236aaec4487SSRICHARAN R #define EMIF_REG_PD_TIM_SHDW_MASK			(0xf << 12)
237bb772a59SSricharan #define EMIF_REG_SR_TIM_SHDW_SHIFT			4
238bb772a59SSricharan #define EMIF_REG_SR_TIM_SHDW_MASK			(0xf << 4)
239bb772a59SSricharan #define EMIF_REG_CS_TIM_SHDW_SHIFT			0
240bb772a59SSricharan #define EMIF_REG_CS_TIM_SHDW_MASK			(0xf << 0)
241bb772a59SSricharan 
242bb772a59SSricharan /* LPDDR2_MODE_REG_DATA */
243bb772a59SSricharan #define EMIF_REG_VALUE_0_SHIFT			0
244bb772a59SSricharan #define EMIF_REG_VALUE_0_MASK			(0x7f << 0)
245bb772a59SSricharan 
246bb772a59SSricharan /* LPDDR2_MODE_REG_CFG */
247bb772a59SSricharan #define EMIF_REG_CS_SHIFT				31
248bb772a59SSricharan #define EMIF_REG_CS_MASK				(1 << 31)
249bb772a59SSricharan #define EMIF_REG_REFRESH_EN_SHIFT			30
250bb772a59SSricharan #define EMIF_REG_REFRESH_EN_MASK			(1 << 30)
251bb772a59SSricharan #define EMIF_REG_ADDRESS_SHIFT			0
252bb772a59SSricharan #define EMIF_REG_ADDRESS_MASK			(0xff << 0)
253bb772a59SSricharan 
254bb772a59SSricharan /* OCP_CONFIG */
255bb772a59SSricharan #define EMIF_REG_SYS_THRESH_MAX_SHIFT		24
256bb772a59SSricharan #define EMIF_REG_SYS_THRESH_MAX_MASK		(0xf << 24)
257bb772a59SSricharan #define EMIF_REG_MPU_THRESH_MAX_SHIFT		20
258bb772a59SSricharan #define EMIF_REG_MPU_THRESH_MAX_MASK		(0xf << 20)
259bb772a59SSricharan #define EMIF_REG_LL_THRESH_MAX_SHIFT		16
260bb772a59SSricharan #define EMIF_REG_LL_THRESH_MAX_MASK			(0xf << 16)
261bb772a59SSricharan #define EMIF_REG_PR_OLD_COUNT_SHIFT			0
262bb772a59SSricharan #define EMIF_REG_PR_OLD_COUNT_MASK			(0xff << 0)
263bb772a59SSricharan 
264bb772a59SSricharan /* OCP_CFG_VAL_1 */
265bb772a59SSricharan #define EMIF_REG_SYS_BUS_WIDTH_SHIFT		30
266bb772a59SSricharan #define EMIF_REG_SYS_BUS_WIDTH_MASK			(0x3 << 30)
267bb772a59SSricharan #define EMIF_REG_LL_BUS_WIDTH_SHIFT			28
268bb772a59SSricharan #define EMIF_REG_LL_BUS_WIDTH_MASK			(0x3 << 28)
269bb772a59SSricharan #define EMIF_REG_WR_FIFO_DEPTH_SHIFT		8
270bb772a59SSricharan #define EMIF_REG_WR_FIFO_DEPTH_MASK			(0xff << 8)
271bb772a59SSricharan #define EMIF_REG_CMD_FIFO_DEPTH_SHIFT		0
272bb772a59SSricharan #define EMIF_REG_CMD_FIFO_DEPTH_MASK		(0xff << 0)
273bb772a59SSricharan 
274bb772a59SSricharan /* OCP_CFG_VAL_2 */
275bb772a59SSricharan #define EMIF_REG_RREG_FIFO_DEPTH_SHIFT		16
276bb772a59SSricharan #define EMIF_REG_RREG_FIFO_DEPTH_MASK		(0xff << 16)
277bb772a59SSricharan #define EMIF_REG_RSD_FIFO_DEPTH_SHIFT		8
278bb772a59SSricharan #define EMIF_REG_RSD_FIFO_DEPTH_MASK		(0xff << 8)
279bb772a59SSricharan #define EMIF_REG_RCMD_FIFO_DEPTH_SHIFT		0
280bb772a59SSricharan #define EMIF_REG_RCMD_FIFO_DEPTH_MASK		(0xff << 0)
281bb772a59SSricharan 
282bb772a59SSricharan /* IODFT_TLGC */
283bb772a59SSricharan #define EMIF_REG_TLEC_SHIFT				16
284bb772a59SSricharan #define EMIF_REG_TLEC_MASK				(0xffff << 16)
285bb772a59SSricharan #define EMIF_REG_MT_SHIFT				14
286bb772a59SSricharan #define EMIF_REG_MT_MASK				(1 << 14)
287bb772a59SSricharan #define EMIF_REG_ACT_CAP_EN_SHIFT			13
288bb772a59SSricharan #define EMIF_REG_ACT_CAP_EN_MASK			(1 << 13)
289bb772a59SSricharan #define EMIF_REG_OPG_LD_SHIFT			12
290bb772a59SSricharan #define EMIF_REG_OPG_LD_MASK			(1 << 12)
291bb772a59SSricharan #define EMIF_REG_RESET_PHY_SHIFT			10
292bb772a59SSricharan #define EMIF_REG_RESET_PHY_MASK			(1 << 10)
293bb772a59SSricharan #define EMIF_REG_MMS_SHIFT				8
294bb772a59SSricharan #define EMIF_REG_MMS_MASK				(1 << 8)
295bb772a59SSricharan #define EMIF_REG_MC_SHIFT				4
296bb772a59SSricharan #define EMIF_REG_MC_MASK				(0x3 << 4)
297bb772a59SSricharan #define EMIF_REG_PC_SHIFT				1
298bb772a59SSricharan #define EMIF_REG_PC_MASK				(0x7 << 1)
299bb772a59SSricharan #define EMIF_REG_TM_SHIFT				0
300bb772a59SSricharan #define EMIF_REG_TM_MASK				(1 << 0)
301bb772a59SSricharan 
302bb772a59SSricharan /* IODFT_CTRL_MISR_RSLT */
303bb772a59SSricharan #define EMIF_REG_DQM_TLMR_SHIFT			16
304bb772a59SSricharan #define EMIF_REG_DQM_TLMR_MASK			(0x3ff << 16)
305bb772a59SSricharan #define EMIF_REG_CTL_TLMR_SHIFT			0
306bb772a59SSricharan #define EMIF_REG_CTL_TLMR_MASK			(0x7ff << 0)
307bb772a59SSricharan 
308bb772a59SSricharan /* IODFT_ADDR_MISR_RSLT */
309bb772a59SSricharan #define EMIF_REG_ADDR_TLMR_SHIFT			0
310bb772a59SSricharan #define EMIF_REG_ADDR_TLMR_MASK			(0x1fffff << 0)
311bb772a59SSricharan 
312bb772a59SSricharan /* IODFT_DATA_MISR_RSLT_1 */
313bb772a59SSricharan #define EMIF_REG_DATA_TLMR_31_0_SHIFT		0
314bb772a59SSricharan #define EMIF_REG_DATA_TLMR_31_0_MASK		(0xffffffff << 0)
315bb772a59SSricharan 
316bb772a59SSricharan /* IODFT_DATA_MISR_RSLT_2 */
317bb772a59SSricharan #define EMIF_REG_DATA_TLMR_63_32_SHIFT		0
318bb772a59SSricharan #define EMIF_REG_DATA_TLMR_63_32_MASK		(0xffffffff << 0)
319bb772a59SSricharan 
320bb772a59SSricharan /* IODFT_DATA_MISR_RSLT_3 */
321bb772a59SSricharan #define EMIF_REG_DATA_TLMR_66_64_SHIFT		0
322bb772a59SSricharan #define EMIF_REG_DATA_TLMR_66_64_MASK		(0x7 << 0)
323bb772a59SSricharan 
324bb772a59SSricharan /* PERF_CNT_1 */
325bb772a59SSricharan #define EMIF_REG_COUNTER1_SHIFT			0
326bb772a59SSricharan #define EMIF_REG_COUNTER1_MASK			(0xffffffff << 0)
327bb772a59SSricharan 
328bb772a59SSricharan /* PERF_CNT_2 */
329bb772a59SSricharan #define EMIF_REG_COUNTER2_SHIFT			0
330bb772a59SSricharan #define EMIF_REG_COUNTER2_MASK			(0xffffffff << 0)
331bb772a59SSricharan 
332bb772a59SSricharan /* PERF_CNT_CFG */
333bb772a59SSricharan #define EMIF_REG_CNTR2_MCONNID_EN_SHIFT		31
334bb772a59SSricharan #define EMIF_REG_CNTR2_MCONNID_EN_MASK		(1 << 31)
335bb772a59SSricharan #define EMIF_REG_CNTR2_REGION_EN_SHIFT		30
336bb772a59SSricharan #define EMIF_REG_CNTR2_REGION_EN_MASK		(1 << 30)
337bb772a59SSricharan #define EMIF_REG_CNTR2_CFG_SHIFT			16
338bb772a59SSricharan #define EMIF_REG_CNTR2_CFG_MASK			(0xf << 16)
339bb772a59SSricharan #define EMIF_REG_CNTR1_MCONNID_EN_SHIFT		15
340bb772a59SSricharan #define EMIF_REG_CNTR1_MCONNID_EN_MASK		(1 << 15)
341bb772a59SSricharan #define EMIF_REG_CNTR1_REGION_EN_SHIFT		14
342bb772a59SSricharan #define EMIF_REG_CNTR1_REGION_EN_MASK		(1 << 14)
343bb772a59SSricharan #define EMIF_REG_CNTR1_CFG_SHIFT			0
344bb772a59SSricharan #define EMIF_REG_CNTR1_CFG_MASK			(0xf << 0)
345bb772a59SSricharan 
346bb772a59SSricharan /* PERF_CNT_SEL */
347bb772a59SSricharan #define EMIF_REG_MCONNID2_SHIFT			24
348bb772a59SSricharan #define EMIF_REG_MCONNID2_MASK			(0xff << 24)
349bb772a59SSricharan #define EMIF_REG_REGION_SEL2_SHIFT			16
350bb772a59SSricharan #define EMIF_REG_REGION_SEL2_MASK			(0x3 << 16)
351bb772a59SSricharan #define EMIF_REG_MCONNID1_SHIFT			8
352bb772a59SSricharan #define EMIF_REG_MCONNID1_MASK			(0xff << 8)
353bb772a59SSricharan #define EMIF_REG_REGION_SEL1_SHIFT			0
354bb772a59SSricharan #define EMIF_REG_REGION_SEL1_MASK			(0x3 << 0)
355bb772a59SSricharan 
356bb772a59SSricharan /* PERF_CNT_TIM */
357bb772a59SSricharan #define EMIF_REG_TOTAL_TIME_SHIFT			0
358bb772a59SSricharan #define EMIF_REG_TOTAL_TIME_MASK			(0xffffffff << 0)
359bb772a59SSricharan 
360bb772a59SSricharan /* READ_IDLE_CTRL */
361bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_SHIFT		16
362bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_MASK			(0xf << 16)
363bb772a59SSricharan #define EMIF_REG_READ_IDLE_INTERVAL_SHIFT		0
364bb772a59SSricharan #define EMIF_REG_READ_IDLE_INTERVAL_MASK		(0x1ff << 0)
365bb772a59SSricharan 
366bb772a59SSricharan /* READ_IDLE_CTRL_SHDW */
367bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_SHDW_SHIFT		16
368bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_SHDW_MASK		(0xf << 16)
369bb772a59SSricharan #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_SHIFT	0
370bb772a59SSricharan #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_MASK	(0x1ff << 0)
371bb772a59SSricharan 
372bb772a59SSricharan /* IRQ_EOI */
373bb772a59SSricharan #define EMIF_REG_EOI_SHIFT				0
374bb772a59SSricharan #define EMIF_REG_EOI_MASK				(1 << 0)
375bb772a59SSricharan 
376bb772a59SSricharan /* IRQSTATUS_RAW_SYS */
377bb772a59SSricharan #define EMIF_REG_DNV_SYS_SHIFT			2
378bb772a59SSricharan #define EMIF_REG_DNV_SYS_MASK			(1 << 2)
379bb772a59SSricharan #define EMIF_REG_TA_SYS_SHIFT			1
380bb772a59SSricharan #define EMIF_REG_TA_SYS_MASK			(1 << 1)
381bb772a59SSricharan #define EMIF_REG_ERR_SYS_SHIFT			0
382bb772a59SSricharan #define EMIF_REG_ERR_SYS_MASK			(1 << 0)
383bb772a59SSricharan 
384bb772a59SSricharan /* IRQSTATUS_RAW_LL */
385bb772a59SSricharan #define EMIF_REG_DNV_LL_SHIFT			2
386bb772a59SSricharan #define EMIF_REG_DNV_LL_MASK			(1 << 2)
387bb772a59SSricharan #define EMIF_REG_TA_LL_SHIFT			1
388bb772a59SSricharan #define EMIF_REG_TA_LL_MASK				(1 << 1)
389bb772a59SSricharan #define EMIF_REG_ERR_LL_SHIFT			0
390bb772a59SSricharan #define EMIF_REG_ERR_LL_MASK			(1 << 0)
391bb772a59SSricharan 
392bb772a59SSricharan /* IRQSTATUS_SYS */
393bb772a59SSricharan 
394bb772a59SSricharan /* IRQSTATUS_LL */
395bb772a59SSricharan 
396bb772a59SSricharan /* IRQENABLE_SET_SYS */
397bb772a59SSricharan #define EMIF_REG_EN_DNV_SYS_SHIFT			2
398bb772a59SSricharan #define EMIF_REG_EN_DNV_SYS_MASK			(1 << 2)
399bb772a59SSricharan #define EMIF_REG_EN_TA_SYS_SHIFT			1
400bb772a59SSricharan #define EMIF_REG_EN_TA_SYS_MASK			(1 << 1)
401bb772a59SSricharan #define EMIF_REG_EN_ERR_SYS_SHIFT			0
402bb772a59SSricharan #define EMIF_REG_EN_ERR_SYS_MASK			(1 << 0)
403bb772a59SSricharan 
404bb772a59SSricharan /* IRQENABLE_SET_LL */
405bb772a59SSricharan #define EMIF_REG_EN_DNV_LL_SHIFT			2
406bb772a59SSricharan #define EMIF_REG_EN_DNV_LL_MASK			(1 << 2)
407bb772a59SSricharan #define EMIF_REG_EN_TA_LL_SHIFT			1
408bb772a59SSricharan #define EMIF_REG_EN_TA_LL_MASK			(1 << 1)
409bb772a59SSricharan #define EMIF_REG_EN_ERR_LL_SHIFT			0
410bb772a59SSricharan #define EMIF_REG_EN_ERR_LL_MASK			(1 << 0)
411bb772a59SSricharan 
412bb772a59SSricharan /* IRQENABLE_CLR_SYS */
413bb772a59SSricharan 
414bb772a59SSricharan /* IRQENABLE_CLR_LL */
415bb772a59SSricharan 
416bb772a59SSricharan /* ZQ_CONFIG */
417bb772a59SSricharan #define EMIF_REG_ZQ_CS1EN_SHIFT			31
418bb772a59SSricharan #define EMIF_REG_ZQ_CS1EN_MASK			(1 << 31)
419bb772a59SSricharan #define EMIF_REG_ZQ_CS0EN_SHIFT			30
420bb772a59SSricharan #define EMIF_REG_ZQ_CS0EN_MASK			(1 << 30)
421bb772a59SSricharan #define EMIF_REG_ZQ_DUALCALEN_SHIFT			29
422bb772a59SSricharan #define EMIF_REG_ZQ_DUALCALEN_MASK			(1 << 29)
423bb772a59SSricharan #define EMIF_REG_ZQ_SFEXITEN_SHIFT			28
424bb772a59SSricharan #define EMIF_REG_ZQ_SFEXITEN_MASK			(1 << 28)
425bb772a59SSricharan #define EMIF_REG_ZQ_ZQINIT_MULT_SHIFT		18
426bb772a59SSricharan #define EMIF_REG_ZQ_ZQINIT_MULT_MASK		(0x3 << 18)
427bb772a59SSricharan #define EMIF_REG_ZQ_ZQCL_MULT_SHIFT			16
428bb772a59SSricharan #define EMIF_REG_ZQ_ZQCL_MULT_MASK			(0x3 << 16)
429bb772a59SSricharan #define EMIF_REG_ZQ_REFINTERVAL_SHIFT		0
430bb772a59SSricharan #define EMIF_REG_ZQ_REFINTERVAL_MASK		(0xffff << 0)
431bb772a59SSricharan 
432bb772a59SSricharan /* TEMP_ALERT_CONFIG */
433bb772a59SSricharan #define EMIF_REG_TA_CS1EN_SHIFT			31
434bb772a59SSricharan #define EMIF_REG_TA_CS1EN_MASK			(1 << 31)
435bb772a59SSricharan #define EMIF_REG_TA_CS0EN_SHIFT			30
436bb772a59SSricharan #define EMIF_REG_TA_CS0EN_MASK			(1 << 30)
437bb772a59SSricharan #define EMIF_REG_TA_SFEXITEN_SHIFT			28
438bb772a59SSricharan #define EMIF_REG_TA_SFEXITEN_MASK			(1 << 28)
439bb772a59SSricharan #define EMIF_REG_TA_DEVWDT_SHIFT			26
440bb772a59SSricharan #define EMIF_REG_TA_DEVWDT_MASK			(0x3 << 26)
441bb772a59SSricharan #define EMIF_REG_TA_DEVCNT_SHIFT			24
442bb772a59SSricharan #define EMIF_REG_TA_DEVCNT_MASK			(0x3 << 24)
443bb772a59SSricharan #define EMIF_REG_TA_REFINTERVAL_SHIFT		0
444bb772a59SSricharan #define EMIF_REG_TA_REFINTERVAL_MASK		(0x3fffff << 0)
445bb772a59SSricharan 
446bb772a59SSricharan /* OCP_ERR_LOG */
447bb772a59SSricharan #define EMIF_REG_MADDRSPACE_SHIFT			14
448bb772a59SSricharan #define EMIF_REG_MADDRSPACE_MASK			(0x3 << 14)
449bb772a59SSricharan #define EMIF_REG_MBURSTSEQ_SHIFT			11
450bb772a59SSricharan #define EMIF_REG_MBURSTSEQ_MASK			(0x7 << 11)
451bb772a59SSricharan #define EMIF_REG_MCMD_SHIFT				8
452bb772a59SSricharan #define EMIF_REG_MCMD_MASK				(0x7 << 8)
453bb772a59SSricharan #define EMIF_REG_MCONNID_SHIFT			0
454bb772a59SSricharan #define EMIF_REG_MCONNID_MASK			(0xff << 0)
455bb772a59SSricharan 
456bb772a59SSricharan /* DDR_PHY_CTRL_1 */
457bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_1_SHIFT		4
458bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_1_MASK		(0xfffffff << 4)
459bb772a59SSricharan #define EMIF_REG_READ_LATENCY_SHIFT			0
460bb772a59SSricharan #define EMIF_REG_READ_LATENCY_MASK			(0xf << 0)
461bb772a59SSricharan #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHIFT		4
462bb772a59SSricharan #define EMIF_REG_DLL_SLAVE_DLY_CTRL_MASK		(0xFF << 4)
463bb772a59SSricharan #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHIFT	12
464bb772a59SSricharan #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_MASK	(0xFFFFF << 12)
465bb772a59SSricharan 
466bb772a59SSricharan /* DDR_PHY_CTRL_1_SHDW */
467bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_SHIFT		4
468bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_MASK		(0xfffffff << 4)
469bb772a59SSricharan #define EMIF_REG_READ_LATENCY_SHDW_SHIFT		0
470bb772a59SSricharan #define EMIF_REG_READ_LATENCY_SHDW_MASK		(0xf << 0)
471bb772a59SSricharan #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_SHIFT	4
472bb772a59SSricharan #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_MASK	(0xFF << 4)
473bb772a59SSricharan #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_SHIFT 12
474bb772a59SSricharan #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_MASK	(0xFFFFF << 12)
475bb772a59SSricharan 
476bb772a59SSricharan /* DDR_PHY_CTRL_2 */
477bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_2_SHIFT		0
478bb772a59SSricharan #define EMIF_REG_DDR_PHY_CTRL_2_MASK		(0xffffffff << 0)
479bb772a59SSricharan 
480784ab7c5SLokesh Vutla /*EMIF_READ_WRITE_LEVELING_CONTROL*/
481784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVLFULL_START_SHIFT	31
482784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVLFULL_START_MASK		(1 << 31)
483784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVLINC_PRE_SHIFT		24
484784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVLINC_PRE_MASK		(0x7F << 24)
485784ab7c5SLokesh Vutla #define EMIF_REG_RDLVLINC_INT_SHIFT		16
486784ab7c5SLokesh Vutla #define EMIF_REG_RDLVLINC_INT_MASK		(0xFF << 16)
487784ab7c5SLokesh Vutla #define EMIF_REG_RDLVLGATEINC_INT_SHIFT		8
488784ab7c5SLokesh Vutla #define EMIF_REG_RDLVLGATEINC_INT_MASK		(0xFF << 8)
489784ab7c5SLokesh Vutla #define EMIF_REG_WRLVLINC_INT_SHIFT		0
490784ab7c5SLokesh Vutla #define EMIF_REG_WRLVLINC_INT_MASK		(0xFF << 0)
491784ab7c5SLokesh Vutla 
492784ab7c5SLokesh Vutla /*EMIF_READ_WRITE_LEVELING_RAMP_CONTROL*/
493784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVL_EN_SHIFT		31
494784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVL_EN_MASK		(1 << 31)
495784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVLINC_RMP_PRE_SHIFT	24
496784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVLINC_RMP_PRE_MASK	(0x7F << 24)
497784ab7c5SLokesh Vutla #define EMIF_REG_RDLVLINC_RMP_INT_SHIFT		16
498784ab7c5SLokesh Vutla #define EMIF_REG_RDLVLINC_RMP_INT_MASK		(0xFF << 16)
499784ab7c5SLokesh Vutla #define EMIF_REG_RDLVLGATEINC_RMP_INT_SHIFT	8
500784ab7c5SLokesh Vutla #define EMIF_REG_RDLVLGATEINC_RMP_INT_MASK	(0xFF << 8)
501784ab7c5SLokesh Vutla #define EMIF_REG_WRLVLINC_RMP_INT_SHIFT		0
502784ab7c5SLokesh Vutla #define EMIF_REG_WRLVLINC_RMP_INT_MASK		(0xFF << 0)
503784ab7c5SLokesh Vutla 
504784ab7c5SLokesh Vutla /*EMIF_READ_WRITE_LEVELING_RAMP_WINDOW*/
505784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVLINC_RMP_WIN_SHIFT	0
506784ab7c5SLokesh Vutla #define EMIF_REG_RDWRLVLINC_RMP_WIN_MASK	(0x1FFF << 0)
507784ab7c5SLokesh Vutla 
508784ab7c5SLokesh Vutla /*Leveling Fields */
509784ab7c5SLokesh Vutla #define DDR3_WR_LVL_INT		0x73
510784ab7c5SLokesh Vutla #define DDR3_RD_LVL_INT		0x33
511784ab7c5SLokesh Vutla #define DDR3_RD_LVL_GATE_INT	0x59
512784ab7c5SLokesh Vutla #define RD_RW_LVL_INC_PRE	0x0
513784ab7c5SLokesh Vutla #define DDR3_FULL_LVL		(1 << EMIF_REG_RDWRLVL_EN_SHIFT)
514784ab7c5SLokesh Vutla 
515784ab7c5SLokesh Vutla #define DDR3_INC_LVL	((DDR3_WR_LVL_INT << EMIF_REG_WRLVLINC_INT_SHIFT)   \
516784ab7c5SLokesh Vutla 		| (DDR3_RD_LVL_GATE_INT << EMIF_REG_RDLVLGATEINC_INT_SHIFT) \
517784ab7c5SLokesh Vutla 		| (DDR3_RD_LVL_INT << EMIF_REG_RDLVLINC_RMP_INT_SHIFT)      \
518784ab7c5SLokesh Vutla 		| (RD_RW_LVL_INC_PRE << EMIF_REG_RDWRLVLINC_RMP_PRE_SHIFT))
519784ab7c5SLokesh Vutla 
520784ab7c5SLokesh Vutla #define SDRAM_CONFIG_EXT_RD_LVL_11_SAMPLES	0x0000C1A7
521784ab7c5SLokesh Vutla #define SDRAM_CONFIG_EXT_RD_LVL_4_SAMPLES	0x000001A7
522784ab7c5SLokesh Vutla 
523bb772a59SSricharan /* DMM */
524bb772a59SSricharan #define DMM_BASE			0x4E000040
525bb772a59SSricharan 
526bb772a59SSricharan /* Memory Adapter */
527bb772a59SSricharan #define MA_BASE				0x482AF040
528bb772a59SSricharan 
529bb772a59SSricharan /* DMM_LISA_MAP */
530bb772a59SSricharan #define EMIF_SYS_ADDR_SHIFT		24
531bb772a59SSricharan #define EMIF_SYS_ADDR_MASK		(0xff << 24)
532bb772a59SSricharan #define EMIF_SYS_SIZE_SHIFT		20
533bb772a59SSricharan #define EMIF_SYS_SIZE_MASK		(0x7 << 20)
534bb772a59SSricharan #define EMIF_SDRC_INTL_SHIFT	18
535bb772a59SSricharan #define EMIF_SDRC_INTL_MASK		(0x3 << 18)
536bb772a59SSricharan #define EMIF_SDRC_ADDRSPC_SHIFT	16
537bb772a59SSricharan #define EMIF_SDRC_ADDRSPC_MASK	(0x3 << 16)
538bb772a59SSricharan #define EMIF_SDRC_MAP_SHIFT		8
539bb772a59SSricharan #define EMIF_SDRC_MAP_MASK		(0x3 << 8)
540bb772a59SSricharan #define EMIF_SDRC_ADDR_SHIFT	0
541bb772a59SSricharan #define EMIF_SDRC_ADDR_MASK		(0xff << 0)
542bb772a59SSricharan 
543bb772a59SSricharan /* DMM_LISA_MAP fields */
544bb772a59SSricharan #define DMM_SDRC_MAP_UNMAPPED		0
545bb772a59SSricharan #define DMM_SDRC_MAP_EMIF1_ONLY		1
546bb772a59SSricharan #define DMM_SDRC_MAP_EMIF2_ONLY		2
547bb772a59SSricharan #define DMM_SDRC_MAP_EMIF1_AND_EMIF2	3
548bb772a59SSricharan 
549bb772a59SSricharan #define DMM_SDRC_INTL_NONE		0
550bb772a59SSricharan #define DMM_SDRC_INTL_128B		1
551bb772a59SSricharan #define DMM_SDRC_INTL_256B		2
552bb772a59SSricharan #define DMM_SDRC_INTL_512		3
553bb772a59SSricharan 
554bb772a59SSricharan #define DMM_SDRC_ADDR_SPC_SDRAM		0
555bb772a59SSricharan #define DMM_SDRC_ADDR_SPC_NVM		1
556bb772a59SSricharan #define DMM_SDRC_ADDR_SPC_INVALID	2
557bb772a59SSricharan 
558bb772a59SSricharan #define DMM_LISA_MAP_INTERLEAVED_BASE_VAL		(\
559bb772a59SSricharan 	(DMM_SDRC_MAP_EMIF1_AND_EMIF2 << EMIF_SDRC_MAP_SHIFT) |\
560bb772a59SSricharan 	(DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT) |\
561bb772a59SSricharan 	(DMM_SDRC_INTL_128B << EMIF_SDRC_INTL_SHIFT) |\
562bb772a59SSricharan 	(CONFIG_SYS_SDRAM_BASE << EMIF_SYS_ADDR_SHIFT))
563bb772a59SSricharan 
564bb772a59SSricharan #define DMM_LISA_MAP_EMIF1_ONLY_BASE_VAL	(\
565bb772a59SSricharan 	(DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\
566bb772a59SSricharan 	(DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\
567bb772a59SSricharan 	(DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT))
568bb772a59SSricharan 
569bb772a59SSricharan #define DMM_LISA_MAP_EMIF2_ONLY_BASE_VAL	(\
570bb772a59SSricharan 	(DMM_SDRC_MAP_EMIF2_ONLY << EMIF_SDRC_MAP_SHIFT)|\
571bb772a59SSricharan 	(DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\
572bb772a59SSricharan 	(DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT))
573bb772a59SSricharan 
574bb772a59SSricharan /* Trap for invalid TILER PAT entries */
575bb772a59SSricharan #define DMM_LISA_MAP_0_INVAL_ADDR_TRAP		(\
576bb772a59SSricharan 	(0  << EMIF_SDRC_ADDR_SHIFT) |\
577bb772a59SSricharan 	(DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\
578bb772a59SSricharan 	(DMM_SDRC_ADDR_SPC_INVALID << EMIF_SDRC_ADDRSPC_SHIFT)|\
579bb772a59SSricharan 	(DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)|\
580bb772a59SSricharan 	(0xFF << EMIF_SYS_ADDR_SHIFT))
581bb772a59SSricharan 
582f4010734SSRICHARAN R #define EMIF_EXT_PHY_CTRL_TIMING_REG	0x5
583f4010734SSRICHARAN R #define EMIF_EXT_PHY_CTRL_CONST_REG	0x13
584bb772a59SSricharan 
585bb772a59SSricharan /* Reg mapping structure */
586bb772a59SSricharan struct emif_reg_struct {
587bb772a59SSricharan 	u32 emif_mod_id_rev;
588bb772a59SSricharan 	u32 emif_status;
589bb772a59SSricharan 	u32 emif_sdram_config;
590bb772a59SSricharan 	u32 emif_lpddr2_nvm_config;
591bb772a59SSricharan 	u32 emif_sdram_ref_ctrl;
592bb772a59SSricharan 	u32 emif_sdram_ref_ctrl_shdw;
593bb772a59SSricharan 	u32 emif_sdram_tim_1;
594bb772a59SSricharan 	u32 emif_sdram_tim_1_shdw;
595bb772a59SSricharan 	u32 emif_sdram_tim_2;
596bb772a59SSricharan 	u32 emif_sdram_tim_2_shdw;
597bb772a59SSricharan 	u32 emif_sdram_tim_3;
598bb772a59SSricharan 	u32 emif_sdram_tim_3_shdw;
599bb772a59SSricharan 	u32 emif_lpddr2_nvm_tim;
600bb772a59SSricharan 	u32 emif_lpddr2_nvm_tim_shdw;
601bb772a59SSricharan 	u32 emif_pwr_mgmt_ctrl;
602bb772a59SSricharan 	u32 emif_pwr_mgmt_ctrl_shdw;
603bb772a59SSricharan 	u32 emif_lpddr2_mode_reg_data;
604bb772a59SSricharan 	u32 padding1[1];
605bb772a59SSricharan 	u32 emif_lpddr2_mode_reg_data_es2;
606bb772a59SSricharan 	u32 padding11[1];
607bb772a59SSricharan 	u32 emif_lpddr2_mode_reg_cfg;
608bb772a59SSricharan 	u32 emif_l3_config;
609bb772a59SSricharan 	u32 emif_l3_cfg_val_1;
610bb772a59SSricharan 	u32 emif_l3_cfg_val_2;
611bb772a59SSricharan 	u32 emif_iodft_tlgc;
612bb772a59SSricharan 	u32 padding2[7];
613bb772a59SSricharan 	u32 emif_perf_cnt_1;
614bb772a59SSricharan 	u32 emif_perf_cnt_2;
615bb772a59SSricharan 	u32 emif_perf_cnt_cfg;
616bb772a59SSricharan 	u32 emif_perf_cnt_sel;
617bb772a59SSricharan 	u32 emif_perf_cnt_tim;
618bb772a59SSricharan 	u32 padding3;
619bb772a59SSricharan 	u32 emif_read_idlectrl;
620bb772a59SSricharan 	u32 emif_read_idlectrl_shdw;
621bb772a59SSricharan 	u32 padding4;
622bb772a59SSricharan 	u32 emif_irqstatus_raw_sys;
623bb772a59SSricharan 	u32 emif_irqstatus_raw_ll;
624bb772a59SSricharan 	u32 emif_irqstatus_sys;
625bb772a59SSricharan 	u32 emif_irqstatus_ll;
626bb772a59SSricharan 	u32 emif_irqenable_set_sys;
627bb772a59SSricharan 	u32 emif_irqenable_set_ll;
628bb772a59SSricharan 	u32 emif_irqenable_clr_sys;
629bb772a59SSricharan 	u32 emif_irqenable_clr_ll;
630bb772a59SSricharan 	u32 padding5;
631bb772a59SSricharan 	u32 emif_zq_config;
632bb772a59SSricharan 	u32 emif_temp_alert_config;
633bb772a59SSricharan 	u32 emif_l3_err_log;
634f4010734SSRICHARAN R 	u32 emif_rd_wr_lvl_rmp_win;
635f4010734SSRICHARAN R 	u32 emif_rd_wr_lvl_rmp_ctl;
636f4010734SSRICHARAN R 	u32 emif_rd_wr_lvl_ctl;
637f4010734SSRICHARAN R 	u32 padding6[1];
638bb772a59SSricharan 	u32 emif_ddr_phy_ctrl_1;
639bb772a59SSricharan 	u32 emif_ddr_phy_ctrl_1_shdw;
640bb772a59SSricharan 	u32 emif_ddr_phy_ctrl_2;
641f4010734SSRICHARAN R 	u32 padding7[12];
642f4010734SSRICHARAN R 	u32 emif_rd_wr_exec_thresh;
643f4010734SSRICHARAN R 	u32 padding8[55];
644f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_1;
645f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_1_shdw;
646f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_2;
647f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_2_shdw;
648f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_3;
649f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_3_shdw;
650f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_4;
651f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_4_shdw;
652f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_5;
653f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_5_shdw;
654f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_6;
655f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_6_shdw;
656f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_7;
657f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_7_shdw;
658f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_8;
659f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_8_shdw;
660f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_9;
661f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_9_shdw;
662f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_10;
663f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_10_shdw;
664f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_11;
665f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_11_shdw;
666f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_12;
667f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_12_shdw;
668f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_13;
669f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_13_shdw;
670f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_14;
671f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_14_shdw;
672f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_15;
673f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_15_shdw;
674f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_16;
675f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_16_shdw;
676f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_17;
677f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_17_shdw;
678f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_18;
679f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_18_shdw;
680f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_19;
681f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_19_shdw;
682f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_20;
683f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_20_shdw;
684f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_21;
685f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_21_shdw;
686f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_22;
687f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_22_shdw;
688f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_23;
689f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_23_shdw;
690f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_24;
691f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_24_shdw;
692bb772a59SSricharan };
693bb772a59SSricharan 
694bb772a59SSricharan struct dmm_lisa_map_regs {
695bb772a59SSricharan 	u32 dmm_lisa_map_0;
696bb772a59SSricharan 	u32 dmm_lisa_map_1;
697bb772a59SSricharan 	u32 dmm_lisa_map_2;
698bb772a59SSricharan 	u32 dmm_lisa_map_3;
699bb772a59SSricharan };
700bb772a59SSricharan 
701bb772a59SSricharan #define CS0	0
702bb772a59SSricharan #define CS1	1
703bb772a59SSricharan /* The maximum frequency at which the LPDDR2 interface can operate in Hz*/
704bb772a59SSricharan #define MAX_LPDDR2_FREQ	400000000	/* 400 MHz */
705bb772a59SSricharan 
706bb772a59SSricharan /*
707bb772a59SSricharan  * The period of DDR clk is represented as numerator and denominator for
708bb772a59SSricharan  * better accuracy in integer based calculations. However, if the numerator
709bb772a59SSricharan  * and denominator are very huge there may be chances of overflow in
710bb772a59SSricharan  * calculations. So, as a trade-off keep denominator(and consequently
711bb772a59SSricharan  * numerator) within a limit sacrificing some accuracy - but not much
712bb772a59SSricharan  * If denominator and numerator are already small (such as at 400 MHz)
713bb772a59SSricharan  * no adjustment is needed
714bb772a59SSricharan  */
715bb772a59SSricharan #define EMIF_PERIOD_DEN_LIMIT	1000
716bb772a59SSricharan /*
717bb772a59SSricharan  * Maximum number of different frequencies supported by EMIF driver
718bb772a59SSricharan  * Determines the number of entries in the pointer array for register
719bb772a59SSricharan  * cache
720bb772a59SSricharan  */
721bb772a59SSricharan #define EMIF_MAX_NUM_FREQUENCIES	6
722bb772a59SSricharan /*
723bb772a59SSricharan  * Indices into the Addressing Table array.
724bb772a59SSricharan  * One entry each for all the different types of devices with different
725bb772a59SSricharan  * addressing schemes
726bb772a59SSricharan  */
727bb772a59SSricharan #define ADDR_TABLE_INDEX64M	0
728bb772a59SSricharan #define ADDR_TABLE_INDEX128M	1
729bb772a59SSricharan #define ADDR_TABLE_INDEX256M	2
730bb772a59SSricharan #define ADDR_TABLE_INDEX512M	3
731bb772a59SSricharan #define ADDR_TABLE_INDEX1GS4	4
732bb772a59SSricharan #define ADDR_TABLE_INDEX2GS4	5
733bb772a59SSricharan #define ADDR_TABLE_INDEX4G	6
734bb772a59SSricharan #define ADDR_TABLE_INDEX8G	7
735bb772a59SSricharan #define ADDR_TABLE_INDEX1GS2	8
736bb772a59SSricharan #define ADDR_TABLE_INDEX2GS2	9
737bb772a59SSricharan #define ADDR_TABLE_INDEXMAX	10
738bb772a59SSricharan 
739bb772a59SSricharan /* Number of Row bits */
740bb772a59SSricharan #define ROW_9  0
741bb772a59SSricharan #define ROW_10 1
742bb772a59SSricharan #define ROW_11 2
743bb772a59SSricharan #define ROW_12 3
744bb772a59SSricharan #define ROW_13 4
745bb772a59SSricharan #define ROW_14 5
746bb772a59SSricharan #define ROW_15 6
747bb772a59SSricharan #define ROW_16 7
748bb772a59SSricharan 
749bb772a59SSricharan /* Number of Column bits */
750bb772a59SSricharan #define COL_8   0
751bb772a59SSricharan #define COL_9   1
752bb772a59SSricharan #define COL_10  2
753bb772a59SSricharan #define COL_11  3
754bb772a59SSricharan #define COL_7   4 /*Not supported by OMAP included for completeness */
755bb772a59SSricharan 
756bb772a59SSricharan /* Number of Banks*/
757bb772a59SSricharan #define BANKS1 0
758bb772a59SSricharan #define BANKS2 1
759bb772a59SSricharan #define BANKS4 2
760bb772a59SSricharan #define BANKS8 3
761bb772a59SSricharan 
762bb772a59SSricharan /* Refresh rate in micro seconds x 10 */
763bb772a59SSricharan #define T_REFI_15_6	156
764bb772a59SSricharan #define T_REFI_7_8	78
765bb772a59SSricharan #define T_REFI_3_9	39
766bb772a59SSricharan 
767bb772a59SSricharan #define EBANK_CS1_DIS	0
768bb772a59SSricharan #define EBANK_CS1_EN	1
769bb772a59SSricharan 
770bb772a59SSricharan /* Read Latency used by the device at reset */
771bb772a59SSricharan #define RL_BOOT		3
772bb772a59SSricharan /* Read Latency for the highest frequency you want to use */
773bb772a59SSricharan #ifdef CONFIG_OMAP54XX
774bb772a59SSricharan #define RL_FINAL	8
775bb772a59SSricharan #else
776bb772a59SSricharan #define RL_FINAL	6
777bb772a59SSricharan #endif
778bb772a59SSricharan 
779bb772a59SSricharan 
780bb772a59SSricharan /* Interleaving policies at EMIF level- between banks and Chip Selects */
781bb772a59SSricharan #define EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING	0
782bb772a59SSricharan #define EMIF_INTERLEAVING_POLICY_NO_BANK_INTERLEAVING	3
783bb772a59SSricharan 
784bb772a59SSricharan /*
785bb772a59SSricharan  * Interleaving policy to be used
786bb772a59SSricharan  * Currently set to MAX interleaving for better performance
787bb772a59SSricharan  */
788bb772a59SSricharan #define EMIF_INTERLEAVING_POLICY EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING
789bb772a59SSricharan 
790bb772a59SSricharan /* State of the core voltage:
791bb772a59SSricharan  * This is important for some parameters such as read idle control and
792bb772a59SSricharan  * ZQ calibration timings. Timings are much stricter when voltage ramp
793bb772a59SSricharan  * is happening compared to when the voltage is stable.
794bb772a59SSricharan  * We need to calculate two sets of values for these parameters and use
795bb772a59SSricharan  * them accordingly
796bb772a59SSricharan  */
797bb772a59SSricharan #define LPDDR2_VOLTAGE_STABLE	0
798bb772a59SSricharan #define LPDDR2_VOLTAGE_RAMPING	1
799bb772a59SSricharan 
800bb772a59SSricharan /* Length of the forced read idle period in terms of cycles */
801bb772a59SSricharan #define EMIF_REG_READ_IDLE_LEN_VAL	5
802bb772a59SSricharan 
803bb772a59SSricharan /* Interval between forced 'read idles' */
804bb772a59SSricharan /* To be used when voltage is changed for DPS/DVFS - 1us */
805bb772a59SSricharan #define READ_IDLE_INTERVAL_DVFS		(1*1000)
806bb772a59SSricharan /*
807bb772a59SSricharan  * To be used when voltage is not scaled except by Smart Reflex
808bb772a59SSricharan  * 50us - or maximum value will do
809bb772a59SSricharan  */
810bb772a59SSricharan #define READ_IDLE_INTERVAL_NORMAL	(50*1000)
811bb772a59SSricharan 
812bb772a59SSricharan 
813bb772a59SSricharan /*
814bb772a59SSricharan  * Unless voltage is changing due to DVFS one ZQCS command every 50ms should
815bb772a59SSricharan  * be enough. This shoule be enough also in the case when voltage is changing
816bb772a59SSricharan  * due to smart-reflex.
817bb772a59SSricharan  */
818bb772a59SSricharan #define EMIF_ZQCS_INTERVAL_NORMAL_IN_US	(50*1000)
819bb772a59SSricharan /*
820bb772a59SSricharan  * If voltage is changing due to DVFS ZQCS should be performed more
821bb772a59SSricharan  * often(every 50us)
822bb772a59SSricharan  */
823bb772a59SSricharan #define EMIF_ZQCS_INTERVAL_DVFS_IN_US	50
824bb772a59SSricharan 
825bb772a59SSricharan /* The interval between ZQCL commands as a multiple of ZQCS interval */
826bb772a59SSricharan #define REG_ZQ_ZQCL_MULT		4
827bb772a59SSricharan /* The interval between ZQINIT commands as a multiple of ZQCL interval */
828bb772a59SSricharan #define REG_ZQ_ZQINIT_MULT		3
829bb772a59SSricharan /* Enable ZQ Calibration on exiting Self-refresh */
830bb772a59SSricharan #define REG_ZQ_SFEXITEN_ENABLE		1
831bb772a59SSricharan /*
832bb772a59SSricharan  * ZQ Calibration simultaneously on both chip-selects:
833bb772a59SSricharan  * Needs one calibration resistor per CS
834bb772a59SSricharan  * None of the boards that we know of have this capability
835bb772a59SSricharan  * So disabled by default
836bb772a59SSricharan  */
837bb772a59SSricharan #define REG_ZQ_DUALCALEN_DISABLE	0
838bb772a59SSricharan /*
839bb772a59SSricharan  * Enable ZQ Calibration by default on CS0. If we are asked to program
840bb772a59SSricharan  * the EMIF there will be something connected to CS0 for sure
841bb772a59SSricharan  */
842bb772a59SSricharan #define REG_ZQ_CS0EN_ENABLE		1
843bb772a59SSricharan 
844bb772a59SSricharan /* EMIF_PWR_MGMT_CTRL register */
845bb772a59SSricharan /* Low power modes */
846bb772a59SSricharan #define LP_MODE_DISABLE		0
847bb772a59SSricharan #define LP_MODE_CLOCK_STOP	1
848bb772a59SSricharan #define LP_MODE_SELF_REFRESH	2
849bb772a59SSricharan #define LP_MODE_PWR_DN		3
850bb772a59SSricharan 
851bb772a59SSricharan /* REG_DPD_EN */
852bb772a59SSricharan #define DPD_DISABLE	0
853bb772a59SSricharan #define DPD_ENABLE	1
854bb772a59SSricharan 
855bb772a59SSricharan /* Maximum delay before Low Power Modes */
856f4010734SSRICHARAN R #ifndef CONFIG_OMAP54XX
857bb772a59SSricharan #define REG_CS_TIM		0xF
858f4010734SSRICHARAN R #else
859f4010734SSRICHARAN R #define REG_CS_TIM		0x0
860f4010734SSRICHARAN R #endif
861bb772a59SSricharan #define REG_SR_TIM		0xF
862bb772a59SSricharan #define REG_PD_TIM		0xF
863bb772a59SSricharan 
864bb772a59SSricharan /* EMIF_PWR_MGMT_CTRL register */
865bb772a59SSricharan #define EMIF_PWR_MGMT_CTRL (\
866bb772a59SSricharan 	((REG_CS_TIM << EMIF_REG_CS_TIM_SHIFT) & EMIF_REG_CS_TIM_MASK)|\
867bb772a59SSricharan 	((REG_SR_TIM << EMIF_REG_SR_TIM_SHIFT) & EMIF_REG_SR_TIM_MASK)|\
868bb772a59SSricharan 	((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\
869bb772a59SSricharan 	((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\
870bb772a59SSricharan 	((LP_MODE_DISABLE << EMIF_REG_LP_MODE_SHIFT)\
871bb772a59SSricharan 			& EMIF_REG_LP_MODE_MASK) |\
872bb772a59SSricharan 	((DPD_DISABLE << EMIF_REG_DPD_EN_SHIFT)\
873bb772a59SSricharan 			& EMIF_REG_DPD_EN_MASK))\
874bb772a59SSricharan 
875bb772a59SSricharan #define EMIF_PWR_MGMT_CTRL_SHDW (\
876bb772a59SSricharan 	((REG_CS_TIM << EMIF_REG_CS_TIM_SHDW_SHIFT)\
877bb772a59SSricharan 			& EMIF_REG_CS_TIM_SHDW_MASK) |\
878bb772a59SSricharan 	((REG_SR_TIM << EMIF_REG_SR_TIM_SHDW_SHIFT)\
879bb772a59SSricharan 			& EMIF_REG_SR_TIM_SHDW_MASK) |\
880bb772a59SSricharan 	((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\
881bb772a59SSricharan 			& EMIF_REG_PD_TIM_SHDW_MASK) |\
882bb772a59SSricharan 	((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\
883bb772a59SSricharan 			& EMIF_REG_PD_TIM_SHDW_MASK))
884bb772a59SSricharan 
885bb772a59SSricharan /* EMIF_L3_CONFIG register value */
886bb772a59SSricharan #define EMIF_L3_CONFIG_VAL_SYS_10_LL_0	0x0A0000FF
887bb772a59SSricharan #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_3_LL_0	0x0A300000
888f4010734SSRICHARAN R #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_5_LL_0	0x0A500000
889bb772a59SSricharan 
890bb772a59SSricharan /*
891bb772a59SSricharan  * Value of bits 12:31 of DDR_PHY_CTRL_1 register:
892bb772a59SSricharan  * All these fields have magic values dependent on frequency and
893bb772a59SSricharan  * determined by PHY and DLL integration with EMIF. Setting the magic
894bb772a59SSricharan  * values suggested by hw team.
895bb772a59SSricharan  */
896bb772a59SSricharan #define EMIF_DDR_PHY_CTRL_1_BASE_VAL			0x049FF
897bb772a59SSricharan #define EMIF_DLL_SLAVE_DLY_CTRL_400_MHZ			0x41
898bb772a59SSricharan #define EMIF_DLL_SLAVE_DLY_CTRL_200_MHZ			0x80
899bb772a59SSricharan #define EMIF_DLL_SLAVE_DLY_CTRL_100_MHZ_AND_LESS	0xFF
900bb772a59SSricharan 
901bb772a59SSricharan /*
902bb772a59SSricharan * MR1 value:
903bb772a59SSricharan * Burst length	: 8
904bb772a59SSricharan * Burst type	: sequential
905bb772a59SSricharan * Wrap		: enabled
906bb772a59SSricharan * nWR		: 3(default). EMIF does not do pre-charge.
907bb772a59SSricharan *		: So nWR is don't care
908bb772a59SSricharan */
909bb772a59SSricharan #define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3	0x23
910f4010734SSRICHARAN R #define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_8	0xc3
911bb772a59SSricharan 
912bb772a59SSricharan /* MR2 */
913bb772a59SSricharan #define MR2_RL3_WL1			1
914bb772a59SSricharan #define MR2_RL4_WL2			2
915bb772a59SSricharan #define MR2_RL5_WL2			3
916bb772a59SSricharan #define MR2_RL6_WL3			4
917bb772a59SSricharan 
918bb772a59SSricharan /* MR10: ZQ calibration codes */
919bb772a59SSricharan #define MR10_ZQ_ZQCS		0x56
920bb772a59SSricharan #define MR10_ZQ_ZQCL		0xAB
921bb772a59SSricharan #define MR10_ZQ_ZQINIT		0xFF
922bb772a59SSricharan #define MR10_ZQ_ZQRESET		0xC3
923bb772a59SSricharan 
924bb772a59SSricharan /* TEMP_ALERT_CONFIG */
925bb772a59SSricharan #define TEMP_ALERT_POLL_INTERVAL_MS	360 /* for temp gradient - 5 C/s */
926bb772a59SSricharan #define TEMP_ALERT_CONFIG_DEVCT_1	0
927bb772a59SSricharan #define TEMP_ALERT_CONFIG_DEVWDT_32	2
928bb772a59SSricharan 
929bb772a59SSricharan /* MR16 value: refresh full array(no partial array self refresh) */
930bb772a59SSricharan #define MR16_REF_FULL_ARRAY	0
931bb772a59SSricharan 
932bb772a59SSricharan /*
933bb772a59SSricharan  * Maximum number of entries we keep in our array of timing tables
934bb772a59SSricharan  * We need not keep all the speed bins supported by the device
935bb772a59SSricharan  * We need to keep timing tables for only the speed bins that we
936bb772a59SSricharan  * are interested in
937bb772a59SSricharan  */
938bb772a59SSricharan #define MAX_NUM_SPEEDBINS	4
939bb772a59SSricharan 
940bb772a59SSricharan /* LPDDR2 Densities */
941bb772a59SSricharan #define LPDDR2_DENSITY_64Mb	0
942bb772a59SSricharan #define LPDDR2_DENSITY_128Mb	1
943bb772a59SSricharan #define LPDDR2_DENSITY_256Mb	2
944bb772a59SSricharan #define LPDDR2_DENSITY_512Mb	3
945bb772a59SSricharan #define LPDDR2_DENSITY_1Gb	4
946bb772a59SSricharan #define LPDDR2_DENSITY_2Gb	5
947bb772a59SSricharan #define LPDDR2_DENSITY_4Gb	6
948bb772a59SSricharan #define LPDDR2_DENSITY_8Gb	7
949bb772a59SSricharan #define LPDDR2_DENSITY_16Gb	8
950bb772a59SSricharan #define LPDDR2_DENSITY_32Gb	9
951bb772a59SSricharan 
952bb772a59SSricharan /* LPDDR2 type */
953bb772a59SSricharan #define	LPDDR2_TYPE_S4	0
954bb772a59SSricharan #define	LPDDR2_TYPE_S2	1
955bb772a59SSricharan #define	LPDDR2_TYPE_NVM	2
956bb772a59SSricharan 
957bb772a59SSricharan /* LPDDR2 IO width */
958bb772a59SSricharan #define	LPDDR2_IO_WIDTH_32	0
959bb772a59SSricharan #define	LPDDR2_IO_WIDTH_16	1
960bb772a59SSricharan #define	LPDDR2_IO_WIDTH_8	2
961bb772a59SSricharan 
962bb772a59SSricharan /* Mode register numbers */
963bb772a59SSricharan #define LPDDR2_MR0	0
964bb772a59SSricharan #define LPDDR2_MR1	1
965bb772a59SSricharan #define LPDDR2_MR2	2
966bb772a59SSricharan #define LPDDR2_MR3	3
967bb772a59SSricharan #define LPDDR2_MR4	4
968bb772a59SSricharan #define LPDDR2_MR5	5
969bb772a59SSricharan #define LPDDR2_MR6	6
970bb772a59SSricharan #define LPDDR2_MR7	7
971bb772a59SSricharan #define LPDDR2_MR8	8
972bb772a59SSricharan #define LPDDR2_MR9	9
973bb772a59SSricharan #define LPDDR2_MR10	10
974bb772a59SSricharan #define LPDDR2_MR11	11
975bb772a59SSricharan #define LPDDR2_MR16	16
976bb772a59SSricharan #define LPDDR2_MR17	17
977bb772a59SSricharan #define LPDDR2_MR18	18
978bb772a59SSricharan 
979bb772a59SSricharan /* MR0 */
980bb772a59SSricharan #define LPDDR2_MR0_DAI_SHIFT	0
981bb772a59SSricharan #define LPDDR2_MR0_DAI_MASK	1
982bb772a59SSricharan #define LPDDR2_MR0_DI_SHIFT	1
983bb772a59SSricharan #define LPDDR2_MR0_DI_MASK	(1 << 1)
984bb772a59SSricharan #define LPDDR2_MR0_DNVI_SHIFT	2
985bb772a59SSricharan #define LPDDR2_MR0_DNVI_MASK	(1 << 2)
986bb772a59SSricharan 
987bb772a59SSricharan /* MR4 */
988bb772a59SSricharan #define MR4_SDRAM_REF_RATE_SHIFT	0
989bb772a59SSricharan #define MR4_SDRAM_REF_RATE_MASK		7
990bb772a59SSricharan #define MR4_TUF_SHIFT			7
991bb772a59SSricharan #define MR4_TUF_MASK			(1 << 7)
992bb772a59SSricharan 
993bb772a59SSricharan /* MR4 SDRAM Refresh Rate field values */
994bb772a59SSricharan #define SDRAM_TEMP_LESS_LOW_SHUTDOWN			0x0
995bb772a59SSricharan #define SDRAM_TEMP_LESS_4X_REFRESH_AND_TIMINGS		0x1
996bb772a59SSricharan #define SDRAM_TEMP_LESS_2X_REFRESH_AND_TIMINGS		0x2
997bb772a59SSricharan #define SDRAM_TEMP_NOMINAL				0x3
998bb772a59SSricharan #define SDRAM_TEMP_RESERVED_4				0x4
999bb772a59SSricharan #define SDRAM_TEMP_HIGH_DERATE_REFRESH			0x5
1000bb772a59SSricharan #define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS	0x6
1001bb772a59SSricharan #define SDRAM_TEMP_VERY_HIGH_SHUTDOWN			0x7
1002bb772a59SSricharan 
1003bb772a59SSricharan #define LPDDR2_MANUFACTURER_SAMSUNG	1
1004bb772a59SSricharan #define LPDDR2_MANUFACTURER_QIMONDA	2
1005bb772a59SSricharan #define LPDDR2_MANUFACTURER_ELPIDA	3
1006bb772a59SSricharan #define LPDDR2_MANUFACTURER_ETRON	4
1007bb772a59SSricharan #define LPDDR2_MANUFACTURER_NANYA	5
1008bb772a59SSricharan #define LPDDR2_MANUFACTURER_HYNIX	6
1009bb772a59SSricharan #define LPDDR2_MANUFACTURER_MOSEL	7
1010bb772a59SSricharan #define LPDDR2_MANUFACTURER_WINBOND	8
1011bb772a59SSricharan #define LPDDR2_MANUFACTURER_ESMT	9
1012bb772a59SSricharan #define LPDDR2_MANUFACTURER_SPANSION 11
1013bb772a59SSricharan #define LPDDR2_MANUFACTURER_SST		12
1014bb772a59SSricharan #define LPDDR2_MANUFACTURER_ZMOS	13
1015bb772a59SSricharan #define LPDDR2_MANUFACTURER_INTEL	14
1016bb772a59SSricharan #define LPDDR2_MANUFACTURER_NUMONYX	254
1017bb772a59SSricharan #define LPDDR2_MANUFACTURER_MICRON	255
1018bb772a59SSricharan 
1019bb772a59SSricharan /* MR8 register fields */
1020bb772a59SSricharan #define MR8_TYPE_SHIFT		0x0
1021bb772a59SSricharan #define MR8_TYPE_MASK		0x3
1022bb772a59SSricharan #define MR8_DENSITY_SHIFT	0x2
1023bb772a59SSricharan #define MR8_DENSITY_MASK	(0xF << 0x2)
1024bb772a59SSricharan #define MR8_IO_WIDTH_SHIFT	0x6
1025bb772a59SSricharan #define MR8_IO_WIDTH_MASK	(0x3 << 0x6)
1026bb772a59SSricharan 
10279ca8bfeaSLokesh Vutla /* SDRAM TYPE */
10289ca8bfeaSLokesh Vutla #define EMIF_SDRAM_TYPE_DDR2	0x2
10299ca8bfeaSLokesh Vutla #define EMIF_SDRAM_TYPE_DDR3	0x3
10309ca8bfeaSLokesh Vutla #define EMIF_SDRAM_TYPE_LPDDR2	0x4
10319ca8bfeaSLokesh Vutla 
1032bb772a59SSricharan struct lpddr2_addressing {
1033bb772a59SSricharan 	u8	num_banks;
1034bb772a59SSricharan 	u8	t_REFI_us_x10;
1035bb772a59SSricharan 	u8	row_sz[2]; /* One entry each for x32 and x16 */
1036bb772a59SSricharan 	u8	col_sz[2]; /* One entry each for x32 and x16 */
1037bb772a59SSricharan };
1038bb772a59SSricharan 
1039bb772a59SSricharan /* Structure for timings from the DDR datasheet */
1040bb772a59SSricharan struct lpddr2_ac_timings {
1041bb772a59SSricharan 	u32 max_freq;
1042bb772a59SSricharan 	u8 RL;
1043bb772a59SSricharan 	u8 tRPab;
1044bb772a59SSricharan 	u8 tRCD;
1045bb772a59SSricharan 	u8 tWR;
1046bb772a59SSricharan 	u8 tRASmin;
1047bb772a59SSricharan 	u8 tRRD;
1048bb772a59SSricharan 	u8 tWTRx2;
1049bb772a59SSricharan 	u8 tXSR;
1050bb772a59SSricharan 	u8 tXPx2;
1051bb772a59SSricharan 	u8 tRFCab;
1052bb772a59SSricharan 	u8 tRTPx2;
1053bb772a59SSricharan 	u8 tCKE;
1054bb772a59SSricharan 	u8 tCKESR;
1055bb772a59SSricharan 	u8 tZQCS;
1056bb772a59SSricharan 	u32 tZQCL;
1057bb772a59SSricharan 	u32 tZQINIT;
1058bb772a59SSricharan 	u8 tDQSCKMAXx2;
1059bb772a59SSricharan 	u8 tRASmax;
1060bb772a59SSricharan 	u8 tFAW;
1061bb772a59SSricharan 
1062bb772a59SSricharan };
1063bb772a59SSricharan 
1064bb772a59SSricharan /*
1065bb772a59SSricharan  * Min tCK values for some of the parameters:
1066bb772a59SSricharan  * If the calculated clock cycles for the respective parameter is
1067bb772a59SSricharan  * less than the corresponding min tCK value, we need to set the min
1068bb772a59SSricharan  * tCK value. This may happen at lower frequencies.
1069bb772a59SSricharan  */
1070bb772a59SSricharan struct lpddr2_min_tck {
1071bb772a59SSricharan 	u32 tRL;
1072bb772a59SSricharan 	u32 tRP_AB;
1073bb772a59SSricharan 	u32 tRCD;
1074bb772a59SSricharan 	u32 tWR;
1075bb772a59SSricharan 	u32 tRAS_MIN;
1076bb772a59SSricharan 	u32 tRRD;
1077bb772a59SSricharan 	u32 tWTR;
1078bb772a59SSricharan 	u32 tXP;
1079bb772a59SSricharan 	u32 tRTP;
1080bb772a59SSricharan 	u8  tCKE;
1081bb772a59SSricharan 	u32 tCKESR;
1082bb772a59SSricharan 	u32 tFAW;
1083bb772a59SSricharan };
1084bb772a59SSricharan 
1085bb772a59SSricharan struct lpddr2_device_details {
1086bb772a59SSricharan 	u8	type;
1087bb772a59SSricharan 	u8	density;
1088bb772a59SSricharan 	u8	io_width;
1089bb772a59SSricharan 	u8	manufacturer;
1090bb772a59SSricharan };
1091bb772a59SSricharan 
1092bb772a59SSricharan struct lpddr2_device_timings {
1093bb772a59SSricharan 	const struct lpddr2_ac_timings **ac_timings;
1094bb772a59SSricharan 	const struct lpddr2_min_tck *min_tck;
1095bb772a59SSricharan };
1096bb772a59SSricharan 
1097bb772a59SSricharan /* Details of the devices connected to each chip-select of an EMIF instance */
1098bb772a59SSricharan struct emif_device_details {
1099bb772a59SSricharan 	const struct lpddr2_device_details *cs0_device_details;
1100bb772a59SSricharan 	const struct lpddr2_device_details *cs1_device_details;
1101bb772a59SSricharan 	const struct lpddr2_device_timings *cs0_device_timings;
1102bb772a59SSricharan 	const struct lpddr2_device_timings *cs1_device_timings;
1103bb772a59SSricharan };
1104bb772a59SSricharan 
1105bb772a59SSricharan /*
1106bb772a59SSricharan  * Structure containing shadow of important registers in EMIF
1107bb772a59SSricharan  * The calculation function fills in this structure to be later used for
1108bb772a59SSricharan  * initialization and DVFS
1109bb772a59SSricharan  */
1110bb772a59SSricharan struct emif_regs {
1111bb772a59SSricharan 	u32 freq;
1112bb772a59SSricharan 	u32 sdram_config_init;
1113bb772a59SSricharan 	u32 sdram_config;
1114bb772a59SSricharan 	u32 ref_ctrl;
1115bb772a59SSricharan 	u32 sdram_tim1;
1116bb772a59SSricharan 	u32 sdram_tim2;
1117bb772a59SSricharan 	u32 sdram_tim3;
1118bb772a59SSricharan 	u32 read_idle_ctrl;
1119bb772a59SSricharan 	u32 zq_config;
1120bb772a59SSricharan 	u32 temp_alert_config;
1121bb772a59SSricharan 	u32 emif_ddr_phy_ctlr_1_init;
1122bb772a59SSricharan 	u32 emif_ddr_phy_ctlr_1;
1123f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_1;
1124f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_2;
1125f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_3;
1126f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_4;
1127f4010734SSRICHARAN R 	u32 emif_ddr_ext_phy_ctrl_5;
112843037d76SLokesh Vutla 	u32 emif_rd_wr_lvl_rmp_win;
112943037d76SLokesh Vutla 	u32 emif_rd_wr_lvl_rmp_ctl;
113043037d76SLokesh Vutla 	u32 emif_rd_wr_lvl_ctl;
113143037d76SLokesh Vutla 	u32 emif_rd_wr_exec_thresh;
1132bb772a59SSricharan };
1133bb772a59SSricharan 
1134*e05a4f1fSLokesh Vutla struct lpddr2_mr_regs {
1135*e05a4f1fSLokesh Vutla 	s8 mr1;
1136*e05a4f1fSLokesh Vutla 	s8 mr2;
1137*e05a4f1fSLokesh Vutla 	s8 mr3;
1138*e05a4f1fSLokesh Vutla 	s8 mr10;
1139*e05a4f1fSLokesh Vutla 	s8 mr16;
1140*e05a4f1fSLokesh Vutla };
1141*e05a4f1fSLokesh Vutla 
1142bb772a59SSricharan /* assert macros */
1143bb772a59SSricharan #if defined(DEBUG)
1144bb772a59SSricharan #define emif_assert(c)	({ if (!(c)) for (;;); })
1145bb772a59SSricharan #else
1146bb772a59SSricharan #define emif_assert(c)	({ if (0) hang(); })
1147bb772a59SSricharan #endif
1148bb772a59SSricharan 
1149bb772a59SSricharan #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
1150bb772a59SSricharan void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs);
1151bb772a59SSricharan void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs);
1152bb772a59SSricharan #else
1153bb772a59SSricharan struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
1154bb772a59SSricharan 			struct lpddr2_device_details *lpddr2_dev_details);
1155bb772a59SSricharan void emif_get_device_timings(u32 emif_nr,
1156bb772a59SSricharan 		const struct lpddr2_device_timings **cs0_device_timings,
1157bb772a59SSricharan 		const struct lpddr2_device_timings **cs1_device_timings);
1158bb772a59SSricharan #endif
1159bb772a59SSricharan 
116025476382SSRICHARAN R void do_ext_phy_settings(u32 base, const struct emif_regs *regs);
1161*e05a4f1fSLokesh Vutla void get_lpddr2_mr_regs(const struct lpddr2_mr_regs **regs);
116225476382SSRICHARAN R 
1163bb772a59SSricharan #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
1164bb772a59SSricharan extern u32 *const T_num;
1165bb772a59SSricharan extern u32 *const T_den;
1166bb772a59SSricharan extern u32 *const emif_sizes;
1167bb772a59SSricharan #endif
1168bb772a59SSricharan 
1169784ab7c5SLokesh Vutla void config_data_eye_leveling_samples(u32 emif_base);
11709ca8bfeaSLokesh Vutla u32 emif_sdram_type(void);
1171bb772a59SSricharan #endif
1172