Add USB support for i.MX27/35 and Phytec i.MX boards
Subsystems (4)
Sascha Hauer
maintainerPATCH 1/1 Add USB support for i.MX27/35 and Phytec i.MX boards
Hi all,
The following patches add platform ehci support for i.MX27 and i.MX35 and USB support for the Phytec i.MX based boards.
Any comments welcome.
Sascha
The following changes since commit 9fd96bbb6a3a1fd9ba24e84a2d7ccc6ccb6beb60:
Sascha Hauer (1):
Merge branch 'imx/master' of git://git.pengutronix.de/git/ukl/linux-2.6 into mxc-master
are available in the git repository at:
git://git.pengutronix.de/git/imx/linux-2.6.git phytec-usb
Sascha Hauer (8):
fsl_mx3_udc: Add i.MX35 support
i.MX ehci platform support: Some fixes i.MX27: Add USB control register access support i.MX35: Add USB control register access support i.MX27 pca100: Add USB support
i.MX27 pcm038: Add USB support
i.MX31 pcm037: Add USB support
i.MX27 pca100: Add USB support
arch/arm/mach-mx2/Kconfig | 2 + arch/arm/mach-mx2/mach-pca100.c | 103 ++++ arch/arm/mach-mx2/mach-pcm038.c | 22 + arch/arm/mach-mx3/Kconfig | 2 + arch/arm/mach-mx3/mach-pcm037.c | 137 ++++-- arch/arm/mach-mx3/mach-pcm043.c | 53 ++ arch/arm/mach-mx3/pcm037.c | 795 +++++++++++++++++++++++++++++ arch/arm/mach-mx3/pcm043.c | 367 +++++++++++++ arch/arm/plat-mxc/ehci.c | 118 ++++- arch/arm/plat-mxc/include/mach/mxc_ehci.h | 4 + drivers/usb/gadget/fsl_mx3_udc.c | 31 +- 11 files changed, 1570 insertions(+), 64 deletions(-) create mode 100644 arch/arm/mach-mx3/pcm037.c create mode 100644 arch/arm/mach-mx3/pcm043.c
Sascha Hauer
maintainerPATCH 1/8 fsl_mx3_udc: Add i.MX35 support
The i.MX35 works fine with this driver, but we do not have the usb_ahb clock.
--- drivers/usb/gadget/fsl_mx3_udc.c | 31 ++++++++++++++++++++----------- 1 files changed, 20 insertions(+), 11 deletions(-)
drivers/usb/gadget/fsl_mx3_udc.c +20 -11
@@ -17,6 +17,8 @@#include <linux/fsl_devices.h> #include <linux/platform_device.h> +#include <mach/hardware.h> +static struct clk *mxc_ahb_clk;static struct clk *mxc_usb_clk;
@@ -28,14 +30,16 @@ int fsl_udc_clk_init(struct platform_device *pdev) pdata = pdev->dev.platform_data; - mxc_ahb_clk =clk_get (&pdev->dev,"usb_ahb" ); -if (IS_ERR (mxc_ahb_clk)) -return PTR_ERR (mxc_ahb_clk); +if (!cpu_is_mx35 ()) { + mxc_ahb_clk =clk_get (&pdev->dev,"usb_ahb" ); +if (IS_ERR (mxc_ahb_clk)) +return PTR_ERR (mxc_ahb_clk); - ret =clk_enable (mxc_ahb_clk); -if (ret <0 ) { -dev_err (&pdev->dev,"clk_enable(\"usb_ahb\") failed\n" ); - goto eenahb; + ret =clk_enable (mxc_ahb_clk); +if (ret <0 ) { +dev_err (&pdev->dev,"clk_enable(\"usb_ahb\") failed\n" ); + goto eenahb; + } }/* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */
@@ -50,6 +54,7 @@ int fsl_udc_clk_init(struct platform_device *pdev)if (pdata->phy_mode !=FSL_USB2_PHY_ULPI && (freq <59999000 || freq >60001000 )) {dev_err (&pdev->dev,"USB_CLK=%lu, should be 60MHz\n" , freq); + ret = -EINVAL ; goto eclkrate; }
@@ -66,9 +71,11 @@ eclkrate:clk_put (mxc_usb_clk); mxc_usb_clk =NULL ; egusb: -clk_disable (mxc_ahb_clk); +if (!cpu_is_mx35 ()) +clk_disable (mxc_ahb_clk); eenahb: -clk_put (mxc_ahb_clk); +if (!cpu_is_mx35 ()) +clk_put (mxc_ahb_clk);return ret; }
@@ -90,6 +97,8 @@ void fsl_udc_clk_release(void)clk_disable (mxc_usb_clk);clk_put (mxc_usb_clk); } -clk_disable (mxc_ahb_clk); -clk_put (mxc_ahb_clk); +if (!cpu_is_mx35 ()) { +clk_disable (mxc_ahb_clk); +clk_put (mxc_ahb_clk); + } }
Signature · 1 line
1.6.6
Sascha Hauer
maintainerPATCH 2/8 i.MX ehci platform support: Some fixes
- The SIC mask is only 2bits wide, not 4
- MX31_OTG_PM_BIT and MX31_H1_PM_BIT use negative logic
- clear MX31_H1_DT_BIT and MX31_H2_DT_BIT so that they can be cleared, not only set.
- return -EINVAL if called with an invalid controller number
--- arch/arm/plat-mxc/ehci.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-)
arch/arm/plat-mxc/ehci.c +9 -7
@@ -25,16 +25,16 @@#define USBCTRL_OTGBASE_OFFSET 0x600#define MX31_OTG_SIC_SHIFT 29 -#define MX31_OTG_SIC_MASK (0xf << MX31_OTG_SIC_SHIFT) +#define MX31_OTG_SIC_MASK (0x3 << MX31_OTG_SIC_SHIFT)#define MX31_OTG_PM_BIT (1 << 24)#define MX31_H2_SIC_SHIFT 21 -#define MX31_H2_SIC_MASK (0xf << MX31_H2_SIC_SHIFT) +#define MX31_H2_SIC_MASK (0x3 << MX31_H2_SIC_SHIFT)#define MX31_H2_PM_BIT (1 << 16)#define MX31_H2_DT_BIT (1 << 5)#define MX31_H1_SIC_SHIFT 13 -#define MX31_H1_SIC_MASK (0xf << MX31_H1_SIC_SHIFT) +#define MX31_H1_SIC_MASK (0x3 << MX31_H1_SIC_SHIFT)#define MX31_H1_PM_BIT (1 << 8)#define MX31_H1_DT_BIT (1 << 4)
@@ -51,15 +51,15 @@ int mxc_set_usbcontrol(int port, unsigned int flags) v &= ~(MX31_OTG_SIC_MASK |MX31_OTG_PM_BIT ); v |= (flags &MXC_EHCI_INTERFACE_MASK ) <<MX31_OTG_SIC_SHIFT ; -if (flags &MXC_EHCI_POWER_PINS_ENABLED ) +if (!(flags &MXC_EHCI_POWER_PINS_ENABLED )) v |=MX31_OTG_PM_BIT ;break ;case 1 :/* H1 port */ - v &= ~(MX31_H1_SIC_MASK |MX31_H1_PM_BIT ); + v &= ~(MX31_H1_SIC_MASK |MX31_H1_PM_BIT |MX31_H1_DT_BIT ); v |= (flags &MXC_EHCI_INTERFACE_MASK ) <<MX31_H1_SIC_SHIFT ; -if (flags &MXC_EHCI_POWER_PINS_ENABLED ) +if (!(flags &MXC_EHCI_POWER_PINS_ENABLED )) v |=MX31_H1_PM_BIT ;if (!(flags &MXC_EHCI_TTL_ENABLED ))
@@ -67,7 +67,7 @@ int mxc_set_usbcontrol(int port, unsigned int flags)break ;case 2 :/* H2 port */ - v &= ~(MX31_H2_SIC_MASK |MX31_H2_PM_BIT ); + v &= ~(MX31_H2_SIC_MASK |MX31_H2_PM_BIT |MX31_H2_DT_BIT ); v |= (flags &MXC_EHCI_INTERFACE_MASK ) <<MX31_H2_SIC_SHIFT ;if (!(flags &MXC_EHCI_POWER_PINS_ENABLED ))
@@ -77,6 +77,8 @@ int mxc_set_usbcontrol(int port, unsigned int flags) v |=MX31_H2_DT_BIT ;break ; +default : +return -EINVAL ; } writel(v, MX31_IO_ADDRESS(MX31_OTG_BASE_ADDR +
Signature · 1 line
1.6.6
Sascha Hauer
maintainerPATCH 3/8 i.MX27: Add USB control register access support
--- arch/arm/plat-mxc/ehci.c | 47 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 deletions(-)
arch/arm/plat-mxc/ehci.c +46 -1
@@ -41,7 +41,7 @@int mxc_set_usbcontrol (int port,unsigned int flags) {unsigned int v; - +#ifdef CONFIG_ARCH_MX3 if (cpu_is_mx31 ()) { v =readl (MX31_IO_ADDRESS (MX31_OTG_BASE_ADDR +USBCTRL_OTGBASE_OFFSET ));
@@ -85,7 +85,52 @@ int mxc_set_usbcontrol(int port, unsigned int flags) USBCTRL_OTGBASE_OFFSET));return 0 ; } +#endif /* CONFIG_ARCH_MX3 */ +#ifdef CONFIG_MACH_MX27 +if (cpu_is_mx27 ()) { +/* On i.MX27 we can use the i.MX31 USBCTRL bits, they +* are identical +*/ + v =readl (MX27_IO_ADDRESS (MX27_OTG_BASE_ADDR + +USBCTRL_OTGBASE_OFFSET )); +switch (port) { +case 0 :/* OTG port */ + v &= ~(MX31_OTG_SIC_MASK |MX31_OTG_PM_BIT ); + v |= (flags &MXC_EHCI_INTERFACE_MASK ) + <<MX31_OTG_SIC_SHIFT ; +if (!(flags &MXC_EHCI_POWER_PINS_ENABLED )) + v |=MX31_OTG_PM_BIT ; +break ; +case 1 :/* H1 port */ + v &= ~(MX31_H1_SIC_MASK |MX31_H1_PM_BIT |MX31_H1_DT_BIT ); + v |= (flags &MXC_EHCI_INTERFACE_MASK ) + <<MX31_H1_SIC_SHIFT ; +if (!(flags &MXC_EHCI_POWER_PINS_ENABLED )) + v |=MX31_H1_PM_BIT ; + +if (!(flags &MXC_EHCI_TTL_ENABLED )) + v |=MX31_H1_DT_BIT ; +break ; +case 2 :/* H2 port */ + v &= ~(MX31_H2_SIC_MASK |MX31_H2_PM_BIT |MX31_H2_DT_BIT ); + v |= (flags &MXC_EHCI_INTERFACE_MASK ) + <<MX31_H2_SIC_SHIFT ; +if (!(flags &MXC_EHCI_POWER_PINS_ENABLED )) + v |=MX31_H2_PM_BIT ; + +if (!(flags &MXC_EHCI_TTL_ENABLED )) + v |=MX31_H2_DT_BIT ; + +break ; +default : +return -EINVAL ; + } +writel (v,MX27_IO_ADDRESS (MX27_OTG_BASE_ADDR + +USBCTRL_OTGBASE_OFFSET )); +return 0 ; + } +#endif /* CONFIG_MACH_MX27 */ printk (KERN_WARNING "%s() unable to setup USBCONTROL for this CPU\n" , __func__);return -EINVAL ;
Signature · 1 line
1.6.6
Sascha Hauer
maintainerPATCH 4/8 i.MX35: Add USB control register access support
--- arch/arm/plat-mxc/ehci.c | 55 +++++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/mxc_ehci.h | 4 ++ 2 files changed, 59 insertions(+), 0 deletions(-)
arch/arm/plat-mxc/ehci.c +55 -0
@@ -38,6 +38,18 @@#define MX31_H1_PM_BIT (1 << 8)#define MX31_H1_DT_BIT (1 << 4) +#define MX35_OTG_SIC_SHIFT 29 +#define MX35_OTG_SIC_MASK (0x3 << MX35_OTG_SIC_SHIFT) +#define MX35_OTG_PM_BIT (1 << 24) + +#define MX35_H1_SIC_SHIFT 21 +#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT) +#define MX35_H1_PM_BIT (1 << 8) +#define MX35_OTG_IPPUE_UP_BIT (1 << 7) +#define MX35_OTG_IPPUE_DOWN_BIT (1 << 6) +#define MX35_H1_TLL_BIT (1 << 5) +#define MX35_OTG_USBTE_BIT (1 << 4) +int mxc_set_usbcontrol (int port,unsigned int flags) {unsigned int v;
@@ -85,6 +97,49 @@ int mxc_set_usbcontrol(int port, unsigned int flags) USBCTRL_OTGBASE_OFFSET));return 0 ; } + +if (cpu_is_mx35 ()) { + v =readl (MX35_IO_ADDRESS (MX35_OTG_BASE_ADDR + +USBCTRL_OTGBASE_OFFSET )); + +switch (port) { +case 0 :/* OTG port */ + v &= ~(MX35_OTG_SIC_MASK |MX35_OTG_PM_BIT ); + v |= (flags &MXC_EHCI_INTERFACE_MASK ) + <<MX35_OTG_SIC_SHIFT ; +if (!(flags &MXC_EHCI_POWER_PINS_ENABLED )) + v |=MX35_OTG_PM_BIT ; + +break ; +case 1 :/* H1 port */ + v &= ~(MX35_H1_SIC_MASK |MX35_H1_PM_BIT |MX35_H1_TLL_BIT | +MX35_OTG_USBTE_BIT |MXC_EHCI_IPPUE_DOWN |MXC_EHCI_IPPUE_UP ); + v |= (flags &MXC_EHCI_INTERFACE_MASK ) + <<MX35_H1_SIC_SHIFT ; +if (!(flags &MXC_EHCI_POWER_PINS_ENABLED )) + v |=MX35_H1_PM_BIT ; + +if (!(flags &MXC_EHCI_TTL_ENABLED )) + v |=MX35_H1_TLL_BIT ; + +if (flags &MXC_EHCI_INTERNAL_PHY ) + v |=MX35_OTG_USBTE_BIT ; + +if (flags &MXC_EHCI_IPPUE_DOWN ) + v |=MX35_OTG_IPPUE_DOWN_BIT ; + +if (flags &MXC_EHCI_IPPUE_UP ) + v |=MX35_OTG_IPPUE_UP_BIT ; + +break ; +default : +return -EINVAL ; + } + +writel (v,MX35_IO_ADDRESS (MX35_OTG_BASE_ADDR + +USBCTRL_OTGBASE_OFFSET )); +return 0 ; + }#endif /* CONFIG_ARCH_MX3 */ #ifdef CONFIG_MACH_MX27 if (cpu_is_mx27 ()) {
arch/arm/plat-mxc/include/mach/mxc_ehci.h +4 -0
@@ -22,6 +22,10 @@#define MXC_EHCI_POWER_PINS_ENABLED (1 << 5)#define MXC_EHCI_TTL_ENABLED (1 << 6) +#define MXC_EHCI_INTERNAL_PHY (1 << 7) +#define MXC_EHCI_IPPUE_DOWN (1 << 8) +#define MXC_EHCI_IPPUE_UP (1 << 9) +struct mxc_usbh_platform_data {int (*init)(struct platform_device *pdev);int (*exit)(struct platform_device *pdev);
Signature · 1 line
1.6.6
Sascha Hauer
maintainerPATCH 4/8 i.MX35: Add USB control register access support
Quoted 41 lines · Sascha Hauer
Signed-off-by Sascha Hauer <[email protected]>Cc Daniel Mack <[email protected]>--- arch/arm/plat-mxc/ehci.c | 55 +++++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/mxc_ehci.h | 4 ++ 2 files changed, 59 insertions(+), 0 deletions(-)arch/arm/plat-mxc/ehci.c +19
-0@@ -38,6 +38,18 @@#define MX31_H1_PM_BIT (1 << 8)#define MX31_H1_DT_BIT (1 << 4) +#define MX35_OTG_SIC_SHIFT 29 +#define MX35_OTG_SIC_MASK (0x3 << MX35_OTG_SIC_SHIFT) +#define MX35_OTG_PM_BIT (1 << 24) + +#define MX35_H1_SIC_SHIFT 21 +#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT) +#define MX35_H1_PM_BIT (1 << 8) +#define MX35_OTG_IPPUE_UP_BIT (1 << 7) +#define MX35_OTG_IPPUE_DOWN_BIT (1 << 6) +#define MX35_H1_TLL_BIT (1 << 5) +#define MX35_OTG_USBTE_BIT (1 << 4) +int mxc_set_usbcontrol (int port,unsigned int flags) {unsigned int v;@@ -85,6 +97,49 @@ int mxc_set_usbcontrol(int port, unsigned int flags) USBCTRL_OTGBASE_OFFSET));return 0 ; } + +if (cpu_is_mx35 ()) { + v =readl (MX35_IO_ADDRESS (MX35_OTG_BASE_ADDR + +USBCTRL_OTGBASE_OFFSET )); + +switch (port) { +case 0 :/* OTG port */
arch/arm/plat-mxc/ehci.c int mxc_set_usbcontrol(int port, unsigned int flags) · line 116
Quoted 10 lines
arch/arm/plat-mxc/ehci.c +10
-0+ v &= ~(MX35_OTG_SIC_MASK |MX35_OTG_PM_BIT ); + v |= (flags &MXC_EHCI_INTERFACE_MASK ) + <<MX35_OTG_SIC_SHIFT ; +if (!(flags &MXC_EHCI_POWER_PINS_ENABLED )) + v |=MX35_OTG_PM_BIT ; + +break ; +case 1 :/* H1 port */ + v &= ~(MX35_H1_SIC_MASK |MX35_H1_PM_BIT |MX35_H1_TLL_BIT | +MX35_OTG_USBTE_BIT |MXC_EHCI_IPPUE_DOWN |MXC_EHCI_IPPUE_UP );
Gna, of course the MX35_OTG_USBTE_BIT / MX35_OTG_IPPUE_UP_BIT bits should be cleared here, not the generic defines.
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 |
PATCH 4/8 i.MX35: Add USB control register access support
In reply to Sascha Hauerarch/arm/plat-mxc/ehci.c line 51
Quoted 4 lines · Sascha Hauer
arch/arm/plat-mxc/ehci.c +3
-0+#define MX35_OTG_IPPUE_UP_BIT (1 << 7) +#define MX35_OTG_IPPUE_DOWN_BIT (1 << 6) +#define MX35_OTG_USBTE_BIT (1 << 4)
Why are these bits called '_OTG_'? They are applied in the 'H1 port' case and reference manual mentions them only for the USB host part.
Enrico
Sascha Hauer
maintainerPATCH 4/8 i.MX35: Add USB control register access support
Quoted 9 lines · Enrico Scholz
arch/arm/plat-mxc/ehci.c line 51
Quoted 4 lines · Sascha Hauer
arch/arm/plat-mxc/ehci.c +3
-0+#define MX35_OTG_IPPUE_UP_BIT (1 << 7) +#define MX35_OTG_IPPUE_DOWN_BIT (1 << 6) +#define MX35_OTG_USBTE_BIT (1 << 4)Why are these bits called '_OTG_'? They are applied in the 'H1 port' case and reference manual mentions them only for the USB host part.
You're right. Will fix
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 |
Sascha Hauer
maintainerPATCH 5/8 i.MX27 pca100: Add USB support
In reply to Sascha Hauer--- arch/arm/mach-mx2/Kconfig | 1 + arch/arm/mach-mx2/mach-pca100.c | 103 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 0 deletions(-)
arch/arm/mach-mx2/Kconfig +1 -0
@@ -100,6 +100,7 @@ config MACH_IMX27LITE config MACH_PCA100 bool "Phytec phyCARD-s (pca100)" depends on MACH_MX27 + select MXC_ULPI if USB_ULPI help Include support for phyCARD-s (aka pca100) platform. This includes specific configurations for the module and its peripherals.
arch/arm/mach-mx2/mach-pca100.c +103 -0
136 lines not on this page · raw message
Signature · 1 line
1.6.6
Sascha Hauer
maintainerPATCH 6/8 i.MX27 pcm038: Add USB support
--- arch/arm/mach-mx2/Kconfig | 1 + arch/arm/mach-mx2/mach-pcm038.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 0 deletions(-)
arch/arm/mach-mx2/Kconfig +1 -0
@@ -37,6 +37,7 @@ config MACH_MX27ADS config MACH_PCM038 bool "Phytec phyCORE-i.MX27 CPU module (pcm038)" depends on MACH_MX27 + select MXC_ULPI if USB_ULPI help Include support for phyCORE-i.MX27 (aka pcm038) platform. This includes specific configurations for the module and its peripherals.
arch/arm/mach-mx2/mach-pcm038.c +22 -0
@@ -40,6 +40,8 @@#include <mach/imx-uart.h> #include <mach/mxc_nand.h> #include <mach/spi.h> +#include <mach/mxc_ehci.h> +#include <mach/ulpi.h> #include "devices.h"
@@ -96,6 +98,19 @@ static int pcm038_pins[] = {PC17_PF_SSI4_RXD ,PC18_PF_SSI4_TXD ,PC19_PF_SSI4_CLK , +/* USB host */ +PA0_PF_USBH2_CLK , +PA1_PF_USBH2_DIR , +PA2_PF_USBH2_DATA7 , +PA3_PF_USBH2_NXT , +PA4_PF_USBH2_STP , +PD19_AF_USBH2_DATA4 , +PD20_AF_USBH2_DATA3 , +PD21_AF_USBH2_DATA6 , +PD22_AF_USBH2_DATA0 , +PD23_AF_USBH2_DATA2 , +PD24_AF_USBH2_DATA1 , + PD26_AF_USBH2_DATA5, };/*
@@ -277,6 +292,11 @@ static struct spi_board_info pcm038_spi_board_info[] __initdata = { } }; +static struct mxc_usbh_platform_data usbh2_pdata = { + .portsc =MXC_EHCI_MODE_ULPI , + .flags =MXC_EHCI_POWER_PINS_ENABLED |MXC_EHCI_INTERFACE_DIFF_UNI , +}; +static void __init pcm038_init (void ) { mxc_gpio_setup_multiple_pins(pcm038_pins, ARRAY_SIZE(pcm038_pins),
@@ -309,6 +329,8 @@ static void __init pcm038_init(void)spi_register_board_info (pcm038_spi_board_info,ARRAY_SIZE (pcm038_spi_board_info)); +mxc_register_device (&mxc_usbh2, &usbh2_pdata); +platform_add_devices (platform_devices,ARRAY_SIZE (platform_devices));#ifdef CONFIG_MACH_PCM970_BASEBOARD
Signature · 1 line
1.6.6
Sascha Hauer
maintainerPATCH 7/8 i.MX31 pcm037: Add USB support
--- arch/arm/mach-mx3/Kconfig | 1 + arch/arm/mach-mx3/mach-pcm037.c | 137 +++++--- arch/arm/mach-mx3/pcm037.c | 795 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-mx3/pcm043.c | 367 ++++++++++++++++++ 4 files changed, 1255 insertions(+), 45 deletions(-) create mode 100644 arch/arm/mach-mx3/pcm037.c create mode 100644 arch/arm/mach-mx3/pcm043.c
arch/arm/mach-mx3/Kconfig +1 -0
@@ -34,6 +34,7 @@ config MACH_MX31ADS_WM1133_EV1 config MACH_PCM037 bool "Support Phytec pcm037 (i.MX31) platforms" select ARCH_MX31 + select MXC_ULPI if USB_ULPI help Include support for Phytec pcm037 platform. This includes specific configurations for the board and its peripherals.
arch/arm/mach-mx3/mach-pcm037.c +92 -45
192 lines not on this page · raw message
arch/arm/mach-mx3/pcm037.c new file +795 -0
795 lines not on this page · raw message
arch/arm/mach-mx3/pcm043.c new file +367 -0
367 lines not on this page · raw message
Signature · 1 line
1.6.6
Sascha Hauer
maintainerPATCH 8/8 i.MX27 pca100: Add USB support
--- arch/arm/mach-mx3/Kconfig | 1 + arch/arm/mach-mx3/mach-pcm043.c | 53 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 0 deletions(-)
arch/arm/mach-mx3/Kconfig +1 -0
@@ -87,6 +87,7 @@ config MACH_QONG config MACH_PCM043 bool "Support Phytec pcm043 (i.MX35) platforms" select ARCH_MX35 + select MXC_ULPI if USB_ULPI help Include support for Phytec pcm043 platform. This includes specific configurations for the board and its peripherals.
arch/arm/mach-mx3/mach-pcm043.c +53 -0
83 lines not on this page · raw message
Signature · 1 line
1.6.6
PATCH 7/8 i.MX31 pcm037: Add USB support
In reply to Sascha Hauerarch/arm/mach-mx3/pcm037.c
Quoted 227 lines · Sascha Hauer
Signed-off-by Sascha Hauer <[email protected]>--- arch/arm/mach-mx3/Kconfig | 1 + arch/arm/mach-mx3/mach-pcm037.c | 137 +++++--- arch/arm/mach-mx3/pcm037.c | 795 +++++++++++++++++++++++++++++++++++++++ arch/arm/mach-mx3/pcm043.c | 367 ++++++++++++++++++ 4 files changed, 1255 insertions(+), 45 deletions(-) create mode 100644 arch/arm/mach-mx3/pcm037.c create mode 100644 arch/arm/mach-mx3/pcm043.carch/arm/mach-mx3/Kconfig +1
-0@@ -34,6 +34,7 @@ config MACH_MX31ADS_WM1133_EV1 config MACH_PCM037 bool "Support Phytec pcm037 (i.MX31) platforms" select ARCH_MX31 + select MXC_ULPI if USB_ULPI help Include support for Phytec pcm037 platform. This includes specific configurations for the board and its peripherals.arch/arm/mach-mx3/mach-pcm037.c +92
-45@@ -33,6 +33,9 @@#include <linux/irq.h> #include <linux/fsl_devices.h> #include <linux/can/platform/sja1000.h> +#include <linux/usb/otg.h> +#include <linux/usb/ulpi.h> +#include <linux/fsl_devices.h> #include <media/soc_camera.h> @@ -51,6 +54,8 @@#include <mach/mx3_camera.h> #include <mach/mx3fb.h> #include <mach/mxc_nand.h> +#include <mach/mxc_ehci.h> +#include <mach/ulpi.h> #include "devices.h" #include "pcm037.h" @@ -172,19 +177,7 @@ static unsigned int pcm037_pins[] = {MX31_PIN_CSI_VSYNC__CSI_VSYNC ,/* GPIO */ IOMUX_MODE (MX31_PIN_ATA_DMACK ,IOMUX_CONFIG_GPIO ), -}; - -static struct physmap_flash_data pcm037_flash_data = { - .width =2 , -}; - -static struct resource pcm037_flash_resource = { - .start =0xa0000000 , - .end =0xa1ffffff , - .flags =IORESOURCE_MEM , -}; - -static int usbotg_pins[] = { +/* OTG */ MX31_PIN_USBOTG_DATA0__USBOTG_DATA0 ,MX31_PIN_USBOTG_DATA1__USBOTG_DATA1 , MX31_PIN_USBOTG_DATA2__USBOTG_DATA2,@@ -197,39 +190,29 @@ static int usbotg_pins[] = {MX31_PIN_USBOTG_DIR__USBOTG_DIR ,MX31_PIN_USBOTG_NXT__USBOTG_NXT ,MX31_PIN_USBOTG_STP__USBOTG_STP , +/* USB host 2 */ +IOMUX_MODE (MX31_PIN_USBH2_CLK ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_USBH2_DIR ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_USBH2_NXT ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_USBH2_STP ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_USBH2_DATA0 ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_USBH2_DATA1 ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_STXD3 ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_SRXD3 ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_SCK3 ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_SFS3 ,IOMUX_CONFIG_FUNC ), +IOMUX_MODE (MX31_PIN_STXD6 ,IOMUX_CONFIG_FUNC ), + IOMUX_MODE(MX31_PIN_SRXD6, IOMUX_CONFIG_FUNC), }; -/* USB OTG HS port */ -static int __init gpio_usbotg_hs_activate (void ) -{ -int ret =mxc_iomux_setup_multiple_pins (usbotg_pins, -ARRAY_SIZE (usbotg_pins),"usbotg" ); - -if (ret <0 ) { -printk (KERN_ERR "Cannot set up OTG pins\n" ); -return ret; - } - -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA0 ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA1 ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA2 ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA3 ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA4 ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA5 ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA6 ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DATA7 ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_CLK ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_DIR ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_NXT ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); -mxc_iomux_set_pad (MX31_PIN_USBOTG_STP ,PAD_CTL_DRV_MAX |PAD_CTL_SRE_FAST ); - -return 0 ; -} +static struct physmap_flash_data pcm037_flash_data = { + .width =2 , +}; -/* OTG config */ -static struct fsl_usb2_platform_data usb_pdata = { - .operating_mode =FSL_USB2_DR_DEVICE , - .phy_mode =FSL_USB2_PHY_ULPI , +static struct resource pcm037_flash_resource = { + .start =0xa0000000 , + .end =0xa1ffffff , + .flags =IORESOURCE_MEM , }; static struct platform_device pcm037_flash = {@@ -561,16 +544,65 @@ static struct platform_device pcm970_sja1000 = { .num_resources = ARRAY_SIZE(pcm970_sja1000_resources), }; +static struct mxc_usbh_platform_data otg_pdata = { + .portsc =MXC_EHCI_MODE_ULPI , + .flags =MXC_EHCI_INTERFACE_DIFF_UNI , +}; + +static struct mxc_usbh_platform_data usbh2_pdata = { + .portsc =MXC_EHCI_MODE_ULPI , + .flags =MXC_EHCI_INTERFACE_DIFF_UNI , +}; + +static struct fsl_usb2_platform_data otg_device_pdata = { + .operating_mode =FSL_USB2_DR_DEVICE , + .phy_mode =FSL_USB2_PHY_ULPI , +}; + +static int otg_mode_host; + +static int __init pcm037_otg_mode (char *options) +{ +if (!strcmp (options,"host" )) + otg_mode_host =1 ; +else if (!strcmp (options,"device" )) + otg_mode_host =0 ; +else +pr_info ("otg_mode neither \"host\" nor \"device\". " +"Defaulting to device\n" ); +return 0 ; +} +__setup ("otg_mode=" , pcm037_otg_mode); +/* * Board specific initialization. */ static void __init mxc_board_init (void ) {int ret; +u32 tmp; + +mxc_iomux_set_gpr (MUX_PGP_UH2 ,1 );mxc_iomux_setup_multiple_pins (pcm037_pins,ARRAY_SIZE (pcm037_pins),"pcm037" ); +#define H2_PAD_CFG (PAD_CTL_DRV_MAX | PAD_CTL_SRE_FAST | PAD_CTL_HYS_CMOS \ + | PAD_CTL_ODE_CMOS | PAD_CTL_100K_PU) + +mxc_iomux_set_pad (MX31_PIN_USBH2_CLK ,H2_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_DIR ,H2_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_NXT ,H2_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_STP ,H2_PAD_CFG ); +mxc_iomux_set_pad (MX31_PIN_USBH2_DATA0 ,H2_PAD_CFG );/* USBH2_DATA0 */ +mxc_iomux_set_pad (MX31_PIN_USBH2_DATA1 ,H2_PAD_CFG );/* USBH2_DATA1 */ +mxc_iomux_set_pad (MX31_PIN_SRXD6 ,H2_PAD_CFG );/* USBH2_DATA2 */ +mxc_iomux_set_pad (MX31_PIN_STXD6 ,H2_PAD_CFG );/* USBH2_DATA3 */ +mxc_iomux_set_pad (MX31_PIN_SFS3 ,H2_PAD_CFG );/* USBH2_DATA4 */ +mxc_iomux_set_pad (MX31_PIN_SCK3 ,H2_PAD_CFG );/* USBH2_DATA5 */ +mxc_iomux_set_pad (MX31_PIN_SRXD3 ,H2_PAD_CFG );/* USBH2_DATA6 */ +mxc_iomux_set_pad (MX31_PIN_STXD3 ,H2_PAD_CFG );/* USBH2_DATA7 */ +if (pcm037_variant () ==PCM037_EET )mxc_iomux_setup_multiple_pins (pcm037_uart1_pins,ARRAY_SIZE (pcm037_uart1_pins),"pcm037_uart1" );@@ -608,8 +640,6 @@ static void __init mxc_board_init(void)mxc_register_device (&mxcsdhc_device0, &sdhc_pdata);mxc_register_device (&mx3_ipu, &mx3_ipu_data);mxc_register_device (&mx3_fb, &mx3fb_pdata); -if (!gpio_usbotg_hs_activate ()) -mxc_register_device (&mxc_otg_udc_device, &usb_pdata);/* CSI */ /* Camera power: default - off */ @@ -623,6 +653,23 @@ static void __init mxc_board_init(void)mxc_register_device (&mx3_camera, &camera_pdata);platform_device_register (&pcm970_sja1000); + +#if defined(CONFIG_USB_ULPI ) +if (otg_mode_host) { + otg_pdata.otg =otg_ulpi_create (&mxc_ulpi_access_ops, +USB_OTG_DRV_VBUS |USB_OTG_DRV_VBUS_EXT ); + +mxc_register_device (&mxc_otg_host, &otg_pdata); + } + + usbh2_pdata.otg =otg_ulpi_create (&mxc_ulpi_access_ops, +USB_OTG_DRV_VBUS |USB_OTG_DRV_VBUS_EXT ); + +mxc_register_device (&mxc_usbh2, &usbh2_pdata); +#endif +if (!otg_mode_host) +mxc_register_device (&mxc_otg_udc_device, &otg_device_pdata); + }static void __init pcm037_timer_init (void )arch/arm/mach-mx3/pcm037.c new file +0
-0
Sascha, maybe you do not want to reintroduce the file pcm037.c with this patch.
Best regards,
Signature · 4 lines
Alberto!
Be Persistent!
- Greg Kroah-Hartman (FOSDEM 2010)PATCH 1/8 fsl_mx3_udc: Add i.MX35 support
In reply to Sascha Hauer(added usb to cc)
Quoted 5 lines · Sascha Hauer
The i.MX35 works fine with this driver, but we do not have the
usb_ahbclock.Signed-off-by Sascha Hauer <[email protected]>Cc Guennadi Liakhovetski <[email protected]>
Sorry for a delay...
Quoted 53 lines
--- drivers/usb/gadget/fsl_mx3_udc.c | 31 ++++++++++++++++++++----------- 1 files changed, 20 insertions(+), 11 deletions(-)drivers/usb/gadget/fsl_mx3_udc.c +12
-7@@ -17,6 +17,8 @@#include <linux/fsl_devices.h> #include <linux/platform_device.h> +#include <mach/hardware.h> +static struct clk *mxc_ahb_clk;static struct clk *mxc_usb_clk;@@ -28,14 +30,16 @@ int fsl_udc_clk_init(struct platform_device *pdev) pdata = pdev->dev.platform_data; - mxc_ahb_clk =clk_get (&pdev->dev,"usb_ahb" ); -if (IS_ERR (mxc_ahb_clk)) -return PTR_ERR (mxc_ahb_clk); +if (!cpu_is_mx35 ()) { + mxc_ahb_clk =clk_get (&pdev->dev,"usb_ahb" ); +if (IS_ERR (mxc_ahb_clk)) +return PTR_ERR (mxc_ahb_clk); - ret =clk_enable (mxc_ahb_clk); -if (ret <0 ) { -dev_err (&pdev->dev,"clk_enable(\"usb_ahb\") failed\n" ); - goto eenahb; + ret =clk_enable (mxc_ahb_clk); +if (ret <0 ) { +dev_err (&pdev->dev,"clk_enable(\"usb_ahb\") failed\n" ); + goto eenahb; + } }/* make sure USB_CLK is running at 60 MHz +/- 1000 Hz */ @@ -50,6 +54,7 @@ int fsl_udc_clk_init(struct platform_device *pdev)if (pdata->phy_mode !=FSL_USB2_PHY_ULPI && (freq <59999000 || freq >60001000 )) {dev_err (&pdev->dev,"USB_CLK=%lu, should be 60MHz\n" , freq); + ret = -EINVAL ; goto eclkrate; }@@ -66,9 +71,11 @@ eclkrate:clk_put (mxc_usb_clk); mxc_usb_clk =NULL ; egusb:
drivers/usb/gadget/fsl_mx3_udc.c eclkrate: · line 81
Quoted 10 lines
drivers/usb/gadget/fsl_mx3_udc.c +4
-2-clk_disable (mxc_ahb_clk); +if (!cpu_is_mx35 ()) +clk_disable (mxc_ahb_clk); eenahb: -clk_put (mxc_ahb_clk); +if (!cpu_is_mx35 ()) +clk_put (mxc_ahb_clk);return ret; }
You could do
egusb:
if (!cpu_is_mx35()) {
clk_disable(mxc_ahb_clk);
eenahb:
clk_put(mxc_ahb_clk);
}here, which (arguably) looks a bit better, but that's not anything critical, I think. Otherwise
Quoted 14 lines
drivers/usb/gadget/fsl_mx3_udc.c +4
-2@@ -90,6 +97,8 @@ void fsl_udc_clk_release(void)clk_disable (mxc_usb_clk);clk_put (mxc_usb_clk); } -clk_disable (mxc_ahb_clk); -clk_put (mxc_ahb_clk); +if (!cpu_is_mx35 ()) { +clk_disable (mxc_ahb_clk); +clk_put (mxc_ahb_clk); + } }Signature · 1 line
1.6.6
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
PATCH 1/1 Add USB support for i.MX27/35 and Phytec i.MX boards
In reply to Sascha HauerHi Sascha,
On Thu, Feb 04, 2010 at 04:03:37PM +0100, Sascha Hauer wrote:
[snip]
Quoted 6 lines
arch/arm/mach-mx2/Kconfig | 2 + arch/arm/mach-mx2/mach-pca100.c | 103 ++++ arch/arm/mach-mx2/mach-pcm038.c | 22 + arch/arm/mach-mx3/Kconfig | 2 + arch/arm/mach-mx3/mach-pcm037.c | 137 ++++-- arch/arm/mach-mx3/mach-pcm043.c | 53 ++
Quoted 8 lines
arch/arm/mach-mx3/pcm037.c | 795 +++++++++++++++++++++++++++++ arch/arm/mach-mx3/pcm043.c | 367 +++++++++++++ arch/arm/plat-mxc/ehci.c | 118 ++++- arch/arm/plat-mxc/include/mach/mxc_ehci.h | 4 + drivers/usb/gadget/fsl_mx3_udc.c | 31 +- 11 files changed, 1570 insertions(+), 64 deletions(-) create mode 100644 arch/arm/mach-mx3/pcm037.c create mode 100644 arch/arm/mach-mx3/pcm043.c
Is the addition of these two files intended?
baruch
Signature · 3 lines
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -Sascha Hauer
maintainerPATCH 1/1 Add USB support for i.MX27/35 and Phytec i.MX boards
Quoted 21 lines · Baruch Siach
Hi Sascha,
On Thu, Feb 04, 2010 at 04:03:37PM +0100, Sascha Hauer wrote:
[snip]
Quoted 6 lines
arch/arm/mach-mx2/Kconfig | 2 + arch/arm/mach-mx2/mach-pca100.c | 103 ++++ arch/arm/mach-mx2/mach-pcm038.c | 22 + arch/arm/mach-mx3/Kconfig | 2 + arch/arm/mach-mx3/mach-pcm037.c | 137 ++++-- arch/arm/mach-mx3/mach-pcm043.c | 53 ++Quoted 8 lines
arch/arm/mach-mx3/pcm037.c | 795 +++++++++++++++++++++++++++++ arch/arm/mach-mx3/pcm043.c | 367 +++++++++++++ arch/arm/plat-mxc/ehci.c | 118 ++++- arch/arm/plat-mxc/include/mach/mxc_ehci.h | 4 + drivers/usb/gadget/fsl_mx3_udc.c | 31 +- 11 files changed, 1570 insertions(+), 64 deletions(-) create mode 100644 arch/arm/mach-mx3/pcm037.c create mode 100644 arch/arm/mach-mx3/pcm043.c
Quoted 1 line
Is the addition of these two files intended?
No. Some git accident... Fixed.
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 |