MXS: Add i.MX28 USB Host driver
Subsystems (5)
v6 cover MXS: Add i.MX28 USB Host driver
This patchset introduces the USB Host driver for i.MX28 CPU, utilising the generic USB PHY infrastructure. Also added is glue code for CI13xxx driver, to allow device mode. This patchset still does NOT support OTG mode, the device/host mode is selected via platform data.
V2: Introduce stub imx-usb driver that then registers the PHY and EHCI drivers.
V3: Add the HCD on demand based on the PHY's state (only add HCD if it's host).
Currently, only the HOST mode is supported.
V4: * Introduce ci13xxx gadget glue
* Reorder patches in a more sensible order
* Introduce platform data, containing VBUS GPIO and port mode (device/gadget)
* Rename imx-usb to imx-otg
* Drop mx28evk usb host patch
* Use more devm_ function
* Rework the mxs-phy to register the same interrupt as ehci-mxs (and effectivelly kill bogus otg_set_vbus() call from ehci-mxs ; use standard ehci irq handling in ehci-mxs)
V5: * Finally move OTG IRQ handling into imx-otg
* Move imx_otg_set_{host,peripheral}() into imx-otg
* Move imx_otg_work() into imx-otg driver (now it all makes sense, yay!)
V6: Do PHY-specific job inside the PHY driver
Marek Vasut (11):
MXS: Make clk_disable return integer
MXS: Add USB EHCI and USB PHY clock handling
MXS: Fixup i.MX233 USB base address name
MXS: Add data shared between imx-otg and EHCI driver
MXS: Modify the ci13xxx_udc to avoid adding UDC
MXS: Add small registration glue for ci13xxx_udc
MXS: Add separate MXS EHCI HCD driver
MXS: Add imx-otg driver
MXS: Add USB PHY driver
MXS: Add platform registration hooks for USB EHCI
MXS: Enable USB on M28EVK
arch/arm/mach-mxs/Kconfig | 2 + arch/arm/mach-mxs/clock-mx28.c | 28 +- arch/arm/mach-mxs/devices-mx28.h | 5 + arch/arm/mach-mxs/devices/Kconfig | 3 + arch/arm/mach-mxs/devices/Makefile | 1 + arch/arm/mach-mxs/devices/platform-usb.c | 89 +++++ arch/arm/mach-mxs/include/mach/clock.h | 2 +- arch/arm/mach-mxs/include/mach/devices-common.h | 13 + arch/arm/mach-mxs/include/mach/mx23.h | 8 +- arch/arm/mach-mxs/mach-m28evk.c | 21 ++ drivers/usb/gadget/Kconfig | 17 + drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/ci13xxx_mxs.c | 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 | 437 +++++++++++++++++++++++ drivers/usb/otg/mxs-phy.c | 293 +++++++++++++++ include/linux/usb/mxs-usb.h | 94 +++++ 23 files changed, 1289 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
Signature · 1 line
1.7.10
PATCH v6 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.
--- 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
@@ -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
@@ -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
PATCH v6 2/11 MXS: Add USB EHCI and USB PHY clock handling
In reply to Marek VasutBased on code by:
Tony Lin <[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
@@ -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
PATCH v6 3/11 MXS: Fixup i.MX233 USB base address name
In reply to Marek VasutModify 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]>
--- 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
@@ -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
PATCH v6 4/11 MXS: Add data shared between imx-otg and EHCI driver
In reply to Marek VasutThis 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.
--- include/linux/usb/mxs-usb.h | 94 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 include/linux/usb/mxs-usb.h
include/linux/usb/mxs-usb.h new file +94 -0
@@ -0,0 +1,94 @@ +/* +* 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; +}; + +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
PATCH v6 5/11 MXS: Modify the ci13xxx_udc to avoid adding UDC
In reply to Marek VasutOn 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.
--- 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
@@ -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
@@ -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
PATCH v6 6/11 MXS: Add small registration glue for ci13xxx_udc
In reply to Marek VasutThis patch adds small registration glue for the ci13xxx_udc that is compatible with the imx-otg driver.
--- 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
@@ -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
@@ -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
PATCH v6 7/11 MXS: Add separate MXS EHCI HCD driver
In reply to Marek VasutThis 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/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
@@ -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
@@ -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
PATCH v6 8/11 MXS: Add imx-otg driver
In reply to Marek VasutThis 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).
--- drivers/usb/otg/Kconfig | 6 + drivers/usb/otg/Makefile | 1 + drivers/usb/otg/imx-otg.c | 437 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 444 insertions(+) create mode 100644 drivers/usb/otg/imx-otg.c
drivers/usb/otg/Kconfig +6 -0
@@ -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
@@ -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 +437 -0
437 lines not on this page · raw message
Signature · 1 line
1.7.10
PATCH 8/11 MXS: Add imx-otg driver
Hi,
Quoted 4 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).
[...]
There is a conceptual bug in the following code. Did you ever run it?
Quoted 2 lines
drivers/usb/otg/imx-otg.c new file +2
-0+INIT_WORK (&priv->work, imx_otg_work); +
[...]
drivers/usb/otg/imx-otg.c line 328
Quoted 4 lines
drivers/usb/otg/imx-otg.c new file +4
-0+if (pdata->gadget_mode) { + data->pdev_gadget =add_platform_device ("ci13xxx-mxs" ,-1 , + data,sizeof (*data), +DMA_BIT_MASK (32 ));
This will blow up due to 'BUG_ON(!list_empty(&work->entry));' in kernel/workqueue.c when schedule_work() is called in imx_otg_set_host() or imx_otg_set_peripheral().
platform_add_data() (called from add_platform_device()) will make a copy of the data structure which contains the initialized work queue. INIT_WORK() will have initialized a list_head embedded in the work queue (making 'next' and 'prev' member pointing to the list_head itself).
The copied list_head will thus have its members pointing to the original data structure rather than the respective copies and thus fail the 'list_empty()' check.
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 ___________________________________________________________
PATCH v6 8/11 MXS: Add imx-otg driver
Dear Lothar Wa?mann,
Quoted 10 lines
Hi,
Quoted 3 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).
[...]
There is a conceptual bug in the following code. Did you ever run it?
Of course, but let's see the problem.
Quoted 14 lines
Quoted 2 lines
drivers/usb/otg/imx-otg.c new file +2
-0+INIT_WORK (&priv->work, imx_otg_work); +[...]
drivers/usb/otg/imx-otg.c line 328
Quoted 4 lines
drivers/usb/otg/imx-otg.c new file +4
-0+if (pdata->gadget_mode) { + data->pdev_gadget =add_platform_device ("ci13xxx-mxs" ,-1 , + data,sizeof (*data), +DMA_BIT_MASK (32 ));This will blow up due to 'BUG_ON(!list_empty(&work->entry));' in
kernel/workqueue.cwhenschedule_work()is called inimx_otg_set_host()orimx_otg_set_peripheral().
Quoted 8 lines
platform_add_data()(called fromadd_platform_device()) will make a copy of the data structure which contains the initialized work queue.INIT_WORK()will have initialized alist_headembedded in the work queue (making 'next' and 'prev' member pointing to thelist_headitself).
The copiedlist_headwill thus have its members pointing to the original data structure rather than the respective copies and thus fail the 'list_empty()' check.
Very nice, good catch, thanks! It never manifested to me, but I'll look into it and fix it in V7. How did you notice this please?
Quoted 2 lines
Lothar Wa?mann
Best regards,
Marek Vasut
PATCH v6 9/11 MXS: Add USB PHY driver
In reply to Marek VasutAdd 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.
--- drivers/usb/otg/Kconfig | 10 ++ drivers/usb/otg/Makefile | 1 + drivers/usb/otg/mxs-phy.c | 293 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 304 insertions(+) create mode 100644 drivers/usb/otg/mxs-phy.c
drivers/usb/otg/Kconfig +10 -0
@@ -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
@@ -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 +293 -0
293 lines not on this page · raw message
Signature · 1 line
1.7.10
PATCH v6 10/11 MXS: Add platform registration hooks for USB EHCI
In reply to Marek VasutBased on code by:
Tony Lin <[email protected]>
--- arch/arm/mach-mxs/devices-mx28.h | 5 ++ arch/arm/mach-mxs/devices/Kconfig | 3 + arch/arm/mach-mxs/devices/Makefile | 1 + arch/arm/mach-mxs/devices/platform-usb.c | 89 +++++++++++++++++++++++ arch/arm/mach-mxs/include/mach/devices-common.h | 13 ++++ 5 files changed, 111 insertions(+) create mode 100644 arch/arm/mach-mxs/devices/platform-usb.c
arch/arm/mach-mxs/devices-mx28.h +5 -0
@@ -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
@@ -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
@@ -11,3 +11,4 @@ obj-y += platform-gpio-mxs.o obj-$(CONFIG_MXS_HAVE_PLATFORM_MXSFB) += platform-mxsfb.o obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_SAIF) += platform-mxs-saif.o obj-$(CONFIG_MXS_HAVE_PLATFORM_RTC_STMP3XXX) += platform-rtc-stmp3xxx.o +obj-$(CONFIG_MXS_HAVE_PLATFORM_USB) += platform-usb.o
arch/arm/mach-mxs/devices/platform-usb.c new file +89 -0
89 lines not on this page · raw message
arch/arm/mach-mxs/include/mach/devices-common.h +13 -0
@@ -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
PATCH v6 11/11 MXS: Enable USB on M28EVK
In reply to Marek VasutEnable the second USB port on M28EVK board.
--- 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
@@ -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
@@ -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
v6 cover MXS: Add i.MX28 USB Host driver
In reply to Marek VasutQuoted 4 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.
I also pushed the patchset here:
http://git.kernel.org/?p=linux/kernel/git/marex/linux-2.6.git;a=shortlog;h=refs/heads/mxs-
usb
Quoted 63 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 moredevm_function
* Rework the mxs-phy to register the same interrupt as ehci-mxs (and effectivelly kill bogusotg_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
* Moveimx_otg_work()into imx-otg driver (now it all makes sense,
yay!) V6: Do PHY-specific job inside the PHY driverMarek Vasut (11):
MXS: Makeclk_disablereturn 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 theci13xxx_udcto avoid adding UDC
MXS: Add small registration glue forci13xxx_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 M28EVKarch/arm/mach-mxs/Kconfig | 2 + arch/arm/mach-mxs/clock-mx28.c | 28 +- arch/arm/mach-mxs/devices-mx28.h | 5 + arch/arm/mach-mxs/devices/Kconfig | 3 + arch/arm/mach-mxs/devices/Makefile | 1 + arch/arm/mach-mxs/devices/platform-usb.c | 89 +++++ arch/arm/mach-mxs/include/mach/clock.h | 2 +- arch/arm/mach-mxs/include/mach/devices-common.h | 13 + arch/arm/mach-mxs/include/mach/mx23.h | 8 +- arch/arm/mach-mxs/mach-m28evk.c | 21 ++ drivers/usb/gadget/Kconfig | 17 + drivers/usb/gadget/Makefile | 1 + drivers/usb/gadget/ci13xxx_mxs.c | 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 | 437 +++++++++++++++++++++++ drivers/usb/otg/mxs-phy.c | 293 +++++++++++++++ include/linux/usb/mxs-usb.h | 94 +++++ 23 files changed, 1289 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 12 lines
Cc Chen Peter-B29397 <[email protected]>Cc Detlev Zundel <[email protected]>Cc Fabio Estevam <[email protected]>Cc Li Frank-B20596 <[email protected]>Cc Linux USB <[email protected]>Cc Liu JunJie-B08287 <[email protected]>Cc Sascha Hauer <[email protected]>Cc Shawn Guo <[email protected]>Cc Shi Make-B15407 <[email protected]>Cc Stefano Babic <[email protected]>Cc Subodh Nijsure <[email protected]>Cc Wolfgang Denk <[email protected]>
Best regards,
Marek Vasut