xref: /openbmc/u-boot/arch/arm/include/asm/arch-imx8m/ddr.h (revision 94df98859663265348a7a8de5a079d82e5dab131)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2017 NXP
4  */
5 
6 #ifndef __ASM_ARCH_IMX8M_DDR_H
7 #define __ASM_ARCH_IMX8M_DDR_H
8 
9 #define DDRC_DDR_SS_GPR0		0x3d000000
10 #define DDRC_IPS_BASE_ADDR_0		0x3f400000
11 #define IP2APB_DDRPHY_IPS_BASE_ADDR(X)	(0x3c000000 + (X * 0x2000000))
12 #define DDRPHY_MEM(X)			(0x3c000000 + (X * 0x2000000) + 0x50000)
13 
14 struct ddrc_freq {
15 	u32 res0[8];
16 	u32 derateen;
17 	u32 derateint;
18 	u32 res1[10];
19 	u32 rfshctl0;
20 	u32 res2[4];
21 	u32 rfshtmg;
22 	u32 rfshtmg1;
23 	u32 res3[28];
24 	u32 init3;
25 	u32 init4;
26 	u32 res;
27 	u32 init6;
28 	u32 init7;
29 	u32 res4[4];
30 	u32 dramtmg0;
31 	u32 dramtmg1;
32 	u32 dramtmg2;
33 	u32 dramtmg3;
34 	u32 dramtmg4;
35 	u32 dramtmg5;
36 	u32 dramtmg6;
37 	u32 dramtmg7;
38 	u32 dramtmg8;
39 	u32 dramtmg9;
40 	u32 dramtmg10;
41 	u32 dramtmg11;
42 	u32 dramtmg12;
43 	u32 dramtmg13;
44 	u32 dramtmg14;
45 	u32 dramtmg15;
46 	u32 dramtmg16;
47 	u32 dramtmg17;
48 	u32 res5[10];
49 	u32 mramtmg0;
50 	u32 mramtmg1;
51 	u32 mramtmg4;
52 	u32 mramtmg9;
53 	u32 zqctl0;
54 	u32 res6[3];
55 	u32 dfitmg0;
56 	u32 dfitmg1;
57 	u32 res7[7];
58 	u32 dfitmg2;
59 	u32 dfitmg3;
60 	u32 res8[33];
61 	u32 odtcfg;
62 };
63 
64 struct imx8m_ddrc_regs {
65 	u32 mstr;
66 	u32 stat;
67 	u32 mstr1;
68 	u32 res1;
69 	u32 mrctrl0;
70 	u32 mrctrl1;
71 	u32 mrstat;
72 	u32 mrctrl2;
73 	u32 derateen;
74 	u32 derateint;
75 	u32 mstr2;
76 	u32 res2;
77 	u32 pwrctl;
78 	u32 pwrtmg;
79 	u32 hwlpctl;
80 	u32 hwffcctl;
81 	u32 hwffcstat;
82 	u32 res3[3];
83 	u32 rfshctl0;
84 	u32 rfshctl1;
85 	u32 rfshctl2;
86 	u32 rfshctl4;
87 	u32 rfshctl3;
88 	u32 rfshtmg;
89 	u32 rfshtmg1;
90 	u32 res4;
91 	u32 ecccfg0;
92 	u32 ecccfg1;
93 	u32 eccstat;
94 	u32 eccclr;
95 	u32 eccerrcnt;
96 	u32 ecccaddr0;
97 	u32 ecccaddr1;
98 	u32 ecccsyn0;
99 	u32 ecccsyn1;
100 	u32 ecccsyn2;
101 	u32 eccbitmask0;
102 	u32 eccbitmask1;
103 	u32 eccbitmask2;
104 	u32 eccuaddr0;
105 	u32 eccuaddr1;
106 	u32 eccusyn0;
107 	u32 eccusyn1;
108 	u32 eccusyn2;
109 	u32 eccpoisonaddr0;
110 	u32 eccpoisonaddr1;
111 	u32 crcparctl0;
112 	u32 crcparctl1;
113 	u32 crcparctl2;
114 	u32 crcparstat;
115 	u32 init0;
116 	u32 init1;
117 	u32 init2;
118 	u32 init3;
119 	u32 init4;
120 	u32 init5;
121 	u32 init6;
122 	u32 init7;
123 	u32 dimmctl;
124 	u32 rankctl;
125 	u32 res5;
126 	u32 chctl;
127 	u32 dramtmg0;
128 	u32 dramtmg1;
129 	u32 dramtmg2;
130 	u32 dramtmg3;
131 	u32 dramtmg4;
132 	u32 dramtmg5;
133 	u32 dramtmg6;
134 	u32 dramtmg7;
135 	u32 dramtmg8;
136 	u32 dramtmg9;
137 	u32 dramtmg10;
138 	u32 dramtmg11;
139 	u32 dramtmg12;
140 	u32 dramtmg13;
141 	u32 dramtmg14;
142 	u32 dramtmg15;
143 	u32 dramtmg16;
144 	u32 dramtmg17;
145 	u32 res6[10];
146 	u32 mramtmg0;
147 	u32 mramtmg1;
148 	u32 mramtmg4;
149 	u32 mramtmg9;
150 	u32 zqctl0;
151 	u32 zqctl1;
152 	u32 zqctl2;
153 	u32 zqstat;
154 	u32 dfitmg0;
155 	u32 dfitmg1;
156 	u32 dfilpcfg0;
157 	u32 dfilpcfg1;
158 	u32 dfiupd0;
159 	u32 dfiupd1;
160 	u32 dfiupd2;
161 	u32 res7;
162 	u32 dfimisc;
163 	u32 dfitmg2;
164 	u32 dfitmg3;
165 	u32 dfistat;
166 	u32 dbictl;
167 	u32 dfiphymstr;
168 	u32 res8[14];
169 	u32 addrmap0;
170 	u32 addrmap1;
171 	u32 addrmap2;
172 	u32 addrmap3;
173 	u32 addrmap4;
174 	u32 addrmap5;
175 	u32 addrmap6;
176 	u32 addrmap7;
177 	u32 addrmap8;
178 	u32 addrmap9;
179 	u32 addrmap10;
180 	u32 addrmap11;
181 	u32 res9[4];
182 	u32 odtcfg;
183 	u32 odtmap;
184 	u32 res10[2];
185 	u32 sched;
186 	u32 sched1;
187 	u32 sched2;
188 	u32 perfhpr1;
189 	u32 res11;
190 	u32 perflpr1;
191 	u32 res12;
192 	u32 perfwr1;
193 	u32 res13[4];
194 	u32 dqmap0;
195 	u32 dqmap1;
196 	u32 dqmap2;
197 	u32 dqmap3;
198 	u32 dqmap4;
199 	u32 dqmap5;
200 	u32 res14[26];
201 	u32 dbg0;
202 	u32 dbg1;
203 	u32 dbgcam;
204 	u32 dbgcmd;
205 	u32 dbgstat;
206 	u32 res15[3];
207 	u32 swctl;
208 	u32 swstat;
209 	u32 res16[2];
210 	u32 ocparcfg0;
211 	u32 ocparcfg1;
212 	u32 ocparcfg2;
213 	u32 ocparcfg3;
214 	u32 ocparstat0;
215 	u32 ocparstat1;
216 	u32 ocparwlog0;
217 	u32 ocparwlog1;
218 	u32 ocparwlog2;
219 	u32 ocparawlog0;
220 	u32 ocparawlog1;
221 	u32 ocparrlog0;
222 	u32 ocparrlog1;
223 	u32 ocpararlog0;
224 	u32 ocpararlog1;
225 	u32 poisoncfg;
226 	u32 poisonstat;
227 	u32 adveccindex;
228 	union  {
229 		u32 adveccstat;
230 		u32 eccapstat;
231 	};
232 	u32 eccpoisonpat0;
233 	u32 eccpoisonpat1;
234 	u32 eccpoisonpat2;
235 	u32 res17[6];
236 	u32 caparpoisonctl;
237 	u32 caparpoisonstat;
238 	u32 res18[2];
239 	u32 dynbsmstat;
240 	u32 res19[18];
241 	u32 pstat;
242 	u32 pccfg;
243 	struct {
244 		u32 pcfgr;
245 		u32 pcfgw;
246 		u32 pcfgc;
247 		struct {
248 			u32 pcfgidmaskch0;
249 			u32 pcfidvaluech0;
250 		} pcfgid[16];
251 		u32 pctrl;
252 		u32 pcfgqos0;
253 		u32 pcfgqos1;
254 		u32 pcfgwqos0;
255 		u32 pcfgwqos1;
256 		u32 res[4];
257 	} pcfg[16];
258 	struct {
259 		u32 sarbase;
260 		u32 sarsize;
261 	} sar[4];
262 	u32 sbrctl;
263 	u32 sbrstat;
264 	u32 sbrwdata0;
265 	u32 sbrwdata1;
266 	u32 pdch;
267 	u32 res20[755];
268 	/* umctl2_regs_dch1 */
269 	u32 ch1_stat;
270 	u32 res21[2];
271 	u32 ch1_mrctrl0;
272 	u32 ch1_mrctrl1;
273 	u32 ch1_mrstat;
274 	u32 ch1_mrctrl2;
275 	u32 res22[4];
276 	u32 ch1_pwrctl;
277 	u32 ch1_pwrtmg;
278 	u32 ch1_hwlpctl;
279 	u32 res23[15];
280 	u32 ch1_eccstat;
281 	u32 ch1_eccclr;
282 	u32 ch1_eccerrcnt;
283 	u32 ch1_ecccaddr0;
284 	u32 ch1_ecccaddr1;
285 	u32 ch1_ecccsyn0;
286 	u32 ch1_ecccsyn1;
287 	u32 ch1_ecccsyn2;
288 	u32 ch1_eccbitmask0;
289 	u32 ch1_eccbitmask1;
290 	u32 ch1_eccbitmask2;
291 	u32 ch1_eccuaddr0;
292 	u32 ch1_eccuaddr1;
293 	u32 ch1_eccusyn0;
294 	u32 ch1_eccusyn1;
295 	u32 ch1_eccusyn2;
296 	u32 res24[2];
297 	u32 ch1_crcparctl0;
298 	u32 res25[2];
299 	u32 ch1_crcparstat;
300 	u32 res26[46];
301 	u32 ch1_zqctl2;
302 	u32 ch1_zqstat;
303 	u32 res27[11];
304 	u32 ch1_dfistat;
305 	u32 res28[33];
306 	u32 ch1_odtmap;
307 	u32 res29[47];
308 	u32 ch1_dbg1;
309 	u32 ch1_dbgcam;
310 	u32 ch1_dbgcmd;
311 	u32 ch1_dbgstat;
312 	u32 res30[123];
313 	/* umctl2_regs_freq1 */
314 	struct ddrc_freq freq1;
315 	u32 res31[109];
316 	/* umctl2_regs_addrmap_alt */
317 	u32 addrmap0_alt;
318 	u32 addrmap1_alt;
319 	u32 addrmap2_alt;
320 	u32 addrmap3_alt;
321 	u32 addrmap4_alt;
322 	u32 addrmap5_alt;
323 	u32 addrmap6_alt;
324 	u32 addrmap7_alt;
325 	u32 addrmap8_alt;
326 	u32 addrmap9_alt;
327 	u32 addrmap10_alt;
328 	u32 addrmap11_alt;
329 	u32 res32[758];
330 	/* umctl2_regs_freq2 */
331 	struct ddrc_freq freq2;
332 	u32 res33[879];
333 	/* umctl2_regs_freq3 */
334 	struct ddrc_freq freq3;
335 };
336 
337 struct imx8m_ddrphy_regs {
338 	u32 reg[0xf0000];
339 };
340 
341 /* PHY State */
342 enum pstate {
343 	PS0,
344 	PS1,
345 	PS2,
346 	PS3,
347 };
348 
349 enum msg_response {
350 	TRAIN_SUCCESS = 0x7,
351 	TRAIN_STREAM_START = 0x8,
352 	TRAIN_FAIL = 0xff,
353 };
354 
355 #endif
356