blob: 0740f49be5bbcd124d18cd1dfc727cf029024924 [file] [log] [blame]
Yanhong Wangd60e8802023-03-29 11:42:16 +08001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2022 StarFive Technology Co., Ltd.
4 * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
5 */
6
7#include <common.h>
8#include <asm/io.h>
9
10static const u32 ddr_train_data[] = {
11 0xb00,
12 0x101,
13 0x640000,
14 0x1,
15 0x0,
16 0x0,
17 0x0,
18 0x0,
19 0x1,
20 0x7,
21 0x10002,
22 0x300080f,
23 0x1,
24 0x5,
25 0x0,
26 0x0,
27 0x0,
28 0x0,
29 0x0,
30 0x0,
31 0x0,
32 0x0,
33 0x0,
34 0x1010000,
35 0x280a0000,
36 0x0,
37 0x1,
38 0x3200000f,
39 0x0,
40 0x0,
41 0x10102,
42 0x1,
43 0x0,
44 0x0,
45 0x0,
46 0xaa,
47 0x55,
48 0xb5,
49 0x4a,
50 0x56,
51 0xa9,
52 0xa9,
53 0xb5,
54 0x1000000,
55 0x1000000,
56 0x0,
57 0xf0f0000,
58 0x14,
59 0x7d0,
60 0x300,
61 0x0,
62 0x0,
63 0x1000000,
64 0x10101,
65 0x0,
66 0x30000,
67 0x100,
68 0x170f,
69 0x0,
70 0x0,
71 0x0,
72 0xa140a01,
73 0x204010a,
74 0x2080510,
75 0x40400,
76 0x1000101,
77 0x10100,
78 0x2040f00,
79 0x34000000,
80 0x0,
81 0x0,
82 0x1000000,
83 0x0,
84 0x0,
85 0x0,
86 0x0,
87 0x10100,
88 0x80101,
89 0x2000200,
90 0x1000100,
91 0x1000000,
92 0x2000200,
93 0x200,
94 0x0,
95 0x0,
96 0x0,
97 0xe000004,
98 0xc0d100f,
99 0xa09080b,
100 0x2010000,
101 0x80103,
102 0x200,
103 0x0,
104 0xf000000,
105 0x4,
106 0xa,
107 0x0,
108 0x0,
109 0x0,
110 0x0,
111 0x0,
112 0x0,
113 0x0,
114 0x30100,
115 0x1010001,
116 0x10200,
117 0x4000103,
118 0x1050001,
119 0x10600,
120 0x107,
121 0x0,
122 0x0,
123 0x10001,
124 0x0,
125 0x0,
126 0x0,
127 0x0,
128 0x10000,
129 0x4,
130 0x0,
131 0x10000,
132 0x0,
133 0x3c0003,
134 0x80100a0,
135 0x16,
136 0x2c,
137 0x33,
138 0x20043,
139 0x2000200,
140 0x4,
141 0x60c,
142 0xa1400,
143 0x280000,
144 0x6,
145 0x46,
146 0x70,
147 0x610,
148 0x12b,
149 0x4001035,
150 0x1010404,
151 0x1e01,
152 0x1e001e,
153 0x1000100,
154 0x100,
155 0x0,
156 0x5060403,
157 0x1011108,
158 0x1010101,
159 0xf0a0a,
160 0x0,
161 0x0,
162 0x4000000,
163 0x4021008,
164 0x4020206,
165 0xc0034,
166 0x100038,
167 0x17003f,
168 0x10001,
169 0x10001,
170 0x10005,
171 0x20064,
172 0x100010b,
173 0x60006,
174 0x650100,
175 0x1000065,
176 0x10c010c,
177 0x1e1a1e1a,
178 0x1011e1a,
179 0xa070601,
180 0xa07060d,
181 0x100b080d,
182 0xc00f,
183 0xc01000,
184 0xc01000,
185 0x21000,
186 0x120005,
187 0x190064,
188 0x10b,
189 0x1100,
190 0x1e1a0056,
191 0x6000101,
192 0x130204,
193 0x1e1a0058,
194 0x1000101,
195 0x230408,
196 0x1e1a005e,
197 0x9000101,
198 0x610,
199 0x4040800,
200 0x40100,
201 0x3000277,
202 0xa032001,
203 0xa0a,
204 0x80908,
205 0x901,
206 0x1100315c,
207 0xa062002,
208 0xa0a,
209 0x141708,
210 0x150d,
211 0x2d00838e,
212 0xf102004,
213 0xf0b,
214 0x8c,
215 0x578,
216 0xc20,
217 0x7940,
218 0x206a,
219 0x14424,
220 0x730006,
221 0x3030133,
222 0x4,
223 0x0,
224 0x4,
225 0x1,
226 0x5,
227 0x2,
228 0x6,
229 0x50,
230 0x1,
231 0x5,
232 0x28,
233 0x73,
234 0xd6,
235 0x1,
236 0x5,
237 0x6b,
238 0x1000133,
239 0x140040,
240 0x10001,
241 0x1900040,
242 0x1000c,
243 0x42b0040,
244 0x320,
245 0x360014,
246 0x1010101,
247 0x2020101,
248 0x8080404,
249 0x67676767,
250 0x67676767,
251 0x67676767,
252 0x67676767,
253 0x0,
254 0x0,
255 0x0,
256 0x0,
257 0x0,
258 0x5500,
259 0x5a00,
260 0x55003c,
261 0x0,
262 0x3c00005a,
263 0x5500,
264 0x5a00,
265 0x55003c,
266 0x0,
267 0x3c00005a,
268 0x18171615,
269 0x14131211,
270 0x7060504,
271 0x3020100,
272 0x0,
273 0x0,
274 0x0,
275 0x1000000,
276 0x4020201,
277 0x80804,
278 0x0,
279 0x4,
280 0x0,
281 0x31,
282 0x31,
283 0x0,
284 0x0,
285 0x4d4d,
286 0x0,
287 0x14,
288 0x9,
289 0x31,
290 0x31,
291 0x0,
292 0x0,
293 0x4d4d,
294 0x0,
295 0x34,
296 0x1b,
297 0x31,
298 0x31,
299 0x0,
300 0x0,
301 0x4d4d,
302 0x0,
303 0x4,
304 0x0,
305 0x31,
306 0x31,
307 0x0,
308 0x0,
309 0x4d4d,
310 0x0,
311 0x14,
312 0x9,
313 0x31,
314 0x31,
315 0x0,
316 0x0,
317 0x4d4d,
318 0x0,
319 0x34,
320 0x1b,
321 0x31,
322 0x31,
323 0x0,
324 0x0,
325 0x4d4d,
326 0x0,
327 0x4,
328 0x0,
329 0x31,
330 0x31,
331 0x0,
332 0x0,
333 0x4d4d,
334 0x0,
335 0x14,
336 0x9,
337 0x31,
338 0x31,
339 0x0,
340 0x0,
341 0x4d4d,
342 0x0,
343 0x34,
344 0x1b,
345 0x31,
346 0x31,
347 0x0,
348 0x0,
349 0x4d4d,
350 0x0,
351 0x4,
352 0x0,
353 0x31,
354 0x31,
355 0x0,
356 0x0,
357 0x4d4d,
358 0x0,
359 0x14,
360 0x9,
361 0x31,
362 0x31,
363 0x0,
364 0x0,
365 0x4d4d,
366 0x0,
367 0x34,
368 0x1b,
369 0x31,
370 0x31,
371 0x0,
372 0x0,
373 0x4d4d,
374};
375
376void ddr_phy_train(u32 *phyreg)
377{
378 u32 i, len;
379
380 len = ARRAY_SIZE(ddr_train_data);
381 for (i = 0; i < len; i++)
382 out_le32(phyreg + i, ddr_train_data[i]);
383}