History

usb: typec: Add attribute file showing the supported USB modes of the port

This attribute file, named "usb_capability", will show the supported USB modes, which are USB 2.0, USB 3.2 and USB4. These modes are defined in the USB Type-C (R2.0) and USB Power Delivery (R3.0 V2.0) Specifications.

Heikki Krogerus committed 2 years ago

Commit 8060bcb1 parent 0990e5c4 files · +112 −0Browse files

Showing the changes to include/linux/usb (1 of 4 files). Show all

Unified · Split

include/linux/usb/typec.h+17−0
@@ -87,6 +87,17 @@ enum typec_orientation { · 86 unmodified lines
8787 TYPEC_ORIENTATION_REVERSE,
8888 };
8989
90+enum usb_mode {
91+ USB_MODE_NONE,
92+ USB_MODE_USB2,
93+ USB_MODE_USB3,
94+ USB_MODE_USB4
95+};
96+
97+#define USB_CAPABILITY_USB2 BIT(0)
98+#define USB_CAPABILITY_USB3 BIT(1)
99+#define USB_CAPABILITY_USB4 BIT(2)
100+
90101 /*
91102 * struct enter_usb_data - Enter_USB Message details
92103 * @eudo: Enter_USB Data Object
@@ -240,6 +251,7 @@ struct typec_partner_desc { · 147 unmodified lines
240251 * @port_type_set: Set port type
241252 * @pd_get: Get available USB Power Delivery Capabilities.
242253 * @pd_set: Set USB Power Delivery Capabilities.
254+ * @default_usb_mode_set: USB Mode to be used by default with Enter_USB Message
243255 */
244256 struct typec_operations {
245257 int (*try_role)(struct typec_port *port, int role);
@@ -250,6 +262,7 @@ struct typec_operations { · 4 unmodified lines
250262 enum typec_port_type type);
251263 struct usb_power_delivery **(*pd_get)(struct typec_port *port);
252264 int (*pd_set)(struct typec_port *port, struct usb_power_delivery *pd);
265+ int (*default_usb_mode_set)(struct typec_port *port, enum usb_mode mode);
253266 };
254267
255268 enum usb_pd_svdm_ver {
@@ -267,6 +280,7 @@ enum usb_pd_svdm_ver { · 11 unmodified lines
267280 * @svdm_version: USB PD Structured VDM version if supported
268281 * @prefer_role: Initial role preference (DRP ports).
269282 * @accessory: Supported Accessory Modes
283+ * @usb_capability: Supported USB Modes
270284 * @fwnode: Optional fwnode of the port
271285 * @driver_data: Private pointer for driver specific info
272286 * @pd: Optional USB Power Delivery Support
@@ -283,6 +297,7 @@ struct typec_capability { · 10 unmodified lines
283297 int prefer_role;
284298 enum typec_accessory accessory[TYPEC_MAX_ACCESSORY];
285299 unsigned int orientation_aware:1;
300+ u8 usb_capability;
286301
287302 struct fwnode_handle *fwnode;
288303 void *driver_data;
@@ -350,6 +365,8 @@ int typec_port_set_usb_power_delivery(struct typec_port *port, struct usb_power_ · 61 unmodified lines
350365 int typec_partner_set_usb_power_delivery(struct typec_partner *partner,
351366 struct usb_power_delivery *pd);
352367
368+void typec_port_set_usb_mode(struct typec_port *port, enum usb_mode mode);
369+
353370 /**
354371 * struct typec_connector - Representation of Type-C port for external drivers
355372 * @attach: notification about device removal