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