Skip to contentSkip to conversation

MXS: Add i.MX28 USB Host driver

RFC PATCH Superseded Marek Vasut 3 participants 27 messages May 1, 2012 – May 10, 2012

Subsystems (5)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure. Also added is glue code for CI13xxx driver, to allow device mode. This patchset still does NOT support OTG mode, the device/host mode is selected via platform data.

NOTE: This patchset is also available at:
http://git.kernel.org/?p=linux/kernel/git/marex/linux-2.6.git;a=shortlog;h=refs/heads/mxs-usb

V2: Introduce stub imx-usb driver that then registers the PHY and EHCI drivers.
V3: Add the HCD on demand based on the PHY's state (only add HCD if it's host).
Currently, only the HOST mode is supported.
V4: * Introduce ci13xxx gadget glue
* Reorder patches in a more sensible order
* Introduce platform data, containing VBUS GPIO and port mode (device/gadget)
* Rename imx-usb to imx-otg
* Drop mx28evk usb host patch
* Use more devm_ function
* Rework the mxs-phy to register the same interrupt as ehci-mxs (and effectivelly kill bogus otg_set_vbus() call from ehci-mxs ; use standard ehci irq handling in ehci-mxs)
V5: * Finally move OTG IRQ handling into imx-otg
* Move imx_otg_set_{host,peripheral}() into imx-otg
* Move imx_otg_work() into imx-otg driver (now it all makes sense, yay!)
V6: Do PHY-specific job inside the PHY driver
V7: * Pass only necessary data to the drivers registered by imx-otg
(memory, irq, pointer to imx-otg device). This should fix issue pointed out by Lothar Wassmann.
* Have single IRQ handler in imx-otg, which then calls host/gadget IRQ handlers only if they're registered via imx_otg_set_irq_handler() call, depending on the current state of the OTG.

Marek Vasut (11):
MXS: Make clk_disable return integer
MXS: Add USB EHCI and USB PHY clock handling
MXS: Fixup i.MX233 USB base address name
MXS: Add data shared between imx-otg and EHCI driver
MXS: Modify the ci13xxx_udc to avoid adding UDC
MXS: Add small registration glue for ci13xxx_udc
MXS: Add separate MXS EHCI HCD driver
MXS: Add imx-otg driver
MXS: Add USB PHY driver
MXS: Add platform registration hooks for USB EHCI
MXS: Enable USB on M28EVK

 arch/arm/mach-mxs/Kconfig                       |    2 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 +-
 arch/arm/mach-mxs/devices-mx28.h                |    5 +
 arch/arm/mach-mxs/devices/Kconfig               |    3 +
 arch/arm/mach-mxs/devices/Makefile              |    1 +
 arch/arm/mach-mxs/devices/platform-usb.c        |   89 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |   13 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   21 +
 drivers/usb/gadget/Kconfig                      |   17 +
 drivers/usb/gadget/Makefile                     |    1 +
 drivers/usb/gadget/ci13xxx_mxs.c                |   73 ++++
 drivers/usb/gadget/ci13xxx_udc.c                |   12 +-
 drivers/usb/gadget/ci13xxx_udc.h                |    1 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  187 +++++++++
 drivers/usb/otg/Kconfig                         |   16 +
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-otg.c                       |  480 +++++++++++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  328 ++++++++++++++++
 include/linux/usb/mxs-usb.h                     |   72 ++++
 23 files changed, 1360 insertions(+), 13 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/gadget/ci13xxx_mxs.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/imx-otg.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
 create mode 100644 include/linux/usb/mxs-usb.h
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 1 line
1.7.10
#1 lore raw

PATCH v7 1/11 MXS: Make clk_disable return integer

This allows subsequent USB clock patch to interchange enable() and disable() calls without adding unnecessary switching cruft.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/clock-mx28.c         |    7 +++++--
 arch/arm/mach-mxs/include/mach/clock.h |    2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)
arch/arm/mach-mxs/clock-mx28.c +5 -2
index cea29c9..43116ba 100644
@@ -86,7 +86,7 @@ static int _raw_clk_enable(struct clk *clk)
 	return 0;
 }
 
-static void _raw_clk_disable(struct clk *clk)
+static int _raw_clk_disable(struct clk *clk)
 {
 	u32 reg;
 
@@ -95,6 +95,8 @@ static void _raw_clk_disable(struct clk *clk)
 		reg |= 1 << clk->enable_shift;
 		__raw_writel(reg, clk->enable_reg);
 	}
+
+	return 0;
 }
 
 /*
@@ -149,7 +151,7 @@ _CLK_ENABLE_PLL(pll1_clk, PLL1, EN_USB_CLKS)
 _CLK_ENABLE_PLL(pll2_clk, PLL2, CLKGATE)
 
 #define _CLK_DISABLE_PLL(name, r, g)					\
-static void name##_disable(struct clk *clk)				\
+static int name##_disable(struct clk *clk)				\
 {									\
 	__raw_writel(BM_CLKCTRL_##r##CTRL0_POWER,			\
 		     CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR);	\
@@ -161,6 +163,7 @@ static void name##_disable(struct clk *clk)				\
 		__raw_writel(BM_CLKCTRL_##r##CTRL0_##g,			\
 			CLKCTRL_BASE_ADDR + HW_CLKCTRL_##r##CTRL0_CLR);	\
 									\
+	return 0;							\
 }
 
 _CLK_DISABLE_PLL(pll0_clk, PLL0, EN_USB_CLKS)
arch/arm/mach-mxs/include/mach/clock.h +1 -1
index 592c9ab..21d1fad 100644
@@ -50,7 +50,7 @@ struct clk {
 	int (*enable) (struct clk *);
 	/* Function ptr to disable the clock. Leave blank if clock can not
 	   be gated. */
-	void (*disable) (struct clk *);
+	int (*disable) (struct clk *);
 	/* Function ptr to set the parent clock of the clock. */
 	int (*set_parent) (struct clk *, struct clk *);
 };
Signature · 1 line
1.7.10
#2 lore raw

PATCH v7 2/11 MXS: Add USB EHCI and USB PHY clock handling

In reply to Marek Vasut

Based on code by:
Tony Lin <[email protected]>

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/clock-mx28.c |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
arch/arm/mach-mxs/clock-mx28.c +19 -2
index 43116ba..8784a72 100644
@@ -577,6 +577,21 @@ static struct clk usb1_clk = {
 	.parent = &pll1_clk,
 };
 
+static struct clk usb_phy_clk0 = {
+	.parent = &pll0_clk,
+	.enable = _raw_clk_disable,
+	.disable = _raw_clk_enable,
+	.enable_reg = CLKCTRL_BASE_ADDR + HW_CLKCTRL_PLL0CTRL0,
+	.enable_shift = 18,
+};
+
+static struct clk usb_phy_clk1 = {
+	.parent = &pll1_clk,
+	.enable = _raw_clk_disable,
+	.disable = _raw_clk_enable,
+	.enable_reg = CLKCTRL_BASE_ADDR + HW_CLKCTRL_PLL1CTRL0,
+	.enable_shift = 18,
+};
 #define _DEFINE_CLOCK(name, er, es, p)					\
 	static struct clk name = {					\
 		.enable_reg	= CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,	\
@@ -636,8 +651,10 @@ static struct clk_lookup lookups[] = {
 	_REGISTER_CLOCK("mxs-mmc.3", NULL, ssp3_clk)
 	_REGISTER_CLOCK("flexcan.0", NULL, can0_clk)
 	_REGISTER_CLOCK("flexcan.1", NULL, can1_clk)
-	_REGISTER_CLOCK(NULL, "usb0", usb0_clk)
-	_REGISTER_CLOCK(NULL, "usb1", usb1_clk)
+	_REGISTER_CLOCK("imx-otg.0", "usb", usb0_clk)
+	_REGISTER_CLOCK("imx-otg.1", "usb", usb1_clk)
+	_REGISTER_CLOCK("mxs-usb-phy.0", "phy", usb_phy_clk0)
+	_REGISTER_CLOCK("mxs-usb-phy.1", "phy", usb_phy_clk1)
 	_REGISTER_CLOCK("mxs-pwm.0", NULL, pwm_clk)
 	_REGISTER_CLOCK("mxs-pwm.1", NULL, pwm_clk)
 	_REGISTER_CLOCK("mxs-pwm.2", NULL, pwm_clk)
Signature · 1 line
1.7.10
#3 lore raw

PATCH v7 3/11 MXS: Fixup i.MX233 USB base address name

In reply to Marek Vasut

Modify USB EHCI and USB PHY base addresses on the i.MX233 to nicely fit into the whole USB registration scheme.

Based on code by:
Tony Lin <[email protected]>

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/include/mach/mx23.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-mxs/include/mach/mx23.h +4 -4
index 599094b..7955b75 100644
@@ -64,8 +64,8 @@
 #define MX23_AUART1_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x06c000)
 #define MX23_AUART2_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x06e000)
 #define MX23_DUART_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x070000)
-#define MX23_USBPHY_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x07c000)
-#define MX23_USBCTRL_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x080000)
+#define MX23_USBPHY0_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x07c000)
+#define MX23_USBCTRL0_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x080000)
 #define MX23_DRAM_BASE_ADDR		(MX23_IO_BASE_ADDR + 0x0e0000)
 
 #define MX23_IO_P2V(x)			MXS_IO_P2V(x)
@@ -89,8 +89,8 @@
 #define MX23_INT_SPDIF_ERROR		10
 #define MX23_INT_SAIF1_IRQ		10
 #define MX23_INT_SAIF2_IRQ		10
-#define MX23_INT_USB_CTRL		11
-#define MX23_INT_USB_WAKEUP		12
+#define MX23_INT_USB0			11
+#define MX23_INT_USB0_WAKEUP		12
 #define MX23_INT_GPMI_DMA		13
 #define MX23_INT_SSP1_DMA		14
 #define MX23_INT_SSP1_ERROR		15
Signature · 1 line
1.7.10
#4 lore raw

PATCH v7 4/11 MXS: Add data shared between imx-otg and EHCI driver

In reply to Marek Vasut

This patch adds common data shared between the MXS EHCI HCD driver, the MXS USB Gadget driver and the imx-otg driver. These data allow passing clock and memory stuff from imx-otg driver into the host/gadget driver.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 include/linux/usb/mxs-usb.h |   72 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
 create mode 100644 include/linux/usb/mxs-usb.h
include/linux/usb/mxs-usb.h new file +72 -0
new file mode 100644
index 0000000..708d61f
@@ -0,0 +1,72 @@
+/*
+ * include/linux/usb/mxs-usb.h
+ *
+ * Freescale i.MX USB driver shared data.
+ *
+ * Copyright (C) 2012 Marek Vasut <[email protected]>
+ * on behalf of DENX Software Engineering GmbH
+ *
+ * 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.
+ */
+
+#ifndef __INCLUDE_LINUX_USB_MXS_USB_H__
+#define __INCLUDE_LINUX_USB_MXS_USB_H__
+
+#include <linux/types.h>
+#include <linux/platform_device.h>
+#include <linux/usb/otg.h>
+#include <linux/irq.h>
+
+struct imx_otg_res {
+	struct resource		*mem_res;
+	void __iomem		*mem;
+	struct device		*dev;
+};
+
+struct imx_otg {
+	struct platform_device	*pdev_host;
+	struct platform_device	*pdev_gadget;
+
+	struct imx_otg_res	res;
+
+	struct clk		*clk;
+	int			irq;
+	int			irq_wakeup;
+
+	uint32_t		gpio_vbus;
+	uint32_t		gpio_vbus_inverted;
+	enum usb_otg_state	new_state;
+	enum usb_otg_state	cur_state;
+	struct usb_otg		otg;
+	struct work_struct	work;
+
+	irqreturn_t		(*host_handler)(int irq, void *data);
+	void			*host_data;
+	irqreturn_t		(*gadget_handler)(int irq, void *data);
+	void			*gadget_data;
+};
+
+void imx_otg_set_irq_handler(struct device *dev,
+			irqreturn_t (*handler)(int irq, void *data),
+			void *data, int host);
+
+struct imx_usb_platform_data {
+	uint32_t		gpio_vbus;
+	bool			gpio_vbus_inverted;
+	bool			host_mode;
+	bool			gadget_mode;
+};
+
+#endif /* __INCLUDE_LINUX_USB_MXS_USB_H__ */
Signature · 1 line
1.7.10
#5 lore raw

PATCH v7 5/11 MXS: Modify the ci13xxx_udc to avoid adding UDC

In reply to Marek Vasut

On the i.MX platform, we are adding the UDC ourselves from the PHY driver. This patch adds a flag into the ci13xxx_udc that avoids adding the UDC if set.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/gadget/ci13xxx_udc.c |   12 ++++++++----
 drivers/usb/gadget/ci13xxx_udc.h |    1 +
 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/usb/gadget/ci13xxx_udc.c +8 -4
index 243ef1a..94f8b19 100644
@@ -2935,9 +2935,11 @@ static int udc_probe(struct ci13xxx_udc_driver *driver, struct device *dev,
 			goto remove_dbg;
 	}
 
-	retval = usb_add_gadget_udc(dev, &udc->gadget);
-	if (retval)
-		goto remove_trans;
+	if (!(udc->udc_driver->flags & CI13XXX_DONT_REGISTER_GADGET)) {
+		retval = usb_add_gadget_udc(dev, &udc->gadget);
+		if (retval)
+			goto remove_trans;
+	}
 
 	pm_runtime_no_callbacks(&udc->gadget.dev);
 	pm_runtime_enable(&udc->gadget.dev);
@@ -2980,7 +2982,9 @@ static void udc_remove(void)
 		err("EINVAL");
 		return;
 	}
-	usb_del_gadget_udc(&udc->gadget);
+
+	if (!(udc->udc_driver->flags & CI13XXX_DONT_REGISTER_GADGET))
+		usb_del_gadget_udc(&udc->gadget);
 
 	if (udc->transceiver) {
 		otg_set_peripheral(udc->transceiver->otg, &udc->gadget);
drivers/usb/gadget/ci13xxx_udc.h +1 -0
index 0d31af5..9f2efa2 100644
@@ -108,6 +108,7 @@ struct ci13xxx_udc_driver {
 #define CI13XXX_REQUIRE_TRANSCEIVER	BIT(1)
 #define CI13XXX_PULLUP_ON_VBUS		BIT(2)
 #define CI13XXX_DISABLE_STREAMING	BIT(3)
+#define CI13XXX_DONT_REGISTER_GADGET	BIT(4)
 
 #define CI13XXX_CONTROLLER_RESET_EVENT		0
 #define CI13XXX_CONTROLLER_STOPPED_EVENT	1
Signature · 1 line
1.7.10
#6 lore raw

PATCH v7 6/11 MXS: Add small registration glue for ci13xxx_udc

In reply to Marek Vasut

This patch adds small registration glue for the ci13xxx_udc that is compatible with the imx-otg driver.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/gadget/Kconfig       |   17 +++++++++
 drivers/usb/gadget/Makefile      |    1 +
 drivers/usb/gadget/ci13xxx_mxs.c |   73 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)
 create mode 100644 drivers/usb/gadget/ci13xxx_mxs.c
drivers/usb/gadget/Kconfig +17 -0
index 2633f75..1fa6b0d 100644
@@ -494,6 +494,23 @@ config USB_CI13XXX_MSM
 	  dynamically linked module called "ci13xxx_msm" and force all
 	  gadget drivers to also be dynamically linked.
 
+config USB_CI13XXX_MXS
+	tristate "MIPS USB CI13xxx for i.MX23/28"
+	depends on ARCH_MXS
+	select USB_GADGET_DUALSPEED
+	select USB_IMX_COMPOSITE
+	help
+	  i.MX SoC has chipidea USB controller.  This driver uses
+	  ci13xxx_udc core.
+	  This driver depends on OTG driver for PHY initialization,
+	  clock management, powering up VBUS, and power management.
+	  This driver is not supported on boards like trout which
+	  has an external PHY.
+
+	  Say "y" to link the driver statically, or "m" to build a
+	  dynamically linked module called "ci13xxx_mxs" and force all
+	  gadget drivers to also be dynamically linked.
+
 #
 # LAST -- dummy/emulated controller
 #
drivers/usb/gadget/Makefile +1 -0
index b7f6eef..1f159a9 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_USB_EG20T)		+= pch_udc.o
 obj-$(CONFIG_USB_MV_UDC)	+= mv_udc.o
 mv_udc-y			:= mv_udc_core.o
 obj-$(CONFIG_USB_CI13XXX_MSM)	+= ci13xxx_msm.o
+obj-$(CONFIG_USB_CI13XXX_MXS)	+= ci13xxx_mxs.o
 obj-$(CONFIG_USB_FUSB300)	+= fusb300_udc.o
 
 #
drivers/usb/gadget/ci13xxx_mxs.c new file +73 -0

73 lines not on this page · raw message

Signature · 1 line
1.7.10
#7 lore raw

PATCH v7 7/11 MXS: Add separate MXS EHCI HCD driver

In reply to Marek Vasut

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.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/host/Kconfig    |    7 ++
 drivers/usb/host/ehci-hcd.c |    5 ++
 drivers/usb/host/ehci-mxs.c |  187 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 199 insertions(+)
 create mode 100644 drivers/usb/host/ehci-mxs.c
drivers/usb/host/Kconfig +7 -0
index f788eb8..85ed593 100644
@@ -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
drivers/usb/host/ehci-hcd.c +5 -0
index 4a3bc5b..16e161c 100644
@@ -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
drivers/usb/host/ehci-mxs.c new file +187 -0

187 lines not on this page · raw message

Signature · 1 line
1.7.10
#8 lore raw

PATCH v7 8/11 MXS: Add imx-otg driver

In reply to Marek Vasut

This driver handles claiming of clocks and memory areas. These are later properly delegated to it's child devices, the USB Host (ehci-mxs) and USB Gadget (ci13xxx-mxs).

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  480 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 487 insertions(+)
 create mode 100644 drivers/usb/otg/imx-otg.c
drivers/usb/otg/Kconfig +6 -0
index 5c87db0..e7c6325 100644
@@ -116,6 +116,12 @@ config FSL_USB2_OTG
 	help
 	  Enable this to support Freescale USB OTG transceiver.
 
+config USB_IMX_COMPOSITE
+	bool
+	help
+	  Composite driver that handles clock and memory mapping for
+	  i.MX USB host and USB PHY.
+
 config USB_MV_OTG
 	tristate "Marvell USB OTG support"
 	depends on USB_EHCI_MV && USB_MV_UDC && USB_SUSPEND
drivers/usb/otg/Makefile +1 -0
index 41aa509..7d2c631 100644
@@ -20,4 +20,5 @@ obj-$(CONFIG_USB_MSM_OTG)	+= msm_otg.o
 obj-$(CONFIG_AB8500_USB)	+= ab8500-usb.o
 fsl_usb2_otg-objs		:= fsl_otg.o otg_fsm.o
 obj-$(CONFIG_FSL_USB2_OTG)	+= fsl_usb2_otg.o
+obj-$(CONFIG_USB_IMX_COMPOSITE)	+= imx-otg.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
drivers/usb/otg/imx-otg.c new file +480 -0

480 lines not on this page · raw message

Signature · 1 line
1.7.10
#9 lore raw

PATCH v7 9/11 MXS: Add USB PHY driver

In reply to Marek Vasut

Add driver that controls the built-in USB PHY in the i.MX233/i.MX28. This enables the PHY upon powerup and shuts it down on shutdown.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |   10 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  328 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 339 insertions(+)
 create mode 100644 drivers/usb/otg/mxs-phy.c
drivers/usb/otg/Kconfig +10 -0
index e7c6325..1de1495 100644
@@ -122,6 +122,16 @@ config USB_IMX_COMPOSITE
 	  Composite driver that handles clock and memory mapping for
 	  i.MX USB host and USB PHY.
 
+config USB_MXS_PHY
+	tristate "Freescale i.MX28 USB PHY support"
+	select USB_OTG_UTILS
+	select USB_IMX_COMPOSITE
+	help
+	  Say Y here if you want to build Freescale i.MX28 USB PHY
+	  driver in kernel.
+
+	  To compile this driver as a module, choose M here.
+
 config USB_MV_OTG
 	tristate "Marvell USB OTG support"
 	depends on USB_EHCI_MV && USB_MV_UDC && USB_SUSPEND
drivers/usb/otg/Makefile +1 -0
index 7d2c631..b8d7d5c 100644
@@ -21,4 +21,5 @@ obj-$(CONFIG_AB8500_USB)	+= ab8500-usb.o
 fsl_usb2_otg-objs		:= fsl_otg.o otg_fsm.o
 obj-$(CONFIG_FSL_USB2_OTG)	+= fsl_usb2_otg.o
 obj-$(CONFIG_USB_IMX_COMPOSITE)	+= imx-otg.o
+obj-$(CONFIG_USB_MXS_PHY)	+= mxs-phy.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
drivers/usb/otg/mxs-phy.c new file +328 -0

328 lines not on this page · raw message

Signature · 1 line
1.7.10
#10 lore raw

PATCH v7 10/11 MXS: Add platform registration hooks for USB EHCI

In reply to Marek Vasut

Based on code by:
Tony Lin <[email protected]>

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/devices-mx28.h                |    5 ++
 arch/arm/mach-mxs/devices/Kconfig               |    3 +
 arch/arm/mach-mxs/devices/Makefile              |    1 +
 arch/arm/mach-mxs/devices/platform-usb.c        |   89 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |   13 ++++
 5 files changed, 111 insertions(+)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
arch/arm/mach-mxs/devices-mx28.h +5 -0
index 9dbeae1..04a9120 100644
@@ -11,6 +11,7 @@
 #include <mach/mx28.h>
 #include <mach/devices-common.h>
 #include <mach/mxsfb.h>
+#include <linux/usb/mxs-usb.h>
 
 extern const struct amba_device mx28_duart_device __initconst;
 #define mx28_add_duart() \
@@ -47,6 +48,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, pdata) \
+	mxs_add_mxs_usbh(&mx28_mxs_usbh_data[id], pdata)
+
 struct platform_device *__init mx28_add_mxsfb(
 		const struct mxsfb_platform_data *pdata);
 
arch/arm/mach-mxs/devices/Kconfig +3 -0
index b8913df..f6709bc 100644
@@ -32,3 +32,6 @@ config MXS_HAVE_PLATFORM_MXS_SAIF
 
 config MXS_HAVE_PLATFORM_RTC_STMP3XXX
 	bool
+
+config MXS_HAVE_PLATFORM_USB
+	bool
arch/arm/mach-mxs/devices/Makefile +1 -0
index c8f5c95..be4cc9e 100644
@@ -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
arch/arm/mach-mxs/devices/platform-usb.c new file +89 -0

89 lines not on this page · raw message

arch/arm/mach-mxs/include/mach/devices-common.h +13 -0
index f2e3839..b4a65ab 100644
@@ -10,6 +10,8 @@
 #include <linux/platform_device.h>
 #include <linux/init.h>
 #include <linux/amba/bus.h>
+#include <linux/fsl_devices.h>
+#include <linux/usb/mxs-usb.h>
 
 extern struct device mxs_apbh_bus;
 
@@ -42,6 +44,17 @@ 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 phy_irq;
+	resource_size_t usb_iobase;
+	resource_size_t phy_iobase;
+};
+void __init mxs_add_mxs_usbh(const struct mxs_usbh_data *data,
+			const struct imx_usb_platform_data *pdata);
+
 /* fec */
 #include <linux/fec.h>
 struct mxs_fec_data {
Signature · 1 line
1.7.10
#11 lore raw

PATCH v7 11/11 MXS: Enable USB on M28EVK

In reply to Marek Vasut

Enable the second USB port on M28EVK board.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Linux USB <[email protected]>
Cc Liu JunJie-B08287 <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shi Make-B15407 <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/Kconfig       |    2 ++
 arch/arm/mach-mxs/mach-m28evk.c |   21 +++++++++++++++++++++
 2 files changed, 23 insertions(+)
arch/arm/mach-mxs/Kconfig +2 -0
index c57f996..05f6e84 100644
@@ -81,6 +81,8 @@ config MODULE_M28
 	select MXS_HAVE_PLATFORM_MXS_I2C
 	select MXS_HAVE_PLATFORM_MXS_MMC
 	select MXS_HAVE_PLATFORM_MXSFB
+	select MXS_HAVE_PLATFORM_USB
+	select USB_ARCH_HAS_EHCI
 	select MXS_OCOTP
 
 config MODULE_APX4
arch/arm/mach-mxs/mach-m28evk.c +21 -0
index 06d7996..912c8d4 100644
@@ -39,6 +39,8 @@
 
 #define MX28EVK_BL_ENABLE	MXS_GPIO_NR(3, 18)
 #define M28EVK_LCD_ENABLE	MXS_GPIO_NR(3, 28)
+#define M28EVK_USB_ENABLE	MXS_GPIO_NR(3, 13)
+#define M28EVK_USBOTG_ENABLE	MXS_GPIO_NR(3, 12)
 
 #define MX28EVK_MMC0_WRITE_PROTECT	MXS_GPIO_NR(2, 12)
 #define MX28EVK_MMC1_WRITE_PROTECT	MXS_GPIO_NR(0, 28)
@@ -210,6 +212,16 @@ static const iomux_cfg_t m28evk_pads[] __initconst = {
 
 	/* Backlight */
 	MX28_PAD_PWM3__GPIO_3_28 | MXS_PAD_CTRL,
+
+	/* USB */
+	MX28_PAD_SSP2_SS2__USB0_OVERCURRENT,
+	MX28_PAD_SSP2_SS1__USB1_OVERCURRENT,
+	MX28_PAD_PWM2__USB0_ID |
+		MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP,
+	MX28_PAD_AUART3_TX__GPIO_3_13 |
+		MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP,
+	MX28_PAD_AUART3_RX__GPIO_3_12 |
+		MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP,
 };
 
 /* led */
@@ -292,6 +304,13 @@ static const struct mxsfb_platform_data m28evk_mxsfb_pdata __initconst = {
 	.ld_intf_width	= STMLCDIF_18BIT,
 };
 
+static struct imx_usb_platform_data m28_usb_data = {
+	.gpio_vbus		= M28EVK_USBOTG_ENABLE,
+	.gpio_vbus_inverted	= 1,
+	.gadget_mode		= 0,
+	.host_mode		= 1,
+};
+
 static struct at24_platform_data m28evk_eeprom = {
 	.byte_len = 16384,
 	.page_size = 32,
@@ -344,6 +363,8 @@ static void __init m28evk_init(void)
 	mx28_add_mxs_i2c(0);
 	i2c_register_board_info(0, m28_stk5v3_i2c_boardinfo,
 			ARRAY_SIZE(m28_stk5v3_i2c_boardinfo));
+
+	mx28_add_mxs_usbh(0, &m28_usb_data);
 }
 
 static void __init m28evk_timer_init(void)
Signature · 1 line
1.7.10
#12 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut
Quoted 12 lines

V7: * Pass only necessary data to the drivers registered by imx-otg
(memory, irq, pointer to imx-otg device). This should fix issue
pointed
out by Lothar Wassmann.
* Have single IRQ handler in imx-otg, which then calls host/gadget
IRQ
handlers only if they're registered via imx_otg_set_irq_handler()
call,
depending on the current state of the OTG.

Hi Marek,

If the host and device interrupt handler are called by otg interrupt handler, then, the interrupt handlers are registered by host/device will be called twice as they are also registered by host/device themselves.

Besides, what kinds of function do you want to add at this patchset? device-only?host-only? basic otg (id switch)? power management (As I have seen you add wakeup interrupt handler)?

#13 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 16 lines
Quoted 16 lines

V7: * Pass only necessary data to the drivers registered by imx-otg

(memory, irq, pointer to imx-otg device). This should fix issue

pointed

out by Lothar Wassmann.

* Have single IRQ handler in imx-otg, which then calls host/gadget

IRQ

handlers only if they're registered via imx_otg_set_irq_handler()

call,

Quoted 7 lines
Quoted 1 line

depending on the current state of the OTG.

Hi Marek,

If the host and device interrupt handler are called by otg interrupt handler, then, the interrupt handlers are registered by host/device will be called twice as they are also registered by host/device themselves.

No they won't, I don't register them in ehci-mxs or ci13xxx-mxs anymore.

Quoted 2 lines

Besides, what kinds of function do you want to add at this patchset?

Device and Host mode, separate so far, configurable by platform data. I'm also looking into the OTG, but let's get this basic stuff right and mainline first.

Quoted 2 lines

device-only?host-only? basic otg (id switch)? power management (As I have seen you add wakeup interrupt handler)?

There is a stub wakeup handler right now, we don't do powermanagement yet.

Peter, thanks for reviewing these :)

Best regards,
Marek Vasut

#14 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Quoted 8 lines
Quoted 3 lines

If the host and device interrupt handler are called by otg interrupt handler, then, the interrupt handlers are registered by host/device

will

Quoted 1 line

be called twice as they are also registered by host/device themselves.

No they won't, I don't register them in ehci-mxs or ci13xxx-mxs anymore.

Have you changed any hcd code? The host interrupt is registered by hcd core code: usb_add_hcd.

Quoted 8 lines
Quoted 2 lines

Besides, what kinds of function do you want to add at this patchset?

Device and Host mode, separate so far, configurable by platform data. I'm also
looking into the OTG, but let's get this basic stuff right and mainline first.

Then, the aim for this patchset is only enable OTG port, and device/host function is selected by platform data, no otg function(id switch) will be supported, correct?

Understanding your scope may help me review your patches.

Quoted 3 lines

Best regards,
Marek Vasut

#15 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

If the host and device interrupt handler are called by otg interrupt handler, then, the interrupt handlers are registered by host/device

will

Quoted 1 line

be called twice as they are also registered by host/device themselves.

No they won't, I don't register them in ehci-mxs or ci13xxx-mxs anymore.

Have you changed any hcd code? The host interrupt is registered by hcd core code: usb_add_hcd.

I pass 0 as IRQ, thinking about it, that's not really correct (it's actually very lame mistake).

Well, let's fix it in V8. I suggest we do a stub handler in the ehci-mxs for usb_add_hcd() and call ehci_irq() from the imx-otg's IRQ handler like it's already done in this patchset.

Quoted 11 lines
Quoted 7 lines
Quoted 2 lines

Besides, what kinds of function do you want to add at this patchset?

Device and Host mode, separate so far, configurable by platform data. I'm also
looking into the OTG, but let's get this basic stuff right and mainline first.

Then, the aim for this patchset is only enable OTG port, and device/host function is selected by platform data, no otg function(id switch) will be supported, correct?

Correct.

But this patchset also works with the host-only port #1 on mx28 (obviously, you can't enable gadget(device) mode for that port).

Quoted 4 lines

Understanding your scope may help me review your patches.

Quoted 2 lines

Best regards,
Marek Vasut

Best regards,
Marek Vasut

#16 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Quoted 8 lines

Well, let's fix it in V8. I suggest we do a stub handler in the ehci-mxs for
usb_add_hcd() and call ehci_irq() from the imx-otg's IRQ handler like it's
already done in this patchset.

I have not understood how you would like to do?

Quoted 5 lines

But this patchset also works with the host-only port #1 on mx28 (obviously, you
can't enable gadget(device) mode for that port).

Currently, there is not generic PHY driver, so only one PHY can be supported at runtime, and only one controller can be enabled if you have used PHY driver.

How can you let otg and host 1 work together with your patchset?

Quoted 7 lines
Quoted 4 lines

Understanding your scope may help me review your patches.

Quoted 2 lines

Best regards,
Marek Vasut

Best regards,
Marek Vasut

#17 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 7 lines
Quoted 5 lines

Well, let's fix it in V8. I suggest we do a stub handler in the ehci-mxs for
usb_add_hcd() and call ehci_irq() from the imx-otg's IRQ handler like it's
already done in this patchset.

I have not understood how you would like to do?

Still use IRQF_SHARED for the usb interrupt, but:
* The IRQ handler in ehci-mxs, that's set in hc_driver.irq would be always returning IRQ_NONE.
* The IRQ handler in imx-otg would call the callback registered via imx_otg_set_irq_handler() only if the port was actually in host mode

Quoted 8 lines
Quoted 4 lines

But this patchset also works with the host-only port #1 on mx28 (obviously, you
can't enable gadget(device) mode for that port).

Currently, there is not generic PHY driver, so only one PHY can be supported at runtime, and only one controller can be enabled if you have used PHY driver.

Correct

Quoted 1 line

How can you let otg and host 1 work together with your patchset?

Sorry for not being clear enough, what I mean was that this patchset supports:
* Port0 in both Device and Host mode (separately, configured via platform data)
* Port1 in Host mode
And that Port0 and Port1 can NOT be enabled at the same time, so the above is mutually exclusive.

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

Understanding your scope may help me review your patches.

Quoted 2 lines

Best regards,
Marek Vasut

Best regards,
Marek Vasut

Best regards,
Marek Vasut

#18 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Quoted 10 lines

Still use IRQF_SHARED for the usb interrupt, but:
* The IRQ handler in ehci-mxs, that's set in hc_driver.irq would be always
returning IRQ_NONE.
* The IRQ handler in imx-otg would call the callback registered via imx_otg_set_irq_handler() only if the port was actually in host mode

The interrupt which is registered by hcd core is usb_hcd_irq, it will call ehci_irq. The hc_driver.irq is included in usb_hcd_irq.

#19 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 9 lines
Quoted 6 lines

Still use IRQF_SHARED for the usb interrupt, but:
* The IRQ handler in ehci-mxs, that's set in hc_driver.irq would be always
returning IRQ_NONE.
* The IRQ handler in imx-otg would call the callback registered via imx_otg_set_irq_handler() only if the port was actually in host mode

The interrupt which is registered by hcd core is usb_hcd_irq, it will call ehci_irq. The hc_driver.irq is included in usb_hcd_irq.

Hm, that's correct. I'll dive in and see if there's any other way around. I think I saw IRQF_DISABLED somewhere there, but that might be just some phantom. Either way, is this direction I'm taking the correct one (have irq handler in imx-otg and send IRQs to gadget/host drivers from there)?

Also, any other comments about this patchset before I roll out another version?

Thanks!

Best regards,
Marek Vasut

#20 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Quoted 13 lines
Quoted 10 lines
Quoted 8 lines

Still use IRQF_SHARED for the usb interrupt, but:
* The IRQ handler in ehci-mxs, that's set in hc_driver.irq would be always
returning IRQ_NONE.
* The IRQ handler in imx-otg would call the callback registered via imx_otg_set_irq_handler() only if the port was actually in host mode

The interrupt which is registered by hcd core is usb_hcd_irq, it will

call

Quoted 1 line

ehci_irq. The hc_driver.irq is included in usb_hcd_irq.

Quoted 8 lines

Hm, that's correct. I'll dive in and see if there's any other way around. I
think I saw IRQF_DISABLED somewhere there, but that might be just some phantom.
Either way, is this direction I'm taking the correct one (have irq handler in
imx-otg and send IRQs to gadget/host drivers from there)?

Sorry for late as I can't see this email at my inbox. If you can handle hcd irq well, I think it is correct direction.

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#21 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 21 lines
Quoted 13 lines
Quoted 8 lines
Quoted 6 lines

Still use IRQF_SHARED for the usb interrupt, but:
* The IRQ handler in ehci-mxs, that's set in hc_driver.irq would be always
returning IRQ_NONE.
* The IRQ handler in imx-otg would call the callback registered via imx_otg_set_irq_handler() only if the port was actually in host mode

The interrupt which is registered by hcd core is usb_hcd_irq, it will

call

Quoted 1 line

ehci_irq. The hc_driver.irq is included in usb_hcd_irq.

Quoted 7 lines

Hm, that's correct. I'll dive in and see if there's any other way around. I
think I saw IRQF_DISABLED somewhere there, but that might be just some phantom.
Either way, is this direction I'm taking the correct one (have irq handler in
imx-otg and send IRQs to gadget/host drivers from there)?

Quoted 1 line

Sorry for late as I can't see this email at my inbox.

That's fine :)

Quoted 1 line

If you can handle hcd irq well, I think it is correct direction.

Good, any other problems you noticed?

Thanks!

Best regards,
Marek Vasut

#22 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Quoted 3 lines

Good, any other problems you noticed?

- Can you change the name from include/linux/usb/mxs-usb.h to imx-usb.h as it will be used for other i.mx platforms.
- For drivers/usb/gadget/ci13xxx_udc.c change,
can you add alexander.shishkin at linux.intel.com to review

Quoted 4 lines

Thanks!

Best regards,
Marek Vasut

#23 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 6 lines
Quoted 1 line

Good, any other problems you noticed?

- Can you change the name from include/linux/usb/mxs-usb.h to imx-usb.h as it will be used for other i.mx platforms.
- For drivers/usb/gadget/ci13xxx_udc.c change,
can you add alexander.shishkin at linux.intel.com to review

Good point, thanks

Quoted 5 lines
Quoted 5 lines

Thanks!

Best regards,
Marek Vasut

Best regards,
Marek Vasut

#24 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut
Quoted 8 lines

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure. Also added is glue code for CI13xxx driver, to allow device mode. This patchset still does NOT support OTG mode, the device/host mode is selected via platform data.

NOTE: This patchset is also available at:
http://git.kernel.org/?p=linux/kernel/git/marex/linux-2.6.git;a=shortlog;h=
refs/heads/mxs-usb

Any news on this please?

Best regards,
Marek Vasut

#25 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut

Hi Marek,

Quoted 4 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure. Also added is glue code for CI13xxx driver, to allow device mode. This patchset still does NOT support OTG mode, the device/host mode is selected via platform data.

When using your patch set with my 3.4-rc6 I get:

After enabling 'CONFIG_USB_EHCI_MXS':

drivers/usb/host/ehci-mxs.c:171: undefined reference to `imx_otg_set_irq_handler'

After enabling 'CONFIG_USB_MXS_PHY':

drivers/usb/otg/imx-otg.c:149: undefined reference to `usb_del_gadget_udc'

And after enabling CONFIG_USB_GADGET it compiles again. But it should be a USB host driver, shouldn't it?

Regards,
Juergen

Signature · 4 lines
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-5121-206917-5128 |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |
#26 lore raw

v7 cover MXS: Add i.MX28 USB Host driver

Dear Juergen Beisert,

Quoted 15 lines

Hi Marek,

Quoted 4 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure. Also added is glue code for CI13xxx driver, to allow device mode. This patchset still does NOT support OTG mode, the device/host mode is selected via platform data.

When using your patch set with my 3.4-rc6 I get:

After enabling 'CONFIG_USB_EHCI_MXS':

drivers/usb/host/ehci-mxs.c:171: undefined reference to `imx_otg_set_irq_handler'

Quoted 6 lines

After enabling 'CONFIG_USB_MXS_PHY':

drivers/usb/otg/imx-otg.c:149: undefined reference to `usb_del_gadget_udc'

And after enabling CONFIG_USB_GADGET it compiles again. But it should be a USB host driver, shouldn't it?

Nice catch, I'll add it into the stack of fixes that need to be made in V8. Though I'd rather rebase V8 on top of usb-next.

btw. this supports both host and gadget mode (not OTG right now), certainly handling the fact the gadget code isn't present in kernel needs to be done. In the meantime, enable also gadget mode and add ci13xxx-mxs into the kernel, it should fix your problem.

Thanks for the report!

Quoted 3 lines

Regards,
Juergen

Best regards,
Marek Vasut