powerpc/mpc85xx:Disable Debug TLB entry before init_tlbs
[platform/kernel/u-boot.git] / common / cmd_bdinfo.c
1 /*
2  * (C) Copyright 2003
3  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23
24 /*
25  * Boot support
26  */
27 #include <common.h>
28 #include <command.h>
29 #include <linux/compiler.h>
30
31 DECLARE_GLOBAL_DATA_PTR;
32
33 __maybe_unused
34 static void print_num(const char *name, ulong value)
35 {
36         printf("%-12s= 0x%08lX\n", name, value);
37 }
38
39 __maybe_unused
40 static void print_eth(int idx)
41 {
42         char name[10], *val;
43         if (idx)
44                 sprintf(name, "eth%iaddr", idx);
45         else
46                 strcpy(name, "ethaddr");
47         val = getenv(name);
48         if (!val)
49                 val = "(not set)";
50         printf("%-12s= %s\n", name, val);
51 }
52
53 __maybe_unused
54 static void print_eths(void)
55 {
56         struct eth_device *dev;
57         int i = 0;
58
59         do {
60                 dev = eth_get_dev_by_index(i);
61                 if (dev) {
62                         printf("eth%dname    = %s\n", i, dev->name);
63                         print_eth(i);
64                         i++;
65                 }
66         } while (dev);
67
68         printf("current eth = %s\n", eth_get_name());
69         printf("ip_addr     = %s\n", getenv("ipaddr"));
70 }
71
72 __maybe_unused
73 static void print_lnum(const char *name, unsigned long long value)
74 {
75         printf("%-12s= 0x%.8llX\n", name, value);
76 }
77
78 __maybe_unused
79 static void print_mhz(const char *name, unsigned long hz)
80 {
81         char buf[32];
82
83         printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
84 }
85
86 #if defined(CONFIG_PPC)
87 void __weak board_detail(void)
88 {
89         /* Please define boot_detail() for your platform */
90 }
91
92 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
93 {
94         bd_t *bd = gd->bd;
95
96 #ifdef DEBUG
97         print_num("bd address",         (ulong)bd);
98 #endif
99         print_num("memstart",           bd->bi_memstart);
100         print_lnum("memsize",           bd->bi_memsize);
101         print_num("flashstart",         bd->bi_flashstart);
102         print_num("flashsize",          bd->bi_flashsize);
103         print_num("flashoffset",        bd->bi_flashoffset);
104         print_num("sramstart",          bd->bi_sramstart);
105         print_num("sramsize",           bd->bi_sramsize);
106 #if     defined(CONFIG_5xx)  || defined(CONFIG_8xx) || \
107         defined(CONFIG_8260) || defined(CONFIG_E500)
108         print_num("immr_base",          bd->bi_immr_base);
109 #endif
110         print_num("bootflags",          bd->bi_bootflags);
111 #if     defined(CONFIG_405CR) || defined(CONFIG_405EP) || \
112         defined(CONFIG_405GP) || \
113         defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
114         defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
115         defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
116         defined(CONFIG_XILINX_405)
117         print_mhz("procfreq",           bd->bi_procfreq);
118         print_mhz("plb_busfreq",        bd->bi_plb_busfreq);
119 #if     defined(CONFIG_405EP) || defined(CONFIG_405GP) || \
120         defined(CONFIG_440EP) || defined(CONFIG_440EPX) || \
121         defined(CONFIG_440GR) || defined(CONFIG_440GRX) || \
122         defined(CONFIG_440SPE) || defined(CONFIG_XILINX_405)
123         print_mhz("pci_busfreq",        bd->bi_pci_busfreq);
124 #endif
125 #else   /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
126 #if defined(CONFIG_CPM2)
127         print_mhz("vco",                bd->bi_vco);
128         print_mhz("sccfreq",            bd->bi_sccfreq);
129         print_mhz("brgfreq",            bd->bi_brgfreq);
130 #endif
131         print_mhz("intfreq",            bd->bi_intfreq);
132 #if defined(CONFIG_CPM2)
133         print_mhz("cpmfreq",            bd->bi_cpmfreq);
134 #endif
135         print_mhz("busfreq",            bd->bi_busfreq);
136 #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_405, CONFIG_440EP CONFIG_440GR */
137
138 #ifdef CONFIG_ENABLE_36BIT_PHYS
139 #ifdef CONFIG_PHYS_64BIT
140         puts("addressing  = 36-bit\n");
141 #else
142         puts("addressing  = 32-bit\n");
143 #endif
144 #endif
145
146         print_eth(0);
147 #if defined(CONFIG_HAS_ETH1)
148         print_eth(1);
149 #endif
150 #if defined(CONFIG_HAS_ETH2)
151         print_eth(2);
152 #endif
153 #if defined(CONFIG_HAS_ETH3)
154         print_eth(3);
155 #endif
156 #if defined(CONFIG_HAS_ETH4)
157         print_eth(4);
158 #endif
159 #if defined(CONFIG_HAS_ETH5)
160         print_eth(5);
161 #endif
162
163 #ifdef CONFIG_HERMES
164         print_mhz("ethspeed",           bd->bi_ethspeed);
165 #endif
166         printf("IP addr     = %s\n", getenv("ipaddr"));
167         printf("baudrate    = %6u bps\n", bd->bi_baudrate);
168         print_num("relocaddr", gd->relocaddr);
169         board_detail();
170         return 0;
171 }
172
173 #elif defined(CONFIG_NIOS2)
174
175 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
176 {
177         bd_t *bd = gd->bd;
178
179         print_num("mem start",          (ulong)bd->bi_memstart);
180         print_lnum("mem size",          (u64)bd->bi_memsize);
181         print_num("flash start",        (ulong)bd->bi_flashstart);
182         print_num("flash size",         (ulong)bd->bi_flashsize);
183         print_num("flash offset",       (ulong)bd->bi_flashoffset);
184
185 #if defined(CONFIG_SYS_SRAM_BASE)
186         print_num ("sram start",        (ulong)bd->bi_sramstart);
187         print_num ("sram size",         (ulong)bd->bi_sramsize);
188 #endif
189
190 #if defined(CONFIG_CMD_NET)
191         print_eth(0);
192         printf("ip_addr     = %s\n", getenv("ipaddr"));
193 #endif
194
195         printf("baudrate    = %u bps\n", bd->bi_baudrate);
196
197         return 0;
198 }
199
200 #elif defined(CONFIG_MICROBLAZE)
201
202 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
203 {
204         bd_t *bd = gd->bd;
205         print_num("mem start      ",    (ulong)bd->bi_memstart);
206         print_lnum("mem size       ",   (u64)bd->bi_memsize);
207         print_num("flash start    ",    (ulong)bd->bi_flashstart);
208         print_num("flash size     ",    (ulong)bd->bi_flashsize);
209         print_num("flash offset   ",    (ulong)bd->bi_flashoffset);
210 #if defined(CONFIG_SYS_SRAM_BASE)
211         print_num("sram start     ",    (ulong)bd->bi_sramstart);
212         print_num("sram size      ",    (ulong)bd->bi_sramsize);
213 #endif
214 #if defined(CONFIG_CMD_NET)
215         print_eths();
216 #endif
217         printf("baudrate    = %u bps\n", bd->bi_baudrate);
218         return 0;
219 }
220
221 #elif defined(CONFIG_SPARC)
222
223 int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
224 {
225         bd_t *bd = gd->bd;
226
227 #ifdef DEBUG
228         print_num("bd address             ", (ulong) bd);
229 #endif
230         print_num("memstart               ", bd->bi_memstart);
231         print_lnum("memsize                ", bd->bi_memsize);
232         print_num("flashstart             ", bd->bi_flashstart);
233         print_num("CONFIG_SYS_MONITOR_BASE       ", CONFIG_SYS_MONITOR_BASE);
234         print_num("CONFIG_ENV_ADDR           ", CONFIG_ENV_ADDR);
235         printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%x (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
236                CONFIG_SYS_MONITOR_LEN);
237         printf("CONFIG_SYS_MALLOC_BASE        = 0x%x (%d)\n", CONFIG_SYS_MALLOC_BASE,
238                CONFIG_SYS_MALLOC_LEN);
239         printf("CONFIG_SYS_INIT_SP_OFFSET     = 0x%x (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
240                CONFIG_SYS_STACK_SIZE);
241         printf("CONFIG_SYS_PROM_OFFSET        = 0x%x (%d)\n", CONFIG_SYS_PROM_OFFSET,
242                CONFIG_SYS_PROM_SIZE);
243         printf("CONFIG_SYS_GBL_DATA_OFFSET    = 0x%x (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET,
244                GENERATED_GBL_DATA_SIZE);
245
246 #if defined(CONFIG_CMD_NET)
247         print_eth(0);
248         printf("ip_addr     = %s\n", getenv("ipaddr"));
249 #endif
250         printf("baudrate               = %6u bps\n", bd->bi_baudrate);
251         return 0;
252 }
253
254 #elif defined(CONFIG_M68K)
255
256 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
257 {
258         bd_t *bd = gd->bd;
259
260         print_num("memstart",           (ulong)bd->bi_memstart);
261         print_lnum("memsize",           (u64)bd->bi_memsize);
262         print_num("flashstart",         (ulong)bd->bi_flashstart);
263         print_num("flashsize",          (ulong)bd->bi_flashsize);
264         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
265 #if defined(CONFIG_SYS_INIT_RAM_ADDR)
266         print_num("sramstart",          (ulong)bd->bi_sramstart);
267         print_num("sramsize",           (ulong)bd->bi_sramsize);
268 #endif
269 #if defined(CONFIG_SYS_MBAR)
270         print_num("mbar",               bd->bi_mbar_base);
271 #endif
272         print_mhz("cpufreq",            bd->bi_intfreq);
273         print_mhz("busfreq",            bd->bi_busfreq);
274 #ifdef CONFIG_PCI
275         print_mhz("pcifreq",            bd->bi_pcifreq);
276 #endif
277 #ifdef CONFIG_EXTRA_CLOCK
278         print_mhz("flbfreq",            bd->bi_flbfreq);
279         print_mhz("inpfreq",            bd->bi_inpfreq);
280         print_mhz("vcofreq",            bd->bi_vcofreq);
281 #endif
282 #if defined(CONFIG_CMD_NET)
283         print_eth(0);
284 #if defined(CONFIG_HAS_ETH1)
285         print_eth(1);
286 #endif
287 #if defined(CONFIG_HAS_ETH2)
288         print_eth(2);
289 #endif
290 #if defined(CONFIG_HAS_ETH3)
291         print_eth(3);
292 #endif
293
294         printf("ip_addr     = %s\n", getenv("ipaddr"));
295 #endif
296         printf("baudrate    = %u bps\n", bd->bi_baudrate);
297
298         return 0;
299 }
300
301 #elif defined(CONFIG_BLACKFIN)
302
303 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
304 {
305         bd_t *bd = gd->bd;
306
307         printf("U-Boot      = %s\n", bd->bi_r_version);
308         printf("CPU         = %s\n", bd->bi_cpu);
309         printf("Board       = %s\n", bd->bi_board_name);
310         print_mhz("VCO",        bd->bi_vco);
311         print_mhz("CCLK",       bd->bi_cclk);
312         print_mhz("SCLK",       bd->bi_sclk);
313
314         print_num("boot_params",        (ulong)bd->bi_boot_params);
315         print_num("memstart",           (ulong)bd->bi_memstart);
316         print_lnum("memsize",           (u64)bd->bi_memsize);
317         print_num("flashstart",         (ulong)bd->bi_flashstart);
318         print_num("flashsize",          (ulong)bd->bi_flashsize);
319         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
320
321         print_eth(0);
322         printf("ip_addr     = %s\n", getenv("ipaddr"));
323         printf("baudrate    = %u bps\n", bd->bi_baudrate);
324
325         return 0;
326 }
327
328 #elif defined(CONFIG_MIPS)
329
330 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
331 {
332         bd_t *bd = gd->bd;
333
334         print_num("boot_params",        (ulong)bd->bi_boot_params);
335         print_num("memstart",           (ulong)bd->bi_memstart);
336         print_lnum("memsize",           (u64)bd->bi_memsize);
337         print_num("flashstart",         (ulong)bd->bi_flashstart);
338         print_num("flashsize",          (ulong)bd->bi_flashsize);
339         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
340
341         print_eth(0);
342         printf("ip_addr     = %s\n", getenv("ipaddr"));
343         printf("baudrate    = %u bps\n", bd->bi_baudrate);
344
345         return 0;
346 }
347
348 #elif defined(CONFIG_AVR32)
349
350 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
351 {
352         bd_t *bd = gd->bd;
353
354         print_num("boot_params",        (ulong)bd->bi_boot_params);
355         print_num("memstart",           (ulong)bd->bi_memstart);
356         print_lnum("memsize",           (u64)bd->bi_memsize);
357         print_num("flashstart",         (ulong)bd->bi_flashstart);
358         print_num("flashsize",          (ulong)bd->bi_flashsize);
359         print_num("flashoffset",        (ulong)bd->bi_flashoffset);
360
361         print_eth(0);
362         printf("ip_addr     = %s\n", getenv("ipaddr"));
363         printf("baudrate    = %u bps\n", bd->bi_baudrate);
364
365         return 0;
366 }
367
368 #elif defined(CONFIG_ARM)
369
370 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
371 {
372         int i;
373         bd_t *bd = gd->bd;
374
375         print_num("arch_number",        bd->bi_arch_number);
376         print_num("boot_params",        (ulong)bd->bi_boot_params);
377
378         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
379                 print_num("DRAM bank",  i);
380                 print_num("-> start",   bd->bi_dram[i].start);
381                 print_num("-> size",    bd->bi_dram[i].size);
382         }
383
384 #if defined(CONFIG_CMD_NET)
385         print_eths();
386 #endif
387         printf("baudrate    = %u bps\n", bd->bi_baudrate);
388 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
389         print_num("TLB addr", gd->arch.tlb_addr);
390 #endif
391         print_num("relocaddr", gd->relocaddr);
392         print_num("reloc off", gd->reloc_off);
393         print_num("irq_sp", gd->irq_sp);        /* irq stack pointer */
394         print_num("sp start ", gd->start_addr_sp);
395 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
396         print_num("FB base  ", gd->fb_base);
397 #endif
398         /*
399          * TODO: Currently only support for davinci SOC's is added.
400          * Remove this check once all the board implement this.
401          */
402 #ifdef CONFIG_CLOCKS
403         printf("ARM frequency = %ld MHz\n", gd->bd->bi_arm_freq);
404         printf("DSP frequency = %ld MHz\n", gd->bd->bi_dsp_freq);
405         printf("DDR frequency = %ld MHz\n", gd->bd->bi_ddr_freq);
406 #endif
407         return 0;
408 }
409
410 #elif defined(CONFIG_SH)
411
412 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
413 {
414         bd_t *bd = gd->bd;
415         print_num("mem start      ",    (ulong)bd->bi_memstart);
416         print_lnum("mem size       ",   (u64)bd->bi_memsize);
417         print_num("flash start    ",    (ulong)bd->bi_flashstart);
418         print_num("flash size     ",    (ulong)bd->bi_flashsize);
419         print_num("flash offset   ",    (ulong)bd->bi_flashoffset);
420
421 #if defined(CONFIG_CMD_NET)
422         print_eth(0);
423         printf("ip_addr     = %s\n", getenv("ipaddr"));
424 #endif
425         printf("baudrate    = %u bps\n", bd->bi_baudrate);
426         return 0;
427 }
428
429 #elif defined(CONFIG_X86)
430
431 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
432 {
433         int i;
434         bd_t *bd = gd->bd;
435
436         print_num("boot_params",        (ulong)bd->bi_boot_params);
437         print_num("bi_memstart",        bd->bi_memstart);
438         print_num("bi_memsize",         bd->bi_memsize);
439         print_num("bi_flashstart",      bd->bi_flashstart);
440         print_num("bi_flashsize",       bd->bi_flashsize);
441         print_num("bi_flashoffset",     bd->bi_flashoffset);
442         print_num("bi_sramstart",       bd->bi_sramstart);
443         print_num("bi_sramsize",        bd->bi_sramsize);
444         print_num("bi_bootflags",       bd->bi_bootflags);
445         print_mhz("cpufreq",            bd->bi_intfreq);
446         print_mhz("busfreq",            bd->bi_busfreq);
447
448         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
449                 print_num("DRAM bank",  i);
450                 print_num("-> start",   bd->bi_dram[i].start);
451                 print_num("-> size",    bd->bi_dram[i].size);
452         }
453
454 #if defined(CONFIG_CMD_NET)
455         print_eth(0);
456         printf("ip_addr     = %s\n", getenv("ipaddr"));
457         print_mhz("ethspeed",       bd->bi_ethspeed);
458 #endif
459         printf("baudrate    = %u bps\n", bd->bi_baudrate);
460
461         return 0;
462 }
463
464 #elif defined(CONFIG_SANDBOX)
465
466 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
467 {
468         int i;
469         bd_t *bd = gd->bd;
470
471         print_num("boot_params", (ulong)bd->bi_boot_params);
472
473         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
474                 print_num("DRAM bank", i);
475                 print_num("-> start", bd->bi_dram[i].start);
476                 print_num("-> size", bd->bi_dram[i].size);
477         }
478
479 #if defined(CONFIG_CMD_NET)
480         print_eth(0);
481         printf("ip_addr     = %s\n", getenv("ipaddr"));
482 #endif
483 #if defined(CONFIG_LCD) || defined(CONFIG_VIDEO)
484         print_num("FB base  ", gd->fb_base);
485 #endif
486         return 0;
487 }
488
489 #elif defined(CONFIG_NDS32)
490
491 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
492 {
493         int i;
494         bd_t *bd = gd->bd;
495
496         print_num("arch_number",        bd->bi_arch_number);
497         print_num("boot_params",        (ulong)bd->bi_boot_params);
498
499         for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
500                 print_num("DRAM bank",  i);
501                 print_num("-> start",   bd->bi_dram[i].start);
502                 print_num("-> size",    bd->bi_dram[i].size);
503         }
504
505 #if defined(CONFIG_CMD_NET)
506         print_eth(0);
507         printf("ip_addr     = %s\n", getenv("ipaddr"));
508 #endif
509         printf("baudrate    = %u bps\n", bd->bi_baudrate);
510
511         return 0;
512 }
513
514 #elif defined(CONFIG_OPENRISC)
515
516 int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
517 {
518         bd_t *bd = gd->bd;
519
520         print_num("mem start",          (ulong)bd->bi_memstart);
521         print_lnum("mem size",          (u64)bd->bi_memsize);
522         print_num("flash start",        (ulong)bd->bi_flashstart);
523         print_num("flash size",         (ulong)bd->bi_flashsize);
524         print_num("flash offset",       (ulong)bd->bi_flashoffset);
525
526 #if defined(CONFIG_CMD_NET)
527         print_eth(0);
528         printf("ip_addr     = %s\n", getenv("ipaddr"));
529 #endif
530
531         printf("baudrate    = %u bps\n", bd->bi_baudrate);
532
533         return 0;
534 }
535
536 #else
537  #error "a case for this architecture does not exist!"
538 #endif
539
540 /* -------------------------------------------------------------------- */
541
542 U_BOOT_CMD(
543         bdinfo, 1,      1,      do_bdinfo,
544         "print Board Info structure",
545         ""
546 );