Files
u-boot/cmd/fru.c
Siva Durga Prasad Paladugu df532608ed cmd: fru: Add support for FRU commands
This patch adds support for fru commands "fru capture"
and "fru display". The fru capture parses the FRU table
present at an address and stores in a structure for later
use. The fru display prints the content of captured structured
in a readable format.

As of now, it supports only common header and board area of FRU.
Also, its supports only English language code and ASCII8 format.

Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
2019-06-06 13:46:52 +02:00

74 lines
1.4 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* (C) Copyright 2019 Xilinx, Inc.
*
*/
#include <common.h>
#include <fdtdec.h>
#include <malloc.h>
#include <fru.h>
static int do_fru_capture(cmd_tbl_t *cmdtp, int flag, int argc,
char *const argv[])
{
unsigned long addr;
char *endp;
int ret;
if (argc < 3)
return CMD_RET_USAGE;
addr = simple_strtoul(argv[2], &endp, 16);
if (*argv[1] == 0 || *endp != 0)
return -1;
ret = fru_capture(addr);
return ret;
}
static int do_fru_display(cmd_tbl_t *cmdtp, int flag, int argc,
char *const argv[])
{
fru_display();
return CMD_RET_SUCCESS;
}
static cmd_tbl_t cmd_fru_sub[] = {
U_BOOT_CMD_MKENT(capture, 3, 0, do_fru_capture, "", ""),
U_BOOT_CMD_MKENT(display, 2, 0, do_fru_display, "", ""),
};
static int do_fru(cmd_tbl_t *cmdtp, int flag, int argc,
char *const argv[])
{
cmd_tbl_t *c;
if (argc < 2)
return CMD_RET_USAGE;
c = find_cmd_tbl(argv[1], &cmd_fru_sub[0],
ARRAY_SIZE(cmd_fru_sub));
if (c)
return c->cmd(c, flag, argc, argv);
return CMD_RET_USAGE;
}
/***************************************************/
#ifdef CONFIG_SYS_LONGHELP
static char fru_help_text[] =
"capture <addr>- Parse and capture FRU table present at address.\n"
"display = Displays content of FRU table that was captured using\n"
" fru capture command\n"
;
#endif
U_BOOT_CMD(
fru, 3, 1, do_fru,
"FRU table info",
fru_help_text
)