wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2001 |
| 3 | * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com |
| 4 | * |
Wolfgang Denk | 3765b3e | 2013-10-07 13:07:26 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | |
Jon Loeliger | ab3abcb | 2007-07-09 18:45:16 -0500 | [diff] [blame] | 11 | #if defined(CONFIG_CMD_BSP) |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 12 | |
| 13 | #include "vpd.h" |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 14 | |
| 15 | /* ====================================================================== |
| 16 | * Interpreter command to retrieve board specific Vital Product Data, "VPD" |
| 17 | * ====================================================================== |
| 18 | */ |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 19 | int do_vpd (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 20 | { |
| 21 | VPD vpd; /* Board specific data struct */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 22 | uchar dev_addr = CONFIG_SYS_DEF_EEPROM_ADDR; |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 23 | |
| 24 | /* Validate usage */ |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 25 | if (argc > 2) |
| 26 | return cmd_usage(cmdtp); |
wdenk | f8cac65 | 2002-08-26 22:36:39 +0000 | [diff] [blame] | 27 | |
| 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 | |
wdenk | 0d49839 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 41 | U_BOOT_CMD( |
| 42 | vpd, 2, 1, do_vpd, |
Peter Tyser | 2fb2604 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 43 | "Read Vital Product Data", |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 44 | "[dev_addr]\n" |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 45 | " - Read VPD Data from default address, or device address 'dev_addr'." |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 46 | ); |
| 47 | |
Jon Loeliger | ab3abcb | 2007-07-09 18:45:16 -0500 | [diff] [blame] | 48 | #endif |