Skip to contentSkip to conversation

MXS: Add i.MX28 USB Host driver

RFC PATCH New Marek Vasut 15 participants 149 messages Apr 17, 2012 – Apr 29, 2012

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

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.

Marek Vasut (8):
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 platform registration hooks for USB EHCI
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 +-
 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        |   79 ++++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   10 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  309 +++++++++++++++++++++++
 drivers/usb/otg/Kconfig                         |    9 +
 drivers/usb/otg/Makefile                        |    1 +
 drivers/usb/otg/mxs-phy.c                       |  256 +++++++++++++++++++
 17 files changed, 736 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/8 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#2 lore raw

PATCH 2/8 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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..ae4f7b3 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("mxs-ehci.0", "usb", usb0_clk)
+	_REGISTER_CLOCK("mxs-ehci.1", "usb", usb1_clk)
+	_REGISTER_CLOCK("mxs-phy.0", "usb0_phy", usb_phy_clk0)
+	_REGISTER_CLOCK("mxs-phy.1", "usb1_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.9.5
maintainer
#3 lore raw

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

Quoted 6 lines · Marek Vasut

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

arch/arm/mach-mxs/clock-mx28.c +0 -0
 	static struct clk name = {					\
 		.enable_reg	= CLKCTRL_BASE_ADDR + HW_CLKCTRL_##er,	\

arch/arm/mach-mxs/clock-mx28.c static struct clk_lookup lookups[] = { · line 657

Quoted 9 lines
arch/arm/mach-mxs/clock-mx28.c +4 -2
@@ -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("mxs-ehci.0", "usb", usb0_clk)
+	_REGISTER_CLOCK("mxs-ehci.1", "usb", usb1_clk)
+	_REGISTER_CLOCK("mxs-phy.0", "usb0_phy", usb_phy_clk0)
+	_REGISTER_CLOCK("mxs-phy.1", "usb1_phy", usb_phy_clk1)

The phy device name should have 'usb' in it to make clear that it's a USB phy and not a network phy. The connection should be simply 'phy' because the device context already makes it clear for what kind of device the clock is.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#4 lore raw

PATCH 3/8 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#5 lore raw

PATCH 4/8 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 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        |   79 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +++
 5 files changed, 96 insertions(+)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
arch/arm/mach-mxs/devices-mx28.h +4 -0
index 5f71bb2..428b184 100644
@@ -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);
 
arch/arm/mach-mxs/devices/Kconfig +3 -0
index abad78d..a297d12 100644
@@ -35,3 +35,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 3e6fb12..2dbdf99 100644
@@ -12,3 +12,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 +79 -0

79 lines not on this page · raw message

arch/arm/mach-mxs/include/mach/devices-common.h +9 -0
index 3bffcd5..8fdd936 100644
@@ -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 {
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH 5/8 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    9 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  256 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 266 insertions(+)
 create mode 100644 drivers/usb/otg/mxs-phy.c
drivers/usb/otg/Kconfig +9 -0
index 5c87db0..8689081 100644
@@ -116,6 +116,15 @@ config FSL_USB2_OTG
 	help
 	  Enable this to support Freescale USB OTG transceiver.
 
+config USB_MXS_PHY
+	tristate "Freescale i.MX28 USB PHY support"
+	select USB_OTG_UTILS
+	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 41aa509..a844b8d 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_MXS_PHY)	+= mxs-phy.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
drivers/usb/otg/mxs-phy.c new file +256 -0

256 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#7 lore raw

PATCH 5/8 MXS: Add USB PHY driver

Quoted 166 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    9 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  256 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 266 insertions(+)
 create mode 100644 drivers/usb/otg/mxs-phy.c
drivers/usb/otg/Kconfig +9 -0
index 5c87db0..8689081 100644
@@ -116,6 +116,15 @@ config FSL_USB2_OTG
 	help
 	  Enable this to support Freescale USB OTG transceiver.
 
+config USB_MXS_PHY
+	tristate "Freescale i.MX28 USB PHY support"
+	select USB_OTG_UTILS
+	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 41aa509..a844b8d 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_MXS_PHY)	+= mxs-phy.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
drivers/usb/otg/mxs-phy.c new file +106 -0
new file mode 100644
index 0000000..9963aa8
@@ -0,0 +1,256 @@
+/*
+ * drivers/usb/otg/mxs-phy.c
+ *
+ * Freescale i.MX28 USB PHY driver.
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/usb/otg.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+
+#include <mach/common.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+#include <mach/mx28.h>
+
+#define HW_USBPHY_PWD				0x00
+
+#define HW_USBPHY_CTRL				0x30
+#define HW_USBPHY_CTRL_SET			0x34
+#define HW_USBPHY_CTRL_CLR			0x38
+#define HW_USBPHY_CTRL_TOG			0x3c
+
+#define BM_USBPHY_CTRL_SFTRST			(1 << 31)
+#define BM_USBPHY_CTRL_CLKGATE			(1 << 30)
+#define BM_USBPHY_CTRL_ENUTMILEVEL3		(1 << 15)
+#define BM_USBPHY_CTRL_ENUTMILEVEL2		(1 << 14)
+#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	(1 << 1)
+
+struct mxs_phy {
+	struct usb_phy	phy;
+	struct device	*dev;
+	struct clk	*clk;
+	struct resource	*res;
+	void __iomem	*reg;
+};
+
+static int phy_init(struct usb_phy *x)
+{
+	struct mxs_phy *phy = container_of(x, struct mxs_phy, phy);
+	uint32_t val;
+
+	/* Enable clock to the PHY. */
+	clk_enable(phy->clk);
+
+	/* Reset the PHY block. */
+	mxs_reset_block(phy->reg + HW_USBPHY_CTRL);
+
+	/* Power up the PHY. */
+	writel(0, phy->reg + HW_USBPHY_PWD);
+
+	/* Enable FS/LS compatibility and HS disconnection detector. */
+	val = BM_USBPHY_CTRL_ENUTMILEVEL2 | BM_USBPHY_CTRL_ENUTMILEVEL3 |
+		BM_USBPHY_CTRL_ENHOSTDISCONDETECT;
+	writel(val, phy->reg + HW_USBPHY_CTRL_SET);
+
+	return 0;
+}
+
+static void phy_shutdown(struct usb_phy *x)
+{
+	struct mxs_phy *phy = container_of(x, struct mxs_phy, phy);
+
+	/* Gate off the PHY. */
+	writel(BM_USBPHY_CTRL_CLKGATE, phy->reg + HW_USBPHY_CTRL_SET);
+
+	/* Disable clock to the PHY. */
+	clk_disable(phy->clk);
+}
+
+static int phy_set_vbus(struct usb_otg *otg, bool enabled)
+{
+	struct usb_phy *x = otg->phy;
+	struct mxs_phy *phy = container_of(x, struct mxs_phy, phy);
+
+	if (enabled)
+		writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+			phy->reg + HW_USBPHY_CTRL_CLR);
+	else
+		writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+			phy->reg + HW_USBPHY_CTRL_SET);
+
+	return 0;
+}
+
+static int __devinit mxs_phy_probe(struct platform_device *pdev)
+{

drivers/usb/otg/mxs-phy.c line 116

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+	struct mxs_phy *phy;
+	struct resource *res;
+	int ret;
+
+	/* Allocate PHY driver's private date. */
+	phy = kzalloc(sizeof *phy, GFP_KERNEL);
+	if (!phy) {
+		ret = -ENOMEM;
+		goto err_alloc_phy;
+	}

Use devm_* functions?

drivers/usb/otg/mxs-phy.c line 174

Quoted 3 lines
drivers/usb/otg/mxs-phy.c new file +3 -0
+
+	/* Enable the PHY clock. */
+	clk_prepare_enable(phy->clk);

The clock is enabled in probe and then again in phy_init. Once is enough.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#8 lore raw

PATCH 5/8 MXS: Add USB PHY driver

In reply to Marek Vasut

drivers/usb/otg/mxs-phy.c line 251

Quoted 5 lines · Marek Vasut

+ * PHY must be registered via subsys_initcall to get it running before EHCI
+ * controller driver.
+ */

drivers/usb/otg/mxs-phy.c new file +2 -0
+subsys_initcall(mxs_phy_init);
+module_exit(mxs_phy_exit);

I think this can be a regular module_init() now, if you change the main driver to call an exported function from here that checks if the phy has been probed, so you can return -EPROBE_DEFER from the main probe function to be called again later.

Arnd

#9 lore raw

PATCH 6/8 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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 |  309 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 321 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 806cc95..d0df8be 100644
@@ -1263,6 +1263,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 +309 -0

309 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#10 lore raw

PATCH 7/8 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/Kconfig       |    2 ++
 arch/arm/mach-mxs/mach-m28evk.c |   10 ++++++++++
 2 files changed, 12 insertions(+)
arch/arm/mach-mxs/Kconfig +2 -0
index 9dbf29f..5b5566c 100644
@@ -83,6 +83,8 @@ config MODULE_M28
 	select MXS_HAVE_PLATFORM_MXS_LRADC
 	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 +10 -0
index f32fadb..a1850bc 100644
@@ -212,6 +212,11 @@ static const iomux_cfg_t m28evk_pads[] __initconst = {
 
 	/* Backlight */
 	MX28_PAD_PWM3__GPIO_3_28 | MXS_PAD_CTRL,
+
+	/* USB */
+	MX28_PAD_SSP2_SS1__USB1_OVERCURRENT,
+	MX28_PAD_AUART3_TX__GPIO_3_13 |
+		MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP,
 };
 
 /* led */
@@ -377,6 +382,11 @@ static void __init m28evk_init(void)
 	mx28_add_ts(&touch_pdata);
 
 	mx28_add_gpmi_nand(&m28evk_gpmi_nand_data);
+
+	gpio_request(MXS_GPIO_NR(3, 13), "USB");
+	gpio_direction_output(MXS_GPIO_NR(3, 13), 0);
+
+	mx28_add_mxs_usbh(1);
 }
 
 static void __init m28evk_timer_init(void)
Signature · 1 line
1.7.9.5
#11 lore raw

PATCH 7/8 MXS: Enable USB on M28EVK

Hello.

Quoted 16 lines · 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 Lin Tony-B19295<[email protected]>
Cc Linux USB<[email protected]>
Cc Sascha Hauer<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Stefano Babic<[email protected]>
Cc Subodh Nijsure<[email protected]>
Cc Tony Lin<[email protected]>
Cc Wolfgang Denk<[email protected]>

[...]

arch/arm/mach-mxs/mach-m28evk.c static void __init m28evk_init(void) · line 386

Quoted 6 lines
arch/arm/mach-mxs/mach-m28evk.c +2 -0
@@ -377,6 +382,11 @@ static void __init m28evk_init(void)
  	mx28_add_ts(&touch_pdata);
 
  	mx28_add_gpmi_nand(&m28evk_gpmi_nand_data);
+
+	gpio_request(MXS_GPIO_NR(3, 13), "USB");

gpio_request() can fail and you don't handle it.

arch/arm/mach-mxs/mach-m28evk.c static void __init m28evk_init(void) · line 387

Quoted 1 line
arch/arm/mach-mxs/mach-m28evk.c +1 -0
+	gpio_direction_output(MXS_GPIO_NR(3, 13), 0);

You can use gpio_request_one() instead of the above 2 calls.

WBR, Sergei

#12 lore raw

PATCH 8/8 MXS: Enable USB on MX28EVK

In reply to Marek Vasut
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/Kconfig        |    2 ++
 arch/arm/mach-mxs/mach-mx28evk.c |   10 ++++++++++
 2 files changed, 12 insertions(+)
arch/arm/mach-mxs/Kconfig +2 -0
index 5b5566c..696e1d1 100644
@@ -53,6 +53,8 @@ config MACH_MX28EVK
 	select MXS_HAVE_PLATFORM_MXS_SAIF
 	select MXS_HAVE_PLATFORM_MXS_I2C
 	select MXS_HAVE_PLATFORM_RTC_STMP3XXX
+	select MXS_HAVE_PLATFORM_USB
+	select USB_ARCH_HAS_EHCI
 	select MXS_OCOTP
 	help
 	  Include support for MX28EVK platform. This includes specific
arch/arm/mach-mxs/mach-mx28evk.c +10 -0
index e386c14..8bdd416 100644
@@ -37,6 +37,7 @@
 #define MX28EVK_BL_ENABLE	MXS_GPIO_NR(3, 18)
 #define MX28EVK_LCD_ENABLE	MXS_GPIO_NR(3, 30)
 #define MX28EVK_FEC_PHY_RESET	MXS_GPIO_NR(4, 13)
+#define MX28EVK_USB1_PWR_EN	MXS_GPIO_NR(3, 8)
 
 #define MX28EVK_MMC0_WRITE_PROTECT	MXS_GPIO_NR(2, 12)
 #define MX28EVK_MMC1_WRITE_PROTECT	MXS_GPIO_NR(0, 28)
@@ -186,6 +187,8 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
 
 	/* led */
 	MX28_PAD_AUART1_TX__GPIO_3_5 | MXS_PAD_CTRL,
+	/* usb1 */
+	MX28_PAD_AUART2_RX__GPIO_3_8 | MXS_PAD_CTRL,
 
 	/* I2C */
 	MX28_PAD_I2C0_SCL__I2C0_SCL |
@@ -451,6 +454,13 @@ static void __init mx28evk_init(void)
 	mx28_add_mxs_mmc(0, &mx28evk_mmc_pdata[0]);
 	mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata[1]);
 
+	ret = gpio_request_one(MX28EVK_USB1_PWR_EN, GPIOF_OUT_INIT_HIGH,
+				"usb1-power-en");
+	if (ret)
+		pr_warn("failed to request gpio usb1-power-en %d\n", ret);
+
+	mx28_add_mxs_usbh(1);
+
 	mx28_add_rtc_stmp3xxx();
 
 	gpio_led_register_device(0, &mx28evk_led_data);
Signature · 1 line
1.7.9.5
#13 lore raw

cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut

Hi Marek,

Quoted 2 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

Great, many thanks!

Unfortunately, I lost the overview over the i.MXxx USB discussion ;)

Could this be used to add support for the mx53 and mx6, too? If yes, what do you think would be needed for this?

Best regards

Dirk

P.S.: What I read from the discussion:

-- cut --
All recent Freescale SoC's USB controller are the same, they are mx23, mx25, mx28, mx31, mx35, mx37, mx50, mx51, mx53, and mx6. But, the transceiver is different between them
* mx23, mx28, mx6 (Transceiver A)
* mx25 mx31, mx35,mx37, mx50, mx51, mx53 (Transceiver B)
-- cut --

Quoted 45 lines

Marek Vasut (8):
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 platform registration hooks for USB EHCI
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 +-
 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        |   79 ++++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   10 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  309 +++++++++++++++++++++++
 drivers/usb/otg/Kconfig                         |    9 +
 drivers/usb/otg/Makefile                        |    1 +
 drivers/usb/otg/mxs-phy.c                       |  256 +++++++++++++++++++
 17 files changed, 736 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
#14 lore raw

cover MXS: Add i.MX28 USB Host driver

Dear Dirk Behme,

Quoted 7 lines

Hi Marek,

Quoted 2 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

Great, many thanks!

Hey, this is still RFC and will need a great discussion.

Quoted 2 lines

Unfortunately, I lost the overview over the i.MXxx USB discussion ;)

Well I put parts together from the old patchset, did some coding on my own ... I still have a few places where I'm very uncertain about so please, review thoroughly.

Quoted 3 lines

Could this be used to add support for the mx53 and mx6, too? If yes, what do you think would be needed for this?

Yes, that's the plan actually. But, isn't mx53 supported by ehci-mxc? I thought the USB PHY core from mx28 was then reused only in mx6q.

You'd have to add support for some clock handling probably (enabling the USB clock on mx53 and maybe some other clock, I'm not quite sure now without the manual), but that should be about it. The MX6q PHY on the other hand looks quite similar to mx28 so it should be easy hacking.

Quoted 7 lines

Best regards

Dirk

P.S.: What I read from the discussion:

Quoted 54 lines

-- cut --
All recent Freescale SoC's USB controller are the same, they are mx23, mx25, mx28, mx31, mx35, mx37, mx50, mx51, mx53, and mx6. But, the transceiver is different between them
* mx23, mx28, mx6 (Transceiver A)
* mx25 mx31, mx35,mx37, mx50, mx51, mx53 (Transceiver B)
-- cut --

Quoted 46 lines

Marek Vasut (8):
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 platform registration hooks for USB EHCI
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 +-
 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        |   79 ++++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   10 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  309
 +++++++++++++++++++++++ drivers/usb/otg/Kconfig                        
 |    9 +
 drivers/usb/otg/Makefile                        |    1 +
 drivers/usb/otg/mxs-phy.c                       |  256
 +++++++++++++++++++ 17 files changed, 736 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

Best regards,
Marek Vasut

#15 lore raw

cover MXS: Add i.MX28 USB Host driver

Quoted 20 lines
Quoted 4 lines · Marek Vasut
Quoted 1 line

This patchset introduces the USB Host driver for i.MX28 CPU,

utilising

Quoted 3 lines
Quoted 1 line

the generic USB PHY infrastructure.

Great, many thanks!

Hey, this is still RFC and will need a great discussion.

Quoted 2 lines

Unfortunately, I lost the overview over the i.MXxx USB discussion ;)

Well I put parts together from the old patchset, did some coding on my own ... I
still have a few places where I'm very uncertain about so please, review thoroughly.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Could this be used to add support for the mx53 and mx6, too? If yes, what do you think would be needed for this?

Yes, that's the plan actually. But, isn't mx53 supported by ehci-mxc? I thought
the USB PHY core from mx28 was then reused only in mx6q.

mx53 is still not supported by ehci-mxc.
Yes, the mx28 and mx6q use the same PHY.

Quoted 73 lines

You'd have to add support for some clock handling probably (enabling the USB
clock on mx53 and maybe some other clock, I'm not quite sure now without the
manual), but that should be about it. The MX6q PHY on the other hand looks quite
similar to mx28 so it should be easy hacking.

Quoted 7 lines

Best regards

Dirk

P.S.: What I read from the discussion:

Quoted 37 lines

-- cut --
All recent Freescale SoC's USB controller are the same, they are mx23, mx25, mx28, mx31, mx35, mx37, mx50, mx51, mx53, and mx6. But, the transceiver is different between them
* mx23, mx28, mx6 (Transceiver A)
* mx25 mx31, mx35,mx37, mx50, mx51, mx53 (Transceiver B)
-- cut --

Quoted 29 lines

Marek Vasut (8):
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 platform registration hooks for USB EHCI
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 +-
 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        |   79 ++++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   10 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  309
 +++++++++++++++++++++++ drivers/usb/otg/Kconfig
 |    9 +
 drivers/usb/otg/Makefile                        |    1 +
 drivers/usb/otg/mxs-phy.c                       |  256

+++++++++++++++++++ 17 files changed, 736 insertions(+), 9

deletions(-)

Quoted 4 lines
Quoted 4 lines
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Quoted 13 lines
Quoted 5 lines
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Quoted 8 lines
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

Best regards,
Marek Vasut

maintainer
#16 lore raw

cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut

Hi Marek,

Quoted 3 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

Another problem is that what you are doing does not integrate at all with otg. I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

Future additions would be:

- Put a USB_MODE_HOST/DEVICE flag into platform_data, and register a host or gadget driver depending on this flag
- Add a USB_MODE_OTG flag to platform_data and implement otg in this driver (or use whatever infrastructure present in the kernel then)

This is similar to what msm does. This way we have the clocks and phys handled where they are needed. We may use this code on i.MX later.

We did this wrong on i.MX (and several other architectures) and getting this right will be hard work. No need to introduce the same flaws again with a new architecture.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#17 lore raw

cover MXS: Add i.MX28 USB Host driver

Dear Sascha Hauer,

Quoted 10 lines

Hi Marek,

Quoted 2 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

All right, I'll let Heikki hack on that. I'm not sure if we have any mx28 based device with multiple USB ports in kernel. Do we ?

Quoted 2 lines

Another problem is that what you are doing does not integrate at all with otg.

Well, how should this be done to integrate with OTG then?

Quoted 10 lines

I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

So the PHY actually registers the EHCI driver (plat_bus->phy->ehci)? That's slightly weird, don't you think?

Quoted 7 lines

Future additions would be:

- Put a USB_MODE_HOST/DEVICE flag into platform_data, and register a host or gadget driver depending on this flag
- Add a USB_MODE_OTG flag to platform_data and implement otg in this driver (or use whatever infrastructure present in the kernel then)

Ok, this sounds reasonable.

Quoted 2 lines

This is similar to what msm does. This way we have the clocks and phys handled where they are needed. We may use this code on i.MX later.

Ok, I'll check the MSM stuff.

Quoted 3 lines

We did this wrong on i.MX (and several other architectures) and getting this right will be hard work. No need to introduce the same flaws again with a new architecture.

Ack, thanks for pointers.

Quoted 1 line

Sascha

Best regards,
Marek Vasut

maintainer
#18 lore raw

cover MXS: Add i.MX28 USB Host driver

Quoted 27 lines · Marek Vasut

Dear Sascha Hauer,

Quoted 10 lines

Hi Marek,

Quoted 2 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

All right, I'll let Heikki hack on that. I'm not sure if we have any mx28 based device with multiple USB ports in kernel. Do we ?

Quoted 2 lines

Another problem is that what you are doing does not integrate at all with otg.

Well, how should this be done to integrate with OTG then?

Quoted 6 lines

I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

Quoted 7 lines
Quoted 4 lines

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

So the PHY actually registers the EHCI driver (plat_bus->phy->ehci)? That's slightly weird, don't you think?

Your hardware device is a device consisting of a ehci core and a USB device core. Currently we register the child devices independently which leads to the mentioned problems. Instead we should register the USB core as a whole and pass the resources to either the client or the host driver.

The phys are completely independent devices (from a bus topology point of view). The USB core just happens to use the phys.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#19 lore raw

cover MXS: Add i.MX28 USB Host driver

Dear Sascha Hauer,

Quoted 33 lines · Marek Vasut
Quoted 32 lines

Dear Sascha Hauer,

Quoted 10 lines

Hi Marek,

Quoted 2 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

All right, I'll let Heikki hack on that. I'm not sure if we have any mx28 based device with multiple USB ports in kernel. Do we ?

Quoted 2 lines

Another problem is that what you are doing does not integrate at all with otg.

Well, how should this be done to integrate with OTG then?

Quoted 10 lines

I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

Quoted 7 lines
Quoted 2 lines

So the PHY actually registers the EHCI driver (plat_bus->phy->ehci)? That's slightly weird, don't you think?

Your hardware device is a device consisting of a ehci core and a USB device core. Currently we register the child devices independently which leads to the mentioned problems. Instead we should register the USB core as a whole and pass the resources to either the client or the host driver.

Ok, giving it a second thought -- you mean to create "stub" driver, which claims and toggles the clock _and_ registers both the EHCI host driver and PHY driver under itself in the hierarchy. Is that correct?

Quoted 2 lines

The phys are completely independent devices (from a bus topology point of view). The USB core just happens to use the phys.

Correct.

Quoted 1 line

Sascha

Best regards,
Marek Vasut

maintainer
#20 lore raw

cover MXS: Add i.MX28 USB Host driver

Quoted 4 lines · Marek Vasut
Quoted 4 lines
Quoted 3 lines

So the PHY actually registers the EHCI driver (plat_bus->phy->ehci)? That's slightly weird, don't you think?

Quoted 8 lines
Quoted 4 lines

Your hardware device is a device consisting of a ehci core and a USB device core. Currently we register the child devices independently which leads to the mentioned problems. Instead we should register the USB core as a whole and pass the resources to either the client or the host driver.

Ok, giving it a second thought -- you mean to create "stub" driver, which claims and toggles the clock _and_ registers both the EHCI host driver and PHY driver under itself in the hierarchy. Is that correct?

No, the registration of the phy is fine the way it is. The stub driver should only register the ehci and the usb device. Maybe some pseudo code helps describing what I mean:

arch/arm/mach-mxs:

	mx28_register_usbphy0();
	mx28_register_usb0();

drivers/usb/otg/mxs-otg.c:

	probe() {
		clk_get();
		clk_prepare_enable();

		usb_get_phy(&pdev->dev);

		if (pdata->mode == USB_OTG_MODE_HOST)
			usb_add_hcd(priv->host);
		else
			usb_gadget_vbus_connect(priv->gadget);
	}

	module_platform_driver(mxs_otg_driver);

drivers/usb/otg/mxs-otg-phy.c:

	probe() {
		clk_get();
		clk_prepare_enable();
		usb_register_phy(phy, "mxs-otg.0");
	}

	module_platform_driver(mxs_otg_phy_driver);

The mxs-otg part can be reused on i.MX aswell, whereas mxs-otg-phy is mxs (and i.MX6 how we just learned) specific.
What currently is missing is a usb_get_phy() with a device argument to get the phy specific to a device. That's a problem, but you currently have it aswell with your current approach

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#21 lore raw

cover MXS: Add i.MX28 USB Host driver

Quoted 48 lines · Marek Vasut
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

So the PHY actually registers the EHCI driver (plat_bus->phy->ehci)? That's slightly weird, don't you think?

Your hardware device is a device consisting of a ehci core and a USB

device

Quoted 1 line
Quoted 1 line

core. Currently we register the child devices independently which

leads

Quoted 1 line
Quoted 1 line

to the mentioned problems. Instead we should register the USB core as

a

Quoted 3 lines
Quoted 1 line

whole and pass the resources to either the client or the host driver.

Ok, giving it a second thought -- you mean to create "stub" driver,

which claims

Quoted 1 line

and toggles the clock _and_ registers both the EHCI host driver and PHY

driver

Quoted 1 line

under itself in the hierarchy. Is that correct?

No, the registration of the phy is fine the way it is. The stub driver should only register the ehci and the usb device. Maybe some pseudo code helps describing what I mean:

arch/arm/mach-mxs:

	mx28_register_usbphy0();
	mx28_register_usb0();

drivers/usb/otg/mxs-otg.c:

	probe() {
		clk_get();
		clk_prepare_enable();

		usb_get_phy(&pdev->dev);

		if (pdata->mode == USB_OTG_MODE_HOST)
			usb_add_hcd(priv->host);
		else
			usb_gadget_vbus_connect(priv->gadget);
	}

	module_platform_driver(mxs_otg_driver);

drivers/usb/otg/mxs-otg-phy.c:

Quoted 8 lines
	probe() {
		clk_get();
		clk_prepare_enable();
		usb_register_phy(phy, "mxs-otg.0");
	}

	module_platform_driver(mxs_otg_phy_driver);

A similar file is drivers/usb/host/fsl-mph-dr-of.c.

Quoted 7 lines

The mxs-otg part can be reused on i.MX aswell, whereas mxs-otg-phy is mxs (and i.MX6 how we just learned) specific.
What currently is missing is a usb_get_phy() with a device argument to get the phy specific to a device. That's a problem, but you currently have it aswell with your current approach

As there are many things need to do, how about finish PHY layer first, then the OTG driver part. After PHY layer and FSL PHY driver finish, the both ports at i.mx28 can be used, and the operation mode (device or host) can be decided by platform code.

Quoted 11 lines

Sascha

--
Pengutronix e.K. |
|
Industrial Linux Solutions | http://www.pengutronix.de/
|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555
|

#22 lore raw

cover MXS: Add i.MX28 USB Host driver

In reply to Sascha Hauer

Hi guys,

Quoted 4 lines · Sascha Hauer

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

No I'm not working on multi PHY support. At one point I was thinking about introducing a very basic support for it but it would not have been enough for USB3 and OMAP4. I believe Kishon has been working on this. Kishon?

Signature · 1 line
heikki
#23 lore raw

cover MXS: Add i.MX28 USB Host driver

In reply to Sascha Hauer
Quoted 26 lines

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

Another problem is that what you are doing does not integrate at all with otg. I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

Future additions would be:

- Put a USB_MODE_HOST/DEVICE flag into platform_data, and register a host or gadget driver depending on this flag
- Add a USB_MODE_OTG flag to platform_data and implement otg in this driver (or use whatever infrastructure present in the kernel then)

Quoted 7 lines

This is similar to what msm does. This way we have the clocks and phys handled where they are needed. We may use this code on i.MX later.

We did this wrong on i.MX (and several other architectures) and getting this right will be hard work. No need to introduce the same flaws again with a new architecture.

Hi Sascha,

We have been discussing i.mx usb re-structure at freescale internal during this periods, one side does not agree with otg driver manages PHY/clock solution due to below reasons:

- May confuse the users who only use device or host function, the users may double "why I need to include otg file to support device/host only function"?

- For some special cases, like device sends resume signal(remote wakeup) after host suspend, but before otg suspend (system needs to refuse to suspend) . It needs to add hcd flag to judge if there is a remote wakeup after host suspend, and if the port is sending resume signal now (when the port is sending resume signal, we can't put power to low power mode). Is it suitable to put some hcd stuffs at otg driver?

- Any disadvantages three individual drivers manage PHY/clock separately after the generic PHY layer/FSL PHY driver have finished? It can define where to get/put PHY/clock operation at individual drivers clearly. When OTG switch, for host mode, the hcd struct (includes interrupt) will be free/created using usb_remove_hcd/usb_add_hcd, for device mode,
we can deinit/init udc like current ci13xxx_udc.c at ci13xxx_vbus_session does.

Quoted 11 lines

Sascha

--
Pengutronix e.K. |
|
Industrial Linux Solutions | http://www.pengutronix.de/
|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555
|

maintainer
#24 lore raw

cover MXS: Add i.MX28 USB Host driver

Quoted 33 lines · On Wed, Apr 18, 2012 at 04:31:50AM +0000, Chen Peter-B29397 wrote:
Quoted 26 lines

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

Another problem is that what you are doing does not integrate at all with otg. I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

Future additions would be:

- Put a USB_MODE_HOST/DEVICE flag into platform_data, and register a host or gadget driver depending on this flag
- Add a USB_MODE_OTG flag to platform_data and implement otg in this driver (or use whatever infrastructure present in the kernel then)

Quoted 7 lines

This is similar to what msm does. This way we have the clocks and phys handled where they are needed. We may use this code on i.MX later.

We did this wrong on i.MX (and several other architectures) and getting this right will be hard work. No need to introduce the same flaws again with a new architecture.

Quoted 8 lines

Hi Sascha,

We have been discussing i.mx usb re-structure at freescale internal during this periods, one side does not agree with otg driver manages PHY/clock solution due to below reasons:

- May confuse the users who only use device or host function, the users may double "why I need to include otg file to support device/host only function"?

I can't find anything confusing in this.

Quoted 6 lines

- For some special cases, like device sends resume signal(remote wakeup) after host suspend, but before otg suspend (system needs to refuse to suspend) . It needs to add hcd flag to judge if there is a remote wakeup after host suspend, and if the port is sending resume signal now (when the port is sending resume signal, we can't put power to low power mode). Is it suitable to put some hcd stuffs at otg driver?

I can't follow you here what the actual problem is, but since the otg driver is the driver for host and gadget (which happens to pass control to either the host or the gadget driver most of the time) it is ok to do whatever it takes in the otg driver to make it work.

Quoted 6 lines

- Any disadvantages three individual drivers manage PHY/clock separately after the generic PHY layer/FSL PHY driver have finished? It can define where to get/put PHY/clock operation at individual drivers clearly. When OTG switch, for host mode, the hcd struct (includes interrupt) will be free/created using usb_remove_hcd/usb_add_hcd, for device mode,
we can deinit/init udc like current ci13xxx_udc.c at ci13xxx_vbus_session does.

I once made a quick hack using the msm otg driver on i.MX. I had to comment out some msm specifics but after that it worked quite well.

Sascga

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#25 lore raw

hi Sascha,
As the previous mail Peter post, we have two concerns about the new arch of USB drvier as followed:
1. If the USB clock and the PHY are centralized managed by the OTG driver, it will introduce an unnecessary dependency between gadget/host function and OTG driver.
That means even gadget/host function is the individual function that customer wanted, we need add OTG driver as well, otherwise, without the PHY and clock support provided by OTG driver, the gadget/host function can't work at all. But from the general viewpoint, the gadget/host function is independent of OTG function, this unnecessary dependency or limitation for customer is not reasonable. Furthermore, this dependency will face much difficulty in some extreme case that some customer only needs host function only but with the OTG ID floating, it was a real case we encounted before.

2. If the USB clock and the PHY are centralized managed by the OTG driver, it will introduce an unavoidable remote wakup issue that:

       Since the USB suspend is separated into two parts: the USB host controller suspend (set portsc.suspend bit to 1)  part which is controlled by host driver and PHY suspend part (set portsc.phcd to 1) which is controlled by OTG driver, during the system suspend, these two parts will be executed in sequence, but the interval between these two parts is out of control.
       Refer to USB spec 2.0, the remote wakeup can happen anytime after 5ms later from bus entered suspended state(set portsc.suspend bit to 1), it means it can happen before, after, even during PHY suspend part executing. Taking the following case into accounted, PHY suspend process is executing, the pseudo code as below:
       {
            ...
            some checking for the remote wakeup;
                                      <------------------ remote wakeup happen here
            set portsc.phcd to 1;
            ...
        }
        At such situation, one issue will be generated that the USB controller is pulling up the resume signal (K), but at the same time, the SW may set PHY to low power mode(set PHCD to 1), it may cause unpredictable result.
        As in our i.MX platform the response to this remote wakeup(pulling up K signal) is out of SW control, and it can happen at anytime (5ms later after bus in suspended state), this issue is unavoidable.

        The safest solution for this issue is setting portsc.phcd within 5ms after bus in suspended state(set portsc.suspend bit to 1), it requires USB host controller suspend and PHY suspend must be executed uninterruptably, natively they can't be separated.

     The above is the shortcoming we thought about the new arch, and we want to know what are you thinking about the shortcoming of current arch, what makes you think the current arch had to be changed.

________________________________________
???: Sascha Hauer [s.hauer at pengutronix.de]
????: 2012?4?18? 15:40
?: Chen Peter-B29397
Cc: Marek Vasut; linux-arm-kernel at lists.infradead.org; Detlev Zundel; Fabio Estevam; Li Frank-B20596; Linux USB; Guo Shawn-R65073; Shawn Guo; Stefano Babic; Subodh Nijsure; Heikki Krogerus; Liu JunJie-B08287; Shi Make-B15407 ??: Re: [RFC PATCH 0/8] MXS: Add i.MX28 USB Host driver

Quoted 33 lines · On Wed, Apr 18, 2012@04:31:50AM +0000, Chen Peter-B29397 wrote:
Quoted 26 lines

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

Another problem is that what you are doing does not integrate at all with otg. I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

Future additions would be:

- Put a USB_MODE_HOST/DEVICE flag into platform_data, and register a host or gadget driver depending on this flag
- Add a USB_MODE_OTG flag to platform_data and implement otg in this driver (or use whatever infrastructure present in the kernel then)

Quoted 7 lines

This is similar to what msm does. This way we have the clocks and phys handled where they are needed. We may use this code on i.MX later.

We did this wrong on i.MX (and several other architectures) and getting this right will be hard work. No need to introduce the same flaws again with a new architecture.

Quoted 8 lines

Hi Sascha,

We have been discussing i.mx usb re-structure at freescale internal during this periods, one side does not agree with otg driver manages PHY/clock solution due to below reasons:

- May confuse the users who only use device or host function, the users may double "why I need to include otg file to support device/host only function"?

I can't find anything confusing in this.

Quoted 6 lines

- For some special cases, like device sends resume signal(remote wakeup) after host suspend, but before otg suspend (system needs to refuse to suspend) . It needs to add hcd flag to judge if there is a remote wakeup after host suspend, and if the port is sending resume signal now (when the port is sending resume signal, we can't put power to low power mode). Is it suitable to put some hcd stuffs at otg driver?

I can't follow you here what the actual problem is, but since the otg driver is the driver for host and gadget (which happens to pass control to either the host or the gadget driver most of the time) it is ok to do whatever it takes in the otg driver to make it work.

Quoted 6 lines

- Any disadvantages three individual drivers manage PHY/clock separately after the generic PHY layer/FSL PHY driver have finished? It can define where to get/put PHY/clock operation at individual drivers clearly. When OTG switch, for host mode, the hcd struct (includes interrupt) will be free/created using usb_remove_hcd/usb_add_hcd, for device mode,
we can deinit/init udc like current ci13xxx_udc.c at ci13xxx_vbus_session does.

I once made a quick hack using the msm otg driver on i.MX. I had to comment out some msm specifics but after that it worked quite well.

Sascga

--

Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#26 lore raw

Dear Liu JunJie-B08287,

Quoted 5 lines

hi Sascha,
As the previous mail Peter post, we have two concerns about the new arch
of USB drvier as followed: 1. If the USB clock and the PHY are centralized managed by the OTG driver, it will introduce an unnecessary dependency between gadget/host function and OTG driver. That means even gadget/host

Quoted 8 lines

function is the individual function that customer wanted, we need add OTG driver as well, otherwise, without the PHY and clock support provided by OTG driver, the gadget/host function can't work at all. But from the general viewpoint, the gadget/host function is independent of OTG function, this unnecessary dependency or limitation for customer is not reasonable. Furthermore, this dependency will face much difficulty in some extreme case that some customer only needs host function only but with the OTG ID floating, it was a real case we encounted before.

Can't this be fixed by passing of proper platform data to the imx-otg?

Quoted 13 lines

2. If the USB clock and the PHY are centralized managed by the OTG
driver, it will introduce an unavoidable remote wakup issue that: Since the USB suspend is separated into two parts: the USB host controller suspend (set portsc.suspend bit to 1) part which is controlled by host driver and PHY suspend part (set portsc.phcd to 1) which is controlled by OTG driver, during the system suspend, these two parts will be executed in sequence, but the interval between these two parts is out of control. Refer to USB spec 2.0, the remote wakeup can happen anytime after 5ms later from bus entered suspended state(set portsc.suspend bit to 1), it means it can happen before, after, even during PHY suspend part executing. Taking the following case into accounted, PHY suspend process is executing, the pseudo code as below: {

Quoted 6 lines
            ...
            some checking for the remote wakeup;
                                      <------------------ remote wakeup
happen here set portsc.phcd to 1;
            ...
        }

Do we support this yet? Besides, you can make sure phy suspends before the controller ... and if the controller detects RW during suspend, it can fail to suspend and that brings the system back up.

Quoted 95 lines

At such situation, one issue will be generated that the USB
controller is pulling up the resume signal (K), but at the same time, the SW may set PHY to low power mode(set PHCD to 1), it may cause unpredictable result. As in our i.MX platform the response to this remote wakeup(pulling up K signal) is out of SW control, and it can happen at anytime (5ms later after bus in suspended state), this issue is unavoidable.

The safest solution for this issue is setting portsc.phcd within
5ms after bus in suspended state(set portsc.suspend bit to 1), it requires USB host controller suspend and PHY suspend must be executed uninterruptably, natively they can't be separated.

The above is the shortcoming we thought about the new arch, and we
want to know what are you thinking about the shortcoming of current arch, what makes you think the current arch had to be changed.

________________________________________
???: Sascha Hauer [s.hauer at pengutronix.de]
????: 2012?4?18? 15:40
?: Chen Peter-B29397
Cc: Marek Vasut; linux-arm-kernel at lists.infradead.org; Detlev Zundel; Fabio Estevam; Li Frank-B20596; Linux USB; Guo Shawn-R65073; Shawn Guo; Stefano Babic; Subodh Nijsure; Heikki Krogerus; Liu JunJie-B08287; Shi Make-B15407 ??: Re: [RFC PATCH 0/8] MXS: Add i.MX28 USB Host driver

Quoted 36 lines · On Wed, Apr 18, 2012 at 04:31:50AM +0000, Chen Peter-B29397 wrote:
Quoted 25 lines

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

Another problem is that what you are doing does not integrate at all with otg. I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

Future additions would be:

- Put a USB_MODE_HOST/DEVICE flag into platform_data, and register a

host or gadget driver depending on this flag

- Add a USB_MODE_OTG flag to platform_data and implement otg in this

Quoted 8 lines

driver (or use whatever infrastructure present in the kernel then)

This is similar to what msm does. This way we have the clocks and phys handled where they are needed. We may use this code on i.MX later.

We did this wrong on i.MX (and several other architectures) and getting this right will be hard work. No need to introduce the same flaws again with a new architecture.

Hi Sascha,

Quoted 7 lines

We have been discussing i.mx usb re-structure at freescale internal during this periods, one side does not agree with otg driver manages PHY/clock solution due to below reasons:

- May confuse the users who only use device or host function, the users may double "why I need to include otg file to support device/host only function"?

I can't find anything confusing in this.

Quoted 6 lines

- For some special cases, like device sends resume signal(remote wakeup) after host suspend, but before otg suspend (system needs to refuse to suspend) . It needs to add hcd flag to judge if there is a remote wakeup after host suspend, and if the port is sending resume signal now (when the port is sending resume signal, we can't put power to low power mode). Is it suitable to put some hcd stuffs at otg driver?

I can't follow you here what the actual problem is, but since the otg driver is the driver for host and gadget (which happens to pass control to either the host or the gadget driver most of the time) it is ok to do whatever it takes in the otg driver to make it work.

Quoted 6 lines

- Any disadvantages three individual drivers manage PHY/clock separately after the generic PHY layer/FSL PHY driver have finished? It can define where to get/put PHY/clock operation at individual drivers clearly. When OTG switch, for host mode, the hcd struct (includes interrupt) will be free/created using usb_remove_hcd/usb_add_hcd, for device mode, we can deinit/init udc like current ci13xxx_udc.c at ci13xxx_vbus_session does.

I once made a quick hack using the msm otg driver on i.MX. I had to comment out some msm specifics but after that it worked quite well.

Quoted 7 lines

Sascga

--

Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

Best regards,
Marek Vasut

#27 lore raw

Call me Tony, :), and search [Tony] for the embedded comments.

-----Original Message-----
From: Marek Vasut [mailto:marex at denx.de]
Sent: Saturday, April 21, 2012 00:26
To: Liu JunJie-B08287
Cc: Sascha Hauer; Chen Peter-B29397; linux-arm-kernel at lists.infradead.org; Detlev Zundel; Fabio Estevam; Li Frank-B20596; Linux USB; Guo Shawn-R65073; Shawn Guo; Stefano Babic; Subodh Nijsure; Heikki Krogerus; Shi Make-B15407
Subject: Re: ??: [RFC PATCH 0/8] MXS: Add i.MX28 USB Host driver

Dear Liu JunJie-B08287,

Quoted 5 lines

hi Sascha,
As the previous mail Peter post, we have two concerns about the new
arch of USB drvier as followed: 1. If the USB clock and the PHY are centralized managed by the OTG driver, it will introduce an unnecessary dependency between gadget/host function and OTG driver.

Quoted 8 lines

That means even gadget/host function is the individual function that
customer wanted, we need add OTG driver as well, otherwise, without
the PHY and clock support provided by OTG driver, the gadget/host
function can't work at all. But from the general viewpoint, the
gadget/host function is independent of OTG function, this unnecessary
dependency or limitation for customer is not reasonable. Furthermore,
this dependency will face much difficulty in some extreme case that
some customer only needs host function only but with the OTG ID floating, it was a real case we encounted before.

Can't this be fixed by passing of proper platform data to the imx-otg?

[Tony] Yes, such special patch or say special parameter in the interface between OTG and gadget/host can resolve such issue. But I don't think it is a good way to design the arch, with more and more special parameter added into the interface will make the interface un-readable and hard to understand.

Quoted 13 lines

2. If the USB clock and the PHY are centralized managed by the OTG
driver, it will introduce an unavoidable remote wakup issue that:
Since the USB suspend is separated into two parts: the USB host
controller suspend (set portsc.suspend bit to 1) part which is
controlled by host driver and PHY suspend part (set portsc.phcd to 1)
which is controlled by OTG driver, during the system suspend, these
two parts will be executed in sequence, but the interval between these two parts is out of control. Refer to USB spec 2.0, the remote wakeup can happen anytime after 5ms
later from bus entered suspended state(set portsc.suspend bit to 1),
it means it can happen before, after, even during PHY suspend part executing. Taking the following case into accounted, PHY suspend process is
executing, the pseudo code as below: {

Quoted 6 lines
            ...
            some checking for the remote wakeup;
                                      <------------------ remote 
wakeup happen here set portsc.phcd to 1;
            ...
        }

Do we support this yet? Besides, you can make sure phy suspends before the controller ... and if the controller detects RW during suspend, it can fail to suspend and that brings the system back up.
[Tony] 1. It is a requirement that we must support. If a modem connected to host, if no communication on modem, the host and modem will enter in suspend mode, and system may try to enter suspend mode too; but the modem may issue remote wake up signal at any time which comply with the usb spec 2.0, we must support this to make the modem wakeup system, and keep modem working well.

2. How could this happen that phy suspends before the controller?
The phy enter into suspend when the data line state is in J mode, or in 3 ms not receive sof. If suspend phy first but keep controller in running/active mode, means the line state is not J, and the sof will not stop, how could the phy retain in suspend mode.

3. even phy suspends before the controller comes to be true, the issue still exist, the interval between the time stamp that controller finishes detecting RW during suspend, and the time stamp that controller really enter into suspend still exists, RW happens within this interval will have the same issue with before.

Quoted 100 lines

At such situation, one issue will be generated that the USB
controller is pulling up the resume signal (K), but at the same time, the SW may set PHY to low power mode(set PHCD to 1), it may cause unpredictable result. As in our i.MX platform the response to this remote wakeup(pulling up K signal) is out of SW control, and it can happen at anytime (5ms later after bus in suspended state), this issue is unavoidable.

The safest solution for this issue is setting portsc.phcd
within 5ms after bus in suspended state(set portsc.suspend bit to 1), it requires USB host controller suspend and PHY suspend must be executed uninterruptably, natively they can't be separated.

The above is the shortcoming we thought about the new arch, and
we want to know what are you thinking about the shortcoming of current arch, what makes you think the current arch had to be changed.

________________________________________
???: Sascha Hauer [s.hauer at pengutronix.de]
????: 2012?4?18? 15:40
?: Chen Peter-B29397
Cc: Marek Vasut; linux-arm-kernel at lists.infradead.org; Detlev Zundel; Fabio Estevam; Li Frank-B20596; Linux USB; Guo Shawn-R65073; Shawn Guo; Stefano Babic; Subodh Nijsure; Heikki Krogerus; Liu JunJie-B08287; Shi Make-B15407
??: Re: [RFC PATCH 0/8] MXS: Add i.MX28 USB Host driver

Quoted 39 lines · On Wed, Apr 18, 2012 at 04:31:50AM +0000, Chen Peter-B29397 wrote:
Quoted 30 lines

Your patches won't work when more than one USB port is enabled because of the singular usb transceiver present in the kernel. That of course is not your fault. I think Heikki (Added to Cc) is working on this issue, but I don't know the status here.

Another problem is that what you are doing does not integrate at all with otg. I don't ask you to implement otg support because you are likely not interested in this, but since you are adding a new ehci glue driver anyway I suggest another approach:

Put a driver under drivers/usb/otg which:

- matches a 'imx-usb' device
- gets/enables all clocks needed for USB
- finds the transceiver
- registers a ehci device

Future additions would be:

- Put a USB_MODE_HOST/DEVICE flag into platform_data, and register a

host or gadget driver depending on this flag

- Add a USB_MODE_OTG flag to platform_data and implement otg in this

driver (or use whatever infrastructure present in the kernel
then)

Quoted 6 lines

This is similar to what msm does. This way we have the clocks and phys handled where they are needed. We may use this code on i.MX later.

We did this wrong on i.MX (and several other architectures) and getting this right will be hard work. No need to introduce the same flaws again with a new architecture.

Hi Sascha,

Quoted 7 lines

We have been discussing i.mx usb re-structure at freescale internal during this periods, one side does not agree with otg driver manages PHY/clock solution due to below reasons:

- May confuse the users who only use device or host function, the users may double "why I need to include otg file to support device/host only function"?

I can't find anything confusing in this.

Quoted 7 lines

- For some special cases, like device sends resume signal(remote wakeup) after host suspend, but before otg suspend (system needs to refuse to
suspend) . It needs to add hcd flag to judge if there is a remote wakeup after host suspend, and if the port is sending resume signal now (when the port is sending resume signal, we can't put power to low power mode). Is it suitable to put some hcd stuffs at otg driver?

I can't follow you here what the actual problem is, but since the otg driver is the driver for host and gadget (which happens to pass control to either the host or the gadget driver most of the time) it is ok to do whatever it takes in the otg driver to make it work.

Quoted 6 lines

- Any disadvantages three individual drivers manage PHY/clock
separately after the generic PHY layer/FSL PHY driver have finished?
It can define where to get/put PHY/clock operation at individual
drivers clearly. When OTG switch, for host mode, the hcd struct
(includes interrupt) will be free/created using
usb_remove_hcd/usb_add_hcd, for device mode, we can deinit/init udc like current ci13xxx_udc.c at ci13xxx_vbus_session does.

I once made a quick hack using the msm otg driver on i.MX. I had to comment out some msm specifics but after that it worked quite well.

Quoted 7 lines

Sascga

--

Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

Best regards,
Marek Vasut

#28 lore raw

v2 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

V2: Introduce stub imx-usb driver that then registers the PHY and EHCI drivers.

Marek Vasut (10):
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-usb, PHY and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add composite imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
 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        |   67 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |    9 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  254 +++++++++++++++++++
 drivers/usb/otg/Kconfig                         |   16 ++
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-usb.c                       |  303 +++++++++++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  201 +++++++++++++++
 include/linux/fsl_devices.h                     |   15 ++
 19 files changed, 939 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/imx-usb.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 1 line
1.7.9.5
#29 lore raw

PATCH v2 1/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#30 lore raw

PATCH v2 2/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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..15fed50 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-usb.0", "usb", usb0_clk)
+	_REGISTER_CLOCK("imx-usb.1", "usb", usb1_clk)
+	_REGISTER_CLOCK("imx-usb.0", "phy", usb_phy_clk0)
+	_REGISTER_CLOCK("imx-usb.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.9.5
#31 lore raw

PATCH v2 3/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#32 lore raw

PATCH v2 4/10 MXS: Add data shared between imx-usb, PHY and EHCI driver

In reply to Marek Vasut

This patch adds common data shared between the MXS USB PHY driver, the MXS EHCI HCD driver and the imx-usb composite driver.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 include/linux/fsl_devices.h |   15 +++++++++++++++
 1 file changed, 15 insertions(+)
include/linux/fsl_devices.h +15 -0
index fffdf00..20038c0 100644
@@ -18,6 +18,7 @@
 #define _FSL_DEVICE_H_
 
 #include <linux/types.h>
+#include <linux/platform_device.h>
 
 /*
  * Some conventions on how we handle peripherals on Freescale chips
@@ -97,6 +98,20 @@ struct fsl_usb2_platform_data {
 	u32		pm_usbgenctrl;
 };
 
+struct imx_usb_data {
+	struct clk	*clk;
+	struct resource	*mem_res;
+	void __iomem	*mem;
+	int		irq;
+};
+
+struct imx_usb {
+	struct platform_device	*host_dev;
+	struct platform_device	*phy_dev;
+	struct imx_usb_data	host;
+	struct imx_usb_data	phy;
+};
+
 /* Flags in fsl_usb2_mph_platform_data */
 #define FSL_USB2_PORT0_ENABLED	0x00000001
 #define FSL_USB2_PORT1_ENABLED	0x00000002
Signature · 1 line
1.7.9.5
#33 lore raw

PATCH v2 5/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 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        |   67 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +++
 5 files changed, 84 insertions(+)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
arch/arm/mach-mxs/devices-mx28.h +4 -0
index 5f71bb2..428b184 100644
@@ -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);
 
arch/arm/mach-mxs/devices/Kconfig +3 -0
index abad78d..a297d12 100644
@@ -35,3 +35,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 3e6fb12..2dbdf99 100644
@@ -12,3 +12,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 +67 -0

67 lines not on this page · raw message

arch/arm/mach-mxs/include/mach/devices-common.h +9 -0
index 3bffcd5..8fdd936 100644
@@ -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 {
Signature · 1 line
1.7.9.5
#34 lore raw

PATCH v2 6/10 MXS: Add composite imx-usb 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 PHY and USB Host.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-usb.c |  303 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/usb/otg/imx-usb.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..e3feaca 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-usb.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
drivers/usb/otg/imx-usb.c new file +303 -0

303 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#35 lore raw

PATCH v2 7/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |   10 +++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  201 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 212 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 e3feaca..56700b3 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-usb.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 +201 -0

201 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#36 lore raw

PATCH v2 8/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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 |  254 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 266 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 806cc95..d0df8be 100644
@@ -1263,6 +1263,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 +254 -0

254 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#37 lore raw

PATCH v2 8/10 MXS: Add separate MXS EHCI HCD driver

Quoted 9 lines

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.

As mxc and mxs platforms use the same USB controller (chipidea's), I wonder if you can use ehci-mxc, or change name from ehci-mxc to ehci-imx? Sascha, what's your opinion?

Quoted 4 lines

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.

For HS disconnect detector, please use like below:
- When there is no device at port, disable it
- When there is a device on the port, enable it
- When bus suspend occurs, disable it
- When bus resume has finishes, enable it.

drivers/usb/host/ehci-mxs.c line 199

Quoted 2 lines
drivers/usb/host/ehci-mxs.c new file +2 -0
+	/* Set up the PORTSCx register */
+	ehci_writel(ehci, MXC_EHCI_MODE_ULPI, &ehci->regs->port_status[0]);

It is UTMI PHY, why you use ULPI mode?

maintainer
#38 lore raw

PATCH v3 8/10 MXS: Add separate MXS EHCI HCD driver

Quoted 4 lines · On Wed, Apr 18, 2012 at 07:01:07AM +0000, Chen Peter-B29397 wrote:
Quoted 4 lines
Quoted 8 lines
Quoted 5 lines

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.

As mxc and mxs platforms use the same USB controller (chipidea's), I wonder if you can use ehci-mxc, or change name from ehci-mxc to ehci-imx? Sascha, what's your opinion?

Maybe better ehci-imx. I think it's a good idea to not use the ehci-mxc glue code but instead write a mxs specific glue code with having in mind that later we want to drop ehci-mxc and use ehci-imx for all imx including mxs. This assumes the USB folks are ok with this, I don't know.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#39 lore raw

PATCH v2 8/10 MXS: Add separate MXS EHCI HCD driver

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines

This driver will handle i.MX233/i.MX28 and I hope soon i.MX6Q. I

tried to

Quoted 2 lines
Quoted 2 lines

keep
this separate from the MXC EHCI to avoid further polution of the MXC

EHCI,

Quoted 3 lines
Quoted 2 lines

though eventually these two might be merged.

As mxc and mxs platforms use the same USB controller (chipidea's), I

wonder if

Quoted 9 lines
Quoted 2 lines

you can use ehci-mxc, or change name from ehci-mxc to ehci-imx? Sascha, what's your opinion?

Maybe better ehci-imx. I think it's a good idea to not use the ehci-mxc glue code but instead write a mxs specific glue code with having in mind that later we want to drop ehci-mxc and use ehci-imx for all imx including mxs. This assumes the USB folks are ok with this, I don't know.

How about create a patch changing name from ehci-mxc to ehci-imx first, then add mx28/mx23/mx6q host ehci driver. I can do it.

Quoted 11 lines

Sascha

--
Pengutronix e.K. |
|
Industrial Linux Solutions | http://www.pengutronix.de/
|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555
|

maintainer
#40 lore raw

PATCH v3 8/10 MXS: Add separate MXS EHCI HCD driver

Quoted 15 lines · On Wed, Apr 18, 2012 at 09:18:23AM +0000, Chen Peter-B29397 wrote:
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines

This driver will handle i.MX233/i.MX28 and I hope soon i.MX6Q. I

tried to

Quoted 2 lines
Quoted 2 lines

keep
this separate from the MXC EHCI to avoid further polution of the MXC

EHCI,

Quoted 3 lines
Quoted 2 lines

though eventually these two might be merged.

As mxc and mxs platforms use the same USB controller (chipidea's), I

wonder if

Quoted 2 lines

you can use ehci-mxc, or change name from ehci-mxc to ehci-imx? Sascha, what's your opinion?

Quoted 8 lines
Quoted 6 lines

Maybe better ehci-imx. I think it's a good idea to not use the ehci-mxc glue code but instead write a mxs specific glue code with having in mind that later we want to drop ehci-mxc and use ehci-imx for all imx including mxs. This assumes the USB folks are ok with this, I don't know.

How about create a patch changing name from ehci-mxc to ehci-imx first, then add mx28/mx23/mx6q host ehci driver. I can do it.

ehci-imx won't need clock handling and it won't need phy handling. Also the setup of the portsc register won't be in the new driver. The clk_get(dev, "usb_phy1") part is horribly broken anyway. It's more than just a rename.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#41 lore raw

PATCH v2 8/10 MXS: Add separate MXS EHCI HCD driver

Quoted 26 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines

This driver will handle i.MX233/i.MX28 and I hope soon i.MX6Q. I

tried to

Quoted 2 lines
Quoted 2 lines

keep
this separate from the MXC EHCI to avoid further polution of the

MXC

Quoted 4 lines
Quoted 4 lines

EHCI,

Quoted 3 lines
Quoted 2 lines

though eventually these two might be merged.

As mxc and mxs platforms use the same USB controller (chipidea's),

I

Quoted 5 lines
Quoted 5 lines

wonder if

Quoted 2 lines

you can use ehci-mxc, or change name from ehci-mxc to ehci-imx? Sascha, what's your opinion?

Maybe better ehci-imx. I think it's a good idea to not use the ehci-

mxc

Quoted 5 lines
Quoted 5 lines

glue code but instead write a mxs specific glue code with having in mind that later we want to drop ehci-mxc and use ehci-imx for all imx including mxs. This assumes the USB folks are ok with this, I don't know.

Quoted 9 lines
Quoted 1 line

How about create a patch changing name from ehci-mxc to ehci-imx first,

then add

Quoted 1 line

mx28/mx23/mx6q host ehci driver. I can do it.

ehci-imx won't need clock handling and it won't need phy handling. Also the setup of the portsc register won't be in the new driver. The clk_get(dev, "usb_phy1") part is horribly broken anyway. It's more than just a rename.

It depends on how you want things to go on, you can
- Create ehci-mxs first, then clean up clk/phy at ehci-mxs/ehci-mxc after generic phy driver and i.mx usb DT support is added, then merge ehci-mxs and ehci-mxc to one ehci-imx. Not sure usb maintainers agree it or not.
- Or rename ehci-mxc to ehci-imx, add mx28 support to ehci-imx. Then, clean up clk/phy after phy driver and DT support are ready. This way the driver ehci-mxs will not appear at drivers/usb/host all the time.

Quoted 11 lines

Sascha

--
Pengutronix e.K. |
|
Industrial Linux Solutions | http://www.pengutronix.de/
|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555
|

maintainer
#42 lore raw

PATCH v3 8/10 MXS: Add separate MXS EHCI HCD driver

Quoted 12 lines · On Thu, Apr 19, 2012 at 02:54:18AM +0000, Chen Peter-B29397 wrote:
Quoted 12 lines
Quoted 4 lines
Quoted 3 lines

How about create a patch changing name from ehci-mxc to ehci-imx first,

then add

Quoted 1 line

mx28/mx23/mx6q host ehci driver. I can do it.

ehci-imx won't need clock handling and it won't need phy handling. Also the setup of the portsc register won't be in the new driver. The clk_get(dev, "usb_phy1") part is horribly broken anyway. It's more than just a rename.

Quoted 4 lines

It depends on how you want things to go on, you can
- Create ehci-mxs first, then clean up clk/phy at ehci-mxs/ehci-mxc after generic phy driver and i.mx usb DT support is added, then merge ehci-mxs and ehci-mxc to one ehci-imx. Not sure usb maintainers agree it or not.

My idea is more to create a ehci-mxs and instead of cleaning up ehci-mxc we switch i.MX over to the new driver and remove ehci-mxc.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#43 lore raw

PATCH v2 9/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/Kconfig       |    2 ++
 arch/arm/mach-mxs/mach-m28evk.c |    9 +++++++++
 2 files changed, 11 insertions(+)
arch/arm/mach-mxs/Kconfig +2 -0
index 9dbf29f..5b5566c 100644
@@ -83,6 +83,8 @@ config MODULE_M28
 	select MXS_HAVE_PLATFORM_MXS_LRADC
 	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 +9 -0
index f32fadb..ecdb0ff 100644
@@ -212,6 +212,11 @@ static const iomux_cfg_t m28evk_pads[] __initconst = {
 
 	/* Backlight */
 	MX28_PAD_PWM3__GPIO_3_28 | MXS_PAD_CTRL,
+
+	/* USB */
+	MX28_PAD_SSP2_SS1__USB1_OVERCURRENT,
+	MX28_PAD_AUART3_TX__GPIO_3_13 |
+		MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP,
 };
 
 /* led */
@@ -377,6 +382,10 @@ static void __init m28evk_init(void)
 	mx28_add_ts(&touch_pdata);
 
 	mx28_add_gpmi_nand(&m28evk_gpmi_nand_data);
+
+	gpio_request_one(MXS_GPIO_NR(3, 13), GPIOF_OUT_INIT_LOW, "USB Power");
+
+	mx28_add_mxs_usbh(1);
 }
 
 static void __init m28evk_timer_init(void)
Signature · 1 line
1.7.9.5
#44 lore raw

PATCH 9/10 MXS: Enable USB on M28EVK

Hello.

Quoted 25 lines · 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 Lin Tony-B19295<[email protected]>
Cc Linux USB<[email protected]>
Cc Sascha Hauer<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Stefano Babic<[email protected]>
Cc Subodh Nijsure<[email protected]>
Cc Tony Lin<[email protected]>
Cc Wolfgang Denk<[email protected]>
---
  arch/arm/mach-mxs/Kconfig       |    2 ++
  arch/arm/mach-mxs/mach-m28evk.c |    9 +++++++++
  2 files changed, 11 insertions(+)
arch/arm/mach-mxs/Kconfig +0 -0
index 9dbf29f..5b5566c 100644

[...]

arch/arm/mach-mxs/Kconfig static void __init m28evk_init(void) · line 386

Quoted 6 lines
arch/arm/mach-mxs/Kconfig +2 -0
@@ -377,6 +382,10 @@ static void __init m28evk_init(void)
  	mx28_add_ts(&touch_pdata);
 
  	mx28_add_gpmi_nand(&m28evk_gpmi_nand_data);
+
+	gpio_request_one(MXS_GPIO_NR(3, 13), GPIOF_OUT_INIT_LOW, "USB Power");

Still can fail, and you don't handle it (unlike the next patch).

WBR, Sergei

#45 lore raw

PATCH v2 9/10 MXS: Enable USB on M28EVK

Dear Sergei Shtylyov,

Quoted 34 lines

Hello.

Quoted 26 lines · 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 Lin Tony-B19295<[email protected]>
Cc Linux USB<[email protected]>
Cc Sascha Hauer<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Stefano Babic<[email protected]>
Cc Subodh Nijsure<[email protected]>
Cc Tony Lin<[email protected]>
Cc Wolfgang Denk<[email protected]>

---

  arch/arm/mach-mxs/Kconfig       |    2 ++
  arch/arm/mach-mxs/mach-m28evk.c |    9 +++++++++
  2 files changed, 11 insertions(+)
arch/arm/mach-mxs/Kconfig +0 -0
index 9dbf29f..5b5566c 100644

[...]

Quoted 2 lines
arch/arm/mach-mxs/Kconfig +0 -0
@@ -377,6 +382,10 @@ static void __init m28evk_init(void)
 
Quoted 8 lines

arch/arm/mach-mxs/Kconfig static void __init m28evk_init(void) · line 388

Quoted 6 lines
arch/arm/mach-mxs/Kconfig +2 -0
  	mx28_add_ts(&touch_pdata);
 
  	mx28_add_gpmi_nand(&m28evk_gpmi_nand_data);
 
+
+	gpio_request_one(MXS_GPIO_NR(3, 13), GPIOF_OUT_INIT_LOW, "USB Power");

Still can fail, and you don't handle it (unlike the next patch).

Hey, it was 4am in the morning when I was submitting this stuff, pardon my mistake ;-) Will be fixed in the new revision, thanks!

Quoted 2 lines

WBR, Sergei

Best regards,
Marek Vasut

#46 lore raw

PATCH v2 10/10 MXS: Enable USB on MX28EVK

In reply to Marek Vasut
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/Kconfig        |    2 ++
 arch/arm/mach-mxs/mach-mx28evk.c |   10 ++++++++++
 2 files changed, 12 insertions(+)
arch/arm/mach-mxs/Kconfig +2 -0
index 5b5566c..696e1d1 100644
@@ -53,6 +53,8 @@ config MACH_MX28EVK
 	select MXS_HAVE_PLATFORM_MXS_SAIF
 	select MXS_HAVE_PLATFORM_MXS_I2C
 	select MXS_HAVE_PLATFORM_RTC_STMP3XXX
+	select MXS_HAVE_PLATFORM_USB
+	select USB_ARCH_HAS_EHCI
 	select MXS_OCOTP
 	help
 	  Include support for MX28EVK platform. This includes specific
arch/arm/mach-mxs/mach-mx28evk.c +10 -0
index e386c14..8bdd416 100644
@@ -37,6 +37,7 @@
 #define MX28EVK_BL_ENABLE	MXS_GPIO_NR(3, 18)
 #define MX28EVK_LCD_ENABLE	MXS_GPIO_NR(3, 30)
 #define MX28EVK_FEC_PHY_RESET	MXS_GPIO_NR(4, 13)
+#define MX28EVK_USB1_PWR_EN	MXS_GPIO_NR(3, 8)
 
 #define MX28EVK_MMC0_WRITE_PROTECT	MXS_GPIO_NR(2, 12)
 #define MX28EVK_MMC1_WRITE_PROTECT	MXS_GPIO_NR(0, 28)
@@ -186,6 +187,8 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
 
 	/* led */
 	MX28_PAD_AUART1_TX__GPIO_3_5 | MXS_PAD_CTRL,
+	/* usb1 */
+	MX28_PAD_AUART2_RX__GPIO_3_8 | MXS_PAD_CTRL,
 
 	/* I2C */
 	MX28_PAD_I2C0_SCL__I2C0_SCL |
@@ -451,6 +454,13 @@ static void __init mx28evk_init(void)
 	mx28_add_mxs_mmc(0, &mx28evk_mmc_pdata[0]);
 	mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata[1]);
 
+	ret = gpio_request_one(MX28EVK_USB1_PWR_EN, GPIOF_OUT_INIT_HIGH,
+				"usb1-power-en");
+	if (ret)
+		pr_warn("failed to request gpio usb1-power-en %d\n", ret);
+
+	mx28_add_mxs_usbh(1);
+
 	mx28_add_rtc_stmp3xxx();
 
 	gpio_led_register_device(0, &mx28evk_led_data);
Signature · 1 line
1.7.9.5
#47 lore raw

v2 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut
Quoted 44 lines

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

V2: Introduce stub imx-usb driver that then registers the PHY and EHCI drivers.

Marek Vasut (10):
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-usb, PHY and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add composite imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
 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        |   67 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |    9 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  254 +++++++++++++++++++
 drivers/usb/otg/Kconfig                         |   16 ++
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-usb.c                       |  303
+++++++++++++++++++++++ drivers/usb/otg/mxs-phy.c                       | 
201 +++++++++++++++ include/linux/fsl_devices.h                     |   15
++
 19 files changed, 939 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/imx-usb.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Quoted 13 lines
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

Ok guys, you can tear me apart on this another round of patchset ... I'll be having some sleep while you do so ;-)

Best regards,
Marek Vasut

#48 lore raw

v2 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut
Quoted 9 lines

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the
generic USB PHY infrastructure.

V2: Introduce stub imx-usb driver that then registers the PHY and EHCI drivers.

- Currently, there is no generic PHY layer, so only one host/device can be supported.

- Now, the PHY and OTG is separated, it is better to put PHY driver to drivers/usb/phy/

- mx23, mx28, mx6q uses the same PHY (FSL PHY), it is better to use the phy driver name as imx-phy.c.

Quoted 55 lines

Marek Vasut (10):
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-usb, PHY and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add composite imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
 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        |   67 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |    9 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  254
+++++++++++++++++++
 drivers/usb/otg/Kconfig                         |   16 ++
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-usb.c                       |  303
+++++++++++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  201 +++++++++++++++
 include/linux/fsl_devices.h                     |   15 ++
 19 files changed, 939 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/imx-usb.c
 create mode 100644 drivers/usb/otg/mxs-phy.c

Cc: Chen Peter-B29397 <[email protected]>
Cc: Detlev Zundel <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Li Frank-B20596 <[email protected]>
Cc: Lin Tony-B19295 <[email protected]>
Cc: Linux USB <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Subodh Nijsure <[email protected]>
Cc: Tony Lin <[email protected]>
Cc: Wolfgang Denk <[email protected]>
--
1.7.9.5

#49 lore raw

v2 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 4 lines
Quoted 4 lines

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the
generic USB PHY infrastructure.

Quoted 8 lines
Quoted 2 lines

V2: Introduce stub imx-usb driver that then registers the PHY and EHCI drivers.

- Currently, there is no generic PHY layer, so only one host/device can be supported.

- Now, the PHY and OTG is separated, it is better to put PHY driver to drivers/usb/phy/

There is no drivers/usb/phy ...

Quoted 3 lines

- mx23, mx28, mx6q uses the same PHY (FSL PHY), it is better to use the phy driver name as imx-phy.c.

Why? mxs == mx23,28,6q and mxc == the rest ... seems to me to be pretty well rooted terminology already.

Quoted 44 lines
Quoted 44 lines

Marek Vasut (10):
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-usb, PHY and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add composite imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
 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        |   67 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |    9 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  254

+++++++++++++++++++

 drivers/usb/otg/Kconfig                         |   16 ++
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-usb.c                       |  303

+++++++++++++++++++++++

 drivers/usb/otg/mxs-phy.c                       |  201 +++++++++++++++
 include/linux/fsl_devices.h                     |   15 ++
 19 files changed, 939 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/imx-usb.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Quoted 15 lines
Quoted 7 lines

Cc: Chen Peter-B29397 <[email protected]>
Cc: Detlev Zundel <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Li Frank-B20596 <[email protected]>
Cc: Lin Tony-B19295 <[email protected]>
Cc: Linux USB <[email protected]>
Cc: Sascha Hauer <[email protected]>

Quoted 8 lines

Cc: Shawn Guo <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Subodh Nijsure <[email protected]>
Cc: Tony Lin <[email protected]>
Cc: Wolfgang Denk <[email protected]>
--
1.7.9.5

Best regards,
Marek Vasut

#50 lore raw

v2 cover MXS: Add i.MX28 USB Host driver

Quoted 7 lines
Quoted 4 lines

- Now, the PHY and OTG is separated, it is better to put PHY driver to drivers/usb/phy/

There is no drivers/usb/phy ...

You can discuss with Felipe Balbi <[email protected]>, if it is ok to create it to put PHY driver.

Quoted 8 lines
Quoted 2 lines

- mx23, mx28, mx6q uses the same PHY (FSL PHY), it is better to use the

phy

Quoted 1 line

driver name as imx-phy.c.

Why? mxs == mx23,28,6q and mxc == the rest ... seems to me to be pretty well
rooted terminology already.

mx23, 28, 6q uses Freescale itself PHY.
mxc uses chipidea PHY.
Originally, I thought it should use IP vendor's name. After thinking it more, it is ok use mxs for mx23,28,6q's PHY.

Quoted 64 lines
Quoted 31 lines
Quoted 31 lines

Marek Vasut (10):
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-usb, PHY and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add composite imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
 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        |   67 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |    9 +
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  254

+++++++++++++++++++

Quoted 7 lines
Quoted 7 lines
 drivers/usb/otg/Kconfig                         |   16 ++
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-usb.c                       |  303

+++++++++++++++++++++++

 drivers/usb/otg/mxs-phy.c                       |  201

+++++++++++++++

Quoted 7 lines
Quoted 7 lines
 include/linux/fsl_devices.h                     |   15 ++
 19 files changed, 939 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/imx-usb.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Quoted 15 lines
Quoted 7 lines

Cc: Chen Peter-B29397 <[email protected]>
Cc: Detlev Zundel <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Li Frank-B20596 <[email protected]>
Cc: Lin Tony-B19295 <[email protected]>
Cc: Linux USB <[email protected]>
Cc: Sascha Hauer <[email protected]>

Quoted 8 lines

Cc: Shawn Guo <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: Subodh Nijsure <[email protected]>
Cc: Tony Lin <[email protected]>
Cc: Wolfgang Denk <[email protected]>
--
1.7.9.5

Best regards,
Marek Vasut

#51 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

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.

Marek Vasut (10):
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-usb and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
 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/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   15 ++
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  228 +++++++++++++++++
 drivers/usb/otg/Kconfig                         |   16 ++
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-usb.c                       |  226 +++++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  305 +++++++++++++++++++++++
 include/linux/fsl_devices.h                     |   10 +
 19 files changed, 952 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/imx-usb.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 1 line
1.7.9.5
#52 lore raw

PATCH v2 1/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#53 lore raw

PATCH v2 2/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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..6136143 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-usb.0", "usb", usb0_clk)
+	_REGISTER_CLOCK("imx-usb.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.9.5
#54 lore raw

PATCH v2 3/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#55 lore raw

PATCH v2 4/10 MXS: Add data shared between imx-usb and EHCI driver

In reply to Marek Vasut

This patch adds common data shared between the MXS EHCI HCD driver and the imx-usb driver. These data allow passing clock and memory stuff from imx-usb driver into the host driver.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 include/linux/fsl_devices.h |   10 ++++++++++
 1 file changed, 10 insertions(+)
include/linux/fsl_devices.h +10 -0
index fffdf00..a1ed1a8 100644
@@ -18,6 +18,7 @@
 #define _FSL_DEVICE_H_
 
 #include <linux/types.h>
+#include <linux/platform_device.h>
 
 /*
  * Some conventions on how we handle peripherals on Freescale chips
@@ -97,6 +98,15 @@ struct fsl_usb2_platform_data {
 	u32		pm_usbgenctrl;
 };
 
+struct imx_usb {
+	struct platform_device	*pdev;
+
+	struct clk		*clk;
+	struct resource		*mem_res;
+	void __iomem		*mem;
+	int			irq;
+};
+
 /* Flags in fsl_usb2_mph_platform_data */
 #define FSL_USB2_PORT0_ENABLED	0x00000001
 #define FSL_USB2_PORT1_ENABLED	0x00000002
Signature · 1 line
1.7.9.5
#56 lore raw

PATCH v2 5/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 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
arch/arm/mach-mxs/devices-mx28.h +4 -0
index 9dbeae1..f1a76d7 100644
@@ -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);
 
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 +78 -0

78 lines not on this page · raw message

arch/arm/mach-mxs/include/mach/devices-common.h +9 -0
index f2e3839..9f319b0 100644
@@ -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 {
Signature · 1 line
1.7.9.5
#57 lore raw

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

Quoted 7 lines · Marek Vasut
 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

#58 lore raw

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

Quoted 10 lines · Arnd Bergmann
Quoted 7 lines · Marek Vasut
 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.

Quoted 5 lines

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

Quoted 3 lines

Is that possible already
or are we missing too much other stuff?

#59 lore raw

PATCH v2 5/10 MXS: Add platform registration hooks for USB EHCI

Dear Shawn Guo,

Quoted 11 lines · Arnd Bergmann
Quoted 10 lines · Marek Vasut
Quoted 8 lines
 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
Quoted 6 lines
Quoted 1 line

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 :)

Quoted 7 lines
Quoted 5 lines

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.

Quoted 5 lines

Regards,
Shawn

Quoted 2 lines

Is that possible already
or are we missing too much other stuff?

Best regards,
Marek Vasut

#60 lore raw

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

Quoted 7 lines · Marek Vasut

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.

Signature · 2 lines
Regards,
Shawn
#61 lore raw

PATCH v2 5/10 MXS: Add platform registration hooks for USB EHCI

Dear Shawn Guo,

Quoted 8 lines · Marek Vasut
Quoted 6 lines

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.

Quoted 4 lines

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

#62 lore raw

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

Quoted 15 lines · Marek Vasut

Dear Shawn Guo,

Quoted 8 lines · Marek Vasut
Quoted 6 lines

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.

Quoted 4 lines

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.

Quoted 5 lines

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.

Signature · 2 lines
Regards,
Shawn
#63 lore raw

PATCH v2 5/10 MXS: Add platform registration hooks for USB EHCI

Dear Shawn Guo,

Quoted 17 lines · Marek Vasut
Quoted 16 lines

Dear Shawn Guo,

Quoted 13 lines · Marek Vasut
Quoted 7 lines

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.

Quoted 6 lines
Quoted 4 lines

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

#64 lore raw

PATCH v2 6/10 MXS: Add imx-usb driver

In reply to Marek Vasut

This driver handles claiming of clocks and memory areas. These are later properly delegated to it's child device, the USB Host.

Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-usb.c |  226 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 233 insertions(+)
 create mode 100644 drivers/usb/otg/imx-usb.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..e3feaca 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-usb.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
drivers/usb/otg/imx-usb.c new file +226 -0

226 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#65 lore raw

PATCH v2 7/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |   10 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  305 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 316 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 e3feaca..56700b3 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-usb.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 +305 -0

305 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#66 lore raw

PATCH v3 7/10 MXS: Add USB PHY driver

Quoted 55 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |   10 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  305 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 316 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 e3feaca..56700b3 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-usb.o
+obj-$(CONFIG_USB_MXS_PHY)	+= mxs-phy.o
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o

drivers/usb/otg/Makefile obj-$(CONFIG_AB8500_USB) += ab8500-usb.o

Quoted 10 lines
drivers/usb/otg/Makefile +10 -0
+
+struct mxs_usb_phy {
+	struct usb_phy		phy;
+
+	struct work_struct	work;
+
+	struct clk		*clk;
+	struct resource		*mem_res;
+	void __iomem		*mem;
+	int			irq;

irq is unused.

Quoted 8 lines
drivers/usb/otg/Makefile +8 -0
+
+static void mxs_usb_work(struct work_struct *w)
+{
+	struct mxs_usb_phy *phy = container_of(w, struct mxs_usb_phy, work);
+	struct usb_otg *otg = phy->phy.otg;
+	struct usb_hcd *hcd;
+
+	switch (otg->phy->state) {

drivers/usb/otg/Makefile

Quoted 10 lines
drivers/usb/otg/Makefile +10 -0
+	case OTG_STATE_A_HOST:
+		if (otg->host) {
+			hcd = bus_to_hcd(otg->host);
+			usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
+		}
+		break;
+	default:
+		break;
+	}
+}

This function should be in imx-otg.

drivers/usb/otg/Makefile

Quoted 9 lines
drivers/usb/otg/Makefile +9 -0
+
+static int __devinit mxs_phy_probe(struct platform_device *pdev)
+{
+	struct mxs_usb_phy *phy;
+	void *retp;
+	int ret;
+
+	/* Allocate PHY driver's private date. */
+	phy = kzalloc(sizeof(*phy), GFP_KERNEL);

devm?

drivers/usb/otg/Makefile

Quoted 8 lines
drivers/usb/otg/Makefile +8 -0
+	if (!phy) {
+		dev_err(&pdev->dev, "Failed to allocate USB PHY structure!\n");
+		ret = -ENOMEM;
+		goto err_alloc_phy;
+	}
+
+	/* Allocate OTG structure. */
+	phy->phy.otg = kzalloc(sizeof(*phy->phy.otg), GFP_KERNEL);

devm?

Quoted 6 lines
drivers/usb/otg/Makefile +6 -0
+	if (!phy->phy.otg) {
+		dev_err(&pdev->dev, "Failed to allocate USB OTG structure!\n");
+		ret = -ENOMEM;
+		goto err_alloc_otg;
+	}
+

drivers/usb/otg/Makefile

Quoted 10 lines
drivers/usb/otg/Makefile +10 -0
+	/* Claim the PHY clock. */
+	phy->clk = clk_get(&pdev->dev, "phy");
+	if (!phy->clk) {
+		dev_err(&pdev->dev, "Failed to claim clock for USB PHY\n");
+		ret = PTR_ERR(phy->clk);
+		goto err_claim_phy_clock;
+	}
+
+	/* Prepare PHY clock. */
+	ret = clk_prepare(phy->clk);

It should be clear that a function named clk_prepare prepares the clock. Please remove such comments.

Quoted 6 lines
drivers/usb/otg/Makefile +6 -0
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to prepare clock for USB PHY.\n");
+		goto err_prepare_phy_clock;
+	}
+
+	/* Get memory area for PHY from resources. */

drivers/usb/otg/Makefile

Quoted 10 lines
drivers/usb/otg/Makefile +10 -0
+	phy->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!phy->mem_res) {
+		dev_err(&pdev->dev, "Specify memory area for this USB PHY!\n");
+		ret = -ENODEV;
+		goto err_get_phy_resource;
+	}
+
+	/* Request the memory region for this USB PHY. */
+	retp = devm_request_mem_region(&pdev->dev, phy->mem_res->start,
+			resource_size(phy->mem_res), pdev->name);

The 'm' in devm is for 'managed' which means that these resources are automatically released on driver exit. You don't have to release them manually. In fact you must not release them with the regular functions. If you want to release them manually you have to use the devm variants.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#67 lore raw

PATCH v2 7/10 MXS: Add USB PHY driver

Dear Sascha Hauer,

Quoted 91 lines · Marek Vasut
Quoted 65 lines

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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

---

 drivers/usb/otg/Kconfig   |   10 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  305
 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 316
 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
drivers/usb/otg/Kconfig +0 -0
 	tristate "Marvell USB OTG support"
 	depends on USB_EHCI_MV && USB_MV_UDC && USB_SUSPEND
drivers/usb/otg/Makefile +1 -0
index e3feaca..56700b3 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-usb.o
 
+obj-$(CONFIG_USB_MXS_PHY)	+= mxs-phy.o
 
 obj-$(CONFIG_USB_MV_OTG)	+= mv_otg.o
 

drivers/usb/otg/Makefile obj-$(CONFIG_AB8500_USB) += ab8500-usb.o

Quoted 10 lines
drivers/usb/otg/Makefile +10 -0
+
+struct mxs_usb_phy {
+	struct usb_phy		phy;
+
+	struct work_struct	work;
+
+	struct clk		*clk;
+	struct resource		*mem_res;
+	void __iomem		*mem;
+	int			irq;

irq is unused.

Quoted 12 lines
drivers/usb/otg/Makefile +12 -0
+
+static void mxs_usb_work(struct work_struct *w)
+{
+	struct mxs_usb_phy *phy = container_of(w, struct mxs_usb_phy, work);
+	struct usb_otg *otg = phy->phy.otg;
+	struct usb_hcd *hcd;
+
+	switch (otg->phy->state) {
+	case OTG_STATE_A_HOST:
+		if (otg->host) {
+			hcd = bus_to_hcd(otg->host);
+			usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
Quoted 8 lines

drivers/usb/otg/Makefile

Quoted 6 lines
drivers/usb/otg/Makefile +6 -0
+		}
+		break;
+	default:
+		break;
+	}
+}

This function should be in imx-otg.

You mean imx-usb? What'd it do in there?

Quoted 66 lines

drivers/usb/otg/Makefile

Quoted 9 lines
drivers/usb/otg/Makefile +9 -0
+
+static int __devinit mxs_phy_probe(struct platform_device *pdev)
+{
+	struct mxs_usb_phy *phy;
+	void *retp;
+	int ret;
+
+	/* Allocate PHY driver's private date. */
+	phy = kzalloc(sizeof(*phy), GFP_KERNEL);

devm?

drivers/usb/otg/Makefile

Quoted 8 lines
drivers/usb/otg/Makefile +8 -0
+	if (!phy) {
+		dev_err(&pdev->dev, "Failed to allocate USB PHY structure!\n");
+		ret = -ENOMEM;
+		goto err_alloc_phy;
+	}
+
+	/* Allocate OTG structure. */
+	phy->phy.otg = kzalloc(sizeof(*phy->phy.otg), GFP_KERNEL);

devm?

Quoted 6 lines
drivers/usb/otg/Makefile +6 -0
+	if (!phy->phy.otg) {
+		dev_err(&pdev->dev, "Failed to allocate USB OTG structure!\n");
+		ret = -ENOMEM;
+		goto err_alloc_otg;
+	}
+

drivers/usb/otg/Makefile

Quoted 10 lines
drivers/usb/otg/Makefile +10 -0
+	/* Claim the PHY clock. */
+	phy->clk = clk_get(&pdev->dev, "phy");
+	if (!phy->clk) {
+		dev_err(&pdev->dev, "Failed to claim clock for USB PHY\n");
+		ret = PTR_ERR(phy->clk);
+		goto err_claim_phy_clock;
+	}
+
+	/* Prepare PHY clock. */
+	ret = clk_prepare(phy->clk);

It should be clear that a function named clk_prepare prepares the clock. Please remove such comments.

Quoted 6 lines
drivers/usb/otg/Makefile +6 -0
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to prepare clock for USB PHY.\n");
+		goto err_prepare_phy_clock;
+	}
+
+	/* Get memory area for PHY from resources. */

drivers/usb/otg/Makefile

Quoted 10 lines
drivers/usb/otg/Makefile +10 -0
+	phy->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!phy->mem_res) {
+		dev_err(&pdev->dev, "Specify memory area for this USB PHY!\n");
+		ret = -ENODEV;
+		goto err_get_phy_resource;
+	}
+
+	/* Request the memory region for this USB PHY. */
+	retp = devm_request_mem_region(&pdev->dev, phy->mem_res->start,
+			resource_size(phy->mem_res), pdev->name);

The 'm' in devm is for 'managed' which means that these resources are automatically released on driver exit. You don't have to release them manually. In fact you must not release them with the regular functions. If you want to release them manually you have to use the devm variants.

Sascha

maintainer
#68 lore raw

PATCH v3 7/10 MXS: Add USB PHY driver

Quoted 22 lines · Marek Vasut

Dear Sascha Hauer,

Quoted 11 lines
Quoted 11 lines
drivers/usb/otg/mxs-phy.c new file +11 -0
+static void mxs_usb_work(struct work_struct *w)
+{
+	struct mxs_usb_phy *phy = container_of(w, struct mxs_usb_phy, work);
+	struct usb_otg *otg = phy->phy.otg;
+	struct usb_hcd *hcd;
+
+	switch (otg->phy->state) {
+	case OTG_STATE_A_HOST:
+		if (otg->host) {
+			hcd = bus_to_hcd(otg->host);
+			usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
Quoted 8 lines

drivers/usb/otg/mxs-phy.c line 109

Quoted 6 lines
drivers/usb/otg/mxs-phy.c new file +6 -0
+		}
+		break;
+	default:
+		break;
+	}
+}

This function should be in imx-otg.

Quoted 1 line

You mean imx-usb? What'd it do in there?

otg/imx-usb.c, yes (though I would prefer imx-otg.c)

It should be there because it's the imx-otg.c driver which manages the state. The phy driver is only a helper.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#69 lore raw

PATCH v2 7/10 MXS: Add USB PHY driver

Dear Sascha Hauer,

Quoted 23 lines · Marek Vasut
Quoted 22 lines

Dear Sascha Hauer,

Quoted 19 lines
Quoted 7 lines
drivers/usb/otg/mxs-phy.c new file +3 -0
+static void mxs_usb_work(struct work_struct *w)
+{
+	struct mxs_usb_phy *phy = container_of(w, struct mxs_usb_phy,

work); + struct usb_otg *otg = phy->phy.otg;

drivers/usb/otg/mxs-phy.c new file +3 -0
+	struct usb_hcd *hcd;
+
+	switch (otg->phy->state) {

drivers/usb/otg/mxs-phy.c line 109

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+	case OTG_STATE_A_HOST:
+		if (otg->host) {
+			hcd = bus_to_hcd(otg->host);
+			usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
+		}
+		break;
+	default:
+		break;
+	}
+}

This function should be in imx-otg.

Quoted 6 lines
Quoted 1 line

You mean imx-usb? What'd it do in there?

otg/imx-usb.c, yes (though I would prefer imx-otg.c)

It should be there because it's the imx-otg.c driver which manages the state. The phy driver is only a helper.

I believe the imx-otg should only call otg_set_host()/otg_set_peripheral() on the particular PHY, in this case mxs-usb-phy, correct? The mxs_usb_work() should stay in the PHY's driver, because it'll likely frob with the PHY's own registers once peripheral support is added.

Quoted 2 lines

Sascha

Best regards,
Marek Vasut

#70 lore raw

PATCH v2 7/10 MXS: Add USB PHY driver

Quoted 32 lines
Quoted 25 lines · Marek Vasut
Quoted 22 lines

Dear Sascha Hauer,

Quoted 19 lines
Quoted 7 lines
drivers/usb/otg/mxs-phy.c new file +3 -0
+static void mxs_usb_work(struct work_struct *w)
+{
+	struct mxs_usb_phy *phy = container_of(w, struct mxs_usb_phy,

work); + struct usb_otg *otg = phy->phy.otg;

drivers/usb/otg/mxs-phy.c new file +3 -0
+	struct usb_hcd *hcd;
+
+	switch (otg->phy->state) {

drivers/usb/otg/mxs-phy.c line 109

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+	case OTG_STATE_A_HOST:
+		if (otg->host) {
+			hcd = bus_to_hcd(otg->host);
+			usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
+		}
+		break;
+	default:
+		break;
+	}
+}

This function should be in imx-otg.

Quoted 6 lines
Quoted 1 line

You mean imx-usb? What'd it do in there?

otg/imx-usb.c, yes (though I would prefer imx-otg.c)

It should be there because it's the imx-otg.c driver which manages the state. The phy driver is only a helper.

Quoted 8 lines

I believe the imx-otg should only call otg_set_host()/otg_set_peripheral() on
the particular PHY, in this case mxs-usb-phy, correct? The mxs_usb_work() should
stay in the PHY's driver, because it'll likely frob with the PHY's own registers
once peripheral support is added.

mxs_usb_work() manages host/device state switch due to id/vbus (at register otgsc) changing. It is better to put it at otg driver.

Quoted 5 lines
Quoted 2 lines

Sascha

Best regards,
Marek Vasut

#71 lore raw

PATCH v2 8/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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 |  228 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 240 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 806cc95..d0df8be 100644
@@ -1263,6 +1263,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 +228 -0

228 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#72 lore raw

PATCH v3 8/10 MXS: Add separate MXS EHCI HCD driver

Quoted 8 lines · 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.

[...]

drivers/usb/host/ehci-mxs.c line 126

Quoted 10 lines
drivers/usb/host/ehci-mxs.c new file +10 -0
+static int ehci_mxs_drv_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct imx_usb *data = pdev->dev.platform_data;
+	struct usb_hcd *hcd;
+	struct ehci_hcd *ehci;
+	struct usb_phy *phy;
+	int ret;
+
+	dev_info(dev, "Initializing i.MX28 USB Controller\n");

This is not (only) i.MX28

Quoted 9 lines
drivers/usb/host/ehci-mxs.c new file +9 -0
+
+	if (!data) {
+		dev_err(dev, "USB Host platform data missing!\n");
+		return -ENODEV;
+	}
+
+	/* Create HCD controller instance. */
+	hcd = usb_create_hcd(&ehci_mxs_hc_driver, dev, dev_name(dev));
+	if (!hcd) {

drivers/usb/host/ehci-mxs.c line 145

Quoted 10 lines
drivers/usb/host/ehci-mxs.c new file +10 -0
+		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;
+
+	clk_enable(data->clk);

The clock shouldn't be here. move this to imx-otg.c

Quoted 29 lines
drivers/usb/host/ehci-mxs.c new file +29 -0
+
+	/* 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);
+
+	/* Initialize the transceiver */
+#ifdef CONFIG_USB_OTG_UTILS
+	phy = usb_get_transceiver();
+	if (!phy) {
+		dev_err(dev, "Unable to find transceiver.\n");
+		ret = -ENODEV;
+		goto err_phy;
+	}
+
+	ret = otg_set_host(phy->otg, &hcd->self);
+	if (ret < 0) {
+		dev_err(dev, "Unable to set transceiver host\n");
+		ret = -ENODEV;
+		goto err_phy_set_host;
+	}
+

drivers/usb/host/ehci-mxs.c line 184

Quoted 10 lines
drivers/usb/host/ehci-mxs.c new file +10 -0
+	ret = usb_phy_init(phy);
+	if (ret < 0) {
+		dev_err(dev, "Unable init transceiver\n");
+		ret = -ENODEV;
+		goto err_phy_init;
+	}
+#else
+	dev_info(dev, "USB_MXS_PHY must have CONFIG_USB_OTG_UTILS enabled\n");
+	goto err_phy;
+#endif

If your code does not work without CONFIG_USB_OTG_UTILS then why doesn't the driver depend on this option?
It doesn't matter, all code inside these ifdefs should go to imx-otg.c.

drivers/usb/host/ehci-mxs.c line 188

Quoted 4 lines
drivers/usb/host/ehci-mxs.c new file +4 -0
+
+	/* Set up the PORTSCx register */
+	ehci_writel(ehci, 0, &ehci->regs->port_status[0]);
+

Should also be in imx-otg.c

Quoted 12 lines
drivers/usb/host/ehci-mxs.c new file +12 -0
+err_phy_init:
+err_phy_set_host:
+#ifdef CONFIG_USB_OTG_UTILS
+	if (phy)
+		usb_put_transceiver(phy);
+#endif
+err_phy:
+	clk_disable(data->clk);
+	usb_put_hcd(hcd);
+	return ret;
+}
+

drivers/usb/host/ehci-mxs.c line 212

Quoted 10 lines
drivers/usb/host/ehci-mxs.c new file +10 -0
+static int __exit ehci_mxs_drv_remove(struct platform_device *pdev)
+{
+	struct imx_usb *data = pdev->dev.platform_data;
+	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_add_hcd is in imx-otg.c so usb_remove_hcd should be aswell.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#73 lore raw

PATCH v2 8/10 MXS: Add separate MXS EHCI HCD driver

Dear Sascha Hauer,

Quoted 11 lines · Marek Vasut
Quoted 7 lines

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.

[...]

Quoted 12 lines

drivers/usb/host/ehci-mxs.c line 126

Quoted 10 lines
drivers/usb/host/ehci-mxs.c new file +10 -0
+static int ehci_mxs_drv_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct imx_usb *data = pdev->dev.platform_data;
+	struct usb_hcd *hcd;
+	struct ehci_hcd *ehci;
+	struct usb_phy *phy;
+	int ret;
+
+	dev_info(dev, "Initializing i.MX28 USB Controller\n");

This is not (only) i.MX28

Let's keep it like that until we get further testing on other platforms.

Quoted 14 lines
Quoted 14 lines
drivers/usb/host/ehci-mxs.c new file +13 -0
+
+	if (!data) {
+		dev_err(dev, "USB Host platform data missing!\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;
+	}
+
Quoted 8 lines

drivers/usb/host/ehci-mxs.c line 145

Quoted 6 lines
drivers/usb/host/ehci-mxs.c new file +6 -0
+	hcd->rsrc_start = data->mem_res->start;
+	hcd->rsrc_len = resource_size(data->mem_res);
+	hcd->regs = data->mem;
+	hcd->irq = data->irq;
+
+	clk_enable(data->clk);

The clock shouldn't be here. move this to imx-otg.c

I see.

Quoted 36 lines
Quoted 36 lines
drivers/usb/host/ehci-mxs.c new file +35 -0
+
+	/* 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);
+
+	/* Initialize the transceiver */
+#ifdef CONFIG_USB_OTG_UTILS
+	phy = usb_get_transceiver();
+	if (!phy) {
+		dev_err(dev, "Unable to find transceiver.\n");
+		ret = -ENODEV;
+		goto err_phy;
+	}
+
+	ret = otg_set_host(phy->otg, &hcd->self);
+	if (ret < 0) {
+		dev_err(dev, "Unable to set transceiver host\n");
+		ret = -ENODEV;
+		goto err_phy_set_host;
+	}
+
+	ret = usb_phy_init(phy);
+	if (ret < 0) {
+		dev_err(dev, "Unable init transceiver\n");
+		ret = -ENODEV;
+		goto err_phy_init;
+	}
Quoted 8 lines

drivers/usb/host/ehci-mxs.c line 184

Quoted 4 lines
drivers/usb/host/ehci-mxs.c new file +4 -0
+#else
+	dev_info(dev, "USB_MXS_PHY must have CONFIG_USB_OTG_UTILS enabled\n");
+	goto err_phy;
+#endif

If your code does not work without CONFIG_USB_OTG_UTILS then why doesn't the driver depend on this option?
It doesn't matter, all code inside these ifdefs should go to imx-otg.c.

Again, you mean imx-usb (the driver registering ehci host) or mxs-usb-phy? Either way, why should it be moved there, why shouldn't it sit in this file? Can you elaborate?

Quoted 6 lines

drivers/usb/host/ehci-mxs.c line 188

Quoted 4 lines
drivers/usb/host/ehci-mxs.c new file +4 -0
+
+	/* Set up the PORTSCx register */
+	ehci_writel(ehci, 0, &ehci->regs->port_status[0]);
+

Should also be in imx-otg.c

This is clearly EHCI thing, why?

Quoted 16 lines
Quoted 16 lines
drivers/usb/host/ehci-mxs.c new file +16 -0
+err_phy_init:
+err_phy_set_host:
+#ifdef CONFIG_USB_OTG_UTILS
+	if (phy)
+		usb_put_transceiver(phy);
+#endif
+err_phy:
+	clk_disable(data->clk);
+	usb_put_hcd(hcd);
+	return ret;
+}
+
+static int __exit ehci_mxs_drv_remove(struct platform_device *pdev)
+{
+	struct imx_usb *data = pdev->dev.platform_data;
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
Quoted 8 lines

drivers/usb/host/ehci-mxs.c line 212

Quoted 6 lines
drivers/usb/host/ehci-mxs.c new file +6 -0
+	struct usb_phy *phy = usb_get_transceiver();
+
+	if (phy)
+		usb_phy_shutdown(phy);
+
+	usb_remove_hcd(hcd);

usb_add_hcd is in imx-otg.c so usb_remove_hcd should be aswell.

Why would that be?

Quoted 1 line

Sascha

Best regards,
Marek Vasut

maintainer
#74 lore raw

PATCH v3 8/10 MXS: Add separate MXS EHCI HCD driver

Quoted 26 lines · Marek Vasut

Dear Sascha Hauer,

Quoted 11 lines · Marek Vasut
Quoted 7 lines

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.

[...]

Quoted 12 lines

drivers/usb/host/ehci-mxs.c line 126

Quoted 10 lines
drivers/usb/host/ehci-mxs.c new file +10 -0
+static int ehci_mxs_drv_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct imx_usb *data = pdev->dev.platform_data;
+	struct usb_hcd *hcd;
+	struct ehci_hcd *ehci;
+	struct usb_phy *phy;
+	int ret;
+
+	dev_info(dev, "Initializing i.MX28 USB Controller\n");

This is not (only) i.MX28

Quoted 1 line

Let's keep it like that until we get further testing on other platforms.

I see no reason for doing that. It does work on all i.MX for sure.

Quoted 12 lines
Quoted 11 lines

drivers/usb/host/ehci-mxs.c line 184

Quoted 7 lines
drivers/usb/host/ehci-mxs.c new file +7 -0
+		ret = -ENODEV;
+		goto err_phy_init;
+	}
+#else
+	dev_info(dev, "USB_MXS_PHY must have CONFIG_USB_OTG_UTILS enabled\n");
+	goto err_phy;
+#endif

If your code does not work without CONFIG_USB_OTG_UTILS then why doesn't the driver depend on this option?
It doesn't matter, all code inside these ifdefs should go to imx-otg.c.

Quoted 1 line

Again, you mean imx-usb (the driver registering ehci host) or mxs-usb-phy?

I mean otg/imx-usb.c (and I'll stick with the name imx-otg)

Quoted 2 lines

Either way, why should it be moved there, why shouldn't it sit in this file? Can you elaborate?

It's the imx-otg driver that manages the state. It's the imx-otg driver which knows how to configure the phy

Quoted 9 lines
Quoted 7 lines

drivers/usb/host/ehci-mxs.c line 188

Quoted 5 lines
drivers/usb/host/ehci-mxs.c new file +4 -0
+
+	/* Set up the PORTSCx register */
+	ehci_writel(ehci, 0, &ehci->regs->port_status[0]);
+

Should also be in imx-otg.c

This is clearly EHCI thing, why?

This is not ehci specific. This is specific to the whole USB controller. You have to set it up for device mode aswell, grep -i for portsc in drivers/usb/gadget.

Quoted 10 lines
Quoted 8 lines

drivers/usb/host/ehci-mxs.c line 212

Quoted 6 lines
drivers/usb/host/ehci-mxs.c new file +6 -0
+	struct usb_phy *phy = usb_get_transceiver();
+
+	if (phy)
+		usb_phy_shutdown(phy);
+
+	usb_remove_hcd(hcd);

usb_add_hcd is in imx-otg.c so usb_remove_hcd should be aswell.

Why would that be?

Let me try to rephrase my intention:

We have to deal with a 2-in-1 device here, a usb host and a usb device controller. Both share some resources, namely:

- the io space
- the clocks
- the interrupt
- while being a seperate device they both share the phy

Everything that is shared should be handled by imx-otg.c. Whenever imx-otg.c detects host mode it passes control to the ehci driver. When imx-otg.c detects that the device is unplugged then it should remove the host via usb_remove_hcd. device mode would be similar.
For now we don't implement device mode and do not automatically detect host/device mode which makes things simpler. Still the calls have to be in the right place.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#75 lore raw

PATCH v2 9/10 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/Kconfig       |    2 ++
 arch/arm/mach-mxs/mach-m28evk.c |   15 +++++++++++++++
 2 files changed, 17 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 +15 -0
index 06d7996..85c4f30 100644
@@ -39,6 +39,7 @@
 
 #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 MX28EVK_MMC0_WRITE_PROTECT	MXS_GPIO_NR(2, 12)
 #define MX28EVK_MMC1_WRITE_PROTECT	MXS_GPIO_NR(0, 28)
@@ -210,6 +211,11 @@ static const iomux_cfg_t m28evk_pads[] __initconst = {
 
 	/* Backlight */
 	MX28_PAD_PWM3__GPIO_3_28 | MXS_PAD_CTRL,
+
+	/* USB */
+	MX28_PAD_SSP2_SS1__USB1_OVERCURRENT,
+	MX28_PAD_AUART3_TX__GPIO_3_13 |
+		MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP,
 };
 
 /* led */
@@ -319,6 +325,8 @@ static struct mxs_mmc_platform_data m28evk_mmc_pdata[] __initdata = {
 
 static void __init m28evk_init(void)
 {
+	int ret;
+
 	mxs_iomux_setup_multiple_pads(m28evk_pads, ARRAY_SIZE(m28evk_pads));
 
 	mx28_add_duart();
@@ -344,6 +352,13 @@ 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));
+
+	ret = gpio_request_one(M28EVK_USB_ENABLE, GPIOF_OUT_INIT_LOW,
+				"USB Power");
+	if (ret)
+		pr_warn("Failed to request USB Power GPIO, %d\n", ret);
+
+	mx28_add_mxs_usbh(1);
 }
 
 static void __init m28evk_timer_init(void)
Signature · 1 line
1.7.9.5
#76 lore raw

PATCH v2 10/10 MXS: Enable USB on MX28EVK

In reply to Marek Vasut
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/Kconfig        |    2 ++
 arch/arm/mach-mxs/mach-mx28evk.c |   10 ++++++++++
 2 files changed, 12 insertions(+)
arch/arm/mach-mxs/Kconfig +2 -0
index 05f6e84..5083db3 100644
@@ -53,6 +53,8 @@ config MACH_MX28EVK
 	select MXS_HAVE_PLATFORM_MXS_SAIF
 	select MXS_HAVE_PLATFORM_MXS_I2C
 	select MXS_HAVE_PLATFORM_RTC_STMP3XXX
+	select MXS_HAVE_PLATFORM_USB
+	select USB_ARCH_HAS_EHCI
 	select MXS_OCOTP
 	help
 	  Include support for MX28EVK platform. This includes specific
arch/arm/mach-mxs/mach-mx28evk.c +10 -0
index e386c14..8bdd416 100644
@@ -37,6 +37,7 @@
 #define MX28EVK_BL_ENABLE	MXS_GPIO_NR(3, 18)
 #define MX28EVK_LCD_ENABLE	MXS_GPIO_NR(3, 30)
 #define MX28EVK_FEC_PHY_RESET	MXS_GPIO_NR(4, 13)
+#define MX28EVK_USB1_PWR_EN	MXS_GPIO_NR(3, 8)
 
 #define MX28EVK_MMC0_WRITE_PROTECT	MXS_GPIO_NR(2, 12)
 #define MX28EVK_MMC1_WRITE_PROTECT	MXS_GPIO_NR(0, 28)
@@ -186,6 +187,8 @@ static const iomux_cfg_t mx28evk_pads[] __initconst = {
 
 	/* led */
 	MX28_PAD_AUART1_TX__GPIO_3_5 | MXS_PAD_CTRL,
+	/* usb1 */
+	MX28_PAD_AUART2_RX__GPIO_3_8 | MXS_PAD_CTRL,
 
 	/* I2C */
 	MX28_PAD_I2C0_SCL__I2C0_SCL |
@@ -451,6 +454,13 @@ static void __init mx28evk_init(void)
 	mx28_add_mxs_mmc(0, &mx28evk_mmc_pdata[0]);
 	mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata[1]);
 
+	ret = gpio_request_one(MX28EVK_USB1_PWR_EN, GPIOF_OUT_INIT_HIGH,
+				"usb1-power-en");
+	if (ret)
+		pr_warn("failed to request gpio usb1-power-en %d\n", ret);
+
+	mx28_add_mxs_usbh(1);
+
 	mx28_add_rtc_stmp3xxx();
 
 	gpio_led_register_device(0, &mx28evk_led_data);
Signature · 1 line
1.7.9.5
#77 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut
Quoted 45 lines

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

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.

Marek Vasut (10):
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-usb and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

 arch/arm/mach-mxs/Kconfig                       |    4 +
 arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
 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/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   15 ++
 arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
 drivers/usb/host/Kconfig                        |    7 +
 drivers/usb/host/ehci-hcd.c                     |    5 +
 drivers/usb/host/ehci-mxs.c                     |  228 +++++++++++++++++
 drivers/usb/otg/Kconfig                         |   16 ++
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-usb.c                       |  226 +++++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  305
+++++++++++++++++++++++ include/linux/fsl_devices.h                     | 
 10 +
 19 files changed, 952 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
 create mode 100644 drivers/usb/host/ehci-mxs.c
 create mode 100644 drivers/usb/otg/imx-usb.c
 create mode 100644 drivers/usb/otg/mxs-phy.c
Quoted 13 lines
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

btw /wrt USB Gadget etc -- how does the drivers/usb/gadget/fsl_udc_core.c and drivers/usb/gadget/ci13xxx_* fit into the big picture? We're gonna use the ci13xxx stuff for Gadget on mx28, correct? Then how does fsl_udc_core.c fit in?

Best regards,
Marek Vasut

maintainer
#78 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

Quoted 15 lines · Marek Vasut
Quoted 14 lines
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
Quoted 5 lines

btw /wrt USB Gadget etc -- how does the drivers/usb/gadget/fsl_udc_core.c and drivers/usb/gadget/ci13xxx_* fit into the big picture? We're gonna use the ci13xxx stuff for Gadget on mx28, correct? Then how does fsl_udc_core.c fit in?

From what I have been told by a collegue the ci13xxx driver works

better, and from what I have seen the code looks better. So I think mxs should use it. i.MX can then use it later aswell. We won't need the fsl_udc_core driver anymore then.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#79 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

Quoted 10 lines · Sascha Hauer
Quoted 4 lines

btw /wrt USB Gadget etc -- how does the drivers/usb/gadget/fsl_udc_core.c and drivers/usb/gadget/ci13xxx_* fit into the big picture? We're gonna use the ci13xxx stuff for Gadget on mx28, correct? Then how does fsl_udc_core.c fit in?

From what I have been told by a collegue the ci13xxx driver works better, and from what I have seen the code looks better. So I think mxs should use it. i.MX can then use it later aswell. We won't need the fsl_udc_core driver anymore then.

Oh, I find I lost many discussions using company email.

Quoted 1 line

From the function and quality level, fsl_udc_core.c is absolutely the

best one for all
i.mx SoCs, as both internal and upstream fsl code use it.

It discussed before:
http://marc.info/?l=linux-usb&m=129906859817430&w=2

I just wonder if ci13xxx_udc.c can support fsl's well as it has below at comment.

/*
* Description: MIPS USB IP core family device controller
* Currently it only supports IP part number CI13412
*/
I will check with IC guys to see if i.mx's controller is compatible with CI13412.
If fsl's compatible with CI13412, then mxs can try to use ci13xxx_udc.c to see if there are any problems, If no problems with kinds of testing, we can switch all i.mx SoC to ci13xxx_udc.c.

Quoted 11 lines

Sascha

--

Pengutronix e.K. ? ? ? ? ? ? ? ? ? ? ? ? ? | ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
Industrial Linux Solutions ? ? ? ? ? ? ? ? | http://www.pengutronix.de/ ?|
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 ? ?|
Amtsgericht Hildesheim, HRA 2686 ? ? ? ? ? | Fax: ? +49-5121-206917-5555 |

--
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

Signature · 2 lines
BR,
Peter Chen
#80 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

Dear Peter Chen,

Quoted 11 lines · Sascha Hauer
Quoted 9 lines
Quoted 4 lines

btw /wrt USB Gadget etc -- how does the drivers/usb/gadget/fsl_udc_core.c and drivers/usb/gadget/ci13xxx_* fit into the big picture? We're gonna use the ci13xxx stuff for Gadget on mx28, correct? Then how does fsl_udc_core.c fit in?

From what I have been told by a collegue the ci13xxx driver works better, and from what I have seen the code looks better. So I think mxs should use it. i.MX can then use it later aswell. We won't need the fsl_udc_core driver anymore then.

Quoted 4 lines

Oh, I find I lost many discussions using company email. From the function and quality level, fsl_udc_core.c is absolutely the best one for all
i.mx SoCs, as both internal and upstream fsl code use it.

Internally though, it looks like crap. Also, ci13xxx and fsl_usb_core is duplicated stuff, correct?

Quoted 11 lines

It discussed before:
http://marc.info/?l=linux-usb&m=129906859817430&w=2

I just wonder if ci13xxx_udc.c can support fsl's well as it has below at comment.

/*
* Description: MIPS USB IP core family device controller
* Currently it only supports IP part number CI13412
*/

It doesn't matter if it's MIPS or whatever it is. Broadcom also managed to hack AMBA bus onto mips core ;-)

Quoted 5 lines

I will check with IC guys to see if i.mx's controller is compatible with CI13412.
If fsl's compatible with CI13412, then mxs can try to use ci13xxx_udc.c to see if there are any problems, If no problems with kinds of testing, we can switch all i.mx SoC to ci13xxx_udc.c.

Sascha, did you need to patch this ci13xxx somehow to get it running on MXS ? Or what was it that said he got it somehow running?

Quoted 12 lines
Quoted 5 lines

Sascha

--
Pengutronix e.K. |

Quoted 7 lines
| Industrial Linux Solutions                 |
http://www.pengutronix.de/  | Peiner Str. 6-8, 31137 Hildesheim, Germany
| Phone: +49-5121-206917-0    | Amtsgericht Hildesheim, HRA 2686        
  | Fax:   +49-5121-206917-5555 | --

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

Best regards,
Marek Vasut

#81 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

Quoted 6 lines · Marek Vasut
Quoted 3 lines

From the function and quality level, fsl_udc_core.c is absolutely the best one for all i.mx SoCs, as both internal and upstream fsl code use it.

Internally though, it looks like crap. Also, ci13xxx and fsl_usb_core is duplicated stuff, correct?

As far as I know, this is a "Synopsys USB 2.0 High Speed Altantic Controller". There are different drivers in mainline for this core:

- ci13xxx_udc
- fsl_usb_core
- langwell_udc

I think there even was a fourth, but I can't remember which one.

All with a different level of abstraction and features.

rsc

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
maintainer
#82 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut
Quoted 13 lines · Marek Vasut

Dear Peter Chen,

Quoted 11 lines · Sascha Hauer
Quoted 9 lines
Quoted 4 lines

btw /wrt USB Gadget etc -- how does the drivers/usb/gadget/fsl_udc_core.c and drivers/usb/gadget/ci13xxx_* fit into the big picture? We're gonna use the ci13xxx stuff for Gadget on mx28, correct? Then how does fsl_udc_core.c fit in?

From what I have been told by a collegue the ci13xxx driver works better, and from what I have seen the code looks better. So I think mxs should use it. i.MX can then use it later aswell. We won't need the fsl_udc_core driver anymore then.

Quoted 6 lines
Quoted 4 lines

Oh, I find I lost many discussions using company email. From the function and quality level, fsl_udc_core.c is absolutely the best one for all
i.mx SoCs, as both internal and upstream fsl code use it.

Internally though, it looks like crap.

+1 on this.

Quoted 1 line

Also, ci13xxx and fsl_usb_core is duplicated stuff, correct?

Yes.

Quoted 9 lines
Quoted 6 lines

I will check with IC guys to see if i.mx's controller is compatible with CI13412.
If fsl's compatible with CI13412, then mxs can try to use ci13xxx_udc.c to see if there are any problems, If no problems with kinds of testing, we can switch all i.mx SoC to ci13xxx_udc.c.

Sascha, did you need to patch this ci13xxx somehow to get it running on MXS ? Or what was it that said he got it somehow running?

It basically works out of the box. I think we have some patches for this driver, maybe michael can comment on this.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#83 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

Quoted 14 lines · Sascha Hauer
Quoted 13 lines · Marek Vasut

Dear Peter Chen,

Quoted 11 lines · Sascha Hauer
Quoted 9 lines
Quoted 4 lines

btw /wrt USB Gadget etc -- how does the drivers/usb/gadget/fsl_udc_core.c and drivers/usb/gadget/ci13xxx_* fit into the big picture? We're gonna use the ci13xxx stuff for Gadget on mx28, correct? Then how does fsl_udc_core.c fit in?

From what I have been told by a collegue the ci13xxx driver works better, and from what I have seen the code looks better. So I think mxs should use it. i.MX can then use it later aswell. We won't need the fsl_udc_core driver anymore then.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Oh, I find I lost many discussions using company email. From the function and quality level, fsl_udc_core.c is absolutely the best one for all
i.mx SoCs, as both internal and upstream fsl code use it.

Internally though, it looks like crap.

+1 on this.

+1

We also made some tests with some gadget devices. IMHO we had troubles with gadget_zero and testusb on the fsl_udc_core.c. I think the testusb results should help to decide which is the most stable implementation.

Quoted 12 lines
Quoted 2 lines

Also, ci13xxx and fsl_usb_core is duplicated stuff, correct?

Yes.

Quoted 7 lines
Quoted 6 lines

I will check with IC guys to see if i.mx's controller is compatible with CI13412.
If fsl's compatible with CI13412, then mxs can try to use ci13xxx_udc.c to see if there are any problems, If no problems with kinds of testing, we can switch all i.mx SoC to ci13xxx_udc.c.

Quoted 5 lines
Quoted 2 lines

Sascha, did you need to patch this ci13xxx somehow to get it running on MXS ? Or what was it that said he got it somehow running?

It basically works out of the box. I think we have some patches for this driver, maybe michael can comment on this.

Yes, i have some smaller bugfix patches hanging around. I will send them to the linux-usb mailinglist until the next week. Additionaly i have some platform gluecode and a platform-support patch for the driver but you probably have the same.

The ci13xxx_udc_driver has a flags element, which has to be set appropriate to the used platform. On the mx23 for example we only were able to get all testusb results correct, when the option CI13XXX_DISABLE_STREAMING was set. In the OTG case the option CI13XXX_REGS_SHARED is mandatory.

Regards,
Michael

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#84 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines

Dear Peter Chen,

Quoted 15 lines · Sascha Hauer
Quoted 9 lines
Quoted 4 lines

btw /wrt USB Gadget etc -- how does the drivers/usb/gadget/fsl_udc_core.c and drivers/usb/gadget/ci13xxx_* fit into the big picture? We're gonna use the ci13xxx stuff for Gadget on mx28, correct? Then how does fsl_udc_core.c fit in?

From what I have been told by a collegue the ci13xxx driver works better, and from what I have seen the code looks better. So I think mxs should use it. i.MX can then use it later aswell. We won't need the fsl_udc_core driver anymore then.

Oh, I find I lost many discussions using company email. From the function and quality level, fsl_udc_core.c is absolutely the best one for all
i.mx SoCs, as both internal and upstream fsl code use it.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Internally though, it looks like crap.

+1 on this.

+1

Your guys all consider ci13xxx is better than fsl_udc_core.c, can you list some reasons?
Or just because it can compatible with your prefer OTG structure (like msm_otg.c)?

Quoted 1 line

From my point, I also admit OTG structure like msm_otg.c is good one

and we can
follow it at i.mx USB structure.

Quoted 5 lines

We also made some tests with some gadget devices. IMHO we had troubles with gadget_zero and testusb on the fsl_udc_core.c. I think the testusb results should help to decide which is the most stable implementation.

ci13xxx one is no problem? Have you checked why it failed at fsl_udc_core.c?

Quoted 24 lines
Quoted 13 lines
Quoted 3 lines

Also, ci13xxx and fsl_usb_core is duplicated stuff, correct?

Yes.

Quoted 7 lines
Quoted 6 lines

I will check with IC guys to see if i.mx's controller is compatible with CI13412.
If fsl's compatible with CI13412, then mxs can try to use ci13xxx_udc.c to see if there are any problems, If no problems with kinds of testing, we can switch all i.mx SoC to ci13xxx_udc.c.

Quoted 5 lines
Quoted 2 lines

Sascha, did you need to patch this ci13xxx somehow to get it running on MXS ? Or what was it that said he got it somehow running?

It basically works out of the box. I think we have some patches for this driver, maybe michael can comment on this.

Yes, i have some smaller bugfix patches hanging around. I will send them to the linux-usb mailinglist until the next week. Additionaly i have some platform gluecode and a platform-support patch for the driver but you probably have the same.

Quoted 5 lines

The ci13xxx_udc_driver has a flags element, which has to be set appropriate to the used platform. On the mx23 for example we only were able to get all testusb results correct, when the option CI13XXX_DISABLE_STREAMING was set. In the OTG case the option CI13XXX_REGS_SHARED is mandatory.

I have checked with IC guys, but they doesn't know something like "CI13412" stands
for.
Yes, current many ARM SoC use chipidea SoC, besides,
- ci13xxx_udc
- fsl_usb_core
- langwell_udc
marvell and Tegra are also use this. I have no maintain experiences on abstract one IP driver
from kinds of SoC venders, if one SoC platform finds problem at ci13xxx_udc core,
and submit the patch, it needs to verify at all SoC platforms, it may increase difficulty
for review process and maintenance.
besides, in case this bug-fix is not compatible across kinds of SoC vendors, how to do?
just add the fix at SoC vendor layer's code like ci13xxx_msm.c?

--
BR,
Peter Chen

maintainer
#85 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

Quoted 46 lines · Peter Chen
Quoted 1 line

Your guys all consider ci13xxx is better than fsl_udc_core.c, can you list some reasons?
Or just because it can compatible with your prefer OTG structure (like msm_otg.c)?
From my point, I also admit OTG structure like msm_otg.c is good one and we can
follow it at i.mx USB structure.

Quoted 5 lines

We also made some tests with some gadget devices. IMHO we had troubles with gadget_zero and testusb on the fsl_udc_core.c. I think the testusb results should help to decide which is the most stable implementation.

ci13xxx one is no problem? Have you checked why it failed at fsl_udc_core.c?

Quoted 24 lines
Quoted 13 lines
Quoted 3 lines

Also, ci13xxx and fsl_usb_core is duplicated stuff, correct?

Yes.

Quoted 7 lines
Quoted 6 lines

I will check with IC guys to see if i.mx's controller is compatible with CI13412.
If fsl's compatible with CI13412, then mxs can try to use ci13xxx_udc.c to see if there are any problems, If no problems with kinds of testing, we can switch all i.mx SoC to ci13xxx_udc.c.

Quoted 5 lines
Quoted 2 lines

Sascha, did you need to patch this ci13xxx somehow to get it running on MXS ? Or what was it that said he got it somehow running?

It basically works out of the box. I think we have some patches for this driver, maybe michael can comment on this.

Yes, i have some smaller bugfix patches hanging around. I will send them to the linux-usb mailinglist until the next week. Additionaly i have some platform gluecode and a platform-support patch for the driver but you probably have the same.

Quoted 5 lines

The ci13xxx_udc_driver has a flags element, which has to be set appropriate to the used platform. On the mx23 for example we only were able to get all testusb results correct, when the option CI13XXX_DISABLE_STREAMING was set. In the OTG case the option CI13XXX_REGS_SHARED is mandatory.

Quoted 14 lines

I have checked with IC guys, but they doesn't know something like "CI13412" stands
for.
Yes, current many ARM SoC use chipidea SoC, besides,
- ci13xxx_udc
- fsl_usb_core
- langwell_udc
marvell and Tegra are also use this. I have no maintain experiences on abstract one IP driver
from kinds of SoC venders, if one SoC platform finds problem at ci13xxx_udc core,
and submit the patch, it needs to verify at all SoC platforms, it may increase difficulty
for review process and maintenance.

It's been some time since I last heard this argument...

Think about it, with this argument you could start writing your own kernel, because how can you be sure that a change to the Linux Kernel will work on your system?
You get much more maintainability from several SoCs sharing the same code and more people fixing the bugs in your driver. Yes drivers do occasionally break because a certain change is incompatible to a particular SoC, but the advantages of sharing code outweigh this multiple times.
(I didn't make this up myself, the Linux community *lives* this for many years now)

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#86 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut
Quoted 44 lines · Marek Vasut

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

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.

Marek Vasut (10):
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-usb and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

  arch/arm/mach-mxs/Kconfig                       |    4 +
  arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
  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/clock.h          |    2 +-
  arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
  arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
  arch/arm/mach-mxs/mach-m28evk.c                 |   15 ++
  arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
  drivers/usb/host/Kconfig                        |    7 +
  drivers/usb/host/ehci-hcd.c                     |    5 +
  drivers/usb/host/ehci-mxs.c                     |  228 +++++++++++++++++
  drivers/usb/otg/Kconfig                         |   16 ++
  drivers/usb/otg/Makefile                        |    2 +
  drivers/usb/otg/imx-usb.c                       |  226 +++++++++++++++++
  drivers/usb/otg/mxs-phy.c                       |  305 +++++++++++++++++++++++
  include/linux/fsl_devices.h                     |   10 +
  19 files changed, 952 insertions(+), 9 deletions(-)

create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c create mode 100644 drivers/usb/host/ehci-mxs.c create mode 100644 drivers/usb/otg/imx-usb.c create mode 100644 drivers/usb/otg/mxs-phy.c

Quoted 14 lines
Cc Chen Peter-B29397<[email protected]>
Cc Detlev Zundel<[email protected]>
Cc Fabio Estevam<[email protected]>
Cc Li Frank-B20596<[email protected]>
Cc Lin Tony-B19295<[email protected]>
Cc Linux USB<[email protected]>
Cc Sascha Hauer<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Stefano Babic<[email protected]>
Cc Subodh Nijsure<[email protected]>
Cc Tony Lin<[email protected]>
Cc Wolfgang Denk<[email protected]>

Tested this (v3) patch set on a MX28 based hardware that I have access to, and things worked as expected.

-Subodh

#87 lore raw

v3 cover MXS: Add i.MX28 USB Host driver

Dear Subodh Nijsure,

Quoted 63 lines · Marek Vasut
Quoted 48 lines

This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure.

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.

Marek Vasut (10):
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-usb and EHCI driver
MXS: Add platform registration hooks for USB EHCI
MXS: Add imx-usb driver
MXS: Add USB PHY driver
MXS: Add separate MXS EHCI HCD driver
MXS: Enable USB on M28EVK
MXS: Enable USB on MX28EVK

  arch/arm/mach-mxs/Kconfig                       |    4 +
  arch/arm/mach-mxs/clock-mx28.c                  |   28 ++-
  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/clock.h          |    2 +-
  arch/arm/mach-mxs/include/mach/devices-common.h |    9 +
  arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
  arch/arm/mach-mxs/mach-m28evk.c                 |   15 ++
  arch/arm/mach-mxs/mach-mx28evk.c                |   10 +
  drivers/usb/host/Kconfig                        |    7 +
  drivers/usb/host/ehci-hcd.c                     |    5 +
  drivers/usb/host/ehci-mxs.c                     |  228
  +++++++++++++++++ drivers/usb/otg/Kconfig                         |  
  16 ++
  drivers/usb/otg/Makefile                        |    2 +
  drivers/usb/otg/imx-usb.c                       |  226
  +++++++++++++++++ drivers/usb/otg/mxs-phy.c                       | 
  305 +++++++++++++++++++++++ include/linux/fsl_devices.h               
       |   10 +
  19 files changed, 952 insertions(+), 9 deletions(-)

create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c create mode 100644 drivers/usb/host/ehci-mxs.c create mode 100644 drivers/usb/otg/imx-usb.c create mode 100644 drivers/usb/otg/mxs-phy.c

Quoted 13 lines
Cc Chen Peter-B29397<[email protected]>
Cc Detlev Zundel<[email protected]>
Cc Fabio Estevam<[email protected]>
Cc Li Frank-B20596<[email protected]>
Cc Lin Tony-B19295<[email protected]>
Cc Linux USB<[email protected]>
Cc Sascha Hauer<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Shawn Guo<[email protected]>
Cc Stefano Babic<[email protected]>
Cc Subodh Nijsure<[email protected]>
Cc Tony Lin<[email protected]>
Cc Wolfgang Denk<[email protected]>
Quoted 4 lines

Tested this (v3) patch set on a MX28 based hardware that I have access to, and things worked as expected.

Thank you for your testing. Today, I was enlightened by some USB celestial being I guess ... I finally got the UDC working and I see the whole big picture of how to implement this thing altogether :-) Expect V4 with some reworks, esp. about IRQ handling etc.

Quoted 2 lines

-Subodh

Best regards,
Marek Vasut

#88 lore raw

v4 cover MXS: Add i.MX28 USB Host driver

In reply to 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.

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)

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        |   84 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |   12 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   20 ++
 drivers/usb/gadget/Kconfig                      |   17 +
 drivers/usb/gadget/Makefile                     |    1 +
 drivers/usb/gadget/ci13xxx_mxs.c                |   67 ++++
 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                     |  197 ++++++++++
 drivers/usb/otg/Kconfig                         |   16 +
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-otg.c                       |  282 +++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  438 +++++++++++++++++++++++
 include/linux/fsl/mxs-usb.h                     |   46 +++
 23 files changed, 1243 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/fsl/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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

NOTE: Adding this ci13xxx-mxs driver was really helpful, it helped me to realise
how this whole monster should look like in the end. Now the mxs-phy is also much more prepared for the OTG operation.

Signature · 1 line
1.7.9.5
#89 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#90 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#91 lore raw

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

Quoted 17 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
Quoted 4 lines
---
 arch/arm/mach-mxs/clock-mx28.c |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

The first 2 patches in series are patching files to be removed. We are switching mxs clock to common clk framework.

Signature · 2 lines
Regards,
Shawn
#92 lore raw

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

Dear Shawn Guo,

Quoted 20 lines · Marek Vasut
Quoted 19 lines

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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

---

Quoted 5 lines
Quoted 2 lines
 arch/arm/mach-mxs/clock-mx28.c |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

The first 2 patches in series are patching files to be removed. We are switching mxs clock to common clk framework.

When is this mxs clock framework scheduled to hit mainline? I obviously had to patch this stuff to work with mainline, once there's new framework, it should be easy to just change these patches.

Best regards,
Marek Vasut

#93 lore raw

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

Quoted 22 lines · Marek Vasut

Dear Shawn Guo,

Quoted 20 lines · Marek Vasut
Quoted 19 lines

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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

---

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
 arch/arm/mach-mxs/clock-mx28.c |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

The first 2 patches in series are patching files to be removed. We are switching mxs clock to common clk framework.

When is this mxs clock framework scheduled to hit mainline?

v3.5 merge window.

Signature · 2 lines
Regards,
Shawn
#94 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#95 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 include/linux/fsl/mxs-usb.h |   46 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 include/linux/fsl/mxs-usb.h
include/linux/fsl/mxs-usb.h new file +46 -0
new file mode 100644
index 0000000..8326a79
@@ -0,0 +1,46 @@
+/*
+ * include/linux/fsl/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_FSL_MXS_USB_H__
+#define __INCLUDE_LINUX_FSL_MXS_USB_H__
+
+#include <linux/types.h>
+#include <linux/platform_device.h>
+
+struct imx_usb {
+	struct platform_device	*pdev_host;
+	struct platform_device	*pdev_gadget;
+
+	struct clk		*clk;
+	struct resource		*mem_res;
+	void __iomem		*mem;
+	int			irq;
+};
+
+struct imx_usb_platform_data {
+	uint32_t		gpio_vbus;
+	bool			gpio_vbus_inverted;
+	bool			host_mode;
+};
+
+#endif /* __INCLUDE_LINUX_FSL_MXS_USB_H__ */
Signature · 1 line
1.7.9.5
#96 lore raw

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

Quoted 19 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
Quoted 4 lines
---
 include/linux/fsl/mxs-usb.h |   46 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 include/linux/fsl/mxs-usb.h

As what Wolfram and Arnd pointed out in thread [1], include/linux/fsl is not a good choice. Instead, it should be include/linux/usb/mxs-usb.h.

Regards,
Shawn

[1] http://thread.gmane.org/gmane.linux.kernel/1271153/focus=163132

#97 lore raw

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

Dear Shawn Guo,

Quoted 22 lines · Marek Vasut
Quoted 21 lines

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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

---

Quoted 7 lines
Quoted 4 lines
 include/linux/fsl/mxs-usb.h |   46
 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46
 insertions(+)
 create mode 100644 include/linux/fsl/mxs-usb.h

As what Wolfram and Arnd pointed out in thread [1], include/linux/fsl is not a good choice. Instead, it should be include/linux/usb/mxs-usb.h.

Ok, noted. Will add in V5. What about the rest of these patches, I'd be interested to hear your opinion on these :-)

Quoted 5 lines

Regards,
Shawn

[1] http://thread.gmane.org/gmane.linux.kernel/1271153/focus=163132

Best regards,
Marek Vasut

#98 lore raw

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

Quoted 3 lines · Marek Vasut

Ok, noted. Will add in V5. What about the rest of these patches, I'd be interested to hear your opinion on these :-)

I have not looked into drivers/usb patches. I doubt I have enough knowledge about usb subsystem to give constructive comments. Sorry.

For arch/arm/mach-mxs changes, I think you have known my position, device tree.

Signature · 2 lines
Regards,
Shawn
#99 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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.9.5
#100 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/gadget/Kconfig       |   17 ++++++++++
 drivers/usb/gadget/Makefile      |    1 +
 drivers/usb/gadget/ci13xxx_mxs.c |   67 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 drivers/usb/gadget/ci13xxx_mxs.c
drivers/usb/gadget/Kconfig +17 -0
index 2633f75..d97abd8 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_msm" 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 +67 -0

67 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#101 lore raw

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

Quoted 9 lines
drivers/usb/gadget/Kconfig +7 -0
+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

drivers/usb/gadget/Kconfig config USB_CI13XXX_MSM · line 513

Quoted 10 lines
drivers/usb/gadget/Kconfig +10 -0
+	  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_msm" and force all
+	  gadget drivers to also be dynamically linked.
+

cil3xxx_msm????? should be cil3xxx_mxs?

Quoted 92 lines

#
# 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 +67 -1
new file mode 100644
index 0000000..35a3dd4
@@ -0,0 +1,67 @@
+/* Copyright (c) 2010, Code Aurora Forum. 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 and
+ * only version 2 as published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+#include <linux/usb/ulpi.h>
+#include <linux/fsl/mxs-usb.h>
+
+#include "ci13xxx_udc.c"
+
+#define MSM_USB_BASE	(udc->regs)
+
+static irqreturn_t mxs_udc_irq(int irq, void *data)
+{
+	return udc_irq();
+}
+
+static struct ci13xxx_udc_driver ci13xxx_mxs_udc_driver = {
+	.name			= "ci13xxx-mxs",
+	.flags			= CI13XXX_REQUIRE_TRANSCEIVER |
+				  CI13XXX_DISABLE_STREAMING |
+				  CI13XXX_DONT_REGISTER_GADGET,
+};
+
+static int ci13xxx_mxs_probe(struct platform_device *pdev)
+{
+	struct imx_usb *data = pdev->dev.platform_data;
+	int ret;
+
+	ret = devm_request_irq(&pdev->dev, data->irq, mxs_udc_irq,
+				IRQF_SHARED, pdev->name, pdev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Failed to request IRQ!\n");
+		return ret;
+	}
+
+	ret = udc_probe(&ci13xxx_mxs_udc_driver, &pdev->dev, data->mem);
+	if (ret < 0)
+		dev_err(&pdev->dev, "Failed to probe CI13xxx-mxs!\n");
+
+	pm_runtime_no_callbacks(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+
+	return ret;
+}
+
+static struct platform_driver ci13xxx_mxs_driver = {
+	.probe		= ci13xxx_mxs_probe,
+	.driver		= {
+		.name	= "ci13xxx-mxs",
+	},
+};
+
+static int __init ci13xxx_mxs_init(void)
+{
+	return platform_driver_register(&ci13xxx_mxs_driver);
+}
+
+module_init(ci13xxx_mxs_init);
+
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:ci13xxx-mxs");
--

1.7.9.5

#102 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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 |  197 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 209 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 +197 -0

197 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#103 lore raw

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

Quoted 6 lines

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.

Hi Marek, I have already explain how to use high speed disconnect detector in early email.

Quoted 6 lines
drivers/usb/host/ehci-mxs.c new file +6 -0
+
+static irqreturn_t mxs_ehci_irq(struct usb_hcd *hcd)
+{
+	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+	struct usb_phy *phy = usb_get_transceiver();
+	uint32_t status;

drivers/usb/host/ehci-mxs.c line 66

Quoted 10 lines
drivers/usb/host/ehci-mxs.c new file +10 -0
+	static uint32_t discon;
+
+	if (phy && phy->otg && phy->otg->set_vbus) {
+		status = ehci_readl(ehci, &ehci->regs->status);
+		status = !!(status & STS_PCD);
+		if (status != discon) {
+			discon = status;
+			phy->otg->set_vbus(phy->otg, status);
+		}
+	}

Conflict with your phy interrupt code.

#104 lore raw

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

Dear Chen Peter-B29397,

Quoted 18 lines
Quoted 4 lines

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.

Hi Marek, I have already explain how to use high speed disconnect detector in early email.

Quoted 10 lines
drivers/usb/host/ehci-mxs.c new file +10 -0
+
+static irqreturn_t mxs_ehci_irq(struct usb_hcd *hcd)
+{
+	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+	struct usb_phy *phy = usb_get_transceiver();
+	uint32_t status;
+	static uint32_t discon;
+
+	if (phy && phy->otg && phy->otg->set_vbus) {
+		status = ehci_readl(ehci, &ehci->regs->status);
Quoted 8 lines

drivers/usb/host/ehci-mxs.c line 66

Quoted 6 lines
drivers/usb/host/ehci-mxs.c new file +6 -0
+		status = !!(status & STS_PCD);
+		if (status != discon) {
+			discon = status;
+			phy->otg->set_vbus(phy->otg, status);
+		}
+	}

Conflict with your phy interrupt code.

Yes, this should have been removed, rebase issue. Damn

Best regards,
Marek Vasut

#105 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  282 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 289 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 +282 -0

282 lines not on this page · raw message

Signature · 1 line
1.7.9.5
maintainer
#106 lore raw

PATCH 8/11 MXS: Add imx-otg driver

Quoted 297 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  282 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 289 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 +239 -0
new file mode 100644
index 0000000..249b6b5
@@ -0,0 +1,282 @@
+/*
+ * drivers/usb/otg/imx-otg.c
+ *
+ * Freescale i.MX USB composite driver.
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/usb.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/hcd.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fsl/mxs-usb.h>
+#include <linux/io.h>
+
+#include <mach/common.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+/*
+ * Allocate platform device with the DMA mask, this is borrowed from
+ * arch/arm/mach-mxs/devices.c
+ */
+static struct platform_device *__devinit add_platform_device(
+		const char *name, int id,
+		const void *data, size_t size_data, u64 dmamask)
+{
+	int ret = -ENOMEM;
+	struct platform_device *pdev;
+
+	pdev = platform_device_alloc(name, id);
+	if (!pdev)
+		goto err;
+
+	if (dmamask) {
+		/*
+		 * This memory isn't freed when the device is put,
+		 * I don't have a nice idea for that though.  Conceptually
+		 * dma_mask in struct device should not be a pointer.
+		 * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
+		 */
+		pdev->dev.dma_mask =
+			kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
+		if (!pdev->dev.dma_mask)
+			/* ret is still -ENOMEM; */
+			goto err;
+
+		*pdev->dev.dma_mask = dmamask;
+		pdev->dev.coherent_dma_mask = dmamask;
+	}
+
+	if (data) {
+		ret = platform_device_add_data(pdev, data, size_data);
+		if (ret)
+			goto err;
+	}
+
+	ret = platform_device_add(pdev);
+	if (ret) {
+err:
+		if (dmamask)
+			kfree(pdev->dev.dma_mask);
+		platform_device_put(pdev);
+		return ERR_PTR(ret);
+	}
+
+	return pdev;
+}
+
+static int __devinit imx_usb_probe(struct platform_device *pdev)
+{
+	struct imx_usb_platform_data *pdata = pdev->dev.platform_data;
+	struct imx_usb *data;
+	struct usb_phy *phy;
+	int ret;
+	void *retp = NULL;
+
+	if (!pdata) {
+		dev_err(&pdev->dev, "No platform data supplied!\n");
+		return -ENODEV;
+	}
+
+	phy = usb_get_transceiver();
+	if (!phy)
+		return -EPROBE_DEFER;
+
+	/*
+	 * Until further notice, this claims all necessary resources.
+	 */
+
+	/* Allocate driver's private date. */
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+	if (!data) {
+		ret = -ENOMEM;
+		goto err_alloc_data;
+	}
+
+	/* Claim the Host clock. */
+	data->clk = clk_get(&pdev->dev, "usb");
+	if (IS_ERR(data->clk)) {
+		dev_err(&pdev->dev, "Failed to claim clock for USB Host\n");
+		ret = PTR_ERR(data->clk);
+		goto err_claim_host_clock;
+	}
+
+	/* Prepare Host clock. */
+	ret = clk_prepare_enable(data->clk);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to enable clock for USB Host.\n");
+		goto err_prepare_host_clock;
+	}
+
+	/* Get memory area for EHCI host from resources. */
+	data->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!data->mem_res) {
+		dev_err(&pdev->dev, "Specify memory area for this USB Host!\n");
+		ret = -ENODEV;
+		goto err_get_host_resource;
+	}
+
+	/* Request the memory region for this USB Host. */
+	retp = devm_request_mem_region(&pdev->dev, data->mem_res->start,
+			resource_size(data->mem_res), pdev->name);
+	if (!retp) {
+		dev_err(&pdev->dev, "USB Host memory area already in use!\n");
+		ret = -EBUSY;
+		goto err_get_host_mem;
+	}
+
+	/* Map the memory region for USB Host. */
+	data->mem = devm_ioremap(&pdev->dev, data->mem_res->start,
+				resource_size(data->mem_res));
+	if (!data->mem) {
+		dev_err(&pdev->dev, "Memory mapping of USB Host failed!\n");
+		ret = -EFAULT;
+		goto err_map_host_mem;
+	}
+
+	/* Get IRQ for EHCI host from resources. */
+	data->irq = platform_get_irq(pdev, 0);
+	if (data->irq < 0) {
+		dev_err(&pdev->dev, "Specify IRQ for this USB Host!\n");
+		ret = -ENODEV;
+		goto err_get_host_irq;
+	}
+
+	/*
+	 * Now finally probe the Host driver!
+	 */
+	if (pdata->host_mode) {
+		data->pdev_host = add_platform_device("mxs-ehci", -1,
+							data, sizeof(*data),
+							DMA_BIT_MASK(32));
+		if (!data->pdev_host) {
+			dev_err(&pdev->dev, "Failed registering Host!\n");
+			ret = -ENODEV;
+			goto err_register_host;
+		}
+	} else {
+		data->pdev_gadget = add_platform_device("ci13xxx-mxs", -1,
+							data, sizeof(*data),
+							DMA_BIT_MASK(32));
+		if (!data->pdev_gadget) {
+			dev_err(&pdev->dev, "Failed registering Host!\n");
+			ret = -ENODEV;
+			goto err_register_gadget;
+		}
+	}
+
+	/*
+	 * Initialize the transceiver
+	 */
+	phy = usb_get_transceiver();
+	if (!phy) {
+		dev_err(&pdev->dev, "Unable to find transceiver.\n");
+		ret = -ENODEV;
+		goto err_phy;
+	}
+
+	ret = usb_phy_init(phy);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Unable init transceiver\n");
+		ret = -ENODEV;
+		goto err_phy_init;
+	}
+
+	/* Set up the PORTSCx register */
+	writel(0, data->mem + 0x144);
+
+	return 0;
+
+err_phy_init:
+	if (phy)
+		usb_put_transceiver(phy);
+err_phy:
+	if (data->pdev_gadget)
+		platform_device_unregister(data->pdev_gadget);
+err_register_gadget:
+	if (data->pdev_host)
+		platform_device_unregister(data->pdev_host);
+err_register_host:
+err_get_host_irq:
+	iounmap(data->mem);
+err_map_host_mem:
+	release_mem_region(data->mem_res->start,
+			resource_size(data->mem_res));
+err_get_host_mem:
+	data->mem_res = NULL;
+err_get_host_resource:
+	clk_disable_unprepare(data->clk);
+err_prepare_host_clock:
+	clk_put(data->clk);
+err_claim_host_clock:
+err_alloc_data:
+	return ret;
+}
+
+static int __devexit imx_usb_remove(struct platform_device *pdev)
+{
+	struct imx_usb *data = platform_get_drvdata(pdev);

drivers/usb/otg/imx-otg.c line 249

Quoted 10 lines
drivers/usb/otg/imx-otg.c new file +10 -0
+
+	if (data->pdev_gadget)
+		platform_device_unregister(data->pdev_gadget);
+
+	if (data->pdev_host)
+		platform_device_unregister(data->pdev_host);
+
+	iounmap(data->mem);
+	release_mem_region(data->mem_res->start,
+			resource_size(data->mem_res));

Again, you are using the managed versions of ioremap and request_mem_region. The whole point of these functions is that these resources are automatically released on driver exit (or failure at probe).

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#107 lore raw

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

Dear Sascha Hauer,

Quoted 316 lines · Marek Vasut
Quoted 315 lines

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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

---

 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  282
 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 289
 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

drivers/usb/otg/Kconfig +0 -0
 	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 +246 -0
new file mode 100644
index 0000000..249b6b5
@@ -0,0 +1,282 @@
+/*
+ * drivers/usb/otg/imx-otg.c
+ *
+ * Freescale i.MX USB composite driver.
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/usb.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/hcd.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+#include <linux/fsl/mxs-usb.h>
+#include <linux/io.h>
+
+#include <mach/common.h>
+#include <mach/hardware.h>
+#include <mach/devices-common.h>
+
+/*
+ * Allocate platform device with the DMA mask, this is borrowed from
+ * arch/arm/mach-mxs/devices.c
+ */
+static struct platform_device *__devinit add_platform_device(
+		const char *name, int id,
+		const void *data, size_t size_data, u64 dmamask)
+{
+	int ret = -ENOMEM;
+	struct platform_device *pdev;
+
+	pdev = platform_device_alloc(name, id);
+	if (!pdev)
+		goto err;
+
+	if (dmamask) {
+		/*
+		 * This memory isn't freed when the device is put,
+		 * I don't have a nice idea for that though.  Conceptually
+		 * dma_mask in struct device should not be a pointer.
+		 * See http://thread.gmane.org/gmane.linux.kernel.pci/9081
+		 */
+		pdev->dev.dma_mask =
+			kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
+		if (!pdev->dev.dma_mask)
+			/* ret is still -ENOMEM; */
+			goto err;
+
+		*pdev->dev.dma_mask = dmamask;
+		pdev->dev.coherent_dma_mask = dmamask;
+	}
+
+	if (data) {
+		ret = platform_device_add_data(pdev, data, size_data);
+		if (ret)
+			goto err;
+	}
+
+	ret = platform_device_add(pdev);
+	if (ret) {
+err:
+		if (dmamask)
+			kfree(pdev->dev.dma_mask);
+		platform_device_put(pdev);
+		return ERR_PTR(ret);
+	}
+
+	return pdev;
+}
+
+static int __devinit imx_usb_probe(struct platform_device *pdev)
+{
+	struct imx_usb_platform_data *pdata = pdev->dev.platform_data;
+	struct imx_usb *data;
+	struct usb_phy *phy;
+	int ret;
+	void *retp = NULL;
+
+	if (!pdata) {
+		dev_err(&pdev->dev, "No platform data supplied!\n");
+		return -ENODEV;
+	}
+
+	phy = usb_get_transceiver();
+	if (!phy)
+		return -EPROBE_DEFER;
+
+	/*
+	 * Until further notice, this claims all necessary resources.
+	 */
+
+	/* Allocate driver's private date. */
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+	if (!data) {
+		ret = -ENOMEM;
+		goto err_alloc_data;
+	}
+
+	/* Claim the Host clock. */
+	data->clk = clk_get(&pdev->dev, "usb");
+	if (IS_ERR(data->clk)) {
+		dev_err(&pdev->dev, "Failed to claim clock for USB Host\n");
+		ret = PTR_ERR(data->clk);
+		goto err_claim_host_clock;
+	}
+
+	/* Prepare Host clock. */
+	ret = clk_prepare_enable(data->clk);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to enable clock for USB Host.\n");
+		goto err_prepare_host_clock;
+	}
+
+	/* Get memory area for EHCI host from resources. */
+	data->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!data->mem_res) {
+		dev_err(&pdev->dev, "Specify memory area for this USB Host!\n");
+		ret = -ENODEV;
+		goto err_get_host_resource;
+	}
+
+	/* Request the memory region for this USB Host. */
+	retp = devm_request_mem_region(&pdev->dev, data->mem_res->start,
+			resource_size(data->mem_res), pdev->name);
+	if (!retp) {
+		dev_err(&pdev->dev, "USB Host memory area already in use!\n");
+		ret = -EBUSY;
+		goto err_get_host_mem;
+	}
+
+	/* Map the memory region for USB Host. */
+	data->mem = devm_ioremap(&pdev->dev, data->mem_res->start,
+				resource_size(data->mem_res));
+	if (!data->mem) {
+		dev_err(&pdev->dev, "Memory mapping of USB Host failed!\n");
+		ret = -EFAULT;
+		goto err_map_host_mem;
+	}
+
+	/* Get IRQ for EHCI host from resources. */
+	data->irq = platform_get_irq(pdev, 0);
+	if (data->irq < 0) {
+		dev_err(&pdev->dev, "Specify IRQ for this USB Host!\n");
+		ret = -ENODEV;
+		goto err_get_host_irq;
+	}
+
+	/*
+	 * Now finally probe the Host driver!
+	 */
+	if (pdata->host_mode) {
+		data->pdev_host = add_platform_device("mxs-ehci", -1,
+							data, sizeof(*data),
+							DMA_BIT_MASK(32));
+		if (!data->pdev_host) {
+			dev_err(&pdev->dev, "Failed registering Host!\n");
+			ret = -ENODEV;
+			goto err_register_host;
+		}
+	} else {
+		data->pdev_gadget = add_platform_device("ci13xxx-mxs", -1,
+							data, sizeof(*data),
+							DMA_BIT_MASK(32));
+		if (!data->pdev_gadget) {
+			dev_err(&pdev->dev, "Failed registering Host!\n");
+			ret = -ENODEV;
+			goto err_register_gadget;
+		}
+	}
+
+	/*
+	 * Initialize the transceiver
+	 */
+	phy = usb_get_transceiver();
+	if (!phy) {
+		dev_err(&pdev->dev, "Unable to find transceiver.\n");
+		ret = -ENODEV;
+		goto err_phy;
+	}
+
+	ret = usb_phy_init(phy);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Unable init transceiver\n");
+		ret = -ENODEV;
+		goto err_phy_init;
+	}
+
+	/* Set up the PORTSCx register */
+	writel(0, data->mem + 0x144);
+
+	return 0;
+
+err_phy_init:
+	if (phy)
+		usb_put_transceiver(phy);
+err_phy:
+	if (data->pdev_gadget)
+		platform_device_unregister(data->pdev_gadget);
+err_register_gadget:
+	if (data->pdev_host)
+		platform_device_unregister(data->pdev_host);
+err_register_host:
+err_get_host_irq:
+	iounmap(data->mem);
+err_map_host_mem:
+	release_mem_region(data->mem_res->start,
+			resource_size(data->mem_res));
+err_get_host_mem:
+	data->mem_res = NULL;
+err_get_host_resource:
+	clk_disable_unprepare(data->clk);
+err_prepare_host_clock:
+	clk_put(data->clk);
+err_claim_host_clock:
+err_alloc_data:
+	return ret;
+}
+
+static int __devexit imx_usb_remove(struct platform_device *pdev)
+{
+	struct imx_usb *data = platform_get_drvdata(pdev);
+
+	if (data->pdev_gadget)
+		platform_device_unregister(data->pdev_gadget);
+
+	if (data->pdev_host)
+		platform_device_unregister(data->pdev_host);
+
Quoted 8 lines

drivers/usb/otg/imx-otg.c line 225

Quoted 3 lines
drivers/usb/otg/imx-otg.c new file +3 -0
+	iounmap(data->mem);
+	release_mem_region(data->mem_res->start,
+			resource_size(data->mem_res));

Again, you are using the managed versions of ioremap and request_mem_region. The whole point of these functions is that these resources are automatically released on driver exit (or failure at probe).

Argh. Anyway, I'm more interested to hear your opinion on the general concept, esp. on Peter's comment on otg_set_host()/otg_set_peripheral() -- their implementation should be in the PHY driver and they should be called from EHCI host / ci13xxx gadget driver, correct?

Quoted 1 line

Sascha

#108 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |   10 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  438 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 449 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 +438 -0

438 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#109 lore raw

PATCH v4 9/11 MXS: Add USB PHY driver

Quoted 19 lines
drivers/usb/otg/mxs-phy.c new file +17 -0
+
+#define HW_USBPHY_PWD				0x00
+
+#define HW_USBPHY_CTRL				0x30
+#define HW_USBPHY_CTRL_SET			0x34
+#define HW_USBPHY_CTRL_CLR			0x38
+#define HW_USBPHY_CTRL_TOG			0x3c
+
+#define BM_USBPHY_CTRL_SFTRST			(1 << 31)
+#define BM_USBPHY_CTRL_CLKGATE			(1 << 30)
+#define BM_USBPHY_CTRL_ENUTMILEVEL3		(1 << 15)
+#define BM_USBPHY_CTRL_ENUTMILEVEL2		(1 << 14)
+#define BM_USBPHY_CTRL_ENIRQDEVPLUGIN		(1 << 11)
+#define BM_USBPHY_CTRL_ENOTGIDDETECT		(1 << 7)
+#define BM_USBPHY_CTRL_ENDEVPLUGINDETECT	(1 << 4)
+#define BM_USBPHY_CTRL_HOSTDISCONDETECT_IRQ	(1 << 3)
+#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	(1 << 1)

drivers/usb/otg/mxs-phy.c line 68

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+
+#define HW_USBPHY_STATUS			0x40
+
+#define BM_USBPHY_STATUS_OTGID_STATUS		(1 << 8)
+#define BM_USBPHY_STATUS_DEVPLUGIN_STATUS	(1 << 6)
+#define BM_USBPHY_STATUS_HOSTDISCON_STATUS	(1 << 3)
+
+/* FIXME */
+#define M28EVK_USBOTG_ENABLE	MXS_GPIO_NR(3, 12)
+

This is platform code, should not put at driver.

Quoted 8 lines
drivers/usb/otg/mxs-phy.c new file +8 -0
+struct mxs_usb_phy {
+	struct usb_phy		phy;
+
+	struct work_struct	work;
+
+	struct clk		*clk;
+	struct resource		*mem_res;
+	void __iomem		*mem;

drivers/usb/otg/mxs-phy.c line 86

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+	int			irq;
+	int			gpio_vbus;
+	int			gpio_vbus_inverted;
+
+	enum usb_otg_state	new_state;
+
+	bool			host_mode;
+};
+
+static int mxs_usb_set_host(struct usb_otg *otg, struct usb_bus *host)

should be at imx-otg.c

Quoted 3 lines
(quoted diff) +2 -0
+
+static int mxs_usb_set_peripheral(struct usb_otg *otg, struct usb_gadget

*gg)

gg may not a good name, how about just gadget?
should be at imx-otg.c

Quoted 1 line

+static void mxs_usb_work(struct work_struct *w)

It is OTG switch routine, and should be put imx-otg.c. Sascha also suggested before.

Quoted 43 lines
drivers/usb/otg/mxs-phy.c new file +43 -0
+{
+	struct mxs_usb_phy *phy = container_of(w, struct mxs_usb_phy, work);
+	struct usb_otg *otg = phy->phy.otg;
+	struct usb_hcd *hcd;
+
+	switch (otg->phy->state) {
+	case OTG_STATE_A_HOST:
+		if (phy->new_state == OTG_STATE_UNDEFINED) {
+			hcd = bus_to_hcd(otg->host);
+			usb_remove_hcd(hcd);
+			otg->phy->state = phy->new_state;
+			/* Turn off VBUS */
+			gpio_set_value(phy->gpio_vbus,
+				phy->gpio_vbus_inverted);
+		}
+		break;
+	case OTG_STATE_B_PERIPHERAL:
+		if (phy->new_state == OTG_STATE_UNDEFINED) {
+			usb_del_gadget_udc(otg->gadget);
+			otg->phy->state = phy->new_state;
+		}
+		break;
+	case OTG_STATE_UNDEFINED:
+		/* Check desired state. */
+		switch (phy->new_state) {
+		case OTG_STATE_A_HOST:
+			if (!otg->host)
+				break;
+			otg->phy->state = phy->new_state;
+
+			/* Turn on VBUS */
+			gpio_set_value(phy->gpio_vbus,
+				!phy->gpio_vbus_inverted);
+
+			hcd = bus_to_hcd(otg->host);
+			usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
+			break;
+		case OTG_STATE_B_PERIPHERAL:
+			if (!otg->gadget)
+				break;
+			otg->phy->state = phy->new_state;
+			usb_add_gadget_udc(phy->phy.dev, otg->gadget);
+			break;

drivers/usb/otg/mxs-phy.c line 179

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+		default:
+			break;
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+

Seems you forget one otg state: OTG_STATE_B_IDLE.

at device mode:
OTG_STATE_UNDEFINED -> OTG_STATE_B_IDLE (nothing on port) OTG_STATE_B_PERIPHERAL -> OTG_STATE_B_IDLE (disconnect with host)

Quoted 13 lines
drivers/usb/otg/mxs-phy.c new file +13 -0
+static int mxs_usb_phy_init(struct usb_phy *x)
+{
+	struct mxs_usb_phy *phy = container_of(x, struct mxs_usb_phy, phy);
+	uint32_t val;
+
+	/* Enable clock to the PHY. */
+	clk_enable(phy->clk);
+
+	/* Reset the PHY block. */
+	mxs_reset_block(phy->mem + HW_USBPHY_CTRL);
+
+	/* Power up the PHY. */
+	writel(0, phy->mem + HW_USBPHY_PWD);

drivers/usb/otg/mxs-phy.c line 202

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+
+	/* Enable FS/LS compatibility. */
+	val = BM_USBPHY_CTRL_ENUTMILEVEL2 | BM_USBPHY_CTRL_ENUTMILEVEL3;
+
+	if (phy->host_mode)
+		val |= BM_USBPHY_CTRL_ENHOSTDISCONDETECT;
+	else
+		val |= BM_USBPHY_CTRL_ENIRQDEVPLUGIN |
+			BM_USBPHY_CTRL_ENOTGIDDETECT |
+			BM_USBPHY_CTRL_ENDEVPLUGINDETECT;

Please explain the meaning of above code?

drivers/usb/otg/mxs-phy.c line 212

Quoted 4 lines
drivers/usb/otg/mxs-phy.c new file +4 -0
+static void mxs_usb_phy_shutdown(struct usb_phy *x)
+{
+	struct mxs_usb_phy *phy = container_of(x, struct mxs_usb_phy, phy);
+

You need to set portsc.phcd=1 and power down phy using set 0xffffffff to HW_USBPHY_PWD.

Quoted 9 lines
drivers/usb/otg/mxs-phy.c new file +9 -0
+	/* Gate off the PHY. */
+	writel(BM_USBPHY_CTRL_CLKGATE, phy->mem + HW_USBPHY_CTRL_SET);
+
+	/* Disable clock to the PHY. */
+	clk_disable(phy->clk);
+}
+
+static irqreturn_t mxs_phy_irq(int irq, void *data)
+{

drivers/usb/otg/mxs-phy.c line 231

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+	struct mxs_usb_phy *phy = data;
+	uint32_t status = readl(phy->mem + HW_USBPHY_STATUS);
+
+	if (status & BM_USBPHY_CTRL_HOSTDISCONDETECT_IRQ)
+		writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+			phy->mem + HW_USBPHY_CTRL_CLR);
+	else
+		writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+			phy->mem + HW_USBPHY_CTRL_SET);
+

Have you tested several connect/disconnect operation with high speed device?
- where you clear BM_USBPHY_CTRL_HOSTDISCONDETECT_IRQ?
- This code will always run at every usb interrupt, in fact, high speed detector only needs to be set/clear with connect/disconnect.

Quoted 19 lines
drivers/usb/otg/mxs-phy.c new file +17 -0
+	return IRQ_NONE;
+}
+
 
 
+
+static int __devexit mxs_phy_remove(struct platform_device *pdev)
+{
+	struct mxs_usb_phy *phy = platform_get_drvdata(pdev);
+
+	/* Stop the PHY work. */
+	cancel_work_sync(&phy->work);
+
+	/* Power down the PHY. */
+	mxs_usb_phy_shutdown(&phy->phy);
+
+	/* Remove the transceiver. */
+	usb_set_transceiver(NULL);
+

drivers/usb/otg/mxs-phy.c line 402

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+	/* Shut off VBUS. */
+	gpio_set_value(phy->gpio_vbus, phy->gpio_vbus_inverted);
+	gpio_free(phy->gpio_vbus);
+
+	/* Free the IRQ requested by this device. */
+	free_irq(phy->irq, phy);
+
+	/* Free the IRQ requested by this device. */
+	free_irq(phy->irq, phy);
+

Two free_irq???

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+	/* Stop the PHY clock. */
+	clk_disable_unprepare(phy->clk);
+	clk_put(phy->clk);
+
+	/* Free the rest. */
+	platform_set_drvdata(pdev, NULL);
+
+	return 0;
+}
+
#110 lore raw

PATCH v4 9/11 MXS: Add USB PHY driver

Dear Chen Peter-B29397,

Quoted 42 lines
Quoted 17 lines
drivers/usb/otg/mxs-phy.c new file +17 -0
+
+#define HW_USBPHY_PWD				0x00
+
+#define HW_USBPHY_CTRL				0x30
+#define HW_USBPHY_CTRL_SET			0x34
+#define HW_USBPHY_CTRL_CLR			0x38
+#define HW_USBPHY_CTRL_TOG			0x3c
+
+#define BM_USBPHY_CTRL_SFTRST			(1 << 31)
+#define BM_USBPHY_CTRL_CLKGATE			(1 << 30)
+#define BM_USBPHY_CTRL_ENUTMILEVEL3		(1 << 15)
+#define BM_USBPHY_CTRL_ENUTMILEVEL2		(1 << 14)
+#define BM_USBPHY_CTRL_ENIRQDEVPLUGIN		(1 << 11)
+#define BM_USBPHY_CTRL_ENOTGIDDETECT		(1 << 7)
+#define BM_USBPHY_CTRL_ENDEVPLUGINDETECT	(1 << 4)
+#define BM_USBPHY_CTRL_HOSTDISCONDETECT_IRQ	(1 << 3)
+#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	(1 << 1)

drivers/usb/otg/mxs-phy.c line 68

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+
+#define HW_USBPHY_STATUS			0x40
+
+#define BM_USBPHY_STATUS_OTGID_STATUS		(1 << 8)
+#define BM_USBPHY_STATUS_DEVPLUGIN_STATUS	(1 << 6)
+#define BM_USBPHY_STATUS_HOSTDISCON_STATUS	(1 << 3)
+
+/* FIXME */
+#define M28EVK_USBOTG_ENABLE	MXS_GPIO_NR(3, 12)
+

This is platform code, should not put at driver.

Quoted 12 lines
drivers/usb/otg/mxs-phy.c new file +12 -0
+struct mxs_usb_phy {
+	struct usb_phy		phy;
+
+	struct work_struct	work;
+
+	struct clk		*clk;
+	struct resource		*mem_res;
+	void __iomem		*mem;
+	int			irq;
+	int			gpio_vbus;
+	int			gpio_vbus_inverted;
+
Quoted 8 lines

drivers/usb/otg/mxs-phy.c line 86

Quoted 6 lines
drivers/usb/otg/mxs-phy.c new file +6 -0
+	enum usb_otg_state	new_state;
+
+	bool			host_mode;
+};
+
+static int mxs_usb_set_host(struct usb_otg *otg, struct usb_bus *host)

should be at imx-otg.c

I don't understand why. This is clearly specific to this PHY driver.

Quoted 7 lines
Quoted 4 lines
(quoted diff) +2 -0
+
+static int mxs_usb_set_peripheral(struct usb_otg *otg, struct usb_gadget

*gg)

gg may not a good name, how about just gadget?
should be at imx-otg.c

DTTO

Quoted 4 lines
Quoted 1 line

+static void mxs_usb_work(struct work_struct *w)

It is OTG switch routine, and should be put imx-otg.c. Sascha also suggested before.

Fine by me, but until someone can clearly explain to me why PHY specific code should be in a shared file (even if it's completely unrelated to it), I see no point moving this.

Quoted 56 lines
Quoted 43 lines
drivers/usb/otg/mxs-phy.c new file +43 -0
+{
+	struct mxs_usb_phy *phy = container_of(w, struct mxs_usb_phy, work);
+	struct usb_otg *otg = phy->phy.otg;
+	struct usb_hcd *hcd;
+
+	switch (otg->phy->state) {
+	case OTG_STATE_A_HOST:
+		if (phy->new_state == OTG_STATE_UNDEFINED) {
+			hcd = bus_to_hcd(otg->host);
+			usb_remove_hcd(hcd);
+			otg->phy->state = phy->new_state;
+			/* Turn off VBUS */
+			gpio_set_value(phy->gpio_vbus,
+				phy->gpio_vbus_inverted);
+		}
+		break;
+	case OTG_STATE_B_PERIPHERAL:
+		if (phy->new_state == OTG_STATE_UNDEFINED) {
+			usb_del_gadget_udc(otg->gadget);
+			otg->phy->state = phy->new_state;
+		}
+		break;
+	case OTG_STATE_UNDEFINED:
+		/* Check desired state. */
+		switch (phy->new_state) {
+		case OTG_STATE_A_HOST:
+			if (!otg->host)
+				break;
+			otg->phy->state = phy->new_state;
+
+			/* Turn on VBUS */
+			gpio_set_value(phy->gpio_vbus,
+				!phy->gpio_vbus_inverted);
+
+			hcd = bus_to_hcd(otg->host);
+			usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
+			break;
+		case OTG_STATE_B_PERIPHERAL:
+			if (!otg->gadget)
+				break;
+			otg->phy->state = phy->new_state;
+			usb_add_gadget_udc(phy->phy.dev, otg->gadget);
+			break;

drivers/usb/otg/mxs-phy.c line 179

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+		default:
+			break;
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+

Seems you forget one otg state: OTG_STATE_B_IDLE.

Quoted 3 lines

at device mode:
OTG_STATE_UNDEFINED -> OTG_STATE_B_IDLE (nothing on port) OTG_STATE_B_PERIPHERAL -> OTG_STATE_B_IDLE (disconnect with host)

This OTG biz really needs further work. So far, we only support Host/Device.

Quoted 51 lines
Quoted 14 lines
drivers/usb/otg/mxs-phy.c new file +13 -0
+static int mxs_usb_phy_init(struct usb_phy *x)
+{
+	struct mxs_usb_phy *phy = container_of(x, struct mxs_usb_phy, phy);
+	uint32_t val;
+
+	/* Enable clock to the PHY. */
+	clk_enable(phy->clk);
+
+	/* Reset the PHY block. */
+	mxs_reset_block(phy->mem + HW_USBPHY_CTRL);
+
+	/* Power up the PHY. */
+	writel(0, phy->mem + HW_USBPHY_PWD);

drivers/usb/otg/mxs-phy.c line 202

Quoted 10 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+
+	/* Enable FS/LS compatibility. */
+	val = BM_USBPHY_CTRL_ENUTMILEVEL2 | BM_USBPHY_CTRL_ENUTMILEVEL3;
+
+	if (phy->host_mode)
+		val |= BM_USBPHY_CTRL_ENHOSTDISCONDETECT;
+	else
+		val |= BM_USBPHY_CTRL_ENIRQDEVPLUGIN |
+			BM_USBPHY_CTRL_ENOTGIDDETECT |
+			BM_USBPHY_CTRL_ENDEVPLUGINDETECT;

Please explain the meaning of above code?

drivers/usb/otg/mxs-phy.c line 212

Quoted 4 lines
drivers/usb/otg/mxs-phy.c new file +4 -0
+static void mxs_usb_phy_shutdown(struct usb_phy *x)
+{
+	struct mxs_usb_phy *phy = container_of(x, struct mxs_usb_phy, phy);
+

You need to set portsc.phcd=1 and power down phy using set 0xffffffff to HW_USBPHY_PWD.

Quoted 16 lines
drivers/usb/otg/mxs-phy.c new file +16 -0
+	/* Gate off the PHY. */
+	writel(BM_USBPHY_CTRL_CLKGATE, phy->mem + HW_USBPHY_CTRL_SET);
+
+	/* Disable clock to the PHY. */
+	clk_disable(phy->clk);
+}
+
+static irqreturn_t mxs_phy_irq(int irq, void *data)
+{
+	struct mxs_usb_phy *phy = data;
+	uint32_t status = readl(phy->mem + HW_USBPHY_STATUS);
+
+	if (status & BM_USBPHY_CTRL_HOSTDISCONDETECT_IRQ)
+		writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+			phy->mem + HW_USBPHY_CTRL_CLR);
+	else
Quoted 8 lines

drivers/usb/otg/mxs-phy.c line 231

Quoted 3 lines
drivers/usb/otg/mxs-phy.c new file +3 -0
+		writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+			phy->mem + HW_USBPHY_CTRL_SET);
+

Have you tested several connect/disconnect operation with high speed device? - where you clear BM_USBPHY_CTRL_HOSTDISCONDETECT_IRQ?
- This code will always run at every usb interrupt, in fact, high speed detector only needs to be set/clear with connect/disconnect.

I have yet to figure out how to actually detect host connect/disconnect in OTG mode while also detect Device connect/disconnect. Can you elaborate on what needs to be set in the CTRL register to generate these interrupts?

Quoted 23 lines
Quoted 23 lines
drivers/usb/otg/mxs-phy.c new file +21 -0
+	return IRQ_NONE;
+}
+
 
 
+
+static int __devexit mxs_phy_remove(struct platform_device *pdev)
+{
+	struct mxs_usb_phy *phy = platform_get_drvdata(pdev);
+
+	/* Stop the PHY work. */
+	cancel_work_sync(&phy->work);
+
+	/* Power down the PHY. */
+	mxs_usb_phy_shutdown(&phy->phy);
+
+	/* Remove the transceiver. */
+	usb_set_transceiver(NULL);
+
+	/* Shut off VBUS. */
+	gpio_set_value(phy->gpio_vbus, phy->gpio_vbus_inverted);
+	gpio_free(phy->gpio_vbus);
+
Quoted 8 lines

drivers/usb/otg/mxs-phy.c line 402

Quoted 6 lines
drivers/usb/otg/mxs-phy.c new file +6 -0
+	/* Free the IRQ requested by this device. */
+	free_irq(phy->irq, phy);
+
+	/* Free the IRQ requested by this device. */
+	free_irq(phy->irq, phy);
+

Two free_irq???

Rebase issue

Quoted 11 lines
Quoted 11 lines
drivers/usb/otg/mxs-phy.c new file +10 -0
+	/* Stop the PHY clock. */
+	clk_disable_unprepare(phy->clk);
+	clk_put(phy->clk);
+
+	/* Free the rest. */
+	platform_set_drvdata(pdev, NULL);
+
+	return 0;
+}
+
#111 lore raw

PATCH v4 9/11 MXS: Add USB PHY driver

Quoted 9 lines
Quoted 3 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+
+static int mxs_usb_set_host(struct usb_otg *otg, struct usb_bus

*host)

Quoted 2 lines

should be at imx-otg.c

I don't understand why. This is clearly specific to this PHY driver.

Please take a look the definition of struct usb_otg and struct usb_phy at include/linux/usb/otg.h. You may need to implement individual struct at individual driver (usb_otg->otg driver, usb_phy->phy driver)

Quoted 10 lines
Quoted 3 lines

It is OTG switch routine, and should be put imx-otg.c. Sascha also suggested before.

Fine by me, but until someone can clearly explain to me why PHY specific code
should be in a shared file (even if it's completely unrelated to it), I see no
point moving this.

Can you explain what kinds of things are PHY specific from your point?

Quoted 11 lines
Quoted 5 lines

Have you tested several connect/disconnect operation with high speed device? - where you clear BM_USBPHY_CTRL_HOSTDISCONDETECT_IRQ?
- This code will always run at every usb interrupt, in fact, high speed detector only needs to be set/clear with connect/disconnect.

I have yet to figure out how to actually detect host connect/disconnect in OTG
mode while also detect Device connect/disconnect. Can you elaborate on what
needs to be set in the CTRL register to generate these interrupts?

At i.mx28, there are two USB related controller, one is USB core controller, another is USB PHY controller. Each has individual interrupt line. You only need to set USB_PHY_CTRL for wakeup interrupt case. Host connect/disconnect: PCD interrupt at EHCI register
Device connect/disconnect: vbus (B_SESSION_VALID) interrupt at otgsc.

For register usage, you can refer freescale git:
http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/log/?h=imx_2.6.35_10.12.01
Although the code structure is not good, you can refer some hardware operation.

#112 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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        |   84 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |   12 ++++
 5 files changed, 105 insertions(+)
 create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
arch/arm/mach-mxs/devices-mx28.h +5 -0
index 9dbeae1..f0e1d54 100644
@@ -11,6 +11,7 @@
 #include <mach/mx28.h>
 #include <mach/devices-common.h>
 #include <mach/mxsfb.h>
+#include <linux/fsl/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 +84 -0

84 lines not on this page · raw message

arch/arm/mach-mxs/include/mach/devices-common.h +12 -0
index f2e3839..3024428 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/fsl/mxs-usb.h>
 
 extern struct device mxs_apbh_bus;
 
@@ -42,6 +44,16 @@ 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,
+			const struct imx_usb_platform_data *pdata);
+
 /* fec */
 #include <linux/fec.h>
 struct mxs_fec_data {
Signature · 1 line
1.7.9.5
#113 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 arch/arm/mach-mxs/Kconfig       |    2 ++
 arch/arm/mach-mxs/mach-m28evk.c |   20 ++++++++++++++++++++
 2 files changed, 22 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 +20 -0
index 06d7996..96d523a 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 */
@@ -317,6 +329,12 @@ static struct mxs_mmc_platform_data m28evk_mmc_pdata[] __initdata = {
 	},
 };
 
+static struct imx_usb_platform_data m28_usb_data = {
+	.gpio_vbus		= M28EVK_USBOTG_ENABLE,
+	.gpio_vbus_inverted	= 1,
+	.host_mode		= 1,
+};
+
 static void __init m28evk_init(void)
 {
 	mxs_iomux_setup_multiple_pads(m28evk_pads, ARRAY_SIZE(m28evk_pads));
@@ -344,6 +362,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.9.5
#114 lore raw

PATCH v4 11/11 MXS: Enable USB on M28EVK

arch/arm/mach-mxs/mach-m28evk.c static void __init m28evk_init(void) · line 367

Quoted 10 lines

Enable the second USB port on M28EVK board.

arch/arm/mach-mxs/mach-m28evk.c +2 -0
+
+	mx28_add_mxs_usbh(0, &m28_usb_data);
 }

You have enabled second port at mx28evk, why it "0"? at your mx28_add_mxs_usbh(0, &m28_usb_data).

Quoted 4 lines

static void __init m28evk_timer_init(void)
--
1.7.9.5

#115 lore raw

PATCH v4 11/11 MXS: Enable USB on M28EVK

Dear Chen Peter-B29397,

Quoted 10 lines

arch/arm/mach-mxs/mach-m28evk.c static void __init m28evk_init(void)

Quoted 7 lines

Enable the second USB port on M28EVK board.

arch/arm/mach-mxs/mach-m28evk.c +2 -0
+
+	mx28_add_mxs_usbh(0, &m28_usb_data);
 
 }

You have enabled second port at mx28evk, why it "0"? at your mx28_add_mxs_usbh(0, &m28_usb_data).

Correct, I needed to test this with the gadget-capable port and this snuck in.

Quoted 5 lines
Quoted 5 lines

static void __init m28evk_timer_init(void)

--
1.7.9.5

Best regards,
Marek Vasut

#116 lore raw

v4 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut
Quoted 10 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.

Does the udc work at this patchset? If it is, you have enabled OTG port and not host 1 port, correct?

Quoted 85 lines

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)

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        |   84 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |   12 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   20 ++
 drivers/usb/gadget/Kconfig                      |   17 +
 drivers/usb/gadget/Makefile                     |    1 +
 drivers/usb/gadget/ci13xxx_mxs.c                |   67 ++++
 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                     |  197 ++++++++++
 drivers/usb/otg/Kconfig                         |   16 +
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-otg.c                       |  282 +++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  438
+++++++++++++++++++++++
 include/linux/fsl/mxs-usb.h                     |   46 +++
 23 files changed, 1243 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/fsl/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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

NOTE: Adding this ci13xxx-mxs driver was really helpful, it helped me to realise
how this whole monster should look like in the end. Now the mxs-phy
is
also much more prepared for the OTG operation.

--
1.7.9.5

#117 lore raw

v4 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 9 lines
Quoted 6 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.

Does the udc work at this patchset? If it is, you have enabled OTG port and not host 1 port, correct?

Wait for V5. Gadget mode should work, V5 should have some further rebase issues fixed.

Quoted 90 lines
Quoted 90 lines

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)

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        |   84 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |   12 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   20 ++
 drivers/usb/gadget/Kconfig                      |   17 +
 drivers/usb/gadget/Makefile                     |    1 +
 drivers/usb/gadget/ci13xxx_mxs.c                |   67 ++++
 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                     |  197 ++++++++++
 drivers/usb/otg/Kconfig                         |   16 +
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-otg.c                       |  282 +++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  438

+++++++++++++++++++++++

 include/linux/fsl/mxs-usb.h                     |   46 +++
 23 files changed, 1243 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/fsl/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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

NOTE: Adding this ci13xxx-mxs driver was really helpful, it helped me to realise

Quoted 8 lines
Quoted 8 lines

how this whole monster should look like in the end. Now the mxs-phy

is

also much more prepared for the OTG operation.

--
1.7.9.5

Best regards,
Marek Vasut

#118 lore raw

v4 cover MXS: Add i.MX28 USB Host driver

Quoted 4 lines
Quoted 4 lines
Quoted 8 lines
Quoted 2 lines

Does the udc work at this patchset? If it is, you have enabled OTG port and not host 1 port, correct?

Wait for V5. Gadget mode should work, V5 should have some further rebase issues
fixed.

From my point, you'd better step by step, first, mainline host and phy.

then, gadget. At last OTG if you have been interested in.

It can be easier for your mainline, as some of them have still not implemented at your local. What's your opinion, Sascha?

#119 lore raw

v4 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

Does the udc work at this patchset? If it is, you have enabled OTG port and not host 1 port, correct?

Wait for V5. Gadget mode should work, V5 should have some further rebase issues
fixed.

From my point, you'd better step by step, first, mainline host and phy. then, gadget. At last OTG if you have been interested in.

OTG is certainly going last, I still have to figure that out. I wanted to add gadget to see how this whole thing will work together to avoid design mistakes.

Quoted 2 lines

It can be easier for your mainline, as some of them have still not implemented at your local. What's your opinion, Sascha?

I don't follow here, what do you mean?

Best regards,
Marek Vasut

#120 lore raw

v4 cover MXS: Add i.MX28 USB Host driver

Quoted 10 lines
Quoted 4 lines

From my point, you'd better step by step, first, mainline host and phy. then, gadget. At last OTG if you have been interested in.

OTG is certainly going last, I still have to figure that out. I wanted to add
gadget to see how this whole thing will work together to avoid design mistakes.

I agree. Current, it is lack of generic PHY layer, so only one PHY can be supported at board if you want to use PHY driver. I would like to submit some generic PHY layer code, but some many internal stuffs in hands now.

Quoted 4 lines
Quoted 2 lines

It can be easier for your mainline, as some of them have still not implemented at your local. What's your opinion, Sascha?

I don't follow here, what do you mean?

My original mind is step by step, but you want to implement the whole structure to see if there is any design mistakes, it is also OK.

Quoted 3 lines

Best regards,
Marek Vasut

#121 lore raw

v4 cover MXS: Add i.MX28 USB Host driver

Dear Chen Peter-B29397,

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

From my point, you'd better step by step, first, mainline host and phy. then, gadget. At last OTG if you have been interested in.

OTG is certainly going last, I still have to figure that out. I wanted to add
gadget to see how this whole thing will work together to avoid design mistakes.

I agree. Current, it is lack of generic PHY layer, so only one PHY can be supported at board if you want to use PHY driver.

Yes, that's indeed a problem. Doesn't seem to be a hard one though.

Quoted 3 lines

I would like to
submit some generic PHY layer code, but some many internal stuffs in hands now.

Good :)

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

It can be easier for your mainline, as some of them have still not implemented at your local. What's your opinion, Sascha?

I don't follow here, what do you mean?

My original mind is step by step, but you want to implement the whole structure to see if there is any design mistakes, it is also OK.

Yes exactly ... I believe it's better this way to see how it works out. I'll try OTG tonight if nothing more important pops up.

Quoted 2 lines
Quoted 2 lines

Best regards,
Marek Vasut

Best regards,
Marek Vasut

#122 lore raw

v4 cover MXS: Add i.MX28 USB Host driver

In reply to Chen Peter-B29397

Dear Chen Peter-B29397,

Quoted 9 lines
Quoted 6 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.

Does the udc work at this patchset? If it is, you have enabled OTG port and not host 1 port, correct?

btw Peter, thanks for the review, you caught some pretty nasty problems.

Quoted 89 lines
Quoted 89 lines

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)

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        |   84 +++++
 arch/arm/mach-mxs/include/mach/clock.h          |    2 +-
 arch/arm/mach-mxs/include/mach/devices-common.h |   12 +
 arch/arm/mach-mxs/include/mach/mx23.h           |    8 +-
 arch/arm/mach-mxs/mach-m28evk.c                 |   20 ++
 drivers/usb/gadget/Kconfig                      |   17 +
 drivers/usb/gadget/Makefile                     |    1 +
 drivers/usb/gadget/ci13xxx_mxs.c                |   67 ++++
 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                     |  197 ++++++++++
 drivers/usb/otg/Kconfig                         |   16 +
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-otg.c                       |  282 +++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  438

+++++++++++++++++++++++

 include/linux/fsl/mxs-usb.h                     |   46 +++
 23 files changed, 1243 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/fsl/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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

NOTE: Adding this ci13xxx-mxs driver was really helpful, it helped me to realise

Quoted 8 lines
Quoted 8 lines

how this whole monster should look like in the end. Now the mxs-phy

is

also much more prepared for the OTG operation.

--
1.7.9.5

Best regards,
Marek Vasut

#123 lore raw

v5 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut

From: Marek Vasut <[email protected]>

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.

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!)

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        |   85 ++++
 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                |   67 ++++
 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                     |  178 +++++++++
 drivers/usb/otg/Kconfig                         |   16 +
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-otg.c                       |  473 +++++++++++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  237 ++++++++++++
 include/linux/usb/mxs-usb.h                     |   95 +++++
 23 files changed, 1266 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 1 line
1.7.10
#124 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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
#125 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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
#126 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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
#127 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 include/linux/usb/mxs-usb.h |   95 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
 create mode 100644 include/linux/usb/mxs-usb.h
include/linux/usb/mxs-usb.h new file +95 -0
new file mode 100644
index 0000000..a4de28e
@@ -0,0 +1,95 @@
+/*
+ * 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>
+
+/* MXS USB PHY register definitions. */
+#define HW_USBPHY_PWD				0x00
+
+#define HW_USBPHY_CTRL				0x30
+#define HW_USBPHY_CTRL_SET			0x34
+#define HW_USBPHY_CTRL_CLR			0x38
+#define HW_USBPHY_CTRL_TOG			0x3c
+
+#define BM_USBPHY_CTRL_SFTRST			(1 << 31)
+#define BM_USBPHY_CTRL_CLKGATE			(1 << 30)
+#define BM_USBPHY_CTRL_ENVBUSCHG_WKUP		(1 << 23)
+#define BM_USBPHY_CTRL_ENIDCHG_WKUP		(1 << 22)
+#define BM_USBPHY_CTRL_ENDPDMCHG_WKUP		(1 << 21)
+#define BM_USBPHY_CTRL_WAKEUP_IRQ		(1 << 17)
+#define BM_USBPHY_CTRL_ENIRQWAKEUP		(1 << 16)
+#define BM_USBPHY_CTRL_ENUTMILEVEL3		(1 << 15)
+#define BM_USBPHY_CTRL_ENUTMILEVEL2		(1 << 14)
+#define BM_USBPHY_CTRL_ENIRQDEVPLUGIN		(1 << 11)
+#define BM_USBPHY_CTRL_RESUME_IRQ		(1 << 10)
+#define BM_USBPHY_CTRL_ENIRQRESUMEDETECT	(1 << 9)
+#define BM_USBPHY_CTRL_ENOTGIDDETECT		(1 << 7)
+#define BM_USBPHY_CTRL_ENDEVPLUGINDETECT	(1 << 4)
+#define BM_USBPHY_CTRL_HOSTDISCONDETECT_IRQ	(1 << 3)
+#define BM_USBPHY_CTRL_ENIRQHOSTDISCON		(1 << 2)
+#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	(1 << 1)
+
+#define HW_USBPHY_STATUS			0x40
+
+#define BM_USBPHY_STATUS_OTGID_STATUS		(1 << 8)
+#define BM_USBPHY_STATUS_DEVPLUGIN_STATUS	(1 << 6)
+#define BM_USBPHY_STATUS_HOSTDISCON_STATUS	(1 << 3)
+
+struct imx_otg_priv {
+	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;
+	struct device		*dev;
+	uint32_t		status;
+};
+
+struct imx_otg {
+	struct platform_device	*pdev_host;
+	struct platform_device	*pdev_gadget;
+
+	struct clk		*clk;
+	struct resource		*mem_res;
+	void __iomem		*mem;
+	int			irq;
+	int			irq_wakeup;
+
+	struct imx_otg_priv	priv;
+};
+
+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
#128 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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
#129 lore raw

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

Quoted 8 lines

Subject: [PATCH 05/11] MXS: Modify the ci13xxx_udc to avoid adding UDC

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.

You may need to add reviewers for is using cil3xxx_udc too.

#130 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/gadget/Kconfig       |   17 ++++++++++
 drivers/usb/gadget/Makefile      |    1 +
 drivers/usb/gadget/ci13xxx_mxs.c |   67 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 85 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 +67 -0

67 lines not on this page · raw message

Signature · 1 line
1.7.10
#131 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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 |  178 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 190 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 +178 -0

178 lines not on this page · raw message

Signature · 1 line
1.7.10
#132 lore raw

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

Quoted 8 lines

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.

Quoted 5 lines

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.

still not understand high speed disconnect detector? I may explain it twice during reviewing.

#133 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  473 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 480 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 +473 -0

473 lines not on this page · raw message

Signature · 1 line
1.7.10
#134 lore raw

PATCH 8/11 MXS: Add imx-otg driver

Hi,

Quoted 71 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  473 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 480 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 +13 -0
new file mode 100644
index 0000000..8440d909
@@ -0,0 +1,473 @@
+/*
+ * drivers/usb/otg/imx-otg.c
+ *
+ * Freescale i.MX USB composite driver.
+ *
+ * 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.
+ *

drivers/usb/otg/imx-otg.c line 23

Quoted 10 lines
drivers/usb/otg/imx-otg.c new file +10 -0
+ * 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.
+ */
+

Why do you call this driver imx-otg when it is actually MXS specific? How would you call a corresponding driver for the remaining i.MX processors?

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
maintainer
#135 lore raw

PATCH 8/11 MXS: Add imx-otg driver

Quoted 79 lines · Lothar Wa?mann

Hi,

Quoted 76 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  473 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 480 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 +18 -0
new file mode 100644
index 0000000..8440d909
@@ -0,0 +1,473 @@
+/*
+ * drivers/usb/otg/imx-otg.c
+ *
+ * Freescale i.MX USB composite driver.
+ *
+ * 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.
+ *
Quoted 8 lines

drivers/usb/otg/imx-otg.c line 23

Quoted 5 lines
drivers/usb/otg/imx-otg.c new file +5 -0
+ * 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.
+ */
+

Why do you call this driver imx-otg when it is actually MXS specific? How would you call a corresponding driver for the remaining i.MX processors?

This is the driver for the all i.MX processors.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#136 lore raw

PATCH 8/11 MXS: Add imx-otg driver

Hi,

Quoted 89 lines · Sascha Hauer
Quoted 79 lines · Lothar Wa?mann

Hi,

Quoted 76 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  473 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 480 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 +18 -0
new file mode 100644
index 0000000..8440d909
@@ -0,0 +1,473 @@
+/*
+ * drivers/usb/otg/imx-otg.c
+ *
+ * Freescale i.MX USB composite driver.
+ *
+ * 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.
+ *
Quoted 8 lines

drivers/usb/otg/imx-otg.c line 23

Quoted 5 lines
drivers/usb/otg/imx-otg.c new file +5 -0
+ * 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.
+ */
+

Why do you call this driver imx-otg when it is actually MXS specific? How would you call a corresponding driver for the remaining i.MX processors?

Quoted 2 lines

This is the driver for the all i.MX processors.

If it is for all i.MX processors, it shouldn't access MXS specific registers, like:
+ writel(wakeup, x->io_priv + HW_USBPHY_CTRL_SET);

Lothar Wa?mann

Signature · 9 lines
___________________________________________________________

Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996

www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
maintainer
#137 lore raw

PATCH 8/11 MXS: Add imx-otg driver

Quoted 96 lines · Lothar Wa?mann

Hi,

Quoted 89 lines · Sascha Hauer
Quoted 79 lines · Lothar Wa?mann

Hi,

Quoted 76 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  473 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 480 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 +18 -0
new file mode 100644
index 0000000..8440d909
@@ -0,0 +1,473 @@
+/*
+ * drivers/usb/otg/imx-otg.c
+ *
+ * Freescale i.MX USB composite driver.
+ *
+ * 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.
+ *
Quoted 8 lines

drivers/usb/otg/imx-otg.c line 23

Quoted 5 lines
drivers/usb/otg/imx-otg.c new file +5 -0
+ * 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.
+ */
+

Why do you call this driver imx-otg when it is actually MXS specific? How would you call a corresponding driver for the remaining i.MX processors?

Quoted 2 lines

This is the driver for the all i.MX processors.

If it is for all i.MX processors, it shouldn't access MXS specific registers, like:

Review

Quoted 1 line
(quoted diff) +1 -0
+		writel(wakeup, x->io_priv + HW_USBPHY_CTRL_SET);

Indeed not. This should be done in the phy driver.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#138 lore raw

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

Dear Sascha Hauer,

Quoted 105 lines · Lothar Wa?mann
Quoted 104 lines

Hi,

Quoted 101 lines · Sascha Hauer
Quoted 99 lines · Lothar Wa?mann

Hi,

Quoted 84 lines · 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

---

 drivers/usb/otg/Kconfig   |    6 +
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/imx-otg.c |  473
 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed,
 480 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

drivers/usb/otg/Kconfig +0 -0
 	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 +9 -0
new file mode 100644
index 0000000..8440d909
@@ -0,0 +1,473 @@
+/*
+ * drivers/usb/otg/imx-otg.c
+ *
+ * Freescale i.MX USB composite driver.
+ *
+ * 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

Quoted 8 lines

+ * 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. + */
+

Why do you call this driver imx-otg when it is actually MXS specific? How would you call a corresponding driver for the remaining i.MX processors?

Quoted 7 lines

Review

Quoted 5 lines
Quoted 1 line

This is the driver for the all i.MX processors.

If it is for all i.MX processors, it shouldn't access MXS specific registers, like:

(quoted diff) +1 -0
+		writel(wakeup, x->io_priv + HW_USBPHY_CTRL_SET);

Indeed not. This should be done in the phy driver.

Ok, so now you figured out that all these set_host() set_peripheral() work() calls should be back in the phy driver, not in the imx-otg? hm ... so back to the V4 of the patchset?

Quoted 2 lines

Sascha

Best regards,
Marek Vasut

maintainer
#139 lore raw

PATCH 8/11 MXS: Add imx-otg driver

Quoted 13 lines · Marek Vasut
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Why do you call this driver imx-otg when it is actually MXS specific? How would you call a corresponding driver for the remaining i.MX processors?

Quoted 7 lines

Review

Quoted 5 lines
Quoted 1 line

This is the driver for the all i.MX processors.

If it is for all i.MX processors, it shouldn't access MXS specific registers, like:

(quoted diff) +1 -0
+		writel(wakeup, x->io_priv + HW_USBPHY_CTRL_SET);

Indeed not. This should be done in the phy driver.

Quoted 3 lines

Ok, so now you figured out that all these set_host() set_peripheral() work() calls should be back in the phy driver, not in the imx-otg? hm ... so back to the V4 of the patchset?

Not really, you are just not allowed to put phy code into imx-otg.c, because the phy may be another one on a different SoC.

That said, I am a bit confused at the moment. There seems to be no method to activate the interrupt in the phy.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#140 lore raw

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

Dear Sascha Hauer,

Quoted 17 lines · Marek Vasut
Quoted 12 lines
Quoted 11 lines

Review

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Why do you call this driver imx-otg when it is actually MXS specific? How would you call a corresponding driver for the remaining i.MX processors?

This is the driver for the all i.MX processors.

If it is for all i.MX processors, it shouldn't access MXS specific registers, like:

(quoted diff) +1 -0
+		writel(wakeup, x->io_priv + HW_USBPHY_CTRL_SET);

Indeed not. This should be done in the phy driver.

Quoted 3 lines

Ok, so now you figured out that all these set_host() set_peripheral() work() calls should be back in the phy driver, not in the imx-otg? hm ... so back to the V4 of the patchset?

Quoted 5 lines

Not really, you are just not allowed to put phy code into imx-otg.c, because the phy may be another one on a different SoC.

That said, I am a bit confused at the moment. There seems to be no method to activate the interrupt in the phy.

There is more to be confused about -- you don't get the host/device connection interrupt from the PHY, but you dig one of them from the EHCI host and the other from the EHCI host too -- which is pretty messed up already.

We can certainly use IRQF_SHARED to trap some of the interrupts in the PHY code, but that's still quite weird.

Quoted 1 line

Sascha

Best regards,
Marek Vasut

#141 lore raw

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

Quoted 8 lines

There is more to be confused about -- you don't get the host/device connection
interrupt from the PHY, but you dig one of them from the EHCI host and the other
from the EHCI host too -- which is pretty messed up already.

Quoted 4 lines

We can certainly use IRQF_SHARED to trap some of the interrupts in the PHY code,
but that's still quite weird.

Below need to be implemented at phy driver:
- struct usb_phy;
- phy's interrupt which is only used for handle wakeup issue, PHY's interrupt line is NOT the same with controller's, so you don't need to use IRQF_SHARED, and request the same irq with controller's.

Below need to be implemented at otg driver:
- struct usb_otg;
- manage PHY through PHY interfaces which are implemented at phy driver.
- OTG interrupt, it only handles ID/vbus interrupt.
- OTG switch routine, it handles host and device's add/remove operation due to id/vbus change and some operation_mode defined at platform_data or DT in fture.

Quoted 4 lines
Quoted 1 line

Sascha

Best regards,
Marek Vasut

#142 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/usb/otg/Kconfig   |   10 ++
 drivers/usb/otg/Makefile  |    1 +
 drivers/usb/otg/mxs-phy.c |  237 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 248 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 +237 -0

237 lines not on this page · raw message

Signature · 1 line
1.7.10
#143 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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        |   85 +++++++++++++++++++++++
 arch/arm/mach-mxs/include/mach/devices-common.h |   13 ++++
 5 files changed, 107 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 +85 -0

85 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
#144 lore raw

PATCH v4 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[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..fe00921 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 */
@@ -317,6 +329,13 @@ static struct mxs_mmc_platform_data m28evk_mmc_pdata[] __initdata = {
 	},
 };
 
+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 void __init m28evk_init(void)
 {
 	mxs_iomux_setup_multiple_pads(m28evk_pads, ARRAY_SIZE(m28evk_pads));
@@ -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
#145 lore raw

v5 cover MXS: Add i.MX28 USB Host driver

In reply to Marek Vasut

Do you really need 138 messages (and counting) all threaded together across the entire history of this patch set? Please stop posting new copies of your patch set as followups to the previous set.

Not only does it rob horizontal space for reading the subjects in the index, but also it either buries your patches ages back or brings the entire 138 messages to the front of mailboxes, depending on your sort preferences. Either way it makes threaded reading of the mailing list really difficult.

Please stop this antisocial behaviour. Thanks.

Quoted 89 lines · Marek Vasut

From: Marek Vasut <[email protected]>

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.

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!)

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        |   85 ++++
 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                |   67 ++++
 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                     |  178 +++++++++
 drivers/usb/otg/Kconfig                         |   16 +
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-otg.c                       |  473 +++++++++++++++++++++++
 drivers/usb/otg/mxs-phy.c                       |  237 ++++++++++++
 include/linux/usb/mxs-usb.h                     |   95 +++++
 23 files changed, 1266 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 Lin Tony-B19295 <[email protected]>
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>
Signature · 7 lines
1.7.10


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#146 lore raw

v5 cover MXS: Add i.MX28 USB Host driver

Dear Russell King - ARM Linux,

Quoted 3 lines

Do you really need 138 messages (and counting) all threaded together across the entire history of this patch set? Please stop posting new copies of your patch set as followups to the previous set.

Well, it's usually to the point where the usb patches change, so instead of posting 8 patches, I post the whole set ot make it consistent.

Quoted 7 lines

Not only does it rob horizontal space for reading the subjects in the index, but also it either buries your patches ages back or brings the entire 138 messages to the front of mailboxes, depending on your sort preferences. Either way it makes threaded reading of the mailing list really difficult.

Please stop this antisocial behaviour. Thanks.

Can you please suggest better solution? You mean post each new set as a separate thread ? Or post each patch as an in-reply-to previous one?

Thanks and sorry for that.

Quoted 77 lines · Marek Vasut
Quoted 76 lines

From: Marek Vasut <[email protected]>

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.

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!)

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        |   85 ++++
 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                |   67 ++++
 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                     |  178 +++++++++
 drivers/usb/otg/Kconfig                         |   16 +
 drivers/usb/otg/Makefile                        |    2 +
 drivers/usb/otg/imx-otg.c                       |  473
 +++++++++++++++++++++++ drivers/usb/otg/mxs-phy.c                      
 |  237 ++++++++++++ include/linux/usb/mxs-usb.h                     |  
 95 +++++
 23 files changed, 1266 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
Quoted 13 lines
Quoted 5 lines
Cc Chen Peter-B29397 <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Li Frank-B20596 <[email protected]>
Cc Lin Tony-B19295 <[email protected]>
Quoted 8 lines
Cc Linux USB <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Shawn Guo <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Subodh Nijsure <[email protected]>
Cc Tony Lin <[email protected]>
Cc Wolfgang Denk <[email protected]>

Best regards,
Marek Vasut

#147 lore raw

v5 cover MXS: Add i.MX28 USB Host driver

Quoted 8 lines · Marek Vasut

Dear Russell King - ARM Linux,

Quoted 3 lines

Do you really need 138 messages (and counting) all threaded together across the entire history of this patch set? Please stop posting new copies of your patch set as followups to the previous set.

Well, it's usually to the point where the usb patches change, so instead of posting 8 patches, I post the whole set ot make it consistent.

Sure, no problem with that.

Quoted 10 lines
Quoted 7 lines

Not only does it rob horizontal space for reading the subjects in the index, but also it either buries your patches ages back or brings the entire 138 messages to the front of mailboxes, depending on your sort preferences. Either way it makes threaded reading of the mailing list really difficult.

Please stop this antisocial behaviour. Thanks.

Can you please suggest better solution? You mean post each new set as a separate thread ? Or post each patch as an in-reply-to previous one?

Please don't thread the posting of a new version of the patches to the previous posting of the older version. In other words, the initial summary mail for V5 should not be threaded to the V4 series, and the individual patches for V5 should only be threaded to the initial summary mail for V5.

So, rather than this as one massive thread:
...[PATCH V3 0/N]

   +-[PATCH V3 1/N]
   | `-Replies
   +-[PATCH V3 2/N]
   | `-Replies
   +-[PATCH V3 3/N]
   | `-Replies
   `-[PATCH V4 0/N]
     +-[PATCH V4 1/N]
     | `-Replies
     +-[PATCH V4 2/N]
     | `-Replies
     +-[PATCH V4 3/N]
     | `-Replies
     `-[PATCH V5 0/N]
        +-[PATCH V5 1/N]
        | `-Replies
        +-[PATCH V5 2/N]
        | `-Replies
        `-[PATCH V5 3/N]
          `-Replies

It should be:
[PATCH V4 0/N]

+-[PATCH V4 1/N]
| `-Replies
+-[PATCH V4 2/N]
| `-Replies

`-[PATCH V4 3/N]
`-Replies

<some time later>

[PATCH V5 0/N]

+-[PATCH V5 1/N]
| `-Replies
+-[PATCH V5 2/N]
| `-Replies

`-[PATCH V5 3/N]
`-Replies

Where the 0/N patches have no parent message. In other words, these sumamry messages have no references or in-reply-to headers.

If you wish to provide a direct reference back to a previous thread, please do so via URLs into archives, or providing the message id or exact subject of the previous series in the new summary message body. But please don't thread each version to the previous version!

#148 lore raw

v5 cover MXS: Add i.MX28 USB Host driver

Dear Russell King - ARM Linux,

Quoted 90 lines · Marek Vasut
Quoted 8 lines

Dear Russell King - ARM Linux,

Quoted 3 lines

Do you really need 138 messages (and counting) all threaded together across the entire history of this patch set? Please stop posting new copies of your patch set as followups to the previous set.

Well, it's usually to the point where the usb patches change, so instead of posting 8 patches, I post the whole set ot make it consistent.

Sure, no problem with that.

Quoted 10 lines
Quoted 7 lines

Not only does it rob horizontal space for reading the subjects in the index, but also it either buries your patches ages back or brings the entire 138 messages to the front of mailboxes, depending on your sort preferences. Either way it makes threaded reading of the mailing list really difficult.

Please stop this antisocial behaviour. Thanks.

Can you please suggest better solution? You mean post each new set as a separate thread ? Or post each patch as an in-reply-to previous one?

Please don't thread the posting of a new version of the patches to the previous posting of the older version. In other words, the initial summary mail for V5 should not be threaded to the V4 series, and the individual patches for V5 should only be threaded to the initial summary mail for V5.

So, rather than this as one massive thread:
...[PATCH V3 0/N]
+-[PATCH V3 1/N]

   | `-Replies

   +-[PATCH V3 2/N]

   | `-Replies

   +-[PATCH V3 3/N]

   | `-Replies

   `-[PATCH V4 0/N]
     +-[PATCH V4 1/N]

     | `-Replies

     +-[PATCH V4 2/N]

     | `-Replies

     +-[PATCH V4 3/N]

     | `-Replies

     `-[PATCH V5 0/N]
        +-[PATCH V5 1/N]

        | `-Replies

        +-[PATCH V5 2/N]

        | `-Replies

        `-[PATCH V5 3/N]
          `-Replies

It should be:
[PATCH V4 0/N]
+-[PATCH V4 1/N]

| `-Replies

+-[PATCH V4 2/N]

| `-Replies

`-[PATCH V4 3/N]
`-Replies

<some time later>

[PATCH V5 0/N]
+-[PATCH V5 1/N]

| `-Replies

+-[PATCH V5 2/N]

Quoted 7 lines

| `-Replies

`-[PATCH V5 3/N]
`-Replies

Where the 0/N patches have no parent message. In other words, these sumamry messages have no references or in-reply-to headers.

I see, roger that!

Quoted 4 lines

If you wish to provide a direct reference back to a previous thread, please do so via URLs into archives, or providing the message id or exact subject of the previous series in the new summary message body. But please don't thread each version to the previous version!

Ack. Thanks for clearing this out, sorry for the mess.

Best regards,
Marek Vasut