hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/usb/typec.h
....@@ -4,11 +4,15 @@
44 #define __LINUX_USB_TYPEC_H
55
66 #include <linux/types.h>
7
+#include <linux/android_kabi.h>
78
89 /* USB Type-C Specification releases */
910 #define USB_TYPEC_REV_1_0 0x100 /* 1.0 */
1011 #define USB_TYPEC_REV_1_1 0x110 /* 1.1 */
1112 #define USB_TYPEC_REV_1_2 0x120 /* 1.2 */
13
+#define USB_TYPEC_REV_1_3 0x130 /* 1.3 */
14
+#define USB_TYPEC_REV_1_4 0x140 /* 1.4 */
15
+#define USB_TYPEC_REV_2_0 0x200 /* 2.0 */
1216
1317 struct typec_partner;
1418 struct typec_cable;
....@@ -71,11 +75,25 @@
7175 };
7276
7377 /*
78
+ * struct enter_usb_data - Enter_USB Message details
79
+ * @eudo: Enter_USB Data Object
80
+ * @active_link_training: Active Cable Plug Link Training
81
+ *
82
+ * @active_link_training is a flag that should be set with uni-directional SBRX
83
+ * communication, and left 0 with passive cables and with bi-directional SBRX
84
+ * communication.
85
+ */
86
+struct enter_usb_data {
87
+ u32 eudo;
88
+ unsigned char active_link_training:1;
89
+};
90
+
91
+/*
7492 * struct usb_pd_identity - USB Power Delivery identity data
7593 * @id_header: ID Header VDO
7694 * @cert_stat: Cert Stat VDO
7795 * @product: Product VDO
78
- * @product_type: Product type VDO
96
+ * @vdo: Product Type Specific VDOs
7997 *
8098 * USB power delivery Discover Identity command response data.
8199 *
....@@ -86,7 +104,7 @@
86104 u32 id_header;
87105 u32 cert_stat;
88106 u32 product;
89
- u32 product_type;
107
+ u32 vdo[3];
90108 };
91109
92110 int typec_partner_set_identity(struct typec_partner *partner);
....@@ -110,9 +128,12 @@
110128 enum typec_port_data roles;
111129 };
112130
131
+void typec_partner_set_pd_revision(struct typec_partner *partner, u16 pd_revision);
132
+int typec_partner_set_num_altmodes(struct typec_partner *partner, int num_altmodes);
113133 struct typec_altmode
114134 *typec_partner_register_altmode(struct typec_partner *partner,
115135 const struct typec_altmode_desc *desc);
136
+int typec_plug_set_num_altmodes(struct typec_plug *plug, int num_altmodes);
116137 struct typec_altmode
117138 *typec_plug_register_altmode(struct typec_plug *plug,
118139 const struct typec_altmode_desc *desc);
....@@ -120,9 +141,17 @@
120141 *typec_port_register_altmode(struct typec_port *port,
121142 const struct typec_altmode_desc *desc);
122143
144
+#ifdef CONFIG_NO_GKI
123145 void typec_port_register_altmodes(struct typec_port *port,
124146 const struct typec_altmode_ops *ops, void *drvdata,
125147 struct typec_altmode **altmodes, size_t n);
148
+#else
149
+static inline void typec_port_register_altmodes(struct typec_port *port,
150
+ const struct typec_altmode_ops *ops, void *drvdata,
151
+ struct typec_altmode **altmodes, size_t n)
152
+{
153
+}
154
+#endif
126155
127156 void typec_unregister_altmode(struct typec_altmode *altmode);
128157
....@@ -151,6 +180,7 @@
151180 * @type: The plug type from USB PD Cable VDO
152181 * @active: Is the cable active or passive
153182 * @identity: Result of Discover Identity command
183
+ * @pd_revision: USB Power Delivery Specification revision if supported
154184 *
155185 * Represents USB Type-C Cable attached to USB Type-C port.
156186 */
....@@ -158,6 +188,8 @@
158188 enum typec_plug_type type;
159189 unsigned int active:1;
160190 struct usb_pd_identity *identity;
191
+ u16 pd_revision; /* 0300H = "3.0" */
192
+
161193 };
162194
163195 /*
....@@ -165,15 +197,46 @@
165197 * @usb_pd: USB Power Delivery support
166198 * @accessory: Audio, Debug or none.
167199 * @identity: Discover Identity command data
200
+ * @pd_revision: USB Power Delivery Specification Revision if supported
168201 *
169202 * Details about a partner that is attached to USB Type-C port. If @identity
170203 * member exists when partner is registered, a directory named "identity" is
171204 * created to sysfs for the partner device.
205
+ *
206
+ * @pd_revision is based on the setting of the "Specification Revision" field
207
+ * in the message header on the initial "Source Capabilities" message received
208
+ * from the partner, or a "Request" message received from the partner, depending
209
+ * on whether our port is a Sink or a Source.
172210 */
173211 struct typec_partner_desc {
174212 unsigned int usb_pd:1;
175213 enum typec_accessory accessory;
176214 struct usb_pd_identity *identity;
215
+ u16 pd_revision; /* 0300H = "3.0" */
216
+};
217
+
218
+/**
219
+ * struct typec_operations - USB Type-C Port Operations
220
+ * @try_role: Set data role preference for DRP port
221
+ * @dr_set: Set Data Role
222
+ * @pr_set: Set Power Role
223
+ * @vconn_set: Source VCONN
224
+ * @port_type_set: Set port type
225
+ */
226
+struct typec_operations {
227
+ int (*try_role)(struct typec_port *port, int role);
228
+ int (*dr_set)(struct typec_port *port, enum typec_data_role role);
229
+ int (*pr_set)(struct typec_port *port, enum typec_role role);
230
+ int (*vconn_set)(struct typec_port *port, enum typec_role role);
231
+ int (*port_type_set)(struct typec_port *port,
232
+ enum typec_port_type type);
233
+ ANDROID_KABI_RESERVE(1);
234
+};
235
+
236
+enum usb_pd_svdm_ver {
237
+ SVDM_VER_1_0 = 0,
238
+ SVDM_VER_2_0 = 1,
239
+ SVDM_VER_MAX = SVDM_VER_2_0,
177240 };
178241
179242 /*
....@@ -182,16 +245,12 @@
182245 * @data: Supported data role of the port
183246 * @revision: USB Type-C Specification release. Binary coded decimal
184247 * @pd_revision: USB Power Delivery Specification revision if supported
248
+ * @svdm_version: USB PD Structured VDM version if supported
185249 * @prefer_role: Initial role preference (DRP ports).
186250 * @accessory: Supported Accessory Modes
187
- * @sw: Cable plug orientation switch
188
- * @mux: Multiplexer switch for Alternate/Accessory Modes
189251 * @fwnode: Optional fwnode of the port
190
- * @try_role: Set data role preference for DRP port
191
- * @dr_set: Set Data Role
192
- * @pr_set: Set Power Role
193
- * @vconn_set: Set VCONN Role
194
- * @port_type_set: Set port type
252
+ * @driver_data: Private pointer for driver specific info
253
+ * @ops: Port operations vector
195254 *
196255 * Static capabilities of a single USB Type-C port.
197256 */
....@@ -200,24 +259,16 @@
200259 enum typec_port_data data;
201260 u16 revision; /* 0120H = "1.2" */
202261 u16 pd_revision; /* 0300H = "3.0" */
262
+ enum usb_pd_svdm_ver svdm_version;
203263 int prefer_role;
204264 enum typec_accessory accessory[TYPEC_MAX_ACCESSORY];
265
+ unsigned int orientation_aware:1;
205266
206
- struct typec_switch *sw;
207
- struct typec_mux *mux;
208267 struct fwnode_handle *fwnode;
268
+ void *driver_data;
209269
210
- int (*try_role)(const struct typec_capability *,
211
- int role);
212
-
213
- int (*dr_set)(const struct typec_capability *,
214
- enum typec_data_role);
215
- int (*pr_set)(const struct typec_capability *,
216
- enum typec_role);
217
- int (*vconn_set)(const struct typec_capability *,
218
- enum typec_role);
219
- int (*port_type_set)(const struct typec_capability *,
220
- enum typec_port_type);
270
+ const struct typec_operations *ops;
271
+ ANDROID_KABI_RESERVE(1);
221272 };
222273
223274 /* Specific to try_role(). Indicates the user want's to clear the preference. */
....@@ -235,6 +286,10 @@
235286 struct typec_cable_desc *desc);
236287 void typec_unregister_cable(struct typec_cable *cable);
237288
289
+struct typec_cable *typec_cable_get(struct typec_port *port);
290
+void typec_cable_put(struct typec_cable *cable);
291
+int typec_cable_is_active(struct typec_cable *cable);
292
+
238293 struct typec_plug *typec_register_plug(struct typec_cable *cable,
239294 struct typec_plug_desc *desc);
240295 void typec_unregister_plug(struct typec_plug *plug);
....@@ -249,7 +304,15 @@
249304 enum typec_orientation typec_get_orientation(struct typec_port *port);
250305 int typec_set_mode(struct typec_port *port, int mode);
251306
307
+void *typec_get_drvdata(struct typec_port *port);
308
+
309
+int typec_find_pwr_opmode(const char *name);
310
+int typec_find_orientation(const char *name);
252311 int typec_find_port_power_role(const char *name);
253312 int typec_find_power_role(const char *name);
254313 int typec_find_port_data_role(const char *name);
314
+
315
+void typec_partner_set_svdm_version(struct typec_partner *partner,
316
+ enum usb_pd_svdm_ver svdm_version);
317
+int typec_get_negotiated_svdm_version(struct typec_port *port);
255318 #endif /* __LINUX_USB_TYPEC_H */