[U-Boot] [PATCH V3 06/20] usb: gadget: mv_udc: fix hardware udc address for i.MX6

Troy Kisky troy.kisky at boundarydevices.com
Fri Aug 2 01:27:23 CEST 2013


The hcor for i.MX6 is 02184340
and the udc should be 02184140

Signed-off-by: Troy Kisky <troy.kisky at boundarydevices.com>

---
I don't know if this is a correct fix, please check carefully.
---
 drivers/usb/gadget/mv_udc.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/mv_udc.c b/drivers/usb/gadget/mv_udc.c
index 7574e31..359b8e1 100644
--- a/drivers/usb/gadget/mv_udc.c
+++ b/drivers/usb/gadget/mv_udc.c
@@ -110,6 +110,16 @@ static struct mv_drv controller = {
 	},
 };
 
+struct mv_udc *get_mv_udc(void)
+{
+#ifdef CONFIG_MXC_USB_PORT
+	return (struct mv_udc *)((unsigned)controller.ctrl->hcor
+			- (0x200 * CONFIG_MXC_USB_PORT));
+#else
+	return (struct mv_udc *)controller.ctrl->hcor;
+#endif
+}
+
 /**
  * mv_get_qh() - return queue head for endpoint
  * @ep_num:	Endpoint number
@@ -213,7 +223,7 @@ static void mv_ep_free_request(struct usb_ep *ep, struct usb_request *_req)
 static void ep_enable(int num, int in)
 {
 	struct ept_queue_head *head;
-	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
+	struct mv_udc *udc = get_mv_udc();
 	unsigned n;
 	head = mv_get_qh(num, in);
 
@@ -316,7 +326,7 @@ static int mv_ep_queue(struct usb_ep *ep,
 		struct usb_request *req, gfp_t gfp_flags)
 {
 	struct mv_ep *mv_ep = container_of(ep, struct mv_ep, ep);
-	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
+	struct mv_udc *udc = get_mv_udc();
 	struct ept_queue_item *item;
 	struct ept_queue_head *head;
 	int bit, num, len, in, ret;
@@ -389,7 +399,7 @@ static void handle_ep_complete(struct mv_ep *ep)
 static void handle_setup(void)
 {
 	struct usb_request *req = &controller.ep[0].req;
-	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
+	struct mv_udc *udc = get_mv_udc();
 	struct ept_queue_head *head;
 	struct usb_ctrlrequest r;
 	int status = 0;
@@ -462,7 +472,7 @@ static void stop_activity(void)
 {
 	int i, num, in;
 	struct ept_queue_head *head;
-	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
+	struct mv_udc *udc = get_mv_udc();
 	writel(readl(&udc->epcomp), &udc->epcomp);
 	writel(readl(&udc->epstat), &udc->epstat);
 	writel(0xffffffff, &udc->epflush);
@@ -485,7 +495,7 @@ static void stop_activity(void)
 
 void udc_irq(void)
 {
-	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
+	struct mv_udc *udc = get_mv_udc();
 	unsigned n = readl(&udc->usbsts);
 	writel(n, &udc->usbsts);
 	int bit, i, num, in;
@@ -543,7 +553,7 @@ void udc_irq(void)
 int usb_gadget_handle_interrupts(void)
 {
 	u32 value;
-	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
+	struct mv_udc *udc = get_mv_udc();
 
 	value = readl(&udc->usbsts);
 	if (value)
@@ -554,7 +564,7 @@ int usb_gadget_handle_interrupts(void)
 
 static int mv_pullup(struct usb_gadget *gadget, int is_on)
 {
-	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
+	struct mv_udc *udc = get_mv_udc();
 	if (is_on) {
 		/* RESET */
 		writel(USBCMD_ITC(MICRO_8FRAME) | USBCMD_RST, &udc->usbcmd);
@@ -582,7 +592,7 @@ static int mv_pullup(struct usb_gadget *gadget, int is_on)
 
 void udc_disconnect(void)
 {
-	struct mv_udc *udc = (struct mv_udc *)controller.ctrl->hcor;
+	struct mv_udc *udc = get_mv_udc();
 	/* disable pullup */
 	stop_activity();
 	writel(USBCMD_FS2, &udc->usbcmd);
@@ -694,7 +704,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
 
 	ret = mvudc_probe();
 	if (!ret) {
-		udc = (struct mv_udc *)controller.ctrl->hcor;
+		udc = get_mv_udc();
 
 		/* select ULPI phy */
 		writel(PTS(PTS_ENABLE) | PFSC, &udc->portsc);
-- 
1.8.1.2



More information about the U-Boot mailing list