usb: typec: tcpm: Add start_srp_connection_detect callback
PATCH 1/3 usb: typec: tcpm: Add start_srp_connection_detect callback
Quoted 4 lines · Hans de Goede
Some tcpc device-drivers need to explicitly be told to watch for connection events, otherwise the tcpc will not generate any
TCPM_CC_EVENTsand devices being plugged into the Type-C port will not be noticed.
Quoted 9 lines
For dual-role ports
tcpm_start_drp_toggling()is used to tell the tcpc to watch for connection events. But for single-role ports we've so far been falling back to just callingtcpm_set_cc(). For some tcpc-s such as the fusb302 this is not enough and noTCPM_CC_EVENTwill be generated.This commit adds a new
start_srp_connection_detectcallback totcpc_devand when this is implemented calls this in place ofstart_drp_togglingfor SRP devices.
Do we indeed need an additional callback for this purpose, or would a single "start_connection_detect" call to replace start_drp_toggling be sufficient ? If necessary, we could add the port type as argument (if the low level driver doesn't already know that).
Thanks,
Guenter
Quoted 54 lines
Fixes ea3b4d5523bc("usb: typec: fusb302: Resolve fixed power role ...")Cc Adam Thomson <[email protected]>Signed-off-by Hans de Goede <[email protected]>--- drivers/usb/typec/tcpm/tcpm.c | 8 ++++++++ include/linux/usb/tcpm.h | 6 ++++++ 2 files changed, 14 insertions(+)drivers/usb/typec/tcpm/tcpm.c +8
-0@@ -2553,6 +2553,14 @@ static bool tcpm_start_drp_toggling(struct tcpm_port *port,return true; } +if (port->tcpc->start_srp_connection_detect && + port->port_type !=TYPEC_PORT_DRP ) { +tcpm_log_force (port,"Start SRP connection detection" ); + ret = port->tcpc->start_srp_connection_detect (port->tcpc, cc); +if (!ret) +return true; + } +return false; }include/linux/usb/tcpm.h +6
-0@@ -125,6 +125,10 @@ struct tcpc_config {* Optional; if supported by hardware, called to start DRP * toggling. DRP toggling is stopped automatically if * a connection is established. +* @start_srp_connection_detect: +* Optional; if supported by hardware, called to start connection +* detection for single role ports. Connection detection is stopped +* automatically if a connection is established. * @try_role: Optional; called to set a preferred role * @pd_transmit:Called to transmit PD message * @mux: Pointer to multiplexer data @@ -149,6 +153,8 @@ struct tcpc_dev { enum typec_role role, enum typec_data_role data);int (*start_drp_toggling)(struct tcpc_dev *dev,enum typec_cc_status cc); +int (*start_srp_connection_detect)(struct tcpc_dev *dev, +enum typec_cc_status cc);int (*try_role)(struct tcpc_dev *dev,int role);int (*pd_transmit)(struct tcpc_dev *dev,enum tcpm_transmit_type type,const struct pd_message *msg);Signature · 1 line
2.21.0