Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96fe53ef authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Felipe Balbi
Browse files

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: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent ceaa0a6e
Loading
Loading
Loading
Loading
+22 −1
Original line number Original line Diff line number Diff line
@@ -622,6 +622,7 @@ static void disable_controller(struct r8a66597 *r8a66597)
{
{
	if (r8a66597->pdata->on_chip) {
	if (r8a66597->pdata->on_chip) {
		r8a66597_bset(r8a66597, SCKE, SYSCFG0);
		r8a66597_bset(r8a66597, SCKE, SYSCFG0);
		r8a66597_bclr(r8a66597, UTST, TESTMODE);


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


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


static void set_feature(struct r8a66597 *r8a66597, struct usb_ctrlrequest *ctrl)
static void set_feature(struct r8a66597 *r8a66597, struct usb_ctrlrequest *ctrl)
{
{
	u16 tmp;
	int timeout = 3000;


	switch (ctrl->bRequestType & USB_RECIP_MASK) {
	switch (ctrl->bRequestType & USB_RECIP_MASK) {
	case USB_RECIP_DEVICE:
	case USB_RECIP_DEVICE:
		switch (le16_to_cpu(ctrl->wValue)) {
		case USB_DEVICE_TEST_MODE:
			control_end(r8a66597, 1);
			control_end(r8a66597, 1);
			/* Wait for the completion of status stage */
			do {
				tmp = r8a66597_read(r8a66597, INTSTS0) & CTSQ;
				udelay(1);
			} while (tmp != CS_IDST || timeout-- > 0);

			if (tmp == CS_IDST)
				r8a66597_bset(r8a66597,
					      le16_to_cpu(ctrl->wIndex >> 8),
					      TESTMODE);
			break;
		default:
			pipe_stall(r8a66597, 0);
			break;
		}
		break;
		break;
	case USB_RECIP_INTERFACE:
	case USB_RECIP_INTERFACE:
		control_end(r8a66597, 1);
		control_end(r8a66597, 1);