[coreboot-gerrit] New patch to review for coreboot: google/chromeec: Add command to control USB PD role

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Mon Nov 28 12:15:35 CET 2016


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17627

-gerrit

commit c34a5665a46fa1c3f9970fe730db22bec7b9c50e
Author: Julius Werner <jwerner at chromium.org>
Date:   Mon Nov 21 20:14:07 2016 -0800

    google/chromeec: Add command to control USB PD role
    
    Normally firmware should have no business messing with the USB PD role
    (source/sink/whatever) in the EC. But, as so often happens, ugly issues
    crop up that require weird work-arounds, and before you know it you need
    to do this for some reason that only makes sense in context. I do now,
    so add this function to send the necessary host command in the simplest
    possible fashion.
    
    BRANCH=gru
    BUG=chrome-os-partner:59346
    TEST=Used it in a follow-up patch.
    
    Change-Id: I07d40feafd6a8387a633d6384efb205baf578d76
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
    Original-Commit-Id: 8b71767caccff9b77d458182ce8066f7abf6321c
    Original-Change-Id: Ie8d0be98f6b703f4db062fe2f728cd2588347202
    Original-Signed-off-by: Julius Werner <jwerner at chromium.org>
    Original-Reviewed-on: https://chromium-review.googlesource.com/413030
    Original-Reviewed-by: Vincent Palatin <vpalatin at chromium.org>
---
 src/ec/google/chromeec/ec.c | 22 ++++++++++++++++++++++
 src/ec/google/chromeec/ec.h |  1 +
 2 files changed, 23 insertions(+)

diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c
index 1308c3d..d0648f7 100644
--- a/src/ec/google/chromeec/ec.c
+++ b/src/ec/google/chromeec/ec.c
@@ -497,6 +497,28 @@ int google_chromeec_set_usb_charge_mode(u8 port_id, enum usb_charge_mode mode)
 	return google_chromeec_command(&cmd);
 }
 
+int google_chromeec_set_usb_pd_role(u8 port, enum usb_pd_control_role role)
+{
+	struct ec_params_usb_pd_control req = {
+		.port = port,
+		.role = role,
+		.mux = USB_PD_CTRL_MUX_NO_CHANGE,
+		.swap = USB_PD_CTRL_SWAP_NONE,
+	};
+	struct ec_response_usb_pd_control rsp;
+	struct chromeec_command cmd = {
+		.cmd_code = EC_CMD_USB_PD_CONTROL,
+		.cmd_version = 0,
+		.cmd_data_in = &req,
+		.cmd_size_in = sizeof(req),
+		.cmd_data_out = &rsp,
+		.cmd_size_out = sizeof(rsp),
+		.cmd_dev_index = 0,
+	};
+
+	return google_chromeec_command(&cmd);
+}
+
 #ifndef __SMM__
 
 static
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h
index f765fe4..71cea7e 100644
--- a/src/ec/google/chromeec/ec.h
+++ b/src/ec/google/chromeec/ec.h
@@ -76,6 +76,7 @@ enum usb_charge_mode {
 	USB_CHARGE_MODE_DOWNSTREAM_1500MA,
 };
 int google_chromeec_set_usb_charge_mode(u8 port_id, enum usb_charge_mode mode);
+int google_chromeec_set_usb_pd_role(u8 port, enum usb_pd_control_role role);
 
 /* internal structure to send a command to the EC and wait for response. */
 struct chromeec_command {



More information about the coreboot-gerrit mailing list