1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * (C) Copyright 2018 Michal Simek
4 */
5
6 #include <asm/arch/ps7_init_gpl.h>
7
8 static unsigned long ps7_pll_init_data_3_0[] = {
9 EMIT_MASKWRITE(0xf8000008, 0x0000ffff, 0x0000df0d),
10 EMIT_MASKWRITE(0xf8000110, 0x003ffff0, 0x000fa220),
11 EMIT_MASKWRITE(0xf8000100, 0x0007f000, 0x00028000),
12 EMIT_MASKWRITE(0xf8000100, 0x00000010, 0x00000010),
13 EMIT_MASKWRITE(0xf8000100, 0x00000001, 0x00000001),
14 EMIT_MASKWRITE(0xf8000100, 0x00000001, 0x00000000),
15 EMIT_MASKPOLL(0xf800010c, 0x00000001),
16 EMIT_MASKWRITE(0xf8000100, 0x00000010, 0x00000000),
17 EMIT_MASKWRITE(0xf8000120, 0x1f003f30, 0x1f000200),
18 EMIT_MASKWRITE(0xf8000114, 0x003ffff0, 0x0012c220),
19 EMIT_MASKWRITE(0xf8000104, 0x0007f000, 0x00020000),
20 EMIT_MASKWRITE(0xf8000104, 0x00000010, 0x00000010),
21 EMIT_MASKWRITE(0xf8000104, 0x00000001, 0x000000),
22 EMIT_MASKWRITE(0xf8000104, 0x00000001, 0x00000000),
23 EMIT_MASKPOLL(0xf800010c, 0x00000002),
24 EMIT_MASKWRITE(0xf8000104, 0x00000010, 0x00000000),
25 EMIT_MASKWRITE(0xf8000124, 0xfff00003, 0x0c200003),
26 EMIT_MASKWRITE(0xf8000118, 0x003ffff0, 0x001452c0),
27 EMIT_MASKWRITE(0xf8000108, 0x0007f000, 0x0001e000),
28 EMIT_MASKWRITE(0xf8000108, 0x00000010, 0x00000010),
29 EMIT_MASKWRITE(0xf8000108, 0x00000001, 0x00000001),
30 EMIT_MASKWRITE(0xf8000108, 0x00000001, 0x00000000),
31 EMIT_MASKPOLL(0xf800010c, 0x00000004),
32 EMIT_MASKWRITE(0xf8000108, 0x00000010, 0x00000000),
33 EMIT_MASKWRITE(0xf8000004, 0x0000ffff, 0x0000767b),
34 EMIT_EXIT(),
35 };
36
37 static unsigned long ps7_clock_init_data_3_0[] = {
38 EMIT_MASKWRITE(0xf8000008, 0x0000ffff, 0x0000df0d),
39 EMIT_MASKWRITE(0xf8000128, 0x03f03f01, 0x00302301),
40 EMIT_MASKWRITE(0xf8000138, 0x00000011, 0x00000001),
41 EMIT_MASKWRITE(0xf8000140, 0x03f03f71, 0x00100801),
42 EMIT_MASKWRITE(0xf8000148, 0x00003f31, 0x00000a01),
43 EMIT_MASKWRITE(0xf8000150, 0x00003f33, 0x00002801),
44 EMIT_MASKWRITE(0xf8000154, 0x00003f33, 0x00001402),
45 EMIT_MASKWRITE(0xf8000168, 0x00003f31, 0x00000501),
46 EMIT_MASKWRITE(0xf8000170, 0x03f03f30, 0x00101400),
47 EMIT_MASKWRITE(0xf8000180, 0x03f03f30, 0x00100a00),
48 EMIT_MASKWRITE(0xf8000190, 0x03f03f30, 0x00101e00),
49 EMIT_MASKWRITE(0xf80001a0, 0x03f03f30, 0x00101400),
50 EMIT_MASKWRITE(0xf80001c4, 0x00000001, 0x00000001),
51 EMIT_MASKWRITE(0xf800012c, 0x01ffcccd, 0x016c044d),
52 EMIT_MASKWRITE(0xf8000004, 0x0000ffff, 0x0000767b),
53 EMIT_EXIT(),
54 };
55
56 static unsigned long ps7_ddr_init_data_3_0[] = {
57 EMIT_MASKWRITE(0xf8006000, 0x0001ffff, 0x00000080),
58 EMIT_MASKWRITE(0xf8006004, 0x0007ffff, 0x00001081),
59 EMIT_MASKWRITE(0xf8006008, 0x03ffffff, 0x03c0780f),
60 EMIT_MASKWRITE(0xf800600c, 0x03ffffff, 0x02001001),
61 EMIT_MASKWRITE(0xf8006010, 0x03ffffff, 0x00014001),
62 EMIT_MASKWRITE(0xf8006014, 0x001fffff, 0x0004281b),
63 EMIT_MASKWRITE(0xf8006018, 0xf7ffffff, 0x44e458d1),
64 EMIT_MASKWRITE(0xf800601c, 0xffffffff, 0xb2023584),
65 EMIT_MASKWRITE(0xf8006020, 0x7fdffffc, 0x2b08b2d0),
66 EMIT_MASKWRITE(0xf8006024, 0x0fffffc3, 0x00000000),
67 EMIT_MASKWRITE(0xf8006028, 0x00003fff, 0x00002007),
68 EMIT_MASKWRITE(0xf800602c, 0xffffffff, 0x00000000),
69 EMIT_MASKWRITE(0xf8006030, 0xffffffff, 0x00040970),
70 EMIT_MASKWRITE(0xf8006034, 0x13ff3fff, 0x000116d4),
71 EMIT_MASKWRITE(0xf8006038, 0x00000003, 0x00000000),
72 EMIT_MASKWRITE(0xf800603c, 0x000fffff, 0x00000777),
73 EMIT_MASKWRITE(0xf8006040, 0xffffffff, 0xfff00000),
74 EMIT_MASKWRITE(0xf8006044, 0x0fffffff, 0x0f666666),
75 EMIT_MASKWRITE(0xf8006048, 0x0003f03f, 0x0003c008),
76 EMIT_MASKWRITE(0xf8006050, 0xff0f8fff, 0x77010800),
77 EMIT_MASKWRITE(0xf8006058, 0x00010000, 0x00000000),
78 EMIT_MASKWRITE(0xf800605c, 0x0000ffff, 0x00005003),
79 EMIT_MASKWRITE(0xf8006060, 0x000017ff, 0x0000003e),
80 EMIT_MASKWRITE(0xf8006064, 0x00021fe0, 0x00020000),
81 EMIT_MASKWRITE(0xf8006068, 0x03ffffff, 0x00284545),
82 EMIT_MASKWRITE(0xf800606c, 0x0000ffff, 0x00001610),
83 EMIT_MASKWRITE(0xf8006078, 0x03ffffff, 0x00466111),
84 EMIT_MASKWRITE(0xf800607c, 0x000fffff, 0x00032222),
85 EMIT_MASKWRITE(0xf80060a4, 0xffffffff, 0x10200802),
86 EMIT_MASKWRITE(0xf80060a8, 0x0fffffff, 0x0690cb73),
87 EMIT_MASKWRITE(0xf80060ac, 0x000001ff, 0x000001fe),
88 EMIT_MASKWRITE(0xf80060b0, 0x1fffffff, 0x1cffffff),
89 EMIT_MASKWRITE(0xf80060b4, 0x00000200, 0x00000200),
90 EMIT_MASKWRITE(0xf80060b8, 0x01ffffff, 0x0020006a),
91 EMIT_MASKWRITE(0xf80060c4, 0x00000003, 0x00000003),
92 EMIT_MASKWRITE(0xf80060c4, 0x00000003, 0x00000000),
93 EMIT_MASKWRITE(0xf80060c8, 0x000000ff, 0x00000000),
94 EMIT_MASKWRITE(0xf80060dc, 0x00000001, 0x00000000),
95 EMIT_MASKWRITE(0xf80060f0, 0x0000ffff, 0x00000000),
96 EMIT_MASKWRITE(0xf80060f4, 0x0000000f, 0x00000008),
97 EMIT_MASKWRITE(0xf8006114, 0x000000ff, 0x00000000),
98 EMIT_MASKWRITE(0xf8006118, 0x7fffffcf, 0x40000001),
99 EMIT_MASKWRITE(0xf800611c, 0x7fffffcf, 0x40000001),
100 EMIT_MASKWRITE(0xf8006120, 0x7fffffcf, 0x40000001),
101 EMIT_MASKWRITE(0xf8006124, 0x7fffffcf, 0x40000001),
102 EMIT_MASKWRITE(0xf800612c, 0x000fffff, 0x0002c000),
103 EMIT_MASKWRITE(0xf8006130, 0x000fffff, 0x0002c400),
104 EMIT_MASKWRITE(0xf8006134, 0x000fffff, 0x0002f003),
105 EMIT_MASKWRITE(0xf8006138, 0x000fffff, 0x0002ec03),
106 EMIT_MASKWRITE(0xf8006140, 0x000fffff, 0x00000035),
107 EMIT_MASKWRITE(0xf8006144, 0x000fffff, 0x00000035),
108 EMIT_MASKWRITE(0xf8006148, 0x000fffff, 0x00000035),
109 EMIT_MASKWRITE(0xf800614c, 0x000fffff, 0x00000035),
110 EMIT_MASKWRITE(0xf8006154, 0x000fffff, 0x00000077),
111 EMIT_MASKWRITE(0xf8006158, 0x000fffff, 0x00000077),
112 EMIT_MASKWRITE(0xf800615c, 0x000fffff, 0x00000083),
113 EMIT_MASKWRITE(0xf8006160, 0x000fffff, 0x00000083),
114 EMIT_MASKWRITE(0xf8006168, 0x001fffff, 0x00000105),
115 EMIT_MASKWRITE(0xf800616c, 0x001fffff, 0x00000106),
116 EMIT_MASKWRITE(0xf8006170, 0x001fffff, 0x00000111),
117 EMIT_MASKWRITE(0xf8006174, 0x001fffff, 0x00000110),
118 EMIT_MASKWRITE(0xf800617c, 0x000fffff, 0x000000b7),
119 EMIT_MASKWRITE(0xf8006180, 0x000fffff, 0x000000b7),
120 EMIT_MASKWRITE(0xf8006184, 0x000fffff, 0x000000c3),
121 EMIT_MASKWRITE(0xf8006188, 0x000fffff, 0x000000c3),
122 EMIT_MASKWRITE(0xf8006190, 0x6ffffefe, 0x00040080),
123 EMIT_MASKWRITE(0xf8006194, 0x000fffff, 0x0001fd01),
124 EMIT_MASKWRITE(0xf8006204, 0xffffffff, 0x00000000),
125 EMIT_MASKWRITE(0xf8006208, 0x000703ff, 0x000003ff),
126 EMIT_MASKWRITE(0xf800620c, 0x000703ff, 0x000003ff),
127 EMIT_MASKWRITE(0xf8006210, 0x000703ff, 0x000003ff),
128 EMIT_MASKWRITE(0xf8006214, 0x000703ff, 0x000003ff),
129 EMIT_MASKWRITE(0xf8006218, 0x000f03ff, 0x000003ff),
130 EMIT_MASKWRITE(0xf800621c, 0x000f03ff, 0x000003ff),
131 EMIT_MASKWRITE(0xf8006220, 0x000f03ff, 0x000003ff),
132 EMIT_MASKWRITE(0xf8006224, 0x000f03ff, 0x000003ff),
133 EMIT_MASKWRITE(0xf80062a8, 0x00000ff5, 0x00000000),
134 EMIT_MASKWRITE(0xf80062ac, 0xffffffff, 0x00000000),
135 EMIT_MASKWRITE(0xf80062b0, 0x003fffff, 0x00005125),
136 EMIT_MASKWRITE(0xf80062b4, 0x0003ffff, 0x000012a8),
137 EMIT_MASKPOLL(0xf8000b74, 0x00002000),
138 EMIT_MASKWRITE(0xf8006000, 0x0001ffff, 0x00000081),
139 EMIT_MASKPOLL(0xf8006054, 0x00000007),
140 EMIT_EXIT(),
141 };
142
143 static unsigned long ps7_mio_init_data_3_0[] = {
144 EMIT_MASKWRITE(0xf8000008, 0x0000ffff, 0x0000df0d),
145 EMIT_MASKWRITE(0xf8000b40, 0x00000fff, 0x00000600),
146 EMIT_MASKWRITE(0xf8000b44, 0x00000fff, 0x00000600),
147 EMIT_MASKWRITE(0xf8000b48, 0x00000fff, 0x00000672),
148 EMIT_MASKWRITE(0xf8000b4c, 0x00000fff, 0x00000672),
149 EMIT_MASKWRITE(0xf8000b50, 0x00000fff, 0x00000674),
150 EMIT_MASKWRITE(0xf8000b54, 0x00000fff, 0x00000674),
151 EMIT_MASKWRITE(0xf8000b58, 0x00000fff, 0x00000600),
152 EMIT_MASKWRITE(0xf8000b5c, 0xffffffff, 0x0018c068),
153 EMIT_MASKWRITE(0xf8000b60, 0xffffffff, 0x00f98068),
154 EMIT_MASKWRITE(0xf8000b64, 0xffffffff, 0x00f98068),
155 EMIT_MASKWRITE(0xf8000b68, 0xffffffff, 0x00f98068),
156 EMIT_MASKWRITE(0xf8000b6c, 0x00007fff, 0x00000205),
157 EMIT_MASKWRITE(0xf8000b70, 0x00000001, 0x00000001),
158 EMIT_MASKWRITE(0xf8000b70, 0x00000021, 0x00000020),
159 EMIT_MASKWRITE(0xf8000b70, 0x07feffff, 0x00000823),
160 EMIT_MASKWRITE(0xf8000700, 0x00003fff, 0x00000610),
161 EMIT_MASKWRITE(0xf8000704, 0x00003fff, 0x00000600),
162 EMIT_MASKWRITE(0xf8000708, 0x00003fff, 0x00000610),
163 EMIT_MASKWRITE(0xf800070c, 0x00003fff, 0x00000610),
164 EMIT_MASKWRITE(0xf8000710, 0x00003fff, 0x00000610),
165 EMIT_MASKWRITE(0xf8000714, 0x00003fff, 0x00000610),
166 EMIT_MASKWRITE(0xf8000718, 0x00003fff, 0x00000610),
167 EMIT_MASKWRITE(0xf800071c, 0x00003fff, 0x00000610),
168 EMIT_MASKWRITE(0xf8000720, 0x00003fff, 0x00000610),
169 EMIT_MASKWRITE(0xf8000724, 0x00003fff, 0x00000610),
170 EMIT_MASKWRITE(0xf8000728, 0x00003fff, 0x00000610),
171 EMIT_MASKWRITE(0xf800072c, 0x00003fff, 0x00000610),
172 EMIT_MASKWRITE(0xf8000730, 0x00003fff, 0x00000610),
173 EMIT_MASKWRITE(0xf8000734, 0x00003fff, 0x00000610),
174 EMIT_MASKWRITE(0xf8000738, 0x00003fff, 0x00000611),
175 EMIT_MASKWRITE(0xf800073c, 0x00003fff, 0x00000600),
176 EMIT_MASKWRITE(0xf8000740, 0x00003fff, 0x00000202),
177 EMIT_MASKWRITE(0xf8000744, 0x00003fff, 0x00000202),
178 EMIT_MASKWRITE(0xf8000748, 0x00003fff, 0x00000202),
179 EMIT_MASKWRITE(0xf800074c, 0x00003fff, 0x00000202),
180 EMIT_MASKWRITE(0xf8000750, 0x00003fff, 0x00000202),
181 EMIT_MASKWRITE(0xf8000754, 0x00003fff, 0x00000202),
182 EMIT_MASKWRITE(0xf8000758, 0x00003fff, 0x00000203),
183 EMIT_MASKWRITE(0xf800075c, 0x00003fff, 0x00000203),
184 EMIT_MASKWRITE(0xf8000760, 0x00003fff, 0x00000203),
185 EMIT_MASKWRITE(0xf8000764, 0x00003fff, 0x00000203),
186 EMIT_MASKWRITE(0xf8000768, 0x00003fff, 0x00000203),
187 EMIT_MASKWRITE(0xf800076c, 0x00003fff, 0x00000203),
188 EMIT_MASKWRITE(0xf8000770, 0x00003fff, 0x00000200),
189 EMIT_MASKWRITE(0xf8000774, 0x00003fff, 0x00000200),
190 EMIT_MASKWRITE(0xf8000778, 0x00003fff, 0x00000200),
191 EMIT_MASKWRITE(0xf800077c, 0x00003fff, 0x00000200),
192 EMIT_MASKWRITE(0xf8000780, 0x00003fff, 0x00000200),
193 EMIT_MASKWRITE(0xf8000784, 0x00003fff, 0x00000200),
194 EMIT_MASKWRITE(0xf8000788, 0x00003fff, 0x00000200),
195 EMIT_MASKWRITE(0xf800078c, 0x00003fff, 0x00000200),
196 EMIT_MASKWRITE(0xf8000790, 0x00003fff, 0x00000200),
197 EMIT_MASKWRITE(0xf8000794, 0x00003fff, 0x00000200),
198 EMIT_MASKWRITE(0xf8000798, 0x00003fff, 0x00000200),
199 EMIT_MASKWRITE(0xf800079c, 0x00003fff, 0x00000200),
200 EMIT_MASKWRITE(0xf80007a0, 0x00003fff, 0x00000280),
201 EMIT_MASKWRITE(0xf80007a4, 0x00003fff, 0x00000280),
202 EMIT_MASKWRITE(0xf80007a8, 0x00003fff, 0x00000280),
203 EMIT_MASKWRITE(0xf80007ac, 0x00003fff, 0x00000280),
204 EMIT_MASKWRITE(0xf80007b0, 0x00003fff, 0x00000280),
205 EMIT_MASKWRITE(0xf80007b4, 0x00003fff, 0x00000280),
206 EMIT_MASKWRITE(0xf80007b8, 0x00003f01, 0x00000201),
207 EMIT_MASKWRITE(0xf80007bc, 0x00003fff, 0x00000200),
208 EMIT_MASKWRITE(0xf80007c0, 0x00003fff, 0x000002e0),
209 EMIT_MASKWRITE(0xf80007c4, 0x00003fff, 0x000002e1),
210 EMIT_MASKWRITE(0xf80007c8, 0x00003f01, 0x00000201),
211 EMIT_MASKWRITE(0xf80007cc, 0x00003fff, 0x00000200),
212 EMIT_MASKWRITE(0xf80007d0, 0x00003fff, 0x00000280),
213 EMIT_MASKWRITE(0xf80007d4, 0x00003fff, 0x00000280),
214 EMIT_MASKWRITE(0xf8000830, 0x003f003f, 0x002e0032),
215 EMIT_MASKWRITE(0xf8000004, 0x0000ffff, 0x0000767b),
216 EMIT_EXIT(),
217 };
218
219 static unsigned long ps7_peripherals_init_data_3_0[] = {
220 EMIT_MASKWRITE(0xf8000008, 0x0000ffff, 0x0000df0d),
221 EMIT_MASKWRITE(0xf8000b48, 0x00000180, 0x00000180),
222 EMIT_MASKWRITE(0xf8000b4c, 0x00000180, 0x00000180),
223 EMIT_MASKWRITE(0xf8000b50, 0x00000180, 0x00000180),
224 EMIT_MASKWRITE(0xf8000b54, 0x00000180, 0x00000180),
225 EMIT_MASKWRITE(0xf8000004, 0x0000ffff, 0x0000767b),
226 EMIT_MASKWRITE(0xe0001034, 0x000000ff, 0x00000006),
227 EMIT_MASKWRITE(0xe0001018, 0x0000ffff, 0x0000003e),
228 EMIT_MASKWRITE(0xe0001000, 0x000001ff, 0x00000017),
229 EMIT_MASKWRITE(0xe0001004, 0x000003ff, 0x00000020),
230 EMIT_MASKWRITE(0xe000d000, 0x00080000, 0x00080000),
231 EMIT_MASKWRITE(0xf8007000, 0x20000000, 0x00000000),
232 EMIT_MASKWRITE(0xe000e014, 0x00ffffff, 0x00449144),
233 EMIT_MASKWRITE(0xe000e018, 0x00000003, 0x00000000),
234 EMIT_MASKWRITE(0xe000e010, 0x03e00000, 0x02400000),
235 EMIT_MASKDELAY(0xf8f00200, 0x00000001),
236 EMIT_MASKDELAY(0xf8f00200, 0x00000001),
237 EMIT_MASKDELAY(0xf8f00200, 0x00000001),
238 EMIT_MASKDELAY(0xf8f00200, 0x00000001),
239 EMIT_MASKDELAY(0xf8f00200, 0x00000001),
240 EMIT_MASKDELAY(0xf8f00200, 0x00000001),
241 EMIT_EXIT(),
242 };
243
244 static unsigned long ps7_post_config_3_0[] = {
245 EMIT_MASKWRITE(0xf8000008, 0x0000ffff, 0x0000df0d),
246 EMIT_MASKWRITE(0xf8000900, 0x0000000f, 0x0000000f),
247 EMIT_MASKWRITE(0xf8000240, 0xffffffff, 0x00000000),
248 EMIT_MASKWRITE(0xf8008000, 0x00000001, 0x00000001),
249 EMIT_MASKWRITE(0xf8008014, 0x00000001, 0x00000001),
250 EMIT_MASKWRITE(0xf8000004, 0x0000ffff, 0x0000767b),
251 EMIT_EXIT(),
252 };
253
ps7_init(void)254 int ps7_init(void)
255 {
256 int ret;
257
258 ret = ps7_config(ps7_mio_init_data_3_0);
259 if (ret != PS7_INIT_SUCCESS)
260 return ret;
261 ret = ps7_config(ps7_pll_init_data_3_0);
262 if (ret != PS7_INIT_SUCCESS)
263 return ret;
264 ret = ps7_config(ps7_clock_init_data_3_0);
265 if (ret != PS7_INIT_SUCCESS)
266 return ret;
267 ret = ps7_config(ps7_ddr_init_data_3_0);
268 if (ret != PS7_INIT_SUCCESS)
269 return ret;
270 ret = ps7_config(ps7_peripherals_init_data_3_0);
271 if (ret != PS7_INIT_SUCCESS)
272 return ret;
273
274 return PS7_INIT_SUCCESS;
275 }
276
ps7_post_config(void)277 int ps7_post_config(void)
278 {
279 return ps7_config(ps7_post_config_3_0);
280 }
281