Patchwork [05/10] MXS: Add platform registration hooks for USB EHCI

login
register
mail settings
Submitter Marek Vasut
Date April 18, 2012, 5:46 p.m.
Message ID <1334771194-18688-6-git-send-email-marex@denx.de>
Download mbox | patch
Permalink /patch/153548/
State New
Headers show

Comments

Marek Vasut - April 18, 2012, 5:46 p.m.
Based on code by:
Tony Lin <tony.lin@freescale.com>

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>
---
 arch/arm/mach-mxs/devices-mx28.h                |    4 ++
 arch/arm/mach-mxs/devices/Kconfig               |    3 +
 arch/arm/mach-mxs/devices/Makefile              |    1 +
 arch/arm/mach-mxs/devices/platform-usb.c        |   78 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +++
 5 files changed, 95 insertions(+)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
Arnd Bergmann - April 19, 2012, 11:51 a.m.
On Wednesday 18 April 2012, Marek Vasut wrote:
>  arch/arm/mach-mxs/devices-mx28.h                |    4 ++
>  arch/arm/mach-mxs/devices/Kconfig               |    3 +
>  arch/arm/mach-mxs/devices/Makefile              |    1 +
>  arch/arm/mach-mxs/devices/platform-usb.c        |   78 +++++++++++++++++++++++
>  arch/arm/mach-mxs/include/mach/devices-common.h |    9 +++
>  5 files changed, 95 insertions(+)
>  create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c

What's the state of the device tree support for mach-mxs now? Since we
allow booting at least the mx28evk with device tree now in -next, it
would be really nice if we didn't have to add this registration code
for non-DT platforms any more and just mandate that everyone who
wants to use USB on that board uses DT. Is that possible already
or are we missing too much other stuff?

	Arnd
Shawn Guo - April 19, 2012, 2:24 p.m.
On Thu, Apr 19, 2012 at 11:51:46AM +0000, Arnd Bergmann wrote:
> On Wednesday 18 April 2012, Marek Vasut wrote:
> >  arch/arm/mach-mxs/devices-mx28.h                |    4 ++
> >  arch/arm/mach-mxs/devices/Kconfig               |    3 +
> >  arch/arm/mach-mxs/devices/Makefile              |    1 +
> >  arch/arm/mach-mxs/devices/platform-usb.c        |   78 +++++++++++++++++++++++
> >  arch/arm/mach-mxs/include/mach/devices-common.h |    9 +++
> >  5 files changed, 95 insertions(+)
> >  create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
> 
> What's the state of the device tree support for mach-mxs now?

The pinctrl-mxs (DT only) was just posted today.  The gpio-mxs will
be the next one I will work on, and I think Dong Aisheng is adding
DT support for mxs-dma and mxs-mmc.  I believe we will reach a pretty
good state when in the v3.5 merge window.

> Since we
> allow booting at least the mx28evk with device tree now in -next, it
> would be really nice if we didn't have to add this registration code
> for non-DT platforms any more and just mandate that everyone who
> wants to use USB on that board uses DT.

I share the same view on this.

Regards,
Shawn

> Is that possible already
> or are we missing too much other stuff?
>
Marek Vasut - April 19, 2012, 9:32 p.m.
Dear Shawn Guo,

> On Thu, Apr 19, 2012 at 11:51:46AM +0000, Arnd Bergmann wrote:
> > On Wednesday 18 April 2012, Marek Vasut wrote:
> > >  arch/arm/mach-mxs/devices-mx28.h                |    4 ++
> > >  arch/arm/mach-mxs/devices/Kconfig               |    3 +
> > >  arch/arm/mach-mxs/devices/Makefile              |    1 +
> > >  arch/arm/mach-mxs/devices/platform-usb.c        |   78
> > >  +++++++++++++++++++++++
> > >  arch/arm/mach-mxs/include/mach/devices-common.h |    9 +++
> > >  5 files changed, 95 insertions(+)
> > >  create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
> > 
> > What's the state of the device tree support for mach-mxs now?
> 
> The pinctrl-mxs (DT only) was just posted today.  The gpio-mxs will
> be the next one I will work on, and I think Dong Aisheng is adding
> DT support for mxs-dma and mxs-mmc.  I believe we will reach a pretty
> good state when in the v3.5 merge window.

This is very good to hear, I'm really interested to see this development :)

> > Since we
> > allow booting at least the mx28evk with device tree now in -next, it
> > would be really nice if we didn't have to add this registration code
> > for non-DT platforms any more and just mandate that everyone who
> > wants to use USB on that board uses DT.
> 
> I share the same view on this.

The Device Tree code for MXS is not ripe yet. We still miss a lot in there. 
Flipping this usb stuff to DT should be easy, I see no point disallowing this 
(and that stands also for the MXS SPI actually) into kernel so more people can 
test it only because you'd like this to wait for who knows how long for the DT 
support to arrive. Don't take it personally, but I still believe it's too early 
to enforce DT on MXS.

> Regards,
> Shawn
> 
> > Is that possible already
> > or are we missing too much other stuff?

Best regards,
Marek Vasut
Shawn Guo - April 20, 2012, 12:40 a.m.
On Thu, Apr 19, 2012 at 11:32:56PM +0200, Marek Vasut wrote:
> The Device Tree code for MXS is not ripe yet. We still miss a lot in there. 
> Flipping this usb stuff to DT should be easy, I see no point disallowing this 
> (and that stands also for the MXS SPI actually) into kernel so more people can 
> test it only because you'd like this to wait for who knows how long for the DT 
> support to arrive. Don't take it personally, but I still believe it's too early 
> to enforce DT on MXS.
> 
Let me put it another way.  When you have drivers/usb changes hit
mainline, while there is still something not ripe for mxs DT support
while stops you adding DT support for usb driver, you have good reason
to ask me take the arch/arm/mach-mxs changes in this series then.
Marek Vasut - April 20, 2012, 12:56 a.m.
Dear Shawn Guo,

> On Thu, Apr 19, 2012 at 11:32:56PM +0200, Marek Vasut wrote:
> > The Device Tree code for MXS is not ripe yet. We still miss a lot in
> > there. Flipping this usb stuff to DT should be easy, I see no point
> > disallowing this (and that stands also for the MXS SPI actually) into
> > kernel so more people can test it only because you'd like this to wait
> > for who knows how long for the DT support to arrive. Don't take it
> > personally, but I still believe it's too early to enforce DT on MXS.
> 
> Let me put it another way.  When you have drivers/usb changes hit
> mainline, while there is still something not ripe for mxs DT support
> while stops you adding DT support for usb driver, you have good reason
> to ask me take the arch/arm/mach-mxs changes in this series then.

Yes, I'm quite aware this stuff might take a bit to get into mainline shape. I 
grouped this and MXS SPI together, maybe the MXS SPI stuff is a better 
representation of what I had in mind (about letting non-DT stuff for mxs slide 
in).

Best regards,
Marek Vasut
Shawn Guo - April 20, 2012, 1:34 a.m.
On Fri, Apr 20, 2012 at 02:56:50AM +0200, Marek Vasut wrote:
> Dear Shawn Guo,
> 
> > On Thu, Apr 19, 2012 at 11:32:56PM +0200, Marek Vasut wrote:
> > > The Device Tree code for MXS is not ripe yet. We still miss a lot in
> > > there. Flipping this usb stuff to DT should be easy, I see no point
> > > disallowing this (and that stands also for the MXS SPI actually) into
> > > kernel so more people can test it only because you'd like this to wait
> > > for who knows how long for the DT support to arrive. Don't take it
> > > personally, but I still believe it's too early to enforce DT on MXS.
> > 
> > Let me put it another way.  When you have drivers/usb changes hit
> > mainline, while there is still something not ripe for mxs DT support
> > while stops you adding DT support for usb driver, you have good reason
> > to ask me take the arch/arm/mach-mxs changes in this series then.
> 
> Yes, I'm quite aware this stuff might take a bit to get into mainline shape. I 
> grouped this and MXS SPI together, maybe the MXS SPI stuff is a better 
> representation of what I had in mind (about letting non-DT stuff for mxs slide 
> in).
> 
I gave Fabio the same comment on his SPI patch.
Marek Vasut - April 20, 2012, 1:40 a.m.
Dear Shawn Guo,

> On Fri, Apr 20, 2012 at 02:56:50AM +0200, Marek Vasut wrote:
> > Dear Shawn Guo,
> > 
> > > On Thu, Apr 19, 2012 at 11:32:56PM +0200, Marek Vasut wrote:
> > > > The Device Tree code for MXS is not ripe yet. We still miss a lot in
> > > > there. Flipping this usb stuff to DT should be easy, I see no point
> > > > disallowing this (and that stands also for the MXS SPI actually) into
> > > > kernel so more people can test it only because you'd like this to
> > > > wait for who knows how long for the DT support to arrive. Don't take
> > > > it personally, but I still believe it's too early to enforce DT on
> > > > MXS.
> > > 
> > > Let me put it another way.  When you have drivers/usb changes hit
> > > mainline, while there is still something not ripe for mxs DT support
> > > while stops you adding DT support for usb driver, you have good reason
> > > to ask me take the arch/arm/mach-mxs changes in this series then.
> > 
> > Yes, I'm quite aware this stuff might take a bit to get into mainline
> > shape. I grouped this and MXS SPI together, maybe the MXS SPI stuff is a
> > better representation of what I had in mind (about letting non-DT stuff
> > for mxs slide in).
> 
> I gave Fabio the same comment on his SPI patch.

Well, let's see how it turns out, I have some questions for Sascha and after I 
sort these out, I'll send V4 of these

Best regards,
Marek Vasut

Patch

diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h
index 9dbeae1..f1a76d7 100644
--- a/arch/arm/mach-mxs/devices-mx28.h
+++ b/arch/arm/mach-mxs/devices-mx28.h
@@ -47,6 +47,10 @@  extern const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst;
 
 #define mx28_add_mxs_pwm(id)		mxs_add_mxs_pwm(MX28_PWM_BASE_ADDR, id)
 
+extern const struct mxs_usbh_data mx28_mxs_usbh_data[] __initconst;
+#define mx28_add_mxs_usbh(id) \
+	mxs_add_mxs_usbh(&mx28_mxs_usbh_data[id])
+
 struct platform_device *__init mx28_add_mxsfb(
 		const struct mxsfb_platform_data *pdata);
 
diff --git a/arch/arm/mach-mxs/devices/Kconfig b/arch/arm/mach-mxs/devices/Kconfig
index b8913df..f6709bc 100644
--- a/arch/arm/mach-mxs/devices/Kconfig
+++ b/arch/arm/mach-mxs/devices/Kconfig
@@ -32,3 +32,6 @@  config MXS_HAVE_PLATFORM_MXS_SAIF
 
 config MXS_HAVE_PLATFORM_RTC_STMP3XXX
 	bool
+
+config MXS_HAVE_PLATFORM_USB
+	bool
diff --git a/arch/arm/mach-mxs/devices/Makefile b/arch/arm/mach-mxs/devices/Makefile
index c8f5c95..be4cc9e 100644
--- a/arch/arm/mach-mxs/devices/Makefile
+++ b/arch/arm/mach-mxs/devices/Makefile
@@ -11,3 +11,4 @@  obj-y += platform-gpio-mxs.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_MXSFB) += platform-mxsfb.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_SAIF) += platform-mxs-saif.o
 obj-$(CONFIG_MXS_HAVE_PLATFORM_RTC_STMP3XXX) += platform-rtc-stmp3xxx.o
+obj-$(CONFIG_MXS_HAVE_PLATFORM_USB) += platform-usb.o
diff --git a/arch/arm/mach-mxs/devices/platform-usb.c b/arch/arm/mach-mxs/devices/platform-usb.c
new file mode 100644
index 0000000..a76e015
--- /dev/null
+++ b/arch/arm/mach-mxs/devices/platform-usb.c
@@ -0,0 +1,78 @@ 
+/*
+ * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+
+#include <linux/compiler.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/fsl_devices.h>
+
+#include <mach/mx23.h>
+#include <mach/mx28.h>
+#include <mach/devices-common.h>
+
+#define mxs_usbh_data_entry_single(soc, _id, hwid)			\
+	{								\
+		.id = _id,						\
+		.usb_irq = soc ## _INT_USB ## hwid,			\
+		.usb_iobase = soc ## _USBCTRL ## hwid ## _BASE_ADDR,	\
+		.phy_iobase = soc ## _USBPHY ## hwid ## _BASE_ADDR,	\
+	}
+
+#define mxs_usbh_data_entry(soc, _id, hwid)				\
+	[_id] = mxs_usbh_data_entry_single(soc, _id, hwid)
+
+#ifdef CONFIG_SOC_IMX23
+const struct mxs_usbh_data mx23_mxs_usbh_data[] __initconst = {
+	mxs_usbh_data_entry(MX23, 0, 0),
+};
+#endif
+
+#ifdef CONFIG_SOC_IMX28
+const struct mxs_usbh_data mx28_mxs_usbh_data[] __initconst = {
+	mxs_usbh_data_entry(MX28, 0, 0),
+	mxs_usbh_data_entry(MX28, 1, 1),
+};
+#endif
+
+void __init mxs_add_mxs_usbh(const struct mxs_usbh_data *data)
+{
+	struct platform_device *pdev;
+	struct resource phy_res[] = {
+		{
+			.start	= data->phy_iobase,
+			.end	= data->phy_iobase + SZ_256 - 1,
+			.flags	= IORESOURCE_MEM,
+		},
+	};
+
+	struct resource usb_res[] = {
+		{
+			.start	= data->usb_iobase,
+			.end	= data->usb_iobase + SZ_64K - 1,
+			.flags	= IORESOURCE_MEM,
+		}, {
+			.start	= data->usb_irq,
+			.end	= data->usb_irq,
+			.flags	= IORESOURCE_IRQ,
+		},
+	};
+
+	pdev = mxs_add_platform_device_dmamask("mxs-usb-phy", data->id,
+					phy_res, ARRAY_SIZE(phy_res),
+					NULL, 0,
+					DMA_BIT_MASK(32));
+	if (!pdev)
+		pr_err("Failed to register USB PHY driver!\n");
+
+	pdev = mxs_add_platform_device_dmamask("imx-usb", data->id,
+					usb_res, ARRAY_SIZE(usb_res),
+					NULL, 0,
+					DMA_BIT_MASK(32));
+	if (!pdev)
+		pr_err("Failed to register USB Host driver!\n");
+}
diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h
index f2e3839..9f319b0 100644
--- a/arch/arm/mach-mxs/include/mach/devices-common.h
+++ b/arch/arm/mach-mxs/include/mach/devices-common.h
@@ -42,6 +42,15 @@  struct mxs_auart_data {
 struct platform_device *__init mxs_add_auart(
 		const struct mxs_auart_data *data);
 
+/* usb host */
+struct mxs_usbh_data {
+	int id;
+	resource_size_t usb_irq;
+	resource_size_t usb_iobase;
+	resource_size_t phy_iobase;
+};
+void __init mxs_add_mxs_usbh(const struct mxs_usbh_data *data);
+
 /* fec */
 #include <linux/fec.h>
 struct mxs_fec_data {