[coreboot-gerrit] Patch set updated for coreboot: 1d7e8c7 ec/google: Move plug-n-play initialization to LPC protocol.

Hung-Te Lin (hungte@chromium.org) gerrit at coreboot.org
Mon Apr 15 13:38:25 CEST 2013


Hung-Te Lin (hungte at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3089

-gerrit

commit 1d7e8c7bdc083aef02755509fa90f8c0b67af174
Author: Hung-Te Lin <hungte at chromium.org>
Date:   Mon Apr 15 18:06:32 2013 +0800

    ec/google: Move plug-n-play initialization to LPC protocol.
    
    "Plug-n-play" is not supported on all platforms using Google's Chrome EC.
    For example, EC on I2C bus will need explicit configuration and initialization.
    So move the plug-n-play initialization to the LPC implementation.
    
    Verified by building Google/Link (with EC/LPC) successfully.
    
    Change-Id: I49e5943503fd5301aa2b2f8c1265f3813719d7e3
    Signed-off-by: Hung-Te Lin <hungte at chromium.org>
---
 src/ec/google/chromeec/ec.c     | 56 +++++++----------------------------------
 src/ec/google/chromeec/ec.h     |  1 +
 src/ec/google/chromeec/ec_lpc.c | 49 ++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 47 deletions(-)

diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c
index d830529..42115be 100644
--- a/src/ec/google/chromeec/ec.c
+++ b/src/ec/google/chromeec/ec.c
@@ -21,7 +21,6 @@
 #include <console/console.h>
 #include <arch/io.h>
 #include <delay.h>
-#include <device/pnp.h>
 #ifndef __PRE_RAM__
 #include <elog.h>
 #include <stdlib.h>
@@ -235,26 +234,20 @@ int google_chromeec_hello(void)
 
 static int ec_image_type; /* Cached EC image type (ro or rw). */
 
-static void google_chromeec_init(device_t dev)
+void google_chromeec_init(void)
 {
 	struct chromeec_command cec_cmd;
-	struct ec_google_chromeec_config *conf = dev->chip_info;
-	struct ec_response_get_version lpcv_cmd;
-
-	if (!dev->enabled)
-		return;
+	struct ec_response_get_version cec_resp = {{0}};
 
 	printk(BIOS_DEBUG, "Google Chrome EC: Initializing keyboard.\n");
-	pc_keyboard_init(&conf->keyboard);
 
 	google_chromeec_hello();
 
-	memset(&lpcv_cmd, 0, sizeof(lpcv_cmd));
 	cec_cmd.cmd_code = EC_CMD_GET_VERSION;
 	cec_cmd.cmd_version = 0;
-	cec_cmd.cmd_data_out = &lpcv_cmd;
+	cec_cmd.cmd_data_out = &cec_resp;
 	cec_cmd.cmd_size_in = 0;
-	cec_cmd.cmd_size_out = sizeof(lpcv_cmd);
+	cec_cmd.cmd_size_out = sizeof(cec_resp);
 	google_chromeec_command(&cec_cmd);
 
 	if (cec_cmd.cmd_code) {
@@ -262,16 +255,16 @@ static void google_chromeec_init(device_t dev)
 		       "Google Chrome EC: version command failed!\n");
 	} else {
 		printk(BIOS_DEBUG, "Google Chrome EC: version:\n");
-		printk(BIOS_DEBUG, "    ro: %s\n", lpcv_cmd.version_string_ro);
-		printk(BIOS_DEBUG, "    rw: %s\n", lpcv_cmd.version_string_rw);
+		printk(BIOS_DEBUG, "    ro: %s\n", cec_resp.version_string_ro);
+		printk(BIOS_DEBUG, "    rw: %s\n", cec_resp.version_string_rw);
 		printk(BIOS_DEBUG, "  running image: %d\n",
-		       lpcv_cmd.current_image);
-		ec_image_type = lpcv_cmd.current_image;
+		       cec_resp.current_image);
+		ec_image_type = cec_resp.current_image;
 	}
 
 	if (cec_cmd.cmd_code ||
 	    (recovery_mode_enabled() &&
-	     (lpcv_cmd.current_image != EC_IMAGE_RO))) {
+	     (cec_resp.current_image != EC_IMAGE_RO))) {
 		struct ec_params_reboot_ec reboot_ec;
 		/* Reboot the EC and make it come back in RO mode */
 		reboot_ec.cmd = EC_REBOOT_COLD;
@@ -290,37 +283,6 @@ static void google_chromeec_init(device_t dev)
 
 }
 
-static void google_chromeec_read_resources(device_t dev)
-{
-	/* Nothing, but this function avoids an error on serial console. */
-}
-
-static void google_chromeec_enable_resources(device_t dev)
-{
-	/* Nothing, but this function avoids an error on serial console. */
-}
-
-static struct device_operations ops = {
-	.init             = google_chromeec_init,
-	.read_resources   = google_chromeec_read_resources,
-	.enable_resources = google_chromeec_enable_resources
-};
-
-static struct pnp_info pnp_dev_info[] = {
-        { &ops, 0, 0, { 0, 0 }, }
-};
-
-static void enable_dev(device_t dev)
-{
-	pnp_enable_devices(dev, &pnp_ops, ARRAY_SIZE(pnp_dev_info),
-			   pnp_dev_info);
-}
-
-struct chip_operations ec_google_chromeec_ops = {
-	CHIP_NAME("Google Chrome EC")
-	.enable_dev = enable_dev,
-};
-
 int google_ec_running_ro(void)
 {
 	return (ec_image_type == EC_IMAGE_RO);
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h
index c78560f..f7512d7 100644
--- a/src/ec/google/chromeec/ec.h
+++ b/src/ec/google/chromeec/ec.h
@@ -30,6 +30,7 @@ int google_chromeec_set_wake_mask(u32 mask);
 u8 google_chromeec_get_event(void);
 int google_ec_running_ro(void);
 u16 google_chromeec_get_board_version(void);
+void google_chromeec_init(void);
 #endif
 
 u32 google_chromeec_get_events_b(void);
diff --git a/src/ec/google/chromeec/ec_lpc.c b/src/ec/google/chromeec/ec_lpc.c
index 6443592..4e8d3fb 100644
--- a/src/ec/google/chromeec/ec_lpc.c
+++ b/src/ec/google/chromeec/ec_lpc.c
@@ -18,9 +18,13 @@
  */
 
 #include <stdint.h>
+#include <stdlib.h>
+
 #include <console/console.h>
 #include <arch/io.h>
 #include <delay.h>
+#include <device/pnp.h>
+#include "chip.h"
 #include "ec.h"
 #include "ec_commands.h"
 
@@ -180,6 +184,51 @@ int google_chromeec_command(struct chromeec_command *cec_command)
 }
 
 #ifndef __PRE_RAM__
+
+#ifndef __SMM__
+static void lpc_ec_init(device_t dev)
+{
+	struct ec_google_chromeec_config *conf = dev->chip_info;
+
+	if (!dev->enabled)
+		return;
+	pc_keyboard_init(&conf->keyboard);
+	google_chromeec_init();
+}
+
+static void lpc_ec_read_resources(device_t dev)
+{
+	/* Nothing, but this function avoids an error on serial console. */
+}
+
+static void lpc_ec_enable_resources(device_t dev)
+{
+	/* Nothing, but this function avoids an error on serial console. */
+}
+
+static struct device_operations ops = {
+	.init             = lpc_ec_init,
+	.read_resources   = lpc_ec_read_resources,
+	.enable_resources = lpc_ec_enable_resources
+};
+
+static struct pnp_info pnp_dev_info[] = {
+	{ &ops, 0, 0, { 0, 0 }, }
+};
+
+static void enable_dev(device_t dev)
+{
+	pnp_enable_devices(dev, &pnp_ops, ARRAY_SIZE(pnp_dev_info),
+			   pnp_dev_info);
+}
+
+struct chip_operations ec_google_chromeec_ops = {
+	CHIP_NAME("Google Chrome EC")
+	.enable_dev = enable_dev,
+};
+
+#endif /* __SMM__ */
+
 u8 google_chromeec_get_event(void)
 {
 	if (google_chromeec_wait_ready(EC_LPC_ADDR_ACPI_CMD)) {



More information about the coreboot-gerrit mailing list