Blame view

cmd/mfsl.c 6.66 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
100ea07e3   Michal Simek   common: fsl: Fix ...
2
3
4
5
  /*
   * (C) Copyright 2007 Michal Simek
   *
   * Michal  SIMEK <monstr@monstr.eu>
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
6
7
8
9
10
11
12
13
14
   */
  
  /*
   * Microblaze FSL support
   */
  
  #include <common.h>
  #include <config.h>
  #include <command.h>
70124c260   Stefano Babic   Fix compile probl...
15
  #include <asm/asm.h>
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
16

54841ab50   Wolfgang Denk   Make sure that ar...
17
  int do_frd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
18
19
20
21
  {
  	unsigned int fslnum;
  	unsigned int num;
  	unsigned int blocking;
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
22
  	if (argc < 2)
4c12eeb8b   Simon Glass   Convert cmd_usage...
23
  		return CMD_RET_USAGE;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
24
25
26
27
28
29
  
  	fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  	blocking = (unsigned int)simple_strtoul (argv[2], NULL, 16);
  	if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) {
  		puts ("Bad number of FSL
  ");
4c12eeb8b   Simon Glass   Convert cmd_usage...
30
  		return CMD_RET_USAGE;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
31
32
33
34
35
  	}
  
  	switch (fslnum) {
  #if (XILINX_FSL_NUMBER > 0)
  	case 0:
ab874d504   Michal Simek   add: FSL control ...
36
37
38
39
40
41
42
43
44
45
46
  		switch (blocking) {
  		case 0:	NGET (num, 0);
  			break;
  		case 1:	NCGET (num, 0);
  			break;
  		case 2:	GET (num, 0);
  			break;
  		case 3:	CGET (num, 0);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
47
48
49
50
51
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 1)
  	case 1:
ab874d504   Michal Simek   add: FSL control ...
52
53
54
55
56
57
58
59
60
61
62
  		switch (blocking) {
  		case 0:	NGET (num, 1);
  			break;
  		case 1:	NCGET (num, 1);
  			break;
  		case 2:	GET (num, 1);
  			break;
  		case 3:	CGET (num, 1);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
63
64
65
66
67
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 2)
  	case 2:
ab874d504   Michal Simek   add: FSL control ...
68
69
70
71
72
73
74
75
76
77
78
  		switch (blocking) {
  		case 0:	NGET (num, 2);
  			break;
  		case 1:	NCGET (num, 2);
  			break;
  		case 2:	GET (num, 2);
  			break;
  		case 3:	CGET (num, 2);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
79
80
81
82
83
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 3)
  	case 3:
ab874d504   Michal Simek   add: FSL control ...
84
85
86
87
88
89
90
91
92
93
94
  		switch (blocking) {
  		case 0:	NGET (num, 3);
  			break;
  		case 1:	NCGET (num, 3);
  			break;
  		case 2:	GET (num, 3);
  			break;
  		case 3:	CGET (num, 3);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
95
96
97
98
99
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 4)
  	case 4:
ab874d504   Michal Simek   add: FSL control ...
100
101
102
103
104
105
106
107
108
109
110
  		switch (blocking) {
  		case 0:	NGET (num, 4);
  			break;
  		case 1:	NCGET (num, 4);
  			break;
  		case 2:	GET (num, 4);
  			break;
  		case 3:	CGET (num, 4);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
111
112
113
114
115
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 5)
  	case 5:
ab874d504   Michal Simek   add: FSL control ...
116
117
118
119
120
121
122
123
124
125
126
  		switch (blocking) {
  		case 0:	NGET (num, 5);
  			break;
  		case 1:	NCGET (num, 5);
  			break;
  		case 2:	GET (num, 5);
  			break;
  		case 3:	CGET (num, 5);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
127
128
129
130
131
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 6)
  	case 6:
ab874d504   Michal Simek   add: FSL control ...
132
133
134
135
136
137
138
139
140
141
142
  		switch (blocking) {
  		case 0:	NGET (num, 6);
  			break;
  		case 1:	NCGET (num, 6);
  			break;
  		case 2:	GET (num, 6);
  			break;
  		case 3:	CGET (num, 6);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
143
144
145
146
147
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 7)
  	case 7:
ab874d504   Michal Simek   add: FSL control ...
148
149
150
151
152
153
154
155
156
157
158
  		switch (blocking) {
  		case 0:	NGET (num, 7);
  			break;
  		case 1:	NCGET (num, 7);
  			break;
  		case 2:	GET (num, 7);
  			break;
  		case 3:	CGET (num, 7);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
159
160
161
162
163
164
  		}
  		break;
  #endif
  	default:
  		return 1;
  	}
f2302d443   Stefan Roese   Fix merge problems
165
166
  	printf ("%01x: 0x%08x - %s %s read
  ", fslnum, num,
ab874d504   Michal Simek   add: FSL control ...
167
168
  		blocking < 2  ? "non blocking" : "blocking",
  		((blocking == 1) || (blocking == 3)) ? "control" : "data" );
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
169
170
  	return 0;
  }
54841ab50   Wolfgang Denk   Make sure that ar...
171
  int do_fwr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
172
173
174
175
  {
  	unsigned int fslnum;
  	unsigned int num;
  	unsigned int blocking;
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
176
  	if (argc < 3)
4c12eeb8b   Simon Glass   Convert cmd_usage...
177
  		return CMD_RET_USAGE;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
178
179
180
181
  
  	fslnum = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  	num = (unsigned int)simple_strtoul (argv[2], NULL, 16);
  	blocking = (unsigned int)simple_strtoul (argv[3], NULL, 16);
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
182
  	if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER)
4c12eeb8b   Simon Glass   Convert cmd_usage...
183
  		return CMD_RET_USAGE;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
184
185
186
187
  
  	switch (fslnum) {
  #if (XILINX_FSL_NUMBER > 0)
  	case 0:
ab874d504   Michal Simek   add: FSL control ...
188
189
190
191
192
193
194
195
196
197
198
  		switch (blocking) {
  		case 0:	NPUT (num, 0);
  			break;
  		case 1:	NCPUT (num, 0);
  			break;
  		case 2:	PUT (num, 0);
  			break;
  		case 3:	CPUT (num, 0);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
199
200
201
202
203
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 1)
  	case 1:
ab874d504   Michal Simek   add: FSL control ...
204
205
206
207
208
209
210
211
212
213
214
  		switch (blocking) {
  		case 0:	NPUT (num, 1);
  			break;
  		case 1:	NCPUT (num, 1);
  			break;
  		case 2:	PUT (num, 1);
  			break;
  		case 3:	CPUT (num, 1);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
215
216
217
218
219
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 2)
  	case 2:
ab874d504   Michal Simek   add: FSL control ...
220
221
222
223
224
225
226
227
228
229
230
  		switch (blocking) {
  		case 0:	NPUT (num, 2);
  			break;
  		case 1:	NCPUT (num, 2);
  			break;
  		case 2:	PUT (num, 2);
  			break;
  		case 3:	CPUT (num, 2);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
231
232
233
234
235
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 3)
  	case 3:
ab874d504   Michal Simek   add: FSL control ...
236
237
238
239
240
241
242
243
244
245
246
  		switch (blocking) {
  		case 0:	NPUT (num, 3);
  			break;
  		case 1:	NCPUT (num, 3);
  			break;
  		case 2:	PUT (num, 3);
  			break;
  		case 3:	CPUT (num, 3);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
247
248
249
250
251
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 4)
  	case 4:
ab874d504   Michal Simek   add: FSL control ...
252
253
254
255
256
257
258
259
260
261
262
  		switch (blocking) {
  		case 0:	NPUT (num, 4);
  			break;
  		case 1:	NCPUT (num, 4);
  			break;
  		case 2:	PUT (num, 4);
  			break;
  		case 3:	CPUT (num, 4);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
263
264
265
266
267
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 5)
  	case 5:
ab874d504   Michal Simek   add: FSL control ...
268
269
270
271
272
273
274
275
276
277
278
  		switch (blocking) {
  		case 0:	NPUT (num, 5);
  			break;
  		case 1:	NCPUT (num, 5);
  			break;
  		case 2:	PUT (num, 5);
  			break;
  		case 3:	CPUT (num, 5);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
279
280
281
282
283
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 6)
  	case 6:
ab874d504   Michal Simek   add: FSL control ...
284
285
286
287
288
289
290
291
292
293
294
  		switch (blocking) {
  		case 0:	NPUT (num, 6);
  			break;
  		case 1:	NCPUT (num, 6);
  			break;
  		case 2:	PUT (num, 6);
  			break;
  		case 3:	CPUT (num, 6);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
295
296
297
298
299
  		}
  		break;
  #endif
  #if (XILINX_FSL_NUMBER > 7)
  	case 7:
ab874d504   Michal Simek   add: FSL control ...
300
301
302
303
304
305
306
307
308
309
310
  		switch (blocking) {
  		case 0:	NPUT (num, 7);
  			break;
  		case 1:	NCPUT (num, 7);
  			break;
  		case 2:	PUT (num, 7);
  			break;
  		case 3:	CPUT (num, 7);
  			break;
  		default:
  			return 2;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
311
312
313
314
315
316
  		}
  		break;
  #endif
  	default:
  		return 1;
  	}
f2302d443   Stefan Roese   Fix merge problems
317
318
  	printf ("%01x: 0x%08x - %s %s write
  ", fslnum, num,
ab874d504   Michal Simek   add: FSL control ...
319
320
  		blocking < 2  ? "non blocking" : "blocking",
  		((blocking == 1) || (blocking == 3)) ? "control" : "data" );
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
321
322
323
  	return 0;
  
  }
54841ab50   Wolfgang Denk   Make sure that ar...
324
  int do_rspr (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
325
  {
e69f66c6e   Michal Simek   add: reading spec...
326
  	unsigned int reg = 0;
48fbd3a4c   Michal Simek   new: add writing ...
327
  	unsigned int val = 0;
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
328

47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
329
  	if (argc < 2)
4c12eeb8b   Simon Glass   Convert cmd_usage...
330
  		return CMD_RET_USAGE;
47e26b1bf   Wolfgang Denk   cmd_usage(): simp...
331

481d43286   Michal Simek   [FIX] repair MFSL...
332
333
  	reg = (unsigned int)simple_strtoul (argv[1], NULL, 16);
  	val = (unsigned int)simple_strtoul (argv[2], NULL, 16);
e69f66c6e   Michal Simek   add: reading spec...
334
335
336
337
338
339
  	switch (reg) {
  	case 0x1:
  		if (argc > 2) {
  			MTS (val, rmsr);
  			NOP;
  			MFS (val, rmsr);
e69f66c6e   Michal Simek   add: reading spec...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
  		} else {
  			MFS (val, rmsr);
  		}
  		puts ("MSR");
  		break;
  	case 0x3:
  		MFS (val, rear);
  		puts ("EAR");
  		break;
  	case 0x5:
  		MFS (val, resr);
  		puts ("ESR");
  		break;
  	default:
481d43286   Michal Simek   [FIX] repair MFSL...
354
355
  		puts ("Unsupported register
  ");
e69f66c6e   Michal Simek   add: reading spec...
356
  		return 1;
48fbd3a4c   Michal Simek   new: add writing ...
357
  	}
f2302d443   Stefan Roese   Fix merge problems
358
359
  	printf (": 0x%08x
  ", val);
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
360
361
362
363
364
365
  	return 0;
  }
  
  /***************************************************/
  
  U_BOOT_CMD (frd, 3, 1, do_frd,
2fb2604d5   Peter Tyser   Command usage cle...
366
  		"read data from FSL",
ab874d504   Michal Simek   add: FSL control ...
367
368
369
370
371
372
373
374
  		"- [fslnum [0|1|2|3]]
  "
  		" 0 - non blocking data read
  "
  		" 1 - non blocking control read
  "
  		" 2 - blocking data read
  "
a89c33db9   Wolfgang Denk   General help mess...
375
  		" 3 - blocking control read");
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
376
377
  
  U_BOOT_CMD (fwr, 4, 1, do_fwr,
2fb2604d5   Peter Tyser   Command usage cle...
378
  		"write data to FSL",
ab874d504   Michal Simek   add: FSL control ...
379
380
381
382
383
384
385
386
  		"- [fslnum [0|1|2|3]]
  "
  		" 0 - non blocking data write
  "
  		" 1 - non blocking control write
  "
  		" 2 - blocking data write
  "
a89c33db9   Wolfgang Denk   General help mess...
387
  		" 3 - blocking control write");
f7e2e0eb0   Michal Simek   new: FSL and MSR ...
388

e69f66c6e   Michal Simek   add: reading spec...
389
  U_BOOT_CMD (rspr, 3, 1, do_rspr,
2fb2604d5   Peter Tyser   Command usage cle...
390
  		"read/write special purpose register",
e69f66c6e   Michal Simek   add: reading spec...
391
392
  		"- reg_num [write value] read/write special purpose register
  "
481d43286   Michal Simek   [FIX] repair MFSL...
393
394
395
396
  		" 1 - MSR - Machine status register
  "
  		" 3 - EAR - Exception address register
  "
a89c33db9   Wolfgang Denk   General help mess...
397
  		" 5 - ESR - Exception status register");