linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: marex@denx.de (Marek Vasut)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 07/11] MXS: Add separate MXS EHCI HCD driver
Date: Tue, 24 Apr 2012 05:18:39 +0200	[thread overview]
Message-ID: <1335237523-9053-8-git-send-email-marex@denx.de> (raw)
In-Reply-To: <1335237523-9053-1-git-send-email-marex@denx.de>

This driver will handle i.MX233/i.MX28 and I hope soon i.MX6Q. I tried to keep
this separate from the MXC EHCI to avoid further polution of the MXC EHCI,
though eventually these two might be merged.

NOTE: I still haven't figured out how to enable/disable the disconnection
detector, it can't be enabled all the time, so I toggle PHY stuff from this
driver, which I doubt is correct.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Chen Peter-B29397 <B29397@freescale.com>
Cc: Detlev Zundel <dzu@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Li Frank-B20596 <B20596@freescale.com>
Cc: Lin Tony-B19295 <B19295@freescale.com>
Cc: Linux USB <linux-usb@vger.kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Shawn Guo <shawn.guo@freescale.com>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Subodh Nijsure <snijsure@grid-net.com>
Cc: Tony Lin <tony.lin@freescale.com>
Cc: Wolfgang Denk <wd@denx.de>
---
 drivers/usb/host/Kconfig    |    7 ++
 drivers/usb/host/ehci-hcd.c |    5 ++
 drivers/usb/host/ehci-mxs.c |  178 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 190 insertions(+)
 create mode 100644 drivers/usb/host/ehci-mxs.c

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index f788eb8..85ed593 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -148,6 +148,13 @@ config USB_EHCI_MXC
 	---help---
 	  Variation of ARC USB block used in some Freescale chips.
 
+config USB_EHCI_MXS
+	bool "Support for Freescale i.MX28 on-chip EHCI USB controller"
+	depends on USB_EHCI_HCD && ARCH_MXS
+	select USB_EHCI_ROOT_HUB_TT
+	---help---
+	  Enable USB support for i.MX28.
+
 config USB_EHCI_HCD_OMAP
 	bool "EHCI support for OMAP3 and later chips"
 	depends on USB_EHCI_HCD && ARCH_OMAP
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 4a3bc5b..16e161c 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1268,6 +1268,11 @@ MODULE_LICENSE ("GPL");
 #define PLATFORM_DRIVER		ehci_mxc_driver
 #endif
 
+#ifdef CONFIG_USB_EHCI_MXS
+#include "ehci-mxs.c"
+#define PLATFORM_DRIVER		ehci_mxs_driver
+#endif
+
 #ifdef CONFIG_USB_EHCI_SH
 #include "ehci-sh.c"
 #define PLATFORM_DRIVER		ehci_hcd_sh_driver
diff --git a/drivers/usb/host/ehci-mxs.c b/drivers/usb/host/ehci-mxs.c
new file mode 100644
index 0000000..4a696b4
--- /dev/null
+++ b/drivers/usb/host/ehci-mxs.c
@@ -0,0 +1,178 @@
+/*
+ * Freescale i.MX28 EHCI driver
+ *
+ * Copyright (c) 2012 Marek Vasut <marex@denx.de>
+ * on behalf of DENX Software Engineering GmbH
+ *
+ * Based on MXC EHCI driver:
+ *
+ * Copyright (c) 2009 Daniel Mack <daniel@caiaq.de>
+ * Copyright (c) 2008 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/delay.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/ulpi.h>
+#include <linux/slab.h>
+#include <linux/usb/mxs-usb.h>
+
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+#include <mach/mx28.h>
+
+#include <asm/mach-types.h>
+
+/* Called during probe() after chip reset completes */
+static int ehci_mxs_setup(struct usb_hcd *hcd)
+{
+	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+
+	hcd->has_tt = 1;
+	ehci_setup(hcd);
+	ehci_port_power(ehci, 0);
+
+	return 0;
+}
+
+static const struct hc_driver ehci_mxs_hc_driver = {
+	.description	= hcd_name,
+	.product_desc	= "Freescale i.MX On-Chip EHCI Host Controller",
+	.hcd_priv_size	= sizeof(struct ehci_hcd),
+
+	/*
+	 * Generic hardware linkage
+	 */
+	.irq		= ehci_irq,
+	.flags		= HCD_USB2 | HCD_MEMORY,
+
+	/*
+	 * Basic lifecycle operations
+	 */
+	.reset		= ehci_mxs_setup,
+	.start		= ehci_run,
+	.stop		= ehci_stop,
+	.shutdown	= ehci_shutdown,
+
+	/*
+	 * managing i/o requests and associated device resources
+	 */
+	.urb_enqueue		= ehci_urb_enqueue,
+	.urb_dequeue		= ehci_urb_dequeue,
+	.endpoint_disable	= ehci_endpoint_disable,
+	.endpoint_reset		= ehci_endpoint_reset,
+
+	/*
+	 * scheduling support
+	 */
+	.get_frame_number	= ehci_get_frame,
+
+	/*
+	 * root hub support
+	 */
+	.hub_status_data	= ehci_hub_status_data,
+	.hub_control		= ehci_hub_control,
+	.bus_suspend		= ehci_bus_suspend,
+	.bus_resume		= ehci_bus_resume,
+	.relinquish_port	= ehci_relinquish_port,
+	.port_handed_over	= ehci_port_handed_over,
+
+	.clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
+};
+
+static int ehci_mxs_drv_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct imx_otg *data = pdev->dev.platform_data;
+	struct usb_hcd *hcd;
+	struct ehci_hcd *ehci;
+	struct usb_phy *phy;
+	int ret;
+
+	dev_info(dev, "Initializing i.MX USB Controller\n");
+
+	if (!data) {
+		dev_err(dev, "USB Host platform data missing!\n");
+		return -ENODEV;
+	}
+
+	/* This should never fail. */
+	phy = usb_get_transceiver();
+	if (!phy) {
+		dev_err(&pdev->dev, "Unable to find transceiver.\n");
+		return -ENODEV;
+	}
+
+	/* Create HCD controller instance. */
+	hcd = usb_create_hcd(&ehci_mxs_hc_driver, dev, dev_name(dev));
+	if (!hcd) {
+		dev_err(dev, "Failed to create HCD instance!\n");
+		return -ENOMEM;
+	}
+
+	hcd->rsrc_start = data->mem_res->start;
+	hcd->rsrc_len = resource_size(data->mem_res);
+	hcd->regs = data->mem;
+	hcd->irq = data->irq;
+
+	/* Wait for the controller to stabilize. */
+	mdelay(10);
+
+	ehci = hcd_to_ehci(hcd);
+
+	/* EHCI registers start at offset 0x100 */
+	ehci->caps = hcd->regs + 0x100;
+	ehci->regs = hcd->regs + 0x100 +
+		HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
+
+	platform_set_drvdata(pdev, hcd);
+
+	/* Connect this host to the PHY. */
+	ret = otg_set_host(phy->otg, &hcd->self);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Unable to set transceiver host\n");
+		usb_put_hcd(hcd);
+		return -ENODEV;
+	}
+
+	return 0;
+}
+
+static int __exit ehci_mxs_drv_remove(struct platform_device *pdev)
+{
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct usb_phy *phy = usb_get_transceiver();
+
+	if (phy)
+		usb_phy_shutdown(phy);
+
+	usb_remove_hcd(hcd);
+	usb_put_hcd(hcd);
+	platform_set_drvdata(pdev, NULL);
+
+	return 0;
+}
+
+static struct platform_driver ehci_mxs_driver = {
+	.probe		= ehci_mxs_drv_probe,
+	.remove		= __exit_p(ehci_mxs_drv_remove),
+	.driver		= {
+		   .name	= "mxs-ehci",
+	},
+};
+
+MODULE_ALIAS("platform:mxs-ehci");
-- 
1.7.10

  parent reply	other threads:[~2012-04-24  3:18 UTC|newest]

Thread overview: 151+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17 10:15 [RFC PATCH 0/8] MXS: Add i.MX28 USB Host driver Marek Vasut
2012-04-17 10:15 ` [PATCH 1/8] MXS: Make clk_disable return integer Marek Vasut
2012-04-17 10:15 ` [PATCH 2/8] MXS: Add USB EHCI and USB PHY clock handling Marek Vasut
2012-04-17 18:01   ` Sascha Hauer
2012-04-17 10:15 ` [PATCH 3/8] MXS: Fixup i.MX233 USB base address name Marek Vasut
2012-04-17 10:15 ` [PATCH 4/8] MXS: Add platform registration hooks for USB EHCI Marek Vasut
2012-04-17 10:15 ` [PATCH 5/8] MXS: Add USB PHY driver Marek Vasut
2012-04-17 17:51   ` Sascha Hauer
2012-04-19 11:40   ` Arnd Bergmann
2012-04-17 10:15 ` [PATCH 6/8] MXS: Add separate MXS EHCI HCD driver Marek Vasut
2012-04-17 10:15 ` [PATCH 7/8] MXS: Enable USB on M28EVK Marek Vasut
2012-04-17 17:40   ` Sergei Shtylyov
2012-04-17 10:15 ` [PATCH 8/8] MXS: Enable USB on MX28EVK Marek Vasut
2012-04-17 10:37 ` [RFC PATCH 0/8] MXS: Add i.MX28 USB Host driver Dirk Behme
2012-04-17 11:24   ` Marek Vasut
2012-04-18  1:00     ` Chen Peter-B29397
2012-04-17 11:29 ` Sascha Hauer
2012-04-17 11:45   ` Marek Vasut
2012-04-17 12:18     ` Sascha Hauer
2012-04-17 20:29       ` Marek Vasut
2012-04-18  7:02         ` Sascha Hauer
2012-04-18  8:05           ` Chen Peter-B29397
2012-04-17 12:36   ` Heikki Krogerus
2012-04-18  4:31   ` Chen Peter-B29397
2012-04-18  7:40     ` Sascha Hauer
2012-04-20 13:10       ` 答复: " Liu JunJie-B08287
2012-04-20 16:25         ` Marek Vasut
2012-04-23  2:02           ` Liu JunJie-B08287
2012-04-18  2:07 ` [RFC PATCH 00/10 V2] " Marek Vasut
2012-04-18  2:07   ` [PATCH 01/10] MXS: Make clk_disable return integer Marek Vasut
2012-04-18  2:07   ` [PATCH 02/10] MXS: Add USB EHCI and USB PHY clock handling Marek Vasut
2012-04-18  2:07   ` [PATCH 03/10] MXS: Fixup i.MX233 USB base address name Marek Vasut
2012-04-18  2:07   ` [PATCH 04/10] MXS: Add data shared between imx-usb, PHY and EHCI driver Marek Vasut
2012-04-18  2:07   ` [PATCH 05/10] MXS: Add platform registration hooks for USB EHCI Marek Vasut
2012-04-18  2:07   ` [PATCH 06/10] MXS: Add composite imx-usb driver Marek Vasut
2012-04-18  2:07   ` [PATCH 07/10] MXS: Add USB PHY driver Marek Vasut
2012-04-18  2:07   ` [PATCH 08/10] MXS: Add separate MXS EHCI HCD driver Marek Vasut
2012-04-18  7:01     ` Chen Peter-B29397
2012-04-18  8:40       ` Sascha Hauer
2012-04-18  9:18         ` Chen Peter-B29397
2012-04-18  9:45           ` Sascha Hauer
2012-04-19  2:54             ` Chen Peter-B29397
2012-04-19  6:34               ` Sascha Hauer
2012-04-18  2:07   ` [PATCH 09/10] MXS: Enable USB on M28EVK Marek Vasut
2012-04-18 12:08     ` Sergei Shtylyov
2012-04-18 12:24       ` Marek Vasut
2012-04-18  2:07   ` [PATCH 10/10] MXS: Enable USB on MX28EVK Marek Vasut
2012-04-18  2:09   ` [RFC PATCH 00/10 V2] MXS: Add i.MX28 USB Host driver Marek Vasut
2012-04-18  7:52   ` Chen Peter-B29397
2012-04-18 17:49     ` Marek Vasut
2012-04-19  2:37       ` Chen Peter-B29397
2012-04-18 17:46   ` [RFC PATCH 00/10 V3] " Marek Vasut
2012-04-18 17:46     ` [PATCH 01/10] MXS: Make clk_disable return integer Marek Vasut
2012-04-18 17:46     ` [PATCH 02/10] MXS: Add USB EHCI and USB PHY clock handling Marek Vasut
2012-04-18 17:46     ` [PATCH 03/10] MXS: Fixup i.MX233 USB base address name Marek Vasut
2012-04-18 17:46     ` [PATCH 04/10] MXS: Add data shared between imx-usb and EHCI driver Marek Vasut
2012-04-18 17:46     ` [PATCH 05/10] MXS: Add platform registration hooks for USB EHCI Marek Vasut
2012-04-19 11:51       ` Arnd Bergmann
2012-04-19 14:24         ` Shawn Guo
2012-04-19 21:32           ` Marek Vasut
2012-04-20  0:40             ` Shawn Guo
2012-04-20  0:56               ` Marek Vasut
2012-04-20  1:34                 ` Shawn Guo
2012-04-20  1:40                   ` Marek Vasut
2012-04-18 17:46     ` [PATCH 06/10] MXS: Add imx-usb driver Marek Vasut
2012-04-18 17:46     ` [PATCH 07/10] MXS: Add USB PHY driver Marek Vasut
2012-04-18 19:36       ` Sascha Hauer
2012-04-18 20:02         ` Marek Vasut
2012-04-18 20:16           ` Sascha Hauer
2012-04-19 22:06             ` Marek Vasut
2012-04-20  2:35               ` Chen Peter-B29397
2012-04-18 17:46     ` [PATCH 08/10] MXS: Add separate MXS EHCI HCD driver Marek Vasut
2012-04-18 19:50       ` Sascha Hauer
2012-04-18 20:07         ` Marek Vasut
2012-04-18 20:43           ` Sascha Hauer
2012-04-18 17:46     ` [PATCH 09/10] MXS: Enable USB on M28EVK Marek Vasut
2012-04-18 17:46     ` [PATCH 10/10] MXS: Enable USB on MX28EVK Marek Vasut
2012-04-20  2:13     ` [RFC PATCH 00/10 V3] MXS: Add i.MX28 USB Host driver Marek Vasut
2012-04-20  9:48       ` Sascha Hauer
2012-04-20 12:26         ` Peter Chen
2012-04-20 12:44           ` Marek Vasut
2012-04-20 13:00             ` Robert Schwebel
2012-04-20 13:26             ` Sascha Hauer
2012-04-20 16:36               ` Michael Grzeschik
2012-04-21  7:42                 ` Peter Chen
2012-04-21  8:17                   ` Sascha Hauer
2012-04-21 13:53     ` Subodh Nijsure
2012-04-21 15:37       ` Marek Vasut
2012-04-22 12:59     ` [RFC PATCH 00/11 V4] " Marek Vasut
2012-04-22 12:59       ` [PATCH 01/11] MXS: Make clk_disable return integer Marek Vasut
2012-04-22 12:59       ` [PATCH 02/11] MXS: Add USB EHCI and USB PHY clock handling Marek Vasut
2012-04-22 14:42         ` Shawn Guo
2012-04-22 15:42           ` Marek Vasut
2012-04-22 16:34             ` Shawn Guo
2012-04-22 12:59       ` [PATCH 03/11] MXS: Fixup i.MX233 USB base address name Marek Vasut
2012-04-22 12:59       ` [PATCH 04/11] MXS: Add data shared between imx-otg and EHCI driver Marek Vasut
2012-04-22 14:39         ` Shawn Guo
2012-04-22 15:42           ` Marek Vasut
2012-04-22 16:38             ` Shawn Guo
2012-04-22 12:59       ` [PATCH 05/11] MXS: Modify the ci13xxx_udc to avoid adding UDC Marek Vasut
2012-04-22 12:59       ` [PATCH 06/11] MXS: Add small registration glue for ci13xxx_udc Marek Vasut
2012-04-23  1:46         ` Chen Peter-B29397
2012-04-22 12:59       ` [PATCH 07/11] MXS: Add separate MXS EHCI HCD driver Marek Vasut
2012-04-23  1:44         ` Chen Peter-B29397
2012-04-23  2:11           ` Marek Vasut
2012-04-22 12:59       ` [PATCH 08/11] MXS: Add imx-otg driver Marek Vasut
2012-04-23  6:39         ` Sascha Hauer
2012-04-23  9:38           ` Marek Vasut
2012-04-22 12:59       ` [PATCH 09/11] MXS: Add USB PHY driver Marek Vasut
2012-04-23  1:42         ` Chen Peter-B29397
2012-04-23  2:17           ` Marek Vasut
2012-04-23 12:20             ` Chen Peter-B29397
2012-04-22 12:59       ` [PATCH 10/11] MXS: Add platform registration hooks for USB EHCI Marek Vasut
2012-04-22 12:59       ` [PATCH 11/11] MXS: Enable USB on M28EVK Marek Vasut
2012-04-23  1:57         ` Chen Peter-B29397
2012-04-23  2:18           ` Marek Vasut
2012-04-23  2:01       ` [RFC PATCH 00/11 V4] MXS: Add i.MX28 USB Host driver Chen Peter-B29397
2012-04-23  2:18         ` Marek Vasut
2012-04-23 11:59           ` Chen Peter-B29397
2012-04-23 12:09             ` Marek Vasut
2012-04-23 12:25               ` Chen Peter-B29397
2012-04-23 12:40                 ` Marek Vasut
2012-04-23  2:37         ` Marek Vasut
2012-04-24  3:18       ` [RFC PATCH 00/11 V5] " Marek Vasut
2012-04-24  3:18         ` [PATCH 01/11] MXS: Make clk_disable return integer Marek Vasut
2012-04-24  3:18         ` [PATCH 02/11] MXS: Add USB EHCI and USB PHY clock handling Marek Vasut
2012-04-24  3:18         ` [PATCH 03/11] MXS: Fixup i.MX233 USB base address name Marek Vasut
2012-04-24  3:18         ` [PATCH 04/11] MXS: Add data shared between imx-otg and EHCI driver Marek Vasut
2012-04-24  3:18         ` [PATCH 05/11] MXS: Modify the ci13xxx_udc to avoid adding UDC Marek Vasut
2012-04-29  8:26           ` Chen Peter-B29397
2012-04-24  3:18         ` [PATCH 06/11] MXS: Add small registration glue for ci13xxx_udc Marek Vasut
2012-04-24  3:18         ` Marek Vasut [this message]
2012-04-29  8:28           ` [PATCH 07/11] MXS: Add separate MXS EHCI HCD driver Chen Peter-B29397
2012-04-24  3:18         ` [PATCH 08/11] MXS: Add imx-otg driver Marek Vasut
2012-04-24 14:48           ` Lothar Waßmann
2012-04-24 14:50             ` Sascha Hauer
2012-04-24 16:13               ` Lothar Waßmann
2012-04-24 16:47                 ` Sascha Hauer
2012-04-24 17:49                   ` Marek Vasut
2012-04-24 20:49                     ` Sascha Hauer
2012-04-24 20:58                       ` Marek Vasut
2012-04-25  0:17                         ` Chen Peter-B29397
2012-04-24  3:18         ` [PATCH 09/11] MXS: Add USB PHY driver Marek Vasut
2012-04-24  3:18         ` [PATCH 10/11] MXS: Add platform registration hooks for USB EHCI Marek Vasut
2012-04-24  3:18         ` [PATCH 11/11] MXS: Enable USB on M28EVK Marek Vasut
2012-04-24 20:02         ` [RFC PATCH 00/11 V5] MXS: Add i.MX28 USB Host driver Russell King - ARM Linux
2012-04-25 12:27           ` Marek Vasut
2012-04-25 12:41             ` Russell King - ARM Linux
2012-04-25 12:43               ` Marek Vasut
  -- strict thread matches above, loose matches on Subject: below --
2012-04-29 22:34 [RFC PATCH 00/11 V6] " Marek Vasut
2012-04-29 22:34 ` [PATCH 07/11] MXS: Add separate MXS EHCI HCD driver Marek Vasut
2012-05-01  1:55 [RFC PATCH 00/11 V7] MXS: Add i.MX28 USB Host driver Marek Vasut
2012-05-01  1:55 ` [PATCH 07/11] MXS: Add separate MXS EHCI HCD driver Marek Vasut

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=1335237523-9053-8-git-send-email-marex@denx.de \
    --to=marex@denx.de \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).