hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/drivers/usb/mtu3/mtu3.h
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: GPL-2.0
1
+/* SPDX-License-Identifier: GPL-2.0 */
22 /*
33 * mtu3.h - MediaTek USB3 DRD header
44 *
....@@ -61,6 +61,15 @@
6161
6262 #define MTU3_U3_IP_SLOT_DEFAULT 2
6363 #define MTU3_U2_IP_SLOT_DEFAULT 1
64
+
65
+/**
66
+ * IP TRUNK version
67
+ * from 0x1003 version, USB3 Gen2 is supported, two changes affect driver:
68
+ * 1. MAXPKT and MULTI bits layout of TXCSR1 and RXCSR1 are adjusted,
69
+ * but not backward compatible
70
+ * 2. QMU extend buffer length supported
71
+ */
72
+#define MTU3_TRUNK_VERS_1003 0x1003
6473
6574 /**
6675 * Normally the device works on HS or SS, to simplify fifo management,
....@@ -135,45 +144,33 @@
135144 * The format of TX GPD is a little different from RX one.
136145 * And the size of GPD is 16 bytes.
137146 *
138
- * @flag:
147
+ * @dw0_info:
139148 * bit0: Hardware Own (HWO)
140149 * bit1: Buffer Descriptor Present (BDP), always 0, BD is not supported
141150 * bit2: Bypass (BPS), 1: HW skips this GPD if HWO = 1
151
+ * bit6: [EL] Zero Length Packet (ZLP), moved from @dw3_info[29]
142152 * bit7: Interrupt On Completion (IOC)
143
- * @chksum: This is used to validate the contents of this GPD;
144
- * If TXQ_CS_EN / RXQ_CS_EN bit is set, an interrupt is issued
145
- * when checksum validation fails;
146
- * Checksum value is calculated over the 16 bytes of the GPD by default;
147
- * @data_buf_len (RX ONLY): This value indicates the length of
148
- * the assigned data buffer
149
- * @tx_ext_addr (TX ONLY): [3:0] are 4 extension bits of @buffer,
150
- * [7:4] are 4 extension bits of @next_gpd
153
+ * bit[31:16]: ([EL] bit[31:12]) allow data buffer length (RX ONLY),
154
+ * the buffer length of the data to receive
155
+ * bit[23:16]: ([EL] bit[31:24]) extension address (TX ONLY),
156
+ * lower 4 bits are extension bits of @buffer,
157
+ * upper 4 bits are extension bits of @next_gpd
151158 * @next_gpd: Physical address of the next GPD
152159 * @buffer: Physical address of the data buffer
153
- * @buf_len:
154
- * (TX): This value indicates the length of the assigned data buffer
155
- * (RX): The total length of data received
156
- * @ext_len: reserved
157
- * @rx_ext_addr(RX ONLY): [3:0] are 4 extension bits of @buffer,
158
- * [7:4] are 4 extension bits of @next_gpd
159
- * @ext_flag:
160
- * bit5 (TX ONLY): Zero Length Packet (ZLP),
160
+ * @dw3_info:
161
+ * bit[15:0]: ([EL] bit[19:0]) data buffer length,
162
+ * (TX): the buffer length of the data to transmit
163
+ * (RX): The total length of data received
164
+ * bit[23:16]: ([EL] bit[31:24]) extension address (RX ONLY),
165
+ * lower 4 bits are extension bits of @buffer,
166
+ * upper 4 bits are extension bits of @next_gpd
167
+ * bit29: ([EL] abandoned) Zero Length Packet (ZLP) (TX ONLY)
161168 */
162169 struct qmu_gpd {
163
- __u8 flag;
164
- __u8 chksum;
165
- union {
166
- __le16 data_buf_len;
167
- __le16 tx_ext_addr;
168
- };
170
+ __le32 dw0_info;
169171 __le32 next_gpd;
170172 __le32 buffer;
171
- __le16 buf_len;
172
- union {
173
- __u8 ext_len;
174
- __u8 rx_ext_addr;
175
- };
176
- __u8 ext_flag;
173
+ __le32 dw3_info;
177174 } __packed;
178175
179176 /**
....@@ -202,6 +199,9 @@
202199 * @id_nb : notifier for iddig(idpin) detection
203200 * @id_work : work of iddig detection notifier
204201 * @id_event : event of iddig detecion notifier
202
+* @role_sw : use USB Role Switch to support dual-role switch, can't use
203
+* extcon at the same time, and extcon is deprecated.
204
+* @role_sw_used : true when the USB Role Switch is used.
205205 * @is_u3_drd: whether port0 supports usb3.0 dual-role device or not
206206 * @manual_drd_enabled: it's true when supports dual-role device by debugfs
207207 * to switch host/device modes depending on user input.
....@@ -215,6 +215,8 @@
215215 struct notifier_block id_nb;
216216 struct work_struct id_work;
217217 unsigned long id_event;
218
+ struct usb_role_switch *role_sw;
219
+ bool role_sw_used;
218220 bool is_u3_drd;
219221 bool manual_drd_enabled;
220222 };
....@@ -291,8 +293,6 @@
291293 const struct usb_endpoint_descriptor *desc;
292294
293295 int flags;
294
- u8 wedged;
295
- u8 busy;
296296 };
297297
298298 struct mtu3_request {
....@@ -316,6 +316,7 @@
316316 * @may_wakeup: means device's remote wakeup is enabled
317317 * @is_self_powered: is reported in device status and the config descriptor
318318 * @delayed_status: true when function drivers ask for delayed status
319
+ * @gen2cp: compatible with USB3 Gen2 IP
319320 * @ep0_req: dummy request used while handling standard USB requests
320321 * for GET_STATUS and SET_SEL
321322 * @setup_buf: ep0 response buffer for GET_STATUS and SET_SEL requests
....@@ -345,7 +346,8 @@
345346 struct usb_gadget_driver *gadget_driver;
346347 struct mtu3_request ep0_req;
347348 u8 setup_buf[EP0_RESPONSE_BUF];
348
- u32 max_speed;
349
+ enum usb_device_speed max_speed;
350
+ enum usb_device_speed speed;
349351
350352 unsigned is_active:1;
351353 unsigned may_wakeup:1;
....@@ -356,6 +358,7 @@
356358 unsigned u2_enable:1;
357359 unsigned is_u3_ip:1;
358360 unsigned delayed_status:1;
361
+ unsigned gen2cp:1;
359362
360363 u8 address;
361364 u8 test_mode_nr;
....@@ -365,12 +368,6 @@
365368 static inline struct mtu3 *gadget_to_mtu3(struct usb_gadget *g)
366369 {
367370 return container_of(g, struct mtu3, g);
368
-}
369
-
370
-static inline int is_first_entry(const struct list_head *list,
371
- const struct list_head *head)
372
-{
373
- return list_is_last(head, list);
374371 }
375372
376373 static inline struct mtu3_request *to_mtu3_request(struct usb_request *req)
....@@ -429,6 +426,7 @@
429426 void mtu3_start(struct mtu3 *mtu);
430427 void mtu3_stop(struct mtu3 *mtu);
431428 void mtu3_dev_on_off(struct mtu3 *mtu, int is_on);
429
+void mtu3_set_speed(struct mtu3 *mtu, enum usb_device_speed speed);
432430
433431 int mtu3_gadget_setup(struct mtu3 *mtu);
434432 void mtu3_gadget_cleanup(struct mtu3 *mtu);