]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - common/cmd_mfsl.c
Fix unused function in cmd_bdinfo.c
[karo-tx-uboot.git] / common / cmd_mfsl.c
1 /*
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>
32 #include <asm/asm.h>
33
34 int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
35 {
36         unsigned int fslnum;
37         unsigned int num;
38         unsigned int blocking;
39
40         if (argc < 2)
41                 return cmd_usage(cmdtp);
42
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");
47                 return cmd_usage(cmdtp);
48         }
49
50         switch (fslnum) {
51 #if (XILINX_FSL_NUMBER > 0)
52         case 0:
53                 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;
64                 }
65                 break;
66 #endif
67 #if (XILINX_FSL_NUMBER > 1)
68         case 1:
69                 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;
80                 }
81                 break;
82 #endif
83 #if (XILINX_FSL_NUMBER > 2)
84         case 2:
85                 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;
96                 }
97                 break;
98 #endif
99 #if (XILINX_FSL_NUMBER > 3)
100         case 3:
101                 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;
112                 }
113                 break;
114 #endif
115 #if (XILINX_FSL_NUMBER > 4)
116         case 4:
117                 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;
128                 }
129                 break;
130 #endif
131 #if (XILINX_FSL_NUMBER > 5)
132         case 5:
133                 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;
144                 }
145                 break;
146 #endif
147 #if (XILINX_FSL_NUMBER > 6)
148         case 6:
149                 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;
160                 }
161                 break;
162 #endif
163 #if (XILINX_FSL_NUMBER > 7)
164         case 7:
165                 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;
176                 }
177                 break;
178 #endif
179         default:
180                 return 1;
181         }
182
183         printf ("%01x: 0x%08x - %s %s read\n", fslnum, num,
184                 blocking < 2  ? "non blocking" : "blocking",
185                 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
186         return 0;
187 }
188
189 int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
190 {
191         unsigned int fslnum;
192         unsigned int num;
193         unsigned int blocking;
194
195         if (argc < 3)
196                 return cmd_usage(cmdtp);
197
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);
201         if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER)
202                 return cmd_usage(cmdtp);
203
204         switch (fslnum) {
205 #if (XILINX_FSL_NUMBER > 0)
206         case 0:
207                 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;
218                 }
219                 break;
220 #endif
221 #if (XILINX_FSL_NUMBER > 1)
222         case 1:
223                 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;
234                 }
235                 break;
236 #endif
237 #if (XILINX_FSL_NUMBER > 2)
238         case 2:
239                 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;
250                 }
251                 break;
252 #endif
253 #if (XILINX_FSL_NUMBER > 3)
254         case 3:
255                 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;
266                 }
267                 break;
268 #endif
269 #if (XILINX_FSL_NUMBER > 4)
270         case 4:
271                 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;
282                 }
283                 break;
284 #endif
285 #if (XILINX_FSL_NUMBER > 5)
286         case 5:
287                 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;
298                 }
299                 break;
300 #endif
301 #if (XILINX_FSL_NUMBER > 6)
302         case 6:
303                 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;
314                 }
315                 break;
316 #endif
317 #if (XILINX_FSL_NUMBER > 7)
318         case 7:
319                 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;
330                 }
331                 break;
332 #endif
333         default:
334                 return 1;
335         }
336
337         printf ("%01x: 0x%08x - %s %s write\n", fslnum, num,
338                 blocking < 2  ? "non blocking" : "blocking",
339                 ((blocking == 1) || (blocking == 3)) ? "control" : "data" );
340         return 0;
341
342 }
343
344 int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
345 {
346         unsigned int reg = 0;
347         unsigned int val = 0;
348
349         if (argc < 2)
350                 return cmd_usage(cmdtp);
351
352         reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
353         val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
354         switch (reg) {
355         case 0x1:
356                 if (argc > 2) {
357                         MTS (val, rmsr);
358                         NOP;
359                         MFS (val, rmsr);
360                 } 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:
374                 puts ("Unsupported register\n");
375                 return 1;
376         }
377         printf (": 0x%08x\n", val);
378         return 0;
379 }
380
381 /***************************************************/
382
383 U_BOOT_CMD (frd, 3, 1, do_frd,
384                 "read data from FSL",
385                 "- [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"
389                 " 3 - blocking control read");
390
391 U_BOOT_CMD (fwr, 4, 1, do_fwr,
392                 "write data to FSL",
393                 "- [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"
397                 " 3 - blocking control write");
398
399 U_BOOT_CMD (rspr, 3, 1, do_rspr,
400                 "read/write special purpose register",
401                 "- reg_num [write value] read/write special purpose register\n"
402                 " 1 - MSR - Machine status register\n"
403                 " 3 - EAR - Exception address register\n"
404                 " 5 - ESR - Exception status register");