[coreboot-gerrit] Patch set updated for coreboot: bfff404 ec/lenovo/h8: Add h8_build_id_and_function_spec_version()

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Mon Dec 2 20:04:02 CET 2013


Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3617

-gerrit

commit bfff4045b664828bac1c8890c98e5141f8cdbb8b
Author: Peter Stuge <peter at stuge.se>
Date:   Sat Jul 6 19:44:47 2013 +0200

    ec/lenovo/h8: Add h8_build_id_and_function_spec_version()
    
    The function reads the Build ID and the supported function specification
    version from the running EC firmware, and stores a text representation
    in the provided output buffer.
    
    Change-Id: I3b647d7f315c9b4922fa9a9c5167a80f6d82e753
    Signed-off-by: Peter Stuge <peter at stuge.se>
---
 src/ec/lenovo/h8/h8.c | 38 +++++++++++++++++++++++++++++---------
 src/ec/lenovo/h8/h8.h |  1 +
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c
index af2aab3..0d1a32d 100644
--- a/src/ec/lenovo/h8/h8.c
+++ b/src/ec/lenovo/h8/h8.c
@@ -26,6 +26,7 @@
 #include "h8.h"
 #include "chip.h"
 #include <pc80/mc146818rtc.h>
+#include <string.h>
 #include <kconfig.h>
 
 #if IS_ENABLED (CONFIG_BOARD_LENOVO_X201)
@@ -57,17 +58,12 @@ void h8_wlan_enable(int on)
 
 static void h8_log_ec_version(void)
 {
-	unsigned char ecfw[9], c;
+	char ecfw[17];
+	u8 len;
 	u16 fwvh, fwvl;
-	int i;
 
-	for(i = 0; i < 8; i++) {
-		c = ec_read(0xf0 + i);
-		if (c < 0x20 || c > 0x7f)
-			break;
-		ecfw[i] = c;
-	}
-	ecfw[i] = '\0';
+	len = h8_build_id_and_function_spec_version(ecfw, sizeof ecfw - 1);
+	ecfw[len] = 0;
 
 	fwvh = ec_read(0xe9);
 	fwvl = ec_read(0xe8);
@@ -114,6 +110,30 @@ int h8_ultrabay_device_present(void)
 	return ec_read(H8_STATUS1) & 0x5 ? 0 : 1;
 }
 
+u8 h8_build_id_and_function_spec_version(char *buf, u8 buf_len)
+{
+	u8 i, c;
+	char str[16 + 1]; /* 16 ASCII chars + \0 */
+
+	/* Build ID */
+	for (i = 0; i < 8; i++) {
+		c = ec_read(0xf0 + i);
+		if (c < 0x20 || c > 0x7f) {
+			i = sprintf(str, "*INVALID");
+			break;
+		}
+		str[i] = c;
+	}
+
+	/* EC firmware function specification version */
+	i += sprintf(str + i, "-%u.%u", ec_read(0xef), ec_read(0xeb));
+
+	i = MIN(buf_len, i);
+	memcpy(buf, str, i);
+
+	return i;
+}
+
 static void h8_enable(device_t dev)
 {
 	struct ec_lenovo_h8_config *conf = dev->chip_info;
diff --git a/src/ec/lenovo/h8/h8.h b/src/ec/lenovo/h8/h8.h
index 7379fc7..061a213 100644
--- a/src/ec/lenovo/h8/h8.h
+++ b/src/ec/lenovo/h8/h8.h
@@ -27,6 +27,7 @@ void h8_usb_power_enable(int on);
 void h8_enable_event(int event);
 void h8_disable_event(int event);
 int h8_ultrabay_device_present(void);
+u8 h8_build_id_and_function_spec_version(char *buf, u8 buf_len);
 
 /* EC registers */
 #define H8_CONFIG0 0x00



More information about the coreboot-gerrit mailing list