usb: typec: Add retimer handle to port altmode

Just like it does with muxes, the Type-C bus code can update the state
of connected retimers (especially when altmode-related transitions
occur). Add a retimer handle to the port altmode struct to enable this.

Signed-off-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20230112221609.540754-2-pmalani@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Prashant Malani 2023-01-12 22:16:06 +00:00 committed by Greg Kroah-Hartman
parent a30951d31b
commit 2476de8288
2 changed files with 16 additions and 3 deletions

View file

@ -7,11 +7,13 @@
struct bus_type;
struct typec_mux;
struct typec_retimer;
struct altmode {
unsigned int id;
struct typec_altmode adev;
struct typec_mux *mux;
struct typec_retimer *retimer;
enum typec_port_data roles;

View file

@ -583,6 +583,7 @@ void typec_unregister_altmode(struct typec_altmode *adev)
{
if (IS_ERR_OR_NULL(adev))
return;
typec_retimer_put(to_altmode(adev)->retimer);
typec_mux_put(to_altmode(adev)->mux);
device_unregister(&adev->dev);
}
@ -2108,16 +2109,26 @@ typec_port_register_altmode(struct typec_port *port,
{
struct typec_altmode *adev;
struct typec_mux *mux;
struct typec_retimer *retimer;
mux = typec_mux_get(&port->dev, desc);
if (IS_ERR(mux))
return ERR_CAST(mux);
adev = typec_register_altmode(&port->dev, desc);
if (IS_ERR(adev))
retimer = typec_retimer_get(&port->dev);
if (IS_ERR(retimer)) {
typec_mux_put(mux);
else
return ERR_CAST(retimer);
}
adev = typec_register_altmode(&port->dev, desc);
if (IS_ERR(adev)) {
typec_retimer_put(retimer);
typec_mux_put(mux);
} else {
to_altmode(adev)->mux = mux;
to_altmode(adev)->retimer = retimer;
}
return adev;
}