summaryrefslogtreecommitdiff
path: root/drivers/usb/typec
diff options
context:
space:
mode:
authorHeikki Krogerus <heikki.krogerus@linux.intel.com>2021-09-20 17:24:17 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-05 12:42:38 +0200
commit6cbe4b2d5a3f290fba764e722b19cb55968a84d2 (patch)
tree40c6b7b6d32a84ab7c6db5a227f6dff7eba0d8d9 /drivers/usb/typec
parente08065069fc7b074712378a95a3522d557e9bbe1 (diff)
usb: typec: ucsi: Check the partner alt modes always if there is PD contract
UCSI does not tell the driver explicitly when the firmware (PPM in UCSI lingo) has actually detected the partner alternate modes, there is no specific change event for that. That's why they have to be checked with any notification that informs that PD contract with that partner has been achieved. Previously the alternate modes were checked always when the firmware (PPM) informed that something with the partner had changed, but on some platforms the EC firmware does not generate separate events for generic partner changes at all. On those platforms the EC firmware notifies the driver only about connections, or separately about the PD contract if it was not achieved soon enough after the initial connection event. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20210920142419.54493-6-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/typec')
-rw-r--r--drivers/usb/typec/ucsi/ucsi.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index 8af292141fe7..188181737acf 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -627,6 +627,7 @@ static void ucsi_pwr_opmode_change(struct ucsi_connector *con)
con->rdo = con->status.request_data_obj;
typec_set_pwr_opmode(con->port, TYPEC_PWR_MODE_PD);
ucsi_get_src_pdos(con, 1);
+ ucsi_partner_task(con, ucsi_check_altmodes, 30, 0);
break;
case UCSI_CONSTAT_PWR_OPMODE_TYPEC1_5:
con->rdo = 0;
@@ -726,8 +727,6 @@ static void ucsi_partner_change(struct ucsi_connector *con)
if (ret)
dev_err(con->ucsi->dev, "con:%d: failed to set usb role:%d\n",
con->num, u_role);
-
- ucsi_partner_task(con, ucsi_check_altmodes, 30, 0);
}
static void ucsi_handle_connector_change(struct work_struct *work)
@@ -878,10 +877,15 @@ static void ucsi_handle_connector_change(struct work_struct *work)
break;
}
- if (con->status.flags & UCSI_CONSTAT_CONNECTED)
+ if (con->status.flags & UCSI_CONSTAT_CONNECTED) {
ucsi_register_partner(con);
- else
+
+ if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) ==
+ UCSI_CONSTAT_PWR_OPMODE_PD)
+ ucsi_partner_task(con, ucsi_check_altmodes, 30, 0);
+ } else {
ucsi_unregister_partner(con);
+ }
ucsi_port_psy_changed(con);
@@ -1244,7 +1248,7 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
ret = 0;
}
- if (con->partner)
+ if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) == UCSI_CONSTAT_PWR_OPMODE_PD)
ucsi_check_altmodes(con);
trace_ucsi_register_port(con->num, &con->status);