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 1/9] USB ehci: Allow to register independently from device
Date: Thu, 13 Dec 2012 18:00:36 +0100	[thread overview]
Message-ID: <1355418044-27452-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1355418044-27452-1-git-send-email-s.hauer@pengutronix.de>

The EHCI core often is part of a otg core. Allow it to be registered
separately from another driver.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/host/ehci-hcd.c |   46 ++++++++++++++++++++++++++-----------------
 include/usb/ehci.h          |   17 ++++++++++++++--
 2 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index d8814aa..d6083e0 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -807,32 +807,18 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 	return -1;
 }
 
-static int ehci_probe(struct device_d *dev)
+int ehci_register(struct device_d *dev, struct ehci_data *data)
 {
 	struct usb_host *host;
 	struct ehci_priv *ehci;
 	uint32_t reg;
-	struct ehci_platform_data *pdata = dev->platform_data;
 
 	ehci = xzalloc(sizeof(struct ehci_priv));
 	host = &ehci->host;
 	dev->priv = ehci;
-
-	/* default to EHCI_HAS_TT to not change behaviour of boards
-	 * without platform_data
-	 */
-	if (pdata)
-		ehci->flags = pdata->flags;
-	else
-		ehci->flags = EHCI_HAS_TT;
-
-	if (dev->num_resources < 2) {
-		printf("echi: need 2 resources base and data");
-		return -ENODEV;
-	}
-
-	ehci->hccr = dev_request_mem_region(dev, 0);
-	ehci->hcor = dev_request_mem_region(dev, 1);
+	ehci->flags = data->flags;
+	ehci->hccr = data->hccr;
+	ehci->hcor = data->hcor;
 
 	ehci->qh_list = dma_alloc_coherent(sizeof(struct QH) * NUM_TD);
 	ehci->td = dma_alloc_coherent(sizeof(struct qTD) * NUM_TD);
@@ -854,6 +840,30 @@ static int ehci_probe(struct device_d *dev)
 	return 0;
 }
 
+static int ehci_probe(struct device_d *dev)
+{
+	struct ehci_data data;
+	struct ehci_platform_data *pdata = dev->platform_data;
+
+	/* default to EHCI_HAS_TT to not change behaviour of boards
+	 * without platform_data
+	 */
+	if (pdata)
+		data.flags = pdata->flags;
+	else
+		data.flags = EHCI_HAS_TT;
+
+	if (dev->num_resources < 2) {
+		printf("echi: need 2 resources base and data");
+		return -ENODEV;
+	}
+
+	data.hccr = dev_request_mem_region(dev, 0);
+	data.hcor = dev_request_mem_region(dev, 1);
+
+	return ehci_register(dev, &data);
+}
+
 static void ehci_remove(struct device_d *dev)
 {
 	struct ehci_priv *ehci = dev->priv;
diff --git a/include/usb/ehci.h b/include/usb/ehci.h
index 2ec862c..4377116 100644
--- a/include/usb/ehci.h
+++ b/include/usb/ehci.h
@@ -5,8 +5,21 @@
 
 struct ehci_platform_data {
 	unsigned long flags;
-	unsigned long hccr_offset;
-	unsigned long hcor_offset;
 };
 
+struct ehci_data {
+	void __iomem *hccr;
+	void __iomem *hcor;
+	unsigned long flags;
+};
+
+#ifdef CONFIG_USB_EHCI
+int ehci_register(struct device_d *dev, struct ehci_data *data);
+#else
+static inline int ehci_register(struct device_d *dev, struct ehci_data *data)
+{
+	return -ENOSYS;
+}
+#endif
+
 #endif  /* __USB_EHCI_H */
-- 
1.7.10.4


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

  reply	other threads:[~2012-12-13 17:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-13 17:00 [PATCH] i.MX chipidea support Sascha Hauer
2012-12-13 17:00 ` Sascha Hauer [this message]
2012-12-13 17:00 ` [PATCH 2/9] USB i.MX: Add chipidea driver support Sascha Hauer
2012-12-13 17:00 ` [PATCH 3/9] ARM i.MX27: Add USB device functions Sascha Hauer
2012-12-13 17:00 ` [PATCH 4/9] ARM i.MX51: " Sascha Hauer
2012-12-13 17:00 ` [PATCH 5/9] ARM i.MX31: " Sascha Hauer
2012-12-13 17:00 ` [PATCH 6/9] ARM i.MX pcm038: switch to chipidea support Sascha Hauer
2012-12-13 17:00 ` [PATCH 7/9] pcm038: Stop ongoing ULPI transfers before registering the transceiver Sascha Hauer
2012-12-13 17:00 ` [PATCH 8/9] fixup! USB i.MX: Add chipidea driver support Sascha Hauer
2012-12-13 17:00 ` [PATCH 9/9] ARM i.MX pcm038: Update defconfig for chipidea driver Sascha Hauer

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=1355418044-27452-2-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