blob: ddf80d71ffdbce209c0e3775c097a3c0a3d87d19 [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>
Stefano Babic68f16f82007-05-16 14:49:12 +020032#include <asm/asm.h>
Michal Simek6455ac02007-05-05 18:27:16 +020033
Wolfgang Denk6262d0212010-06-28 22:00:46 +020034int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Michal Simek6455ac02007-05-05 18:27:16 +020035{
36 unsigned int fslnum;
37 unsigned int num;
38 unsigned int blocking;
39
Wolfgang Denk3b683112010-07-17 01:06:04 +020040 if (argc < 2)
Simon Glassa06dfc72011-12-10 08:44:01 +000041 return CMD_RET_USAGE;
Michal Simek6455ac02007-05-05 18:27:16 +020042
43 fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
44 blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
45 if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
46 puts ("Bad number of FSL\n");
Simon Glassa06dfc72011-12-10 08:44:01 +000047 return CMD_RET_USAGE;
Michal Simek6455ac02007-05-05 18:27:16 +020048 }
49
50 switch (fslnum) {
51#if (XILINX_FSL_NUMBER > 0)
52 case 0:
Michal Simekee1aced2007-05-08 14:39:11 +020053 switch (blocking) {
54 case 0: NGET (num, 0);
55 break;
56 case 1: NCGET (num, 0);
57 break;
58 case 2: GET (num, 0);
59 break;
60 case 3: CGET (num, 0);
61 break;
62 default:
63 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020064 }
65 break;
66#endif
67#if (XILINX_FSL_NUMBER > 1)
68 case 1:
Michal Simekee1aced2007-05-08 14:39:11 +020069 switch (blocking) {
70 case 0: NGET (num, 1);
71 break;
72 case 1: NCGET (num, 1);
73 break;
74 case 2: GET (num, 1);
75 break;
76 case 3: CGET (num, 1);
77 break;
78 default:
79 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020080 }
81 break;
82#endif
83#if (XILINX_FSL_NUMBER > 2)
84 case 2:
Michal Simekee1aced2007-05-08 14:39:11 +020085 switch (blocking) {
86 case 0: NGET (num, 2);
87 break;
88 case 1: NCGET (num, 2);
89 break;
90 case 2: GET (num, 2);
91 break;
92 case 3: CGET (num, 2);
93 break;
94 default:
95 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +020096 }
97 break;
98#endif
99#if (XILINX_FSL_NUMBER > 3)
100 case 3:
Michal Simekee1aced2007-05-08 14:39:11 +0200101 switch (blocking) {
102 case 0: NGET (num, 3);
103 break;
104 case 1: NCGET (num, 3);
105 break;
106 case 2: GET (num, 3);
107 break;
108 case 3: CGET (num, 3);
109 break;
110 default:
111 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200112 }
113 break;
114#endif
115#if (XILINX_FSL_NUMBER > 4)
116 case 4:
Michal Simekee1aced2007-05-08 14:39:11 +0200117 switch (blocking) {
118 case 0: NGET (num, 4);
119 break;
120 case 1: NCGET (num, 4);
121 break;
122 case 2: GET (num, 4);
123 break;
124 case 3: CGET (num, 4);
125 break;
126 default:
127 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200128 }
129 break;
130#endif
131#if (XILINX_FSL_NUMBER > 5)
132 case 5:
Michal Simekee1aced2007-05-08 14:39:11 +0200133 switch (blocking) {
134 case 0: NGET (num, 5);
135 break;
136 case 1: NCGET (num, 5);
137 break;
138 case 2: GET (num, 5);
139 break;
140 case 3: CGET (num, 5);
141 break;
142 default:
143 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200144 }
145 break;
146#endif
147#if (XILINX_FSL_NUMBER > 6)
148 case 6:
Michal Simekee1aced2007-05-08 14:39:11 +0200149 switch (blocking) {
150 case 0: NGET (num, 6);
151 break;
152 case 1: NCGET (num, 6);
153 break;
154 case 2: GET (num, 6);
155 break;
156 case 3: CGET (num, 6);
157 break;
158 default:
159 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200160 }
161 break;
162#endif
163#if (XILINX_FSL_NUMBER > 7)
164 case 7:
Michal Simekee1aced2007-05-08 14:39:11 +0200165 switch (blocking) {
166 case 0: NGET (num, 7);
167 break;
168 case 1: NCGET (num, 7);
169 break;
170 case 2: GET (num, 7);
171 break;
172 case 3: CGET (num, 7);
173 break;
174 default:
175 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200176 }
177 break;
178#endif
179 default:
180 return 1;
181 }
182
Stefan Roese37628252008-08-06 14:05:38 +0200183 printf ("%01x: 0x%08x - %s %s read\n", fslnum, num,
Michal Simekee1aced2007-05-08 14:39:11 +0200184 blocking < 2 ? "non blocking" : "blocking",
185 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
Michal Simek6455ac02007-05-05 18:27:16 +0200186 return 0;
187}
188
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200189int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Michal Simek6455ac02007-05-05 18:27:16 +0200190{
191 unsigned int fslnum;
192 unsigned int num;
193 unsigned int blocking;
194
Wolfgang Denk3b683112010-07-17 01:06:04 +0200195 if (argc < 3)
Simon Glassa06dfc72011-12-10 08:44:01 +0000196 return CMD_RET_USAGE;
Michal Simek6455ac02007-05-05 18:27:16 +0200197
198 fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
199 num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
200 blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
Wolfgang Denk3b683112010-07-17 01:06:04 +0200201 if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER)
Simon Glassa06dfc72011-12-10 08:44:01 +0000202 return CMD_RET_USAGE;
Michal Simek6455ac02007-05-05 18:27:16 +0200203
204 switch (fslnum) {
205#if (XILINX_FSL_NUMBER > 0)
206 case 0:
Michal Simekee1aced2007-05-08 14:39:11 +0200207 switch (blocking) {
208 case 0: NPUT (num, 0);
209 break;
210 case 1: NCPUT (num, 0);
211 break;
212 case 2: PUT (num, 0);
213 break;
214 case 3: CPUT (num, 0);
215 break;
216 default:
217 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200218 }
219 break;
220#endif
221#if (XILINX_FSL_NUMBER > 1)
222 case 1:
Michal Simekee1aced2007-05-08 14:39:11 +0200223 switch (blocking) {
224 case 0: NPUT (num, 1);
225 break;
226 case 1: NCPUT (num, 1);
227 break;
228 case 2: PUT (num, 1);
229 break;
230 case 3: CPUT (num, 1);
231 break;
232 default:
233 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200234 }
235 break;
236#endif
237#if (XILINX_FSL_NUMBER > 2)
238 case 2:
Michal Simekee1aced2007-05-08 14:39:11 +0200239 switch (blocking) {
240 case 0: NPUT (num, 2);
241 break;
242 case 1: NCPUT (num, 2);
243 break;
244 case 2: PUT (num, 2);
245 break;
246 case 3: CPUT (num, 2);
247 break;
248 default:
249 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200250 }
251 break;
252#endif
253#if (XILINX_FSL_NUMBER > 3)
254 case 3:
Michal Simekee1aced2007-05-08 14:39:11 +0200255 switch (blocking) {
256 case 0: NPUT (num, 3);
257 break;
258 case 1: NCPUT (num, 3);
259 break;
260 case 2: PUT (num, 3);
261 break;
262 case 3: CPUT (num, 3);
263 break;
264 default:
265 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200266 }
267 break;
268#endif
269#if (XILINX_FSL_NUMBER > 4)
270 case 4:
Michal Simekee1aced2007-05-08 14:39:11 +0200271 switch (blocking) {
272 case 0: NPUT (num, 4);
273 break;
274 case 1: NCPUT (num, 4);
275 break;
276 case 2: PUT (num, 4);
277 break;
278 case 3: CPUT (num, 4);
279 break;
280 default:
281 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200282 }
283 break;
284#endif
285#if (XILINX_FSL_NUMBER > 5)
286 case 5:
Michal Simekee1aced2007-05-08 14:39:11 +0200287 switch (blocking) {
288 case 0: NPUT (num, 5);
289 break;
290 case 1: NCPUT (num, 5);
291 break;
292 case 2: PUT (num, 5);
293 break;
294 case 3: CPUT (num, 5);
295 break;
296 default:
297 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200298 }
299 break;
300#endif
301#if (XILINX_FSL_NUMBER > 6)
302 case 6:
Michal Simekee1aced2007-05-08 14:39:11 +0200303 switch (blocking) {
304 case 0: NPUT (num, 6);
305 break;
306 case 1: NCPUT (num, 6);
307 break;
308 case 2: PUT (num, 6);
309 break;
310 case 3: CPUT (num, 6);
311 break;
312 default:
313 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200314 }
315 break;
316#endif
317#if (XILINX_FSL_NUMBER > 7)
318 case 7:
Michal Simekee1aced2007-05-08 14:39:11 +0200319 switch (blocking) {
320 case 0: NPUT (num, 7);
321 break;
322 case 1: NCPUT (num, 7);
323 break;
324 case 2: PUT (num, 7);
325 break;
326 case 3: CPUT (num, 7);
327 break;
328 default:
329 return 2;
Michal Simek6455ac02007-05-05 18:27:16 +0200330 }
331 break;
332#endif
333 default:
334 return 1;
335 }
336
Stefan Roese37628252008-08-06 14:05:38 +0200337 printf ("%01x: 0x%08x - %s %s write\n", fslnum, num,
Michal Simekee1aced2007-05-08 14:39:11 +0200338 blocking < 2 ? "non blocking" : "blocking",
339 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
Michal Simek6455ac02007-05-05 18:27:16 +0200340 return 0;
341
342}
343
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200344int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Michal Simek6455ac02007-05-05 18:27:16 +0200345{
Michal Simekebf7b232007-05-08 15:57:43 +0200346 unsigned int reg = 0;
Michal Simek603aa742007-05-07 17:11:09 +0200347 unsigned int val = 0;
Michal Simek6455ac02007-05-05 18:27:16 +0200348
Wolfgang Denk3b683112010-07-17 01:06:04 +0200349 if (argc < 2)
Simon Glassa06dfc72011-12-10 08:44:01 +0000350 return CMD_RET_USAGE;
Wolfgang Denk3b683112010-07-17 01:06:04 +0200351
Michal Simek25e1ddb2007-09-24 00:17:42 +0200352 reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
353 val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
Michal Simekebf7b232007-05-08 15:57:43 +0200354 switch (reg) {
355 case 0x1:
356 if (argc > 2) {
357 MTS (val, rmsr);
358 NOP;
359 MFS (val, rmsr);
Michal Simekebf7b232007-05-08 15:57:43 +0200360 } else {
361 MFS (val, rmsr);
362 }
363 puts ("MSR");
364 break;
365 case 0x3:
366 MFS (val, rear);
367 puts ("EAR");
368 break;
369 case 0x5:
370 MFS (val, resr);
371 puts ("ESR");
372 break;
373 default:
Michal Simek25e1ddb2007-09-24 00:17:42 +0200374 puts ("Unsupported register\n");
Michal Simekebf7b232007-05-08 15:57:43 +0200375 return 1;
Michal Simek603aa742007-05-07 17:11:09 +0200376 }
Stefan Roese37628252008-08-06 14:05:38 +0200377 printf (": 0x%08x\n", val);
Michal Simek6455ac02007-05-05 18:27:16 +0200378 return 0;
379}
380
381/***************************************************/
382
383U_BOOT_CMD (frd, 3, 1, do_frd,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600384 "read data from FSL",
Michal Simekee1aced2007-05-08 14:39:11 +0200385 "- [fslnum [0|1|2|3]]\n"
386 " 0 - non blocking data read\n"
387 " 1 - non blocking control read\n"
388 " 2 - blocking data read\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200389 " 3 - blocking control read");
Michal Simek6455ac02007-05-05 18:27:16 +0200390
391U_BOOT_CMD (fwr, 4, 1, do_fwr,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600392 "write data to FSL",
Michal Simekee1aced2007-05-08 14:39:11 +0200393 "- [fslnum [0|1|2|3]]\n"
394 " 0 - non blocking data write\n"
395 " 1 - non blocking control write\n"
396 " 2 - blocking data write\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200397 " 3 - blocking control write");
Michal Simek6455ac02007-05-05 18:27:16 +0200398
Michal Simekebf7b232007-05-08 15:57:43 +0200399U_BOOT_CMD (rspr, 3, 1, do_rspr,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600400 "read/write special purpose register",
Michal Simekebf7b232007-05-08 15:57:43 +0200401 "- reg_num [write value] read/write special purpose register\n"
Michal Simek25e1ddb2007-09-24 00:17:42 +0200402 " 1 - MSR - Machine status register\n"
403 " 3 - EAR - Exception address register\n"
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200404 " 5 - ESR - Exception status register");