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>
|
2020-09-23 03:16:40 +00:00
|
|
|
#include <dm.h>
|
2019-08-01 15:46:52 +00:00
|
|
|
#include <env.h>
|
2020-07-20 08:10:45 +00:00
|
|
|
#include <lmb.h>
|
2023-04-22 13:01:31 +00:00
|
|
|
#include <mapmem.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <net.h>
|
2023-07-12 15:04:37 +00:00
|
|
|
#include <serial.h>
|
2020-09-23 03:16:40 +00:00
|
|
|
#include <video.h>
|
2019-11-14 19:57:20 +00:00
|
|
|
#include <vsprintf.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <asm/cache.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2022-08-29 17:02:04 +00:00
|
|
|
#include <display_options.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
|
|
|
|
2022-08-29 17:02:04 +00:00
|
|
|
void bdinfo_print_size(const char *name, uint64_t size)
|
|
|
|
{
|
|
|
|
printf("%-12s= ", name);
|
|
|
|
print_size(size, "\n");
|
|
|
|
}
|
|
|
|
|
2023-03-10 20:47:14 +00:00
|
|
|
void bdinfo_print_str(const char *name, const char *str)
|
|
|
|
{
|
|
|
|
printf("%-12s= %s\n", name, str);
|
|
|
|
}
|
|
|
|
|
2021-01-31 12:36:05 +00:00
|
|
|
void bdinfo_print_num_l(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
|
|
|
|
2021-01-31 12:36:05 +00:00
|
|
|
void bdinfo_print_num_ll(const char *name, unsigned long long value)
|
|
|
|
{
|
|
|
|
printf("%-12s= 0x%.*llx\n", name, 2 * (int)sizeof(ulong), value);
|
|
|
|
}
|
|
|
|
|
2023-04-22 13:01:33 +00:00
|
|
|
static void print_eth(void)
|
2011-12-04 17:45:22 +00:00
|
|
|
{
|
2023-04-22 13:01:33 +00:00
|
|
|
const int idx = eth_get_dev_index();
|
|
|
|
uchar enetaddr[6];
|
|
|
|
char name[10];
|
|
|
|
int ret;
|
|
|
|
|
2011-12-04 17:45:22 +00:00
|
|
|
if (idx)
|
|
|
|
sprintf(name, "eth%iaddr", idx);
|
|
|
|
else
|
|
|
|
strcpy(name, "ethaddr");
|
2023-04-22 13:01:33 +00:00
|
|
|
|
|
|
|
ret = eth_env_get_enetaddr_by_index("eth", idx, enetaddr);
|
2023-04-22 13:01:32 +00:00
|
|
|
|
|
|
|
printf("current eth = %s\n", eth_get_name());
|
2023-04-22 13:01:33 +00:00
|
|
|
if (!ret)
|
|
|
|
printf("%-12s= (not set)\n", name);
|
|
|
|
else
|
|
|
|
printf("%-12s= %pM\n", name, enetaddr);
|
2023-04-22 13:01:32 +00:00
|
|
|
printf("IP addr = %s\n", env_get("ipaddr"));
|
2011-12-04 17:45:22 +00:00
|
|
|
}
|
2009-02-11 23:50:10 +00:00
|
|
|
|
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
|
|
|
{
|
|
|
|
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) {
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("DRAM bank", i);
|
2021-01-31 12:36:06 +00:00
|
|
|
bdinfo_print_num_ll("-> start", bd->bi_dram[i].start);
|
|
|
|
bdinfo_print_num_ll("-> size", bd->bi_dram[i].size);
|
2016-08-06 03:57:27 +00:00
|
|
|
}
|
2016-07-28 00:57:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-10 20:16:56 +00:00
|
|
|
__weak void arch_print_bdinfo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-09-23 03:16:40 +00:00
|
|
|
static void show_video_info(void)
|
|
|
|
{
|
|
|
|
const struct udevice *dev;
|
|
|
|
struct uclass *uc;
|
|
|
|
|
|
|
|
uclass_id_foreach_dev(UCLASS_VIDEO, dev, uc) {
|
|
|
|
printf("%-12s= %s %sactive\n", "Video", dev->name,
|
|
|
|
device_active(dev) ? "" : "in");
|
|
|
|
if (device_active(dev)) {
|
|
|
|
struct video_priv *upriv = dev_get_uclass_priv(dev);
|
2023-03-10 20:47:18 +00:00
|
|
|
struct video_uc_plat *plat = dev_get_uclass_plat(dev);
|
2020-09-23 03:16:40 +00:00
|
|
|
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_ll("FB base", (ulong)upriv->fb);
|
2023-03-10 20:47:18 +00:00
|
|
|
if (upriv->copy_fb) {
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_ll("FB copy",
|
|
|
|
(ulong)upriv->copy_fb);
|
2023-03-10 20:47:18 +00:00
|
|
|
bdinfo_print_num_l(" copy size",
|
|
|
|
plat->copy_size);
|
|
|
|
}
|
2020-09-23 03:16:40 +00:00
|
|
|
printf("%-12s= %dx%dx%d\n", "FB size", upriv->xsize,
|
|
|
|
upriv->ysize, 1 << upriv->bpix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-12 15:04:37 +00:00
|
|
|
static void print_serial(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct serial_device_info info;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!dev || !IS_ENABLED(CONFIG_DM_SERIAL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ret = serial_getinfo(dev, &info);
|
|
|
|
if (ret)
|
|
|
|
return;
|
|
|
|
|
|
|
|
bdinfo_print_num_l("serial addr", info.addr);
|
|
|
|
bdinfo_print_num_l(" width", info.reg_width);
|
|
|
|
bdinfo_print_num_l(" shift", info.reg_shift);
|
|
|
|
bdinfo_print_num_l(" offset", info.reg_offset);
|
|
|
|
bdinfo_print_num_l(" clock", info.clock);
|
|
|
|
}
|
|
|
|
|
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
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("bd address", (ulong)bd);
|
2020-05-10 20:16:37 +00:00
|
|
|
#endif
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("boot_params", (ulong)bd->bi_boot_params);
|
2020-05-10 20:16:37 +00:00
|
|
|
print_bi_dram(bd);
|
2020-07-24 11:12:13 +00:00
|
|
|
if (IS_ENABLED(CONFIG_SYS_HAS_SRAM)) {
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("sramstart", (ulong)bd->bi_sramstart);
|
|
|
|
bdinfo_print_num_l("sramsize", (ulong)bd->bi_sramsize);
|
2020-07-24 11:12:13 +00:00
|
|
|
}
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("flashstart", (ulong)bd->bi_flashstart);
|
|
|
|
bdinfo_print_num_l("flashsize", (ulong)bd->bi_flashsize);
|
|
|
|
bdinfo_print_num_l("flashoffset", (ulong)bd->bi_flashoffset);
|
2020-05-10 20:16:46 +00:00
|
|
|
printf("baudrate = %u bps\n", gd->baudrate);
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("relocaddr", gd->relocaddr);
|
|
|
|
bdinfo_print_num_l("reloc off", gd->reloc_off);
|
2020-05-10 20:16:50 +00:00
|
|
|
printf("%-12s= %u-bit\n", "Build", (uint)sizeof(void *) * 8);
|
2023-04-22 13:01:32 +00:00
|
|
|
if (IS_ENABLED(CONFIG_CMD_NET))
|
2023-04-22 13:01:33 +00:00
|
|
|
print_eth();
|
2023-04-22 13:01:31 +00:00
|
|
|
bdinfo_print_num_l("fdt_blob", (ulong)map_to_sysmem(gd->fdt_blob));
|
|
|
|
bdinfo_print_num_l("new_fdt", (ulong)map_to_sysmem(gd->new_fdt));
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("fdt_size", (ulong)gd->fdt_size);
|
2022-10-18 13:46:31 +00:00
|
|
|
if (IS_ENABLED(CONFIG_VIDEO))
|
2020-09-23 03:16:40 +00:00
|
|
|
show_video_info();
|
2020-05-10 20:16:39 +00:00
|
|
|
#if CONFIG_IS_ENABLED(MULTI_DTB_FIT)
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("multi_dtb_fit", (ulong)gd->multi_dtb_fit);
|
2020-05-10 20:16:39 +00:00
|
|
|
#endif
|
2022-09-07 07:52:09 +00:00
|
|
|
if (IS_ENABLED(CONFIG_LMB) && gd->fdt_blob) {
|
2020-07-20 08:10:45 +00:00
|
|
|
struct lmb lmb;
|
|
|
|
|
|
|
|
lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
|
|
|
|
lmb_dump_all_force(&lmb);
|
2021-12-17 03:59:34 +00:00
|
|
|
if (IS_ENABLED(CONFIG_OF_REAL))
|
|
|
|
printf("devicetree = %s\n", fdtdec_get_srcname());
|
2020-07-20 08:10:45 +00:00
|
|
|
}
|
2023-07-12 15:04:37 +00:00
|
|
|
print_serial(gd->cur_serial_dev);
|
2020-05-10 20:16:56 +00:00
|
|
|
|
2023-07-16 03:38:46 +00:00
|
|
|
if (IS_ENABLED(CONFIG_CMD_BDINFO_EXTRA)) {
|
|
|
|
bdinfo_print_num_ll("stack ptr", (ulong)&bd);
|
|
|
|
bdinfo_print_num_ll("ram_top ptr", (ulong)gd->ram_top);
|
2023-07-16 03:38:53 +00:00
|
|
|
bdinfo_print_num_l("malloc base", gd_malloc_start());
|
2023-07-16 03:38:46 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
);
|