blob: e8e8e3c0de8c3f1a85512e331d4371c079f2383c [file] [log] [blame]
Michal Simek9140ae52013-10-16 09:06:31 +02001/*
2 * (C) Copyright 2007 Michal Simek
3 *
4 * Michal SIMEK <monstr@monstr.eu>
Michal Simek6455ac02007-05-05 18:27:16 +02005 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Michal Simek6455ac02007-05-05 18:27:16 +02007 */
8
9/*
10 * Microblaze FSL support
11 */
12
13#include <common.h>
14#include <config.h>
15#include <command.h>
Stefano Babic68f16f82007-05-16 14:49:12 +020016#include <asm/asm.h>
Michal Simek6455ac02007-05-05 18:27:16 +020017
Wolfgang Denk6262d0212010-06-28 22:00:46 +020018int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Michal Simek6455ac02007-05-05 18:27:16 +020019{
20 unsigned int fslnum;
21 unsigned int num;
22 unsigned int blocking;
23
Wolfgang Denk3b683112010-07-17 01:06:04 +020024 if (argc < 2)
Simon Glassa06dfc72011-12-10 08:44:01 +000025 return CMD_RET_USAGE;
Michal Simek6455ac02007-05-05 18:27:16 +020026
27 fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
28 blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
29 if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
30 puts ("Bad number of FSL\n");
Simon Glassa06dfc72011-12-10 08:44:01 +000031 return CMD_RET_USAGE;
Michal Simek6455ac02007-05-05 18:27:16 +020032 }
33
34 switch (fslnum) {
35#if (XILINX_FSL_NUMBER > 0)
36 case 0:
Michal Simekee1aced2007-05-08 14:39:11 +020037 switch (blocking) {
38 case 0: NGET (num, 0);
39 break;
40 case 1: NCGET (num, 0);
41 break;
42 case 2: GET (num, 0);
43 break;
44 case 3: CGET (num, 0);
45 break;
46 default:
47 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020048 }
49 break;
50#endif
51#if (XILINX_FSL_NUMBER > 1)
52 case 1:
Michal Simekee1aced2007-05-08 14:39:11 +020053 switch (blocking) {
54 case 0: NGET (num, 1);
55 break;
56 case 1: NCGET (num, 1);
57 break;
58 case 2: GET (num, 1);
59 break;
60 case 3: CGET (num, 1);
61 break;
62 default:
63 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020064 }
65 break;
66#endif
67#if (XILINX_FSL_NUMBER > 2)
68 case 2:
Michal Simekee1aced2007-05-08 14:39:11 +020069 switch (blocking) {
70 case 0: NGET (num, 2);
71 break;
72 case 1: NCGET (num, 2);
73 break;
74 case 2: GET (num, 2);
75 break;
76 case 3: CGET (num, 2);
77 break;
78 default:
79 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020080 }
81 break;
82#endif
83#if (XILINX_FSL_NUMBER > 3)
84 case 3:
Michal Simekee1aced2007-05-08 14:39:11 +020085 switch (blocking) {
86 case 0: NGET (num, 3);
87 break;
88 case 1: NCGET (num, 3);
89 break;
90 case 2: GET (num, 3);
91 break;
92 case 3: CGET (num, 3);
93 break;
94 default:
95 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020096 }
97 break;
98#endif
99#if (XILINX_FSL_NUMBER > 4)
100 case 4:
Michal Simekee1aced2007-05-08 14:39:11 +0200101 switch (blocking) {
102 case 0: NGET (num, 4);
103 break;
104 case 1: NCGET (num, 4);
105 break;
106 case 2: GET (num, 4);
107 break;
108 case 3: CGET (num, 4);
109 break;
110 default:
111 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200112 }
113 break;
114#endif
115#if (XILINX_FSL_NUMBER > 5)
116 case 5:
Michal Simekee1aced2007-05-08 14:39:11 +0200117 switch (blocking) {
118 case 0: NGET (num, 5);
119 break;
120 case 1: NCGET (num, 5);
121 break;
122 case 2: GET (num, 5);
123 break;
124 case 3: CGET (num, 5);
125 break;
126 default:
127 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200128 }
129 break;
130#endif
131#if (XILINX_FSL_NUMBER > 6)
132 case 6:
Michal Simekee1aced2007-05-08 14:39:11 +0200133 switch (blocking) {
134 case 0: NGET (num, 6);
135 break;
136 case 1: NCGET (num, 6);
137 break;
138 case 2: GET (num, 6);
139 break;
140 case 3: CGET (num, 6);
141 break;
142 default:
143 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200144 }
145 break;
146#endif
147#if (XILINX_FSL_NUMBER > 7)
148 case 7:
Michal Simekee1aced2007-05-08 14:39:11 +0200149 switch (blocking) {
150 case 0: NGET (num, 7);
151 break;
152 case 1: NCGET (num, 7);
153 break;
154 case 2: GET (num, 7);
155 break;
156 case 3: CGET (num, 7);
157 break;
158 default:
159 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200160 }
161 break;
162#endif
163 default:
164 return 1;
165 }
166
Stefan Roese37628252008-08-06 14:05:38 +0200167 printf ("%01x: 0x%08x - %s %s read\n", fslnum, num,
Michal Simekee1aced2007-05-08 14:39:11 +0200168 blocking < 2 ? "non blocking" : "blocking",
169 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
Michal Simek6455ac02007-05-05 18:27:16 +0200170 return 0;
171}
172
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200173int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Michal Simek6455ac02007-05-05 18:27:16 +0200174{
175 unsigned int fslnum;
176 unsigned int num;
177 unsigned int blocking;
178
Wolfgang Denk3b683112010-07-17 01:06:04 +0200179 if (argc < 3)
Simon Glassa06dfc72011-12-10 08:44:01 +0000180 return CMD_RET_USAGE;
Michal Simek6455ac02007-05-05 18:27:16 +0200181
182 fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
183 num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
184 blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
Wolfgang Denk3b683112010-07-17 01:06:04 +0200185 if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER)
Simon Glassa06dfc72011-12-10 08:44:01 +0000186 return CMD_RET_USAGE;
Michal Simek6455ac02007-05-05 18:27:16 +0200187
188 switch (fslnum) {
189#if (XILINX_FSL_NUMBER > 0)
190 case 0:
Michal Simekee1aced2007-05-08 14:39:11 +0200191 switch (blocking) {
192 case 0: NPUT (num, 0);
193 break;
194 case 1: NCPUT (num, 0);
195 break;
196 case 2: PUT (num, 0);
197 break;
198 case 3: CPUT (num, 0);
199 break;
200 default:
201 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200202 }
203 break;
204#endif
205#if (XILINX_FSL_NUMBER > 1)
206 case 1:
Michal Simekee1aced2007-05-08 14:39:11 +0200207 switch (blocking) {
208 case 0: NPUT (num, 1);
209 break;
210 case 1: NCPUT (num, 1);
211 break;
212 case 2: PUT (num, 1);
213 break;
214 case 3: CPUT (num, 1);
215 break;
216 default:
217 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200218 }
219 break;
220#endif
221#if (XILINX_FSL_NUMBER > 2)
222 case 2:
Michal Simekee1aced2007-05-08 14:39:11 +0200223 switch (blocking) {
224 case 0: NPUT (num, 2);
225 break;
226 case 1: NCPUT (num, 2);
227 break;
228 case 2: PUT (num, 2);
229 break;
230 case 3: CPUT (num, 2);
231 break;
232 default:
233 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200234 }
235 break;
236#endif
237#if (XILINX_FSL_NUMBER > 3)
238 case 3:
Michal Simekee1aced2007-05-08 14:39:11 +0200239 switch (blocking) {
240 case 0: NPUT (num, 3);
241 break;
242 case 1: NCPUT (num, 3);
243 break;
244 case 2: PUT (num, 3);
245 break;
246 case 3: CPUT (num, 3);
247 break;
248 default:
249 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200250 }
251 break;
252#endif
253#if (XILINX_FSL_NUMBER > 4)
254 case 4:
Michal Simekee1aced2007-05-08 14:39:11 +0200255 switch (blocking) {
256 case 0: NPUT (num, 4);
257 break;
258 case 1: NCPUT (num, 4);
259 break;
260 case 2: PUT (num, 4);
261 break;
262 case 3: CPUT (num, 4);
263 break;
264 default:
265 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200266 }
267 break;
268#endif
269#if (XILINX_FSL_NUMBER > 5)
270 case 5:
Michal Simekee1aced2007-05-08 14:39:11 +0200271 switch (blocking) {
272 case 0: NPUT (num, 5);
273 break;
274 case 1: NCPUT (num, 5);
275 break;
276 case 2: PUT (num, 5);
277 break;
278 case 3: CPUT (num, 5);
279 break;
280 default:
281 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200282 }
283 break;
284#endif
285#if (XILINX_FSL_NUMBER > 6)
286 case 6:
Michal Simekee1aced2007-05-08 14:39:11 +0200287 switch (blocking) {
288 case 0: NPUT (num, 6);
289 break;
290 case 1: NCPUT (num, 6);
291 break;
292 case 2: PUT (num, 6);
293 break;
294 case 3: CPUT (num, 6);
295 break;
296 default:
297 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200298 }
299 break;
300#endif
301#if (XILINX_FSL_NUMBER > 7)
302 case 7:
Michal Simekee1aced2007-05-08 14:39:11 +0200303 switch (blocking) {
304 case 0: NPUT (num, 7);
305 break;
306 case 1: NCPUT (num, 7);
307 break;
308 case 2: PUT (num, 7);
309 break;
310 case 3: CPUT (num, 7);
311 break;
312 default:
313 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200314 }
315 break;
316#endif
317 default:
318 return 1;
319 }
320
Stefan Roese37628252008-08-06 14:05:38 +0200321 printf ("%01x: 0x%08x - %s %s write\n", fslnum, num,
Michal Simekee1aced2007-05-08 14:39:11 +0200322 blocking < 2 ? "non blocking" : "blocking",
323 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
Michal Simek6455ac02007-05-05 18:27:16 +0200324 return 0;
325
326}
327
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200328int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Michal Simek6455ac02007-05-05 18:27:16 +0200329{
Michal Simekebf7b232007-05-08 15:57:43 +0200330 unsigned int reg = 0;
Michal Simek603aa742007-05-07 17:11:09 +0200331 unsigned int val = 0;
Michal Simek6455ac02007-05-05 18:27:16 +0200332
Wolfgang Denk3b683112010-07-17 01:06:04 +0200333 if (argc < 2)
Simon Glassa06dfc72011-12-10 08:44:01 +0000334 return CMD_RET_USAGE;
Wolfgang Denk3b683112010-07-17 01:06:04 +0200335
Michal Simek25e1ddb2007-09-24 00:17:42 +0200336 reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
337 val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
Michal Simekebf7b232007-05-08 15:57:43 +0200338 switch (reg) {
339 case 0x1:
340 if (argc > 2) {
341 MTS (val, rmsr);
342 NOP;
343 MFS (val, rmsr);
Michal Simekebf7b232007-05-08 15:57:43 +0200344 } else {
345 MFS (val, rmsr);
346 }
347 puts ("MSR");
348 break;
349 case 0x3:
350 MFS (val, rear);
351 puts ("EAR");
352 break;
353 case 0x5:
354 MFS (val, resr);
355 puts ("ESR");
356 break;
357 default:
Michal Simek25e1ddb2007-09-24 00:17:42 +0200358 puts ("Unsupported register\n");
Michal Simekebf7b232007-05-08 15:57:43 +0200359 return 1;
Michal Simek603aa742007-05-07 17:11:09 +0200360 }
Stefan Roese37628252008-08-06 14:05:38 +0200361 printf (": 0x%08x\n", val);
Michal Simek6455ac02007-05-05 18:27:16 +0200362 return 0;
363}
364
365/***************************************************/
366
367U_BOOT_CMD (frd, 3, 1, do_frd,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600368 "read data from FSL",
Michal Simekee1aced2007-05-08 14:39:11 +0200369 "- [fslnum [0|1|2|3]]\n"
370 " 0 - non blocking data read\n"
371 " 1 - non blocking control read\n"
372 " 2 - blocking data read\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200373 " 3 - blocking control read");
Michal Simek6455ac02007-05-05 18:27:16 +0200374
375U_BOOT_CMD (fwr, 4, 1, do_fwr,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600376 "write data to FSL",
Michal Simekee1aced2007-05-08 14:39:11 +0200377 "- [fslnum [0|1|2|3]]\n"
378 " 0 - non blocking data write\n"
379 " 1 - non blocking control write\n"
380 " 2 - blocking data write\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200381 " 3 - blocking control write");
Michal Simek6455ac02007-05-05 18:27:16 +0200382
Michal Simekebf7b232007-05-08 15:57:43 +0200383U_BOOT_CMD (rspr, 3, 1, do_rspr,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600384 "read/write special purpose register",
Michal Simekebf7b232007-05-08 15:57:43 +0200385 "- reg_num [write value] read/write special purpose register\n"
Michal Simek25e1ddb2007-09-24 00:17:42 +0200386 " 1 - MSR - Machine status register\n"
387 " 3 - EAR - Exception address register\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200388 " 5 - ESR - Exception status register");