Skip to content

Commit f3b28e5

Browse files
Chunfeng YunFelipe Balbi
authored andcommitted
usb: mtu3: fix operation failure when test TEST_J/K
There is an error dialog popped up in PC when test TEST_J/K by EHSETT tool, due to not waiting for the completion of control transfer. Here fix it by entering test mode after Status Stage finish. Signed-off-by: Chunfeng Yun <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 11254eb commit f3b28e5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/usb/mtu3/mtu3_gadget_ep0.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Author: Chunfeng.Yun <[email protected]>
88
*/
99

10+
#include <linux/iopoll.h>
1011
#include <linux/usb/composite.h>
1112

1213
#include "mtu3.h"
@@ -263,6 +264,7 @@ static int handle_test_mode(struct mtu3 *mtu, struct usb_ctrlrequest *setup)
263264
{
264265
void __iomem *mbase = mtu->mac_base;
265266
int handled = 1;
267+
u32 value;
266268

267269
switch (le16_to_cpu(setup->wIndex) >> 8) {
268270
case TEST_J:
@@ -292,6 +294,14 @@ static int handle_test_mode(struct mtu3 *mtu, struct usb_ctrlrequest *setup)
292294
if (mtu->test_mode_nr == TEST_PACKET_MODE)
293295
ep0_load_test_packet(mtu);
294296

297+
/* send status before entering test mode. */
298+
value = mtu3_readl(mbase, U3D_EP0CSR) & EP0_W1C_BITS;
299+
mtu3_writel(mbase, U3D_EP0CSR, value | EP0_SETUPPKTRDY | EP0_DATAEND);
300+
301+
/* wait for ACK status sent by host */
302+
readl_poll_timeout(mbase + U3D_EP0CSR, value,
303+
!(value & EP0_DATAEND), 100, 5000);
304+
295305
mtu3_writel(mbase, U3D_USB2_TEST_MODE, mtu->test_mode_nr);
296306

297307
mtu->ep0_state = MU3D_EP0_STATE_SETUP;

0 commit comments

Comments
 (0)