[U-Boot] [PATCH 0/17] Various patches in common/

This collection of patches to common/ adds the following:
- EDID support for LCD displays - TPM stress test - gettime command to find out the time since boot - Adds coreboot information to the 'version' command - Fixes LMB on x86 - Allows the console overwrite to be selected by board files - SHA256 hashing - Merging of saved environment variables with the default environment - Reading raw data from a partition of a block device
Also fixes a few minor bugs and tidy-ups.
ARUN MANKUZHI (1): Add sha256 command for hashing
Anton Staaf (2): Add gettime command console: Call overwrite_console before searching for console devices
Doug Anderson (1): env: Add the ability to merge the saved env with the default.
Kenneth Waters (1): Add a command to read raw blocks from a partition
Luigi Semenzato (1): tpm: Add TPM stress test
Simon Glass (4): arm: Add new bootstage step for the main loop Fix use of conditional LMB Update time command to avoid using get_timer_masked() console: Enable function to display console info
Stefan Reinauer (1): Add coreboot version to u-boot's version command
Taylor Hutt (1): mmc: Fix incorrect handling of 'read' & 'write' commands
Tom Wai-Hong Tam (3): edid: Library of EDID decode and print edid: Add I2C command for printing the EDID fdt: edid: Enable fdt_add_edid() function when CONFIG_LCD defined
Vadim Bendebury (1): Add console command to access io space registers
Vincent Palatin (1): stdio: remove useless strncpy
README | 17 +++ common/Makefile | 5 + common/cmd_bootm.c | 2 +- common/cmd_gettime.c | 56 +++++++++ common/cmd_i2c.c | 39 ++++++ common/cmd_io.c | 93 ++++++++++++++ common/cmd_mmc.c | 9 +- common/cmd_read.c | 81 ++++++++++++ common/cmd_sha256.c | 57 +++++++++ common/cmd_time.c | 5 +- common/cmd_tpm.c | 93 +++++++++++++- common/cmd_version.c | 7 +- common/console.c | 21 +++- common/edid.c | 307 ++++++++++++++++++++++++++++++++++++++++++++++ common/env_common.c | 25 ++++ common/fdt_support.c | 2 +- common/main.c | 2 + common/stdio.c | 1 - include/command.h | 8 +- include/config_cmd_all.h | 5 + include/edid.h | 275 +++++++++++++++++++++++++++++++++++++++++ 21 files changed, 1084 insertions(+), 26 deletions(-) create mode 100644 common/cmd_gettime.c create mode 100644 common/cmd_io.c create mode 100644 common/cmd_read.c create mode 100644 common/cmd_sha256.c create mode 100644 common/edid.c create mode 100644 include/edid.h

Mark when we get to the main loop.
Signed-off-by: Simon Glass sjg@chromium.org --- common/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/common/main.c b/common/main.c index 9507cec..ed1da24 100644 --- a/common/main.c +++ b/common/main.c @@ -299,6 +299,8 @@ void main_loop (void) char bcs_set[16]; #endif /* CONFIG_BOOTCOUNT_LIMIT */
+ bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); + #ifdef CONFIG_BOOTCOUNT_LIMIT bootcount = bootcount_load(); bootcount++;

Dear Simon Glass,
In message 1351902453-27956-2-git-send-email-sjg@chromium.org you wrote:
Mark when we get to the main loop.
Signed-off-by: Simon Glass sjg@chromium.org
common/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/common/main.c b/common/main.c index 9507cec..ed1da24 100644 --- a/common/main.c +++ b/common/main.c @@ -299,6 +299,8 @@ void main_loop (void) char bcs_set[16]; #endif /* CONFIG_BOOTCOUNT_LIMIT */
- bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
#ifdef CONFIG_BOOTCOUNT_LIMIT bootcount = bootcount_load(); bootcount++;
In which way is this patch ARM specific?
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:12 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-2-git-send-email-sjg@chromium.org you wrote:
Mark when we get to the main loop.
Signed-off-by: Simon Glass sjg@chromium.org
common/main.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/common/main.c b/common/main.c index 9507cec..ed1da24 100644 --- a/common/main.c +++ b/common/main.c @@ -299,6 +299,8 @@ void main_loop (void) char bcs_set[16]; #endif /* CONFIG_BOOTCOUNT_LIMIT */
bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
#ifdef CONFIG_BOOTCOUNT_LIMIT bootcount = bootcount_load(); bootcount++;
In which way is this patch ARM specific?
It is not - I fixed it up and forgot to remove the tag. I will resubmit once I sort out the rest of the series.
Regards, Simon
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Do not underestimate the value of print statements for debugging.

From: Anton Staaf robotboy@chromium.org
Gettime returns the current timer value. If CONFIG_SYS_HZ is defined then the timer value is also converted to seconds.
Tegra20 (SeaBoard) # gettime Timer val: 7754 Seconds : 7 Remainder : 754 sys_hz = 1000
Signed-off-by: Anton Staaf robotboy@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- README | 1 + common/Makefile | 1 + common/cmd_gettime.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 59 insertions(+), 0 deletions(-) create mode 100644 common/cmd_gettime.c
diff --git a/README b/README index 22fd6b7..a080225 100644 --- a/README +++ b/README @@ -815,6 +815,7 @@ The following options need to be configured: CONFIG_CMD_FDOS * Dos diskette Support CONFIG_CMD_FLASH flinfo, erase, protect CONFIG_CMD_FPGA FPGA device initialization support + CONFIG_CMD_GETTIME * Get time since boot CONFIG_CMD_GO * the 'go' command (exec code) CONFIG_CMD_GREPENV * search environment CONFIG_CMD_HWFLOW * RTS/CTS hw flow control diff --git a/common/Makefile b/common/Makefile index 9e43322..0fb79ed 100644 --- a/common/Makefile +++ b/common/Makefile @@ -100,6 +100,7 @@ ifdef CONFIG_FPGA COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o endif COBJS-$(CONFIG_CMD_FS_GENERIC) += cmd_fs.o +COBJS-$(CONFIG_CMD_GETTIME) += cmd_gettime.o COBJS-$(CONFIG_CMD_GPIO) += cmd_gpio.o COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o diff --git a/common/cmd_gettime.c b/common/cmd_gettime.c new file mode 100644 index 0000000..d7d36a9 --- /dev/null +++ b/common/cmd_gettime.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * + * Copyright (c) 2009, Code Aurora Forum. All rights reserved. + * + * (C) Copyright 2001 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec + */ +#include <common.h> +#include <command.h> + +static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + unsigned long int val = get_timer(0); + +#ifdef CONFIG_SYS_HZ + printf("Timer val: %lu\n", val); + printf("Seconds : %lu\n", val / CONFIG_SYS_HZ); + printf("Remainder : %lu\n", val % CONFIG_SYS_HZ); + printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ); +#else + printf("CONFIG_SYS_HZ not defined"); + printf("Timer Val %lu", val); +#endif + + return 0; +} + +U_BOOT_CMD( + gettime, 1, 1, do_gettime, + "get timer val elapsed,\n", + "get time elapsed from uboot start\n" +); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index f434cd0..b87967e 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -40,6 +40,7 @@ #define CONFIG_CMD_FDOS /* Floppy DOS support */ #define CONFIG_CMD_FLASH /* flinfo, erase, protect */ #define CONFIG_CMD_FPGA /* FPGA configuration Support */ +#define CONFIG_CMD_GETTIME /* Get time since boot */ #define CONFIG_CMD_HWFLOW /* RTS/CTS hw flow control */ #define CONFIG_CMD_I2C /* I2C serial bus support */ #define CONFIG_CMD_IDE /* IDE harddisk support */

Hi Simon,
On Fri, Nov 02, 2012 at 05:27:18PM -0700, Simon Glass wrote:
From: Anton Staaf robotboy@chromium.org
Gettime returns the current timer value. If CONFIG_SYS_HZ is defined then the timer value is also converted to seconds.
Tegra20 (SeaBoard) # gettime Timer val: 7754 Seconds : 7 Remainder : 754 sys_hz = 1000
Signed-off-by: Anton Staaf robotboy@chromium.org Signed-off-by: Simon Glass sjg@chromium.org
README | 1 + common/Makefile | 1 + common/cmd_gettime.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 59 insertions(+), 0 deletions(-) create mode 100644 common/cmd_gettime.c
diff --git a/README b/README index 22fd6b7..a080225 100644 --- a/README +++ b/README @@ -815,6 +815,7 @@ The following options need to be configured: CONFIG_CMD_FDOS * Dos diskette Support CONFIG_CMD_FLASH flinfo, erase, protect CONFIG_CMD_FPGA FPGA device initialization support
CONFIG_CMD_GETTIME * Get time since boot
Here should be TABs instead of spaces.
CONFIG_CMD_GO * the 'go' command (exec code) CONFIG_CMD_GREPENV * search environment CONFIG_CMD_HWFLOW * RTS/CTS hw flow control
diff --git a/common/Makefile b/common/Makefile index 9e43322..0fb79ed 100644 --- a/common/Makefile +++ b/common/Makefile @@ -100,6 +100,7 @@ ifdef CONFIG_FPGA COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o endif COBJS-$(CONFIG_CMD_FS_GENERIC) += cmd_fs.o +COBJS-$(CONFIG_CMD_GETTIME) += cmd_gettime.o COBJS-$(CONFIG_CMD_GPIO) += cmd_gpio.o COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o diff --git a/common/cmd_gettime.c b/common/cmd_gettime.c new file mode 100644 index 0000000..d7d36a9 --- /dev/null +++ b/common/cmd_gettime.c @@ -0,0 +1,56 @@ +/*
- Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
- Copyright (c) 2009, Code Aurora Forum. All rights reserved.
- (C) Copyright 2001
- Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+/*
- Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec
- */
+#include <common.h> +#include <command.h>
+static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
+{
- unsigned long int val = get_timer(0);
+#ifdef CONFIG_SYS_HZ
- printf("Timer val: %lu\n", val);
- printf("Seconds : %lu\n", val / CONFIG_SYS_HZ);
- printf("Remainder : %lu\n", val % CONFIG_SYS_HZ);
- printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ);
+#else
- printf("CONFIG_SYS_HZ not defined");
- printf("Timer Val %lu", val);
+#endif
- return 0;
+}
+U_BOOT_CMD(
- gettime, 1, 1, do_gettime,
I would put here spaces instead of TABs.
- "get timer val elapsed,\n",
- "get time elapsed from uboot start\n"
+); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index f434cd0..b87967e 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -40,6 +40,7 @@ #define CONFIG_CMD_FDOS /* Floppy DOS support */ #define CONFIG_CMD_FLASH /* flinfo, erase, protect */ #define CONFIG_CMD_FPGA /* FPGA configuration Support */ +#define CONFIG_CMD_GETTIME /* Get time since boot */ #define CONFIG_CMD_HWFLOW /* RTS/CTS hw flow control */ #define CONFIG_CMD_I2C /* I2C serial bus support */
#define CONFIG_CMD_IDE /* IDE harddisk support */
1.7.7.3
Luka

Hi Luka,
On Sat, Nov 3, 2012 at 1:22 AM, Luka Perkov uboot@lukaperkov.net wrote:
Hi Simon,
On Fri, Nov 02, 2012 at 05:27:18PM -0700, Simon Glass wrote:
From: Anton Staaf robotboy@chromium.org
Gettime returns the current timer value. If CONFIG_SYS_HZ is defined then the timer value is also converted to seconds.
Tegra20 (SeaBoard) # gettime Timer val: 7754 Seconds : 7 Remainder : 754 sys_hz = 1000
Signed-off-by: Anton Staaf robotboy@chromium.org Signed-off-by: Simon Glass sjg@chromium.org
README | 1 + common/Makefile | 1 + common/cmd_gettime.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 59 insertions(+), 0 deletions(-) create mode 100644 common/cmd_gettime.c
diff --git a/README b/README index 22fd6b7..a080225 100644 --- a/README +++ b/README @@ -815,6 +815,7 @@ The following options need to be configured: CONFIG_CMD_FDOS * Dos diskette Support CONFIG_CMD_FLASH flinfo, erase, protect CONFIG_CMD_FPGA FPGA device initialization support
CONFIG_CMD_GETTIME * Get time since boot
Here should be TABs instead of spaces.
Done
CONFIG_CMD_GO * the 'go' command (exec code) CONFIG_CMD_GREPENV * search environment CONFIG_CMD_HWFLOW * RTS/CTS hw flow control
diff --git a/common/Makefile b/common/Makefile index 9e43322..0fb79ed 100644 --- a/common/Makefile +++ b/common/Makefile @@ -100,6 +100,7 @@ ifdef CONFIG_FPGA COBJS-$(CONFIG_CMD_FPGA) += cmd_fpga.o endif COBJS-$(CONFIG_CMD_FS_GENERIC) += cmd_fs.o +COBJS-$(CONFIG_CMD_GETTIME) += cmd_gettime.o COBJS-$(CONFIG_CMD_GPIO) += cmd_gpio.o COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o diff --git a/common/cmd_gettime.c b/common/cmd_gettime.c new file mode 100644 index 0000000..d7d36a9 --- /dev/null +++ b/common/cmd_gettime.c @@ -0,0 +1,56 @@ +/*
- Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
- Copyright (c) 2009, Code Aurora Forum. All rights reserved.
- (C) Copyright 2001
- Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- See file CREDITS for list of people who contributed to this
- project.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- MA 02111-1307 USA
- */
+/*
- Get Timer overflows after 2^32 / CONFIG_SYS_HZ (32Khz) = 131072 sec
- */
+#include <common.h> +#include <command.h>
+static int do_gettime(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
+{
unsigned long int val = get_timer(0);
+#ifdef CONFIG_SYS_HZ
printf("Timer val: %lu\n", val);
printf("Seconds : %lu\n", val / CONFIG_SYS_HZ);
printf("Remainder : %lu\n", val % CONFIG_SYS_HZ);
printf("sys_hz = %lu\n", (unsigned long int)CONFIG_SYS_HZ);
+#else
printf("CONFIG_SYS_HZ not defined");
printf("Timer Val %lu", val);
+#endif
return 0;
+}
+U_BOOT_CMD(
gettime, 1, 1, do_gettime,
I would put here spaces instead of TABs.
I don't actually see any spaces on that line.
"get timer val elapsed,\n",
"get time elapsed from uboot start\n"
+); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index f434cd0..b87967e 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -40,6 +40,7 @@ #define CONFIG_CMD_FDOS /* Floppy DOS support */ #define CONFIG_CMD_FLASH /* flinfo, erase, protect */ #define CONFIG_CMD_FPGA /* FPGA configuration Support */ +#define CONFIG_CMD_GETTIME /* Get time since boot */ #define CONFIG_CMD_HWFLOW /* RTS/CTS hw flow control */ #define CONFIG_CMD_I2C /* I2C serial bus support */
#define CONFIG_CMD_IDE /* IDE harddisk support */
1.7.7.3
Luka
Regards, Simon

Dear Simon Glass,
In message 1351902453-27956-3-git-send-email-sjg@chromium.org you wrote:
From: Anton Staaf robotboy@chromium.org
Gettime returns the current timer value. If CONFIG_SYS_HZ is defined then the timer value is also converted to seconds.
Tegra20 (SeaBoard) # gettime Timer val: 7754 Seconds : 7 Remainder : 754 sys_hz = 1000
What exactly is this good for?
Also, are there any boards where CONFIG_SYS_HZ is NOT set? [Which are these?]
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:24 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-3-git-send-email-sjg@chromium.org you wrote:
From: Anton Staaf robotboy@chromium.org
Gettime returns the current timer value. If CONFIG_SYS_HZ is defined then the timer value is also converted to seconds.
Tegra20 (SeaBoard) # gettime Timer val: 7754 Seconds : 7 Remainder : 754 sys_hz = 1000
What exactly is this good for?
Just for displaying the current time value and sys_hz. If you don't think it is useful, please say so and we will drop it.
Also, are there any boards where CONFIG_SYS_HZ is NOT set? [Which are these?]
There are a few:
(for f in 01_of_04_g59852d03_Merge-branch-'master/*/autoconf.mk; do if ! grep -q CONFIG_SYS_HZ $f; then echo $f; fi; done) | awk -F/ '{print $2}' M52277EVB M52277EVB_stmicro M53017EVB M54418TWR M54418TWR_nand_mii M54418TWR_nand_rmii M54418TWR_nand_rmii_lowfreq M54418TWR_serial_mii M54418TWR_serial_rmii
Regards, Simon
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Earth -- mother of the most beautiful women in the universe. -- Apollo, "Who Mourns for Adonais?" stardate 3468.1

From: Kenneth Waters kwaters@chromium.org
Sometimes data is on a block device and within a partition, but not in a particular filesystem.
This commands permits reading raw data from a partition.
Signed-off-by: Kenneth Waters kwaters@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- README | 1 + common/Makefile | 1 + common/cmd_read.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 84 insertions(+), 0 deletions(-) create mode 100644 common/cmd_read.c
diff --git a/README b/README index a080225..05c5688 100644 --- a/README +++ b/README @@ -852,6 +852,7 @@ The following options need to be configured: CONFIG_CMD_PING * send ICMP ECHO_REQUEST to network host CONFIG_CMD_PORTIO * Port I/O + CONFIG_CMD_READ * Read raw data from partition CONFIG_CMD_REGINFO * Register dump CONFIG_CMD_RUN run command in env variable CONFIG_CMD_SAVES * save S record dump diff --git a/common/Makefile b/common/Makefile index 0fb79ed..84968f8 100644 --- a/common/Makefile +++ b/common/Makefile @@ -142,6 +142,7 @@ endif COBJS-y += cmd_pcmcia.o COBJS-$(CONFIG_CMD_PORTIO) += cmd_portio.o COBJS-$(CONFIG_CMD_PXE) += cmd_pxe.o +COBJS-$(CONFIG_CMD_READ) += cmd_read.o COBJS-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o COBJS-$(CONFIG_CMD_SATA) += cmd_sata.o diff --git a/common/cmd_read.c b/common/cmd_read.c new file mode 100644 index 0000000..f0fc9bf --- /dev/null +++ b/common/cmd_read.c @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Alternatively, this software may be distributed under the terms of the + * GNU General Public License ("GPL") version 2 as published by the Free + * Software Foundation. + */ + +#include <common.h> +#include <command.h> +#include <part.h> + +int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + char *ep; + block_dev_desc_t *dev_desc = NULL; + int dev; + int part = 0; + disk_partition_t part_info; + ulong offset = 0u; + ulong limit = 0u; + void *addr; + uint blk; + uint cnt; + + if (argc != 6) { + cmd_usage(cmdtp); + return 1; + } + + dev = (int)simple_strtoul(argv[2], &ep, 16); + if (*ep) { + if (*ep != ':') { + printf("Invalid block device %s\n", argv[2]); + return 1; + } + part = (int)simple_strtoul(++ep, NULL, 16); + } + + dev_desc = get_dev(argv[1], dev); + if (dev_desc == NULL) { + printf("Block device %s %d not supported\n", argv[1], dev); + return 1; + } + + addr = (void *)simple_strtoul(argv[3], NULL, 16); + blk = simple_strtoul(argv[4], NULL, 16); + cnt = simple_strtoul(argv[5], NULL, 16); + + if (part != 0) { + if (get_partition_info(dev_desc, part, &part_info)) { + printf("Cannot find partition %d\n", part); + return 1; + } + offset = part_info.start; + limit = part_info.size; + } else { + /* Largest address not available in block_dev_desc_t. */ + limit = ~0; + } + + if (cnt + blk > limit) { + printf("Read out of range\n"); + return 1; + } + + if (dev_desc->block_read(dev, offset + blk, cnt, addr) < 0) { + printf("Error reading blocks\n"); + return 1; + } + + return 0; +} + +U_BOOT_CMD( + read, 6, 0, do_read, + "Load binary data from a partition", + "<interface> <dev[:part]> addr blk# cnt" +); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index b87967e..148d676 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -71,6 +71,7 @@ #define CONFIG_CMD_REGINFO /* Register dump */ #define CONFIG_CMD_REISER /* Reiserfs support */ #define CONFIG_CMD_RARP /* rarpboot support */ +#define CONFIG_CMD_READ /* Read data from partition */ #define CONFIG_CMD_RUN /* run command in env variable */ #define CONFIG_CMD_SAVEENV /* saveenv */ #define CONFIG_CMD_SAVES /* save S record dump */

This code was not guarded with CONFIG_LMB so failed to build on x86.
Signed-off-by: Simon Glass sjg@chromium.org --- common/cmd_bootm.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 83fa5d7..2f52cd0 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -537,7 +537,7 @@ int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc, } break; #endif -#if defined(CONFIG_OF_LIBFDT) +#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_LMB) case BOOTM_STATE_FDT: { boot_fdt_add_mem_rsv_regions(&images.lmb,

From: Vincent Palatin vpalatin@chromium.org
The name is already copied when we memopy the whole structure.
Signed-off-by: Vincent Palatin vpalatin@chromium.org
Commit-Ready: Vincent Palatin vpalatin@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- common/stdio.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/common/stdio.c b/common/stdio.c index 605ff3f..c7a323f 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -135,7 +135,6 @@ struct stdio_dev* stdio_clone(struct stdio_dev *dev) return NULL;
memcpy(_dev, dev, sizeof(struct stdio_dev)); - strncpy(_dev->name, dev->name, 16);
return _dev; }

Dear Simon Glass,
In message 1351902453-27956-6-git-send-email-sjg@chromium.org you wrote:
From: Vincent Palatin vpalatin@chromium.org
The name is already copied when we memopy the whole structure.
memopy?
--- a/common/stdio.c +++ b/common/stdio.c @@ -135,7 +135,6 @@ struct stdio_dev* stdio_clone(struct stdio_dev *dev) return NULL;
memcpy(_dev, dev, sizeof(struct stdio_dev));
- strncpy(_dev->name, dev->name, 16);
_dev contains just the pointer, not the data, so why can we omit copying the data?
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:31 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-6-git-send-email-sjg@chromium.org you wrote:
From: Vincent Palatin vpalatin@chromium.org
The name is already copied when we memopy the whole structure.
memopy?
Done
--- a/common/stdio.c +++ b/common/stdio.c @@ -135,7 +135,6 @@ struct stdio_dev* stdio_clone(struct stdio_dev *dev) return NULL;
memcpy(_dev, dev, sizeof(struct stdio_dev));
strncpy(_dev->name, dev->name, 16);
_dev contains just the pointer, not the data, so why can we omit copying the data?
I will add more detail to the commit message:
This is because struct stdio_dev has this field:
char name[16]; /* Device name */
So the data is inline, rather than being a pointer.
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de "It is better for civilization to be going down the drain than to be coming up it." - Henry Allen
Regards, Simon

From: Doug Anderson dianders@chromium.org
This is a useful mechanism any time you have a way to update the saved environment outside of u-boot. This can be a tool like fw_setenv.
Signed-off-by: Doug Anderson dianders@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- README | 7 +++++++ common/env_common.c | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/README b/README index 05c5688..785953f 100644 --- a/README +++ b/README @@ -4098,6 +4098,13 @@ Please note that changes to some configuration parameters may take only effect after the next boot (yes, that's just like Windoze :-).
+If merge_with_default is in the loaded environment, and is not "0", then +the loaded environment will be merged on top of the default environment +instead of just replacing it. This means that your saved environment can +contain only the variables you need to change from the default. This is +useful with fw_setenv. + + Command Line Parsing: =====================
diff --git a/common/env_common.c b/common/env_common.c index 3d3cb70..f7fe7a2 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -34,6 +34,19 @@
DECLARE_GLOBAL_DATA_PTR;
+/* + * Create a saved enviroment with this env variable set to "1" to merge the + * saved environment on top of the default environment. The idea is that your + * saved environment would just contain variables that you'd like to override + * from the default so that as you update u-boot (w/ potential changes to the + * default) you get all the updates. + * + * This is really most useful when you have a tool like fw_setenv to manage + * your saved environment. Using 'saveenv' to save your environment will saved + * the _merged_ environment (AKA it won't unmerge things). + */ +#define MERGE_WITH_DEFAULT "merge_with_default" + /************************************************************************ * Default settings to be used when no valid environment is found */ @@ -156,7 +169,19 @@ int env_import(const char *buf, int check)
if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0, 0, NULL, 0 /* do_apply */)) { + char *merge_val; + gd->flags |= GD_FLG_ENV_READY; + merge_val = getenv(MERGE_WITH_DEFAULT); + + if (merge_val != NULL && merge_val[0] != '0') { + set_default_env(""); + himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', + H_NOCLEAR, 0, NULL, 0 /* do_apply */); + hdelete_r(MERGE_WITH_DEFAULT, &env_htab, + 0 /* do_apply */); + puts("Merged saved with default environment\n\n"); + } return 1; }

Dear Simon Glass,
In message 1351902453-27956-7-git-send-email-sjg@chromium.org you wrote:
From: Doug Anderson dianders@chromium.org
This is a useful mechanism any time you have a way to update the saved environment outside of u-boot. This can be a tool like fw_setenv.
I don't see the need for this.
What exactly does it that "env reset" followed by "env import" does not do?
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:28 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-7-git-send-email-sjg@chromium.org you wrote:
From: Doug Anderson dianders@chromium.org
This is a useful mechanism any time you have a way to update the saved environment outside of u-boot. This can be a tool like fw_setenv.
I don't see the need for this.
What exactly does it that "env reset" followed by "env import" does not do?
It allows the environment to either overwrite or merge, under the control of the imported environment itself. I suppose the same could be achieved by a script anyway. Let's drop it.
Regards, Simon
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Don't put off for tomorrow what you can do today, because if you enjoy it today you can do it again tomorrow.

From: Stefan Reinauer reinauer@chromium.org
Since U-Boot runs from coreboot on x86, the Coreboot version is an important part of the boot state. This version information is available in the coreboot tables, so print it when the 'version' command is used.
Signed-off-by: Simon Glass sjg@chromium.org --- common/cmd_version.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/common/cmd_version.c b/common/cmd_version.c index e4b2ac1..860c7ea 100644 --- a/common/cmd_version.c +++ b/common/cmd_version.c @@ -25,6 +25,9 @@ #include <command.h> #include <version.h> #include <linux/compiler.h> +#ifdef CONFIG_SYS_COREBOOT +#include <asm/arch/sysinfo.h> +#endif
const char __weak version_string[] = U_BOOT_VERSION_STRING;
@@ -37,7 +40,9 @@ int do_version(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #ifdef LD_VERSION_STRING puts(LD_VERSION_STRING "\n"); #endif - +#ifdef CONFIG_SYS_COREBOOT + printf("coreboot-%s (%s)\n", lib_sysinfo.version, lib_sysinfo.build); +#endif return 0; }

It is better to use get_timer() by itself now, according to the new timer API.
Signed-off-by: Simon Glass sjg@chromium.org --- common/cmd_time.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/cmd_time.c b/common/cmd_time.c index 6dbdbbf..f1891f9 100644 --- a/common/cmd_time.c +++ b/common/cmd_time.c @@ -32,6 +32,7 @@ static int run_command_and_time_it(int flag, int argc, char * const argv[], { cmd_tbl_t *cmdtp = find_cmd(argv[0]); int retval = 0; + ulong start;
if (!cmdtp) { printf("%s: command not found\n", argv[0]); @@ -45,9 +46,9 @@ static int run_command_and_time_it(int flag, int argc, char * const argv[], * boards. We could use the new timer API that Graeme is proposing * so that this piece of code would be arch-independent. */ - *cycles = get_timer_masked(); + start = get_timer(0); retval = cmdtp->cmd(cmdtp, flag, argc, argv); - *cycles = get_timer_masked() - *cycles; + *cycles = get_timer(start);
return retval; }

From: ARUN MANKUZHI arun.m@samsung.com
sha256 command is added which can be used to test SHA 256 hash algorithm.
Signed-off-by: ARUN MANKUZHI arun.m@samsung.com Signed-off-by: Simon Glass sjg@chromium.org --- README | 1 + common/Makefile | 1 + common/cmd_sha256.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 60 insertions(+), 0 deletions(-) create mode 100644 common/cmd_sha256.c
diff --git a/README b/README index 785953f..31e25fe 100644 --- a/README +++ b/README @@ -861,6 +861,7 @@ The following options need to be configured: (requires CONFIG_CMD_I2C) CONFIG_CMD_SETGETDCR Support for DCR Register access (4xx only) + CONFIG_CMD_SHA256 * Calculate SHA256 for block CONFIG_CMD_SF * Read/write/erase SPI NOR flash CONFIG_CMD_SHA1SUM print sha1 memory digest (requires CONFIG_CMD_MEMORY) diff --git a/common/Makefile b/common/Makefile index 84968f8..6f6f0fa 100644 --- a/common/Makefile +++ b/common/Makefile @@ -150,6 +150,7 @@ COBJS-$(CONFIG_CMD_SF) += cmd_sf.o COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o COBJS-$(CONFIG_CMD_SHA1SUM) += cmd_sha1sum.o COBJS-$(CONFIG_CMD_SETEXPR) += cmd_setexpr.o +COBJS-$(CONFIG_CMD_SHA256) += cmd_sha256.o COBJS-$(CONFIG_CMD_SPI) += cmd_spi.o COBJS-$(CONFIG_CMD_SPIBOOTLDR) += cmd_spibootldr.o COBJS-$(CONFIG_CMD_STRINGS) += cmd_strings.o diff --git a/common/cmd_sha256.c b/common/cmd_sha256.c new file mode 100644 index 0000000..006391d --- /dev/null +++ b/common/cmd_sha256.c @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <command.h> +#include <sha256.h> + +int do_sha256(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + unsigned long inlen; + unsigned char *input, *out; + int i; + sha256_context sha_cnxt; + if (argc < 4) { + printf("usage: sha256 <input> <input length> <output>\n"); + return 0; + } + input = (unsigned char *)simple_strtoul(argv[1], NULL, 16); + inlen = simple_strtoul(argv[2], NULL, 16); + out = (unsigned char *)simple_strtoul(argv[3], NULL, 16); + + sha256_starts(&sha_cnxt); + sha256_update(&sha_cnxt, input, inlen); + sha256_finish(&sha_cnxt, out); + + for (i = 0; i < 32; i++) + printf("0x%02X ", out[i]); + printf("\n"); + + return 0; +} + +U_BOOT_CMD( + sha256, 4, 1, do_sha256, + "print hash result", + "<input> <inputlength> <output>" +); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index 148d676..efd17e6 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -79,6 +79,7 @@ #define CONFIG_CMD_SDRAM /* SDRAM DIMM SPD info printout */ #define CONFIG_CMD_SETEXPR /* setexpr support */ #define CONFIG_CMD_SETGETDCR /* DCR support on 4xx */ +#define CONFIG_CMD_SHA256 /* Calculate SHA256 for block */ #define CONFIG_CMD_SNTP /* SNTP support */ #define CONFIG_CMD_SOURCE /* "source" command support */ #define CONFIG_CMD_SPI /* SPI utility */

Dear Simon Glass,
In message 1351902453-27956-10-git-send-email-sjg@chromium.org you wrote:
From: ARUN MANKUZHI arun.m@samsung.com
sha256 command is added which can be used to test SHA 256 hash algorithm.
Signed-off-by: ARUN MANKUZHI arun.m@samsung.com Signed-off-by: Simon Glass sjg@chromium.org
README | 1 + common/Makefile | 1 + common/cmd_sha256.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 60 insertions(+), 0 deletions(-) create mode 100644 common/cmd_sha256.c
Please make sure interface and functionality is similar to what we do elsewhere, i. e. with the crc32 command.
+U_BOOT_CMD(
- sha256, 4, 1, do_sha256,
- "print hash result",
- "<input> <inputlength> <output>"
+);
What is "<input>" or "<output>" supposed to mean? I don;t understand this.
"<output>" should not be mandatory. I would appreciate if we could use similar help text as with the crc32 command:
crc32 - checksum calculation
Usage: crc32 address count [addr] - compute CRC32 checksum [save at addr]
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:23 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-10-git-send-email-sjg@chromium.org you wrote:
From: ARUN MANKUZHI arun.m@samsung.com
sha256 command is added which can be used to test SHA 256 hash algorithm.
Signed-off-by: ARUN MANKUZHI arun.m@samsung.com Signed-off-by: Simon Glass sjg@chromium.org
README | 1 + common/Makefile | 1 + common/cmd_sha256.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ include/config_cmd_all.h | 1 + 4 files changed, 60 insertions(+), 0 deletions(-) create mode 100644 common/cmd_sha256.c
Please make sure interface and functionality is similar to what we do elsewhere, i. e. with the crc32 command.
OK I didn't notice some new patches in SHA1 also, which provide an enhanced command similar to crc32. It's isn't really sensible to duplicate that code. Thanks for pointing that out.
I think we should come up with some sort of generic hashing command which can deal with multiple algorithms. Then SHA1 and SHA256 at least can share the same basic parsing / verification code. I will take a look at this, and put it in a new version of this series.
+U_BOOT_CMD(
sha256, 4, 1, do_sha256,
"print hash result",
"<input> <inputlength> <output>"
+);
What is "<input>" or "<output>" supposed to mean? I don;t understand this.
"<output>" should not be mandatory. I would appreciate if we could use similar help text as with the crc32 command:
crc32 - checksum calculation Usage: crc32 address count [addr] - compute CRC32 checksum [save at addr]
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de "Love is an ideal thing, marriage a real thing; a confusion of the real with the ideal never goes unpunished." - Goethe
Regards, Simon

From: Tom Wai-Hong Tam waihong@chromium.org
This implements a library for accessing EDID data from an LCD panel. This is used to obtain information about the panel such as its resolution and type.
This is a tidied-up version of the original code pulled from https://github.com/ynezz/u-boot-edid.
The changes we made are: - removed bit fields in the struct; - removed endianness cases in the struct; - fixed some wrong definitions; - fixed to fit 80 columns; - fixed some code styles.
Signed-off-by: Tom Wai-Hong Tam waihong@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- common/Makefile | 1 + common/edid.c | 307 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/edid.h | 275 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 583 insertions(+), 0 deletions(-) create mode 100644 common/edid.c create mode 100644 include/edid.h
diff --git a/common/Makefile b/common/Makefile index 6f6f0fa..eac38fc 100644 --- a/common/Makefile +++ b/common/Makefile @@ -103,6 +103,7 @@ COBJS-$(CONFIG_CMD_FS_GENERIC) += cmd_fs.o COBJS-$(CONFIG_CMD_GETTIME) += cmd_gettime.o COBJS-$(CONFIG_CMD_GPIO) += cmd_gpio.o COBJS-$(CONFIG_CMD_I2C) += cmd_i2c.o +COBJS-$(CONFIG_I2C_EDID) += edid.o COBJS-$(CONFIG_CMD_IDE) += cmd_ide.o COBJS-$(CONFIG_CMD_IMMAP) += cmd_immap.o COBJS-$(CONFIG_CMD_INI) += cmd_ini.o diff --git a/common/edid.c b/common/edid.c new file mode 100644 index 0000000..c82c298 --- /dev/null +++ b/common/edid.c @@ -0,0 +1,307 @@ +/* + * Copyright (c) 2012 The Chromium OS Authors. + * + * (C) Copyright 2010 + * Petr Stetiar ynezz@true.cz + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * Contains stolen code from ddcprobe project which is: + * Copyright (C) Nalin Dahyabhai bigfun@pobox.com + * + */ + +#include <common.h> +#include <edid.h> +#include <linux/ctype.h> +#include <linux/string.h> + +int edid_check_info(struct edid1_info *edid_info) +{ + if ((edid_info == NULL) || (edid_info->version == 0)) + return -1; + + if (memcmp(edid_info->header, "\x0\xff\xff\xff\xff\xff\xff\x0", 8)) + return -1; + + if (edid_info->version == 0xff && edid_info->revision == 0xff) + return -1; + + return 0; +} + +int edid_get_ranges(struct edid1_info *edid, unsigned int *hmin, + unsigned int *hmax, unsigned int *vmin, + unsigned int *vmax) +{ + int i; + struct edid_monitor_descriptor *monitor; + + *hmin = *hmax = *vmin = *vmax = 0; + if (edid_check_info(edid)) + return -1; + + for (i = 0; i < ARRAY_SIZE(edid->monitor_details.descriptor); i++) { + monitor = &edid->monitor_details.descriptor[i]; + if (monitor->type == EDID_MONITOR_DESCRIPTOR_RANGE) { + *hmin = monitor->data.range_data.horizontal_min; + *hmax = monitor->data.range_data.horizontal_max; + *vmin = monitor->data.range_data.vertical_min; + *vmax = monitor->data.range_data.vertical_max; + return 0; + } + } + return -1; +} + +/** + * Snip the tailing whitespace/return of a string. + * + * @param string The string to be snipped + * @return the snipped string + */ +static char *snip(char *string) +{ + char *s; + + /* + * This is always a 13 character buffer + * and it's not always terminated. + */ + string[12] = '\0'; + s = &string[strlen(string) - 1]; + + while (s >= string && (isspace(*s) || *s == '\n' || *s == '\r' || + *s == '\0')) + *(s--) = '\0'; + + return string; +} + +/** + * Print an EDID monitor descriptor block + * + * @param monitor The EDID monitor descriptor block + * @have_timing Modifies to 1 if the desciptor contains timing info + */ +static void edid_print_dtd(struct edid_monitor_descriptor *monitor, + unsigned int *have_timing) +{ + unsigned char *bytes = (unsigned char *)monitor; + struct edid_detailed_timing *timing = + (struct edid_detailed_timing *)monitor; + + if (bytes[0] == 0 && bytes[1] == 0) { + if (monitor->type == EDID_MONITOR_DESCRIPTOR_SERIAL) + printf("Monitor serial number: %s\n", + snip(monitor->data.string)); + else if (monitor->type == EDID_MONITOR_DESCRIPTOR_ASCII) + printf("Monitor ID: %s\n", + snip(monitor->data.string)); + else if (monitor->type == EDID_MONITOR_DESCRIPTOR_NAME) + printf("Monitor name: %s\n", + snip(monitor->data.string)); + else if (monitor->type == EDID_MONITOR_DESCRIPTOR_RANGE) + printf("Monitor range limits, horizontal sync: " + "%d-%d kHz, vertical refresh: " + "%d-%d Hz, max pixel clock: " + "%d MHz\n", + monitor->data.range_data.horizontal_min, + monitor->data.range_data.horizontal_max, + monitor->data.range_data.vertical_min, + monitor->data.range_data.vertical_max, + monitor->data.range_data.pixel_clock_max * 10); + } else { + uint32_t pixclock, h_active, h_blanking, v_active, v_blanking; + uint32_t h_total, v_total, vfreq; + + pixclock = EDID_DETAILED_TIMING_PIXEL_CLOCK(*timing); + h_active = EDID_DETAILED_TIMING_HORIZONTAL_ACTIVE(*timing); + h_blanking = EDID_DETAILED_TIMING_HORIZONTAL_BLANKING(*timing); + v_active = EDID_DETAILED_TIMING_VERTICAL_ACTIVE(*timing); + v_blanking = EDID_DETAILED_TIMING_VERTICAL_BLANKING(*timing); + + h_total = h_active + h_blanking; + v_total = v_active + v_blanking; + if (v_total * h_total) + vfreq = pixclock / (v_total * h_total); + else + vfreq = 1; /* Error case */ + printf("\t%dx%d%c\t%d Hz (detailed)\n", h_active, + v_active, h_active > 1000 ? ' ' : '\t', vfreq); + *have_timing = 1; + } +} + +/** + * Get the manufacturer name from an EDID info. + * + * @param edid_info The EDID info to be printed + * @param name Returns the string of the manufacturer name + */ +static void edid_get_manufacturer_name(struct edid1_info *edid, char *name) +{ + name[0] = EDID1_INFO_MANUFACTURER_NAME_CHAR1(*edid) + 'A' - 1; + name[1] = EDID1_INFO_MANUFACTURER_NAME_CHAR2(*edid) + 'A' - 1; + name[2] = EDID1_INFO_MANUFACTURER_NAME_CHAR3(*edid) + 'A' - 1; + name[3] = '\0'; +} + +void edid_print_info(struct edid1_info *edid_info) +{ + int i; + char manufacturer[4]; + unsigned int have_timing = 0; + uint32_t serial_number; + + if (edid_check_info(edid_info)) { + printf("Not a valid EDID\n"); + return; + } + + printf("EDID version: %d.%d\n", + edid_info->version, edid_info->revision); + + printf("Product ID code: %04x\n", EDID1_INFO_PRODUCT_CODE(*edid_info)); + + edid_get_manufacturer_name(edid_info, manufacturer); + printf("Manufacturer: %s\n", manufacturer); + + serial_number = EDID1_INFO_SERIAL_NUMBER(*edid_info); + if (serial_number != 0xffffffff) { + if (strcmp(manufacturer, "MAG") == 0) + serial_number -= 0x7000000; + if (strcmp(manufacturer, "OQI") == 0) + serial_number -= 456150000; + if (strcmp(manufacturer, "VSC") == 0) + serial_number -= 640000000; + } + printf("Serial number: %08x\n", serial_number); + printf("Manufactured in week: %d year: %d\n", + edid_info->week, edid_info->year + 1990); + + printf("Video input definition: %svoltage level %d%s%s%s%s%s\n", + EDID1_INFO_VIDEO_INPUT_DIGITAL(*edid_info) ? + "digital signal, " : "analog signal, ", + EDID1_INFO_VIDEO_INPUT_VOLTAGE_LEVEL(*edid_info), + EDID1_INFO_VIDEO_INPUT_BLANK_TO_BLACK(*edid_info) ? + ", blank to black" : "", + EDID1_INFO_VIDEO_INPUT_SEPARATE_SYNC(*edid_info) ? + ", separate sync" : "", + EDID1_INFO_VIDEO_INPUT_COMPOSITE_SYNC(*edid_info) ? + ", composite sync" : "", + EDID1_INFO_VIDEO_INPUT_SYNC_ON_GREEN(*edid_info) ? + ", sync on green" : "", + EDID1_INFO_VIDEO_INPUT_SERRATION_V(*edid_info) ? + ", serration v" : ""); + + printf("Monitor is %s\n", + EDID1_INFO_FEATURE_RGB(*edid_info) ? "RGB" : "non-RGB"); + + printf("Maximum visible display size: %d cm x %d cm\n", + edid_info->max_size_horizontal, + edid_info->max_size_vertical); + + printf("Power management features: %s%s, %s%s, %s%s\n", + EDID1_INFO_FEATURE_ACTIVE_OFF(*edid_info) ? + "" : "no ", "active off", + EDID1_INFO_FEATURE_SUSPEND(*edid_info) ? "" : "no ", "suspend", + EDID1_INFO_FEATURE_STANDBY(*edid_info) ? "" : "no ", "standby"); + + printf("Estabilished timings:\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_720X400_70(*edid_info)) + printf("\t720x400\t\t70 Hz (VGA 640x400, IBM)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_720X400_88(*edid_info)) + printf("\t720x400\t\t88 Hz (XGA2)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_640X480_60(*edid_info)) + printf("\t640x480\t\t60 Hz (VGA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_640X480_67(*edid_info)) + printf("\t640x480\t\t67 Hz (Mac II, Apple)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_640X480_72(*edid_info)) + printf("\t640x480\t\t72 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_640X480_75(*edid_info)) + printf("\t640x480\t\t75 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_800X600_56(*edid_info)) + printf("\t800x600\t\t56 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_800X600_60(*edid_info)) + printf("\t800x600\t\t60 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_800X600_72(*edid_info)) + printf("\t800x600\t\t72 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_800X600_75(*edid_info)) + printf("\t800x600\t\t75 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_832X624_75(*edid_info)) + printf("\t832x624\t\t75 Hz (Mac II)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_1024X768_87I(*edid_info)) + printf("\t1024x768\t87 Hz Interlaced (8514A)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_1024X768_60(*edid_info)) + printf("\t1024x768\t60 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_1024X768_70(*edid_info)) + printf("\t1024x768\t70 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_1024X768_75(*edid_info)) + printf("\t1024x768\t75 Hz (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_1280X1024_75(*edid_info)) + printf("\t1280x1024\t75 (VESA)\n"); + if (EDID1_INFO_ESTABLISHED_TIMING_1152X870_75(*edid_info)) + printf("\t1152x870\t75 (Mac II)\n"); + + /* Standard timings. */ + printf("Standard timings:\n"); + for (i = 0; i < ARRAY_SIZE(edid_info->standard_timings); i++) { + unsigned int aspect = 10000; + unsigned int x, y; + unsigned char xres, vfreq; + + xres = EDID1_INFO_STANDARD_TIMING_XRESOLUTION(*edid_info, i); + vfreq = EDID1_INFO_STANDARD_TIMING_VFREQ(*edid_info, i); + if ((xres != vfreq) || + ((xres != 0) && (xres != 1)) || + ((vfreq != 0) && (vfreq != 1))) { + switch (EDID1_INFO_STANDARD_TIMING_ASPECT(*edid_info, + i)) { + case ASPECT_625: + aspect = 6250; + break; + case ASPECT_75: + aspect = 7500; + break; + case ASPECT_8: + aspect = 8000; + break; + case ASPECT_5625: + aspect = 5625; + break; + } + x = (xres + 31) * 8; + y = x * aspect / 10000; + printf("\t%dx%d%c\t%d Hz\n", x, y, + x > 1000 ? ' ' : '\t', (vfreq & 0x3f) + 60); + have_timing = 1; + } + } + + /* Detailed timing information. */ + for (i = 0; i < ARRAY_SIZE(edid_info->monitor_details.descriptor); + i++) { + edid_print_dtd(&edid_info->monitor_details.descriptor[i], + &have_timing); + } + + if (!have_timing) + printf("\tNone\n"); +} diff --git a/include/edid.h b/include/edid.h new file mode 100644 index 0000000..4788de9 --- /dev/null +++ b/include/edid.h @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2012 The Chromium OS Authors. + * + * (C) Copyright 2010 + * Petr Stetiar ynezz@true.cz + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * Contains stolen code from ddcprobe project which is: + * Copyright (C) Nalin Dahyabhai bigfun@pobox.com + * + */ + +#ifndef __EDID_H_ +#define __EDID_H_ + +#include <linux/types.h> + +#define GET_BIT(_x, _pos) \ + (((_x) >> (_pos)) & 1) +#define GET_BITS(_x, _pos_msb, _pos_lsb) \ + (((_x) >> (_pos_lsb)) & ((1 << ((_pos_msb) - (_pos_lsb) + 1)) - 1)) + +/* Aspect ratios used in EDID info. */ +enum edid_aspect { + ASPECT_625 = 0, + ASPECT_75, + ASPECT_8, + ASPECT_5625, +}; + +/* Detailed timing information used in EDID v1.x */ +struct edid_detailed_timing { + unsigned char pixel_clock[2]; +#define EDID_DETAILED_TIMING_PIXEL_CLOCK(_x) \ + (((((uint32_t)(_x).pixel_clock[1]) << 8) + \ + (_x).pixel_clock[0]) * 10000) + unsigned char horizontal_active; + unsigned char horizontal_blanking; + unsigned char horizontal_active_blanking_hi; +#define EDID_DETAILED_TIMING_HORIZONTAL_ACTIVE(_x) \ + ((GET_BITS((_x).horizontal_active_blanking_hi, 7, 4) << 8) + \ + (_x).horizontal_active) +#define EDID_DETAILED_TIMING_HORIZONTAL_BLANKING(_x) \ + ((GET_BITS((_x).horizontal_active_blanking_hi, 3, 0) << 8) + \ + (_x).horizontal_blanking) + unsigned char vertical_active; + unsigned char vertical_blanking; + unsigned char vertical_active_blanking_hi; +#define EDID_DETAILED_TIMING_VERTICAL_ACTIVE(_x) \ + ((GET_BITS((_x).vertical_active_blanking_hi, 7, 4) << 8) + \ + (_x).vertical_active) +#define EDID_DETAILED_TIMING_VERTICAL_BLANKING(_x) \ + ((GET_BITS((_x).vertical_active_blanking_hi, 3, 0) << 8) + \ + (_x).vertical_blanking) + unsigned char hsync_offset; + unsigned char hsync_pulse_width; + unsigned char sync_offset_pulse_width; + unsigned char hsync_vsync_offset_pulse_width_hi; +#define EDID_DETAILED_TIMING_HSYNC_OFFSET(_x) \ + ((GET_BITS((_x).hsync_vsync_offset_pulse_width_hi, 7, 6) << 8) + \ + (_x).hsync_offset) +#define EDID_DETAILED_TIMING_HSYNC_PULSE_WIDTH(_x) \ + ((GET_BITS((_x).hsync_vsync_offset_pulse_width_hi, 5, 4) << 8) + \ + (_x).hsync_pulse_width) +#define EDID_DETAILED_TIMING_VSYNC_OFFSET(_x) \ + ((GET_BITS((_x).hsync_vsync_offset_pulse_width_hi, 3, 2) << 4) + \ + GET_BITS((_x).vsync_offset_pulse_width, 7, 4)) +#define EDID_DETAILED_TIMING_VSYNC_PULSE_WIDTH(_x) \ + ((GET_BITS((_x).hsync_vsync_offset_pulse_width_hi, 1, 0) << 4) + \ + GET_BITS((_x).vsync_offset_pulse_width, 3, 0)) + unsigned char himage_size; + unsigned char vimage_size; + unsigned char himage_vimage_size_hi; +#define EDID_DETAILED_TIMING_HIMAGE_SIZE(_x) \ + ((GET_BITS((_x).himage_vimage_size_hi, 7, 4) << 8) + (_x).himage_size) +#define EDID_DETAILED_TIMING_VIMAGE_SIZE(_x) \ + ((GET_BITS((_x).himage_vimage_size_hi, 3, 0) << 8) + (_x).vimage_size) + unsigned char hborder; + unsigned char vborder; + unsigned char flags; +#define EDID_DETAILED_TIMING_FLAG_INTERLACED(_x) \ + GET_BIT((_x).flags, 7) +#define EDID_DETAILED_TIMING_FLAG_STEREO(_x) \ + GET_BITS((_x).flags, 6, 5) +#define EDID_DETAILED_TIMING_FLAG_DIGITAL_COMPOSITE(_x) \ + GET_BITS((_x).flags, 4, 3) +#define EDID_DETAILED_TIMING_FLAG_POLARITY(_x) \ + GET_BITS((_x).flags, 2, 1) +#define EDID_DETAILED_TIMING_FLAG_INTERLEAVED(_x) \ + GET_BIT((_x).flags, 0) +} __attribute__ ((__packed__)); + +enum edid_monitor_descriptor_types { + EDID_MONITOR_DESCRIPTOR_SERIAL = 0xff, + EDID_MONITOR_DESCRIPTOR_ASCII = 0xfe, + EDID_MONITOR_DESCRIPTOR_RANGE = 0xfd, + EDID_MONITOR_DESCRIPTOR_NAME = 0xfc, +}; + +struct edid_monitor_descriptor { + uint16_t zero_flag_1; + unsigned char zero_flag_2; + unsigned char type; + unsigned char zero_flag_3; + union { + char string[13]; + struct { + unsigned char vertical_min; + unsigned char vertical_max; + unsigned char horizontal_min; + unsigned char horizontal_max; + unsigned char pixel_clock_max; + unsigned char gtf_data[8]; + } range_data; + } data; +} __attribute__ ((__packed__)); + +struct edid1_info { + unsigned char header[8]; + unsigned char manufacturer_name[2]; +#define EDID1_INFO_MANUFACTURER_NAME_ZERO(_x) \ + GET_BIT(((_x).manufacturer_name[0]), 7) +#define EDID1_INFO_MANUFACTURER_NAME_CHAR1(_x) \ + GET_BITS(((_x).manufacturer_name[0]), 6, 2) +#define EDID1_INFO_MANUFACTURER_NAME_CHAR2(_x) \ + ((GET_BITS(((_x).manufacturer_name[0]), 1, 0) << 3) + \ + GET_BITS(((_x).manufacturer_name[1]), 7, 5)) +#define EDID1_INFO_MANUFACTURER_NAME_CHAR3(_x) \ + GET_BITS(((_x).manufacturer_name[1]), 4, 0) + unsigned char product_code[2]; +#define EDID1_INFO_PRODUCT_CODE(_x) \ + (((uint16_t)(_x).product_code[1] << 8) + (_x).product_code[0]) + unsigned char serial_number[4]; +#define EDID1_INFO_SERIAL_NUMBER(_x) \ + (((uint32_t)(_x).serial_number[3] << 24) + \ + ((_x).serial_number[2] << 16) + ((_x).serial_number[1] << 8) + \ + (_x).serial_number[0]) + unsigned char week; + unsigned char year; + unsigned char version; + unsigned char revision; + unsigned char video_input_definition; +#define EDID1_INFO_VIDEO_INPUT_DIGITAL(_x) \ + GET_BIT(((_x).video_input_definition), 7) +#define EDID1_INFO_VIDEO_INPUT_VOLTAGE_LEVEL(_x) \ + GET_BITS(((_x).video_input_definition), 6, 5) +#define EDID1_INFO_VIDEO_INPUT_BLANK_TO_BLACK(_x) \ + GET_BIT(((_x).video_input_definition), 4) +#define EDID1_INFO_VIDEO_INPUT_SEPARATE_SYNC(_x) \ + GET_BIT(((_x).video_input_definition), 3) +#define EDID1_INFO_VIDEO_INPUT_COMPOSITE_SYNC(_x) \ + GET_BIT(((_x).video_input_definition), 2) +#define EDID1_INFO_VIDEO_INPUT_SYNC_ON_GREEN(_x) \ + GET_BIT(((_x).video_input_definition), 1) +#define EDID1_INFO_VIDEO_INPUT_SERRATION_V(_x) \ + GET_BIT(((_x).video_input_definition), 0) + unsigned char max_size_horizontal; + unsigned char max_size_vertical; + unsigned char gamma; + unsigned char feature_support; +#define EDID1_INFO_FEATURE_STANDBY(_x) \ + GET_BIT(((_x).feature_support), 7) +#define EDID1_INFO_FEATURE_SUSPEND(_x) \ + GET_BIT(((_x).feature_support), 6) +#define EDID1_INFO_FEATURE_ACTIVE_OFF(_x) \ + GET_BIT(((_x).feature_support), 5) +#define EDID1_INFO_FEATURE_DISPLAY_TYPE(_x) \ + GET_BITS(((_x).feature_support), 4, 3) +#define EDID1_INFO_FEATURE_RGB(_x) \ + GET_BIT(((_x).feature_support), 2) +#define EDID1_INFO_FEATURE_PREFERRED_TIMING_MODE(_x) \ + GET_BIT(((_x).feature_support), 1) +#define EDID1_INFO_FEATURE_DEFAULT_GTF_SUPPORT(_x) \ + GET_BIT(((_x).feature_support), 0) + unsigned char color_characteristics[10]; + unsigned char established_timings[3]; +#define EDID1_INFO_ESTABLISHED_TIMING_720X400_70(_x) \ + GET_BIT(((_x).established_timings[0]), 7) +#define EDID1_INFO_ESTABLISHED_TIMING_720X400_88(_x) \ + GET_BIT(((_x).established_timings[0]), 6) +#define EDID1_INFO_ESTABLISHED_TIMING_640X480_60(_x) \ + GET_BIT(((_x).established_timings[0]), 5) +#define EDID1_INFO_ESTABLISHED_TIMING_640X480_67(_x) \ + GET_BIT(((_x).established_timings[0]), 4) +#define EDID1_INFO_ESTABLISHED_TIMING_640X480_72(_x) \ + GET_BIT(((_x).established_timings[0]), 3) +#define EDID1_INFO_ESTABLISHED_TIMING_640X480_75(_x) \ + GET_BIT(((_x).established_timings[0]), 2) +#define EDID1_INFO_ESTABLISHED_TIMING_800X600_56(_x) \ + GET_BIT(((_x).established_timings[0]), 1) +#define EDID1_INFO_ESTABLISHED_TIMING_800X600_60(_x) \ + GET_BIT(((_x).established_timings[0]), 0) +#define EDID1_INFO_ESTABLISHED_TIMING_800X600_72(_x) \ + GET_BIT(((_x).established_timings[1]), 7) +#define EDID1_INFO_ESTABLISHED_TIMING_800X600_75(_x) \ + GET_BIT(((_x).established_timings[1]), 6) +#define EDID1_INFO_ESTABLISHED_TIMING_832X624_75(_x) \ + GET_BIT(((_x).established_timings[1]), 5) +#define EDID1_INFO_ESTABLISHED_TIMING_1024X768_87I(_x) \ + GET_BIT(((_x).established_timings[1]), 4) +#define EDID1_INFO_ESTABLISHED_TIMING_1024X768_60(_x) \ + GET_BIT(((_x).established_timings[1]), 3) +#define EDID1_INFO_ESTABLISHED_TIMING_1024X768_70(_x) \ + GET_BIT(((_x).established_timings[1]), 2) +#define EDID1_INFO_ESTABLISHED_TIMING_1024X768_75(_x) \ + GET_BIT(((_x).established_timings[1]), 1) +#define EDID1_INFO_ESTABLISHED_TIMING_1280X1024_75(_x) \ + GET_BIT(((_x).established_timings[1]), 0) +#define EDID1_INFO_ESTABLISHED_TIMING_1152X870_75(_x) \ + GET_BIT(((_x).established_timings[2]), 7) + struct { + unsigned char xresolution; + unsigned char aspect_vfreq; + } __attribute__((__packed__)) standard_timings[8]; +#define EDID1_INFO_STANDARD_TIMING_XRESOLUTION(_x, _i) \ + (((_x).standard_timings[_i]).xresolution) +#define EDID1_INFO_STANDARD_TIMING_ASPECT(_x, _i) \ + GET_BITS(((_x).standard_timings[_i].aspect_vfreq), 7, 6) +#define EDID1_INFO_STANDARD_TIMING_VFREQ(_x, _i) \ + GET_BITS(((_x).standard_timings[_i].aspect_vfreq), 5, 0) + union { + unsigned char timing[72]; + struct edid_monitor_descriptor descriptor[4]; + } monitor_details; + unsigned char extension_flag; + unsigned char checksum; +} __attribute__ ((__packed__)); + +/** + * Print the EDID info. + * + * @param edid_info The EDID info to be printed + */ +void edid_print_info(struct edid1_info *edid_info); + +/** + * Check the EDID info. + * + * @param info The EDID info to be checked + * @return 0 on valid, or -1 on invalid + */ +int edid_check_info(struct edid1_info *info); + +/** + * Get the horizontal and vertical rate ranges of the monitor. + * + * @param edid The EDID info + * @param hmin Returns the minimum horizontal rate + * @param hmax Returns the maxium horizontal rate + * @param vmin Returns the minimum vertical rate + * @param vmax Returns the maxium vertical rate + * @return 0 on success, or -1 on error + */ +int edid_get_ranges(struct edid1_info *edid, unsigned int *hmin, + unsigned int *hmax, unsigned int *vmin, + unsigned int *vmax); + +#endif /* __EDID_H_ */

From: Tom Wai-Hong Tam waihong@chromium.org
Add a single command to read the EDID information over I2C.
For example:
SMDK5250 # i2c dev 7 Setting bus to 7 SMDK5250 # i2c edid 50 EDID version: 1.4 Product ID code: 305c Manufacturer: AUO Serial number: 00000000 Manufactured in week: 0 year: 2011 Video input definition: digital signal, voltage level 0, blank to black Monitor is non-RGB Maximum visible display size: 26 cm x 14 cm Power management features: no active off, no suspend, no standby Estabilished timings: Standard timings: 1366x768 60 Hz (detailed) 1366x768 60 Hz (detailed) Monitor ID: 2VD2K.B116XW
Signed-off-by: Tom Wai-Hong Tam waihong@chromium.org Signed-off-by: Sean Paul seanpaul@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- README | 7 +++++++ common/cmd_i2c.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 0 deletions(-)
diff --git a/README b/README index 31e25fe..daa95cb 100644 --- a/README +++ b/README @@ -1465,6 +1465,13 @@ CBFS (Coreboot Filesystem) support Normally display is black on white background; define CONFIG_SYS_WHITE_ON_BLACK to get it inverted.
+ + CONFIG_I2C_EDI + + Enables an 'i2c edid' command which can read EDID + information over I2C from an attached LCD display. + + - Splash Screen Support: CONFIG_SPLASH_SCREEN
If this option is set, the environment is checked for diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 82e63e1..e7f7b55 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -78,6 +78,7 @@
#include <common.h> #include <command.h> +#include <edid.h> #include <environment.h> #include <i2c.h> #include <malloc.h> @@ -1246,6 +1247,38 @@ static int do_sdram (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) } #endif
+/* + * Syntax: + * i2c edid {i2c_chip} + */ +#if defined(CONFIG_I2C_EDID) +int do_edid(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + u_char chip; + struct edid1_info edid; + + if (argc < 2) { + cmd_usage(cmdtp); + return 1; + } + + chip = simple_strtoul(argv[1], NULL, 16); + if (i2c_read(chip, 0, 1, (uchar *)&edid, sizeof(edid)) != 0) { + puts("Error reading EDID content.\n"); + return 1; + } + + if (edid_check_info(&edid)) { + puts("Content isn't valid EDID.\n"); + return 1; + } + + edid_print_info(&edid); + return 0; + +} +#endif /* CONFIG_I2C_EDID */ + #if defined(CONFIG_I2C_MUX) static int do_i2c_add_bus(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) { @@ -1335,6 +1368,9 @@ static cmd_tbl_t cmd_i2c_sub[] = { #if defined(CONFIG_I2C_MULTI_BUS) U_BOOT_CMD_MKENT(dev, 1, 1, do_i2c_bus_num, "", ""), #endif /* CONFIG_I2C_MULTI_BUS */ +#if defined(CONFIG_I2C_EDID) + U_BOOT_CMD_MKENT(edid, 1, 1, do_edid, "", ""), +#endif /* CONFIG_I2C_EDID */ U_BOOT_CMD_MKENT(loop, 3, 1, do_i2c_loop, "", ""), U_BOOT_CMD_MKENT(md, 3, 1, do_i2c_md, "", ""), U_BOOT_CMD_MKENT(mm, 2, 1, do_i2c_mm, "", ""), @@ -1387,6 +1423,9 @@ U_BOOT_CMD( #if defined(CONFIG_I2C_MULTI_BUS) "i2c dev [dev] - show or set current I2C bus\n" #endif /* CONFIG_I2C_MULTI_BUS */ +#if defined(CONFIG_I2C_EDID) + "i2c edid chip - print EDID configuration information\n" +#endif /* CONFIG_I2C_EDID */ "i2c loop chip address[.0, .1, .2] [# of objects] - looping read of device\n" "i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device\n" "i2c mm chip address[.0, .1, .2] - write to I2C device (auto-incrementing)\n"

From: Tom Wai-Hong Tam waihong@chromium.org
This function can be used for LCDs as well as monitors.
Signed-off-by: Tom Wai-Hong Tam waihong@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- common/fdt_support.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c index 963ea90..6b9fa05 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1315,7 +1315,7 @@ int fdt_set_status_by_alias(void *fdt, const char* alias, return fdt_set_node_status(fdt, offset, status, error_code); }
-#if defined(CONFIG_VIDEO) +#if defined(CONFIG_VIDEO) || defined(CONFIG_LCD) int fdt_add_edid(void *blob, const char *compat, unsigned char *edid_buf) { int noff;

From: Taylor Hutt thutt@chromium.org
If a malformed 'read' or 'write' command is issued, the Sandbox U-Boot can crash because the command-handling code does no error checking on the number of provided arguments.
This change makes the mmc 'erase', 'read' and 'write' commands only function if the proper number of arguments are supplied.
Also puts the else assignment at the beginning fo the if() statement to shortens the generated code. This removes an unnecessary jump from the generated code.
BRANCH=none Signed-off-by: Taylor Hutt thutt@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- common/cmd_mmc.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 79a1088..735947b 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -250,14 +250,13 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; }
- if (strcmp(argv[1], "read") == 0) + state = MMC_INVALID; + if (argc == 5 && strcmp(argv[1], "read") == 0) state = MMC_READ; - else if (strcmp(argv[1], "write") == 0) + else if (argc == 5 && strcmp(argv[1], "write") == 0) state = MMC_WRITE; - else if (strcmp(argv[1], "erase") == 0) + else if (argc == 4 && strcmp(argv[1], "erase") == 0) state = MMC_ERASE; - else - state = MMC_INVALID;
if (state != MMC_INVALID) { struct mmc *mmc = find_mmc_device(curr_device);

From: Anton Staaf robotboy@chromium.org
Move the overwrite_console function call to before the search for the console devices. This lets the board specific function replace the environment variables and have that picked up by the console code.
Signed-off-by: Simon Glass sjg@chromium.org --- common/console.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/common/console.c b/common/console.c index 1177f7d..831897b 100644 --- a/common/console.c +++ b/common/console.c @@ -1,4 +1,6 @@ /* + * Copyright (c) 2009, Code Aurora Forum. All rights reserved. + * * (C) Copyright 2000 * Paolo Scaffardi, AIRVENT SAM s.p.a - RIMINI(ITALY), arsenio@tin.it * @@ -622,6 +624,7 @@ int console_init_r(void) { char *stdinname, *stdoutname, *stderrname; struct stdio_dev *inputdev = NULL, *outputdev = NULL, *errdev = NULL; + int overwrite_console_retval; #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE int i; #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */ @@ -636,13 +639,19 @@ int console_init_r(void) gd->jt[XF_puts] = serial_puts; gd->jt[XF_printf] = serial_printf;
- /* stdin stdout and stderr are in environment */ - /* scan for it */ + /* + * stdin stdout and stderr are in environment. + * Call OVERWRITE_CONSOLE function before scanning for stdio, stdout, + * stderr to get latest pointer after update. + * (getenv() returns NULL if var not present) + */ + overwrite_console_retval = OVERWRITE_CONSOLE; stdinname = getenv("stdin"); stdoutname = getenv("stdout"); stderrname = getenv("stderr");
- if (OVERWRITE_CONSOLE == 0) { /* if not overwritten by config switch */ + /* if not overwritten by config switch */ + if (overwrite_console_retval == 0) { inputdev = search_device(DEV_FLAGS_INPUT, stdinname); outputdev = search_device(DEV_FLAGS_OUTPUT, stdoutname); errdev = search_device(DEV_FLAGS_OUTPUT, stderrname);

Dear Simon Glass,
In message 1351902453-27956-15-git-send-email-sjg@chromium.org you wrote:
From: Anton Staaf robotboy@chromium.org
Move the overwrite_console function call to before the search for the console devices. This lets the board specific function replace the environment variables and have that picked up by the console code.
Can you please explain what "replace the environment variables" means, and how this is related to the console code?
Or what exactly this patch is needed for?
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:32 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-15-git-send-email-sjg@chromium.org you wrote:
From: Anton Staaf robotboy@chromium.org
Move the overwrite_console function call to before the search for the console devices. This lets the board specific function replace the environment variables and have that picked up by the console code.
Can you please explain what "replace the environment variables" means, and how this is related to the console code?
It allows the environment variables (e.g. stdin) to be changed by the overwrite_console function call.
I have had another look at this, and I believe that Allen Warren's patch last week for Tegra does a similar thing:
http://patchwork.ozlabs.org/patch/196412/
So I think we can drop this patch.
Regards, Simon
Or what exactly this patch is needed for?
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Mike's Law: For a lumber company employing two men and a cut-off saw, the marginal product of labor for any number of additional workers equals zero until the acquisition of another cut-off saw. Let's not even consider a chainsaw.
- Mike Dennison [You could always schedule the saw, though - ed.]

Dear Simon,
In message CAPnjgZ1mmjh7xD3ZAqznjfGE2UVG_KM1j0pwF4xsL3pRY23f6Q@mail.gmail.com you wrote:
Move the overwrite_console function call to before the search for the console devices. This lets the board specific function replace the environment variables and have that picked up by the console code.
Can you please explain what "replace the environment variables" means, and how this is related to the console code?
It allows the environment variables (e.g. stdin) to be changed by the overwrite_console function call.
Ah! I feared that would be some other way to reset / change / overwrite the _whole_ environment - "the environment variables" is not really specific.
So I think we can drop this patch.
Fine.
Best regards,
Wolfgang Denk

From: Vadim Bendebury vbendeb@chromium.org
Provide u-boot console functions to access IO space registers. A no thrills implementation, accessing one register at a time.
For example: boot > iod 80 0080: 00000094 boot > iod.w 80 0080: 0094 boot > iod.b 80 0080: 94 boot > iow.b 0x80 12 boot > iod 0x80 0080: 00000012
Signed-off-by: Vadim Bendebury vbendeb@chromium.org Signed-off-by: Simon Glass sjg@chromium.org --- common/Makefile | 1 + common/cmd_io.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++ include/command.h | 8 ++-- include/config_cmd_all.h | 2 + 4 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 common/cmd_io.c
diff --git a/common/Makefile b/common/Makefile index eac38fc..d8cdca1 100644 --- a/common/Makefile +++ b/common/Makefile @@ -119,6 +119,7 @@ COBJS-$(CONFIG_LOGBUFFER) += cmd_log.o COBJS-$(CONFIG_ID_EEPROM) += cmd_mac.o COBJS-$(CONFIG_CMD_MD5SUM) += cmd_md5sum.o COBJS-$(CONFIG_CMD_MEMORY) += cmd_mem.o +COBJS-$(CONFIG_CMD_IO) += cmd_io.o COBJS-$(CONFIG_CMD_MFSL) += cmd_mfsl.o COBJS-$(CONFIG_MII) += miiphyutil.o COBJS-$(CONFIG_CMD_MII) += miiphyutil.o diff --git a/common/cmd_io.c b/common/cmd_io.c new file mode 100644 index 0000000..6450cb5 --- /dev/null +++ b/common/cmd_io.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2012 The Chromium OS Authors. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * IO space access commands. + */ + +#include <common.h> +#include <command.h> +#include <asm/io.h> + +/* + * IO Display + * + * Syntax: + * iod{.b, .w, .l} {addr} + */ +int do_io_iod(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + ulong addr; + int size; + + if (argc != 2) + return CMD_RET_USAGE; + + size = cmd_get_data_size(argv[0], 4); + if (size < 0) + return 1; + + addr = simple_strtoul(argv[1], NULL, 16); + + printf("%04x: ", (u16) addr); + + if (size == 4) + printf("%08x\n", inl(addr)); + else if (size == 2) + printf("%04x\n", inw(addr)); + else + printf("%02x\n", inb(addr)); + + return 0; +} + +int do_io_iow(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) +{ + ulong addr, size, val; + + if (argc != 3) + return CMD_RET_USAGE; + + size = cmd_get_data_size(argv[0], 4); + if (size < 0) + return 1; + + addr = simple_strtoul(argv[1], NULL, 16); + val = simple_strtoul(argv[2], NULL, 16); + + if (size == 4) + outl((u32) val, addr); + else if (size == 2) + outw((u16) val, addr); + else + outb((u8) val, addr); + + return 0; +} + +/**************************************************/ +U_BOOT_CMD(iod, 2, 0, do_io_iod, + "IO space display", "[.b, .w, .l] address [# of objects]"); + +U_BOOT_CMD(iow, 3, 0, do_io_iow, + "IO space modify (auto-incrementing address)", + "[.b, .w, .l] address"); diff --git a/include/command.h b/include/command.h index 10bc260..476e7cf 100644 --- a/include/command.h +++ b/include/command.h @@ -89,10 +89,10 @@ extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int * */
#if defined(CONFIG_CMD_MEMORY) \ - || defined(CONFIG_CMD_I2C) \ - || defined(CONFIG_CMD_ITEST) \ - || defined(CONFIG_CMD_PCI) \ - || defined(CONFIG_CMD_PORTIO) + || defined(CONFIG_CMD_I2C) \ + || defined(CONFIG_CMD_ITEST) \ + || defined(CONFIG_CMD_PCI) \ + || defined(CONFIG_CMD_PORTIO) #define CMD_DATA_SIZE extern int cmd_get_data_size(char* arg, int default_size); #endif diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index efd17e6..500b5cd 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -42,11 +42,13 @@ #define CONFIG_CMD_FPGA /* FPGA configuration Support */ #define CONFIG_CMD_GETTIME /* Get time since boot */ #define CONFIG_CMD_HWFLOW /* RTS/CTS hw flow control */ +#define CONFIG_CMD_IO /* Command to access IO ports */ #define CONFIG_CMD_I2C /* I2C serial bus support */ #define CONFIG_CMD_IDE /* IDE harddisk support */ #define CONFIG_CMD_IMI /* iminfo */ #define CONFIG_CMD_IMLS /* List all found images */ #define CONFIG_CMD_IMMAP /* IMMR dump support */ +#define CONFIG_CMD_IO /* Access to X86 IO space */ #define CONFIG_CMD_IRQ /* irqinfo */ #define CONFIG_CMD_ITEST /* Integer (and string) test */ #define CONFIG_CMD_JFFS2 /* JFFS2 Support */

Dear Simon Glass,
In message 1351902453-27956-16-git-send-email-sjg@chromium.org you wrote:
From: Vadim Bendebury vbendeb@chromium.org
Provide u-boot console functions to access IO space registers. A no thrills implementation, accessing one register at a time.
For example: boot > iod 80 0080: 00000094 boot > iod.w 80 0080: 0094 boot > iod.b 80 0080: 94 boot > iow.b 0x80 12 boot > iod 0x80 0080: 00000012
What are the exact use cases where this is necessary, i. e. where plain md / mw does not work?
Best regards,
Wolfgang Denk

On Sat, Nov 3, 2012 at 8:26 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-16-git-send-email-sjg@chromium.org you wrote:
From: Vadim Bendebury vbendeb@chromium.org
Provide u-boot console functions to access IO space registers. A no thrills implementation, accessing one register at a time.
For example: boot > iod 80 0080: 00000094 boot > iod.w 80 0080: 0094 boot > iod.b 80 0080: 94 boot > iow.b 0x80 12 boot > iod 0x80 0080: 00000012
What are the exact use cases where this is necessary, i. e. where plain md / mw does not work?
Wolfgang,
the x86 architecture defines this different kind of address space, device IO, in addition to memory address space. This is a remnant of the days when address lines were sparse.
On typical x86 systems devices are accessed through this device IO space, and this patch adds a command which allows the operator to read and write device registers on such systems.
Cheers, /vb
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Quantum particles: The dreams that stuff is made of. _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

The CONFIG_SYS_CONSOLE_INFO_QUIET option should suppress the console information, but allow boards to display it later if required. Adjust the code to support this.
This is used to avoid printing the information while the LCD display is not ready, since it only becomes ready when stdio init is complete.
BRANCH=snow Signed-off-by: Simon Glass sjg@chromium.org --- common/console.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/common/console.c b/common/console.c index 831897b..d3bbc26 100644 --- a/common/console.c +++ b/common/console.c @@ -593,7 +593,6 @@ int console_init_f(void)
void stdio_print_current_devices(void) { -#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET /* Print information */ puts("In: "); if (stdio_devices[stdin] == NULL) { @@ -615,7 +614,6 @@ void stdio_print_current_devices(void) } else { printf ("%s\n", stdio_devices[stderr]->name); } -#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */ }
#ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV @@ -694,7 +692,9 @@ done:
gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
+#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET stdio_print_current_devices(); +#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
#ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE /* set the environment variables (will overwrite previous env settings) */ @@ -769,7 +769,9 @@ int console_init_r(void)
gd->flags |= GD_FLG_DEVINIT; /* device initialization completed */
+#ifndef CONFIG_SYS_CONSOLE_INFO_QUIET stdio_print_current_devices(); +#endif /* CONFIG_SYS_CONSOLE_INFO_QUIET */
/* Setting environment variables */ for (i = 0; i < 3; i++) {

Dear Simon Glass,
In message 1351902453-27956-17-git-send-email-sjg@chromium.org you wrote:
The CONFIG_SYS_CONSOLE_INFO_QUIET option should suppress the console information, but allow boards to display it later if required. Adjust the code to support this.
This is used to avoid printing the information while the LCD display is not ready, since it only becomes ready when stdio init is complete.
BRANCH=snow
Please get such comments out of the commit messages.
Signed-off-by: Simon Glass sjg@chromium.org
common/console.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
This is broken. You miss the fact that stdio_print_current_devices() gets called in a number of other places as well (you should have asked yourself why it isn't a static function). See at least board/mpl/mip405/mip405.c
Best regards,
Wolfgang Denk

HI Wolfgang,
On Sat, Nov 3, 2012 at 8:15 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-17-git-send-email-sjg@chromium.org you wrote:
The CONFIG_SYS_CONSOLE_INFO_QUIET option should suppress the console information, but allow boards to display it later if required. Adjust the code to support this.
This is used to avoid printing the information while the LCD display is not ready, since it only becomes ready when stdio init is complete.
BRANCH=snow
Please get such comments out of the commit messages.
Yes done, Tom has merged the patman patch for this.
Signed-off-by: Simon Glass sjg@chromium.org
common/console.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
This is broken. You miss the fact that stdio_print_current_devices() gets called in a number of other places as well (you should have asked yourself why it isn't a static function). See at least board/mpl/mip405/mip405.c
Yes I realise that, but why would a board specifically call stdio_print_current_devices() if the board's config has defined CONFIG_SYS_CONSOLE_INFO_QUIET?
It seems to me that if we want to print it, we should be able to call the function to do so, and that the option is only there to stop the generic code from printing it when we don't want it.
The README says only:
- CONFIG_SYS_CONSOLE_INFO_QUIET Suppress display of console information at boot.
Or do I misunderstand this?
Regards, Simon
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de "In matrimony, to hesitate is sometimes to be saved." - Butler

From: Luigi Semenzato semenzato@chromium.org
Add a simple command to stress-test a TPM (Trusted Platform Module).
Signed-off-by: Luigi Semenzato semenzato@chromium.org
Commit-Ready: Stefan Reinauer reinauer@google.com Signed-off-by: Simon Glass sjg@chromium.org --- common/cmd_tpm.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 87 insertions(+), 6 deletions(-)
diff --git a/common/cmd_tpm.c b/common/cmd_tpm.c index 6f5cd48..0970a6f 100644 --- a/common/cmd_tpm.c +++ b/common/cmd_tpm.c @@ -63,19 +63,68 @@ static int tpm_process(int argc, char * const argv[], cmd_tbl_t *cmdtp) return rv; }
-static int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +#define CHECK(exp) do { \ + int _rv = exp; \ + if (_rv) { \ + printf("CHECK: %s %d %x\n", #exp, __LINE__, _rv);\ + } \ + } while (0) + +static int tpm_process_stress(int repeat_count) { + int i; int rv = 0; + u8 request[] = {0x0, 0xc1, + 0x0, 0x0, 0x0, 0x16, + 0x0, 0x0, 0x0, 0x65, + 0x0, 0x0, 0x0, 0x4, + 0x0, 0x0, 0x0, 0x4, + 0x0, 0x0, 0x1, 0x9}; + u8 response[MAX_TRANSACTION_SIZE]; + u32 rlength = MAX_TRANSACTION_SIZE; + + CHECK(tis_init()); + + for (i = 0; i < repeat_count; i++) { + CHECK(tis_open()); + rv = tis_sendrecv(request, sizeof(request), response, &rlength); + if (rv) { + printf("tpm test failed at step %d with 0x%x\n", i, rv); + CHECK(tis_close()); + break; + } + CHECK(tis_close()); + if ((response[6] || response[7] || response[8] || response[9]) + && response[9] != 0x26) { + /* Ignore postinit errors */ + printf("tpm command failed at step %d\n" + "tpm error code: %02x%02x%02x%02x\n", i, + response[6], response[7], + response[8], response[9]); + rv = -1; + break; + } + } + return rv; +}
- /* - * Verify that in case it is present, the first argument, it is - * exactly one character in size. - */ - if (argc < 7) { + +static int do_tpm_many(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[], int repeat_count) + +{ + int rv = 0; + + if (argc < 7 && repeat_count == 0) { puts("command should be at least six bytes in size\n"); return -1; }
+ if (repeat_count > 0) { + rv = tpm_process_stress(repeat_count); + return rv; + } + if (tis_init()) { puts("tis_init() failed!\n"); return -1; @@ -96,8 +145,40 @@ static int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return rv; }
+ +static int do_tpm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + return do_tpm_many(cmdtp, flag, argc, argv, 0); +} + + U_BOOT_CMD(tpm, MAX_TRANSACTION_SIZE, 1, do_tpm, "<byte> [<byte> ...] - write data and read response", "send arbitrary data (at least 6 bytes) to the TPM " "device and read the response" ); + +static int do_tpm_stress(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + long unsigned int n; + int rv; + + if (argc != 2) { + puts("usage: tpm_stress <count>\n"); + return -1; + } + + rv = strict_strtoul(argv[1], 10, &n); + if (rv) { + puts("tpm_stress: bad count"); + return -1; + } + + return do_tpm_many(cmdtp, flag, argc, argv, n); +} + +U_BOOT_CMD(tpm_stress, 2, 1, do_tpm_stress, + "<n> - stress-test communication with TPM", + "Repeat a TPM transaction (request-response) N times" +);

Dear Simon Glass,
In message 1351902453-27956-18-git-send-email-sjg@chromium.org you wrote:
From: Luigi Semenzato semenzato@chromium.org
Add a simple command to stress-test a TPM (Trusted Platform Module).
Signed-off-by: Luigi Semenzato semenzato@chromium.org
Commit-Ready: Stefan Reinauer reinauer@google.com Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_tpm.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 87 insertions(+), 6 deletions(-)
See previous comments about TPM code. Please let's dump all this unused stuff.
Best regards,
Wolfgang Denk

Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:29 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-18-git-send-email-sjg@chromium.org you wrote:
From: Luigi Semenzato semenzato@chromium.org
Add a simple command to stress-test a TPM (Trusted Platform Module).
Signed-off-by: Luigi Semenzato semenzato@chromium.org
Commit-Ready: Stefan Reinauer reinauer@google.com Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_tpm.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 87 insertions(+), 6 deletions(-)
See previous comments about TPM code. Please let's dump all this unused stuff.
As mentioned, patches are pending to enable this for two boards (ARM and x86).
Regards, Simon
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de "You'll pay to know what you really think." - J.R. "Bob" Dobbs

Dear Simon Glass,
Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:29 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-18-git-send-email-sjg@chromium.org you wrote:
From: Luigi Semenzato semenzato@chromium.org
Add a simple command to stress-test a TPM (Trusted Platform Module).
Signed-off-by: Luigi Semenzato semenzato@chromium.org
Commit-Ready: Stefan Reinauer reinauer@google.com Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_tpm.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 87 insertions(+), 6 deletions(-)
See previous comments about TPM code. Please let's dump all this unused stuff.
As mentioned, patches are pending to enable this for two boards (ARM and x86).
Hm, does this TPM argument still go on?
Actually, my position is I'd be all for dumping it right away (I even posted a patch some time ago), if it wasn't for SJG posting patches adding another TPM chip. Moreover, now I see there are patches for cmd_tpm.c . So I see a lot of effort invested into doing the TPM right.
What is the actual problem with keeping this code in our codebase and patching it then? It's all used now, problem solved, or am I missing something?
Best regards, Marek Vasut

Hi,
On Mon, Nov 19, 2012 at 3:50 PM, Marek Vasut marex@denx.de wrote:
Dear Simon Glass,
Hi Wolfgang,
On Sat, Nov 3, 2012 at 8:29 AM, Wolfgang Denk wd@denx.de wrote:
Dear Simon Glass,
In message 1351902453-27956-18-git-send-email-sjg@chromium.org you wrote:
From: Luigi Semenzato semenzato@chromium.org
Add a simple command to stress-test a TPM (Trusted Platform Module).
Signed-off-by: Luigi Semenzato semenzato@chromium.org
Commit-Ready: Stefan Reinauer reinauer@google.com Signed-off-by: Simon Glass sjg@chromium.org
common/cmd_tpm.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 87 insertions(+), 6 deletions(-)
See previous comments about TPM code. Please let's dump all this unused stuff.
As mentioned, patches are pending to enable this for two boards (ARM and x86).
Hm, does this TPM argument still go on?
Actually, my position is I'd be all for dumping it right away (I even posted a patch some time ago), if it wasn't for SJG posting patches adding another TPM chip. Moreover, now I see there are patches for cmd_tpm.c . So I see a lot of effort invested into doing the TPM right.
What is the actual problem with keeping this code in our codebase and patching it then? It's all used now, problem solved, or am I missing something?
Yes there has been quite a bit of effort on this. I hope we can keep this code, and perhaps even others way wish to help. I am looking at how to create a very simple kernel verification method based around a FIT image.
Best regards, Marek Vasut
Regards, Simon

Dear Simon Glass,
[...]
What is the actual problem with keeping this code in our codebase and patching it then? It's all used now, problem solved, or am I missing something?
Yes there has been quite a bit of effort on this. I hope we can keep this code, and perhaps even others way wish to help.
I'm not sure how many others have any interest in the TPM, it's chromebook-only thing so far ;-)
I am looking at how to create a very simple kernel verification method based around a FIT image.
I'd say all in due time. I'd say start a new thread about this and properly discuss it before implementing.
Best regards, Marek Vasut

Dear Simon,
In message CAPnjgZ1aa+ro+H1Ci1M5GUqJoK-VTrS_oKSMbGs4sWiNZZmBzA@mail.gmail.com you wrote:
Yes there has been quite a bit of effort on this. I hope we can keep this code, and perhaps even others way wish to help. I am looking at how to create a very simple kernel verification method based around a FIT image.
So far, and even after all our discussions, these are but announcements and half-baked promises. But there isno real progress visible in mainline code. Yes, there are bits and pieces thrown at us, but they are not really useful in mainline - you argument "not yet", but my statement is as long as such code is not ready, we should not bother adding it here. And especially I do not want to see this dead body grow even more.
Best regards,
Wolfgang Denk
participants (5)
-
Luka Perkov
-
Marek Vasut
-
Simon Glass
-
Vadim Bendebury
-
Wolfgang Denk