usb: typec: altmodes: add svdm version info for typec cables
Add typec_cable_set_svdm_version and typec_get_cable_svdm version symbols. Cables can operate under a lower PD revision than the port partner, and the max SVDM version is tied to the PD revision. So, typec_cable maintains its own svdm_version. Add typec_altmode_get_cable_svdm_version to return the cable's negotiated svdm_version for altmode drivers to use. Signed-off-by: RD Babiera <rdbabiera@google.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20240108191620.987785-16-rdbabiera@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7494d4bc8e
commit
231b731841
@ -2131,6 +2131,46 @@ int typec_get_negotiated_svdm_version(struct typec_port *port)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(typec_get_negotiated_svdm_version);
|
||||
|
||||
/**
|
||||
* typec_get_cable_svdm_version - Get cable negotiated SVDM Version
|
||||
* @port: USB Type-C Port.
|
||||
*
|
||||
* Get the negotiated SVDM Version for the cable. The Version is set to the port
|
||||
* default value based on the PD Revision during cable registration, and updated
|
||||
* after a successful Discover Identity if the negotiated value is less than the
|
||||
* default.
|
||||
*
|
||||
* Returns usb_pd_svdm_ver if the cable has been registered otherwise -ENODEV.
|
||||
*/
|
||||
int typec_get_cable_svdm_version(struct typec_port *port)
|
||||
{
|
||||
enum usb_pd_svdm_ver svdm_version;
|
||||
struct device *cable_dev;
|
||||
|
||||
cable_dev = device_find_child(&port->dev, NULL, cable_match);
|
||||
if (!cable_dev)
|
||||
return -ENODEV;
|
||||
|
||||
svdm_version = to_typec_cable(cable_dev)->svdm_version;
|
||||
put_device(cable_dev);
|
||||
|
||||
return svdm_version;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(typec_get_cable_svdm_version);
|
||||
|
||||
/**
|
||||
* typec_cable_set_svdm_version - Set negotiated Structured VDM (SVDM) Version
|
||||
* @cable: USB Type-C Active Cable that supports SVDM
|
||||
* @svdm_version: Negotiated SVDM Version
|
||||
*
|
||||
* This routine is used to save the negotiated SVDM Version.
|
||||
*/
|
||||
void typec_cable_set_svdm_version(struct typec_cable *cable, enum usb_pd_svdm_ver svdm_version)
|
||||
{
|
||||
cable->svdm_version = svdm_version;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(typec_cable_set_svdm_version);
|
||||
|
||||
/**
|
||||
* typec_get_drvdata - Return private driver data pointer
|
||||
* @port: USB Type-C port
|
||||
|
@ -23,6 +23,7 @@ struct typec_cable {
|
||||
struct usb_pd_identity *identity;
|
||||
unsigned int active:1;
|
||||
u16 pd_revision; /* 0300H = "3.0" */
|
||||
enum usb_pd_svdm_ver svdm_version;
|
||||
};
|
||||
|
||||
struct typec_partner {
|
||||
|
@ -337,6 +337,9 @@ void typec_partner_set_svdm_version(struct typec_partner *partner,
|
||||
enum usb_pd_svdm_ver svdm_version);
|
||||
int typec_get_negotiated_svdm_version(struct typec_port *port);
|
||||
|
||||
int typec_get_cable_svdm_version(struct typec_port *port);
|
||||
void typec_cable_set_svdm_version(struct typec_cable *cable, enum usb_pd_svdm_ver svdm_version);
|
||||
|
||||
struct usb_power_delivery *typec_partner_usb_power_delivery_register(struct typec_partner *partner,
|
||||
struct usb_power_delivery_desc *desc);
|
||||
|
||||
|
@ -95,6 +95,16 @@ int typec_cable_altmode_exit(struct typec_altmode *altmode, enum typec_plug_inde
|
||||
int typec_cable_altmode_vdm(struct typec_altmode *altmode, enum typec_plug_index sop,
|
||||
const u32 header, const u32 *vdo, int count);
|
||||
|
||||
/**
|
||||
* typec_altmode_get_cable_svdm_version - Get negotiated SVDM version for cable plug
|
||||
* @altmode: Handle to the alternate mode
|
||||
*/
|
||||
static inline int
|
||||
typec_altmode_get_cable_svdm_version(struct typec_altmode *altmode)
|
||||
{
|
||||
return typec_get_cable_svdm_version(typec_altmode2port(altmode));
|
||||
}
|
||||
|
||||
/*
|
||||
* These are the connector states (USB, Safe and Alt Mode) defined in USB Type-C
|
||||
* Specification. SVID specific connector states are expected to follow and
|
||||
|
Loading…
x
Reference in New Issue
Block a user