blob: 31f5b36ade0acca5c428b17051c76a8c93ae2119 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Michal Simek100ea072013-10-16 09:06:31 +02002/*
3 * (C) Copyright 2007 Michal Simek
4 *
5 * Michal SIMEK <monstr@monstr.eu>
Michal Simekf7e2e0e2007-05-05 18:27:16 +02006 */
7
8/*
9 * Microblaze FSL support
10 */
11
12#include <common.h>
13#include <config.h>
14#include <command.h>
Stefano Babic70124c22007-05-16 14:49:12 +020015#include <asm/asm.h>
Michal Simekf7e2e0e2007-05-05 18:27:16 +020016
Simon Glass09140112020-05-10 11:40:03 -060017int do_frd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Michal Simekf7e2e0e2007-05-05 18:27:16 +020018{
19 unsigned int fslnum;
20 unsigned int num;
21 unsigned int blocking;
22
Wolfgang Denk47e26b12010-07-17 01:06:04 +020023 if (argc < 2)
Simon Glass4c12eeb2011-12-10 08:44:01 +000024 return CMD_RET_USAGE;
Michal Simekf7e2e0e2007-05-05 18:27:16 +020025
26 fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
27 blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
28 if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
29 puts ("Bad number of FSL\n");
Simon Glass4c12eeb2011-12-10 08:44:01 +000030 return CMD_RET_USAGE;
Michal Simekf7e2e0e2007-05-05 18:27:16 +020031 }
32
33 switch (fslnum) {
34#if (XILINX_FSL_NUMBER > 0)
35 case 0:
Michal Simekab874d52007-05-08 14:39:11 +020036 switch (blocking) {
37 case 0: NGET (num, 0);
38 break;
39 case 1: NCGET (num, 0);
40 break;
41 case 2: GET (num, 0);
42 break;
43 case 3: CGET (num, 0);
44 break;
45 default:
46 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +020047 }
48 break;
49#endif
50#if (XILINX_FSL_NUMBER > 1)
51 case 1:
Michal Simekab874d52007-05-08 14:39:11 +020052 switch (blocking) {
53 case 0: NGET (num, 1);
54 break;
55 case 1: NCGET (num, 1);
56 break;
57 case 2: GET (num, 1);
58 break;
59 case 3: CGET (num, 1);
60 break;
61 default:
62 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +020063 }
64 break;
65#endif
66#if (XILINX_FSL_NUMBER > 2)
67 case 2:
Michal Simekab874d52007-05-08 14:39:11 +020068 switch (blocking) {
69 case 0: NGET (num, 2);
70 break;
71 case 1: NCGET (num, 2);
72 break;
73 case 2: GET (num, 2);
74 break;
75 case 3: CGET (num, 2);
76 break;
77 default:
78 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +020079 }
80 break;
81#endif
82#if (XILINX_FSL_NUMBER > 3)
83 case 3:
Michal Simekab874d52007-05-08 14:39:11 +020084 switch (blocking) {
85 case 0: NGET (num, 3);
86 break;
87 case 1: NCGET (num, 3);
88 break;
89 case 2: GET (num, 3);
90 break;
91 case 3: CGET (num, 3);
92 break;
93 default:
94 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +020095 }
96 break;
97#endif
98#if (XILINX_FSL_NUMBER > 4)
99 case 4:
Michal Simekab874d52007-05-08 14:39:11 +0200100 switch (blocking) {
101 case 0: NGET (num, 4);
102 break;
103 case 1: NCGET (num, 4);
104 break;
105 case 2: GET (num, 4);
106 break;
107 case 3: CGET (num, 4);
108 break;
109 default:
110 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200111 }
112 break;
113#endif
114#if (XILINX_FSL_NUMBER > 5)
115 case 5:
Michal Simekab874d52007-05-08 14:39:11 +0200116 switch (blocking) {
117 case 0: NGET (num, 5);
118 break;
119 case 1: NCGET (num, 5);
120 break;
121 case 2: GET (num, 5);
122 break;
123 case 3: CGET (num, 5);
124 break;
125 default:
126 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200127 }
128 break;
129#endif
130#if (XILINX_FSL_NUMBER > 6)
131 case 6:
Michal Simekab874d52007-05-08 14:39:11 +0200132 switch (blocking) {
133 case 0: NGET (num, 6);
134 break;
135 case 1: NCGET (num, 6);
136 break;
137 case 2: GET (num, 6);
138 break;
139 case 3: CGET (num, 6);
140 break;
141 default:
142 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200143 }
144 break;
145#endif
146#if (XILINX_FSL_NUMBER > 7)
147 case 7:
Michal Simekab874d52007-05-08 14:39:11 +0200148 switch (blocking) {
149 case 0: NGET (num, 7);
150 break;
151 case 1: NCGET (num, 7);
152 break;
153 case 2: GET (num, 7);
154 break;
155 case 3: CGET (num, 7);
156 break;
157 default:
158 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200159 }
160 break;
161#endif
162 default:
163 return 1;
164 }
165
Stefan Roesef2302d42008-08-06 14:05:38 +0200166 printf ("%01x: 0x%08x - %s %s read\n", fslnum, num,
Michal Simekab874d52007-05-08 14:39:11 +0200167 blocking < 2 ? "non blocking" : "blocking",
168 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200169 return 0;
170}
171
Simon Glass09140112020-05-10 11:40:03 -0600172int do_fwr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200173{
174 unsigned int fslnum;
175 unsigned int num;
176 unsigned int blocking;
177
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200178 if (argc < 3)
Simon Glass4c12eeb2011-12-10 08:44:01 +0000179 return CMD_RET_USAGE;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200180
181 fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
182 num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
183 blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200184 if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER)
Simon Glass4c12eeb2011-12-10 08:44:01 +0000185 return CMD_RET_USAGE;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200186
187 switch (fslnum) {
188#if (XILINX_FSL_NUMBER > 0)
189 case 0:
Michal Simekab874d52007-05-08 14:39:11 +0200190 switch (blocking) {
191 case 0: NPUT (num, 0);
192 break;
193 case 1: NCPUT (num, 0);
194 break;
195 case 2: PUT (num, 0);
196 break;
197 case 3: CPUT (num, 0);
198 break;
199 default:
200 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200201 }
202 break;
203#endif
204#if (XILINX_FSL_NUMBER > 1)
205 case 1:
Michal Simekab874d52007-05-08 14:39:11 +0200206 switch (blocking) {
207 case 0: NPUT (num, 1);
208 break;
209 case 1: NCPUT (num, 1);
210 break;
211 case 2: PUT (num, 1);
212 break;
213 case 3: CPUT (num, 1);
214 break;
215 default:
216 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200217 }
218 break;
219#endif
220#if (XILINX_FSL_NUMBER > 2)
221 case 2:
Michal Simekab874d52007-05-08 14:39:11 +0200222 switch (blocking) {
223 case 0: NPUT (num, 2);
224 break;
225 case 1: NCPUT (num, 2);
226 break;
227 case 2: PUT (num, 2);
228 break;
229 case 3: CPUT (num, 2);
230 break;
231 default:
232 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200233 }
234 break;
235#endif
236#if (XILINX_FSL_NUMBER > 3)
237 case 3:
Michal Simekab874d52007-05-08 14:39:11 +0200238 switch (blocking) {
239 case 0: NPUT (num, 3);
240 break;
241 case 1: NCPUT (num, 3);
242 break;
243 case 2: PUT (num, 3);
244 break;
245 case 3: CPUT (num, 3);
246 break;
247 default:
248 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200249 }
250 break;
251#endif
252#if (XILINX_FSL_NUMBER > 4)
253 case 4:
Michal Simekab874d52007-05-08 14:39:11 +0200254 switch (blocking) {
255 case 0: NPUT (num, 4);
256 break;
257 case 1: NCPUT (num, 4);
258 break;
259 case 2: PUT (num, 4);
260 break;
261 case 3: CPUT (num, 4);
262 break;
263 default:
264 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200265 }
266 break;
267#endif
268#if (XILINX_FSL_NUMBER > 5)
269 case 5:
Michal Simekab874d52007-05-08 14:39:11 +0200270 switch (blocking) {
271 case 0: NPUT (num, 5);
272 break;
273 case 1: NCPUT (num, 5);
274 break;
275 case 2: PUT (num, 5);
276 break;
277 case 3: CPUT (num, 5);
278 break;
279 default:
280 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200281 }
282 break;
283#endif
284#if (XILINX_FSL_NUMBER > 6)
285 case 6:
Michal Simekab874d52007-05-08 14:39:11 +0200286 switch (blocking) {
287 case 0: NPUT (num, 6);
288 break;
289 case 1: NCPUT (num, 6);
290 break;
291 case 2: PUT (num, 6);
292 break;
293 case 3: CPUT (num, 6);
294 break;
295 default:
296 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200297 }
298 break;
299#endif
300#if (XILINX_FSL_NUMBER > 7)
301 case 7:
Michal Simekab874d52007-05-08 14:39:11 +0200302 switch (blocking) {
303 case 0: NPUT (num, 7);
304 break;
305 case 1: NCPUT (num, 7);
306 break;
307 case 2: PUT (num, 7);
308 break;
309 case 3: CPUT (num, 7);
310 break;
311 default:
312 return 2;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200313 }
314 break;
315#endif
316 default:
317 return 1;
318 }
319
Stefan Roesef2302d42008-08-06 14:05:38 +0200320 printf ("%01x: 0x%08x - %s %s write\n", fslnum, num,
Michal Simekab874d52007-05-08 14:39:11 +0200321 blocking < 2 ? "non blocking" : "blocking",
322 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200323 return 0;
324
325}
326
Simon Glass09140112020-05-10 11:40:03 -0600327int do_rspr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200328{
Michal Simeke69f66c2007-05-08 15:57:43 +0200329 unsigned int reg = 0;
Michal Simek48fbd3a2007-05-07 17:11:09 +0200330 unsigned int val = 0;
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200331
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200332 if (argc < 2)
Simon Glass4c12eeb2011-12-10 08:44:01 +0000333 return CMD_RET_USAGE;
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200334
Michal Simek481d4322007-09-24 00:17:42 +0200335 reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
336 val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
Michal Simeke69f66c2007-05-08 15:57:43 +0200337 switch (reg) {
338 case 0x1:
339 if (argc > 2) {
340 MTS (val, rmsr);
341 NOP;
342 MFS (val, rmsr);
Michal Simeke69f66c2007-05-08 15:57:43 +0200343 } else {
344 MFS (val, rmsr);
345 }
346 puts ("MSR");
347 break;
348 case 0x3:
349 MFS (val, rear);
350 puts ("EAR");
351 break;
352 case 0x5:
353 MFS (val, resr);
354 puts ("ESR");
355 break;
356 default:
Michal Simek481d4322007-09-24 00:17:42 +0200357 puts ("Unsupported register\n");
Michal Simeke69f66c2007-05-08 15:57:43 +0200358 return 1;
Michal Simek48fbd3a2007-05-07 17:11:09 +0200359 }
Stefan Roesef2302d42008-08-06 14:05:38 +0200360 printf (": 0x%08x\n", val);
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200361 return 0;
362}
363
364/***************************************************/
365
366U_BOOT_CMD (frd, 3, 1, do_frd,
Peter Tyser2fb26042009-01-27 18:03:12 -0600367 "read data from FSL",
Michal Simekab874d52007-05-08 14:39:11 +0200368 "- [fslnum [0|1|2|3]]\n"
369 " 0 - non blocking data read\n"
370 " 1 - non blocking control read\n"
371 " 2 - blocking data read\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200372 " 3 - blocking control read");
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200373
374U_BOOT_CMD (fwr, 4, 1, do_fwr,
Peter Tyser2fb26042009-01-27 18:03:12 -0600375 "write data to FSL",
Michal Simekab874d52007-05-08 14:39:11 +0200376 "- [fslnum [0|1|2|3]]\n"
377 " 0 - non blocking data write\n"
378 " 1 - non blocking control write\n"
379 " 2 - blocking data write\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200380 " 3 - blocking control write");
Michal Simekf7e2e0e2007-05-05 18:27:16 +0200381
Michal Simeke69f66c2007-05-08 15:57:43 +0200382U_BOOT_CMD (rspr, 3, 1, do_rspr,
Peter Tyser2fb26042009-01-27 18:03:12 -0600383 "read/write special purpose register",
Michal Simeke69f66c2007-05-08 15:57:43 +0200384 "- reg_num [write value] read/write special purpose register\n"
Michal Simek481d4322007-09-24 00:17:42 +0200385 " 1 - MSR - Machine status register\n"
386 " 3 - EAR - Exception address register\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200387 " 5 - ESR - Exception status register");