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>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <net.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);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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);
|
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"));
|
|
|
|
}
|
2021-01-31 12:36:05 +00:00
|
|
|
bdinfo_print_num_l("fdt_blob", (ulong)gd->fdt_blob);
|
|
|
|
bdinfo_print_num_l("new_fdt", (ulong)gd->new_fdt);
|
|
|
|
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
|
|
|
}
|
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
|
|
|
);
|