[coreboot-gerrit] Patch set updated for coreboot: 9391fdc ec/google: Generalize communication protocol support in EC drivers.

Gabe Black (gabeblack@chromium.org) gerrit at coreboot.org
Wed Jul 10 14:32:20 CEST 2013


Gabe Black (gabeblack at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3749

-gerrit

commit 9391fdc494bbb48ca807d6e00f2a767cf0522eae
Author: Hung-Te Lin <hungte at chromium.org>
Date:   Fri Jun 21 20:11:47 2013 +0800

    ec/google: Generalize communication protocol support in EC drivers.
    
    Since EC protocol v3, the packet format will be the same for all buses (inclding
    I2C, SPI, and LPC). That will simplify the implementation in each individual bus
    driver source file.
    
    To prepare for that, we will move the protocol part into crosec_proto.c:
    crosec_command_proto, with bus driver in callback "crosec_io".
    
    Change-Id: I9ccd19a57a182899dd1ef1cd90598679c1546295
    Signed-off-by: Hung-Te Lin <hungte at chromium.org>
---
 src/ec/google/chromeec/Makefile.inc   |  6 +++---
 src/ec/google/chromeec/crosec_proto.c | 34 ++++++++++++++++++++++++++++++++++
 src/ec/google/chromeec/ec.h           |  9 +++++++++
 3 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/src/ec/google/chromeec/Makefile.inc b/src/ec/google/chromeec/Makefile.inc
index 922c1fe..73b5b5e 100644
--- a/src/ec/google/chromeec/Makefile.inc
+++ b/src/ec/google/chromeec/Makefile.inc
@@ -1,9 +1,9 @@
-ramstage-y += ec.c
+ramstage-y += ec.c crosec_proto.c
 ramstage-$(CONFIG_EC_GOOGLE_CHROMEEC_I2C) += ec_i2c.c
 ramstage-$(CONFIG_EC_GOOGLE_CHROMEEC_LPC) += ec_lpc.c
-smm-y += ec.c
+smm-y += ec.c crosec_proto.c
 smm-$(CONFIG_EC_GOOGLE_CHROMEEC_I2C) += ec_i2c.c
 smm-$(CONFIG_EC_GOOGLE_CHROMEEC_LPC) += ec_lpc.c
-romstage-y += ec.c
+romstage-y += ec.c crosec_proto.c
 romstage-$(CONFIG_EC_GOOGLE_CHROMEEC_I2C) += ec_i2c.c
 romstage-$(CONFIG_EC_GOOGLE_CHROMEEC_LPC) += ec_lpc.c
diff --git a/src/ec/google/chromeec/crosec_proto.c b/src/ec/google/chromeec/crosec_proto.c
new file mode 100644
index 0000000..016de8d
--- /dev/null
+++ b/src/ec/google/chromeec/crosec_proto.c
@@ -0,0 +1,34 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Google Inc.  All rights reserved.
+ *
+ * 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; version 2 of the License
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <arch/io.h>
+#include <console/console.h>
+#include <delay.h>
+#include <stdint.h>
+#include <string.h>
+#include "ec.h"
+#include "ec_commands.h"
+#include "ec_message.h"
+
+int crosec_command_proto(struct chromeec_command *cec_command,
+			 crosec_io_t crosec_io, void *context)
+{
+	// TODO(hungte) Add v3 protocol.
+	return -1;
+}
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h
index 7679a8b..13e9f23 100644
--- a/src/ec/google/chromeec/ec.h
+++ b/src/ec/google/chromeec/ec.h
@@ -21,6 +21,8 @@
 
 #ifndef _EC_GOOGLE_CHROMEEC_EC_H
 #define _EC_GOOGLE_CHROMEEC_EC_H
+#include <stddef.h>
+#include <stdint.h>
 
 #ifndef __PRE_RAM__
 u32 google_chromeec_get_wake_mask(void);
@@ -60,6 +62,13 @@ struct chromeec_command {
 				   * actual received size out */
 };
 
+/* internal standard implementation for EC command protocols. */
+typedef int (*crosec_io_t)(uint8_t *write_bytes, size_t write_size,
+			   uint8_t *read_bytes, size_t read_size,
+			   void *context);
+int crosec_command_proto(struct chromeec_command *cec_command,
+			 crosec_io_t crosec_io, void *context);
+
 int google_chromeec_command(struct chromeec_command *cec_command);
 
 #endif /* _EC_GOOGLE_CHROMEEC_EC_H */



More information about the coreboot-gerrit mailing list