blob: f98ad8af82e0f8854299be77a911b91515e71856 [file] [log] [blame]
Michal Simek0766ef82021-02-17 09:40:38 +01001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * (c) Copyright 2015 Xilinx, Inc. All rights reserved.
4 */
5
6#include <asm/arch/psu_init_gpl.h>
7#include <xil_io.h>
8
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02009static int serdes_rst_seq(u32 lane3_protocol, u32 lane3_rate,
10 u32 lane2_protocol, u32 lane2_rate,
11 u32 lane1_protocol, u32 lane1_rate,
12 u32 lane0_protocol, u32 lane0_rate)
Michal Simek0766ef82021-02-17 09:40:38 +010013{
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +020014 Xil_Out32(0xFD410098, 0x00000000);
15 Xil_Out32(0xFD401010, 0x00000040);
16 Xil_Out32(0xFD405010, 0x00000040);
17 Xil_Out32(0xFD409010, 0x00000040);
18 Xil_Out32(0xFD40D010, 0x00000040);
19 Xil_Out32(0xFD402084, 0x00000080);
20 Xil_Out32(0xFD406084, 0x00000080);
21 Xil_Out32(0xFD40A084, 0x00000080);
22 Xil_Out32(0xFD40E084, 0x00000080);
23 Xil_Out32(0xFD410098, 0x00000004);
24 mask_delay(50);
25 if (lane0_rate == 1)
26 Xil_Out32(0xFD410098, 0x0000000E);
27 Xil_Out32(0xFD410098, 0x00000006);
28 if (lane0_rate == 1) {
29 Xil_Out32(0xFD40000C, 0x00000004);
30 Xil_Out32(0xFD40400C, 0x00000004);
31 Xil_Out32(0xFD40800C, 0x00000004);
32 Xil_Out32(0xFD40C00C, 0x00000004);
33 Xil_Out32(0xFD410098, 0x00000007);
34 mask_delay(400);
35 Xil_Out32(0xFD40000C, 0x0000000C);
36 Xil_Out32(0xFD40400C, 0x0000000C);
37 Xil_Out32(0xFD40800C, 0x0000000C);
38 Xil_Out32(0xFD40C00C, 0x0000000C);
39 mask_delay(15);
40 Xil_Out32(0xFD410098, 0x0000000F);
41 mask_delay(100);
42 }
43 if (lane0_protocol != 0)
44 mask_poll(0xFD4023E4, 0x00000010U);
45 if (lane1_protocol != 0)
46 mask_poll(0xFD4063E4, 0x00000010U);
47 if (lane2_protocol != 0)
48 mask_poll(0xFD40A3E4, 0x00000010U);
49 if (lane3_protocol != 0)
50 mask_poll(0xFD40E3E4, 0x00000010U);
51 mask_delay(50);
52 Xil_Out32(0xFD401010, 0x000000C0);
53 Xil_Out32(0xFD405010, 0x000000C0);
54 Xil_Out32(0xFD409010, 0x000000C0);
55 Xil_Out32(0xFD40D010, 0x000000C0);
56 Xil_Out32(0xFD401010, 0x00000080);
57 Xil_Out32(0xFD405010, 0x00000080);
58 Xil_Out32(0xFD409010, 0x00000080);
59 Xil_Out32(0xFD40D010, 0x00000080);
Michal Simek0766ef82021-02-17 09:40:38 +010060
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +020061 Xil_Out32(0xFD402084, 0x000000C0);
62 Xil_Out32(0xFD406084, 0x000000C0);
63 Xil_Out32(0xFD40A084, 0x000000C0);
64 Xil_Out32(0xFD40E084, 0x000000C0);
65 mask_delay(50);
66 Xil_Out32(0xFD402084, 0x00000080);
67 Xil_Out32(0xFD406084, 0x00000080);
68 Xil_Out32(0xFD40A084, 0x00000080);
69 Xil_Out32(0xFD40E084, 0x00000080);
70 mask_delay(50);
71 Xil_Out32(0xFD401010, 0x00000000);
72 Xil_Out32(0xFD405010, 0x00000000);
73 Xil_Out32(0xFD409010, 0x00000000);
74 Xil_Out32(0xFD40D010, 0x00000000);
75 Xil_Out32(0xFD402084, 0x00000000);
76 Xil_Out32(0xFD406084, 0x00000000);
77 Xil_Out32(0xFD40A084, 0x00000000);
78 Xil_Out32(0xFD40E084, 0x00000000);
79 mask_delay(500);
Michal Simek0766ef82021-02-17 09:40:38 +010080 return 1;
81}
82
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +020083static int serdes_bist_static_settings(u32 lane_active)
Michal Simek0766ef82021-02-17 09:40:38 +010084{
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +020085 if (lane_active == 0) {
86 Xil_Out32(0xFD403004, (Xil_In32(0xFD403004) & 0xFFFFFF1F));
87 Xil_Out32(0xFD403068, 0x1);
88 Xil_Out32(0xFD40306C, 0x1);
89 Xil_Out32(0xFD4010AC, 0x0020);
90 Xil_Out32(0xFD403008, 0x0);
91 Xil_Out32(0xFD40300C, 0xF4);
92 Xil_Out32(0xFD403010, 0x0);
93 Xil_Out32(0xFD403014, 0x0);
94 Xil_Out32(0xFD403018, 0x00);
95 Xil_Out32(0xFD40301C, 0xFB);
96 Xil_Out32(0xFD403020, 0xFF);
97 Xil_Out32(0xFD403024, 0x0);
98 Xil_Out32(0xFD403028, 0x00);
99 Xil_Out32(0xFD40302C, 0x00);
100 Xil_Out32(0xFD403030, 0x4A);
101 Xil_Out32(0xFD403034, 0x4A);
102 Xil_Out32(0xFD403038, 0x4A);
103 Xil_Out32(0xFD40303C, 0x4A);
104 Xil_Out32(0xFD403040, 0x0);
105 Xil_Out32(0xFD403044, 0x14);
106 Xil_Out32(0xFD403048, 0x02);
107 Xil_Out32(0xFD403004, (Xil_In32(0xFD403004) & 0xFFFFFF1F));
108 }
109 if (lane_active == 1) {
110 Xil_Out32(0xFD407004, (Xil_In32(0xFD407004) & 0xFFFFFF1F));
111 Xil_Out32(0xFD407068, 0x1);
112 Xil_Out32(0xFD40706C, 0x1);
113 Xil_Out32(0xFD4050AC, 0x0020);
114 Xil_Out32(0xFD407008, 0x0);
115 Xil_Out32(0xFD40700C, 0xF4);
116 Xil_Out32(0xFD407010, 0x0);
117 Xil_Out32(0xFD407014, 0x0);
118 Xil_Out32(0xFD407018, 0x00);
119 Xil_Out32(0xFD40701C, 0xFB);
120 Xil_Out32(0xFD407020, 0xFF);
121 Xil_Out32(0xFD407024, 0x0);
122 Xil_Out32(0xFD407028, 0x00);
123 Xil_Out32(0xFD40702C, 0x00);
124 Xil_Out32(0xFD407030, 0x4A);
125 Xil_Out32(0xFD407034, 0x4A);
126 Xil_Out32(0xFD407038, 0x4A);
127 Xil_Out32(0xFD40703C, 0x4A);
128 Xil_Out32(0xFD407040, 0x0);
129 Xil_Out32(0xFD407044, 0x14);
130 Xil_Out32(0xFD407048, 0x02);
131 Xil_Out32(0xFD407004, (Xil_In32(0xFD407004) & 0xFFFFFF1F));
132 }
133
134 if (lane_active == 2) {
135 Xil_Out32(0xFD40B004, (Xil_In32(0xFD40B004) & 0xFFFFFF1F));
136 Xil_Out32(0xFD40B068, 0x1);
137 Xil_Out32(0xFD40B06C, 0x1);
138 Xil_Out32(0xFD4090AC, 0x0020);
139 Xil_Out32(0xFD40B008, 0x0);
140 Xil_Out32(0xFD40B00C, 0xF4);
141 Xil_Out32(0xFD40B010, 0x0);
142 Xil_Out32(0xFD40B014, 0x0);
143 Xil_Out32(0xFD40B018, 0x00);
144 Xil_Out32(0xFD40B01C, 0xFB);
145 Xil_Out32(0xFD40B020, 0xFF);
146 Xil_Out32(0xFD40B024, 0x0);
147 Xil_Out32(0xFD40B028, 0x00);
148 Xil_Out32(0xFD40B02C, 0x00);
149 Xil_Out32(0xFD40B030, 0x4A);
150 Xil_Out32(0xFD40B034, 0x4A);
151 Xil_Out32(0xFD40B038, 0x4A);
152 Xil_Out32(0xFD40B03C, 0x4A);
153 Xil_Out32(0xFD40B040, 0x0);
154 Xil_Out32(0xFD40B044, 0x14);
155 Xil_Out32(0xFD40B048, 0x02);
156 Xil_Out32(0xFD40B004, (Xil_In32(0xFD40B004) & 0xFFFFFF1F));
157 }
Michal Simek0766ef82021-02-17 09:40:38 +0100158
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200159 if (lane_active == 3) {
160 Xil_Out32(0xFD40F004, (Xil_In32(0xFD40F004) & 0xFFFFFF1F));
161 Xil_Out32(0xFD40F068, 0x1);
162 Xil_Out32(0xFD40F06C, 0x1);
163 Xil_Out32(0xFD40D0AC, 0x0020);
164 Xil_Out32(0xFD40F008, 0x0);
165 Xil_Out32(0xFD40F00C, 0xF4);
166 Xil_Out32(0xFD40F010, 0x0);
167 Xil_Out32(0xFD40F014, 0x0);
168 Xil_Out32(0xFD40F018, 0x00);
169 Xil_Out32(0xFD40F01C, 0xFB);
170 Xil_Out32(0xFD40F020, 0xFF);
171 Xil_Out32(0xFD40F024, 0x0);
172 Xil_Out32(0xFD40F028, 0x00);
173 Xil_Out32(0xFD40F02C, 0x00);
174 Xil_Out32(0xFD40F030, 0x4A);
175 Xil_Out32(0xFD40F034, 0x4A);
176 Xil_Out32(0xFD40F038, 0x4A);
177 Xil_Out32(0xFD40F03C, 0x4A);
178 Xil_Out32(0xFD40F040, 0x0);
179 Xil_Out32(0xFD40F044, 0x14);
180 Xil_Out32(0xFD40F048, 0x02);
181 Xil_Out32(0xFD40F004, (Xil_In32(0xFD40F004) & 0xFFFFFF1F));
182 }
Michal Simek0766ef82021-02-17 09:40:38 +0100183 return 1;
184}
185
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200186static int serdes_bist_run(u32 lane_active)
Michal Simek0766ef82021-02-17 09:40:38 +0100187{
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200188 if (lane_active == 0) {
189 psu_mask_write(0xFD410044, 0x00000003U, 0x00000000U);
190 psu_mask_write(0xFD410040, 0x00000003U, 0x00000000U);
191 psu_mask_write(0xFD410038, 0x00000007U, 0x00000001U);
192 Xil_Out32(0xFD4010AC, 0x0020);
193 Xil_Out32(0xFD403004, (Xil_In32(0xFD403004) | 0x1));
Michal Simek0766ef82021-02-17 09:40:38 +0100194 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200195 if (lane_active == 1) {
196 psu_mask_write(0xFD410044, 0x0000000CU, 0x00000000U);
197 psu_mask_write(0xFD410040, 0x0000000CU, 0x00000000U);
198 psu_mask_write(0xFD410038, 0x00000070U, 0x00000010U);
199 Xil_Out32(0xFD4050AC, 0x0020);
200 Xil_Out32(0xFD407004, (Xil_In32(0xFD407004) | 0x1));
201 }
202 if (lane_active == 2) {
203 psu_mask_write(0xFD410044, 0x00000030U, 0x00000000U);
204 psu_mask_write(0xFD410040, 0x00000030U, 0x00000000U);
205 psu_mask_write(0xFD41003C, 0x00000007U, 0x00000001U);
206 Xil_Out32(0xFD4090AC, 0x0020);
207 Xil_Out32(0xFD40B004, (Xil_In32(0xFD40B004) | 0x1));
208 }
209 if (lane_active == 3) {
210 psu_mask_write(0xFD410040, 0x000000C0U, 0x00000000U);
211 psu_mask_write(0xFD410044, 0x000000C0U, 0x00000000U);
212 psu_mask_write(0xFD41003C, 0x00000070U, 0x00000010U);
213 Xil_Out32(0xFD40D0AC, 0x0020);
214 Xil_Out32(0xFD40F004, (Xil_In32(0xFD40F004) | 0x1));
215 }
216 mask_delay(100);
217 return 1;
218}
Michal Simek0766ef82021-02-17 09:40:38 +0100219
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200220static int serdes_bist_result(u32 lane_active)
221{
222 u32 pkt_cnt_l0, pkt_cnt_h0, err_cnt_l0, err_cnt_h0;
Michal Simek0766ef82021-02-17 09:40:38 +0100223
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200224 if (lane_active == 0) {
225 pkt_cnt_l0 = Xil_In32(0xFD40304C);
226 pkt_cnt_h0 = Xil_In32(0xFD403050);
227 err_cnt_l0 = Xil_In32(0xFD403054);
228 err_cnt_h0 = Xil_In32(0xFD403058);
229 }
230 if (lane_active == 1) {
231 pkt_cnt_l0 = Xil_In32(0xFD40704C);
232 pkt_cnt_h0 = Xil_In32(0xFD407050);
233 err_cnt_l0 = Xil_In32(0xFD407054);
234 err_cnt_h0 = Xil_In32(0xFD407058);
235 }
236 if (lane_active == 2) {
237 pkt_cnt_l0 = Xil_In32(0xFD40B04C);
238 pkt_cnt_h0 = Xil_In32(0xFD40B050);
239 err_cnt_l0 = Xil_In32(0xFD40B054);
240 err_cnt_h0 = Xil_In32(0xFD40B058);
241 }
242 if (lane_active == 3) {
243 pkt_cnt_l0 = Xil_In32(0xFD40F04C);
244 pkt_cnt_h0 = Xil_In32(0xFD40F050);
245 err_cnt_l0 = Xil_In32(0xFD40F054);
246 err_cnt_h0 = Xil_In32(0xFD40F058);
247 }
248 if (lane_active == 0)
249 Xil_Out32(0xFD403004, 0x0);
250 if (lane_active == 1)
251 Xil_Out32(0xFD407004, 0x0);
252 if (lane_active == 2)
253 Xil_Out32(0xFD40B004, 0x0);
254 if (lane_active == 3)
255 Xil_Out32(0xFD40F004, 0x0);
256 if (err_cnt_l0 > 0 || err_cnt_h0 > 0 ||
257 (pkt_cnt_l0 == 0 && pkt_cnt_h0 == 0))
258 return 0;
Michal Simek0766ef82021-02-17 09:40:38 +0100259 return 1;
260}
261
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200262static int serdes_illcalib_pcie_gen1(u32 lane3_protocol, u32 lane3_rate,
263 u32 lane2_protocol, u32 lane2_rate,
264 u32 lane1_protocol, u32 lane1_rate,
265 u32 lane0_protocol, u32 lane0_rate,
266 u32 gen2_calib)
Michal Simek0766ef82021-02-17 09:40:38 +0100267{
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200268 u64 tempbistresult;
269 u32 currbistresult[4];
270 u32 prevbistresult[4];
271 u32 itercount = 0;
272 u32 ill12_val[4], ill1_val[4];
273 u32 loop = 0;
274 u32 iterresult[8];
275 u32 meancount[4];
276 u32 bistpasscount[4];
277 u32 meancountalt[4];
278 u32 meancountalt_bistpasscount[4];
279 u32 lane0_active;
280 u32 lane1_active;
281 u32 lane2_active;
282 u32 lane3_active;
283
284 lane0_active = (lane0_protocol == 1);
285 lane1_active = (lane1_protocol == 1);
286 lane2_active = (lane2_protocol == 1);
287 lane3_active = (lane3_protocol == 1);
288 for (loop = 0; loop <= 3; loop++) {
289 iterresult[loop] = 0;
290 iterresult[loop + 4] = 0;
291 meancountalt[loop] = 0;
292 meancountalt_bistpasscount[loop] = 0;
293 meancount[loop] = 0;
294 prevbistresult[loop] = 0;
295 bistpasscount[loop] = 0;
Michal Simek0766ef82021-02-17 09:40:38 +0100296 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200297 itercount = 0;
298 if (lane0_active)
299 serdes_bist_static_settings(0);
300 if (lane1_active)
301 serdes_bist_static_settings(1);
302 if (lane2_active)
303 serdes_bist_static_settings(2);
304 if (lane3_active)
305 serdes_bist_static_settings(3);
306 do {
307 if (gen2_calib != 1) {
308 if (lane0_active == 1)
309 ill1_val[0] = ((0x04 + itercount * 8) % 0x100);
310 if (lane0_active == 1)
311 ill12_val[0] =
312 ((0x04 + itercount * 8) >=
313 0x100) ? 0x10 : 0x00;
314 if (lane1_active == 1)
315 ill1_val[1] = ((0x04 + itercount * 8) % 0x100);
316 if (lane1_active == 1)
317 ill12_val[1] =
318 ((0x04 + itercount * 8) >=
319 0x100) ? 0x10 : 0x00;
320 if (lane2_active == 1)
321 ill1_val[2] = ((0x04 + itercount * 8) % 0x100);
322 if (lane2_active == 1)
323 ill12_val[2] =
324 ((0x04 + itercount * 8) >=
325 0x100) ? 0x10 : 0x00;
326 if (lane3_active == 1)
327 ill1_val[3] = ((0x04 + itercount * 8) % 0x100);
328 if (lane3_active == 1)
329 ill12_val[3] =
330 ((0x04 + itercount * 8) >=
331 0x100) ? 0x10 : 0x00;
332
333 if (lane0_active == 1)
334 Xil_Out32(0xFD401924, ill1_val[0]);
335 if (lane0_active == 1)
336 psu_mask_write(0xFD401990, 0x000000F0U,
337 ill12_val[0]);
338 if (lane1_active == 1)
339 Xil_Out32(0xFD405924, ill1_val[1]);
340 if (lane1_active == 1)
341 psu_mask_write(0xFD405990, 0x000000F0U,
342 ill12_val[1]);
343 if (lane2_active == 1)
344 Xil_Out32(0xFD409924, ill1_val[2]);
345 if (lane2_active == 1)
346 psu_mask_write(0xFD409990, 0x000000F0U,
347 ill12_val[2]);
348 if (lane3_active == 1)
349 Xil_Out32(0xFD40D924, ill1_val[3]);
350 if (lane3_active == 1)
351 psu_mask_write(0xFD40D990, 0x000000F0U,
352 ill12_val[3]);
353 }
354 if (gen2_calib == 1) {
355 if (lane0_active == 1)
356 ill1_val[0] = ((0x104 + itercount * 8) % 0x100);
357 if (lane0_active == 1)
358 ill12_val[0] =
359 ((0x104 + itercount * 8) >=
360 0x200) ? 0x02 : 0x01;
361 if (lane1_active == 1)
362 ill1_val[1] = ((0x104 + itercount * 8) % 0x100);
363 if (lane1_active == 1)
364 ill12_val[1] =
365 ((0x104 + itercount * 8) >=
366 0x200) ? 0x02 : 0x01;
367 if (lane2_active == 1)
368 ill1_val[2] = ((0x104 + itercount * 8) % 0x100);
369 if (lane2_active == 1)
370 ill12_val[2] =
371 ((0x104 + itercount * 8) >=
372 0x200) ? 0x02 : 0x01;
373 if (lane3_active == 1)
374 ill1_val[3] = ((0x104 + itercount * 8) % 0x100);
375 if (lane3_active == 1)
376 ill12_val[3] =
377 ((0x104 + itercount * 8) >=
378 0x200) ? 0x02 : 0x01;
379
380 if (lane0_active == 1)
381 Xil_Out32(0xFD401928, ill1_val[0]);
382 if (lane0_active == 1)
383 psu_mask_write(0xFD401990, 0x0000000FU,
384 ill12_val[0]);
385 if (lane1_active == 1)
386 Xil_Out32(0xFD405928, ill1_val[1]);
387 if (lane1_active == 1)
388 psu_mask_write(0xFD405990, 0x0000000FU,
389 ill12_val[1]);
390 if (lane2_active == 1)
391 Xil_Out32(0xFD409928, ill1_val[2]);
392 if (lane2_active == 1)
393 psu_mask_write(0xFD409990, 0x0000000FU,
394 ill12_val[2]);
395 if (lane3_active == 1)
396 Xil_Out32(0xFD40D928, ill1_val[3]);
397 if (lane3_active == 1)
398 psu_mask_write(0xFD40D990, 0x0000000FU,
399 ill12_val[3]);
400 }
401
402 if (lane0_active == 1)
403 psu_mask_write(0xFD401018, 0x00000030U, 0x00000010U);
404 if (lane1_active == 1)
405 psu_mask_write(0xFD405018, 0x00000030U, 0x00000010U);
406 if (lane2_active == 1)
407 psu_mask_write(0xFD409018, 0x00000030U, 0x00000010U);
408 if (lane3_active == 1)
409 psu_mask_write(0xFD40D018, 0x00000030U, 0x00000010U);
410 if (lane0_active == 1)
411 currbistresult[0] = 0;
412 if (lane1_active == 1)
413 currbistresult[1] = 0;
414 if (lane2_active == 1)
415 currbistresult[2] = 0;
416 if (lane3_active == 1)
417 currbistresult[3] = 0;
418 serdes_rst_seq(lane3_protocol, lane3_rate, lane2_protocol,
419 lane2_rate, lane1_protocol, lane1_rate,
420 lane0_protocol, lane0_rate);
421 if (lane3_active == 1)
422 serdes_bist_run(3);
423 if (lane2_active == 1)
424 serdes_bist_run(2);
425 if (lane1_active == 1)
426 serdes_bist_run(1);
427 if (lane0_active == 1)
428 serdes_bist_run(0);
429 tempbistresult = 0;
430 if (lane3_active == 1)
431 tempbistresult = tempbistresult | serdes_bist_result(3);
432 tempbistresult = tempbistresult << 1;
433 if (lane2_active == 1)
434 tempbistresult = tempbistresult | serdes_bist_result(2);
435 tempbistresult = tempbistresult << 1;
436 if (lane1_active == 1)
437 tempbistresult = tempbistresult | serdes_bist_result(1);
438 tempbistresult = tempbistresult << 1;
439 if (lane0_active == 1)
440 tempbistresult = tempbistresult | serdes_bist_result(0);
441 Xil_Out32(0xFD410098, 0x0);
442 Xil_Out32(0xFD410098, 0x2);
Michal Simek0766ef82021-02-17 09:40:38 +0100443
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200444 if (itercount < 32) {
445 iterresult[0] =
446 ((iterresult[0] << 1) |
447 ((tempbistresult & 0x1) == 0x1));
448 iterresult[1] =
449 ((iterresult[1] << 1) |
450 ((tempbistresult & 0x2) == 0x2));
451 iterresult[2] =
452 ((iterresult[2] << 1) |
453 ((tempbistresult & 0x4) == 0x4));
454 iterresult[3] =
455 ((iterresult[3] << 1) |
456 ((tempbistresult & 0x8) == 0x8));
457 } else {
458 iterresult[4] =
459 ((iterresult[4] << 1) |
460 ((tempbistresult & 0x1) == 0x1));
461 iterresult[5] =
462 ((iterresult[5] << 1) |
463 ((tempbistresult & 0x2) == 0x2));
464 iterresult[6] =
465 ((iterresult[6] << 1) |
466 ((tempbistresult & 0x4) == 0x4));
467 iterresult[7] =
468 ((iterresult[7] << 1) |
469 ((tempbistresult & 0x8) == 0x8));
470 }
471 currbistresult[0] =
472 currbistresult[0] | ((tempbistresult & 0x1) == 1);
473 currbistresult[1] =
474 currbistresult[1] | ((tempbistresult & 0x2) == 0x2);
475 currbistresult[2] =
476 currbistresult[2] | ((tempbistresult & 0x4) == 0x4);
477 currbistresult[3] =
478 currbistresult[3] | ((tempbistresult & 0x8) == 0x8);
Michal Simek0766ef82021-02-17 09:40:38 +0100479
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200480 for (loop = 0; loop <= 3; loop++) {
481 if (currbistresult[loop] == 1 && prevbistresult[loop] == 1)
482 bistpasscount[loop] = bistpasscount[loop] + 1;
483 if (bistpasscount[loop] < 4 &&
484 currbistresult[loop] == 0 && itercount > 2) {
485 if (meancountalt_bistpasscount[loop] <
486 bistpasscount[loop]) {
487 meancountalt_bistpasscount[loop] =
488 bistpasscount[loop];
489 meancountalt[loop] =
490 ((itercount - 1) -
491 ((bistpasscount[loop] + 1) / 2));
492 }
493 bistpasscount[loop] = 0;
494 }
495 if (meancount[loop] == 0 && bistpasscount[loop] >= 4 &&
496 (currbistresult[loop] == 0 || itercount == 63) &&
497 prevbistresult[loop] == 1)
498 meancount[loop] =
499 (itercount - 1) -
500 ((bistpasscount[loop] + 1) / 2);
501 prevbistresult[loop] = currbistresult[loop];
502 }
503 } while (++itercount < 64);
Michal Simek0766ef82021-02-17 09:40:38 +0100504
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200505 for (loop = 0; loop <= 3; loop++) {
506 if (lane0_active == 0 && loop == 0)
507 continue;
508 if (lane1_active == 0 && loop == 1)
509 continue;
510 if (lane2_active == 0 && loop == 2)
511 continue;
512 if (lane3_active == 0 && loop == 3)
513 continue;
Michal Simek0766ef82021-02-17 09:40:38 +0100514
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200515 if (meancount[loop] == 0)
516 meancount[loop] = meancountalt[loop];
Michal Simek0766ef82021-02-17 09:40:38 +0100517
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200518 if (gen2_calib != 1) {
519 ill1_val[loop] = ((0x04 + meancount[loop] * 8) % 0x100);
520 ill12_val[loop] =
521 ((0x04 + meancount[loop] * 8) >=
522 0x100) ? 0x10 : 0x00;
523 Xil_Out32(0xFFFE0000 + loop * 4, iterresult[loop]);
524 Xil_Out32(0xFFFE0010 + loop * 4, iterresult[loop + 4]);
525 Xil_Out32(0xFFFE0020 + loop * 4, bistpasscount[loop]);
526 Xil_Out32(0xFFFE0030 + loop * 4, meancount[loop]);
527 }
528 if (gen2_calib == 1) {
529 ill1_val[loop] =
530 ((0x104 + meancount[loop] * 8) % 0x100);
531 ill12_val[loop] =
532 ((0x104 + meancount[loop] * 8) >=
533 0x200) ? 0x02 : 0x01;
534 Xil_Out32(0xFFFE0040 + loop * 4, iterresult[loop]);
535 Xil_Out32(0xFFFE0050 + loop * 4, iterresult[loop + 4]);
536 Xil_Out32(0xFFFE0060 + loop * 4, bistpasscount[loop]);
537 Xil_Out32(0xFFFE0070 + loop * 4, meancount[loop]);
538 }
Michal Simek0766ef82021-02-17 09:40:38 +0100539 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200540 if (gen2_calib != 1) {
541 if (lane0_active == 1)
542 Xil_Out32(0xFD401924, ill1_val[0]);
543 if (lane0_active == 1)
544 psu_mask_write(0xFD401990, 0x000000F0U, ill12_val[0]);
545 if (lane1_active == 1)
546 Xil_Out32(0xFD405924, ill1_val[1]);
547 if (lane1_active == 1)
548 psu_mask_write(0xFD405990, 0x000000F0U, ill12_val[1]);
549 if (lane2_active == 1)
550 Xil_Out32(0xFD409924, ill1_val[2]);
551 if (lane2_active == 1)
552 psu_mask_write(0xFD409990, 0x000000F0U, ill12_val[2]);
553 if (lane3_active == 1)
554 Xil_Out32(0xFD40D924, ill1_val[3]);
555 if (lane3_active == 1)
556 psu_mask_write(0xFD40D990, 0x000000F0U, ill12_val[3]);
Michal Simek0766ef82021-02-17 09:40:38 +0100557 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200558 if (gen2_calib == 1) {
559 if (lane0_active == 1)
560 Xil_Out32(0xFD401928, ill1_val[0]);
561 if (lane0_active == 1)
562 psu_mask_write(0xFD401990, 0x0000000FU, ill12_val[0]);
563 if (lane1_active == 1)
564 Xil_Out32(0xFD405928, ill1_val[1]);
565 if (lane1_active == 1)
566 psu_mask_write(0xFD405990, 0x0000000FU, ill12_val[1]);
567 if (lane2_active == 1)
568 Xil_Out32(0xFD409928, ill1_val[2]);
569 if (lane2_active == 1)
570 psu_mask_write(0xFD409990, 0x0000000FU, ill12_val[2]);
571 if (lane3_active == 1)
572 Xil_Out32(0xFD40D928, ill1_val[3]);
573 if (lane3_active == 1)
574 psu_mask_write(0xFD40D990, 0x0000000FU, ill12_val[3]);
575 }
Michal Simek0766ef82021-02-17 09:40:38 +0100576
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200577 if (lane0_active == 1)
578 psu_mask_write(0xFD401018, 0x00000030U, 0x00000000U);
579 if (lane1_active == 1)
580 psu_mask_write(0xFD405018, 0x00000030U, 0x00000000U);
581 if (lane2_active == 1)
582 psu_mask_write(0xFD409018, 0x00000030U, 0x00000000U);
583 if (lane3_active == 1)
584 psu_mask_write(0xFD40D018, 0x00000030U, 0x00000000U);
Michal Simek0766ef82021-02-17 09:40:38 +0100585
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200586 Xil_Out32(0xFD410098, 0);
587 if (lane0_active == 1) {
588 Xil_Out32(0xFD403004, 0);
589 Xil_Out32(0xFD403008, 0);
590 Xil_Out32(0xFD40300C, 0);
591 Xil_Out32(0xFD403010, 0);
592 Xil_Out32(0xFD403014, 0);
593 Xil_Out32(0xFD403018, 0);
594 Xil_Out32(0xFD40301C, 0);
595 Xil_Out32(0xFD403020, 0);
596 Xil_Out32(0xFD403024, 0);
597 Xil_Out32(0xFD403028, 0);
598 Xil_Out32(0xFD40302C, 0);
599 Xil_Out32(0xFD403030, 0);
600 Xil_Out32(0xFD403034, 0);
601 Xil_Out32(0xFD403038, 0);
602 Xil_Out32(0xFD40303C, 0);
603 Xil_Out32(0xFD403040, 0);
604 Xil_Out32(0xFD403044, 0);
605 Xil_Out32(0xFD403048, 0);
606 Xil_Out32(0xFD40304C, 0);
607 Xil_Out32(0xFD403050, 0);
608 Xil_Out32(0xFD403054, 0);
609 Xil_Out32(0xFD403058, 0);
610 Xil_Out32(0xFD403068, 1);
611 Xil_Out32(0xFD40306C, 0);
612 Xil_Out32(0xFD4010AC, 0);
613 psu_mask_write(0xFD410044, 0x00000003U, 0x00000001U);
614 psu_mask_write(0xFD410040, 0x00000003U, 0x00000001U);
615 psu_mask_write(0xFD410038, 0x00000007U, 0x00000000U);
Michal Simek0766ef82021-02-17 09:40:38 +0100616 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200617 if (lane1_active == 1) {
618 Xil_Out32(0xFD407004, 0);
619 Xil_Out32(0xFD407008, 0);
620 Xil_Out32(0xFD40700C, 0);
621 Xil_Out32(0xFD407010, 0);
622 Xil_Out32(0xFD407014, 0);
623 Xil_Out32(0xFD407018, 0);
624 Xil_Out32(0xFD40701C, 0);
625 Xil_Out32(0xFD407020, 0);
626 Xil_Out32(0xFD407024, 0);
627 Xil_Out32(0xFD407028, 0);
628 Xil_Out32(0xFD40702C, 0);
629 Xil_Out32(0xFD407030, 0);
630 Xil_Out32(0xFD407034, 0);
631 Xil_Out32(0xFD407038, 0);
632 Xil_Out32(0xFD40703C, 0);
633 Xil_Out32(0xFD407040, 0);
634 Xil_Out32(0xFD407044, 0);
635 Xil_Out32(0xFD407048, 0);
636 Xil_Out32(0xFD40704C, 0);
637 Xil_Out32(0xFD407050, 0);
638 Xil_Out32(0xFD407054, 0);
639 Xil_Out32(0xFD407058, 0);
640 Xil_Out32(0xFD407068, 1);
641 Xil_Out32(0xFD40706C, 0);
642 Xil_Out32(0xFD4050AC, 0);
643 psu_mask_write(0xFD410044, 0x0000000CU, 0x00000004U);
644 psu_mask_write(0xFD410040, 0x0000000CU, 0x00000004U);
645 psu_mask_write(0xFD410038, 0x00000070U, 0x00000000U);
Michal Simek0766ef82021-02-17 09:40:38 +0100646 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200647 if (lane2_active == 1) {
648 Xil_Out32(0xFD40B004, 0);
649 Xil_Out32(0xFD40B008, 0);
650 Xil_Out32(0xFD40B00C, 0);
651 Xil_Out32(0xFD40B010, 0);
652 Xil_Out32(0xFD40B014, 0);
653 Xil_Out32(0xFD40B018, 0);
654 Xil_Out32(0xFD40B01C, 0);
655 Xil_Out32(0xFD40B020, 0);
656 Xil_Out32(0xFD40B024, 0);
657 Xil_Out32(0xFD40B028, 0);
658 Xil_Out32(0xFD40B02C, 0);
659 Xil_Out32(0xFD40B030, 0);
660 Xil_Out32(0xFD40B034, 0);
661 Xil_Out32(0xFD40B038, 0);
662 Xil_Out32(0xFD40B03C, 0);
663 Xil_Out32(0xFD40B040, 0);
664 Xil_Out32(0xFD40B044, 0);
665 Xil_Out32(0xFD40B048, 0);
666 Xil_Out32(0xFD40B04C, 0);
667 Xil_Out32(0xFD40B050, 0);
668 Xil_Out32(0xFD40B054, 0);
669 Xil_Out32(0xFD40B058, 0);
670 Xil_Out32(0xFD40B068, 1);
671 Xil_Out32(0xFD40B06C, 0);
672 Xil_Out32(0xFD4090AC, 0);
673 psu_mask_write(0xFD410044, 0x00000030U, 0x00000010U);
674 psu_mask_write(0xFD410040, 0x00000030U, 0x00000010U);
675 psu_mask_write(0xFD41003C, 0x00000007U, 0x00000000U);
Michal Simek0766ef82021-02-17 09:40:38 +0100676 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200677 if (lane3_active == 1) {
678 Xil_Out32(0xFD40F004, 0);
679 Xil_Out32(0xFD40F008, 0);
680 Xil_Out32(0xFD40F00C, 0);
681 Xil_Out32(0xFD40F010, 0);
682 Xil_Out32(0xFD40F014, 0);
683 Xil_Out32(0xFD40F018, 0);
684 Xil_Out32(0xFD40F01C, 0);
685 Xil_Out32(0xFD40F020, 0);
686 Xil_Out32(0xFD40F024, 0);
687 Xil_Out32(0xFD40F028, 0);
688 Xil_Out32(0xFD40F02C, 0);
689 Xil_Out32(0xFD40F030, 0);
690 Xil_Out32(0xFD40F034, 0);
691 Xil_Out32(0xFD40F038, 0);
692 Xil_Out32(0xFD40F03C, 0);
693 Xil_Out32(0xFD40F040, 0);
694 Xil_Out32(0xFD40F044, 0);
695 Xil_Out32(0xFD40F048, 0);
696 Xil_Out32(0xFD40F04C, 0);
697 Xil_Out32(0xFD40F050, 0);
698 Xil_Out32(0xFD40F054, 0);
699 Xil_Out32(0xFD40F058, 0);
700 Xil_Out32(0xFD40F068, 1);
701 Xil_Out32(0xFD40F06C, 0);
702 Xil_Out32(0xFD40D0AC, 0);
703 psu_mask_write(0xFD410044, 0x000000C0U, 0x00000040U);
704 psu_mask_write(0xFD410040, 0x000000C0U, 0x00000040U);
705 psu_mask_write(0xFD41003C, 0x00000070U, 0x00000000U);
706 }
707 return 1;
708}
Michal Simek0766ef82021-02-17 09:40:38 +0100709
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200710static int serdes_illcalib(u32 lane3_protocol, u32 lane3_rate,
711 u32 lane2_protocol, u32 lane2_rate,
712 u32 lane1_protocol, u32 lane1_rate,
713 u32 lane0_protocol, u32 lane0_rate)
714{
715 unsigned int rdata = 0;
716 unsigned int sata_gen2 = 1;
717 unsigned int temp_ill12 = 0;
718 unsigned int temp_PLL_REF_SEL_OFFSET;
719 unsigned int temp_TM_IQ_ILL1;
720 unsigned int temp_TM_E_ILL1;
721 unsigned int temp_tx_dig_tm_61;
722 unsigned int temp_tm_dig_6;
723 unsigned int temp_pll_fbdiv_frac_3_msb_offset;
Michal Simek0766ef82021-02-17 09:40:38 +0100724
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200725 if (lane0_protocol == 2 || lane0_protocol == 1) {
726 Xil_Out32(0xFD401910, 0xF3);
727 Xil_Out32(0xFD40193C, 0xF3);
728 Xil_Out32(0xFD401914, 0xF3);
729 Xil_Out32(0xFD401940, 0xF3);
730 }
731 if (lane1_protocol == 2 || lane1_protocol == 1) {
732 Xil_Out32(0xFD405910, 0xF3);
733 Xil_Out32(0xFD40593C, 0xF3);
734 Xil_Out32(0xFD405914, 0xF3);
735 Xil_Out32(0xFD405940, 0xF3);
736 }
737 if (lane2_protocol == 2 || lane2_protocol == 1) {
738 Xil_Out32(0xFD409910, 0xF3);
739 Xil_Out32(0xFD40993C, 0xF3);
740 Xil_Out32(0xFD409914, 0xF3);
741 Xil_Out32(0xFD409940, 0xF3);
742 }
743 if (lane3_protocol == 2 || lane3_protocol == 1) {
744 Xil_Out32(0xFD40D910, 0xF3);
745 Xil_Out32(0xFD40D93C, 0xF3);
746 Xil_Out32(0xFD40D914, 0xF3);
747 Xil_Out32(0xFD40D940, 0xF3);
748 }
Michal Simek0766ef82021-02-17 09:40:38 +0100749
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200750 if (sata_gen2 == 1) {
751 if (lane0_protocol == 2) {
752 temp_pll_fbdiv_frac_3_msb_offset = Xil_In32(0xFD402360);
753 Xil_Out32(0xFD402360, 0x0);
754 temp_PLL_REF_SEL_OFFSET = Xil_In32(0xFD410000);
755 psu_mask_write(0xFD410000, 0x0000001FU, 0x0000000DU);
756 temp_TM_IQ_ILL1 = Xil_In32(0xFD4018F8);
757 temp_TM_E_ILL1 = Xil_In32(0xFD401924);
758 Xil_Out32(0xFD4018F8, 0x78);
759 temp_tx_dig_tm_61 = Xil_In32(0xFD4000F4);
760 temp_tm_dig_6 = Xil_In32(0xFD40106C);
761 psu_mask_write(0xFD4000F4, 0x0000000BU, 0x00000000U);
762 psu_mask_write(0xFD40106C, 0x0000000FU, 0x00000000U);
763 temp_ill12 = Xil_In32(0xFD401990) & 0xF0;
Michal Simek0766ef82021-02-17 09:40:38 +0100764
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200765 serdes_illcalib_pcie_gen1(0, 0, 0, 0, 0, 0, 1, 0, 0);
Michal Simek0766ef82021-02-17 09:40:38 +0100766
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200767 Xil_Out32(0xFD402360, temp_pll_fbdiv_frac_3_msb_offset);
768 Xil_Out32(0xFD41000C, temp_PLL_REF_SEL_OFFSET);
769 Xil_Out32(0xFD4018F8, temp_TM_IQ_ILL1);
770 Xil_Out32(0xFD4000F4, temp_tx_dig_tm_61);
771 Xil_Out32(0xFD40106C, temp_tm_dig_6);
772 Xil_Out32(0xFD401928, Xil_In32(0xFD401924));
773 temp_ill12 =
774 temp_ill12 | (Xil_In32(0xFD401990) >> 4 & 0xF);
775 Xil_Out32(0xFD401990, temp_ill12);
776 Xil_Out32(0xFD401924, temp_TM_E_ILL1);
Michal Simek0766ef82021-02-17 09:40:38 +0100777 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200778 if (lane1_protocol == 2) {
779 temp_pll_fbdiv_frac_3_msb_offset = Xil_In32(0xFD406360);
780 Xil_Out32(0xFD406360, 0x0);
781 temp_PLL_REF_SEL_OFFSET = Xil_In32(0xFD410004);
782 psu_mask_write(0xFD410004, 0x0000001FU, 0x0000000DU);
783 temp_TM_IQ_ILL1 = Xil_In32(0xFD4058F8);
784 temp_TM_E_ILL1 = Xil_In32(0xFD405924);
785 Xil_Out32(0xFD4058F8, 0x78);
786 temp_tx_dig_tm_61 = Xil_In32(0xFD4040F4);
787 temp_tm_dig_6 = Xil_In32(0xFD40506C);
788 psu_mask_write(0xFD4040F4, 0x0000000BU, 0x00000000U);
789 psu_mask_write(0xFD40506C, 0x0000000FU, 0x00000000U);
790 temp_ill12 = Xil_In32(0xFD405990) & 0xF0;
Michal Simek0766ef82021-02-17 09:40:38 +0100791
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200792 serdes_illcalib_pcie_gen1(0, 0, 0, 0, 1, 0, 0, 0, 0);
Michal Simek0766ef82021-02-17 09:40:38 +0100793
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200794 Xil_Out32(0xFD406360, temp_pll_fbdiv_frac_3_msb_offset);
795 Xil_Out32(0xFD41000C, temp_PLL_REF_SEL_OFFSET);
796 Xil_Out32(0xFD4058F8, temp_TM_IQ_ILL1);
797 Xil_Out32(0xFD4040F4, temp_tx_dig_tm_61);
798 Xil_Out32(0xFD40506C, temp_tm_dig_6);
799 Xil_Out32(0xFD405928, Xil_In32(0xFD405924));
800 temp_ill12 =
801 temp_ill12 | (Xil_In32(0xFD405990) >> 4 & 0xF);
802 Xil_Out32(0xFD405990, temp_ill12);
803 Xil_Out32(0xFD405924, temp_TM_E_ILL1);
804 }
805 if (lane2_protocol == 2) {
806 temp_pll_fbdiv_frac_3_msb_offset = Xil_In32(0xFD40A360);
807 Xil_Out32(0xFD40A360, 0x0);
808 temp_PLL_REF_SEL_OFFSET = Xil_In32(0xFD410008);
809 psu_mask_write(0xFD410008, 0x0000001FU, 0x0000000DU);
810 temp_TM_IQ_ILL1 = Xil_In32(0xFD4098F8);
811 temp_TM_E_ILL1 = Xil_In32(0xFD409924);
812 Xil_Out32(0xFD4098F8, 0x78);
813 temp_tx_dig_tm_61 = Xil_In32(0xFD4080F4);
814 temp_tm_dig_6 = Xil_In32(0xFD40906C);
815 psu_mask_write(0xFD4080F4, 0x0000000BU, 0x00000000U);
816 psu_mask_write(0xFD40906C, 0x0000000FU, 0x00000000U);
817 temp_ill12 = Xil_In32(0xFD409990) & 0xF0;
Michal Simek0766ef82021-02-17 09:40:38 +0100818
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200819 serdes_illcalib_pcie_gen1(0, 0, 1, 0, 0, 0, 0, 0, 0);
820
821 Xil_Out32(0xFD40A360, temp_pll_fbdiv_frac_3_msb_offset);
822 Xil_Out32(0xFD41000C, temp_PLL_REF_SEL_OFFSET);
823 Xil_Out32(0xFD4098F8, temp_TM_IQ_ILL1);
824 Xil_Out32(0xFD4080F4, temp_tx_dig_tm_61);
825 Xil_Out32(0xFD40906C, temp_tm_dig_6);
826 Xil_Out32(0xFD409928, Xil_In32(0xFD409924));
827 temp_ill12 =
828 temp_ill12 | (Xil_In32(0xFD409990) >> 4 & 0xF);
829 Xil_Out32(0xFD409990, temp_ill12);
830 Xil_Out32(0xFD409924, temp_TM_E_ILL1);
Michal Simek0766ef82021-02-17 09:40:38 +0100831 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200832 if (lane3_protocol == 2) {
833 temp_pll_fbdiv_frac_3_msb_offset = Xil_In32(0xFD40E360);
834 Xil_Out32(0xFD40E360, 0x0);
835 temp_PLL_REF_SEL_OFFSET = Xil_In32(0xFD41000C);
836 psu_mask_write(0xFD41000C, 0x0000001FU, 0x0000000DU);
837 temp_TM_IQ_ILL1 = Xil_In32(0xFD40D8F8);
838 temp_TM_E_ILL1 = Xil_In32(0xFD40D924);
839 Xil_Out32(0xFD40D8F8, 0x78);
840 temp_tx_dig_tm_61 = Xil_In32(0xFD40C0F4);
841 temp_tm_dig_6 = Xil_In32(0xFD40D06C);
842 psu_mask_write(0xFD40C0F4, 0x0000000BU, 0x00000000U);
843 psu_mask_write(0xFD40D06C, 0x0000000FU, 0x00000000U);
844 temp_ill12 = Xil_In32(0xFD40D990) & 0xF0;
845
846 serdes_illcalib_pcie_gen1(1, 0, 0, 0, 0, 0, 0, 0, 0);
847
848 Xil_Out32(0xFD40E360, temp_pll_fbdiv_frac_3_msb_offset);
849 Xil_Out32(0xFD41000C, temp_PLL_REF_SEL_OFFSET);
850 Xil_Out32(0xFD40D8F8, temp_TM_IQ_ILL1);
851 Xil_Out32(0xFD40C0F4, temp_tx_dig_tm_61);
852 Xil_Out32(0xFD40D06C, temp_tm_dig_6);
853 Xil_Out32(0xFD40D928, Xil_In32(0xFD40D924));
854 temp_ill12 =
855 temp_ill12 | (Xil_In32(0xFD40D990) >> 4 & 0xF);
856 Xil_Out32(0xFD40D990, temp_ill12);
857 Xil_Out32(0xFD40D924, temp_TM_E_ILL1);
Michal Simek0766ef82021-02-17 09:40:38 +0100858 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200859 rdata = Xil_In32(0xFD410098);
860 rdata = (rdata & 0xDF);
861 Xil_Out32(0xFD410098, rdata);
Michal Simek0766ef82021-02-17 09:40:38 +0100862 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200863
864 if (lane0_protocol == 2 && lane0_rate == 3) {
865 psu_mask_write(0xFD40198C, 0x000000F0U, 0x00000020U);
866 psu_mask_write(0xFD40192C, 0x000000FFU, 0x00000094U);
Michal Simek0766ef82021-02-17 09:40:38 +0100867 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200868 if (lane1_protocol == 2 && lane1_rate == 3) {
869 psu_mask_write(0xFD40598C, 0x000000F0U, 0x00000020U);
870 psu_mask_write(0xFD40592C, 0x000000FFU, 0x00000094U);
871 }
872 if (lane2_protocol == 2 && lane2_rate == 3) {
873 psu_mask_write(0xFD40998C, 0x000000F0U, 0x00000020U);
874 psu_mask_write(0xFD40992C, 0x000000FFU, 0x00000094U);
875 }
876 if (lane3_protocol == 2 && lane3_rate == 3) {
877 psu_mask_write(0xFD40D98C, 0x000000F0U, 0x00000020U);
878 psu_mask_write(0xFD40D92C, 0x000000FFU, 0x00000094U);
879 }
880
881 if (lane0_protocol == 1) {
882 if (lane0_rate == 0) {
883 serdes_illcalib_pcie_gen1(lane3_protocol, lane3_rate,
884 lane2_protocol, lane2_rate,
885 lane1_protocol, lane1_rate,
886 lane0_protocol, 0, 0);
887 } else {
888 serdes_illcalib_pcie_gen1(lane3_protocol, lane3_rate,
889 lane2_protocol, lane2_rate,
890 lane1_protocol, lane1_rate,
891 lane0_protocol, 0, 0);
892 serdes_illcalib_pcie_gen1(lane3_protocol, lane3_rate,
893 lane2_protocol, lane2_rate,
894 lane1_protocol, lane1_rate,
895 lane0_protocol, lane0_rate,
896 1);
897 }
Michal Simek0766ef82021-02-17 09:40:38 +0100898 }
899
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +0200900 if (lane0_protocol == 3)
901 Xil_Out32(0xFD401914, 0xF3);
902 if (lane0_protocol == 3)
903 Xil_Out32(0xFD401940, 0xF3);
904 if (lane0_protocol == 3)
905 Xil_Out32(0xFD401990, 0x20);
906 if (lane0_protocol == 3)
907 Xil_Out32(0xFD401924, 0x37);
908
909 if (lane1_protocol == 3)
910 Xil_Out32(0xFD405914, 0xF3);
911 if (lane1_protocol == 3)
912 Xil_Out32(0xFD405940, 0xF3);
913 if (lane1_protocol == 3)
914 Xil_Out32(0xFD405990, 0x20);
915 if (lane1_protocol == 3)
916 Xil_Out32(0xFD405924, 0x37);
917
918 if (lane2_protocol == 3)
919 Xil_Out32(0xFD409914, 0xF3);
920 if (lane2_protocol == 3)
921 Xil_Out32(0xFD409940, 0xF3);
922 if (lane2_protocol == 3)
923 Xil_Out32(0xFD409990, 0x20);
924 if (lane2_protocol == 3)
925 Xil_Out32(0xFD409924, 0x37);
926
927 if (lane3_protocol == 3)
928 Xil_Out32(0xFD40D914, 0xF3);
929 if (lane3_protocol == 3)
930 Xil_Out32(0xFD40D940, 0xF3);
931 if (lane3_protocol == 3)
932 Xil_Out32(0xFD40D990, 0x20);
933 if (lane3_protocol == 3)
934 Xil_Out32(0xFD40D924, 0x37);
935
936 return 1;
937}
938
939static unsigned long psu_pll_init_data(void)
940{
941 psu_mask_write(0xFF5E0034, 0xFE7FEDEFU, 0x7E4B0C82U);
942 psu_mask_write(0xFF5E0030, 0x00717F00U, 0x00015A00U);
943 psu_mask_write(0xFF5E0030, 0x00000008U, 0x00000008U);
944 psu_mask_write(0xFF5E0030, 0x00000001U, 0x00000001U);
945 psu_mask_write(0xFF5E0030, 0x00000001U, 0x00000000U);
946 mask_poll(0xFF5E0040, 0x00000002U);
947 psu_mask_write(0xFF5E0030, 0x00000008U, 0x00000000U);
948 psu_mask_write(0xFF5E0048, 0x00003F00U, 0x00000300U);
949 psu_mask_write(0xFF5E0108, 0x013F3F07U, 0x01012300U);
950 psu_mask_write(0xFF5E0024, 0xFE7FEDEFU, 0x7E4B0C82U);
951 psu_mask_write(0xFF5E0020, 0x00717F00U, 0x00015A00U);
952 psu_mask_write(0xFF5E0020, 0x00000008U, 0x00000008U);
953 psu_mask_write(0xFF5E0020, 0x00000001U, 0x00000001U);
954 psu_mask_write(0xFF5E0020, 0x00000001U, 0x00000000U);
955 mask_poll(0xFF5E0040, 0x00000001U);
956 psu_mask_write(0xFF5E0020, 0x00000008U, 0x00000000U);
957 psu_mask_write(0xFF5E0044, 0x00003F00U, 0x00000300U);
958 psu_mask_write(0xFD1A0024, 0xFE7FEDEFU, 0x7E4B0C62U);
959 psu_mask_write(0xFD1A0020, 0x00717F00U, 0x00014800U);
960 psu_mask_write(0xFD1A0020, 0x00000008U, 0x00000008U);
961 psu_mask_write(0xFD1A0020, 0x00000001U, 0x00000001U);
962 psu_mask_write(0xFD1A0020, 0x00000001U, 0x00000000U);
963 mask_poll(0xFD1A0044, 0x00000001U);
964 psu_mask_write(0xFD1A0020, 0x00000008U, 0x00000000U);
965 psu_mask_write(0xFD1A0048, 0x00003F00U, 0x00000300U);
966 psu_mask_write(0xFD1A0030, 0xFE7FEDEFU, 0x7E4B0C62U);
967 psu_mask_write(0xFD1A002C, 0x00717F00U, 0x00013F00U);
968 psu_mask_write(0xFD1A002C, 0x00000008U, 0x00000008U);
969 psu_mask_write(0xFD1A002C, 0x00000001U, 0x00000001U);
970 psu_mask_write(0xFD1A002C, 0x00000001U, 0x00000000U);
971 mask_poll(0xFD1A0044, 0x00000002U);
972 psu_mask_write(0xFD1A002C, 0x00000008U, 0x00000000U);
973 psu_mask_write(0xFD1A004C, 0x00003F00U, 0x00000200U);
974 psu_mask_write(0xFD1A003C, 0xFE7FEDEFU, 0x7E4B0C82U);
975 psu_mask_write(0xFD1A0038, 0x00717F00U, 0x00015A00U);
976 psu_mask_write(0xFD1A0038, 0x00000008U, 0x00000008U);
977 psu_mask_write(0xFD1A0038, 0x00000001U, 0x00000001U);
978 psu_mask_write(0xFD1A0038, 0x00000001U, 0x00000000U);
979 mask_poll(0xFD1A0044, 0x00000004U);
980 psu_mask_write(0xFD1A0038, 0x00000008U, 0x00000000U);
981 psu_mask_write(0xFD1A0050, 0x00003F00U, 0x00000300U);
982
983 return 1;
984}
985
986static unsigned long psu_clock_init_data(void)
987{
988 psu_mask_write(0xFF5E005C, 0x063F3F07U, 0x06010C00U);
989 psu_mask_write(0xFF5E0100, 0x013F3F07U, 0x01010600U);
990 psu_mask_write(0xFF5E0060, 0x023F3F07U, 0x02010600U);
991 psu_mask_write(0xFF5E004C, 0x023F3F07U, 0x02031900U);
992 psu_mask_write(0xFF5E0068, 0x013F3F07U, 0x01010C00U);
993 psu_mask_write(0xFF5E0070, 0x013F3F07U, 0x01010800U);
994 psu_mask_write(0xFF18030C, 0x00020000U, 0x00000000U);
995 psu_mask_write(0xFF5E0074, 0x013F3F07U, 0x01010F00U);
996 psu_mask_write(0xFF5E0120, 0x013F3F07U, 0x01010F00U);
997 psu_mask_write(0xFF5E0124, 0x013F3F07U, 0x01010F00U);
998 psu_mask_write(0xFF5E0090, 0x01003F07U, 0x01000302U);
999 psu_mask_write(0xFF5E009C, 0x01003F07U, 0x01000602U);
1000 psu_mask_write(0xFF5E00A4, 0x01003F07U, 0x01000800U);
1001 psu_mask_write(0xFF5E00A8, 0x01003F07U, 0x01000302U);
1002 psu_mask_write(0xFF5E00AC, 0x01003F07U, 0x01000F02U);
1003 psu_mask_write(0xFF5E00B0, 0x01003F07U, 0x01000602U);
1004 psu_mask_write(0xFF5E00B8, 0x01003F07U, 0x01000302U);
1005 psu_mask_write(0xFF5E00C0, 0x013F3F07U, 0x01010F00U);
1006 psu_mask_write(0xFF5E0108, 0x013F3F07U, 0x01011E02U);
1007 psu_mask_write(0xFF5E0104, 0x00000007U, 0x00000000U);
1008 psu_mask_write(0xFF5E0128, 0x01003F07U, 0x01000F00U);
1009 psu_mask_write(0xFD1A00A0, 0x01003F07U, 0x01000200U);
1010 psu_mask_write(0xFD1A0060, 0x03003F07U, 0x03000100U);
1011 psu_mask_write(0xFD1A0068, 0x01003F07U, 0x01000200U);
1012 psu_mask_write(0xFD1A0080, 0x00003F07U, 0x00000200U);
1013 psu_mask_write(0xFD1A00B8, 0x01003F07U, 0x01000200U);
1014 psu_mask_write(0xFD1A00BC, 0x01003F07U, 0x01000200U);
1015 psu_mask_write(0xFD1A00C0, 0x01003F07U, 0x01000203U);
1016 psu_mask_write(0xFD1A00C4, 0x01003F07U, 0x01000502U);
1017 psu_mask_write(0xFD1A00F8, 0x00003F07U, 0x00000200U);
1018 psu_mask_write(0xFF180380, 0x000000FFU, 0x00000000U);
1019 psu_mask_write(0xFD610100, 0x00000001U, 0x00000000U);
1020 psu_mask_write(0xFF180300, 0x00000001U, 0x00000000U);
1021 psu_mask_write(0xFF410050, 0x00000001U, 0x00000000U);
1022
1023 return 1;
1024}
1025
1026static unsigned long psu_ddr_init_data(void)
1027{
1028 psu_mask_write(0xFD1A0108, 0x00000008U, 0x00000008U);
1029 psu_mask_write(0xFD070000, 0xE30FBE3DU, 0x81040010U);
1030 psu_mask_write(0xFD070010, 0x8000F03FU, 0x00000030U);
1031 psu_mask_write(0xFD070020, 0x000003F3U, 0x00000200U);
1032 psu_mask_write(0xFD070024, 0xFFFFFFFFU, 0x00800000U);
1033 psu_mask_write(0xFD070030, 0x0000007FU, 0x00000000U);
1034 psu_mask_write(0xFD070034, 0x00FFFF1FU, 0x00408210U);
1035 psu_mask_write(0xFD070050, 0x00F1F1F4U, 0x00210000U);
1036 psu_mask_write(0xFD070054, 0x0FFF0FFFU, 0x00000000U);
1037 psu_mask_write(0xFD070060, 0x00000073U, 0x00000001U);
1038 psu_mask_write(0xFD070064, 0x0FFF83FFU, 0x007F80B8U);
1039 psu_mask_write(0xFD070070, 0x00000017U, 0x00000010U);
1040 psu_mask_write(0xFD070074, 0x00000003U, 0x00000000U);
1041 psu_mask_write(0xFD0700C4, 0x3F000391U, 0x10000200U);
1042 psu_mask_write(0xFD0700C8, 0x01FF1F3FU, 0x0040051FU);
1043 psu_mask_write(0xFD0700D0, 0xC3FF0FFFU, 0x00020102U);
1044 psu_mask_write(0xFD0700D4, 0x01FF7F0FU, 0x00020000U);
1045 psu_mask_write(0xFD0700D8, 0x0000FF0FU, 0x00002205U);
1046 psu_mask_write(0xFD0700DC, 0xFFFFFFFFU, 0x07300301U);
1047 psu_mask_write(0xFD0700E0, 0xFFFFFFFFU, 0x00100200U);
1048 psu_mask_write(0xFD0700E4, 0x00FF03FFU, 0x00210004U);
1049 psu_mask_write(0xFD0700E8, 0xFFFFFFFFU, 0x000006C0U);
1050 psu_mask_write(0xFD0700EC, 0xFFFF0000U, 0x08190000U);
1051 psu_mask_write(0xFD0700F0, 0x0000003FU, 0x00000010U);
1052 psu_mask_write(0xFD0700F4, 0x00000FFFU, 0x0000066FU);
1053 psu_mask_write(0xFD070100, 0x7F3F7F3FU, 0x0F102311U);
1054 psu_mask_write(0xFD070104, 0x001F1F7FU, 0x00040419U);
1055 psu_mask_write(0xFD070108, 0x3F3F3F3FU, 0x0608070CU);
1056 psu_mask_write(0xFD07010C, 0x3FF3F3FFU, 0x0050400CU);
1057 psu_mask_write(0xFD070110, 0x1F0F0F1FU, 0x08030409U);
1058 psu_mask_write(0xFD070114, 0x0F0F3F1FU, 0x06060403U);
1059 psu_mask_write(0xFD070118, 0x0F0F000FU, 0x01010004U);
1060 psu_mask_write(0xFD07011C, 0x00000F0FU, 0x00000606U);
1061 psu_mask_write(0xFD070120, 0x7F7F7F7FU, 0x04040D07U);
1062 psu_mask_write(0xFD070124, 0x40070F3FU, 0x00020309U);
1063 psu_mask_write(0xFD07012C, 0x7F1F031FU, 0x1207010EU);
1064 psu_mask_write(0xFD070130, 0x00030F1FU, 0x00020608U);
1065 psu_mask_write(0xFD070180, 0xF7FF03FFU, 0x81000040U);
1066 psu_mask_write(0xFD070184, 0x3FFFFFFFU, 0x0201908AU);
1067 psu_mask_write(0xFD070190, 0x1FBFBF3FU, 0x048B8208U);
1068 psu_mask_write(0xFD070194, 0xF31F0F0FU, 0x00030304U);
1069 psu_mask_write(0xFD070198, 0x0FF1F1F1U, 0x07000101U);
1070 psu_mask_write(0xFD07019C, 0x000000F1U, 0x00000021U);
1071 psu_mask_write(0xFD0701A0, 0xC3FF03FFU, 0x00400003U);
1072 psu_mask_write(0xFD0701A4, 0x00FF00FFU, 0x00C800FFU);
1073 psu_mask_write(0xFD0701B0, 0x00000007U, 0x00000000U);
1074 psu_mask_write(0xFD0701B4, 0x00003F3FU, 0x00000906U);
1075 psu_mask_write(0xFD0701C0, 0x00000007U, 0x00000001U);
1076 psu_mask_write(0xFD070200, 0x0000001FU, 0x0000001FU);
1077 psu_mask_write(0xFD070204, 0x001F1F1FU, 0x001F0909U);
1078 psu_mask_write(0xFD070208, 0x0F0F0F0FU, 0x01010100U);
1079 psu_mask_write(0xFD07020C, 0x0F0F0F0FU, 0x01010101U);
1080 psu_mask_write(0xFD070210, 0x00000F0FU, 0x00000F0FU);
1081 psu_mask_write(0xFD070214, 0x0F0F0F0FU, 0x070F0707U);
1082 psu_mask_write(0xFD070218, 0x8F0F0F0FU, 0x07070707U);
1083 psu_mask_write(0xFD07021C, 0x00000F0FU, 0x00000F0FU);
1084 psu_mask_write(0xFD070220, 0x00001F1FU, 0x00001F01U);
1085 psu_mask_write(0xFD070224, 0x0F0F0F0FU, 0x07070707U);
1086 psu_mask_write(0xFD070228, 0x0F0F0F0FU, 0x07070707U);
1087 psu_mask_write(0xFD07022C, 0x0000000FU, 0x00000007U);
1088 psu_mask_write(0xFD070240, 0x0F1F0F7CU, 0x0600060CU);
1089 psu_mask_write(0xFD070244, 0x00003333U, 0x00000001U);
1090 psu_mask_write(0xFD070250, 0x7FFF3F07U, 0x01002001U);
1091 psu_mask_write(0xFD070264, 0xFF00FFFFU, 0x08000040U);
1092 psu_mask_write(0xFD07026C, 0xFF00FFFFU, 0x08000040U);
1093 psu_mask_write(0xFD070280, 0xFFFFFFFFU, 0x00000000U);
1094 psu_mask_write(0xFD070284, 0xFFFFFFFFU, 0x00000000U);
1095 psu_mask_write(0xFD070288, 0xFFFFFFFFU, 0x00000000U);
1096 psu_mask_write(0xFD07028C, 0xFFFFFFFFU, 0x00000000U);
1097 psu_mask_write(0xFD070290, 0x0000FFFFU, 0x00000000U);
1098 psu_mask_write(0xFD070294, 0x00000001U, 0x00000001U);
1099 psu_mask_write(0xFD070300, 0x00000011U, 0x00000000U);
1100 psu_mask_write(0xFD07030C, 0x80000033U, 0x00000000U);
1101 psu_mask_write(0xFD070320, 0x00000001U, 0x00000000U);
1102 psu_mask_write(0xFD070400, 0x00000111U, 0x00000001U);
1103 psu_mask_write(0xFD070404, 0x000073FFU, 0x0000200FU);
1104 psu_mask_write(0xFD070408, 0x000073FFU, 0x0000200FU);
1105 psu_mask_write(0xFD070490, 0x00000001U, 0x00000001U);
1106 psu_mask_write(0xFD070494, 0x0033000FU, 0x0020000BU);
1107 psu_mask_write(0xFD070498, 0x07FF07FFU, 0x00000000U);
1108 psu_mask_write(0xFD0704B4, 0x000073FFU, 0x0000200FU);
1109 psu_mask_write(0xFD0704B8, 0x000073FFU, 0x0000200FU);
1110 psu_mask_write(0xFD070540, 0x00000001U, 0x00000001U);
1111 psu_mask_write(0xFD070544, 0x03330F0FU, 0x02000B03U);
1112 psu_mask_write(0xFD070548, 0x07FF07FFU, 0x00000000U);
1113 psu_mask_write(0xFD070564, 0x000073FFU, 0x0000200FU);
1114 psu_mask_write(0xFD070568, 0x000073FFU, 0x0000200FU);
1115 psu_mask_write(0xFD0705F0, 0x00000001U, 0x00000001U);
1116 psu_mask_write(0xFD0705F4, 0x03330F0FU, 0x02000B03U);
1117 psu_mask_write(0xFD0705F8, 0x07FF07FFU, 0x00000000U);
1118 psu_mask_write(0xFD070614, 0x000073FFU, 0x0000200FU);
1119 psu_mask_write(0xFD070618, 0x000073FFU, 0x0000200FU);
1120 psu_mask_write(0xFD0706A0, 0x00000001U, 0x00000001U);
1121 psu_mask_write(0xFD0706A4, 0x0033000FU, 0x00100003U);
1122 psu_mask_write(0xFD0706A8, 0x07FF07FFU, 0x0000004FU);
1123 psu_mask_write(0xFD0706AC, 0x0033000FU, 0x00100003U);
1124 psu_mask_write(0xFD0706B0, 0x000007FFU, 0x0000004FU);
1125 psu_mask_write(0xFD0706C4, 0x000073FFU, 0x0000200FU);
1126 psu_mask_write(0xFD0706C8, 0x000073FFU, 0x0000200FU);
1127 psu_mask_write(0xFD070750, 0x00000001U, 0x00000001U);
1128 psu_mask_write(0xFD070754, 0x0033000FU, 0x00100003U);
1129 psu_mask_write(0xFD070758, 0x07FF07FFU, 0x0000004FU);
1130 psu_mask_write(0xFD07075C, 0x0033000FU, 0x00100003U);
1131 psu_mask_write(0xFD070760, 0x000007FFU, 0x0000004FU);
1132 psu_mask_write(0xFD070774, 0x000073FFU, 0x0000200FU);
1133 psu_mask_write(0xFD070778, 0x000073FFU, 0x0000200FU);
1134 psu_mask_write(0xFD070800, 0x00000001U, 0x00000001U);
1135 psu_mask_write(0xFD070804, 0x0033000FU, 0x00100003U);
1136 psu_mask_write(0xFD070808, 0x07FF07FFU, 0x0000004FU);
1137 psu_mask_write(0xFD07080C, 0x0033000FU, 0x00100003U);
1138 psu_mask_write(0xFD070810, 0x000007FFU, 0x0000004FU);
1139 psu_mask_write(0xFD070F04, 0x000001FFU, 0x00000000U);
1140 psu_mask_write(0xFD070F08, 0x000000FFU, 0x00000000U);
1141 psu_mask_write(0xFD070F0C, 0x000001FFU, 0x00000010U);
1142 psu_mask_write(0xFD070F10, 0x000000FFU, 0x0000000FU);
1143 psu_mask_write(0xFD072190, 0x1FBFBF3FU, 0x07828002U);
1144 psu_mask_write(0xFD1A0108, 0x0000000CU, 0x00000000U);
1145 psu_mask_write(0xFD080010, 0xFFFFFFFFU, 0x07001E00U);
1146 psu_mask_write(0xFD080018, 0xFFFFFFFFU, 0x00F0FC00U);
1147 psu_mask_write(0xFD08001C, 0xFFFFFFFFU, 0x55AA5480U);
1148 psu_mask_write(0xFD080024, 0xFFFFFFFFU, 0x010100F4U);
1149 psu_mask_write(0xFD080040, 0xFFFFFFFFU, 0x41A20D10U);
1150 psu_mask_write(0xFD080044, 0xFFFFFFFFU, 0xCD141275U);
1151 psu_mask_write(0xFD080068, 0xFFFFFFFFU, 0x01100000U);
1152 psu_mask_write(0xFD080090, 0xFFFFFFFFU, 0x02A04161U);
1153 psu_mask_write(0xFD0800C0, 0xFFFFFFFFU, 0x00000000U);
1154 psu_mask_write(0xFD0800C4, 0xFFFFFFFFU, 0x000000E3U);
1155 psu_mask_write(0xFD080100, 0xFFFFFFFFU, 0x0800040CU);
1156 psu_mask_write(0xFD080110, 0xFFFFFFFFU, 0x07220F08U);
1157 psu_mask_write(0xFD080114, 0xFFFFFFFFU, 0x28200008U);
1158 psu_mask_write(0xFD080118, 0xFFFFFFFFU, 0x000F0300U);
1159 psu_mask_write(0xFD08011C, 0xFFFFFFFFU, 0x83000800U);
1160 psu_mask_write(0xFD080120, 0xFFFFFFFFU, 0x01702B07U);
1161 psu_mask_write(0xFD080124, 0xFFFFFFFFU, 0x00310F08U);
1162 psu_mask_write(0xFD080128, 0xFFFFFFFFU, 0x00000B0FU);
1163 psu_mask_write(0xFD080140, 0xFFFFFFFFU, 0x08400020U);
1164 psu_mask_write(0xFD080144, 0xFFFFFFFFU, 0x00000C80U);
1165 psu_mask_write(0xFD080150, 0xFFFFFFFFU, 0x00000000U);
1166 psu_mask_write(0xFD080154, 0xFFFFFFFFU, 0x00000200U);
1167 psu_mask_write(0xFD080180, 0xFFFFFFFFU, 0x00000630U);
1168 psu_mask_write(0xFD080184, 0xFFFFFFFFU, 0x00000301U);
1169 psu_mask_write(0xFD080188, 0xFFFFFFFFU, 0x00000010U);
1170 psu_mask_write(0xFD08018C, 0xFFFFFFFFU, 0x00000200U);
1171 psu_mask_write(0xFD080190, 0xFFFFFFFFU, 0x00000000U);
1172 psu_mask_write(0xFD080194, 0xFFFFFFFFU, 0x000006C0U);
1173 psu_mask_write(0xFD080198, 0xFFFFFFFFU, 0x00000819U);
1174 psu_mask_write(0xFD0801AC, 0xFFFFFFFFU, 0x00000000U);
1175 psu_mask_write(0xFD0801B0, 0xFFFFFFFFU, 0x0000004DU);
1176 psu_mask_write(0xFD0801B4, 0xFFFFFFFFU, 0x00000008U);
1177 psu_mask_write(0xFD0801B8, 0xFFFFFFFFU, 0x0000004DU);
1178 psu_mask_write(0xFD0801D8, 0xFFFFFFFFU, 0x00000000U);
1179 psu_mask_write(0xFD080200, 0xFFFFFFFFU, 0x800091C7U);
1180 psu_mask_write(0xFD080204, 0xFFFFFFFFU, 0x00010236U);
1181 psu_mask_write(0xFD080240, 0xFFFFFFFFU, 0x00141054U);
1182 psu_mask_write(0xFD080250, 0xFFFFFFFFU, 0x00088000U);
1183 psu_mask_write(0xFD080414, 0xFFFFFFFFU, 0x12341000U);
1184 psu_mask_write(0xFD0804F4, 0xFFFFFFFFU, 0x00000005U);
1185 psu_mask_write(0xFD080500, 0xFFFFFFFFU, 0x30000028U);
1186 psu_mask_write(0xFD080508, 0xFFFFFFFFU, 0x0A000000U);
1187 psu_mask_write(0xFD08050C, 0xFFFFFFFFU, 0x00000009U);
1188 psu_mask_write(0xFD080510, 0xFFFFFFFFU, 0x0A000000U);
1189 psu_mask_write(0xFD080520, 0xFFFFFFFFU, 0x0300B0CEU);
1190 psu_mask_write(0xFD080528, 0xFFFFFFFFU, 0xF9032019U);
1191 psu_mask_write(0xFD08052C, 0xFFFFFFFFU, 0x07F001E3U);
1192 psu_mask_write(0xFD080544, 0xFFFFFFFFU, 0x00000000U);
1193 psu_mask_write(0xFD080548, 0xFFFFFFFFU, 0x00000000U);
1194 psu_mask_write(0xFD080558, 0xFFFFFFFFU, 0x00000000U);
1195 psu_mask_write(0xFD08055C, 0xFFFFFFFFU, 0x00000000U);
1196 psu_mask_write(0xFD080560, 0xFFFFFFFFU, 0x00000000U);
1197 psu_mask_write(0xFD080564, 0xFFFFFFFFU, 0x00000000U);
1198 psu_mask_write(0xFD080680, 0xFFFFFFFFU, 0x008A8A58U);
1199 psu_mask_write(0xFD080684, 0xFFFFFFFFU, 0x000079DDU);
1200 psu_mask_write(0xFD080694, 0xFFFFFFFFU, 0x01E10210U);
1201 psu_mask_write(0xFD080698, 0xFFFFFFFFU, 0x01E10000U);
1202 psu_mask_write(0xFD0806A4, 0xFFFFFFFFU, 0x00087BDBU);
1203 psu_mask_write(0xFD080700, 0xFFFFFFFFU, 0x40800604U);
1204 psu_mask_write(0xFD080704, 0xFFFFFFFFU, 0x00007FFFU);
1205 psu_mask_write(0xFD08070C, 0xFFFFFFFFU, 0x3F000008U);
1206 psu_mask_write(0xFD080710, 0xFFFFFFFFU, 0x0E00B03CU);
1207 psu_mask_write(0xFD080714, 0xFFFFFFFFU, 0x09095555U);
1208 psu_mask_write(0xFD080718, 0xFFFFFFFFU, 0x09092B2BU);
1209 psu_mask_write(0xFD080800, 0xFFFFFFFFU, 0x40800604U);
1210 psu_mask_write(0xFD080804, 0xFFFFFFFFU, 0x00007FFFU);
1211 psu_mask_write(0xFD08080C, 0xFFFFFFFFU, 0x3F000008U);
1212 psu_mask_write(0xFD080810, 0xFFFFFFFFU, 0x0E00B03CU);
1213 psu_mask_write(0xFD080814, 0xFFFFFFFFU, 0x09095555U);
1214 psu_mask_write(0xFD080818, 0xFFFFFFFFU, 0x09092B2BU);
1215 psu_mask_write(0xFD080900, 0xFFFFFFFFU, 0x40800604U);
1216 psu_mask_write(0xFD080904, 0xFFFFFFFFU, 0x00007FFFU);
1217 psu_mask_write(0xFD08090C, 0xFFFFFFFFU, 0x3F000008U);
1218 psu_mask_write(0xFD080910, 0xFFFFFFFFU, 0x0E00B004U);
1219 psu_mask_write(0xFD080914, 0xFFFFFFFFU, 0x09095555U);
1220 psu_mask_write(0xFD080918, 0xFFFFFFFFU, 0x09092B2BU);
1221 psu_mask_write(0xFD080A00, 0xFFFFFFFFU, 0x40800604U);
1222 psu_mask_write(0xFD080A04, 0xFFFFFFFFU, 0x00007FFFU);
1223 psu_mask_write(0xFD080A0C, 0xFFFFFFFFU, 0x3F000008U);
1224 psu_mask_write(0xFD080A10, 0xFFFFFFFFU, 0x0E00B004U);
1225 psu_mask_write(0xFD080A14, 0xFFFFFFFFU, 0x09095555U);
1226 psu_mask_write(0xFD080A18, 0xFFFFFFFFU, 0x09092B2BU);
1227 psu_mask_write(0xFD080B00, 0xFFFFFFFFU, 0x40800604U);
1228 psu_mask_write(0xFD080B04, 0xFFFFFFFFU, 0x00007FFFU);
1229 psu_mask_write(0xFD080B08, 0xFFFFFFFFU, 0x00000000U);
1230 psu_mask_write(0xFD080B0C, 0xFFFFFFFFU, 0x3F000008U);
1231 psu_mask_write(0xFD080B10, 0xFFFFFFFFU, 0x0E00B004U);
1232 psu_mask_write(0xFD080B14, 0xFFFFFFFFU, 0x09095555U);
1233 psu_mask_write(0xFD080B18, 0xFFFFFFFFU, 0x09092B2BU);
1234 psu_mask_write(0xFD080C00, 0xFFFFFFFFU, 0x40800604U);
1235 psu_mask_write(0xFD080C04, 0xFFFFFFFFU, 0x00007FFFU);
1236 psu_mask_write(0xFD080C08, 0xFFFFFFFFU, 0x00000000U);
1237 psu_mask_write(0xFD080C0C, 0xFFFFFFFFU, 0x3F000008U);
1238 psu_mask_write(0xFD080C10, 0xFFFFFFFFU, 0x0E00B03CU);
1239 psu_mask_write(0xFD080C14, 0xFFFFFFFFU, 0x09095555U);
1240 psu_mask_write(0xFD080C18, 0xFFFFFFFFU, 0x09092B2BU);
1241 psu_mask_write(0xFD080D00, 0xFFFFFFFFU, 0x40800604U);
1242 psu_mask_write(0xFD080D04, 0xFFFFFFFFU, 0x00007FFFU);
1243 psu_mask_write(0xFD080D08, 0xFFFFFFFFU, 0x00000000U);
1244 psu_mask_write(0xFD080D0C, 0xFFFFFFFFU, 0x3F000008U);
1245 psu_mask_write(0xFD080D10, 0xFFFFFFFFU, 0x0E00B004U);
1246 psu_mask_write(0xFD080D14, 0xFFFFFFFFU, 0x09095555U);
1247 psu_mask_write(0xFD080D18, 0xFFFFFFFFU, 0x09092B2BU);
1248 psu_mask_write(0xFD080E00, 0xFFFFFFFFU, 0x40800604U);
1249 psu_mask_write(0xFD080E04, 0xFFFFFFFFU, 0x00007FFFU);
1250 psu_mask_write(0xFD080E08, 0xFFFFFFFFU, 0x00000000U);
1251 psu_mask_write(0xFD080E0C, 0xFFFFFFFFU, 0x3F000008U);
1252 psu_mask_write(0xFD080E10, 0xFFFFFFFFU, 0x0E00B03CU);
1253 psu_mask_write(0xFD080E14, 0xFFFFFFFFU, 0x09095555U);
1254 psu_mask_write(0xFD080E18, 0xFFFFFFFFU, 0x09092B2BU);
1255 psu_mask_write(0xFD080F00, 0xFFFFFFFFU, 0x80803660U);
1256 psu_mask_write(0xFD080F04, 0xFFFFFFFFU, 0x55556000U);
1257 psu_mask_write(0xFD080F08, 0xFFFFFFFFU, 0xAAAAAAAAU);
1258 psu_mask_write(0xFD080F0C, 0xFFFFFFFFU, 0x0029A4A4U);
1259 psu_mask_write(0xFD080F10, 0xFFFFFFFFU, 0x0C00B000U);
1260 psu_mask_write(0xFD080F14, 0xFFFFFFFFU, 0x09095555U);
1261 psu_mask_write(0xFD080F18, 0xFFFFFFFFU, 0x09092B2BU);
1262 psu_mask_write(0xFD081400, 0xFFFFFFFFU, 0x2A019FFEU);
1263 psu_mask_write(0xFD081404, 0xFFFFFFFFU, 0x01100000U);
1264 psu_mask_write(0xFD08141C, 0xFFFFFFFFU, 0x01264300U);
1265 psu_mask_write(0xFD08142C, 0xFFFFFFFFU, 0x00041800U);
1266 psu_mask_write(0xFD081430, 0xFFFFFFFFU, 0x70800000U);
1267 psu_mask_write(0xFD081440, 0xFFFFFFFFU, 0x2A019FFEU);
1268 psu_mask_write(0xFD081444, 0xFFFFFFFFU, 0x01100000U);
1269 psu_mask_write(0xFD08145C, 0xFFFFFFFFU, 0x01264300U);
1270 psu_mask_write(0xFD08146C, 0xFFFFFFFFU, 0x00041800U);
1271 psu_mask_write(0xFD081470, 0xFFFFFFFFU, 0x70800000U);
1272 psu_mask_write(0xFD081480, 0xFFFFFFFFU, 0x2A019FFEU);
1273 psu_mask_write(0xFD081484, 0xFFFFFFFFU, 0x01100000U);
1274 psu_mask_write(0xFD08149C, 0xFFFFFFFFU, 0x01264300U);
1275 psu_mask_write(0xFD0814AC, 0xFFFFFFFFU, 0x00041800U);
1276 psu_mask_write(0xFD0814B0, 0xFFFFFFFFU, 0x70800000U);
1277 psu_mask_write(0xFD0814C0, 0xFFFFFFFFU, 0x2A019FFEU);
1278 psu_mask_write(0xFD0814C4, 0xFFFFFFFFU, 0x01100000U);
1279 psu_mask_write(0xFD0814DC, 0xFFFFFFFFU, 0x01264300U);
1280 psu_mask_write(0xFD0814EC, 0xFFFFFFFFU, 0x00041800U);
1281 psu_mask_write(0xFD0814F0, 0xFFFFFFFFU, 0x70800000U);
1282 psu_mask_write(0xFD081500, 0xFFFFFFFFU, 0x15019FFEU);
1283 psu_mask_write(0xFD081504, 0xFFFFFFFFU, 0x21100000U);
1284 psu_mask_write(0xFD08151C, 0xFFFFFFFFU, 0x01266300U);
1285 psu_mask_write(0xFD08152C, 0xFFFFFFFFU, 0x00041800U);
1286 psu_mask_write(0xFD081530, 0xFFFFFFFFU, 0x70400000U);
1287 psu_mask_write(0xFD0817DC, 0xFFFFFFFFU, 0x012643C4U);
1288
1289 return 1;
1290}
Michal Simek0766ef82021-02-17 09:40:38 +01001291
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001292static unsigned long psu_ddr_qos_init_data(void)
1293{
1294 psu_mask_write(0xFD360008, 0x0000000FU, 0x00000000U);
1295 psu_mask_write(0xFD36001C, 0x0000000FU, 0x00000000U);
1296 psu_mask_write(0xFD370008, 0x0000000FU, 0x00000000U);
1297 psu_mask_write(0xFD37001C, 0x0000000FU, 0x00000000U);
1298 psu_mask_write(0xFD380008, 0x0000000FU, 0x00000000U);
1299 psu_mask_write(0xFD38001C, 0x0000000FU, 0x00000000U);
1300 psu_mask_write(0xFD390008, 0x0000000FU, 0x00000000U);
1301 psu_mask_write(0xFD39001C, 0x0000000FU, 0x00000000U);
1302 psu_mask_write(0xFD3A0008, 0x0000000FU, 0x00000000U);
1303 psu_mask_write(0xFD3A001C, 0x0000000FU, 0x00000000U);
1304 psu_mask_write(0xFD3B0008, 0x0000000FU, 0x00000000U);
1305 psu_mask_write(0xFD3B001C, 0x0000000FU, 0x00000000U);
1306 psu_mask_write(0xFF9B0008, 0x0000000FU, 0x00000000U);
1307 psu_mask_write(0xFF9B001C, 0x0000000FU, 0x00000000U);
1308
1309 return 1;
1310}
1311
1312static unsigned long psu_mio_init_data(void)
1313{
1314 psu_mask_write(0xFF180000, 0x000000FEU, 0x00000002U);
1315 psu_mask_write(0xFF180004, 0x000000FEU, 0x00000002U);
1316 psu_mask_write(0xFF180008, 0x000000FEU, 0x00000002U);
1317 psu_mask_write(0xFF18000C, 0x000000FEU, 0x00000002U);
1318 psu_mask_write(0xFF180010, 0x000000FEU, 0x00000002U);
1319 psu_mask_write(0xFF180014, 0x000000FEU, 0x00000002U);
1320 psu_mask_write(0xFF180018, 0x000000FEU, 0x00000002U);
1321 psu_mask_write(0xFF18001C, 0x000000FEU, 0x00000002U);
1322 psu_mask_write(0xFF180020, 0x000000FEU, 0x00000002U);
1323 psu_mask_write(0xFF180024, 0x000000FEU, 0x00000002U);
1324 psu_mask_write(0xFF180028, 0x000000FEU, 0x00000002U);
1325 psu_mask_write(0xFF18002C, 0x000000FEU, 0x00000002U);
1326 psu_mask_write(0xFF180030, 0x000000FEU, 0x00000002U);
1327 psu_mask_write(0xFF180034, 0x000000FEU, 0x00000000U);
1328 psu_mask_write(0xFF180038, 0x000000FEU, 0x00000040U);
1329 psu_mask_write(0xFF18003C, 0x000000FEU, 0x00000040U);
1330 psu_mask_write(0xFF180040, 0x000000FEU, 0x00000040U);
1331 psu_mask_write(0xFF180044, 0x000000FEU, 0x00000040U);
1332 psu_mask_write(0xFF180048, 0x000000FEU, 0x000000C0U);
1333 psu_mask_write(0xFF18004C, 0x000000FEU, 0x000000C0U);
1334 psu_mask_write(0xFF180050, 0x000000FEU, 0x00000000U);
1335 psu_mask_write(0xFF180054, 0x000000FEU, 0x00000000U);
1336 psu_mask_write(0xFF180058, 0x000000FEU, 0x00000000U);
1337 psu_mask_write(0xFF18005C, 0x000000FEU, 0x00000000U);
1338 psu_mask_write(0xFF180060, 0x000000FEU, 0x00000000U);
1339 psu_mask_write(0xFF180064, 0x000000FEU, 0x00000000U);
1340 psu_mask_write(0xFF180068, 0x000000FEU, 0x00000000U);
1341 psu_mask_write(0xFF18006C, 0x000000FEU, 0x00000000U);
1342 psu_mask_write(0xFF180070, 0x000000FEU, 0x00000000U);
1343 psu_mask_write(0xFF180074, 0x000000FEU, 0x00000000U);
1344 psu_mask_write(0xFF180078, 0x000000FEU, 0x00000000U);
1345 psu_mask_write(0xFF18007C, 0x000000FEU, 0x00000000U);
1346 psu_mask_write(0xFF180080, 0x000000FEU, 0x00000008U);
1347 psu_mask_write(0xFF180084, 0x000000FEU, 0x00000008U);
1348 psu_mask_write(0xFF180098, 0x000000FEU, 0x00000000U);
1349 psu_mask_write(0xFF18009C, 0x000000FEU, 0x00000010U);
1350 psu_mask_write(0xFF1800A0, 0x000000FEU, 0x00000010U);
1351 psu_mask_write(0xFF1800A4, 0x000000FEU, 0x00000010U);
1352 psu_mask_write(0xFF1800A8, 0x000000FEU, 0x00000010U);
1353 psu_mask_write(0xFF1800AC, 0x000000FEU, 0x00000000U);
1354 psu_mask_write(0xFF1800B0, 0x000000FEU, 0x00000000U);
1355 psu_mask_write(0xFF1800B4, 0x000000FEU, 0x00000010U);
1356 psu_mask_write(0xFF1800B8, 0x000000FEU, 0x00000010U);
1357 psu_mask_write(0xFF1800BC, 0x000000FEU, 0x00000010U);
1358 psu_mask_write(0xFF1800C0, 0x000000FEU, 0x00000010U);
1359 psu_mask_write(0xFF1800C4, 0x000000FEU, 0x00000010U);
1360 psu_mask_write(0xFF1800C8, 0x000000FEU, 0x00000010U);
1361 psu_mask_write(0xFF1800CC, 0x000000FEU, 0x00000010U);
1362 psu_mask_write(0xFF1800D0, 0x000000FEU, 0x00000004U);
1363 psu_mask_write(0xFF1800D4, 0x000000FEU, 0x00000004U);
1364 psu_mask_write(0xFF1800D8, 0x000000FEU, 0x00000004U);
1365 psu_mask_write(0xFF1800DC, 0x000000FEU, 0x00000004U);
1366 psu_mask_write(0xFF1800E0, 0x000000FEU, 0x00000004U);
1367 psu_mask_write(0xFF1800E4, 0x000000FEU, 0x00000004U);
1368 psu_mask_write(0xFF1800E8, 0x000000FEU, 0x00000004U);
1369 psu_mask_write(0xFF1800EC, 0x000000FEU, 0x00000004U);
1370 psu_mask_write(0xFF1800F0, 0x000000FEU, 0x00000004U);
1371 psu_mask_write(0xFF1800F4, 0x000000FEU, 0x00000004U);
1372 psu_mask_write(0xFF1800F8, 0x000000FEU, 0x00000004U);
1373 psu_mask_write(0xFF1800FC, 0x000000FEU, 0x00000004U);
1374 psu_mask_write(0xFF180100, 0x000000FEU, 0x00000002U);
1375 psu_mask_write(0xFF180104, 0x000000FEU, 0x00000002U);
1376 psu_mask_write(0xFF180108, 0x000000FEU, 0x00000002U);
1377 psu_mask_write(0xFF18010C, 0x000000FEU, 0x00000002U);
1378 psu_mask_write(0xFF180110, 0x000000FEU, 0x00000002U);
1379 psu_mask_write(0xFF180114, 0x000000FEU, 0x00000002U);
1380 psu_mask_write(0xFF180118, 0x000000FEU, 0x00000002U);
1381 psu_mask_write(0xFF18011C, 0x000000FEU, 0x00000002U);
1382 psu_mask_write(0xFF180120, 0x000000FEU, 0x00000002U);
1383 psu_mask_write(0xFF180124, 0x000000FEU, 0x00000002U);
1384 psu_mask_write(0xFF180128, 0x000000FEU, 0x00000002U);
1385 psu_mask_write(0xFF18012C, 0x000000FEU, 0x00000002U);
1386 psu_mask_write(0xFF180130, 0x000000FEU, 0x000000C0U);
1387 psu_mask_write(0xFF180134, 0x000000FEU, 0x000000C0U);
1388 psu_mask_write(0xFF180204, 0xFFFFFFFFU, 0x00040000U);
1389 psu_mask_write(0xFF180208, 0xFFFFFFFFU, 0x00B02000U);
1390 psu_mask_write(0xFF18020C, 0x00003FFFU, 0x00000FC0U);
1391 psu_mask_write(0xFF180138, 0x03FFFFFFU, 0x03FFFFFFU);
1392 psu_mask_write(0xFF18013C, 0x03FFFFFFU, 0x03FFFFFFU);
1393 psu_mask_write(0xFF180140, 0x03FFFFFFU, 0x00000000U);
1394 psu_mask_write(0xFF180144, 0x03FFFFFFU, 0x03FFFFFFU);
1395 psu_mask_write(0xFF180148, 0x03FFFFFFU, 0x03FFFFFFU);
1396 psu_mask_write(0xFF18014C, 0x03FFFFFFU, 0x00000000U);
1397 psu_mask_write(0xFF180154, 0x03FFFFFFU, 0x03FFFFFFU);
1398 psu_mask_write(0xFF180158, 0x03FFFFFFU, 0x03FFFFFFU);
1399 psu_mask_write(0xFF18015C, 0x03FFFFFFU, 0x00000000U);
1400 psu_mask_write(0xFF180160, 0x03FFFFFFU, 0x03FFFFFFU);
1401 psu_mask_write(0xFF180164, 0x03FFFFFFU, 0x03FFFFFFU);
1402 psu_mask_write(0xFF180168, 0x03FFFFFFU, 0x00000000U);
1403 psu_mask_write(0xFF180170, 0x03FFFFFFU, 0x03FFFFFFU);
1404 psu_mask_write(0xFF180174, 0x03FFFFFFU, 0x03FFFFFFU);
1405 psu_mask_write(0xFF180178, 0x03FFFFFFU, 0x00000000U);
1406 psu_mask_write(0xFF18017C, 0x03FFFFFFU, 0x03FFFFFFU);
1407 psu_mask_write(0xFF180180, 0x03FFFFFFU, 0x03FFFFFFU);
1408 psu_mask_write(0xFF180184, 0x03FFFFFFU, 0x00000000U);
1409 psu_mask_write(0xFF180200, 0x0000000FU, 0x00000000U);
1410
Michal Simek0766ef82021-02-17 09:40:38 +01001411 return 1;
1412}
1413
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001414static unsigned long psu_peripherals_pre_init_data(void)
Michal Simek0766ef82021-02-17 09:40:38 +01001415{
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001416 psu_mask_write(0xFF5E0108, 0x013F3F07U, 0x01012302U);
1417 psu_mask_write(0xFF5E0238, 0x00000001U, 0x00000001U);
Michal Simek0766ef82021-02-17 09:40:38 +01001418
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001419 return 1;
1420}
Michal Simek0766ef82021-02-17 09:40:38 +01001421
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001422static unsigned long psu_peripherals_init_data(void)
1423{
1424 psu_mask_write(0xFD1A0100, 0x00008046U, 0x00000000U);
1425 psu_mask_write(0xFF5E0238, 0x001A0000U, 0x00000000U);
1426 psu_mask_write(0xFF5E023C, 0x0093C018U, 0x00000000U);
1427 psu_mask_write(0xFF5E0230, 0x00000008U, 0x00000000U);
1428 psu_mask_write(0xFF5E0238, 0x00000001U, 0x00000000U);
1429 psu_mask_write(0xFF180390, 0x00000004U, 0x00000004U);
1430 psu_mask_write(0xFF5E023C, 0x00000400U, 0x00000000U);
1431 psu_mask_write(0xFF5E0238, 0x00000040U, 0x00000000U);
1432 psu_mask_write(0xFF180310, 0x00008000U, 0x00000000U);
1433 psu_mask_write(0xFF180320, 0x33840000U, 0x02840000U);
1434 psu_mask_write(0xFF18031C, 0x7FFE0000U, 0x64500000U);
1435 psu_mask_write(0xFF180358, 0x00000008U, 0x00000008U);
1436 psu_mask_write(0xFF180324, 0x03C00000U, 0x00000000U);
1437 psu_mask_write(0xFF5E0238, 0x00000600U, 0x00000000U);
1438 psu_mask_write(0xFF5E0238, 0x00008000U, 0x00000000U);
1439 psu_mask_write(0xFF5E0238, 0x00007800U, 0x00000000U);
1440 psu_mask_write(0xFF5E0238, 0x00000002U, 0x00000000U);
1441 psu_mask_write(0xFF5E0238, 0x00040000U, 0x00000000U);
1442 psu_mask_write(0xFF4B0024, 0x000000FFU, 0x000000FFU);
1443 psu_mask_write(0xFFCA5000, 0x00001FFFU, 0x00000000U);
1444 psu_mask_write(0xFD5C0060, 0x000F000FU, 0x00000000U);
1445 psu_mask_write(0xFFA60040, 0x80000000U, 0x80000000U);
1446 psu_mask_write(0xFF260020, 0xFFFFFFFFU, 0x05F5DD18U);
1447 psu_mask_write(0xFF260000, 0x00000001U, 0x00000001U);
1448 psu_mask_write(0xFF5E0250, 0x00000F0FU, 0x00000202U);
1449
1450 mask_delay(1);
1451 psu_mask_write(0xFF5E0250, 0x00000F0FU, 0x00000002U);
1452
1453 mask_delay(5);
1454 psu_mask_write(0xFF5E0250, 0x00000F0FU, 0x00000202U);
1455
1456 return 1;
1457}
1458
1459static unsigned long psu_serdes_init_data(void)
1460{
1461 psu_mask_write(0xFD410008, 0x0000001FU, 0x00000008U);
1462 psu_mask_write(0xFD41000C, 0x0000001FU, 0x0000000FU);
1463 psu_mask_write(0xFD402868, 0x00000080U, 0x00000080U);
1464 psu_mask_write(0xFD40286C, 0x00000080U, 0x00000080U);
1465 psu_mask_write(0xFD40A094, 0x00000010U, 0x00000010U);
1466 psu_mask_write(0xFD40A368, 0x000000FFU, 0x00000038U);
1467 psu_mask_write(0xFD40A36C, 0x00000007U, 0x00000003U);
1468 psu_mask_write(0xFD40E368, 0x000000FFU, 0x000000E0U);
1469 psu_mask_write(0xFD40E36C, 0x00000007U, 0x00000003U);
1470 psu_mask_write(0xFD40A370, 0x000000FFU, 0x000000F4U);
1471 psu_mask_write(0xFD40A374, 0x000000FFU, 0x00000031U);
1472 psu_mask_write(0xFD40A378, 0x000000FFU, 0x00000002U);
1473 psu_mask_write(0xFD40A37C, 0x00000033U, 0x00000030U);
1474 psu_mask_write(0xFD40E370, 0x000000FFU, 0x000000C9U);
1475 psu_mask_write(0xFD40E374, 0x000000FFU, 0x000000D2U);
1476 psu_mask_write(0xFD40E378, 0x000000FFU, 0x00000001U);
1477 psu_mask_write(0xFD40E37C, 0x000000B3U, 0x000000B0U);
1478 psu_mask_write(0xFD40906C, 0x00000003U, 0x00000003U);
1479 psu_mask_write(0xFD4080F4, 0x00000003U, 0x00000003U);
1480 psu_mask_write(0xFD40E360, 0x00000040U, 0x00000040U);
1481 psu_mask_write(0xFD40D06C, 0x0000000FU, 0x0000000FU);
1482 psu_mask_write(0xFD40C0F4, 0x0000000BU, 0x0000000BU);
1483 psu_mask_write(0xFD4090CC, 0x00000020U, 0x00000020U);
1484 psu_mask_write(0xFD401074, 0x00000010U, 0x00000010U);
1485 psu_mask_write(0xFD405074, 0x00000010U, 0x00000010U);
1486 psu_mask_write(0xFD409074, 0x00000010U, 0x00000010U);
1487 psu_mask_write(0xFD40D074, 0x00000010U, 0x00000010U);
1488 psu_mask_write(0xFD401994, 0x00000007U, 0x00000007U);
1489 psu_mask_write(0xFD405994, 0x00000007U, 0x00000007U);
1490 psu_mask_write(0xFD40989C, 0x00000080U, 0x00000080U);
1491 psu_mask_write(0xFD4098F8, 0x000000FFU, 0x0000001AU);
1492 psu_mask_write(0xFD4098FC, 0x000000FFU, 0x0000001AU);
1493 psu_mask_write(0xFD409990, 0x000000FFU, 0x00000010U);
1494 psu_mask_write(0xFD409924, 0x000000FFU, 0x000000FEU);
1495 psu_mask_write(0xFD409928, 0x000000FFU, 0x00000000U);
1496 psu_mask_write(0xFD409900, 0x000000FFU, 0x0000001AU);
1497 psu_mask_write(0xFD40992C, 0x000000FFU, 0x00000000U);
1498 psu_mask_write(0xFD409980, 0x000000FFU, 0x000000FFU);
1499 psu_mask_write(0xFD409914, 0x000000FFU, 0x000000F7U);
1500 psu_mask_write(0xFD409918, 0x00000001U, 0x00000001U);
1501 psu_mask_write(0xFD409940, 0x000000FFU, 0x000000F7U);
1502 psu_mask_write(0xFD409944, 0x00000001U, 0x00000001U);
1503 psu_mask_write(0xFD409994, 0x00000007U, 0x00000007U);
1504 psu_mask_write(0xFD40D89C, 0x00000080U, 0x00000080U);
1505 psu_mask_write(0xFD40D8F8, 0x000000FFU, 0x0000007DU);
1506 psu_mask_write(0xFD40D8FC, 0x000000FFU, 0x0000007DU);
1507 psu_mask_write(0xFD40D990, 0x000000FFU, 0x00000001U);
1508 psu_mask_write(0xFD40D924, 0x000000FFU, 0x0000009CU);
1509 psu_mask_write(0xFD40D928, 0x000000FFU, 0x00000039U);
1510 psu_mask_write(0xFD40D98C, 0x000000F0U, 0x00000020U);
1511 psu_mask_write(0xFD40D900, 0x000000FFU, 0x0000007DU);
1512 psu_mask_write(0xFD40D92C, 0x000000FFU, 0x00000064U);
1513 psu_mask_write(0xFD40D980, 0x000000FFU, 0x000000FFU);
1514 psu_mask_write(0xFD40D914, 0x000000FFU, 0x000000F7U);
1515 psu_mask_write(0xFD40D918, 0x00000001U, 0x00000001U);
1516 psu_mask_write(0xFD40D940, 0x000000FFU, 0x000000F7U);
1517 psu_mask_write(0xFD40D944, 0x00000001U, 0x00000001U);
1518 psu_mask_write(0xFD40D994, 0x00000007U, 0x00000007U);
1519 psu_mask_write(0xFD40107C, 0x0000000FU, 0x00000001U);
1520 psu_mask_write(0xFD40507C, 0x0000000FU, 0x00000001U);
1521 psu_mask_write(0xFD40907C, 0x0000000FU, 0x00000001U);
1522 psu_mask_write(0xFD40D07C, 0x0000000FU, 0x00000001U);
1523 psu_mask_write(0xFD4019A4, 0x000000FFU, 0x000000FFU);
1524 psu_mask_write(0xFD401038, 0x00000040U, 0x00000040U);
1525 psu_mask_write(0xFD40102C, 0x00000040U, 0x00000040U);
1526 psu_mask_write(0xFD4059A4, 0x000000FFU, 0x000000FFU);
1527 psu_mask_write(0xFD405038, 0x00000040U, 0x00000040U);
1528 psu_mask_write(0xFD40502C, 0x00000040U, 0x00000040U);
1529 psu_mask_write(0xFD4099A4, 0x000000FFU, 0x000000FFU);
1530 psu_mask_write(0xFD409038, 0x00000040U, 0x00000040U);
1531 psu_mask_write(0xFD40902C, 0x00000040U, 0x00000040U);
1532 psu_mask_write(0xFD40D9A4, 0x000000FFU, 0x000000FFU);
1533 psu_mask_write(0xFD40D038, 0x00000040U, 0x00000040U);
1534 psu_mask_write(0xFD40D02C, 0x00000040U, 0x00000040U);
1535 psu_mask_write(0xFD4019AC, 0x00000003U, 0x00000000U);
1536 psu_mask_write(0xFD4059AC, 0x00000003U, 0x00000000U);
1537 psu_mask_write(0xFD4099AC, 0x00000003U, 0x00000000U);
1538 psu_mask_write(0xFD40D9AC, 0x00000003U, 0x00000000U);
1539 psu_mask_write(0xFD401978, 0x00000010U, 0x00000010U);
1540 psu_mask_write(0xFD405978, 0x00000010U, 0x00000010U);
1541 psu_mask_write(0xFD409978, 0x00000010U, 0x00000010U);
1542 psu_mask_write(0xFD40D978, 0x00000010U, 0x00000010U);
1543
1544 serdes_illcalib(2, 3, 3, 0, 0, 0, 0, 0);
1545 psu_mask_write(0xFD410014, 0x00000077U, 0x00000023U);
1546 psu_mask_write(0xFD40C1D8, 0x00000001U, 0x00000001U);
1547 psu_mask_write(0xFD40DC14, 0x000000FFU, 0x000000E6U);
1548 psu_mask_write(0xFD40DC40, 0x0000001FU, 0x0000000CU);
1549 psu_mask_write(0xFD40D94C, 0x00000020U, 0x00000020U);
1550 psu_mask_write(0xFD40D950, 0x00000007U, 0x00000006U);
1551 psu_mask_write(0xFD40C048, 0x000000FFU, 0x00000001U);
1552
1553 return 1;
1554}
1555
1556static unsigned long psu_resetout_init_data(void)
1557{
1558 psu_mask_write(0xFF5E023C, 0x00000400U, 0x00000000U);
1559 psu_mask_write(0xFF9D0080, 0x00000001U, 0x00000001U);
1560 psu_mask_write(0xFF9D007C, 0x00000001U, 0x00000000U);
1561 psu_mask_write(0xFF5E023C, 0x00000140U, 0x00000000U);
1562 psu_mask_write(0xFF5E0230, 0x00000008U, 0x00000000U);
1563 psu_mask_write(0xFD3D0100, 0x00000003U, 0x00000003U);
1564 psu_mask_write(0xFD1A0100, 0x00000002U, 0x00000000U);
1565 psu_mask_write(0xFE20C200, 0x00023FFFU, 0x00022457U);
1566 psu_mask_write(0xFE20C630, 0x003FFF00U, 0x00000000U);
1567 psu_mask_write(0xFE20C11C, 0x00000600U, 0x00000600U);
1568 psu_mask_write(0xFE20C12C, 0x00004000U, 0x00004000U);
1569 psu_mask_write(0xFD480064, 0x00000200U, 0x00000200U);
1570 mask_poll(0xFD40A3E4, 0x00000010U);
1571 mask_poll(0xFD40E3E4, 0x00000010U);
1572 psu_mask_write(0xFD0C00AC, 0xFFFFFFFFU, 0x28184018U);
1573 psu_mask_write(0xFD0C00B0, 0xFFFFFFFFU, 0x0E081406U);
1574 psu_mask_write(0xFD0C00B4, 0xFFFFFFFFU, 0x064A0813U);
1575 psu_mask_write(0xFD0C00B8, 0xFFFFFFFFU, 0x3FFC96A4U);
Michal Simek0766ef82021-02-17 09:40:38 +01001576
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001577 return 1;
1578}
Michal Simek0766ef82021-02-17 09:40:38 +01001579
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001580static unsigned long psu_resetin_init_data(void)
1581{
1582 psu_mask_write(0xFF5E023C, 0x00000540U, 0x00000540U);
1583 psu_mask_write(0xFF5E0230, 0x00000008U, 0x00000008U);
1584 psu_mask_write(0xFD1A0100, 0x00000002U, 0x00000002U);
Michal Simek0766ef82021-02-17 09:40:38 +01001585
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001586 return 1;
1587}
Michal Simek0766ef82021-02-17 09:40:38 +01001588
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001589static unsigned long psu_afi_config(void)
1590{
1591 psu_mask_write(0xFD1A0100, 0x00001F80U, 0x00000000U);
1592 psu_mask_write(0xFF5E023C, 0x00080000U, 0x00000000U);
1593 psu_mask_write(0xFD615000, 0x00000300U, 0x00000200U);
1594 psu_mask_write(0xFD360000, 0x00000003U, 0x00000002U);
1595 psu_mask_write(0xFD370000, 0x00000003U, 0x00000002U);
1596 psu_mask_write(0xFD360014, 0x00000003U, 0x00000002U);
1597 psu_mask_write(0xFD370014, 0x00000003U, 0x00000002U);
Michal Simek0766ef82021-02-17 09:40:38 +01001598
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001599 return 1;
1600}
Michal Simek0766ef82021-02-17 09:40:38 +01001601
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001602static unsigned long psu_ddr_phybringup_data(void)
1603{
1604 unsigned int regval = 0;
1605 unsigned int pll_retry = 10;
1606 unsigned int pll_locked = 0;
1607 int cur_R006_tREFPRD;
Michal Simek0766ef82021-02-17 09:40:38 +01001608
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001609 while ((pll_retry > 0) && (!pll_locked)) {
1610 Xil_Out32(0xFD080004, 0x00040010);
1611 Xil_Out32(0xFD080004, 0x00040011);
Michal Simek0766ef82021-02-17 09:40:38 +01001612
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001613 while ((Xil_In32(0xFD080030) & 0x1) != 1)
1614 ;
1615 pll_locked = (Xil_In32(0xFD080030) & 0x80000000)
1616 >> 31;
1617 pll_locked &= (Xil_In32(0xFD0807E0) & 0x10000)
1618 >> 16;
1619 pll_locked &= (Xil_In32(0xFD0809E0) & 0x10000) >> 16;
1620 pll_locked &= (Xil_In32(0xFD080BE0) & 0x10000)
1621 >> 16;
1622 pll_locked &= (Xil_In32(0xFD080DE0) & 0x10000)
1623 >> 16;
1624 pll_retry--;
Michal Simek0766ef82021-02-17 09:40:38 +01001625 }
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001626 Xil_Out32(0xFD0800C4, Xil_In32(0xFD0800C4) | (pll_retry << 16));
1627 if (!pll_locked)
1628 return 0;
Michal Simek0766ef82021-02-17 09:40:38 +01001629
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001630 Xil_Out32(0xFD080004U, 0x00040063U);
Michal Simek0766ef82021-02-17 09:40:38 +01001631
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001632 while ((Xil_In32(0xFD080030U) & 0x0000000FU) != 0x0000000FU)
1633 ;
1634 prog_reg(0xFD080004U, 0x00000001U, 0x00000000U, 0x00000001U);
Michal Simek0766ef82021-02-17 09:40:38 +01001635
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001636 while ((Xil_In32(0xFD080030U) & 0x000000FFU) != 0x0000001FU)
1637 ;
1638 Xil_Out32(0xFD0701B0U, 0x00000001U);
1639 Xil_Out32(0xFD070320U, 0x00000001U);
1640 while ((Xil_In32(0xFD070004U) & 0x0000000FU) != 0x00000001U)
1641 ;
1642 prog_reg(0xFD080014U, 0x00000040U, 0x00000006U, 0x00000001U);
1643 Xil_Out32(0xFD080004, 0x0004FE01);
1644 regval = Xil_In32(0xFD080030);
1645 while (regval != 0x80000FFF)
1646 regval = Xil_In32(0xFD080030);
1647 regval = ((Xil_In32(0xFD080030) & 0x1FFF0000) >> 18);
1648 if (regval != 0)
1649 return 0;
Michal Simek0766ef82021-02-17 09:40:38 +01001650
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001651 Xil_Out32(0xFD080200U, 0x100091C7U);
Michal Simek0766ef82021-02-17 09:40:38 +01001652
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001653 cur_R006_tREFPRD = (Xil_In32(0xFD080018U) & 0x0003FFFFU) >> 0x00000000U;
1654 prog_reg(0xFD080018, 0x3FFFF, 0x0, cur_R006_tREFPRD);
Michal Simek0766ef82021-02-17 09:40:38 +01001655
Stefan Herbrechtsmeierfd6d5112022-06-20 18:36:50 +02001656 prog_reg(0xFD08001CU, 0x00000018U, 0x00000003U, 0x00000003U);
1657 prog_reg(0xFD08142CU, 0x00000030U, 0x00000004U, 0x00000003U);
1658 prog_reg(0xFD08146CU, 0x00000030U, 0x00000004U, 0x00000003U);
1659 prog_reg(0xFD0814ACU, 0x00000030U, 0x00000004U, 0x00000003U);
1660 prog_reg(0xFD0814ECU, 0x00000030U, 0x00000004U, 0x00000003U);
1661 prog_reg(0xFD08152CU, 0x00000030U, 0x00000004U, 0x00000003U);
1662
1663 Xil_Out32(0xFD080004, 0x00060001);
1664 regval = Xil_In32(0xFD080030);
1665 while ((regval & 0x80004001) != 0x80004001)
1666 regval = Xil_In32(0xFD080030);
1667
1668 regval = ((Xil_In32(0xFD080030) & 0x1FFF0000) >> 18);
1669 if (regval != 0)
1670 return 0;
1671
1672 prog_reg(0xFD08001CU, 0x00000018U, 0x00000003U, 0x00000000U);
1673 prog_reg(0xFD08142CU, 0x00000030U, 0x00000004U, 0x00000000U);
1674 prog_reg(0xFD08146CU, 0x00000030U, 0x00000004U, 0x00000000U);
1675 prog_reg(0xFD0814ACU, 0x00000030U, 0x00000004U, 0x00000000U);
1676 prog_reg(0xFD0814ECU, 0x00000030U, 0x00000004U, 0x00000000U);
1677 prog_reg(0xFD08152CU, 0x00000030U, 0x00000004U, 0x00000000U);
1678
1679 Xil_Out32(0xFD080200U, 0x800091C7U);
1680 prog_reg(0xFD080018, 0x3FFFF, 0x0, cur_R006_tREFPRD);
1681
1682 Xil_Out32(0xFD080004, 0x0000C001);
1683 regval = Xil_In32(0xFD080030);
1684 while ((regval & 0x80000C01) != 0x80000C01)
1685 regval = Xil_In32(0xFD080030);
1686
1687 Xil_Out32(0xFD070180U, 0x01000040U);
1688 Xil_Out32(0xFD070060U, 0x00000000U);
1689 prog_reg(0xFD080014U, 0x00000040U, 0x00000006U, 0x00000000U);
Michal Simek0766ef82021-02-17 09:40:38 +01001690
1691 return 1;
1692}
1693
1694static int serdes_enb_coarse_saturation(void)
1695{
1696 Xil_Out32(0xFD402094, 0x00000010);
1697 Xil_Out32(0xFD406094, 0x00000010);
1698 Xil_Out32(0xFD40A094, 0x00000010);
1699 Xil_Out32(0xFD40E094, 0x00000010);
1700 return 1;
1701}
1702
1703static int serdes_fixcal_code(void)
1704{
1705 int maskstatus = 1;
1706 unsigned int rdata = 0;
1707 unsigned int match_pmos_code[23];
1708 unsigned int match_nmos_code[23];
1709 unsigned int match_ical_code[7];
1710 unsigned int match_rcal_code[7];
1711 unsigned int p_code = 0;
1712 unsigned int n_code = 0;
1713 unsigned int i_code = 0;
1714 unsigned int r_code = 0;
1715 unsigned int repeat_count = 0;
1716 unsigned int L3_TM_CALIB_DIG20 = 0;
1717 unsigned int L3_TM_CALIB_DIG19 = 0;
1718 unsigned int L3_TM_CALIB_DIG18 = 0;
1719 unsigned int L3_TM_CALIB_DIG16 = 0;
1720 unsigned int L3_TM_CALIB_DIG15 = 0;
1721 unsigned int L3_TM_CALIB_DIG14 = 0;
1722 int i = 0;
1723 int count = 0;
1724
1725 rdata = Xil_In32(0xFD40289C);
1726 rdata = rdata & ~0x03;
1727 rdata = rdata | 0x1;
1728 Xil_Out32(0xFD40289C, rdata);
1729
1730 do {
1731 if (count == 1100000)
1732 break;
1733 rdata = Xil_In32(0xFD402B1C);
1734 count++;
1735 } while ((rdata & 0x0000000E) != 0x0000000E);
1736
1737 for (i = 0; i < 23; i++) {
1738 match_pmos_code[i] = 0;
1739 match_nmos_code[i] = 0;
1740 }
1741 for (i = 0; i < 7; i++) {
1742 match_ical_code[i] = 0;
1743 match_rcal_code[i] = 0;
1744 }
1745
1746 do {
1747 Xil_Out32(0xFD410010, 0x00000000);
1748 Xil_Out32(0xFD410014, 0x00000000);
1749
1750 Xil_Out32(0xFD410010, 0x00000001);
1751 Xil_Out32(0xFD410014, 0x00000000);
1752
1753 maskstatus = mask_poll(0xFD40EF14, 0x2);
1754 if (maskstatus == 0) {
1755 xil_printf("#SERDES initialization timed out\n\r");
1756 return maskstatus;
1757 }
1758
1759 p_code = mask_read(0xFD40EF18, 0xFFFFFFFF);
1760 n_code = mask_read(0xFD40EF1C, 0xFFFFFFFF);
1761 ;
1762 i_code = mask_read(0xFD40EF24, 0xFFFFFFFF);
1763 r_code = mask_read(0xFD40EF28, 0xFFFFFFFF);
1764 ;
1765
1766 if (p_code >= 0x26 && p_code <= 0x3C)
1767 match_pmos_code[p_code - 0x26] += 1;
1768
1769 if (n_code >= 0x26 && n_code <= 0x3C)
1770 match_nmos_code[n_code - 0x26] += 1;
1771
1772 if (i_code >= 0xC && i_code <= 0x12)
1773 match_ical_code[i_code - 0xc] += 1;
1774
1775 if (r_code >= 0x6 && r_code <= 0xC)
1776 match_rcal_code[r_code - 0x6] += 1;
1777
1778 } while (repeat_count++ < 10);
1779
1780 for (i = 0; i < 23; i++) {
1781 if (match_pmos_code[i] >= match_pmos_code[0]) {
1782 match_pmos_code[0] = match_pmos_code[i];
1783 p_code = 0x26 + i;
1784 }
1785 if (match_nmos_code[i] >= match_nmos_code[0]) {
1786 match_nmos_code[0] = match_nmos_code[i];
1787 n_code = 0x26 + i;
1788 }
1789 }
1790
1791 for (i = 0; i < 7; i++) {
1792 if (match_ical_code[i] >= match_ical_code[0]) {
1793 match_ical_code[0] = match_ical_code[i];
1794 i_code = 0xC + i;
1795 }
1796 if (match_rcal_code[i] >= match_rcal_code[0]) {
1797 match_rcal_code[0] = match_rcal_code[i];
1798 r_code = 0x6 + i;
1799 }
1800 }
1801
1802 L3_TM_CALIB_DIG20 = mask_read(0xFD40EC50, 0xFFFFFFF0);
1803 L3_TM_CALIB_DIG20 = L3_TM_CALIB_DIG20 | 0x8 | ((p_code >> 2) & 0x7);
1804
1805 L3_TM_CALIB_DIG19 = mask_read(0xFD40EC4C, 0xFFFFFF18);
1806 L3_TM_CALIB_DIG19 = L3_TM_CALIB_DIG19 | ((p_code & 0x3) << 6)
1807 | 0x20 | 0x4 | ((n_code >> 3) & 0x3);
1808
1809 L3_TM_CALIB_DIG18 = mask_read(0xFD40EC48, 0xFFFFFF0F);
1810 L3_TM_CALIB_DIG18 = L3_TM_CALIB_DIG18 | ((n_code & 0x7) << 5) | 0x10;
1811
1812 L3_TM_CALIB_DIG16 = mask_read(0xFD40EC40, 0xFFFFFFF8);
1813 L3_TM_CALIB_DIG16 = L3_TM_CALIB_DIG16 | ((r_code >> 1) & 0x7);
1814
1815 L3_TM_CALIB_DIG15 = mask_read(0xFD40EC3C, 0xFFFFFF30);
1816 L3_TM_CALIB_DIG15 = L3_TM_CALIB_DIG15 | ((r_code & 0x1) << 7)
1817 | 0x40 | 0x8 | ((i_code >> 1) & 0x7);
1818
1819 L3_TM_CALIB_DIG14 = mask_read(0xFD40EC38, 0xFFFFFF3F);
1820 L3_TM_CALIB_DIG14 = L3_TM_CALIB_DIG14 | ((i_code & 0x1) << 7) | 0x40;
1821
1822 Xil_Out32(0xFD40EC50, L3_TM_CALIB_DIG20);
1823 Xil_Out32(0xFD40EC4C, L3_TM_CALIB_DIG19);
1824 Xil_Out32(0xFD40EC48, L3_TM_CALIB_DIG18);
1825 Xil_Out32(0xFD40EC40, L3_TM_CALIB_DIG16);
1826 Xil_Out32(0xFD40EC3C, L3_TM_CALIB_DIG15);
1827 Xil_Out32(0xFD40EC38, L3_TM_CALIB_DIG14);
1828 return maskstatus;
1829}
1830
1831static int init_serdes(void)
1832{
1833 int status = 1;
1834
1835 status &= psu_resetin_init_data();
1836
1837 status &= serdes_fixcal_code();
1838 status &= serdes_enb_coarse_saturation();
1839
1840 status &= psu_serdes_init_data();
1841 status &= psu_resetout_init_data();
1842
1843 return status;
1844}
1845
1846static void init_peripheral(void)
1847{
1848 psu_mask_write(0xFD5F0018, 0x8000001FU, 0x8000001FU);
1849}
1850
1851int psu_init(void)
1852{
1853 int status = 1;
1854
1855 status &= psu_mio_init_data();
1856 status &= psu_peripherals_pre_init_data();
1857 status &= psu_pll_init_data();
1858 status &= psu_clock_init_data();
1859 status &= psu_ddr_init_data();
1860 status &= psu_ddr_phybringup_data();
1861 status &= psu_peripherals_init_data();
1862 status &= init_serdes();
1863 init_peripheral();
1864
1865 status &= psu_afi_config();
1866 psu_ddr_qos_init_data();
1867
1868 if (status == 0)
1869 return 1;
1870 return 0;
1871}