Skip to content

Commit 96fe53e

Browse files
shimodayFelipe Balbi
authored andcommitted
usb: gadget: r8a66597-udc: add support for TEST_MODE
The USB high speed device must support the TEST_MODE, but the driver didn't support it. When we sent the SET_FEATURE for TEST_MODE to the driver, the request was successful, but the module didn't enter the TEST_MODE. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
1 parent ceaa0a6 commit 96fe53e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

drivers/usb/gadget/r8a66597-udc.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ static void disable_controller(struct r8a66597 *r8a66597)
622622
{
623623
if (r8a66597->pdata->on_chip) {
624624
r8a66597_bset(r8a66597, SCKE, SYSCFG0);
625+
r8a66597_bclr(r8a66597, UTST, TESTMODE);
625626

626627
/* disable interrupts */
627628
r8a66597_write(r8a66597, 0, INTENB0);
@@ -639,6 +640,7 @@ static void disable_controller(struct r8a66597 *r8a66597)
639640
r8a66597_bclr(r8a66597, SCKE, SYSCFG0);
640641

641642
} else {
643+
r8a66597_bclr(r8a66597, UTST, TESTMODE);
642644
r8a66597_bclr(r8a66597, SCKE, SYSCFG0);
643645
udelay(1);
644646
r8a66597_bclr(r8a66597, PLLC, SYSCFG0);
@@ -1003,10 +1005,29 @@ static void clear_feature(struct r8a66597 *r8a66597,
10031005

10041006
static void set_feature(struct r8a66597 *r8a66597, struct usb_ctrlrequest *ctrl)
10051007
{
1008+
u16 tmp;
1009+
int timeout = 3000;
10061010

10071011
switch (ctrl->bRequestType & USB_RECIP_MASK) {
10081012
case USB_RECIP_DEVICE:
1009-
control_end(r8a66597, 1);
1013+
switch (le16_to_cpu(ctrl->wValue)) {
1014+
case USB_DEVICE_TEST_MODE:
1015+
control_end(r8a66597, 1);
1016+
/* Wait for the completion of status stage */
1017+
do {
1018+
tmp = r8a66597_read(r8a66597, INTSTS0) & CTSQ;
1019+
udelay(1);
1020+
} while (tmp != CS_IDST || timeout-- > 0);
1021+
1022+
if (tmp == CS_IDST)
1023+
r8a66597_bset(r8a66597,
1024+
le16_to_cpu(ctrl->wIndex >> 8),
1025+
TESTMODE);
1026+
break;
1027+
default:
1028+
pipe_stall(r8a66597, 0);
1029+
break;
1030+
}
10101031
break;
10111032
case USB_RECIP_INTERFACE:
10121033
control_end(r8a66597, 1);

0 commit comments

Comments
 (0)