History

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

Utkarsh Patel committed 5 years ago

Commit 8553a971 parent ba8ce512 files · +33 −0Browse files

Unified · Split

2 files
  1. drivers/platform/chrome/cros_ec_typec.c +16 −0
  2. include/linux/platform_data/cros_ec_commands.h +17 −0
drivers/platform/chrome/cros_ec_typec.c+16−0
@@ -81,6 +81,7 @@ struct cros_typec_data { · 80 unmodified lines
81 struct notifier_block nb;81 struct notifier_block nb;
82 struct work_struct port_work;82 struct work_struct port_work;
83 bool typec_cmd_supported;83 bool typec_cmd_supported;
84 bool needs_mux_ack;
84};85};
85 86
86static int cros_typec_parse_port_props(struct typec_capability *cap,87static 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, · 444 unmodified lines
531 struct ec_response_usb_pd_control_v2 *pd_ctrl)532 struct ec_response_usb_pd_control_v2 *pd_ctrl)
532{533{
533 struct cros_typec_port *port = typec->ports[port_num];534 struct cros_typec_port *port = typec->ports[port_num];
535 struct ec_params_usb_pd_mux_ack mux_ack;
534 enum typec_orientation orientation;536 enum typec_orientation orientation;
535 int ret;537 int ret;
536 538
@@ -570,6 +572,18 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num, · 33 unmodified lines
570 mux_flags);572 mux_flags);
571 }573 }
572 574
575 if (!typec->needs_mux_ack)
576 return ret;
577
578 /* Sending Acknowledgment to EC */
579 mux_ack.port = port_num;
580
581 if (cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_MUX_ACK, &mux_ack,
582 sizeof(mux_ack), NULL, 0) < 0)
583 dev_warn(typec->dev,
584 "Failed to send Mux ACK to EC for port: %d\n",
585 port_num);
586
573 return ret;587 return ret;
574}588}
575 589
@@ -1053,6 +1067,8 @@ static int cros_typec_probe(struct platform_device *pdev) · 477 unmodified lines
1053 1067
1054 typec->typec_cmd_supported = !!cros_typec_feature_supported(typec,1068 typec->typec_cmd_supported = !!cros_typec_feature_supported(typec,
1055 EC_FEATURE_TYPEC_CMD);1069 EC_FEATURE_TYPEC_CMD);
1070 typec->needs_mux_ack = !!cros_typec_feature_supported(typec,
1071 EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK);
1056 1072
1057 ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,1073 ret = cros_typec_ec_command(typec, 0, EC_CMD_USB_PD_PORTS, NULL, 0,
1058 &resp, sizeof(resp));1074 &resp, sizeof(resp));
include/linux/platform_data/cros_ec_commands.h+17−0
@@ -1286,6 +1286,16 @@ enum ec_feature_code { · 1285 unmodified lines
1286 EC_FEATURE_ISH = 40,1286 EC_FEATURE_ISH = 40,
1287 /* New TCPMv2 TYPEC_ prefaced commands supported */1287 /* New TCPMv2 TYPEC_ prefaced commands supported */
1288 EC_FEATURE_TYPEC_CMD = 41,1288 EC_FEATURE_TYPEC_CMD = 41,
1289 /*
1290 * The EC will wait for direction from the AP to enter Type-C alternate
1291 * modes or USB4.
1292 */
1293 EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY = 42,
1294 /*
1295 * The EC will wait for an acknowledge from the AP after setting the
1296 * mux.
1297 */
1298 EC_FEATURE_TYPEC_MUX_REQUIRE_AP_ACK = 43,
1289};1299};
1290 1300
1291#define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32)1301#define EC_FEATURE_MASK_0(event_code) BIT(event_code % 32)
@@ -6054,6 +6064,13 @@ struct ec_params_charger_control { · 4762 unmodified lines
6054 uint8_t allow_charging;6064 uint8_t allow_charging;
6055} __ec_align_size1;6065} __ec_align_size1;
6056 6066
6067/* Get ACK from the USB-C SS muxes */
6068#define EC_CMD_USB_PD_MUX_ACK 0x0603
6069
6070struct ec_params_usb_pd_mux_ack {
6071 uint8_t port; /* USB-C port number */
6072} __ec_align1;
6073
6057/*****************************************************************************/6074/*****************************************************************************/
6058/*6075/*
6059 * Reserve a range of host commands for board-specific, experimental, or6076 * Reserve a range of host commands for board-specific, experimental, or