From 1402207cdb93a0f12ef5b544184c17b35d4ffd12 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 17 Jun 2014 10:47:30 +0200
Subject: [PATCH 9/9] at91 udc: force full speed

Some WRS speciments won't work correctly with automatic speed setup.
This patch forces full-speed on the device (instead of the
autodetected high-speed), and thus they work.

Speed is not a problem anyways, because it is just a serial port.

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
---
 drivers/usb/gadget/atmel_usba_udc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index e7c65a4..bd6ccfb 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -1158,12 +1158,12 @@ static int do_test_mode(struct usba_udc *udc)
 		break;
 	case 0x0300:
 		/*
-		 * Test_SE0_NAK: Force high-speed mode and set up ep0
+		 * Test_SE0_NAK: Force full-speed mode and set up ep0
 		 * for Bulk IN transfers
 		 */
 		ep = &usba_ep[0];
 		usba_writel(udc, TST,
-				USBA_BF(SPEED_CFG, USBA_SPEED_CFG_FORCE_HIGH));
+				USBA_BF(SPEED_CFG, USBA_SPEED_CFG_FORCE_FULL));
 		usba_ep_writel(ep, CFG,
 				USBA_BF(EPT_SIZE, USBA_EPT_SIZE_64)
 				| USBA_EPT_DIR_IN
@@ -1832,6 +1832,9 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
 		toggle_bias(1);
 		usba_writel(udc, CTRL, USBA_ENABLE_MASK);
 		usba_writel(udc, INT_ENB, USBA_END_OF_RESET);
+		/* Also, force full spedd or sometimes it won't work on WRS */
+		usba_writel(udc, TST,
+			    USBA_BF(SPEED_CFG, USBA_SPEED_CFG_FORCE_FULL));
 	}
 	spin_unlock_irqrestore(&udc->lock, flags);
 
-- 
1.7.7.2

