4 * Copyright (C) 2009-2010 Texas Instruments, Inc.
6 * Aneesh V <aneesh@ti.com>
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.
15 #include <asm/types.h>
20 #define EMIF1_BASE 0x4c000000
21 #define EMIF2_BASE 0x4d000000
26 /* Registers shifts, masks and values */
29 #define EMIF_REG_SCHEME_SHIFT 30
30 #define EMIF_REG_SCHEME_MASK (0x3 << 30)
31 #define EMIF_REG_MODULE_ID_SHIFT 16
32 #define EMIF_REG_MODULE_ID_MASK (0xfff << 16)
33 #define EMIF_REG_RTL_VERSION_SHIFT 11
34 #define EMIF_REG_RTL_VERSION_MASK (0x1f << 11)
35 #define EMIF_REG_MAJOR_REVISION_SHIFT 8
36 #define EMIF_REG_MAJOR_REVISION_MASK (0x7 << 8)
37 #define EMIF_REG_MINOR_REVISION_SHIFT 0
38 #define EMIF_REG_MINOR_REVISION_MASK (0x3f << 0)
41 #define EMIF_REG_BE_SHIFT 31
42 #define EMIF_REG_BE_MASK (1 << 31)
43 #define EMIF_REG_DUAL_CLK_MODE_SHIFT 30
44 #define EMIF_REG_DUAL_CLK_MODE_MASK (1 << 30)
45 #define EMIF_REG_FAST_INIT_SHIFT 29
46 #define EMIF_REG_FAST_INIT_MASK (1 << 29)
47 #define EMIF_REG_PHY_DLL_READY_SHIFT 2
48 #define EMIF_REG_PHY_DLL_READY_MASK (1 << 2)
51 #define EMIF_REG_SDRAM_TYPE_SHIFT 29
52 #define EMIF_REG_SDRAM_TYPE_MASK (0x7 << 29)
53 #define EMIF_REG_SDRAM_TYPE_DDR1 0
54 #define EMIF_REG_SDRAM_TYPE_LPDDR1 1
55 #define EMIF_REG_SDRAM_TYPE_DDR2 2
56 #define EMIF_REG_SDRAM_TYPE_DDR3 3
57 #define EMIF_REG_SDRAM_TYPE_LPDDR2_S4 4
58 #define EMIF_REG_SDRAM_TYPE_LPDDR2_S2 5
59 #define EMIF_REG_IBANK_POS_SHIFT 27
60 #define EMIF_REG_IBANK_POS_MASK (0x3 << 27)
61 #define EMIF_REG_DDR_TERM_SHIFT 24
62 #define EMIF_REG_DDR_TERM_MASK (0x7 << 24)
63 #define EMIF_REG_DDR2_DDQS_SHIFT 23
64 #define EMIF_REG_DDR2_DDQS_MASK (1 << 23)
65 #define EMIF_REG_DYN_ODT_SHIFT 21
66 #define EMIF_REG_DYN_ODT_MASK (0x3 << 21)
67 #define EMIF_REG_DDR_DISABLE_DLL_SHIFT 20
68 #define EMIF_REG_DDR_DISABLE_DLL_MASK (1 << 20)
69 #define EMIF_REG_SDRAM_DRIVE_SHIFT 18
70 #define EMIF_REG_SDRAM_DRIVE_MASK (0x3 << 18)
71 #define EMIF_REG_CWL_SHIFT 16
72 #define EMIF_REG_CWL_MASK (0x3 << 16)
73 #define EMIF_REG_NARROW_MODE_SHIFT 14
74 #define EMIF_REG_NARROW_MODE_MASK (0x3 << 14)
75 #define EMIF_REG_CL_SHIFT 10
76 #define EMIF_REG_CL_MASK (0xf << 10)
77 #define EMIF_REG_ROWSIZE_SHIFT 7
78 #define EMIF_REG_ROWSIZE_MASK (0x7 << 7)
79 #define EMIF_REG_IBANK_SHIFT 4
80 #define EMIF_REG_IBANK_MASK (0x7 << 4)
81 #define EMIF_REG_EBANK_SHIFT 3
82 #define EMIF_REG_EBANK_MASK (1 << 3)
83 #define EMIF_REG_PAGESIZE_SHIFT 0
84 #define EMIF_REG_PAGESIZE_MASK (0x7 << 0)
87 #define EMIF_REG_CS1NVMEN_SHIFT 30
88 #define EMIF_REG_CS1NVMEN_MASK (1 << 30)
89 #define EMIF_REG_EBANK_POS_SHIFT 27
90 #define EMIF_REG_EBANK_POS_MASK (1 << 27)
91 #define EMIF_REG_RDBNUM_SHIFT 4
92 #define EMIF_REG_RDBNUM_MASK (0x3 << 4)
93 #define EMIF_REG_RDBSIZE_SHIFT 0
94 #define EMIF_REG_RDBSIZE_MASK (0x7 << 0)
97 #define EMIF_REG_INITREF_DIS_SHIFT 31
98 #define EMIF_REG_INITREF_DIS_MASK (1 << 31)
99 #define EMIF_REG_SRT_SHIFT 29
100 #define EMIF_REG_SRT_MASK (1 << 29)
101 #define EMIF_REG_ASR_SHIFT 28
102 #define EMIF_REG_ASR_MASK (1 << 28)
103 #define EMIF_REG_PASR_SHIFT 24
104 #define EMIF_REG_PASR_MASK (0x7 << 24)
105 #define EMIF_REG_REFRESH_RATE_SHIFT 0
106 #define EMIF_REG_REFRESH_RATE_MASK (0xffff << 0)
108 /* SDRAM_REF_CTRL_SHDW */
109 #define EMIF_REG_REFRESH_RATE_SHDW_SHIFT 0
110 #define EMIF_REG_REFRESH_RATE_SHDW_MASK (0xffff << 0)
113 #define EMIF_REG_T_RP_SHIFT 25
114 #define EMIF_REG_T_RP_MASK (0xf << 25)
115 #define EMIF_REG_T_RCD_SHIFT 21
116 #define EMIF_REG_T_RCD_MASK (0xf << 21)
117 #define EMIF_REG_T_WR_SHIFT 17
118 #define EMIF_REG_T_WR_MASK (0xf << 17)
119 #define EMIF_REG_T_RAS_SHIFT 12
120 #define EMIF_REG_T_RAS_MASK (0x1f << 12)
121 #define EMIF_REG_T_RC_SHIFT 6
122 #define EMIF_REG_T_RC_MASK (0x3f << 6)
123 #define EMIF_REG_T_RRD_SHIFT 3
124 #define EMIF_REG_T_RRD_MASK (0x7 << 3)
125 #define EMIF_REG_T_WTR_SHIFT 0
126 #define EMIF_REG_T_WTR_MASK (0x7 << 0)
128 /* SDRAM_TIM_1_SHDW */
129 #define EMIF_REG_T_RP_SHDW_SHIFT 25
130 #define EMIF_REG_T_RP_SHDW_MASK (0xf << 25)
131 #define EMIF_REG_T_RCD_SHDW_SHIFT 21
132 #define EMIF_REG_T_RCD_SHDW_MASK (0xf << 21)
133 #define EMIF_REG_T_WR_SHDW_SHIFT 17
134 #define EMIF_REG_T_WR_SHDW_MASK (0xf << 17)
135 #define EMIF_REG_T_RAS_SHDW_SHIFT 12
136 #define EMIF_REG_T_RAS_SHDW_MASK (0x1f << 12)
137 #define EMIF_REG_T_RC_SHDW_SHIFT 6
138 #define EMIF_REG_T_RC_SHDW_MASK (0x3f << 6)
139 #define EMIF_REG_T_RRD_SHDW_SHIFT 3
140 #define EMIF_REG_T_RRD_SHDW_MASK (0x7 << 3)
141 #define EMIF_REG_T_WTR_SHDW_SHIFT 0
142 #define EMIF_REG_T_WTR_SHDW_MASK (0x7 << 0)
145 #define EMIF_REG_T_XP_SHIFT 28
146 #define EMIF_REG_T_XP_MASK (0x7 << 28)
147 #define EMIF_REG_T_ODT_SHIFT 25
148 #define EMIF_REG_T_ODT_MASK (0x7 << 25)
149 #define EMIF_REG_T_XSNR_SHIFT 16
150 #define EMIF_REG_T_XSNR_MASK (0x1ff << 16)
151 #define EMIF_REG_T_XSRD_SHIFT 6
152 #define EMIF_REG_T_XSRD_MASK (0x3ff << 6)
153 #define EMIF_REG_T_RTP_SHIFT 3
154 #define EMIF_REG_T_RTP_MASK (0x7 << 3)
155 #define EMIF_REG_T_CKE_SHIFT 0
156 #define EMIF_REG_T_CKE_MASK (0x7 << 0)
158 /* SDRAM_TIM_2_SHDW */
159 #define EMIF_REG_T_XP_SHDW_SHIFT 28
160 #define EMIF_REG_T_XP_SHDW_MASK (0x7 << 28)
161 #define EMIF_REG_T_ODT_SHDW_SHIFT 25
162 #define EMIF_REG_T_ODT_SHDW_MASK (0x7 << 25)
163 #define EMIF_REG_T_XSNR_SHDW_SHIFT 16
164 #define EMIF_REG_T_XSNR_SHDW_MASK (0x1ff << 16)
165 #define EMIF_REG_T_XSRD_SHDW_SHIFT 6
166 #define EMIF_REG_T_XSRD_SHDW_MASK (0x3ff << 6)
167 #define EMIF_REG_T_RTP_SHDW_SHIFT 3
168 #define EMIF_REG_T_RTP_SHDW_MASK (0x7 << 3)
169 #define EMIF_REG_T_CKE_SHDW_SHIFT 0
170 #define EMIF_REG_T_CKE_SHDW_MASK (0x7 << 0)
173 #define EMIF_REG_T_CKESR_SHIFT 21
174 #define EMIF_REG_T_CKESR_MASK (0x7 << 21)
175 #define EMIF_REG_ZQ_ZQCS_SHIFT 15
176 #define EMIF_REG_ZQ_ZQCS_MASK (0x3f << 15)
177 #define EMIF_REG_T_TDQSCKMAX_SHIFT 13
178 #define EMIF_REG_T_TDQSCKMAX_MASK (0x3 << 13)
179 #define EMIF_REG_T_RFC_SHIFT 4
180 #define EMIF_REG_T_RFC_MASK (0x1ff << 4)
181 #define EMIF_REG_T_RAS_MAX_SHIFT 0
182 #define EMIF_REG_T_RAS_MAX_MASK (0xf << 0)
184 /* SDRAM_TIM_3_SHDW */
185 #define EMIF_REG_T_CKESR_SHDW_SHIFT 21
186 #define EMIF_REG_T_CKESR_SHDW_MASK (0x7 << 21)
187 #define EMIF_REG_ZQ_ZQCS_SHDW_SHIFT 15
188 #define EMIF_REG_ZQ_ZQCS_SHDW_MASK (0x3f << 15)
189 #define EMIF_REG_T_TDQSCKMAX_SHDW_SHIFT 13
190 #define EMIF_REG_T_TDQSCKMAX_SHDW_MASK (0x3 << 13)
191 #define EMIF_REG_T_RFC_SHDW_SHIFT 4
192 #define EMIF_REG_T_RFC_SHDW_MASK (0x1ff << 4)
193 #define EMIF_REG_T_RAS_MAX_SHDW_SHIFT 0
194 #define EMIF_REG_T_RAS_MAX_SHDW_MASK (0xf << 0)
197 #define EMIF_REG_NVM_T_XP_SHIFT 28
198 #define EMIF_REG_NVM_T_XP_MASK (0x7 << 28)
199 #define EMIF_REG_NVM_T_WTR_SHIFT 24
200 #define EMIF_REG_NVM_T_WTR_MASK (0x7 << 24)
201 #define EMIF_REG_NVM_T_RP_SHIFT 20
202 #define EMIF_REG_NVM_T_RP_MASK (0xf << 20)
203 #define EMIF_REG_NVM_T_WRA_SHIFT 16
204 #define EMIF_REG_NVM_T_WRA_MASK (0xf << 16)
205 #define EMIF_REG_NVM_T_RRD_SHIFT 8
206 #define EMIF_REG_NVM_T_RRD_MASK (0xff << 8)
207 #define EMIF_REG_NVM_T_RCDMIN_SHIFT 0
208 #define EMIF_REG_NVM_T_RCDMIN_MASK (0xff << 0)
210 /* LPDDR2_NVM_TIM_SHDW */
211 #define EMIF_REG_NVM_T_XP_SHDW_SHIFT 28
212 #define EMIF_REG_NVM_T_XP_SHDW_MASK (0x7 << 28)
213 #define EMIF_REG_NVM_T_WTR_SHDW_SHIFT 24
214 #define EMIF_REG_NVM_T_WTR_SHDW_MASK (0x7 << 24)
215 #define EMIF_REG_NVM_T_RP_SHDW_SHIFT 20
216 #define EMIF_REG_NVM_T_RP_SHDW_MASK (0xf << 20)
217 #define EMIF_REG_NVM_T_WRA_SHDW_SHIFT 16
218 #define EMIF_REG_NVM_T_WRA_SHDW_MASK (0xf << 16)
219 #define EMIF_REG_NVM_T_RRD_SHDW_SHIFT 8
220 #define EMIF_REG_NVM_T_RRD_SHDW_MASK (0xff << 8)
221 #define EMIF_REG_NVM_T_RCDMIN_SHDW_SHIFT 0
222 #define EMIF_REG_NVM_T_RCDMIN_SHDW_MASK (0xff << 0)
225 #define EMIF_REG_IDLEMODE_SHIFT 30
226 #define EMIF_REG_IDLEMODE_MASK (0x3 << 30)
227 #define EMIF_REG_PD_TIM_SHIFT 12
228 #define EMIF_REG_PD_TIM_MASK (0xf << 12)
229 #define EMIF_REG_DPD_EN_SHIFT 11
230 #define EMIF_REG_DPD_EN_MASK (1 << 11)
231 #define EMIF_REG_LP_MODE_SHIFT 8
232 #define EMIF_REG_LP_MODE_MASK (0x7 << 8)
233 #define EMIF_REG_SR_TIM_SHIFT 4
234 #define EMIF_REG_SR_TIM_MASK (0xf << 4)
235 #define EMIF_REG_CS_TIM_SHIFT 0
236 #define EMIF_REG_CS_TIM_MASK (0xf << 0)
238 /* PWR_MGMT_CTRL_SHDW */
239 #define EMIF_REG_PD_TIM_SHDW_SHIFT 12
240 #define EMIF_REG_PD_TIM_SHDW_MASK (0xf << 12)
241 #define EMIF_REG_SR_TIM_SHDW_SHIFT 4
242 #define EMIF_REG_SR_TIM_SHDW_MASK (0xf << 4)
243 #define EMIF_REG_CS_TIM_SHDW_SHIFT 0
244 #define EMIF_REG_CS_TIM_SHDW_MASK (0xf << 0)
246 /* LPDDR2_MODE_REG_DATA */
247 #define EMIF_REG_VALUE_0_SHIFT 0
248 #define EMIF_REG_VALUE_0_MASK (0x7f << 0)
250 /* LPDDR2_MODE_REG_CFG */
251 #define EMIF_REG_CS_SHIFT 31
252 #define EMIF_REG_CS_MASK (1 << 31)
253 #define EMIF_REG_REFRESH_EN_SHIFT 30
254 #define EMIF_REG_REFRESH_EN_MASK (1 << 30)
255 #define EMIF_REG_ADDRESS_SHIFT 0
256 #define EMIF_REG_ADDRESS_MASK (0xff << 0)
259 #define EMIF_REG_SYS_THRESH_MAX_SHIFT 24
260 #define EMIF_REG_SYS_THRESH_MAX_MASK (0xf << 24)
261 #define EMIF_REG_MPU_THRESH_MAX_SHIFT 20
262 #define EMIF_REG_MPU_THRESH_MAX_MASK (0xf << 20)
263 #define EMIF_REG_LL_THRESH_MAX_SHIFT 16
264 #define EMIF_REG_LL_THRESH_MAX_MASK (0xf << 16)
265 #define EMIF_REG_PR_OLD_COUNT_SHIFT 0
266 #define EMIF_REG_PR_OLD_COUNT_MASK (0xff << 0)
269 #define EMIF_REG_SYS_BUS_WIDTH_SHIFT 30
270 #define EMIF_REG_SYS_BUS_WIDTH_MASK (0x3 << 30)
271 #define EMIF_REG_LL_BUS_WIDTH_SHIFT 28
272 #define EMIF_REG_LL_BUS_WIDTH_MASK (0x3 << 28)
273 #define EMIF_REG_WR_FIFO_DEPTH_SHIFT 8
274 #define EMIF_REG_WR_FIFO_DEPTH_MASK (0xff << 8)
275 #define EMIF_REG_CMD_FIFO_DEPTH_SHIFT 0
276 #define EMIF_REG_CMD_FIFO_DEPTH_MASK (0xff << 0)
279 #define EMIF_REG_RREG_FIFO_DEPTH_SHIFT 16
280 #define EMIF_REG_RREG_FIFO_DEPTH_MASK (0xff << 16)
281 #define EMIF_REG_RSD_FIFO_DEPTH_SHIFT 8
282 #define EMIF_REG_RSD_FIFO_DEPTH_MASK (0xff << 8)
283 #define EMIF_REG_RCMD_FIFO_DEPTH_SHIFT 0
284 #define EMIF_REG_RCMD_FIFO_DEPTH_MASK (0xff << 0)
287 #define EMIF_REG_TLEC_SHIFT 16
288 #define EMIF_REG_TLEC_MASK (0xffff << 16)
289 #define EMIF_REG_MT_SHIFT 14
290 #define EMIF_REG_MT_MASK (1 << 14)
291 #define EMIF_REG_ACT_CAP_EN_SHIFT 13
292 #define EMIF_REG_ACT_CAP_EN_MASK (1 << 13)
293 #define EMIF_REG_OPG_LD_SHIFT 12
294 #define EMIF_REG_OPG_LD_MASK (1 << 12)
295 #define EMIF_REG_RESET_PHY_SHIFT 10
296 #define EMIF_REG_RESET_PHY_MASK (1 << 10)
297 #define EMIF_REG_MMS_SHIFT 8
298 #define EMIF_REG_MMS_MASK (1 << 8)
299 #define EMIF_REG_MC_SHIFT 4
300 #define EMIF_REG_MC_MASK (0x3 << 4)
301 #define EMIF_REG_PC_SHIFT 1
302 #define EMIF_REG_PC_MASK (0x7 << 1)
303 #define EMIF_REG_TM_SHIFT 0
304 #define EMIF_REG_TM_MASK (1 << 0)
306 /* IODFT_CTRL_MISR_RSLT */
307 #define EMIF_REG_DQM_TLMR_SHIFT 16
308 #define EMIF_REG_DQM_TLMR_MASK (0x3ff << 16)
309 #define EMIF_REG_CTL_TLMR_SHIFT 0
310 #define EMIF_REG_CTL_TLMR_MASK (0x7ff << 0)
312 /* IODFT_ADDR_MISR_RSLT */
313 #define EMIF_REG_ADDR_TLMR_SHIFT 0
314 #define EMIF_REG_ADDR_TLMR_MASK (0x1fffff << 0)
316 /* IODFT_DATA_MISR_RSLT_1 */
317 #define EMIF_REG_DATA_TLMR_31_0_SHIFT 0
318 #define EMIF_REG_DATA_TLMR_31_0_MASK (0xffffffff << 0)
320 /* IODFT_DATA_MISR_RSLT_2 */
321 #define EMIF_REG_DATA_TLMR_63_32_SHIFT 0
322 #define EMIF_REG_DATA_TLMR_63_32_MASK (0xffffffff << 0)
324 /* IODFT_DATA_MISR_RSLT_3 */
325 #define EMIF_REG_DATA_TLMR_66_64_SHIFT 0
326 #define EMIF_REG_DATA_TLMR_66_64_MASK (0x7 << 0)
329 #define EMIF_REG_COUNTER1_SHIFT 0
330 #define EMIF_REG_COUNTER1_MASK (0xffffffff << 0)
333 #define EMIF_REG_COUNTER2_SHIFT 0
334 #define EMIF_REG_COUNTER2_MASK (0xffffffff << 0)
337 #define EMIF_REG_CNTR2_MCONNID_EN_SHIFT 31
338 #define EMIF_REG_CNTR2_MCONNID_EN_MASK (1 << 31)
339 #define EMIF_REG_CNTR2_REGION_EN_SHIFT 30
340 #define EMIF_REG_CNTR2_REGION_EN_MASK (1 << 30)
341 #define EMIF_REG_CNTR2_CFG_SHIFT 16
342 #define EMIF_REG_CNTR2_CFG_MASK (0xf << 16)
343 #define EMIF_REG_CNTR1_MCONNID_EN_SHIFT 15
344 #define EMIF_REG_CNTR1_MCONNID_EN_MASK (1 << 15)
345 #define EMIF_REG_CNTR1_REGION_EN_SHIFT 14
346 #define EMIF_REG_CNTR1_REGION_EN_MASK (1 << 14)
347 #define EMIF_REG_CNTR1_CFG_SHIFT 0
348 #define EMIF_REG_CNTR1_CFG_MASK (0xf << 0)
351 #define EMIF_REG_MCONNID2_SHIFT 24
352 #define EMIF_REG_MCONNID2_MASK (0xff << 24)
353 #define EMIF_REG_REGION_SEL2_SHIFT 16
354 #define EMIF_REG_REGION_SEL2_MASK (0x3 << 16)
355 #define EMIF_REG_MCONNID1_SHIFT 8
356 #define EMIF_REG_MCONNID1_MASK (0xff << 8)
357 #define EMIF_REG_REGION_SEL1_SHIFT 0
358 #define EMIF_REG_REGION_SEL1_MASK (0x3 << 0)
361 #define EMIF_REG_TOTAL_TIME_SHIFT 0
362 #define EMIF_REG_TOTAL_TIME_MASK (0xffffffff << 0)
365 #define EMIF_REG_READ_IDLE_LEN_SHIFT 16
366 #define EMIF_REG_READ_IDLE_LEN_MASK (0xf << 16)
367 #define EMIF_REG_READ_IDLE_INTERVAL_SHIFT 0
368 #define EMIF_REG_READ_IDLE_INTERVAL_MASK (0x1ff << 0)
370 /* READ_IDLE_CTRL_SHDW */
371 #define EMIF_REG_READ_IDLE_LEN_SHDW_SHIFT 16
372 #define EMIF_REG_READ_IDLE_LEN_SHDW_MASK (0xf << 16)
373 #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_SHIFT 0
374 #define EMIF_REG_READ_IDLE_INTERVAL_SHDW_MASK (0x1ff << 0)
377 #define EMIF_REG_EOI_SHIFT 0
378 #define EMIF_REG_EOI_MASK (1 << 0)
380 /* IRQSTATUS_RAW_SYS */
381 #define EMIF_REG_DNV_SYS_SHIFT 2
382 #define EMIF_REG_DNV_SYS_MASK (1 << 2)
383 #define EMIF_REG_TA_SYS_SHIFT 1
384 #define EMIF_REG_TA_SYS_MASK (1 << 1)
385 #define EMIF_REG_ERR_SYS_SHIFT 0
386 #define EMIF_REG_ERR_SYS_MASK (1 << 0)
388 /* IRQSTATUS_RAW_LL */
389 #define EMIF_REG_DNV_LL_SHIFT 2
390 #define EMIF_REG_DNV_LL_MASK (1 << 2)
391 #define EMIF_REG_TA_LL_SHIFT 1
392 #define EMIF_REG_TA_LL_MASK (1 << 1)
393 #define EMIF_REG_ERR_LL_SHIFT 0
394 #define EMIF_REG_ERR_LL_MASK (1 << 0)
400 /* IRQENABLE_SET_SYS */
401 #define EMIF_REG_EN_DNV_SYS_SHIFT 2
402 #define EMIF_REG_EN_DNV_SYS_MASK (1 << 2)
403 #define EMIF_REG_EN_TA_SYS_SHIFT 1
404 #define EMIF_REG_EN_TA_SYS_MASK (1 << 1)
405 #define EMIF_REG_EN_ERR_SYS_SHIFT 0
406 #define EMIF_REG_EN_ERR_SYS_MASK (1 << 0)
408 /* IRQENABLE_SET_LL */
409 #define EMIF_REG_EN_DNV_LL_SHIFT 2
410 #define EMIF_REG_EN_DNV_LL_MASK (1 << 2)
411 #define EMIF_REG_EN_TA_LL_SHIFT 1
412 #define EMIF_REG_EN_TA_LL_MASK (1 << 1)
413 #define EMIF_REG_EN_ERR_LL_SHIFT 0
414 #define EMIF_REG_EN_ERR_LL_MASK (1 << 0)
416 /* IRQENABLE_CLR_SYS */
418 /* IRQENABLE_CLR_LL */
421 #define EMIF_REG_ZQ_CS1EN_SHIFT 31
422 #define EMIF_REG_ZQ_CS1EN_MASK (1 << 31)
423 #define EMIF_REG_ZQ_CS0EN_SHIFT 30
424 #define EMIF_REG_ZQ_CS0EN_MASK (1 << 30)
425 #define EMIF_REG_ZQ_DUALCALEN_SHIFT 29
426 #define EMIF_REG_ZQ_DUALCALEN_MASK (1 << 29)
427 #define EMIF_REG_ZQ_SFEXITEN_SHIFT 28
428 #define EMIF_REG_ZQ_SFEXITEN_MASK (1 << 28)
429 #define EMIF_REG_ZQ_ZQINIT_MULT_SHIFT 18
430 #define EMIF_REG_ZQ_ZQINIT_MULT_MASK (0x3 << 18)
431 #define EMIF_REG_ZQ_ZQCL_MULT_SHIFT 16
432 #define EMIF_REG_ZQ_ZQCL_MULT_MASK (0x3 << 16)
433 #define EMIF_REG_ZQ_REFINTERVAL_SHIFT 0
434 #define EMIF_REG_ZQ_REFINTERVAL_MASK (0xffff << 0)
436 /* TEMP_ALERT_CONFIG */
437 #define EMIF_REG_TA_CS1EN_SHIFT 31
438 #define EMIF_REG_TA_CS1EN_MASK (1 << 31)
439 #define EMIF_REG_TA_CS0EN_SHIFT 30
440 #define EMIF_REG_TA_CS0EN_MASK (1 << 30)
441 #define EMIF_REG_TA_SFEXITEN_SHIFT 28
442 #define EMIF_REG_TA_SFEXITEN_MASK (1 << 28)
443 #define EMIF_REG_TA_DEVWDT_SHIFT 26
444 #define EMIF_REG_TA_DEVWDT_MASK (0x3 << 26)
445 #define EMIF_REG_TA_DEVCNT_SHIFT 24
446 #define EMIF_REG_TA_DEVCNT_MASK (0x3 << 24)
447 #define EMIF_REG_TA_REFINTERVAL_SHIFT 0
448 #define EMIF_REG_TA_REFINTERVAL_MASK (0x3fffff << 0)
451 #define EMIF_REG_MADDRSPACE_SHIFT 14
452 #define EMIF_REG_MADDRSPACE_MASK (0x3 << 14)
453 #define EMIF_REG_MBURSTSEQ_SHIFT 11
454 #define EMIF_REG_MBURSTSEQ_MASK (0x7 << 11)
455 #define EMIF_REG_MCMD_SHIFT 8
456 #define EMIF_REG_MCMD_MASK (0x7 << 8)
457 #define EMIF_REG_MCONNID_SHIFT 0
458 #define EMIF_REG_MCONNID_MASK (0xff << 0)
461 #define EMIF_REG_DDR_PHY_CTRL_1_SHIFT 4
462 #define EMIF_REG_DDR_PHY_CTRL_1_MASK (0xfffffff << 4)
463 #define EMIF_REG_READ_LATENCY_SHIFT 0
464 #define EMIF_REG_READ_LATENCY_MASK (0xf << 0)
465 #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHIFT 4
466 #define EMIF_REG_DLL_SLAVE_DLY_CTRL_MASK (0xFF << 4)
467 #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHIFT 12
468 #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_MASK (0xFFFFF << 12)
470 /* DDR_PHY_CTRL_1_SHDW */
471 #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_SHIFT 4
472 #define EMIF_REG_DDR_PHY_CTRL_1_SHDW_MASK (0xfffffff << 4)
473 #define EMIF_REG_READ_LATENCY_SHDW_SHIFT 0
474 #define EMIF_REG_READ_LATENCY_SHDW_MASK (0xf << 0)
475 #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_SHIFT 4
476 #define EMIF_REG_DLL_SLAVE_DLY_CTRL_SHDW_MASK (0xFF << 4)
477 #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_SHIFT 12
478 #define EMIF_EMIF_DDR_PHY_CTRL_1_BASE_VAL_SHDW_MASK (0xFFFFF << 12)
481 #define EMIF_REG_DDR_PHY_CTRL_2_SHIFT 0
482 #define EMIF_REG_DDR_PHY_CTRL_2_MASK (0xffffffff << 0)
484 /*EMIF_READ_WRITE_LEVELING_CONTROL*/
485 #define EMIF_REG_RDWRLVLFULL_START_SHIFT 31
486 #define EMIF_REG_RDWRLVLFULL_START_MASK (1 << 31)
487 #define EMIF_REG_RDWRLVLINC_PRE_SHIFT 24
488 #define EMIF_REG_RDWRLVLINC_PRE_MASK (0x7F << 24)
489 #define EMIF_REG_RDLVLINC_INT_SHIFT 16
490 #define EMIF_REG_RDLVLINC_INT_MASK (0xFF << 16)
491 #define EMIF_REG_RDLVLGATEINC_INT_SHIFT 8
492 #define EMIF_REG_RDLVLGATEINC_INT_MASK (0xFF << 8)
493 #define EMIF_REG_WRLVLINC_INT_SHIFT 0
494 #define EMIF_REG_WRLVLINC_INT_MASK (0xFF << 0)
496 /*EMIF_READ_WRITE_LEVELING_RAMP_CONTROL*/
497 #define EMIF_REG_RDWRLVL_EN_SHIFT 31
498 #define EMIF_REG_RDWRLVL_EN_MASK (1 << 31)
499 #define EMIF_REG_RDWRLVLINC_RMP_PRE_SHIFT 24
500 #define EMIF_REG_RDWRLVLINC_RMP_PRE_MASK (0x7F << 24)
501 #define EMIF_REG_RDLVLINC_RMP_INT_SHIFT 16
502 #define EMIF_REG_RDLVLINC_RMP_INT_MASK (0xFF << 16)
503 #define EMIF_REG_RDLVLGATEINC_RMP_INT_SHIFT 8
504 #define EMIF_REG_RDLVLGATEINC_RMP_INT_MASK (0xFF << 8)
505 #define EMIF_REG_WRLVLINC_RMP_INT_SHIFT 0
506 #define EMIF_REG_WRLVLINC_RMP_INT_MASK (0xFF << 0)
508 /*EMIF_READ_WRITE_LEVELING_RAMP_WINDOW*/
509 #define EMIF_REG_RDWRLVLINC_RMP_WIN_SHIFT 0
510 #define EMIF_REG_RDWRLVLINC_RMP_WIN_MASK (0x1FFF << 0)
513 #define DDR3_WR_LVL_INT 0x73
514 #define DDR3_RD_LVL_INT 0x33
515 #define DDR3_RD_LVL_GATE_INT 0x59
516 #define RD_RW_LVL_INC_PRE 0x0
517 #define DDR3_FULL_LVL (1 << EMIF_REG_RDWRLVL_EN_SHIFT)
519 #define DDR3_INC_LVL ((DDR3_WR_LVL_INT << EMIF_REG_WRLVLINC_INT_SHIFT) \
520 | (DDR3_RD_LVL_GATE_INT << EMIF_REG_RDLVLGATEINC_INT_SHIFT) \
521 | (DDR3_RD_LVL_INT << EMIF_REG_RDLVLINC_RMP_INT_SHIFT) \
522 | (RD_RW_LVL_INC_PRE << EMIF_REG_RDWRLVLINC_RMP_PRE_SHIFT))
524 #define SDRAM_CONFIG_EXT_RD_LVL_11_SAMPLES 0x0000C1A7
525 #define SDRAM_CONFIG_EXT_RD_LVL_4_SAMPLES 0x000001A7
526 #define SDRAM_CONFIG_EXT_RD_LVL_11_SAMPLES_ES2 0x0000C1C7
529 #define DMM_BASE 0x4E000040
532 #define MA_BASE 0x482AF040
535 #define EMIF_SYS_ADDR_SHIFT 24
536 #define EMIF_SYS_ADDR_MASK (0xff << 24)
537 #define EMIF_SYS_SIZE_SHIFT 20
538 #define EMIF_SYS_SIZE_MASK (0x7 << 20)
539 #define EMIF_SDRC_INTL_SHIFT 18
540 #define EMIF_SDRC_INTL_MASK (0x3 << 18)
541 #define EMIF_SDRC_ADDRSPC_SHIFT 16
542 #define EMIF_SDRC_ADDRSPC_MASK (0x3 << 16)
543 #define EMIF_SDRC_MAP_SHIFT 8
544 #define EMIF_SDRC_MAP_MASK (0x3 << 8)
545 #define EMIF_SDRC_ADDR_SHIFT 0
546 #define EMIF_SDRC_ADDR_MASK (0xff << 0)
548 /* DMM_LISA_MAP fields */
549 #define DMM_SDRC_MAP_UNMAPPED 0
550 #define DMM_SDRC_MAP_EMIF1_ONLY 1
551 #define DMM_SDRC_MAP_EMIF2_ONLY 2
552 #define DMM_SDRC_MAP_EMIF1_AND_EMIF2 3
554 #define DMM_SDRC_INTL_NONE 0
555 #define DMM_SDRC_INTL_128B 1
556 #define DMM_SDRC_INTL_256B 2
557 #define DMM_SDRC_INTL_512 3
559 #define DMM_SDRC_ADDR_SPC_SDRAM 0
560 #define DMM_SDRC_ADDR_SPC_NVM 1
561 #define DMM_SDRC_ADDR_SPC_INVALID 2
563 #define DMM_LISA_MAP_INTERLEAVED_BASE_VAL (\
564 (DMM_SDRC_MAP_EMIF1_AND_EMIF2 << EMIF_SDRC_MAP_SHIFT) |\
565 (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT) |\
566 (DMM_SDRC_INTL_128B << EMIF_SDRC_INTL_SHIFT) |\
567 (CONFIG_SYS_SDRAM_BASE << EMIF_SYS_ADDR_SHIFT))
569 #define DMM_LISA_MAP_EMIF1_ONLY_BASE_VAL (\
570 (DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\
571 (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\
572 (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT))
574 #define DMM_LISA_MAP_EMIF2_ONLY_BASE_VAL (\
575 (DMM_SDRC_MAP_EMIF2_ONLY << EMIF_SDRC_MAP_SHIFT)|\
576 (DMM_SDRC_ADDR_SPC_SDRAM << EMIF_SDRC_ADDRSPC_SHIFT)|\
577 (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT))
579 /* Trap for invalid TILER PAT entries */
580 #define DMM_LISA_MAP_0_INVAL_ADDR_TRAP (\
581 (0 << EMIF_SDRC_ADDR_SHIFT) |\
582 (DMM_SDRC_MAP_EMIF1_ONLY << EMIF_SDRC_MAP_SHIFT)|\
583 (DMM_SDRC_ADDR_SPC_INVALID << EMIF_SDRC_ADDRSPC_SHIFT)|\
584 (DMM_SDRC_INTL_NONE << EMIF_SDRC_INTL_SHIFT)|\
585 (0xFF << EMIF_SYS_ADDR_SHIFT))
587 #define EMIF_EXT_PHY_CTRL_TIMING_REG 0x5
589 /* Reg mapping structure */
590 struct emif_reg_struct {
593 u32 emif_sdram_config;
594 u32 emif_lpddr2_nvm_config;
595 u32 emif_sdram_ref_ctrl;
596 u32 emif_sdram_ref_ctrl_shdw;
597 u32 emif_sdram_tim_1;
598 u32 emif_sdram_tim_1_shdw;
599 u32 emif_sdram_tim_2;
600 u32 emif_sdram_tim_2_shdw;
601 u32 emif_sdram_tim_3;
602 u32 emif_sdram_tim_3_shdw;
603 u32 emif_lpddr2_nvm_tim;
604 u32 emif_lpddr2_nvm_tim_shdw;
605 u32 emif_pwr_mgmt_ctrl;
606 u32 emif_pwr_mgmt_ctrl_shdw;
607 u32 emif_lpddr2_mode_reg_data;
609 u32 emif_lpddr2_mode_reg_data_es2;
611 u32 emif_lpddr2_mode_reg_cfg;
613 u32 emif_l3_cfg_val_1;
614 u32 emif_l3_cfg_val_2;
619 u32 emif_perf_cnt_cfg;
620 u32 emif_perf_cnt_sel;
621 u32 emif_perf_cnt_tim;
623 u32 emif_read_idlectrl;
624 u32 emif_read_idlectrl_shdw;
626 u32 emif_irqstatus_raw_sys;
627 u32 emif_irqstatus_raw_ll;
628 u32 emif_irqstatus_sys;
629 u32 emif_irqstatus_ll;
630 u32 emif_irqenable_set_sys;
631 u32 emif_irqenable_set_ll;
632 u32 emif_irqenable_clr_sys;
633 u32 emif_irqenable_clr_ll;
636 u32 emif_temp_alert_config;
638 u32 emif_rd_wr_lvl_rmp_win;
639 u32 emif_rd_wr_lvl_rmp_ctl;
640 u32 emif_rd_wr_lvl_ctl;
642 u32 emif_ddr_phy_ctrl_1;
643 u32 emif_ddr_phy_ctrl_1_shdw;
644 u32 emif_ddr_phy_ctrl_2;
646 u32 emif_prio_class_serv_map;
647 u32 emif_connect_id_serv_1_map;
648 u32 emif_connect_id_serv_2_map;
650 u32 emif_rd_wr_exec_thresh;
653 u32 emif_ddr_phy_status[21];
655 u32 emif_ddr_ext_phy_ctrl_1;
656 u32 emif_ddr_ext_phy_ctrl_1_shdw;
657 u32 emif_ddr_ext_phy_ctrl_2;
658 u32 emif_ddr_ext_phy_ctrl_2_shdw;
659 u32 emif_ddr_ext_phy_ctrl_3;
660 u32 emif_ddr_ext_phy_ctrl_3_shdw;
661 u32 emif_ddr_ext_phy_ctrl_4;
662 u32 emif_ddr_ext_phy_ctrl_4_shdw;
663 u32 emif_ddr_ext_phy_ctrl_5;
664 u32 emif_ddr_ext_phy_ctrl_5_shdw;
665 u32 emif_ddr_ext_phy_ctrl_6;
666 u32 emif_ddr_ext_phy_ctrl_6_shdw;
667 u32 emif_ddr_ext_phy_ctrl_7;
668 u32 emif_ddr_ext_phy_ctrl_7_shdw;
669 u32 emif_ddr_ext_phy_ctrl_8;
670 u32 emif_ddr_ext_phy_ctrl_8_shdw;
671 u32 emif_ddr_ext_phy_ctrl_9;
672 u32 emif_ddr_ext_phy_ctrl_9_shdw;
673 u32 emif_ddr_ext_phy_ctrl_10;
674 u32 emif_ddr_ext_phy_ctrl_10_shdw;
675 u32 emif_ddr_ext_phy_ctrl_11;
676 u32 emif_ddr_ext_phy_ctrl_11_shdw;
677 u32 emif_ddr_ext_phy_ctrl_12;
678 u32 emif_ddr_ext_phy_ctrl_12_shdw;
679 u32 emif_ddr_ext_phy_ctrl_13;
680 u32 emif_ddr_ext_phy_ctrl_13_shdw;
681 u32 emif_ddr_ext_phy_ctrl_14;
682 u32 emif_ddr_ext_phy_ctrl_14_shdw;
683 u32 emif_ddr_ext_phy_ctrl_15;
684 u32 emif_ddr_ext_phy_ctrl_15_shdw;
685 u32 emif_ddr_ext_phy_ctrl_16;
686 u32 emif_ddr_ext_phy_ctrl_16_shdw;
687 u32 emif_ddr_ext_phy_ctrl_17;
688 u32 emif_ddr_ext_phy_ctrl_17_shdw;
689 u32 emif_ddr_ext_phy_ctrl_18;
690 u32 emif_ddr_ext_phy_ctrl_18_shdw;
691 u32 emif_ddr_ext_phy_ctrl_19;
692 u32 emif_ddr_ext_phy_ctrl_19_shdw;
693 u32 emif_ddr_ext_phy_ctrl_20;
694 u32 emif_ddr_ext_phy_ctrl_20_shdw;
695 u32 emif_ddr_ext_phy_ctrl_21;
696 u32 emif_ddr_ext_phy_ctrl_21_shdw;
697 u32 emif_ddr_ext_phy_ctrl_22;
698 u32 emif_ddr_ext_phy_ctrl_22_shdw;
699 u32 emif_ddr_ext_phy_ctrl_23;
700 u32 emif_ddr_ext_phy_ctrl_23_shdw;
701 u32 emif_ddr_ext_phy_ctrl_24;
702 u32 emif_ddr_ext_phy_ctrl_24_shdw;
704 u32 emif_ddr_fifo_misaligned_clear_1;
705 u32 emif_ddr_fifo_misaligned_clear_2;
708 struct dmm_lisa_map_regs {
718 /* The maximum frequency at which the LPDDR2 interface can operate in Hz*/
719 #define MAX_LPDDR2_FREQ 400000000 /* 400 MHz */
722 * The period of DDR clk is represented as numerator and denominator for
723 * better accuracy in integer based calculations. However, if the numerator
724 * and denominator are very huge there may be chances of overflow in
725 * calculations. So, as a trade-off keep denominator(and consequently
726 * numerator) within a limit sacrificing some accuracy - but not much
727 * If denominator and numerator are already small (such as at 400 MHz)
728 * no adjustment is needed
730 #define EMIF_PERIOD_DEN_LIMIT 1000
732 * Maximum number of different frequencies supported by EMIF driver
733 * Determines the number of entries in the pointer array for register
736 #define EMIF_MAX_NUM_FREQUENCIES 6
738 * Indices into the Addressing Table array.
739 * One entry each for all the different types of devices with different
742 #define ADDR_TABLE_INDEX64M 0
743 #define ADDR_TABLE_INDEX128M 1
744 #define ADDR_TABLE_INDEX256M 2
745 #define ADDR_TABLE_INDEX512M 3
746 #define ADDR_TABLE_INDEX1GS4 4
747 #define ADDR_TABLE_INDEX2GS4 5
748 #define ADDR_TABLE_INDEX4G 6
749 #define ADDR_TABLE_INDEX8G 7
750 #define ADDR_TABLE_INDEX1GS2 8
751 #define ADDR_TABLE_INDEX2GS2 9
752 #define ADDR_TABLE_INDEXMAX 10
754 /* Number of Row bits */
764 /* Number of Column bits */
769 #define COL_7 4 /*Not supported by OMAP included for completeness */
777 /* Refresh rate in micro seconds x 10 */
778 #define T_REFI_15_6 156
779 #define T_REFI_7_8 78
780 #define T_REFI_3_9 39
782 #define EBANK_CS1_DIS 0
783 #define EBANK_CS1_EN 1
785 /* Read Latency used by the device at reset */
787 /* Read Latency for the highest frequency you want to use */
788 #ifdef CONFIG_OMAP54XX
795 /* Interleaving policies at EMIF level- between banks and Chip Selects */
796 #define EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING 0
797 #define EMIF_INTERLEAVING_POLICY_NO_BANK_INTERLEAVING 3
800 * Interleaving policy to be used
801 * Currently set to MAX interleaving for better performance
803 #define EMIF_INTERLEAVING_POLICY EMIF_INTERLEAVING_POLICY_MAX_INTERLEAVING
805 /* State of the core voltage:
806 * This is important for some parameters such as read idle control and
807 * ZQ calibration timings. Timings are much stricter when voltage ramp
808 * is happening compared to when the voltage is stable.
809 * We need to calculate two sets of values for these parameters and use
812 #define LPDDR2_VOLTAGE_STABLE 0
813 #define LPDDR2_VOLTAGE_RAMPING 1
815 /* Length of the forced read idle period in terms of cycles */
816 #define EMIF_REG_READ_IDLE_LEN_VAL 5
818 /* Interval between forced 'read idles' */
819 /* To be used when voltage is changed for DPS/DVFS - 1us */
820 #define READ_IDLE_INTERVAL_DVFS (1*1000)
822 * To be used when voltage is not scaled except by Smart Reflex
823 * 50us - or maximum value will do
825 #define READ_IDLE_INTERVAL_NORMAL (50*1000)
829 * Unless voltage is changing due to DVFS one ZQCS command every 50ms should
830 * be enough. This shoule be enough also in the case when voltage is changing
831 * due to smart-reflex.
833 #define EMIF_ZQCS_INTERVAL_NORMAL_IN_US (50*1000)
835 * If voltage is changing due to DVFS ZQCS should be performed more
838 #define EMIF_ZQCS_INTERVAL_DVFS_IN_US 50
840 /* The interval between ZQCL commands as a multiple of ZQCS interval */
841 #define REG_ZQ_ZQCL_MULT 4
842 /* The interval between ZQINIT commands as a multiple of ZQCL interval */
843 #define REG_ZQ_ZQINIT_MULT 3
844 /* Enable ZQ Calibration on exiting Self-refresh */
845 #define REG_ZQ_SFEXITEN_ENABLE 1
847 * ZQ Calibration simultaneously on both chip-selects:
848 * Needs one calibration resistor per CS
849 * None of the boards that we know of have this capability
850 * So disabled by default
852 #define REG_ZQ_DUALCALEN_DISABLE 0
854 * Enable ZQ Calibration by default on CS0. If we are asked to program
855 * the EMIF there will be something connected to CS0 for sure
857 #define REG_ZQ_CS0EN_ENABLE 1
859 /* EMIF_PWR_MGMT_CTRL register */
860 /* Low power modes */
861 #define LP_MODE_DISABLE 0
862 #define LP_MODE_CLOCK_STOP 1
863 #define LP_MODE_SELF_REFRESH 2
864 #define LP_MODE_PWR_DN 3
867 #define DPD_DISABLE 0
870 /* Maximum delay before Low Power Modes */
871 #define REG_CS_TIM 0x0
872 #define REG_SR_TIM 0x0
873 #define REG_PD_TIM 0x0
876 /* EMIF_PWR_MGMT_CTRL register */
877 #define EMIF_PWR_MGMT_CTRL (\
878 ((REG_CS_TIM << EMIF_REG_CS_TIM_SHIFT) & EMIF_REG_CS_TIM_MASK)|\
879 ((REG_SR_TIM << EMIF_REG_SR_TIM_SHIFT) & EMIF_REG_SR_TIM_MASK)|\
880 ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\
881 ((REG_PD_TIM << EMIF_REG_PD_TIM_SHIFT) & EMIF_REG_PD_TIM_MASK)|\
882 ((LP_MODE_DISABLE << EMIF_REG_LP_MODE_SHIFT)\
883 & EMIF_REG_LP_MODE_MASK) |\
884 ((DPD_DISABLE << EMIF_REG_DPD_EN_SHIFT)\
885 & EMIF_REG_DPD_EN_MASK))\
887 #define EMIF_PWR_MGMT_CTRL_SHDW (\
888 ((REG_CS_TIM << EMIF_REG_CS_TIM_SHDW_SHIFT)\
889 & EMIF_REG_CS_TIM_SHDW_MASK) |\
890 ((REG_SR_TIM << EMIF_REG_SR_TIM_SHDW_SHIFT)\
891 & EMIF_REG_SR_TIM_SHDW_MASK) |\
892 ((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\
893 & EMIF_REG_PD_TIM_SHDW_MASK) |\
894 ((REG_PD_TIM << EMIF_REG_PD_TIM_SHDW_SHIFT)\
895 & EMIF_REG_PD_TIM_SHDW_MASK))
897 /* EMIF_L3_CONFIG register value */
898 #define EMIF_L3_CONFIG_VAL_SYS_10_LL_0 0x0A0000FF
899 #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_3_LL_0 0x0A300000
900 #define EMIF_L3_CONFIG_VAL_SYS_10_MPU_5_LL_0 0x0A500000
903 * Value of bits 12:31 of DDR_PHY_CTRL_1 register:
904 * All these fields have magic values dependent on frequency and
905 * determined by PHY and DLL integration with EMIF. Setting the magic
906 * values suggested by hw team.
908 #define EMIF_DDR_PHY_CTRL_1_BASE_VAL 0x049FF
909 #define EMIF_DLL_SLAVE_DLY_CTRL_400_MHZ 0x41
910 #define EMIF_DLL_SLAVE_DLY_CTRL_200_MHZ 0x80
911 #define EMIF_DLL_SLAVE_DLY_CTRL_100_MHZ_AND_LESS 0xFF
916 * Burst type : sequential
918 * nWR : 3(default). EMIF does not do pre-charge.
919 * : So nWR is don't care
921 #define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3 0x23
922 #define MR1_BL_8_BT_SEQ_WRAP_EN_NWR_8 0xc3
925 #define MR2_RL3_WL1 1
926 #define MR2_RL4_WL2 2
927 #define MR2_RL5_WL2 3
928 #define MR2_RL6_WL3 4
930 /* MR10: ZQ calibration codes */
931 #define MR10_ZQ_ZQCS 0x56
932 #define MR10_ZQ_ZQCL 0xAB
933 #define MR10_ZQ_ZQINIT 0xFF
934 #define MR10_ZQ_ZQRESET 0xC3
936 /* TEMP_ALERT_CONFIG */
937 #define TEMP_ALERT_POLL_INTERVAL_MS 360 /* for temp gradient - 5 C/s */
938 #define TEMP_ALERT_CONFIG_DEVCT_1 0
939 #define TEMP_ALERT_CONFIG_DEVWDT_32 2
941 /* MR16 value: refresh full array(no partial array self refresh) */
942 #define MR16_REF_FULL_ARRAY 0
945 * Maximum number of entries we keep in our array of timing tables
946 * We need not keep all the speed bins supported by the device
947 * We need to keep timing tables for only the speed bins that we
950 #define MAX_NUM_SPEEDBINS 4
952 /* LPDDR2 Densities */
953 #define LPDDR2_DENSITY_64Mb 0
954 #define LPDDR2_DENSITY_128Mb 1
955 #define LPDDR2_DENSITY_256Mb 2
956 #define LPDDR2_DENSITY_512Mb 3
957 #define LPDDR2_DENSITY_1Gb 4
958 #define LPDDR2_DENSITY_2Gb 5
959 #define LPDDR2_DENSITY_4Gb 6
960 #define LPDDR2_DENSITY_8Gb 7
961 #define LPDDR2_DENSITY_16Gb 8
962 #define LPDDR2_DENSITY_32Gb 9
965 #define LPDDR2_TYPE_S4 0
966 #define LPDDR2_TYPE_S2 1
967 #define LPDDR2_TYPE_NVM 2
969 /* LPDDR2 IO width */
970 #define LPDDR2_IO_WIDTH_32 0
971 #define LPDDR2_IO_WIDTH_16 1
972 #define LPDDR2_IO_WIDTH_8 2
974 /* Mode register numbers */
985 #define LPDDR2_MR10 10
986 #define LPDDR2_MR11 11
987 #define LPDDR2_MR16 16
988 #define LPDDR2_MR17 17
989 #define LPDDR2_MR18 18
992 #define LPDDR2_MR0_DAI_SHIFT 0
993 #define LPDDR2_MR0_DAI_MASK 1
994 #define LPDDR2_MR0_DI_SHIFT 1
995 #define LPDDR2_MR0_DI_MASK (1 << 1)
996 #define LPDDR2_MR0_DNVI_SHIFT 2
997 #define LPDDR2_MR0_DNVI_MASK (1 << 2)
1000 #define MR4_SDRAM_REF_RATE_SHIFT 0
1001 #define MR4_SDRAM_REF_RATE_MASK 7
1002 #define MR4_TUF_SHIFT 7
1003 #define MR4_TUF_MASK (1 << 7)
1005 /* MR4 SDRAM Refresh Rate field values */
1006 #define SDRAM_TEMP_LESS_LOW_SHUTDOWN 0x0
1007 #define SDRAM_TEMP_LESS_4X_REFRESH_AND_TIMINGS 0x1
1008 #define SDRAM_TEMP_LESS_2X_REFRESH_AND_TIMINGS 0x2
1009 #define SDRAM_TEMP_NOMINAL 0x3
1010 #define SDRAM_TEMP_RESERVED_4 0x4
1011 #define SDRAM_TEMP_HIGH_DERATE_REFRESH 0x5
1012 #define SDRAM_TEMP_HIGH_DERATE_REFRESH_AND_TIMINGS 0x6
1013 #define SDRAM_TEMP_VERY_HIGH_SHUTDOWN 0x7
1015 #define LPDDR2_MANUFACTURER_SAMSUNG 1
1016 #define LPDDR2_MANUFACTURER_QIMONDA 2
1017 #define LPDDR2_MANUFACTURER_ELPIDA 3
1018 #define LPDDR2_MANUFACTURER_ETRON 4
1019 #define LPDDR2_MANUFACTURER_NANYA 5
1020 #define LPDDR2_MANUFACTURER_HYNIX 6
1021 #define LPDDR2_MANUFACTURER_MOSEL 7
1022 #define LPDDR2_MANUFACTURER_WINBOND 8
1023 #define LPDDR2_MANUFACTURER_ESMT 9
1024 #define LPDDR2_MANUFACTURER_SPANSION 11
1025 #define LPDDR2_MANUFACTURER_SST 12
1026 #define LPDDR2_MANUFACTURER_ZMOS 13
1027 #define LPDDR2_MANUFACTURER_INTEL 14
1028 #define LPDDR2_MANUFACTURER_NUMONYX 254
1029 #define LPDDR2_MANUFACTURER_MICRON 255
1031 /* MR8 register fields */
1032 #define MR8_TYPE_SHIFT 0x0
1033 #define MR8_TYPE_MASK 0x3
1034 #define MR8_DENSITY_SHIFT 0x2
1035 #define MR8_DENSITY_MASK (0xF << 0x2)
1036 #define MR8_IO_WIDTH_SHIFT 0x6
1037 #define MR8_IO_WIDTH_MASK (0x3 << 0x6)
1040 #define EMIF_SDRAM_TYPE_DDR2 0x2
1041 #define EMIF_SDRAM_TYPE_DDR3 0x3
1042 #define EMIF_SDRAM_TYPE_LPDDR2 0x4
1044 struct lpddr2_addressing {
1047 u8 row_sz[2]; /* One entry each for x32 and x16 */
1048 u8 col_sz[2]; /* One entry each for x32 and x16 */
1051 /* Structure for timings from the DDR datasheet */
1052 struct lpddr2_ac_timings {
1077 * Min tCK values for some of the parameters:
1078 * If the calculated clock cycles for the respective parameter is
1079 * less than the corresponding min tCK value, we need to set the min
1080 * tCK value. This may happen at lower frequencies.
1082 struct lpddr2_min_tck {
1097 struct lpddr2_device_details {
1104 struct lpddr2_device_timings {
1105 const struct lpddr2_ac_timings **ac_timings;
1106 const struct lpddr2_min_tck *min_tck;
1109 /* Details of the devices connected to each chip-select of an EMIF instance */
1110 struct emif_device_details {
1111 const struct lpddr2_device_details *cs0_device_details;
1112 const struct lpddr2_device_details *cs1_device_details;
1113 const struct lpddr2_device_timings *cs0_device_timings;
1114 const struct lpddr2_device_timings *cs1_device_timings;
1118 * Structure containing shadow of important registers in EMIF
1119 * The calculation function fills in this structure to be later used for
1120 * initialization and DVFS
1124 u32 sdram_config_init;
1133 u32 temp_alert_config;
1134 u32 emif_ddr_phy_ctlr_1_init;
1135 u32 emif_ddr_phy_ctlr_1;
1136 u32 emif_ddr_ext_phy_ctrl_1;
1137 u32 emif_ddr_ext_phy_ctrl_2;
1138 u32 emif_ddr_ext_phy_ctrl_3;
1139 u32 emif_ddr_ext_phy_ctrl_4;
1140 u32 emif_ddr_ext_phy_ctrl_5;
1141 u32 emif_rd_wr_lvl_rmp_win;
1142 u32 emif_rd_wr_lvl_rmp_ctl;
1143 u32 emif_rd_wr_lvl_ctl;
1144 u32 emif_rd_wr_exec_thresh;
1145 u32 emif_prio_class_serv_map;
1146 u32 emif_connect_id_serv_1_map;
1147 u32 emif_connect_id_serv_2_map;
1148 u32 emif_cos_config;
1151 struct lpddr2_mr_regs {
1159 struct read_write_regs {
1164 static inline u32 get_emif_rev(u32 base)
1166 struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
1168 return (readl(&emif->emif_mod_id_rev) & EMIF_REG_MAJOR_REVISION_MASK)
1169 >> EMIF_REG_MAJOR_REVISION_SHIFT;
1173 * Get SDRAM type connected to EMIF.
1174 * Assuming similar SDRAM parts are connected to both EMIF's
1175 * which is typically the case. So it is sufficient to get
1176 * SDRAM type from EMIF1.
1178 static inline u32 emif_sdram_type(void)
1180 struct emif_reg_struct *emif = (struct emif_reg_struct *)EMIF1_BASE;
1182 return (readl(&emif->emif_sdram_config) &
1183 EMIF_REG_SDRAM_TYPE_MASK) >> EMIF_REG_SDRAM_TYPE_SHIFT;
1188 #define emif_assert(c) ({ if (!(c)) for (;;); })
1190 #define emif_assert(c) ({ if (0) hang(); })
1193 #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
1194 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs);
1195 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs);
1197 struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
1198 struct lpddr2_device_details *lpddr2_dev_details);
1199 void emif_get_device_timings(u32 emif_nr,
1200 const struct lpddr2_device_timings **cs0_device_timings,
1201 const struct lpddr2_device_timings **cs1_device_timings);
1204 void do_ext_phy_settings(u32 base, const struct emif_regs *regs);
1205 void get_lpddr2_mr_regs(const struct lpddr2_mr_regs **regs);
1207 #ifndef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
1208 extern u32 *const T_num;
1209 extern u32 *const T_den;
1212 void config_data_eye_leveling_samples(u32 emif_base);
1213 u32 emif_sdram_type(void);
1214 const struct read_write_regs *get_bug_regs(u32 *iterations);