1 /* SPDX-License-Identifier: GPL-2.0 */
3 #ifndef __USB_TYPEC_CLASS__
4 #define __USB_TYPEC_CLASS__
6 #include <linux/device.h>
7 #include <linux/usb/typec.h>
14 enum typec_plug_index index;
21 enum typec_plug_type type;
22 struct usb_pd_identity *identity;
23 unsigned int active:1;
24 u16 pd_revision; /* 0300H = "3.0" */
27 struct typec_partner {
29 unsigned int usb_pd:1;
30 struct usb_pd_identity *identity;
31 enum typec_accessory accessory;
34 u16 pd_revision; /* 0300H = "3.0" */
35 enum usb_pd_svdm_ver svdm_version;
37 struct usb_power_delivery *pd;
45 struct usb_power_delivery *pd;
48 enum typec_data_role data_role;
49 enum typec_role pwr_role;
50 enum typec_role vconn_role;
51 enum typec_pwr_opmode pwr_opmode;
52 enum typec_port_type port_type;
53 struct mutex port_type_lock;
55 enum typec_orientation orientation;
56 struct typec_switch *sw;
57 struct typec_mux *mux;
58 struct typec_retimer *retimer;
60 const struct typec_capability *cap;
61 const struct typec_operations *ops;
64 #define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev)
65 #define to_typec_plug(_dev_) container_of(_dev_, struct typec_plug, dev)
66 #define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev)
67 #define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev)
69 extern const struct device_type typec_partner_dev_type;
70 extern const struct device_type typec_cable_dev_type;
71 extern const struct device_type typec_plug_dev_type;
72 extern const struct device_type typec_port_dev_type;
74 #define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type)
75 #define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type)
76 #define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type)
77 #define is_typec_port(dev) ((dev)->type == &typec_port_dev_type)
79 extern struct class typec_mux_class;
80 extern struct class retimer_class;
81 extern struct class typec_class;
83 #if defined(CONFIG_ACPI)
84 int typec_link_ports(struct typec_port *connector);
85 void typec_unlink_ports(struct typec_port *connector);
87 static inline int typec_link_ports(struct typec_port *connector) { return 0; }
88 static inline void typec_unlink_ports(struct typec_port *connector) { }
91 #endif /* __USB_TYPEC_CLASS__ */