ca834732b82f45808b16b5712f36a390ac7583b8
[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 <net.h>                /* for print_IPaddr */
30
31
32 #if (CONFIG_COMMANDS & CFG_CMD_BDI)
33 static void print_num(const char *, ulong);
34
35 #ifndef CONFIG_ARM      /* PowerPC and other */
36
37 #ifdef CONFIG_PPC
38 static void print_str(const char *, const char *);
39
40 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
41 {
42         DECLARE_GLOBAL_DATA_PTR;
43
44         int i;
45         bd_t *bd = gd->bd;
46         char buf[32];
47
48 #ifdef DEBUG
49         print_num ("bd address",    (ulong)bd           );
50 #endif
51         print_num ("memstart",      bd->bi_memstart     );
52         print_num ("memsize",       bd->bi_memsize      );
53         print_num ("flashstart",    bd->bi_flashstart   );
54         print_num ("flashsize",     bd->bi_flashsize    );
55         print_num ("flashoffset",   bd->bi_flashoffset  );
56         print_num ("sramstart",     bd->bi_sramstart    );
57         print_num ("sramsize",      bd->bi_sramsize     );
58 #if defined(CONFIG_5xx)  || defined(CONFIG_8xx) || \
59     defined(CONFIG_8260) || defined(CONFIG_E500)
60         print_num ("immr_base",     bd->bi_immr_base    );
61 #endif
62         print_num ("bootflags",     bd->bi_bootflags    );
63 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
64     defined(CONFIG_405EP) || defined(CONFIG_XILINX_ML300)
65         print_str ("procfreq",      strmhz(buf, bd->bi_procfreq));
66         print_str ("plb_busfreq",   strmhz(buf, bd->bi_plb_busfreq));
67 #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || defined(CONFIG_XILINX_ML300)
68         print_str ("pci_busfreq",   strmhz(buf, bd->bi_pci_busfreq));
69 #endif
70 #else   /* ! CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_ML300 */
71 #if defined(CONFIG_8260) || defined(CONFIG_MPC8560)
72         print_str ("vco",           strmhz(buf, bd->bi_vco));
73         print_str ("sccfreq",       strmhz(buf, bd->bi_sccfreq));
74         print_str ("brgfreq",       strmhz(buf, bd->bi_brgfreq));
75 #endif
76         print_str ("intfreq",       strmhz(buf, bd->bi_intfreq));
77 #if defined(CONFIG_8260) || defined(CONFIG_MPC8560)
78         print_str ("cpmfreq",       strmhz(buf, bd->bi_cpmfreq));
79 #endif
80         print_str ("busfreq",       strmhz(buf, bd->bi_busfreq));
81 #endif /* CONFIG_405GP, CONFIG_405CR, CONFIG_405EP, CONFIG_XILINX_ML300 */
82 #if defined(CONFIG_MPC8220)
83         print_str ("inpfreq",       strmhz(buf, bd->bi_inpfreq));
84         print_str ("flbfreq",       strmhz(buf, bd->bi_flbfreq));
85         print_str ("pcifreq",       strmhz(buf, bd->bi_pcifreq));
86         print_str ("vcofreq",       strmhz(buf, bd->bi_vcofreq));
87         print_str ("pevfreq",       strmhz(buf, bd->bi_pevfreq));
88 #endif
89
90         puts ("ethaddr     =");
91         for (i=0; i<6; ++i) {
92                 printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
93         }
94
95 #if defined(CONFIG_HAS_ETH1)
96         puts ("\neth1addr    =");
97         for (i=0; i<6; ++i) {
98                 printf ("%c%02X", i ? ':' : ' ', bd->bi_enet1addr[i]);
99         }
100 #endif
101
102 #if defined(CONFIG_HAS_ETH2)
103        puts ("\neth2addr    =");
104        for (i=0; i<6; ++i) {
105                 printf ("%c%02X", i ? ':' : ' ', bd->bi_enet2addr[i]);
106         }
107 #endif
108
109 #if defined(CONFIG_HAS_ETH3)
110        puts ("\neth3addr    =");
111        for (i=0; i<6; ++i) {
112                 printf ("%c%02X", i ? ':' : ' ', bd->bi_enet3addr[i]);
113         }
114 #endif
115
116 #ifdef CONFIG_HERMES
117         print_str ("ethspeed",      strmhz(buf, bd->bi_ethspeed));
118 #endif
119         puts ("\nIP addr     = ");      print_IPaddr (bd->bi_ip_addr);
120         printf ("\nbaudrate    = %6ld bps\n", bd->bi_baudrate   );
121         return 0;
122 }
123
124 #elif defined(CONFIG_NIOS) /* NIOS*/
125
126 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
127 {
128         DECLARE_GLOBAL_DATA_PTR;
129
130         int i;
131         bd_t *bd = gd->bd;
132
133         print_num ("memstart",          (ulong)bd->bi_memstart);
134         print_num ("memsize",           (ulong)bd->bi_memsize);
135         print_num ("flashstart",        (ulong)bd->bi_flashstart);
136         print_num ("flashsize",         (ulong)bd->bi_flashsize);
137         print_num ("flashoffset",       (ulong)bd->bi_flashoffset);
138
139         puts ("ethaddr     =");
140         for (i=0; i<6; ++i) {
141                 printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
142         }
143         puts ("\nip_addr     = ");
144         print_IPaddr (bd->bi_ip_addr);
145         printf ("\nbaudrate    = %ld bps\n", bd->bi_baudrate);
146
147         return 0;
148 }
149
150 #elif defined(CONFIG_NIOS2) /* Nios-II */
151
152 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
153 {
154         DECLARE_GLOBAL_DATA_PTR;
155
156         int i;
157         bd_t *bd = gd->bd;
158
159         print_num ("mem start",         (ulong)bd->bi_memstart);
160         print_num ("mem size",          (ulong)bd->bi_memsize);
161         print_num ("flash start",       (ulong)bd->bi_flashstart);
162         print_num ("flash size",        (ulong)bd->bi_flashsize);
163         print_num ("flash offset",      (ulong)bd->bi_flashoffset);
164
165 #if defined(CFG_SRAM_BASE)
166         print_num ("sram start",        (ulong)bd->bi_sramstart);
167         print_num ("sram size",         (ulong)bd->bi_sramsize);
168 #endif
169
170 #if defined(CFG_CMD_NET)
171         puts ("ethaddr     =");
172         for (i=0; i<6; ++i) {
173                 printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
174         }
175         puts ("\nip_addr     = ");
176         print_IPaddr (bd->bi_ip_addr);
177 #endif
178
179         printf ("\nbaudrate    = %ld bps\n", bd->bi_baudrate);
180
181         return 0;
182 }
183
184 #else /* ! PPC, which leaves MIPS */
185
186 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
187 {
188         DECLARE_GLOBAL_DATA_PTR;
189
190         int i;
191         bd_t *bd = gd->bd;
192
193         print_num ("boot_params",       (ulong)bd->bi_boot_params);
194         print_num ("memstart",          (ulong)bd->bi_memstart);
195         print_num ("memsize",           (ulong)bd->bi_memsize);
196         print_num ("flashstart",        (ulong)bd->bi_flashstart);
197         print_num ("flashsize",         (ulong)bd->bi_flashsize);
198         print_num ("flashoffset",       (ulong)bd->bi_flashoffset);
199
200         puts ("ethaddr     =");
201         for (i=0; i<6; ++i) {
202                 printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
203         }
204         puts ("\nip_addr     = ");
205         print_IPaddr (bd->bi_ip_addr);
206         printf ("\nbaudrate    = %d bps\n", bd->bi_baudrate);
207
208         return 0;
209 }
210 #endif  /* MIPS */
211
212 #else   /* ARM */
213
214 int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
215 {
216         DECLARE_GLOBAL_DATA_PTR;
217
218         int i;
219         bd_t *bd = gd->bd;
220
221         print_num ("arch_number",       bd->bi_arch_number);
222         print_num ("env_t",             (ulong)bd->bi_env);
223         print_num ("boot_params",       (ulong)bd->bi_boot_params);
224
225         for (i=0; i<CONFIG_NR_DRAM_BANKS; ++i) {
226                 print_num("DRAM bank",  i);
227                 print_num("-> start",   bd->bi_dram[i].start);
228                 print_num("-> size",    bd->bi_dram[i].size);
229         }
230
231         puts ("ethaddr     =");
232         for (i=0; i<6; ++i) {
233                 printf ("%c%02X", i ? ':' : ' ', bd->bi_enetaddr[i]);
234         }
235         puts  ( "\n"
236                 "ip_addr     = ");
237         print_IPaddr (bd->bi_ip_addr);
238         printf ("\n"
239                 "baudrate    = %d bps\n", bd->bi_baudrate);
240
241         return 0;
242 }
243
244 #endif /* CONFIG_ARM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
245
246 static void print_num(const char *name, ulong value)
247 {
248         printf ("%-12s= 0x%08lX\n", name, value);
249 }
250
251 #ifdef CONFIG_PPC
252 static void print_str(const char *name, const char *str)
253 {
254         printf ("%-12s= %6s MHz\n", name, str);
255 }
256 #endif  /* CONFIG_PPC */
257
258
259 /* -------------------------------------------------------------------- */
260
261 U_BOOT_CMD(
262         bdinfo, 1,      1,      do_bdinfo,
263         "bdinfo  - print Board Info structure\n",
264         NULL
265 );
266 #endif  /* CFG_CMD_BDI */