2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2003-06-27 21:31:46 +00:00
|
|
|
/*
|
2020-05-10 20:17:00 +00:00
|
|
|
* Implements the 'bd' command to show board information
|
|
|
|
*
|
2003-06-27 21:31:46 +00:00
|
|
|
* (C) Copyright 2003
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2019-08-01 15:46:52 +00:00
|
|
|
#include <env.h>
|
2020-07-20 08:10:45 +00:00
|
|
|
#include <lmb.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <net.h>
|
2019-11-14 19:57:20 +00:00
|
|
|
#include <vsprintf.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <asm/cache.h>
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2006-03-31 16:32:53 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2020-05-10 20:16:55 +00:00
|
|
|
void bdinfo_print_num(const char *name, ulong value)
|
2011-12-04 17:45:22 +00:00
|
|
|
{
|
2018-10-11 11:15:01 +00:00
|
|
|
printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
|
2011-12-04 17:45:22 +00:00
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2011-12-04 17:45:22 +00:00
|
|
|
static void print_eth(int idx)
|
|
|
|
{
|
|
|
|
char name[10], *val;
|
|
|
|
if (idx)
|
|
|
|
sprintf(name, "eth%iaddr", idx);
|
|
|
|
else
|
|
|
|
strcpy(name, "ethaddr");
|
2017-08-03 18:22:12 +00:00
|
|
|
val = env_get(name);
|
2011-12-04 17:45:22 +00:00
|
|
|
if (!val)
|
|
|
|
val = "(not set)";
|
|
|
|
printf("%-12s= %s\n", name, val);
|
|
|
|
}
|
2009-02-11 23:50:10 +00:00
|
|
|
|
2012-10-03 08:36:11 +00:00
|
|
|
static void print_lnum(const char *name, unsigned long long value)
|
2011-12-04 17:45:22 +00:00
|
|
|
{
|
|
|
|
printf("%-12s= 0x%.8llX\n", name, value);
|
|
|
|
}
|
|
|
|
|
2020-05-10 20:16:55 +00:00
|
|
|
void bdinfo_print_mhz(const char *name, unsigned long hz)
|
2011-12-04 17:45:22 +00:00
|
|
|
{
|
|
|
|
char buf[32];
|
|
|
|
|
|
|
|
printf("%-12s= %6s MHz\n", name, strmhz(buf, hz));
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2020-06-26 06:13:33 +00:00
|
|
|
static void print_bi_dram(const struct bd_info *bd)
|
2016-07-28 00:57:20 +00:00
|
|
|
{
|
|
|
|
#ifdef CONFIG_NR_DRAM_BANKS
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) {
|
2016-08-06 03:57:27 +00:00
|
|
|
if (bd->bi_dram[i].size) {
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("DRAM bank", i);
|
|
|
|
bdinfo_print_num("-> start", bd->bi_dram[i].start);
|
|
|
|
bdinfo_print_num("-> size", bd->bi_dram[i].size);
|
2016-08-06 03:57:27 +00:00
|
|
|
}
|
2016-07-28 00:57:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-05-10 20:16:56 +00:00
|
|
|
__weak void arch_print_bdinfo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
2016-08-10 15:36:43 +00:00
|
|
|
{
|
2020-06-26 06:13:33 +00:00
|
|
|
struct bd_info *bd = gd->bd;
|
2020-05-10 20:16:37 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("bd address", (ulong)bd);
|
2020-05-10 20:16:37 +00:00
|
|
|
#endif
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("boot_params", (ulong)bd->bi_boot_params);
|
2020-05-10 20:16:37 +00:00
|
|
|
print_bi_dram(bd);
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("memstart", (ulong)bd->bi_memstart);
|
2020-05-10 20:16:47 +00:00
|
|
|
print_lnum("memsize", (u64)bd->bi_memsize);
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("flashstart", (ulong)bd->bi_flashstart);
|
|
|
|
bdinfo_print_num("flashsize", (ulong)bd->bi_flashsize);
|
|
|
|
bdinfo_print_num("flashoffset", (ulong)bd->bi_flashoffset);
|
2020-05-10 20:16:46 +00:00
|
|
|
printf("baudrate = %u bps\n", gd->baudrate);
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("relocaddr", gd->relocaddr);
|
|
|
|
bdinfo_print_num("reloc off", gd->reloc_off);
|
2020-05-10 20:16:50 +00:00
|
|
|
printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
|
2020-05-10 20:16:54 +00:00
|
|
|
if (IS_ENABLED(CONFIG_CMD_NET)) {
|
2020-05-10 20:16:53 +00:00
|
|
|
printf("current eth = %s\n", eth_get_name());
|
2020-05-10 20:16:54 +00:00
|
|
|
print_eth(0);
|
|
|
|
printf("IP addr = %s\n", env_get("ipaddr"));
|
|
|
|
}
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("fdt_blob", (ulong)gd->fdt_blob);
|
|
|
|
bdinfo_print_num("new_fdt", (ulong)gd->new_fdt);
|
|
|
|
bdinfo_print_num("fdt_size", (ulong)gd->fdt_size);
|
2020-05-10 20:16:39 +00:00
|
|
|
#if defined(CONFIG_LCD) || defined(CONFIG_VIDEO) || defined(CONFIG_DM_VIDEO)
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("FB base ", gd->fb_base);
|
2020-05-10 20:16:39 +00:00
|
|
|
#endif
|
|
|
|
#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
|
2020-05-10 20:16:55 +00:00
|
|
|
bdinfo_print_num("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
|
2020-05-10 20:16:39 +00:00
|
|
|
#endif
|
2020-07-20 08:10:45 +00:00
|
|
|
if (gd->fdt_blob) {
|
|
|
|
struct lmb lmb;
|
|
|
|
|
|
|
|
lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
|
|
|
|
lmb_dump_all_force(&lmb);
|
|
|
|
}
|
2020-05-10 20:16:56 +00:00
|
|
|
|
|
|
|
arch_print_bdinfo();
|
2020-05-10 20:16:28 +00:00
|
|
|
|
2016-08-10 15:36:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-06-27 21:31:46 +00:00
|
|
|
|
2003-07-01 21:06:45 +00:00
|
|
|
U_BOOT_CMD(
|
|
|
|
bdinfo, 1, 1, do_bdinfo,
|
2009-01-28 00:03:12 +00:00
|
|
|
"print Board Info structure",
|
2009-05-24 15:06:54 +00:00
|
|
|
""
|
2003-06-27 21:31:46 +00:00
|
|
|
);
|