blob: 879cb6133cd07d2ddca438594844823e75c31f5b [file] [log] [blame]
wdenkf8cac652002-08-26 22:36:39 +00001/*
2 * (C) Copyright 2001
3 * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com
4 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenkf8cac652002-08-26 22:36:39 +00006 */
7
8#include <common.h>
9#include <command.h>
10
Jon Loeligerab3abcb2007-07-09 18:45:16 -050011#if defined(CONFIG_CMD_BSP)
wdenkf8cac652002-08-26 22:36:39 +000012
13#include "vpd.h"
wdenkf8cac652002-08-26 22:36:39 +000014
15/* ======================================================================
16 * Interpreter command to retrieve board specific Vital Product Data, "VPD"
17 * ======================================================================
18 */
Wolfgang Denk54841ab2010-06-28 22:00:46 +020019int do_vpd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
wdenkf8cac652002-08-26 22:36:39 +000020{
21 VPD vpd; /* Board specific data struct */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020022 uchar dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
wdenkf8cac652002-08-26 22:36:39 +000023
24 /* Validate usage */
Wolfgang Denk47e26b12010-07-17 01:06:04 +020025 if (argc > 2)
26 return cmd_usage(cmdtp);
wdenkf8cac652002-08-26 22:36:39 +000027
28 /* Passed in EEPROM address */
29 if (argc == 2)
30 dev_addr = (uchar) simple_strtoul (argv[1], NULL, 16);
31
32 /* Read VPD and output it */
33 if (!vpd_get_data (dev_addr, &vpd)) {
34 vpd_print (&vpd);
35 return 0;
36 }
37
38 return 1;
39}
40
wdenk0d498392003-07-01 21:06:45 +000041U_BOOT_CMD(
42 vpd, 2, 1, do_vpd,
Peter Tyser2fb26042009-01-27 18:03:12 -060043 "Read Vital Product Data",
wdenk8bde7f72003-06-27 21:31:46 +000044 "[dev_addr]\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +020045 " - Read VPD Data from default address, or device address 'dev_addr'."
wdenk8bde7f72003-06-27 21:31:46 +000046);
47
Jon Loeligerab3abcb2007-07-09 18:45:16 -050048#endif