blob: 8d4c1a38d7fcba45e840d7a7965643d8ec042284 [file] [log] [blame]
Michal Simek6455ac02007-05-05 18:27:16 +02001/*
2 * (C) Copyright 2007 Michal Simek
3 *
4 * Michal SIMEK <monstr@monstr.eu>
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25/*
26 * Microblaze FSL support
27 */
28
29#include <common.h>
30#include <config.h>
31#include <command.h>
Michal Simek6455ac02007-05-05 18:27:16 +020032
Jon Loeligerd76b5c12007-07-08 18:02:23 -050033#if defined(CONFIG_CMD_MFSL)
Stefano Babic68f16f82007-05-16 14:49:12 +020034#include <asm/asm.h>
Michal Simek6455ac02007-05-05 18:27:16 +020035
36int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
37{
38 unsigned int fslnum;
39 unsigned int num;
40 unsigned int blocking;
41
42 if (argc < 2) {
43 printf ("Usage:\n%s\n", cmdtp->usage);
44 return 1;
45 }
46
47 fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
48 blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
49 if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
50 puts ("Bad number of FSL\n");
51 printf ("Usage:\n%s\n", cmdtp->usage);
52 return 1;
53 }
54
55 switch (fslnum) {
56#if (XILINX_FSL_NUMBER > 0)
57 case 0:
Michal Simekee1aced2007-05-08 14:39:11 +020058 switch (blocking) {
59 case 0: NGET (num, 0);
60 break;
61 case 1: NCGET (num, 0);
62 break;
63 case 2: GET (num, 0);
64 break;
65 case 3: CGET (num, 0);
66 break;
67 default:
68 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020069 }
70 break;
71#endif
72#if (XILINX_FSL_NUMBER > 1)
73 case 1:
Michal Simekee1aced2007-05-08 14:39:11 +020074 switch (blocking) {
75 case 0: NGET (num, 1);
76 break;
77 case 1: NCGET (num, 1);
78 break;
79 case 2: GET (num, 1);
80 break;
81 case 3: CGET (num, 1);
82 break;
83 default:
84 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020085 }
86 break;
87#endif
88#if (XILINX_FSL_NUMBER > 2)
89 case 2:
Michal Simekee1aced2007-05-08 14:39:11 +020090 switch (blocking) {
91 case 0: NGET (num, 2);
92 break;
93 case 1: NCGET (num, 2);
94 break;
95 case 2: GET (num, 2);
96 break;
97 case 3: CGET (num, 2);
98 break;
99 default:
100 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200101 }
102 break;
103#endif
104#if (XILINX_FSL_NUMBER > 3)
105 case 3:
Michal Simekee1aced2007-05-08 14:39:11 +0200106 switch (blocking) {
107 case 0: NGET (num, 3);
108 break;
109 case 1: NCGET (num, 3);
110 break;
111 case 2: GET (num, 3);
112 break;
113 case 3: CGET (num, 3);
114 break;
115 default:
116 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200117 }
118 break;
119#endif
120#if (XILINX_FSL_NUMBER > 4)
121 case 4:
Michal Simekee1aced2007-05-08 14:39:11 +0200122 switch (blocking) {
123 case 0: NGET (num, 4);
124 break;
125 case 1: NCGET (num, 4);
126 break;
127 case 2: GET (num, 4);
128 break;
129 case 3: CGET (num, 4);
130 break;
131 default:
132 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200133 }
134 break;
135#endif
136#if (XILINX_FSL_NUMBER > 5)
137 case 5:
Michal Simekee1aced2007-05-08 14:39:11 +0200138 switch (blocking) {
139 case 0: NGET (num, 5);
140 break;
141 case 1: NCGET (num, 5);
142 break;
143 case 2: GET (num, 5);
144 break;
145 case 3: CGET (num, 5);
146 break;
147 default:
148 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200149 }
150 break;
151#endif
152#if (XILINX_FSL_NUMBER > 6)
153 case 6:
Michal Simekee1aced2007-05-08 14:39:11 +0200154 switch (blocking) {
155 case 0: NGET (num, 6);
156 break;
157 case 1: NCGET (num, 6);
158 break;
159 case 2: GET (num, 6);
160 break;
161 case 3: CGET (num, 6);
162 break;
163 default:
164 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200165 }
166 break;
167#endif
168#if (XILINX_FSL_NUMBER > 7)
169 case 7:
Michal Simekee1aced2007-05-08 14:39:11 +0200170 switch (blocking) {
171 case 0: NGET (num, 7);
172 break;
173 case 1: NCGET (num, 7);
174 break;
175 case 2: GET (num, 7);
176 break;
177 case 3: CGET (num, 7);
178 break;
179 default:
180 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200181 }
182 break;
183#endif
184 default:
185 return 1;
186 }
187
Michal Simekee1aced2007-05-08 14:39:11 +0200188 printf ("%01x: 0x%08lx - %s %s read\n", fslnum, num,
189 blocking < 2 ? "non blocking" : "blocking",
190 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
Michal Simek6455ac02007-05-05 18:27:16 +0200191 return 0;
192}
193
194int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
195{
196 unsigned int fslnum;
197 unsigned int num;
198 unsigned int blocking;
199
200 if (argc < 3) {
201 printf ("Usage:\n%s\n", cmdtp->usage);
202 return 1;
203 }
204
205 fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
206 num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
207 blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
208 if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
209 printf ("Bad number of FSL\nUsage:\n%s\n", cmdtp->usage);
210 return 1;
211 }
212
213 switch (fslnum) {
214#if (XILINX_FSL_NUMBER > 0)
215 case 0:
Michal Simekee1aced2007-05-08 14:39:11 +0200216 switch (blocking) {
217 case 0: NPUT (num, 0);
218 break;
219 case 1: NCPUT (num, 0);
220 break;
221 case 2: PUT (num, 0);
222 break;
223 case 3: CPUT (num, 0);
224 break;
225 default:
226 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200227 }
228 break;
229#endif
230#if (XILINX_FSL_NUMBER > 1)
231 case 1:
Michal Simekee1aced2007-05-08 14:39:11 +0200232 switch (blocking) {
233 case 0: NPUT (num, 1);
234 break;
235 case 1: NCPUT (num, 1);
236 break;
237 case 2: PUT (num, 1);
238 break;
239 case 3: CPUT (num, 1);
240 break;
241 default:
242 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200243 }
244 break;
245#endif
246#if (XILINX_FSL_NUMBER > 2)
247 case 2:
Michal Simekee1aced2007-05-08 14:39:11 +0200248 switch (blocking) {
249 case 0: NPUT (num, 2);
250 break;
251 case 1: NCPUT (num, 2);
252 break;
253 case 2: PUT (num, 2);
254 break;
255 case 3: CPUT (num, 2);
256 break;
257 default:
258 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200259 }
260 break;
261#endif
262#if (XILINX_FSL_NUMBER > 3)
263 case 3:
Michal Simekee1aced2007-05-08 14:39:11 +0200264 switch (blocking) {
265 case 0: NPUT (num, 3);
266 break;
267 case 1: NCPUT (num, 3);
268 break;
269 case 2: PUT (num, 3);
270 break;
271 case 3: CPUT (num, 3);
272 break;
273 default:
274 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200275 }
276 break;
277#endif
278#if (XILINX_FSL_NUMBER > 4)
279 case 4:
Michal Simekee1aced2007-05-08 14:39:11 +0200280 switch (blocking) {
281 case 0: NPUT (num, 4);
282 break;
283 case 1: NCPUT (num, 4);
284 break;
285 case 2: PUT (num, 4);
286 break;
287 case 3: CPUT (num, 4);
288 break;
289 default:
290 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200291 }
292 break;
293#endif
294#if (XILINX_FSL_NUMBER > 5)
295 case 5:
Michal Simekee1aced2007-05-08 14:39:11 +0200296 switch (blocking) {
297 case 0: NPUT (num, 5);
298 break;
299 case 1: NCPUT (num, 5);
300 break;
301 case 2: PUT (num, 5);
302 break;
303 case 3: CPUT (num, 5);
304 break;
305 default:
306 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200307 }
308 break;
309#endif
310#if (XILINX_FSL_NUMBER > 6)
311 case 6:
Michal Simekee1aced2007-05-08 14:39:11 +0200312 switch (blocking) {
313 case 0: NPUT (num, 6);
314 break;
315 case 1: NCPUT (num, 6);
316 break;
317 case 2: PUT (num, 6);
318 break;
319 case 3: CPUT (num, 6);
320 break;
321 default:
322 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200323 }
324 break;
325#endif
326#if (XILINX_FSL_NUMBER > 7)
327 case 7:
Michal Simekee1aced2007-05-08 14:39:11 +0200328 switch (blocking) {
329 case 0: NPUT (num, 7);
330 break;
331 case 1: NCPUT (num, 7);
332 break;
333 case 2: PUT (num, 7);
334 break;
335 case 3: CPUT (num, 7);
336 break;
337 default:
338 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200339 }
340 break;
341#endif
342 default:
343 return 1;
344 }
345
Michal Simekee1aced2007-05-08 14:39:11 +0200346 printf ("%01x: 0x%08lx - %s %s write\n", fslnum, num,
347 blocking < 2 ? "non blocking" : "blocking",
348 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
Michal Simek6455ac02007-05-05 18:27:16 +0200349 return 0;
350
351}
352
Michal Simekebf7b232007-05-08 15:57:43 +0200353int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
Michal Simek6455ac02007-05-05 18:27:16 +0200354{
Michal Simekebf7b232007-05-08 15:57:43 +0200355 unsigned int reg = 0;
Michal Simek603aa742007-05-07 17:11:09 +0200356 unsigned int val = 0;
Michal Simek6455ac02007-05-05 18:27:16 +0200357
Michal Simekebf7b232007-05-08 15:57:43 +0200358 reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
359 val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
Michal Simek3e928412007-09-24 00:08:37 +0200360 if (argc < 1) {
Michal Simek6455ac02007-05-05 18:27:16 +0200361 printf ("Usage:\n%s\n", cmdtp->usage);
362 return 1;
363 }
Michal Simekebf7b232007-05-08 15:57:43 +0200364 switch (reg) {
365 case 0x1:
366 if (argc > 2) {
367 MTS (val, rmsr);
368 NOP;
369 MFS (val, rmsr);
370
371 } else {
372 MFS (val, rmsr);
373 }
374 puts ("MSR");
375 break;
376 case 0x3:
377 MFS (val, rear);
378 puts ("EAR");
379 break;
380 case 0x5:
381 MFS (val, resr);
382 puts ("ESR");
383 break;
384 default:
385 return 1;
Michal Simek603aa742007-05-07 17:11:09 +0200386 }
Michal Simekebf7b232007-05-08 15:57:43 +0200387 printf (": 0x%08lx\n", val);
Michal Simek6455ac02007-05-05 18:27:16 +0200388 return 0;
389}
390
391/***************************************************/
392
393U_BOOT_CMD (frd, 3, 1, do_frd,
Michal Simekee1aced2007-05-08 14:39:11 +0200394 "frd - read data from FSL\n",
395 "- [fslnum [0|1|2|3]]\n"
396 " 0 - non blocking data read\n"
397 " 1 - non blocking control read\n"
398 " 2 - blocking data read\n"
399 " 3 - blocking control read\n");
400
Michal Simek6455ac02007-05-05 18:27:16 +0200401
402U_BOOT_CMD (fwr, 4, 1, do_fwr,
Michal Simekee1aced2007-05-08 14:39:11 +0200403 "fwr - write data to FSL\n",
404 "- [fslnum [0|1|2|3]]\n"
405 " 0 - non blocking data write\n"
406 " 1 - non blocking control write\n"
407 " 2 - blocking data write\n"
408 " 3 - blocking control write\n");
Michal Simek6455ac02007-05-05 18:27:16 +0200409
Michal Simekebf7b232007-05-08 15:57:43 +0200410U_BOOT_CMD (rspr, 3, 1, do_rspr,
Michal Simek3e928412007-09-24 00:08:37 +0200411 "rmsr - read/write special purpose register\n",
Michal Simekebf7b232007-05-08 15:57:43 +0200412 "- reg_num [write value] read/write special purpose register\n"
Michal Simek3e928412007-09-24 00:08:37 +0200413 " 0 - MSR - Machine status register\n"
414 " 1 - EAR - Exception address register\n"
415 " 2 - ESR - Exception status register\n");
Michal Simek6455ac02007-05-05 18:27:16 +0200416
Jon Loeligerd704d912007-07-10 11:02:44 -0500417#endif