Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: typec: ucsi: add callback for connector status updates

Allow UCSI glue driver to perform addtional work to update connector
status. For example, it might check the cable orientation. This call is
performed after reading new connector statatus, so the platform driver
can peek at new connection status bits.

The callback is called both when registering the port and when the
connector change event is being handled.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20240411-ucsi-orient-aware-v2-1-d4b1cb22a33f@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Dmitry Baryshkov and committed by
Greg Kroah-Hartman
24bce22d 0a723ed3

+9
+6
drivers/usb/typec/ucsi/ucsi.c
··· 1199 1199 1200 1200 trace_ucsi_connector_change(con->num, &con->status); 1201 1201 1202 + if (ucsi->ops->connector_status) 1203 + ucsi->ops->connector_status(con); 1204 + 1202 1205 role = !!(con->status.flags & UCSI_CONSTAT_PWR_DIR); 1203 1206 1204 1207 if (con->status.change & UCSI_CONSTAT_POWER_DIR_CHANGE) { ··· 1592 1589 goto out; 1593 1590 } 1594 1591 ret = 0; /* ucsi_send_command() returns length on success */ 1592 + 1593 + if (ucsi->ops->connector_status) 1594 + ucsi->ops->connector_status(con); 1595 1595 1596 1596 switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) { 1597 1597 case UCSI_CONSTAT_PARTNER_TYPE_UFP:
+3
drivers/usb/typec/ucsi/ucsi.h
··· 16 16 17 17 struct ucsi; 18 18 struct ucsi_altmode; 19 + struct ucsi_connector; 19 20 struct dentry; 20 21 21 22 /* UCSI offsets (Bytes) */ ··· 60 59 * @sync_write: Blocking write operation 61 60 * @async_write: Non-blocking write operation 62 61 * @update_altmodes: Squashes duplicate DP altmodes 62 + * @connector_status: Updates connector status, called holding connector lock 63 63 * 64 64 * Read and write routines for UCSI interface. @sync_write must wait for the 65 65 * Command Completion Event from the PPM before returning, and @async_write must ··· 75 73 const void *val, size_t val_len); 76 74 bool (*update_altmodes)(struct ucsi *ucsi, struct ucsi_altmode *orig, 77 75 struct ucsi_altmode *updated); 76 + void (*connector_status)(struct ucsi_connector *con); 78 77 }; 79 78 80 79 struct ucsi *ucsi_create(struct device *dev, const struct ucsi_operations *ops);