Skip to content

Commit 2ee9737

Browse files
Prashant MalaniEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec_typec: Register PD CTRL cmd v2
Recognize EC_CMD_USB_PD_CONTROL command version 2. This is necessary in order to process Type C mux information (like DP alt mode pin configuration), which is needed by the Type C Connector class API to configure the Type C muxes correctly While we are here, rename the struct member storing this version number from cmd_ver to pd_ctrl_ver, which more accurately reflects what is being stored. Also, slightly change the logic for calling cros_typec_set_port_params_*(). Now, v0 is called when pd_ctrl_ver is 0, and v1 is called otherwise. Signed-off-by: Prashant Malani <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent e32b16c commit 2ee9737

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/platform/chrome/cros_ec_typec.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct cros_typec_data {
3737
struct device *dev;
3838
struct cros_ec_device *ec;
3939
int num_ports;
40-
unsigned int cmd_ver;
40+
unsigned int pd_ctrl_ver;
4141
/* Array of ports, indexed by port number. */
4242
struct cros_typec_port *ports[EC_USB_PD_MAX_PORTS];
4343
struct notifier_block nb;
@@ -340,7 +340,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
340340
req.mux = USB_PD_CTRL_MUX_NO_CHANGE;
341341
req.swap = USB_PD_CTRL_SWAP_NONE;
342342

343-
ret = cros_typec_ec_command(typec, typec->cmd_ver,
343+
ret = cros_typec_ec_command(typec, typec->pd_ctrl_ver,
344344
EC_CMD_USB_PD_CONTROL, &req, sizeof(req),
345345
&resp, sizeof(resp));
346346
if (ret < 0)
@@ -351,7 +351,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num)
351351
dev_dbg(typec->dev, "Polarity %d: 0x%hhx\n", port_num, resp.polarity);
352352
dev_dbg(typec->dev, "State %d: %s\n", port_num, resp.state);
353353

354-
if (typec->cmd_ver == 1)
354+
if (typec->pd_ctrl_ver != 0)
355355
cros_typec_set_port_params_v1(typec, port_num, &resp);
356356
else
357357
cros_typec_set_port_params_v0(typec, port_num,
@@ -374,13 +374,15 @@ static int cros_typec_get_cmd_version(struct cros_typec_data *typec)
374374
if (ret < 0)
375375
return ret;
376376

377-
if (resp.version_mask & EC_VER_MASK(1))
378-
typec->cmd_ver = 1;
377+
if (resp.version_mask & EC_VER_MASK(2))
378+
typec->pd_ctrl_ver = 2;
379+
else if (resp.version_mask & EC_VER_MASK(1))
380+
typec->pd_ctrl_ver = 1;
379381
else
380-
typec->cmd_ver = 0;
382+
typec->pd_ctrl_ver = 0;
381383

382384
dev_dbg(typec->dev, "PD Control has version mask 0x%hhx\n",
383-
typec->cmd_ver);
385+
typec->pd_ctrl_ver);
384386

385387
return 0;
386388
}

0 commit comments

Comments
 (0)