usb: typec: USB Power Delivery helpers for ports and partners
All the USB Type-C Connector Class devices are protected, so the drivers can not directly access them. This will adds a few helpers that can be used to link the ports and partners to the correct USB Power Delivery objects. For ports a new optional sysfs attribute file is also added that can be used to select the USB Power Delivery capabilities that the port will advertise to the partner. Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20220502132058.86236-3-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
662a60102c
commit
a7cff92f06
4 changed files with 174 additions and 0 deletions
|
|
@ -22,6 +22,8 @@ struct typec_altmode_ops;
|
|||
struct fwnode_handle;
|
||||
struct device;
|
||||
|
||||
struct usb_power_delivery;
|
||||
|
||||
enum typec_port_type {
|
||||
TYPEC_PORT_SRC,
|
||||
TYPEC_PORT_SNK,
|
||||
|
|
@ -223,6 +225,8 @@ struct typec_partner_desc {
|
|||
* @pr_set: Set Power Role
|
||||
* @vconn_set: Source VCONN
|
||||
* @port_type_set: Set port type
|
||||
* @pd_get: Get available USB Power Delivery Capabilities.
|
||||
* @pd_set: Set USB Power Delivery Capabilities.
|
||||
*/
|
||||
struct typec_operations {
|
||||
int (*try_role)(struct typec_port *port, int role);
|
||||
|
|
@ -231,6 +235,8 @@ struct typec_operations {
|
|||
int (*vconn_set)(struct typec_port *port, enum typec_role role);
|
||||
int (*port_type_set)(struct typec_port *port,
|
||||
enum typec_port_type type);
|
||||
struct usb_power_delivery **(*pd_get)(struct typec_port *port);
|
||||
int (*pd_set)(struct typec_port *port, struct usb_power_delivery *pd);
|
||||
};
|
||||
|
||||
enum usb_pd_svdm_ver {
|
||||
|
|
@ -250,6 +256,7 @@ enum usb_pd_svdm_ver {
|
|||
* @accessory: Supported Accessory Modes
|
||||
* @fwnode: Optional fwnode of the port
|
||||
* @driver_data: Private pointer for driver specific info
|
||||
* @pd: Optional USB Power Delivery Support
|
||||
* @ops: Port operations vector
|
||||
*
|
||||
* Static capabilities of a single USB Type-C port.
|
||||
|
|
@ -267,6 +274,8 @@ struct typec_capability {
|
|||
struct fwnode_handle *fwnode;
|
||||
void *driver_data;
|
||||
|
||||
struct usb_power_delivery *pd;
|
||||
|
||||
const struct typec_operations *ops;
|
||||
};
|
||||
|
||||
|
|
@ -318,4 +327,8 @@ 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_port_set_usb_power_delivery(struct typec_port *port, struct usb_power_delivery *pd);
|
||||
int typec_partner_set_usb_power_delivery(struct typec_partner *partner,
|
||||
struct usb_power_delivery *pd);
|
||||
|
||||
#endif /* __LINUX_USB_TYPEC_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue