1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 #ifndef __USB_TYPEC_CLASS__ 4 #define __USB_TYPEC_CLASS__ 5 6 #include <linux/device.h> 7 #include <linux/usb/typec.h> 8 9 struct typec_mux; 10 struct typec_switch; 11 12 struct typec_plug { 13 struct device dev; 14 enum typec_plug_index index; 15 struct ida mode_ids; 16 int num_altmodes; 17 }; 18 19 struct typec_cable { 20 struct device dev; 21 enum typec_plug_type type; 22 struct usb_pd_identity *identity; 23 unsigned int active:1; 24 u16 pd_revision; /* 0300H = "3.0" */ 25 }; 26 27 struct typec_partner { 28 struct device dev; 29 unsigned int usb_pd:1; 30 struct usb_pd_identity *identity; 31 enum typec_accessory accessory; 32 struct ida mode_ids; 33 int num_altmodes; 34 u16 pd_revision; /* 0300H = "3.0" */ 35 enum usb_pd_svdm_ver svdm_version; 36 }; 37 38 struct typec_port { 39 unsigned int id; 40 struct device dev; 41 struct ida mode_ids; 42 43 int prefer_role; 44 enum typec_data_role data_role; 45 enum typec_role pwr_role; 46 enum typec_role vconn_role; 47 enum typec_pwr_opmode pwr_opmode; 48 enum typec_port_type port_type; 49 struct mutex port_type_lock; 50 51 enum typec_orientation orientation; 52 struct typec_switch *sw; 53 struct typec_mux *mux; 54 55 const struct typec_capability *cap; 56 const struct typec_operations *ops; 57 }; 58 59 #define to_typec_port(_dev_) container_of(_dev_, struct typec_port, dev) 60 #define to_typec_plug(_dev_) container_of(_dev_, struct typec_plug, dev) 61 #define to_typec_cable(_dev_) container_of(_dev_, struct typec_cable, dev) 62 #define to_typec_partner(_dev_) container_of(_dev_, struct typec_partner, dev) 63 64 extern const struct device_type typec_partner_dev_type; 65 extern const struct device_type typec_cable_dev_type; 66 extern const struct device_type typec_plug_dev_type; 67 extern const struct device_type typec_port_dev_type; 68 69 #define is_typec_partner(dev) ((dev)->type == &typec_partner_dev_type) 70 #define is_typec_cable(dev) ((dev)->type == &typec_cable_dev_type) 71 #define is_typec_plug(dev) ((dev)->type == &typec_plug_dev_type) 72 #define is_typec_port(dev) ((dev)->type == &typec_port_dev_type) 73 74 extern struct class typec_mux_class; 75 extern struct class typec_class; 76 77 #if defined(CONFIG_ACPI) 78 int typec_link_ports(struct typec_port *connector); 79 void typec_unlink_ports(struct typec_port *connector); 80 #else typec_link_ports(struct typec_port * connector)81static inline int typec_link_ports(struct typec_port *connector) { return 0; } typec_unlink_ports(struct typec_port * connector)82static inline void typec_unlink_ports(struct typec_port *connector) { } 83 #endif 84 85 #endif /* __USB_TYPEC_CLASS__ */ 86