diff options
author | Utkarsh Patel <utkarsh.h.patel@intel.com> | 2020-12-09 22:09:03 -0800 |
---|---|---|
committer | Benson Leung <bleung@chromium.org> | 2021-01-05 12:57:15 -0800 |
commit | 8553a979fcd03448a4096c7d431b7ee1a52bfca3 (patch) | |
tree | 979838f70bccf1282b85baa7672821957d41857c /drivers/platform/chrome/cros_ec_typec.c | |
parent | ba8ce515454e1fc5e73ff8989c18c596a3449fef (diff) | |
download | linux-stable-8553a979fcd03448a4096c7d431b7ee1a52bfca3.tar.gz linux-stable-8553a979fcd03448a4096c7d431b7ee1a52bfca3.tar.bz2 linux-stable-8553a979fcd03448a4096c7d431b7ee1a52bfca3.zip |
platform/chrome: cros_ec_typec: Send mux configuration acknowledgment to EC
In some corner cases downgrade of the superspeed typec device(e.g. Dell
typec Dock, apple dongle) was seen because before the SOC mux configuration
finishes, EC starts configuring the next mux state.
With this change, once the SOC mux is configured, kernel will send an
acknowledgment to EC via Host command EC_CMD_USB_PD_MUX_ACK [1].
After sending the host event EC will wait for the acknowledgment from
kernel before starting the PD negotiation for the next mux state. This
helps to have a framework to build better error handling along with the
synchronization of timing sensitive mux states.
This change also brings in corresponding EC header updates from the EC code
base [1].
[1]:
https://chromium.googlesource.com/chromiumos/platform/ec/+/refs/heads/master/include/ec_commands.h
Signed-off-by: Utkarsh Patel <utkarsh.h.patel@intel.com>
Reviewed-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20201210060903.2205-3-utkarsh.h.patel@intel.com
Diffstat (limited to 'drivers/platform/chrome/cros_ec_typec.c')
-rw-r--r-- | drivers/platform/chrome/cros_ec_typec.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 6068433dd2e2..e724a5eaef1c 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -81,6 +81,7 @@ struct cros_typec_data { struct notifier_block nb; struct work_struct port_work; bool typec_cmd_supported; + bool needs_mux_ack; }; static int cros_typec_parse_port_props(struct typec_capability *cap, @@ -531,6 +532,7 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, struct ec_response_usb_pd_control_v2 *pd_ctrl) { struct cros_typec_port *port = typec->ports[port_num]; + struct ec_params_usb_pd_mux_ack mux_ack; enum typec_orientation orientation; int ret; @@ -570,6 +572,18 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, mux_flags); } + if (!typec->needs_mux_ack) + return ret; + + /* Sending Acknowledgment to EC */ + mux_ack.port = port_num; + + if (cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack, + sizeof(mux_ack), NULL, 0) < 0) + dev_warn(typec->dev, + "Failed to send Mux ACK to EC for port: %d\n", + port_num); + return ret; } @@ -1053,6 +1067,8 @@ static int cros_typec_probe(struct platform_device *pdev) typec->typec_cmd_supported = !!cros_typec_feature_supported(typec, EC_FEATURE_TYPEC_CMD); + typec->needs_mux_ack = !!cros_typec_feature_supported(typec, + EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK); ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0, &resp, sizeof(resp)); |