mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] USB i.MX: Add chipidea gadget support
Date: Thu, 14 Feb 2013 10:09:25 +0100	[thread overview]
Message-ID: <1360832965-7378-1-git-send-email-s.hauer@pengutronix.de> (raw)

This adds USB gadget support to the i.MX chipidea driver. Basically
we have to add a register function to the fsl udc driver and call
this from the chipidea driver if device mode is selected.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/gadget/fsl_udc.c   |   11 +++++++++--
 drivers/usb/imx/chipidea-imx.c |    6 ++----
 include/usb/fsl_usb2.h         |    6 ++++++
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/gadget/fsl_udc.c b/drivers/usb/gadget/fsl_udc.c
index 0a7c3ae..968c58f 100644
--- a/drivers/usb/gadget/fsl_udc.c
+++ b/drivers/usb/gadget/fsl_udc.c
@@ -2257,7 +2257,7 @@ static struct poller_struct poller = {
 	.func		= fsl_udc_poller
 };
 
-static int fsl_udc_probe(struct device_d *dev)
+int ci_udc_register(struct device_d *dev, void __iomem *regs)
 {
 	int ret, i;
 	u32 dccparams;
@@ -2265,7 +2265,7 @@ static int fsl_udc_probe(struct device_d *dev)
 	udc_controller = xzalloc(sizeof(*udc_controller));
 	udc_controller->stopped = 1;
 
-	dr_regs = dev_request_mem_region(dev, 0);
+	dr_regs = regs;
 
 	/* Read Device Controller Capability Parameters register */
 	dccparams = readl(&dr_regs->dccparams);
@@ -2326,6 +2326,13 @@ err_out:
 	return ret;
 }
 
+static int fsl_udc_probe(struct device_d *dev)
+{
+	void __iomem *regs = dev_request_mem_region(dev, 0);
+
+	return ci_udc_register(dev, regs);
+}
+
 static struct driver_d fsl_udc_driver = {
         .name   = "fsl-udc",
         .probe  = fsl_udc_probe,
diff --git a/drivers/usb/imx/chipidea-imx.c b/drivers/usb/imx/chipidea-imx.c
index de80c36..ec4db27 100644
--- a/drivers/usb/imx/chipidea-imx.c
+++ b/drivers/usb/imx/chipidea-imx.c
@@ -19,6 +19,7 @@
 #include <usb/ehci.h>
 #include <usb/chipidea-imx.h>
 #include <usb/ulpi.h>
+#include <usb/fsl_usb2.h>
 
 #define MXC_EHCI_PORTSC_MASK ((0xf << 28) | (1 << 25))
 
@@ -99,10 +100,7 @@ static int imx_chipidea_probe(struct device_d *dev)
 	if (pdata->mode == IMX_USB_MODE_HOST) {
 		ret = ehci_register(dev, &data);
 	} else {
-		/*
-		 * Not yet implemented. Register USB gadget driver here.
-		 */
-		ret = -ENOSYS;
+		ret = ci_udc_register(dev, base);
 	}
 
 	return ret;
diff --git a/include/usb/fsl_usb2.h b/include/usb/fsl_usb2.h
index fd37ade..dec3933 100644
--- a/include/usb/fsl_usb2.h
+++ b/include/usb/fsl_usb2.h
@@ -1,3 +1,6 @@
+#ifndef __USB_FSL_USB2_H
+#define __USB_FSL_USB2_H
+
 enum fsl_usb2_operating_modes {
 	FSL_USB2_MPH_HOST,
 	FSL_USB2_DR_HOST,
@@ -20,3 +23,6 @@ struct fsl_usb2_platform_data {
 	unsigned int			port_enables;
 };
 
+int ci_udc_register(struct device_d *dev, void __iomem *regs);
+
+#endif /* __USB_FSL_USB2_H */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2013-02-14  9:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360832965-7378-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox