blob: a16750840510c6c0df703a64e11bd9e21f98e3cb [file] [log] [blame]
Aneesh Vcc565582011-07-21 09:10:09 -04001/*
2 * OMAP44xx EMIF header
3 *
4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
5 *
6 * Aneesh V <aneesh@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef _EMIF_H_
14#define _EMIF_H_
15#include <asm/types.h>
16#include <common.h>
17
18/* Base address */
19#define OMAP44XX_EMIF1 0x4c000000
20#define OMAP44XX_EMIF2 0x4d000000
21
22/* Registers shifts and masks */
23
24/* EMIF_MOD_ID_REV */
25#define OMAP44XX_REG_SCHEME_SHIFT 30
26#define OMAP44XX_REG_SCHEME_MASK (0x3 << 30)
27#define OMAP44XX_REG_MODULE_ID_SHIFT 16
28#define OMAP44XX_REG_MODULE_ID_MASK (0xfff << 16)
29#define OMAP44XX_REG_RTL_VERSION_SHIFT 11
30#define OMAP44XX_REG_RTL_VERSION_MASK (0x1f << 11)
31#define OMAP44XX_REG_MAJOR_REVISION_SHIFT 8
32#define OMAP44XX_REG_MAJOR_REVISION_MASK (0x7 << 8)
33#define OMAP44XX_REG_MINOR_REVISION_SHIFT 0
34#define OMAP44XX_REG_MINOR_REVISION_MASK (0x3f << 0)
35
36/* STATUS */
37#define OMAP44XX_REG_BE_SHIFT 31
38#define OMAP44XX_REG_BE_MASK (1 << 31)
39#define OMAP44XX_REG_DUAL_CLK_MODE_SHIFT 30
40#define OMAP44XX_REG_DUAL_CLK_MODE_MASK (1 << 30)
41#define OMAP44XX_REG_FAST_INIT_SHIFT 29
42#define OMAP44XX_REG_FAST_INIT_MASK (1 << 29)
43#define OMAP44XX_REG_PHY_DLL_READY_SHIFT 2
44#define OMAP44XX_REG_PHY_DLL_READY_MASK (1 << 2)
45
46/* SDRAM_CONFIG */
47#define OMAP44XX_REG_SDRAM_TYPE_SHIFT 29
48#define OMAP44XX_REG_SDRAM_TYPE_MASK (0x7 << 29)
49#define OMAP44XX_REG_IBANK_POS_SHIFT 27
50#define OMAP44XX_REG_IBANK_POS_MASK (0x3 << 27)
51#define OMAP44XX_REG_DDR_TERM_SHIFT 24
52#define OMAP44XX_REG_DDR_TERM_MASK (0x7 << 24)
53#define OMAP44XX_REG_DDR2_DDQS_SHIFT 23
54#define OMAP44XX_REG_DDR2_DDQS_MASK (1 << 23)
55#define OMAP44XX_REG_DYN_ODT_SHIFT 21
56#define OMAP44XX_REG_DYN_ODT_MASK (0x3 << 21)
57#define OMAP44XX_REG_DDR_DISABLE_DLL_SHIFT 20
58#define OMAP44XX_REG_DDR_DISABLE_DLL_MASK (1 << 20)
59#define OMAP44XX_REG_SDRAM_DRIVE_SHIFT 18
60#define OMAP44XX_REG_SDRAM_DRIVE_MASK (0x3 << 18)
61#define OMAP44XX_REG_CWL_SHIFT 16
62#define OMAP44XX_REG_CWL_MASK (0x3 << 16)
63#define OMAP44XX_REG_NARROW_MODE_SHIFT 14
64#define OMAP44XX_REG_NARROW_MODE_MASK (0x3 << 14)
65#define OMAP44XX_REG_CL_SHIFT 10
66#define OMAP44XX_REG_CL_MASK (0xf << 10)
67#define OMAP44XX_REG_ROWSIZE_SHIFT 7
68#define OMAP44XX_REG_ROWSIZE_MASK (0x7 << 7)
69#define OMAP44XX_REG_IBANK_SHIFT 4
70#define OMAP44XX_REG_IBANK_MASK (0x7 << 4)
71#define OMAP44XX_REG_EBANK_SHIFT 3
72#define OMAP44XX_REG_EBANK_MASK (1 << 3)
73#define OMAP44XX_REG_PAGESIZE_SHIFT 0
74#define OMAP44XX_REG_PAGESIZE_MASK (0x7 << 0)
75
76/* SDRAM_CONFIG_2 */
77#define OMAP44XX_REG_CS1NVMEN_SHIFT 30
78#define OMAP44XX_REG_CS1NVMEN_MASK (1 << 30)
79#define OMAP44XX_REG_EBANK_POS_SHIFT 27
80#define OMAP44XX_REG_EBANK_POS_MASK (1 << 27)
81#define OMAP44XX_REG_RDBNUM_SHIFT 4
82#define OMAP44XX_REG_RDBNUM_MASK (0x3 << 4)
83#define OMAP44XX_REG_RDBSIZE_SHIFT 0
84#define OMAP44XX_REG_RDBSIZE_MASK (0x7 << 0)
85
86/* SDRAM_REF_CTRL */
87#define OMAP44XX_REG_INITREF_DIS_SHIFT 31
88#define OMAP44XX_REG_INITREF_DIS_MASK (1 << 31)
89#define OMAP44XX_REG_SRT_SHIFT 29
90#define OMAP44XX_REG_SRT_MASK (1 << 29)
91#define OMAP44XX_REG_ASR_SHIFT 28
92#define OMAP44XX_REG_ASR_MASK (1 << 28)
93#define OMAP44XX_REG_PASR_SHIFT 24
94#define OMAP44XX_REG_PASR_MASK (0x7 << 24)
95#define OMAP44XX_REG_REFRESH_RATE_SHIFT 0
96#define OMAP44XX_REG_REFRESH_RATE_MASK (0xffff << 0)
97
98/* SDRAM_REF_CTRL_SHDW */
99#define OMAP44XX_REG_REFRESH_RATE_SHDW_SHIFT 0
100#define OMAP44XX_REG_REFRESH_RATE_SHDW_MASK (0xffff << 0)
101
102/* SDRAM_TIM_1 */
103#define OMAP44XX_REG_T_RP_SHIFT 25
104#define OMAP44XX_REG_T_RP_MASK (0xf << 25)
105#define OMAP44XX_REG_T_RCD_SHIFT 21
106#define OMAP44XX_REG_T_RCD_MASK (0xf << 21)
107#define OMAP44XX_REG_T_WR_SHIFT 17
108#define OMAP44XX_REG_T_WR_MASK (0xf << 17)
109#define OMAP44XX_REG_T_RAS_SHIFT 12
110#define OMAP44XX_REG_T_RAS_MASK (0x1f << 12)
111#define OMAP44XX_REG_T_RC_SHIFT 6
112#define OMAP44XX_REG_T_RC_MASK (0x3f << 6)
113#define OMAP44XX_REG_T_RRD_SHIFT 3
114#define OMAP44XX_REG_T_RRD_MASK (0x7 << 3)
115#define OMAP44XX_REG_T_WTR_SHIFT 0
116#define OMAP44XX_REG_T_WTR_MASK (0x7 << 0)
117
118/* SDRAM_TIM_1_SHDW */
119#define OMAP44XX_REG_T_RP_SHDW_SHIFT 25
120#define OMAP44XX_REG_T_RP_SHDW_MASK (0xf << 25)
121#define OMAP44XX_REG_T_RCD_SHDW_SHIFT 21
122#define OMAP44XX_REG_T_RCD_SHDW_MASK (0xf << 21)
123#define OMAP44XX_REG_T_WR_SHDW_SHIFT 17
124#define OMAP44XX_REG_T_WR_SHDW_MASK (0xf << 17)
125#define OMAP44XX_REG_T_RAS_SHDW_SHIFT 12
126#define OMAP44XX_REG_T_RAS_SHDW_MASK (0x1f << 12)
127#define OMAP44XX_REG_T_RC_SHDW_SHIFT 6
128#define OMAP44XX_REG_T_RC_SHDW_MASK (0x3f << 6)
129#define OMAP44XX_REG_T_RRD_SHDW_SHIFT 3
130#define OMAP44XX_REG_T_RRD_SHDW_MASK (0x7 << 3)
131#define OMAP44XX_REG_T_WTR_SHDW_SHIFT 0
132#define OMAP44XX_REG_T_WTR_SHDW_MASK (0x7 << 0)
133
134/* SDRAM_TIM_2 */
135#define OMAP44XX_REG_T_XP_SHIFT 28
136#define OMAP44XX_REG_T_XP_MASK (0x7 << 28)
137#define OMAP44XX_REG_T_ODT_SHIFT 25
138#define OMAP44XX_REG_T_ODT_MASK (0x7 << 25)
139#define OMAP44XX_REG_T_XSNR_SHIFT 16
140#define OMAP44XX_REG_T_XSNR_MASK (0x1ff << 16)
141#define OMAP44XX_REG_T_XSRD_SHIFT 6
142#define OMAP44XX_REG_T_XSRD_MASK (0x3ff << 6)
143#define OMAP44XX_REG_T_RTP_SHIFT 3
144#define OMAP44XX_REG_T_RTP_MASK (0x7 << 3)
145#define OMAP44XX_REG_T_CKE_SHIFT 0
146#define OMAP44XX_REG_T_CKE_MASK (0x7 << 0)
147
148/* SDRAM_TIM_2_SHDW */
149#define OMAP44XX_REG_T_XP_SHDW_SHIFT 28
150#define OMAP44XX_REG_T_XP_SHDW_MASK (0x7 << 28)
151#define OMAP44XX_REG_T_ODT_SHDW_SHIFT 25
152#define OMAP44XX_REG_T_ODT_SHDW_MASK (0x7 << 25)
153#define OMAP44XX_REG_T_XSNR_SHDW_SHIFT 16
154#define OMAP44XX_REG_T_XSNR_SHDW_MASK (0x1ff << 16)
155#define OMAP44XX_REG_T_XSRD_SHDW_SHIFT 6
156#define OMAP44XX_REG_T_XSRD_SHDW_MASK (0x3ff << 6)
157#define OMAP44XX_REG_T_RTP_SHDW_SHIFT 3
158#define OMAP44XX_REG_T_RTP_SHDW_MASK (0x7 << 3)
159#define OMAP44XX_REG_T_CKE_SHDW_SHIFT 0
160#define OMAP44XX_REG_T_CKE_SHDW_MASK (0x7 << 0)
161
162/* SDRAM_TIM_3 */
163#define OMAP44XX_REG_T_CKESR_SHIFT 21
164#define OMAP44XX_REG_T_CKESR_MASK (0x7 << 21)
165#define OMAP44XX_REG_ZQ_ZQCS_SHIFT 15
166#define OMAP44XX_REG_ZQ_ZQCS_MASK (0x3f << 15)
167#define OMAP44XX_REG_T_TDQSCKMAX_SHIFT 13
168#define OMAP44XX_REG_T_TDQSCKMAX_MASK (0x3 << 13)
169#define OMAP44XX_REG_T_RFC_SHIFT 4
170#define OMAP44XX_REG_T_RFC_MASK (0x1ff << 4)
171#define OMAP44XX_REG_T_RAS_MAX_SHIFT 0
172#define OMAP44XX_REG_T_RAS_MAX_MASK (0xf << 0)
173
174/* SDRAM_TIM_3_SHDW */
175#define OMAP44XX_REG_T_CKESR_SHDW_SHIFT 21
176#define OMAP44XX_REG_T_CKESR_SHDW_MASK (0x7 << 21)
177#define OMAP44XX_REG_ZQ_ZQCS_SHDW_SHIFT 15
178#define OMAP44XX_REG_ZQ_ZQCS_SHDW_MASK (0x3f << 15)
179#define OMAP44XX_REG_T_TDQSCKMAX_SHDW_SHIFT 13
180#define OMAP44XX_REG_T_TDQSCKMAX_SHDW_MASK (0x3 << 13)
181#define OMAP44XX_REG_T_RFC_SHDW_SHIFT 4
182#define OMAP44XX_REG_T_RFC_SHDW_MASK (0x1ff << 4)
183#define OMAP44XX_REG_T_RAS_MAX_SHDW_SHIFT 0
184#define OMAP44XX_REG_T_RAS_MAX_SHDW_MASK (0xf << 0)
185
186/* LPDDR2_NVM_TIM */
187#define OMAP44XX_REG_NVM_T_XP_SHIFT 28
188#define OMAP44XX_REG_NVM_T_XP_MASK (0x7 << 28)
189#define OMAP44XX_REG_NVM_T_WTR_SHIFT 24
190#define OMAP44XX_REG_NVM_T_WTR_MASK (0x7 << 24)
191#define OMAP44XX_REG_NVM_T_RP_SHIFT 20
192#define OMAP44XX_REG_NVM_T_RP_MASK (0xf << 20)
193#define OMAP44XX_REG_NVM_T_WRA_SHIFT 16
194#define OMAP44XX_REG_NVM_T_WRA_MASK (0xf << 16)
195#define OMAP44XX_REG_NVM_T_RRD_SHIFT 8
196#define OMAP44XX_REG_NVM_T_RRD_MASK (0xff << 8)
197#define OMAP44XX_REG_NVM_T_RCDMIN_SHIFT 0
198#define OMAP44XX_REG_NVM_T_RCDMIN_MASK (0xff << 0)
199
200/* LPDDR2_NVM_TIM_SHDW */
201#define OMAP44XX_REG_NVM_T_XP_SHDW_SHIFT 28
202#define OMAP44XX_REG_NVM_T_XP_SHDW_MASK (0x7 << 28)
203#define OMAP44XX_REG_NVM_T_WTR_SHDW_SHIFT 24
204#define OMAP44XX_REG_NVM_T_WTR_SHDW_MASK (0x7 << 24)
205#define OMAP44XX_REG_NVM_T_RP_SHDW_SHIFT 20
206#define OMAP44XX_REG_NVM_T_RP_SHDW_MASK (0xf << 20)
207#define OMAP44XX_REG_NVM_T_WRA_SHDW_SHIFT 16
208#define OMAP44XX_REG_NVM_T_WRA_SHDW_MASK (0xf << 16)
209#define OMAP44XX_REG_NVM_T_RRD_SHDW_SHIFT 8
210#define OMAP44XX_REG_NVM_T_RRD_SHDW_MASK (0xff << 8)
211#define OMAP44XX_REG_NVM_T_RCDMIN_SHDW_SHIFT 0
212#define OMAP44XX_REG_NVM_T_RCDMIN_SHDW_MASK (0xff << 0)
213
214/* PWR_MGMT_CTRL */
215#define OMAP44XX_REG_IDLEMODE_SHIFT 30
216#define OMAP44XX_REG_IDLEMODE_MASK (0x3 << 30)
217#define OMAP44XX_REG_PD_TIM_SHIFT 12
218#define OMAP44XX_REG_PD_TIM_MASK (0xf << 12)
219#define OMAP44XX_REG_DPD_EN_SHIFT 11
220#define OMAP44XX_REG_DPD_EN_MASK (1 << 11)
221#define OMAP44XX_REG_LP_MODE_SHIFT 8
222#define OMAP44XX_REG_LP_MODE_MASK (0x7 << 8)
223#define OMAP44XX_REG_SR_TIM_SHIFT 4
224#define OMAP44XX_REG_SR_TIM_MASK (0xf << 4)
225#define OMAP44XX_REG_CS_TIM_SHIFT 0
226#define OMAP44XX_REG_CS_TIM_MASK (0xf << 0)
227
228/* PWR_MGMT_CTRL_SHDW */
229#define OMAP44XX_REG_PD_TIM_SHDW_SHIFT 8
230#define OMAP44XX_REG_PD_TIM_SHDW_MASK (0xf << 8)
231#define OMAP44XX_REG_SR_TIM_SHDW_SHIFT 4
232#define OMAP44XX_REG_SR_TIM_SHDW_MASK (0xf << 4)
233#define OMAP44XX_REG_CS_TIM_SHDW_SHIFT 0
234#define OMAP44XX_REG_CS_TIM_SHDW_MASK (0xf << 0)
235
236/* LPDDR2_MODE_REG_DATA */
237#define OMAP44XX_REG_VALUE_0_SHIFT 0
238#define OMAP44XX_REG_VALUE_0_MASK (0x7f << 0)
239
240/* LPDDR2_MODE_REG_CFG */
241#define OMAP44XX_REG_CS_SHIFT 31
242#define OMAP44XX_REG_CS_MASK (1 << 31)
243#define OMAP44XX_REG_REFRESH_EN_SHIFT 30
244#define OMAP44XX_REG_REFRESH_EN_MASK (1 << 30)
245#define OMAP44XX_REG_ADDRESS_SHIFT 0
246#define OMAP44XX_REG_ADDRESS_MASK (0xff << 0)
247
248/* OCP_CONFIG */
249#define OMAP44XX_REG_SYS_THRESH_MAX_SHIFT 24
250#define OMAP44XX_REG_SYS_THRESH_MAX_MASK (0xf << 24)
251#define OMAP44XX_REG_LL_THRESH_MAX_SHIFT 16
252#define OMAP44XX_REG_LL_THRESH_MAX_MASK (0xf << 16)
253#define OMAP44XX_REG_PR_OLD_COUNT_SHIFT 0
254#define OMAP44XX_REG_PR_OLD_COUNT_MASK (0xff << 0)
255
256/* OCP_CFG_VAL_1 */
257#define OMAP44XX_REG_SYS_BUS_WIDTH_SHIFT 30
258#define OMAP44XX_REG_SYS_BUS_WIDTH_MASK (0x3 << 30)
259#define OMAP44XX_REG_LL_BUS_WIDTH_SHIFT 28
260#define OMAP44XX_REG_LL_BUS_WIDTH_MASK (0x3 << 28)
261#define OMAP44XX_REG_WR_FIFO_DEPTH_SHIFT 8
262#define OMAP44XX_REG_WR_FIFO_DEPTH_MASK (0xff << 8)
263#define OMAP44XX_REG_CMD_FIFO_DEPTH_SHIFT 0
264#define OMAP44XX_REG_CMD_FIFO_DEPTH_MASK (0xff << 0)
265
266/* OCP_CFG_VAL_2 */
267#define OMAP44XX_REG_RREG_FIFO_DEPTH_SHIFT 16
268#define OMAP44XX_REG_RREG_FIFO_DEPTH_MASK (0xff << 16)
269#define OMAP44XX_REG_RSD_FIFO_DEPTH_SHIFT 8
270#define OMAP44XX_REG_RSD_FIFO_DEPTH_MASK (0xff << 8)
271#define OMAP44XX_REG_RCMD_FIFO_DEPTH_SHIFT 0
272#define OMAP44XX_REG_RCMD_FIFO_DEPTH_MASK (0xff << 0)
273
274/* IODFT_TLGC */
275#define OMAP44XX_REG_TLEC_SHIFT 16
276#define OMAP44XX_REG_TLEC_MASK (0xffff << 16)
277#define OMAP44XX_REG_MT_SHIFT 14
278#define OMAP44XX_REG_MT_MASK (1 << 14)
279#define OMAP44XX_REG_ACT_CAP_EN_SHIFT 13
280#define OMAP44XX_REG_ACT_CAP_EN_MASK (1 << 13)
281#define OMAP44XX_REG_OPG_LD_SHIFT 12
282#define OMAP44XX_REG_OPG_LD_MASK (1 << 12)
283#define OMAP44XX_REG_RESET_PHY_SHIFT 10
284#define OMAP44XX_REG_RESET_PHY_MASK (1 << 10)
285#define OMAP44XX_REG_MMS_SHIFT 8
286#define OMAP44XX_REG_MMS_MASK (1 << 8)
287#define OMAP44XX_REG_MC_SHIFT 4
288#define OMAP44XX_REG_MC_MASK (0x3 << 4)
289#define OMAP44XX_REG_PC_SHIFT 1
290#define OMAP44XX_REG_PC_MASK (0x7 << 1)
291#define OMAP44XX_REG_TM_SHIFT 0
292#define OMAP44XX_REG_TM_MASK (1 << 0)
293
294/* IODFT_CTRL_MISR_RSLT */
295#define OMAP44XX_REG_DQM_TLMR_SHIFT 16
296#define OMAP44XX_REG_DQM_TLMR_MASK (0x3ff << 16)
297#define OMAP44XX_REG_CTL_TLMR_SHIFT 0
298#define OMAP44XX_REG_CTL_TLMR_MASK (0x7ff << 0)
299
300/* IODFT_ADDR_MISR_RSLT */
301#define OMAP44XX_REG_ADDR_TLMR_SHIFT 0
302#define OMAP44XX_REG_ADDR_TLMR_MASK (0x1fffff << 0)
303
304/* IODFT_DATA_MISR_RSLT_1 */
305#define OMAP44XX_REG_DATA_TLMR_31_0_SHIFT 0
306#define OMAP44XX_REG_DATA_TLMR_31_0_MASK (0xffffffff << 0)
307
308/* IODFT_DATA_MISR_RSLT_2 */
309#define OMAP44XX_REG_DATA_TLMR_63_32_SHIFT 0
310#define OMAP44XX_REG_DATA_TLMR_63_32_MASK (0xffffffff << 0)
311
312/* IODFT_DATA_MISR_RSLT_3 */
313#define OMAP44XX_REG_DATA_TLMR_66_64_SHIFT 0
314#define OMAP44XX_REG_DATA_TLMR_66_64_MASK (0x7 << 0)
315
316/* PERF_CNT_1 */
317#define OMAP44XX_REG_COUNTER1_SHIFT 0
318#define OMAP44XX_REG_COUNTER1_MASK (0xffffffff << 0)
319
320/* PERF_CNT_2 */
321#define OMAP44XX_REG_COUNTER2_SHIFT 0
322#define OMAP44XX_REG_COUNTER2_MASK (0xffffffff << 0)
323
324/* PERF_CNT_CFG */
325#define OMAP44XX_REG_CNTR2_MCONNID_EN_SHIFT 31
326#define OMAP44XX_REG_CNTR2_MCONNID_EN_MASK (1 << 31)
327#define OMAP44XX_REG_CNTR2_REGION_EN_SHIFT 30
328#define OMAP44XX_REG_CNTR2_REGION_EN_MASK (1 << 30)
329#define OMAP44XX_REG_CNTR2_CFG_SHIFT 16
330#define OMAP44XX_REG_CNTR2_CFG_MASK (0xf << 16)
331#define OMAP44XX_REG_CNTR1_MCONNID_EN_SHIFT 15
332#define OMAP44XX_REG_CNTR1_MCONNID_EN_MASK (1 << 15)
333#define OMAP44XX_REG_CNTR1_REGION_EN_SHIFT 14
334#define OMAP44XX_REG_CNTR1_REGION_EN_MASK (1 << 14)
335#define OMAP44XX_REG_CNTR1_CFG_SHIFT 0
336#define OMAP44XX_REG_CNTR1_CFG_MASK (0xf << 0)
337
338/* PERF_CNT_SEL */
339#define OMAP44XX_REG_MCONNID2_SHIFT 24
340#define OMAP44XX_REG_MCONNID2_MASK (0xff << 24)
341#define OMAP44XX_REG_REGION_SEL2_SHIFT 16
342#define OMAP44XX_REG_REGION_SEL2_MASK (0x3 << 16)
343#define OMAP44XX_REG_MCONNID1_SHIFT 8
344#define OMAP44XX_REG_MCONNID1_MASK (0xff << 8)
345#define OMAP44XX_REG_REGION_SEL1_SHIFT 0
346#define OMAP44XX_REG_REGION_SEL1_MASK (0x3 << 0)
347
348/* PERF_CNT_TIM */
349#define OMAP44XX_REG_TOTAL_TIME_SHIFT 0
350#define OMAP44XX_REG_TOTAL_TIME_MASK (0xffffffff << 0)
351
352/* READ_IDLE_CTRL */
353#define OMAP44XX_REG_READ_IDLE_LEN_SHIFT 16
354#define OMAP44XX_REG_READ_IDLE_LEN_MASK (0xf << 16)
355#define OMAP44XX_REG_READ_IDLE_INTERVAL_SHIFT 0
356#define OMAP44XX_REG_READ_IDLE_INTERVAL_MASK (0x1ff << 0)
357
358/* READ_IDLE_CTRL_SHDW */
359#define OMAP44XX_REG_READ_IDLE_LEN_SHDW_SHIFT 16
360#define OMAP44XX_REG_READ_IDLE_LEN_SHDW_MASK (0xf << 16)
361#define OMAP44XX_REG_READ_IDLE_INTERVAL_SHDW_SHIFT 0
362#define OMAP44XX_REG_READ_IDLE_INTERVAL_SHDW_MASK (0x1ff << 0)
363
364/* IRQ_EOI */
365#define OMAP44XX_REG_EOI_SHIFT 0
366#define OMAP44XX_REG_EOI_MASK (1 << 0)
367
368/* IRQSTATUS_RAW_SYS */
369#define OMAP44XX_REG_DNV_SYS_SHIFT 2
370#define OMAP44XX_REG_DNV_SYS_MASK (1 << 2)
371#define OMAP44XX_REG_TA_SYS_SHIFT 1
372#define OMAP44XX_REG_TA_SYS_MASK (1 << 1)
373#define OMAP44XX_REG_ERR_SYS_SHIFT 0
374#define OMAP44XX_REG_ERR_SYS_MASK (1 << 0)
375
376/* IRQSTATUS_RAW_LL */
377#define OMAP44XX_REG_DNV_LL_SHIFT 2
378#define OMAP44XX_REG_DNV_LL_MASK (1 << 2)
379#define OMAP44XX_REG_TA_LL_SHIFT 1
380#define OMAP44XX_REG_TA_LL_MASK (1 << 1)
381#define OMAP44XX_REG_ERR_LL_SHIFT 0
382#define OMAP44XX_REG_ERR_LL_MASK (1 << 0)
383
384/* IRQSTATUS_SYS */
385
386/* IRQSTATUS_LL */
387
388/* IRQENABLE_SET_SYS */
389#define OMAP44XX_REG_EN_DNV_SYS_SHIFT 2
390#define OMAP44XX_REG_EN_DNV_SYS_MASK (1 << 2)
391#define OMAP44XX_REG_EN_TA_SYS_SHIFT 1
392#define OMAP44XX_REG_EN_TA_SYS_MASK (1 << 1)
393#define OMAP44XX_REG_EN_ERR_SYS_SHIFT 0
394#define OMAP44XX_REG_EN_ERR_SYS_MASK (1 << 0)
395
396/* IRQENABLE_SET_LL */
397#define OMAP44XX_REG_EN_DNV_LL_SHIFT 2
398#define OMAP44XX_REG_EN_DNV_LL_MASK (1 << 2)
399#define OMAP44XX_REG_EN_TA_LL_SHIFT 1
400#define OMAP44XX_REG_EN_TA_LL_MASK (1 << 1)
401#define OMAP44XX_REG_EN_ERR_LL_SHIFT 0
402#define OMAP44XX_REG_EN_ERR_LL_MASK (1 << 0)
403
404/* IRQENABLE_CLR_SYS */
405
406/* IRQENABLE_CLR_LL */
407
408/* ZQ_CONFIG */
409#define OMAP44XX_REG_ZQ_CS1EN_SHIFT 31
410#define OMAP44XX_REG_ZQ_CS1EN_MASK (1 << 31)
411#define OMAP44XX_REG_ZQ_CS0EN_SHIFT 30
412#define OMAP44XX_REG_ZQ_CS0EN_MASK (1 << 30)
413#define OMAP44XX_REG_ZQ_DUALCALEN_SHIFT 29
414#define OMAP44XX_REG_ZQ_DUALCALEN_MASK (1 << 29)
415#define OMAP44XX_REG_ZQ_SFEXITEN_SHIFT 28
416#define OMAP44XX_REG_ZQ_SFEXITEN_MASK (1 << 28)
417#define OMAP44XX_REG_ZQ_ZQINIT_MULT_SHIFT 18
418#define OMAP44XX_REG_ZQ_ZQINIT_MULT_MASK (0x3 << 18)
419#define OMAP44XX_REG_ZQ_ZQCL_MULT_SHIFT 16
420#define OMAP44XX_REG_ZQ_ZQCL_MULT_MASK (0x3 << 16)
421#define OMAP44XX_REG_ZQ_REFINTERVAL_SHIFT 0
422#define OMAP44XX_REG_ZQ_REFINTERVAL_MASK (0xffff << 0)
423
424/* TEMP_ALERT_CONFIG */
425#define OMAP44XX_REG_TA_CS1EN_SHIFT 31
426#define OMAP44XX_REG_TA_CS1EN_MASK (1 << 31)
427#define OMAP44XX_REG_TA_CS0EN_SHIFT 30
428#define OMAP44XX_REG_TA_CS0EN_MASK (1 << 30)
429#define OMAP44XX_REG_TA_SFEXITEN_SHIFT 28
430#define OMAP44XX_REG_TA_SFEXITEN_MASK (1 << 28)
431#define OMAP44XX_REG_TA_DEVWDT_SHIFT 26
432#define OMAP44XX_REG_TA_DEVWDT_MASK (0x3 << 26)
433#define OMAP44XX_REG_TA_DEVCNT_SHIFT 24
434#define OMAP44XX_REG_TA_DEVCNT_MASK (0x3 << 24)
435#define OMAP44XX_REG_TA_REFINTERVAL_SHIFT 0
436#define OMAP44XX_REG_TA_REFINTERVAL_MASK (0x3fffff << 0)
437
438/* OCP_ERR_LOG */
439#define OMAP44XX_REG_MADDRSPACE_SHIFT 14
440#define OMAP44XX_REG_MADDRSPACE_MASK (0x3 << 14)
441#define OMAP44XX_REG_MBURSTSEQ_SHIFT 11
442#define OMAP44XX_REG_MBURSTSEQ_MASK (0x7 << 11)
443#define OMAP44XX_REG_MCMD_SHIFT 8
444#define OMAP44XX_REG_MCMD_MASK (0x7 << 8)
445#define OMAP44XX_REG_MCONNID_SHIFT 0
446#define OMAP44XX_REG_MCONNID_MASK (0xff << 0)
447
448/* DDR_PHY_CTRL_1 */
449#define OMAP44XX_REG_DDR_PHY_CTRL_1_SHIFT 4
450#define OMAP44XX_REG_DDR_PHY_CTRL_1_MASK (0xfffffff << 4)
451#define OMAP44XX_REG_READ_LATENCY_SHIFT 0
452#define OMAP44XX_REG_READ_LATENCY_MASK (0xf << 0)
453#define OMAP44XX_REG_DLL_SLAVE_DLY_CTRL_SHIFT 4
454#define OMAP44XX_REG_DLL_SLAVE_DLY_CTRL_MASK (0xFF << 4)
455#define OMAP44XX_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHIFT 12
456#define OMAP44XX_EMIF_DDR_PHY_CTRL_1_BASE_VAL_MASK (0xFFFFF << 12)
457
458/* DDR_PHY_CTRL_1_SHDW */
459#define OMAP44XX_REG_DDR_PHY_CTRL_1_SHDW_SHIFT 4
460#define OMAP44XX_REG_DDR_PHY_CTRL_1_SHDW_MASK (0xfffffff << 4)
461#define OMAP44XX_REG_READ_LATENCY_SHDW_SHIFT 0
462#define OMAP44XX_REG_READ_LATENCY_SHDW_MASK (0xf << 0)
463#define OMAP44XX_REG_DLL_SLAVE_DLY_CTRL_SHDW_SHIFT 4
464#define OMAP44XX_REG_DLL_SLAVE_DLY_CTRL_SHDW_MASK (0xFF << 4)
465#define OMAP44XX_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_SHIFT 12
466#define OMAP44XX_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_MASK (0xFFFFF << 12)
467
468/* DDR_PHY_CTRL_2 */
469#define OMAP44XX_REG_DDR_PHY_CTRL_2_SHIFT 0
470#define OMAP44XX_REG_DDR_PHY_CTRL_2_MASK (0xffffffff << 0)
471
472/* DMM */
473#define OMAP44XX_DMM_LISA_MAP_BASE 0x4E000040
474
475/* DMM_LISA_MAP */
476#define OMAP44XX_SYS_ADDR_SHIFT 24
477#define OMAP44XX_SYS_ADDR_MASK (0xff << 24)
478#define OMAP44XX_SYS_SIZE_SHIFT 20
479#define OMAP44XX_SYS_SIZE_MASK (0x7 << 20)
480#define OMAP44XX_SDRC_INTL_SHIFT 18
481#define OMAP44XX_SDRC_INTL_MASK (0x3 << 18)
482#define OMAP44XX_SDRC_ADDRSPC_SHIFT 16
483#define OMAP44XX_SDRC_ADDRSPC_MASK (0x3 << 16)
484#define OMAP44XX_SDRC_MAP_SHIFT 8
485#define OMAP44XX_SDRC_MAP_MASK (0x3 << 8)
486#define OMAP44XX_SDRC_ADDR_SHIFT 0
487#define OMAP44XX_SDRC_ADDR_MASK (0xff << 0)
488
489/* DMM_LISA_MAP fields */
490#define DMM_SDRC_MAP_UNMAPPED 0
491#define DMM_SDRC_MAP_EMIF1_ONLY 1
492#define DMM_SDRC_MAP_EMIF2_ONLY 2
493#define DMM_SDRC_MAP_EMIF1_AND_EMIF2 3
494
495#define DMM_SDRC_INTL_NONE 0
496#define DMM_SDRC_INTL_128B 1
497#define DMM_SDRC_INTL_256B 2
498#define DMM_SDRC_INTL_512 3
499
500#define DMM_SDRC_ADDR_SPC_SDRAM 0
501#define DMM_SDRC_ADDR_SPC_NVM 1
502#define DMM_SDRC_ADDR_SPC_INVALID 2
503
504#define DMM_LISA_MAP_INTERLEAVED_BASE_VAL (\
505 (DMM_SDRC_MAP_EMIF1_AND_EMIF2 << OMAP44XX_SDRC_MAP_SHIFT) |\
506 (DMM_SDRC_ADDR_SPC_SDRAM << OMAP44XX_SDRC_ADDRSPC_SHIFT) |\
507 (DMM_SDRC_INTL_128B << OMAP44XX_SDRC_INTL_SHIFT) |\
508 (CONFIG_SYS_SDRAM_BASE << OMAP44XX_SYS_ADDR_SHIFT))
509
510#define DMM_LISA_MAP_EMIF1_ONLY_BASE_VAL (\
511 (DMM_SDRC_MAP_EMIF1_ONLY << OMAP44XX_SDRC_MAP_SHIFT)|\
512 (DMM_SDRC_ADDR_SPC_SDRAM << OMAP44XX_SDRC_ADDRSPC_SHIFT)|\
513 (DMM_SDRC_INTL_NONE << OMAP44XX_SDRC_INTL_SHIFT))
514
515#define DMM_LISA_MAP_EMIF2_ONLY_BASE_VAL (\
516 (DMM_SDRC_MAP_EMIF2_ONLY << OMAP44XX_SDRC_MAP_SHIFT)|\
517 (DMM_SDRC_ADDR_SPC_SDRAM << OMAP44XX_SDRC_ADDRSPC_SHIFT)|\
518 (DMM_SDRC_INTL_NONE << OMAP44XX_SDRC_INTL_SHIFT))
519
520/* Trap for invalid TILER PAT entries */
521#define DMM_LISA_MAP_0_INVAL_ADDR_TRAP (\
522 (0 << OMAP44XX_SDRC_ADDR_SHIFT) |\
523 (DMM_SDRC_MAP_EMIF1_ONLY << OMAP44XX_SDRC_MAP_SHIFT)|\
524 (DMM_SDRC_ADDR_SPC_INVALID << OMAP44XX_SDRC_ADDRSPC_SHIFT)|\
525 (DMM_SDRC_INTL_NONE << OMAP44XX_SDRC_INTL_SHIFT)|\
526 (0xFF << OMAP44XX_SYS_ADDR_SHIFT))
527
528
529/* Reg mapping structure */
530struct emif_reg_struct {
531 u32 emif_mod_id_rev;
532 u32 emif_status;
533 u32 emif_sdram_config;
534 u32 emif_lpddr2_nvm_config;
535 u32 emif_sdram_ref_ctrl;
536 u32 emif_sdram_ref_ctrl_shdw;
537 u32 emif_sdram_tim_1;
538 u32 emif_sdram_tim_1_shdw;
539 u32 emif_sdram_tim_2;
540 u32 emif_sdram_tim_2_shdw;
541 u32 emif_sdram_tim_3;
542 u32 emif_sdram_tim_3_shdw;
543 u32 emif_lpddr2_nvm_tim;
544 u32 emif_lpddr2_nvm_tim_shdw;
545 u32 emif_pwr_mgmt_ctrl;
546 u32 emif_pwr_mgmt_ctrl_shdw;
547 u32 emif_lpddr2_mode_reg_data;
548 u32 padding1[1];
549 u32 emif_lpddr2_mode_reg_data_es2;
550 u32 padding11[1];
551 u32 emif_lpddr2_mode_reg_cfg;
552 u32 emif_l3_config;
553 u32 emif_l3_cfg_val_1;
554 u32 emif_l3_cfg_val_2;
555 u32 emif_iodft_tlgc;
556 u32 padding2[7];
557 u32 emif_perf_cnt_1;
558 u32 emif_perf_cnt_2;
559 u32 emif_perf_cnt_cfg;
560 u32 emif_perf_cnt_sel;
561 u32 emif_perf_cnt_tim;
562 u32 padding3;
563 u32 emif_read_idlectrl;
564 u32 emif_read_idlectrl_shdw;
565 u32 padding4;
566 u32 emif_irqstatus_raw_sys;
567 u32 emif_irqstatus_raw_ll;
568 u32 emif_irqstatus_sys;
569 u32 emif_irqstatus_ll;
570 u32 emif_irqenable_set_sys;
571 u32 emif_irqenable_set_ll;
572 u32 emif_irqenable_clr_sys;
573 u32 emif_irqenable_clr_ll;
574 u32 padding5;
575 u32 emif_zq_config;
576 u32 emif_temp_alert_config;
577 u32 emif_l3_err_log;
578 u32 padding6[4];
579 u32 emif_ddr_phy_ctrl_1;
580 u32 emif_ddr_phy_ctrl_1_shdw;
581 u32 emif_ddr_phy_ctrl_2;
582};
583
584struct dmm_lisa_map_regs {
585 u32 dmm_lisa_map_0;
586 u32 dmm_lisa_map_1;
587 u32 dmm_lisa_map_2;
588 u32 dmm_lisa_map_3;
589};
590
591struct control_lpddr2io_regs {
592 u32 control_lpddr2io1_0;
593 u32 control_lpddr2io1_1;
594 u32 control_lpddr2io1_2;
595 u32 control_lpddr2io1_3;
596 u32 control_lpddr2io2_0;
597 u32 control_lpddr2io2_1;
598 u32 control_lpddr2io2_2;
599 u32 control_lpddr2io2_3;
600};
601
602#define CS0 0
603#define CS1 1
604/* The maximum frequency at which the LPDDR2 interface can operate in Hz*/
605#define MAX_LPDDR2_FREQ 400000000 /* 400 MHz */
606
607/*
608 * The period of DDR clk is represented as numerator and denominator for
609 * better accuracy in integer based calculations. However, if the numerator
610 * and denominator are very huge there may be chances of overflow in
611 * calculations. So, as a trade-off keep denominator(and consequently
612 * numerator) within a limit sacrificing some accuracy - but not much
613 * If denominator and numerator are already small (such as at 400 MHz)
614 * no adjustment is needed
615 */
616#define EMIF_PERIOD_DEN_LIMIT 1000
617/*
618 * Maximum number of different frequencies supported by EMIF driver
619 * Determines the number of entries in the pointer array for register
620 * cache
621 */
622#define EMIF_MAX_NUM_FREQUENCIES 6
623/*
624 * Indices into the Addressing Table array.
625 * One entry each for all the different types of devices with different
626 * addressing schemes
627 */
628#define ADDR_TABLE_INDEX64M 0
629#define ADDR_TABLE_INDEX128M 1
630#define ADDR_TABLE_INDEX256M 2
631#define ADDR_TABLE_INDEX512M 3
632#define ADDR_TABLE_INDEX1GS4 4
633#define ADDR_TABLE_INDEX2GS4 5
634#define ADDR_TABLE_INDEX4G 6
635#define ADDR_TABLE_INDEX8G 7
636#define ADDR_TABLE_INDEX1GS2 8
637#define ADDR_TABLE_INDEX2GS2 9
638#define ADDR_TABLE_INDEXMAX 10
639
640/* Number of Row bits */
641#define ROW_9 0
642#define ROW_10 1
643#define ROW_11 2
644#define ROW_12 3
645#define ROW_13 4
646#define ROW_14 5
647#define ROW_15 6
648#define ROW_16 7
649
650/* Number of Column bits */
651#define COL_8 0
652#define COL_9 1
653#define COL_10 2
654#define COL_11 3
655#define COL_7 4 /*Not supported by OMAP included for completeness */
656
657/* Number of Banks*/
658#define BANKS1 0
659#define BANKS2 1
660#define BANKS4 2
661#define BANKS8 3
662
663/* Refresh rate in micro seconds x 10 */
664#define T_REFI_15_6 156
665#define T_REFI_7_8 78
666#define T_REFI_3_9 39
667
668#define EBANK_CS1_DIS 0
669#define EBANK_CS1_EN 1
670
671/* Read Latency used by the device at reset */
672#define RL_BOOT 3
673/* Read Latency for the highest frequency you want to use */
674#define RL_FINAL 6
675
676/* Interleaving policies at EMIF level- between banks and Chip Selects */
677#define EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING 0
678#define EMIF_INTERLEAVING_POLICY_NO_BANK_INTERLEAVING 3
679
680/*
681 * Interleaving policy to be used
682 * Currently set to MAX interleaving for better performance
683 */
684#define EMIF_INTERLEAVING_POLICY EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING
685
686/* State of the core voltage:
687 * This is important for some parameters such as read idle control and
688 * ZQ calibration timings. Timings are much stricter when voltage ramp
689 * is happening compared to when the voltage is stable.
690 * We need to calculate two sets of values for these parameters and use
691 * them accordingly
692 */
693#define LPDDR2_VOLTAGE_STABLE 0
694#define LPDDR2_VOLTAGE_RAMPING 1
695
696/* Length of the forced read idle period in terms of cycles */
697#define EMIF_REG_READ_IDLE_LEN_VAL 5
698
699/* Interval between forced 'read idles' */
700/* To be used when voltage is changed for DPS/DVFS - 1us */
701#define READ_IDLE_INTERVAL_DVFS (1*1000)
702/*
703 * To be used when voltage is not scaled except by Smart Reflex
704 * 50us - or maximum value will do
705 */
706#define READ_IDLE_INTERVAL_NORMAL (50*1000)
707
708
709/*
710 * Unless voltage is changing due to DVFS one ZQCS command every 50ms should
711 * be enough. This shoule be enough also in the case when voltage is changing
712 * due to smart-reflex.
713 */
714#define EMIF_ZQCS_INTERVAL_NORMAL_IN_US (50*1000)
715/*
716 * If voltage is changing due to DVFS ZQCS should be performed more
717 * often(every 50us)
718 */
719#define EMIF_ZQCS_INTERVAL_DVFS_IN_US 50
720
721/* The interval between ZQCL commands as a multiple of ZQCS interval */
722#define REG_ZQ_ZQCL_MULT 4
723/* The interval between ZQINIT commands as a multiple of ZQCL interval */
724#define REG_ZQ_ZQINIT_MULT 3
725/* Enable ZQ Calibration on exiting Self-refresh */
726#define REG_ZQ_SFEXITEN_ENABLE 1
727/*
728 * ZQ Calibration simultaneously on both chip-selects:
729 * Needs one calibration resistor per CS
730 * None of the boards that we know of have this capability
731 * So disabled by default
732 */
733#define REG_ZQ_DUALCALEN_DISABLE 0
734/*
735 * Enable ZQ Calibration by default on CS0. If we are asked to program
736 * the EMIF there will be something connected to CS0 for sure
737 */
738#define REG_ZQ_CS0EN_ENABLE 1
739
740/* EMIF_PWR_MGMT_CTRL register */
741/* Low power modes */
742#define LP_MODE_DISABLE 0
743#define LP_MODE_CLOCK_STOP 1
744#define LP_MODE_SELF_REFRESH 2
745#define LP_MODE_PWR_DN 3
746
747/* REG_DPD_EN */
748#define DPD_DISABLE 0
749#define DPD_ENABLE 1
750
751/* Maximum delay before Low Power Modes */
752#define REG_CS_TIM 0xF
753#define REG_SR_TIM 0xF
754#define REG_PD_TIM 0xF
755
756/* EMIF_PWR_MGMT_CTRL register */
757#define EMIF_PWR_MGMT_CTRL (\
758 ((REG_CS_TIM << OMAP44XX_REG_CS_TIM_SHIFT) & OMAP44XX_REG_CS_TIM_MASK)|\
759 ((REG_SR_TIM << OMAP44XX_REG_SR_TIM_SHIFT) & OMAP44XX_REG_SR_TIM_MASK)|\
760 ((REG_PD_TIM << OMAP44XX_REG_PD_TIM_SHIFT) & OMAP44XX_REG_PD_TIM_MASK)|\
761 ((REG_PD_TIM << OMAP44XX_REG_PD_TIM_SHIFT) & OMAP44XX_REG_PD_TIM_MASK)|\
762 ((LP_MODE_DISABLE << OMAP44XX_REG_LP_MODE_SHIFT)\
763 & OMAP44XX_REG_LP_MODE_MASK) |\
764 ((DPD_DISABLE << OMAP44XX_REG_DPD_EN_SHIFT)\
765 & OMAP44XX_REG_DPD_EN_MASK))\
766
767#define EMIF_PWR_MGMT_CTRL_SHDW (\
768 ((REG_CS_TIM << OMAP44XX_REG_CS_TIM_SHDW_SHIFT)\
769 & OMAP44XX_REG_CS_TIM_SHDW_MASK) |\
770 ((REG_SR_TIM << OMAP44XX_REG_SR_TIM_SHDW_SHIFT)\
771 & OMAP44XX_REG_SR_TIM_SHDW_MASK) |\
772 ((REG_PD_TIM << OMAP44XX_REG_PD_TIM_SHDW_SHIFT)\
773 & OMAP44XX_REG_PD_TIM_SHDW_MASK) |\
774 ((REG_PD_TIM << OMAP44XX_REG_PD_TIM_SHDW_SHIFT)\
775 & OMAP44XX_REG_PD_TIM_SHDW_MASK))
776
777/* EMIF_L3_CONFIG register value for ES1*/
778#define EMIF_L3_CONFIG_VAL_SYS_THRESH_0A_LL_THRESH_00 0x0A0000FF
779/*
780 * Value of bits 12:31 of DDR_PHY_CTRL_1 register:
781 * All these fields have magic values dependent on frequency and
782 * determined by PHY and DLL integration with EMIF. Setting the magic
783 * values suggested by hw team.
784 */
785#define EMIF_DDR_PHY_CTRL_1_BASE_VAL 0x049FF
786#define EMIF_DLL_SLAVE_DLY_CTRL_400_MHZ 0x41
787#define EMIF_DLL_SLAVE_DLY_CTRL_200_MHZ 0x80
788#define EMIF_DLL_SLAVE_DLY_CTRL_100_MHZ_AND_LESS 0xFF
789
790/*
791* MR1 value:
792* Burst length : 8
793* Burst type : sequential
794* Wrap : enabled
795* nWR : 3(default). EMIF does not do pre-charge.
796* : So nWR is don't care
797*/
798#define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3 0x23
799
800/* MR2 */
801#define MR2_RL3_WL1 1
802#define MR2_RL4_WL2 2
803#define MR2_RL5_WL2 3
804#define MR2_RL6_WL3 4
805
806/* MR10: ZQ calibration codes */
807#define MR10_ZQ_ZQCS 0x56
808#define MR10_ZQ_ZQCL 0xAB
809#define MR10_ZQ_ZQINIT 0xFF
810#define MR10_ZQ_ZQRESET 0xC3
811
812/* TEMP_ALERT_CONFIG */
813#define TEMP_ALERT_POLL_INTERVAL_MS 360 /* for temp gradient - 5 C/s */
814#define TEMP_ALERT_CONFIG_DEVCT_1 0
815#define TEMP_ALERT_CONFIG_DEVWDT_32 2
816
817/* MR16 value: refresh full array(no partial array self refresh) */
818#define MR16_REF_FULL_ARRAY 0
819
820/* LPDDR2 IO regs */
821#define CONTROL_LPDDR2IO_SLEW_125PS_DRV8_PULL_DOWN 0x1C1C1C1C
822#define CONTROL_LPDDR2IO_SLEW_325PS_DRV8_GATE_KEEPER 0x9E9E9E9E
823
824/* CONTROL_EFUSE_2 */
825#define CONTROL_EFUSE_2_NMOS_PMOS_PTV_CODE_1 0x00ffc000
826
827/*
828 * Maximum number of entries we keep in our array of timing tables
829 * We need not keep all the speed bins supported by the device
830 * We need to keep timing tables for only the speed bins that we
831 * are interested in
832 */
833#define MAX_NUM_SPEEDBINS 4
834
835/* LPDDR2 Densities */
836#define LPDDR2_DENSITY_64Mb 0
837#define LPDDR2_DENSITY_128Mb 1
838#define LPDDR2_DENSITY_256Mb 2
839#define LPDDR2_DENSITY_512Mb 3
840#define LPDDR2_DENSITY_1Gb 4
841#define LPDDR2_DENSITY_2Gb 5
842#define LPDDR2_DENSITY_4Gb 6
843#define LPDDR2_DENSITY_8Gb 7
844#define LPDDR2_DENSITY_16Gb 8
845#define LPDDR2_DENSITY_32Gb 9
846
847/* LPDDR2 type */
848#define LPDDR2_TYPE_S4 0
849#define LPDDR2_TYPE_S2 1
850#define LPDDR2_TYPE_NVM 2
851
852/* LPDDR2 IO width */
853#define LPDDR2_IO_WIDTH_32 0
854#define LPDDR2_IO_WIDTH_16 1
855#define LPDDR2_IO_WIDTH_8 2
856
857/* Mode register numbers */
858#define LPDDR2_MR0 0
859#define LPDDR2_MR1 1
860#define LPDDR2_MR2 2
861#define LPDDR2_MR3 3
862#define LPDDR2_MR4 4
863#define LPDDR2_MR5 5
864#define LPDDR2_MR6 6
865#define LPDDR2_MR7 7
866#define LPDDR2_MR8 8
867#define LPDDR2_MR9 9
868#define LPDDR2_MR10 10
869#define LPDDR2_MR11 11
870#define LPDDR2_MR16 16
871#define LPDDR2_MR17 17
872#define LPDDR2_MR18 18
873
874/* MR0 */
875#define LPDDR2_MR0_DAI_SHIFT 0
876#define LPDDR2_MR0_DAI_MASK 1
877#define LPDDR2_MR0_DI_SHIFT 1
878#define LPDDR2_MR0_DI_MASK (1 << 1)
879#define LPDDR2_MR0_DNVI_SHIFT 2
880#define LPDDR2_MR0_DNVI_MASK (1 << 2)
881
882/* MR4 */
883#define MR4_SDRAM_REF_RATE_SHIFT 0
884#define MR4_SDRAM_REF_RATE_MASK 7
885#define MR4_TUF_SHIFT 7
886#define MR4_TUF_MASK (1 << 7)
887
888/* MR4 SDRAM Refresh Rate field values */
889#define SDRAM_TEMP_LESS_LOW_SHUTDOWN 0x0
890#define SDRAM_TEMP_LESS_4X_REFRESH_AND_TIMINGS 0x1
891#define SDRAM_TEMP_LESS_2X_REFRESH_AND_TIMINGS 0x2
892#define SDRAM_TEMP_NOMINAL 0x3
893#define SDRAM_TEMP_RESERVED_4 0x4
894#define SDRAM_TEMP_HIGH_DERATE_REFRESH 0x5
895#define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS 0x6
896#define SDRAM_TEMP_VERY_HIGH_SHUTDOWN 0x7
897
898#define LPDDR2_MANUFACTURER_SAMSUNG 1
899#define LPDDR2_MANUFACTURER_QIMONDA 2
900#define LPDDR2_MANUFACTURER_ELPIDA 3
901#define LPDDR2_MANUFACTURER_ETRON 4
902#define LPDDR2_MANUFACTURER_NANYA 5
903#define LPDDR2_MANUFACTURER_HYNIX 6
904#define LPDDR2_MANUFACTURER_MOSEL 7
905#define LPDDR2_MANUFACTURER_WINBOND 8
906#define LPDDR2_MANUFACTURER_ESMT 9
907#define LPDDR2_MANUFACTURER_SPANSION 11
908#define LPDDR2_MANUFACTURER_SST 12
909#define LPDDR2_MANUFACTURER_ZMOS 13
910#define LPDDR2_MANUFACTURER_INTEL 14
911#define LPDDR2_MANUFACTURER_NUMONYX 254
912#define LPDDR2_MANUFACTURER_MICRON 255
913
914/* MR8 register fields */
915#define MR8_TYPE_SHIFT 0x0
916#define MR8_TYPE_MASK 0x3
917#define MR8_DENSITY_SHIFT 0x2
918#define MR8_DENSITY_MASK (0xF << 0x2)
919#define MR8_IO_WIDTH_SHIFT 0x6
920#define MR8_IO_WIDTH_MASK (0x3 << 0x6)
921
922struct lpddr2_addressing {
923 u8 num_banks;
924 u8 t_REFI_us_x10;
925 u8 row_sz[2]; /* One entry each for x32 and x16 */
926 u8 col_sz[2]; /* One entry each for x32 and x16 */
927};
928
929/* Structure for timings from the DDR datasheet */
930struct lpddr2_ac_timings {
931 u32 max_freq;
932 u8 RL;
933 u8 tRPab;
934 u8 tRCD;
935 u8 tWR;
936 u8 tRASmin;
937 u8 tRRD;
938 u8 tWTRx2;
939 u8 tXSR;
940 u8 tXPx2;
941 u8 tRFCab;
942 u8 tRTPx2;
943 u8 tCKE;
944 u8 tCKESR;
945 u8 tZQCS;
946 u32 tZQCL;
947 u32 tZQINIT;
948 u8 tDQSCKMAXx2;
949 u8 tRASmax;
950 u8 tFAW;
951
952};
953
954/*
955 * Min tCK values for some of the parameters:
956 * If the calculated clock cycles for the respective parameter is
957 * less than the corresponding min tCK value, we need to set the min
958 * tCK value. This may happen at lower frequencies.
959 */
960struct lpddr2_min_tck {
961 u32 tRL;
962 u32 tRP_AB;
963 u32 tRCD;
964 u32 tWR;
965 u32 tRAS_MIN;
966 u32 tRRD;
967 u32 tWTR;
968 u32 tXP;
969 u32 tRTP;
970 u8 tCKE;
971 u32 tCKESR;
972 u32 tFAW;
973};
974
975struct lpddr2_device_details {
976 u8 type;
977 u8 density;
978 u8 io_width;
979 u8 manufacturer;
980};
981
982struct lpddr2_device_timings {
983 const struct lpddr2_ac_timings **ac_timings;
984 const struct lpddr2_min_tck *min_tck;
985};
986
987/* Details of the devices connected to each chip-select of an EMIF instance */
988struct emif_device_details {
989 const struct lpddr2_device_details *cs0_device_details;
990 const struct lpddr2_device_details *cs1_device_details;
991 const struct lpddr2_device_timings *cs0_device_timings;
992 const struct lpddr2_device_timings *cs1_device_timings;
993};
994
995/*
996 * Structure containing shadow of important registers in EMIF
997 * The calculation function fills in this structure to be later used for
998 * initialization and DVFS
999 */
1000struct emif_regs {
1001 u32 freq;
1002 u32 sdram_config_init;
1003 u32 sdram_config;
1004 u32 ref_ctrl;
1005 u32 sdram_tim1;
1006 u32 sdram_tim2;
1007 u32 sdram_tim3;
1008 u32 read_idle_ctrl;
1009 u32 zq_config;
1010 u32 temp_alert_config;
1011 u32 emif_ddr_phy_ctlr_1_init;
1012 u32 emif_ddr_phy_ctlr_1;
1013};
1014
1015/* assert macros */
1016#if defined(DEBUG)
1017#define emif_assert(c) ({ if (!(c)) for (;;); })
1018#else
1019#define emif_assert(c) ({ if (0) hang(); })
1020#endif
1021
Aneesh Vc0e88522011-07-21 09:10:12 -04001022#ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
Aneesh Vcc565582011-07-21 09:10:09 -04001023void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs);
1024void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs);
Aneesh Vc0e88522011-07-21 09:10:12 -04001025#else
1026void emif_get_device_details(u32 emif_nr,
1027 struct lpddr2_device_details *cs0_device_details,
1028 struct lpddr2_device_details *cs1_device_details);
1029void emif_get_device_timings(u32 emif_nr,
1030 const struct lpddr2_device_timings **cs0_device_timings,
1031 const struct lpddr2_device_timings **cs1_device_timings);
1032#endif
Aneesh Vcc565582011-07-21 09:10:09 -04001033
1034#endif