public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] usb: ci_udc: Fix set address to work with older controllers
@ 2015-02-24 16:44 Alban Bedel
  2015-02-24 16:44 ` [U-Boot] [PATCH 2/3] ARM: tegra: Fix the USB gadget configuration for T20 Alban Bedel
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Alban Bedel @ 2015-02-24 16:44 UTC (permalink / raw)
  To: u-boot

Older controllers don't implement "Device Address Advance" which allow
to pass the device address to the controller when it is received.
To support such controller we need to store the requested address and
only apply it after the next IN transfer completed on EP0.

Signed-off-by: Alban Bedel <alban.bedel@avionic-design.de>
---
 drivers/usb/gadget/ci_udc.c | 18 +++++++++++++-----
 drivers/usb/gadget/ci_udc.h |  1 +
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/ci_udc.c b/drivers/usb/gadget/ci_udc.c
index b0ef35e..694745f 100644
--- a/drivers/usb/gadget/ci_udc.c
+++ b/drivers/usb/gadget/ci_udc.c
@@ -523,6 +523,13 @@ static void handle_ep_complete(struct ci_ep *ci_ep)
 
 	DBG("ept%d %s req %p, complete %x\n",
 	    num, in ? "in" : "out", ci_req, len);
+	/* The device address must be applied after the next IN transfer
+	 * completed on ep0. */
+	if (num == 0 && in && controller.set_address) {
+		struct ci_udc *udc = (struct ci_udc *)controller.ctrl->hcor;
+		writel(controller.set_address << 25, &udc->devaddr);
+		controller.set_address = 0;
+	}
 	if (num != 0 || controller.ep0_data_phase)
 		ci_req->req.complete(&ci_ep->ep, &ci_req->req);
 	if (num == 0 && controller.ep0_data_phase) {
@@ -614,11 +621,9 @@ static void handle_setup(void)
 		return;
 
 	case SETUP(USB_RECIP_DEVICE, USB_REQ_SET_ADDRESS):
-		/*
-		 * write address delayed (will take effect
-		 * after the next IN txn)
-		 */
-		writel((r.wValue << 25) | (1 << 24), &udc->devaddr);
+		/* The device address must be updated after the next IN
+		 * request completed */
+		controller.set_address = r.wValue;
 		req->length = 0;
 		usb_ep_queue(controller.gadget.ep0, req, 0);
 		return;
@@ -670,6 +675,9 @@ static void stop_activity(void)
 			ci_flush_qh(num);
 		}
 	}
+
+	/* clear any pending set address */
+	controller.set_address = 0;
 }
 
 void udc_irq(void)
diff --git a/drivers/usb/gadget/ci_udc.h b/drivers/usb/gadget/ci_udc.h
index 346164a..44e70b1 100644
--- a/drivers/usb/gadget/ci_udc.h
+++ b/drivers/usb/gadget/ci_udc.h
@@ -99,6 +99,7 @@ struct ci_drv {
 	struct usb_gadget		gadget;
 	struct ci_req			*ep0_req;
 	bool				ep0_data_phase;
+	uint8_t				set_address;
 	struct usb_gadget_driver	*driver;
 	struct ehci_ctrl		*ctrl;
 	struct ept_queue_head		*epts;
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-02-26 17:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-24 16:44 [U-Boot] [PATCH 1/3] usb: ci_udc: Fix set address to work with older controllers Alban Bedel
2015-02-24 16:44 ` [U-Boot] [PATCH 2/3] ARM: tegra: Fix the USB gadget configuration for T20 Alban Bedel
2015-02-24 16:54   ` Stephen Warren
2015-02-24 17:39     ` Alban Bedel
2015-02-24 16:44 ` [U-Boot] [PATCH 3/3] ARM: tegra: usb gadgets: Allow accessing the NAND via DFU Alban Bedel
2015-02-24 16:56   ` Stephen Warren
2015-02-24 17:37     ` Alban Bedel
2015-02-24 18:49       ` Stephen Warren
2015-02-24 17:00 ` [U-Boot] [PATCH 1/3] usb: ci_udc: Fix set address to work with older controllers Stephen Warren
2015-02-24 17:41   ` Alban Bedel
2015-02-24 19:25     ` Stephen Warren
2015-02-26 17:03       ` Alban Bedel
2015-02-26 17:24         ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox