Skip to contentSkip to conversation

ARM: mx3/mx35_3ds: Add USB OTG Host mode

PATCH Superseded Fabio Estevam 3 participants 6 messages Dec 21, 2010 – Dec 22, 2010

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 ARM: mx3/mx35_3ds: Add USB OTG Host mode

---
 arch/arm/mach-mx3/Kconfig         |    1 +
 arch/arm/mach-mx3/mach-mx35_3ds.c |   34 ++++++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)
arch/arm/mach-mx3/Kconfig +1 -0
index 9037c4e..f474e2e 100644
@@ -185,6 +185,7 @@ config MACH_MX35_3DS
 	select IMX_HAVE_PLATFORM_MXC_EHCI
 	select IMX_HAVE_PLATFORM_MXC_NAND
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
+	select MXC_ULPI if USB_ULPI
 	help
 	  Include support for MX35PDK platform. This includes specific
 	  configurations for the board and its peripherals.
arch/arm/mach-mx3/mach-mx35_3ds.c +32 -2
index 8bd8992..3cb4f5c 100644
@@ -26,6 +26,8 @@
 #include <linux/platform_device.h>
 #include <linux/memory.h>
 #include <linux/gpio.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/ulpi.h>
 
 #include <linux/mtd/physmap.h>
 
@@ -39,6 +41,7 @@
 #include <mach/iomux-mx35.h>
 #include <mach/irqs.h>
 #include <mach/3ds_debugboard.h>
+#include <mach/ulpi.h>
 
 #include "devices-imx35.h"
 #include "devices.h"
@@ -125,12 +128,34 @@ static const struct fsl_usb2_platform_data usb_otg_pdata __initconst = {
 	.phy_mode	= FSL_USB2_PHY_UTMI_WIDE,
 };
 
+#if defined(CONFIG_USB_ULPI)
+static struct mxc_usbh_platform_data otg_pdata __initdata = {
+	.portsc	= MXC_EHCI_MODE_UTMI,
+	.flags	= MXC_EHCI_INTERNAL_PHY,
+};
+
 /* USB HOST config */
 static const struct mxc_usbh_platform_data usb_host_pdata __initconst = {
 	.portsc		= MXC_EHCI_MODE_SERIAL,
 	.flags		= MXC_EHCI_INTERFACE_SINGLE_UNI |
 			  MXC_EHCI_INTERNAL_PHY,
 };
+#endif
+
+static int otg_mode_host;
+
+static int __init mx35_3ds_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=", mx35_3ds_otg_mode);
 
 /*
  * Board specific initialization.
@@ -144,10 +169,15 @@ static void __init mxc_board_init(void)
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 
 	imx35_add_imx_uart0(&uart_pdata);
-
-	imx35_add_fsl_usb2_udc(&usb_otg_pdata);
+
+#if defined(CONFIG_USB_ULPI)
+	if (otg_mode_host)
+		imx35_add_mxc_ehci_otg(&otg_pdata);
 
 	imx35_add_mxc_ehci_hs(&usb_host_pdata);
+#endif
+	if (!otg_mode_host)
+		imx35_add_fsl_usb2_udc(&usb_otg_pdata);
 
 	imx35_add_mxc_nand(&mx35pdk_nand_board_info);
 	imx35_add_sdhci_esdhc_imx(0, NULL);
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 2/3 ARM: imx/mx27_3ds: Add USB OTG support

---
 arch/arm/mach-imx/Kconfig         |    3 ++
 arch/arm/mach-imx/mach-mx27_3ds.c |   71 +++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 0 deletions(-)
arch/arm/mach-imx/Kconfig +3 -0
index fed3ee5..9a715ce 100644
@@ -235,10 +235,13 @@ endchoice
 config MACH_MX27_3DS
 	bool "MX27PDK platform"
 	select SOC_IMX27
+	select IMX_HAVE_PLATFORM_FSL_USB2_UDC
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_UART
+	select IMX_HAVE_PLATFORM_MXC_EHCI
 	select IMX_HAVE_PLATFORM_MXC_MMC
+	select MXC_ULPI if USB_ULPI
 	help
 	  Include support for MX27PDK platform. This includes specific
 	  configurations for the board and its peripherals.
arch/arm/mach-imx/mach-mx27_3ds.c +71 -0

105 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#2 lore raw

PATCH 3/3 ARM: imx/mx25_3ds: Add USB support

---
 arch/arm/mach-imx/Kconfig         |    3 +++
 arch/arm/mach-imx/mach-mx25_3ds.c |   16 +++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
arch/arm/mach-imx/Kconfig +3 -0
index fed3ee5..4a6c51a 100644
@@ -97,14 +97,17 @@ comment "MX25 platforms:"
 config MACH_MX25_3DS
 	bool "Support MX25PDK (3DS) Platform"
 	select SOC_IMX25
+	select IMX_HAVE_PLATFORM_FSL_USB2_UDC
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMXDI_RTC
 	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_EHCI
+	select IMX_HAVE_PLATFORM_MXC_EHCI
 	select IMX_HAVE_PLATFORM_MXC_NAND
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
+	select MXC_ULPI if USB_ULPI
 
 config MACH_EUKREA_CPUIMX25
 	bool "Support Eukrea CPUIMX25 Platform"
arch/arm/mach-imx/mach-mx25_3ds.c +15 -1
index 8b8e75b..62885d4 100644
@@ -30,6 +30,8 @@
 #include <linux/gpio.h>
 #include <linux/platform_device.h>
 #include <linux/input/matrix_keypad.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/ulpi.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>
@@ -40,6 +42,7 @@
 #include <mach/common.h>
 #include <mach/mx25.h>
 #include <mach/iomux-mx25.h>
+#include <mach/ulpi.h>
 
 #include "devices-imx25.h"
 
@@ -184,13 +187,24 @@ static const struct matrix_keymap_data mx25pdk_keymap_data __initdata = {
 	.keymap_size	= ARRAY_SIZE(mx25pdk_keymap),
 };
 
+static const struct mxc_usbh_platform_data usbh2_pdata __initconst = {
+	.portsc	= MXC_EHCI_MODE_SERIAL,
+	.flags	= MXC_EHCI_INTERNAL_PHY,
+};
+
+static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
+	.operating_mode = FSL_USB2_DR_DEVICE,
+	.phy_mode       = FSL_USB2_PHY_UTMI,
+};
+
 static void __init mx25pdk_init(void)
 {
 	mxc_iomux_v3_setup_multiple_pads(mx25pdk_pads,
 			ARRAY_SIZE(mx25pdk_pads));
 
 	imx25_add_imx_uart0(&uart_pdata);
-	imx25_add_mxc_ehci_hs(NULL);
+	imx25_add_fsl_usb2_udc(&otg_device_pdata);
+	imx25_add_mxc_ehci_hs(&usbh2_pdata);
 	imx25_add_mxc_nand(&mx25pdk_nand_board_info);
 	imx25_add_imxdi_rtc(NULL);
 	imx25_add_imx_fb(&mx25pdk_fb_pdata);
Signature · 1 line
1.6.0.4
#3 lore raw

PATCH 3/3 ARM: imx/mx25_3ds: Add USB support

Quoted 42 lines · Fabio Estevam
---
 arch/arm/mach-imx/Kconfig         |    3 +++
 arch/arm/mach-imx/mach-mx25_3ds.c |   16 +++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
arch/arm/mach-imx/Kconfig +3 -0
index fed3ee5..4a6c51a 100644
@@ -97,14 +97,17 @@ comment "MX25 platforms:"
 config MACH_MX25_3DS
 	bool "Support MX25PDK (3DS) Platform"
 	select SOC_IMX25
+	select IMX_HAVE_PLATFORM_FSL_USB2_UDC
 	select IMX_HAVE_PLATFORM_IMX2_WDT
 	select IMX_HAVE_PLATFORM_IMXDI_RTC
 	select IMX_HAVE_PLATFORM_IMX_FB
 	select IMX_HAVE_PLATFORM_IMX_KEYPAD
 	select IMX_HAVE_PLATFORM_IMX_UART
 	select IMX_HAVE_PLATFORM_MXC_EHCI
+	select IMX_HAVE_PLATFORM_MXC_EHCI
 	select IMX_HAVE_PLATFORM_MXC_NAND
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
+	select MXC_ULPI if USB_ULPI
 
 config MACH_EUKREA_CPUIMX25
 	bool "Support Eukrea CPUIMX25 Platform"
arch/arm/mach-imx/mach-mx25_3ds.c +2 -0
index 8b8e75b..62885d4 100644
@@ -30,6 +30,8 @@
 #include <linux/gpio.h>
 #include <linux/platform_device.h>
 #include <linux/input/matrix_keypad.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/ulpi.h>
 
 #include <mach/hardware.h>
 #include <asm/mach-types.h>

arch/arm/mach-imx/mach-mx25_3ds.c line 45

Quoted 4 lines
arch/arm/mach-imx/mach-mx25_3ds.c +1 -0
@@ -40,6 +42,7 @@
 #include <mach/common.h>
 #include <mach/mx25.h>
 #include <mach/iomux-mx25.h>
+#include <mach/ulpi.h>

Why do you need both ulpi.h included here? I don't see anything using it in your patch.

Quoted 29 lines
arch/arm/mach-imx/mach-mx25_3ds.c +12 -1
 #include "devices-imx25.h"
 
@@ -184,13 +187,24 @@ static const struct matrix_keymap_data mx25pdk_keymap_data __initdata = {
 	.keymap_size	= ARRAY_SIZE(mx25pdk_keymap),
 };
 
+static const struct mxc_usbh_platform_data usbh2_pdata __initconst = {
+	.portsc	= MXC_EHCI_MODE_SERIAL,
+	.flags	= MXC_EHCI_INTERNAL_PHY,
+};
+
+static const struct fsl_usb2_platform_data otg_device_pdata __initconst = {
+	.operating_mode = FSL_USB2_DR_DEVICE,
+	.phy_mode       = FSL_USB2_PHY_UTMI,
+};
+
 static void __init mx25pdk_init(void)
 {
 	mxc_iomux_v3_setup_multiple_pads(mx25pdk_pads,
 			ARRAY_SIZE(mx25pdk_pads));
 
 	imx25_add_imx_uart0(&uart_pdata);
-	imx25_add_mxc_ehci_hs(NULL);
+	imx25_add_fsl_usb2_udc(&otg_device_pdata);
+	imx25_add_mxc_ehci_hs(&usbh2_pdata);
 	imx25_add_mxc_nand(&mx25pdk_nand_board_info);
 	imx25_add_imxdi_rtc(NULL);
 	imx25_add_imx_fb(&mx25pdk_fb_pdata);
Signature · 2 lines
Regards,
Igor.
#4 lore raw

PATCH 1/3 ARM: mx3/mx35_3ds: Add USB OTG Host mode

In reply to Fabio Estevam

Hi Fabio,

Quoted 40 lines · Fabio Estevam
---
 arch/arm/mach-mx3/Kconfig         |    1 +
 arch/arm/mach-mx3/mach-mx35_3ds.c |   34 ++++++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)
arch/arm/mach-mx3/Kconfig +1 -0
index 9037c4e..f474e2e 100644
@@ -185,6 +185,7 @@ config MACH_MX35_3DS
 	select IMX_HAVE_PLATFORM_MXC_EHCI
 	select IMX_HAVE_PLATFORM_MXC_NAND
 	select IMX_HAVE_PLATFORM_SDHCI_ESDHC_IMX
+	select MXC_ULPI if USB_ULPI
 	help
 	  Include support for MX35PDK platform. This includes specific
 	  configurations for the board and its peripherals.
arch/arm/mach-mx3/mach-mx35_3ds.c +3 -0
index 8bd8992..3cb4f5c 100644
@@ -26,6 +26,8 @@
 #include <linux/platform_device.h>
 #include <linux/memory.h>
 #include <linux/gpio.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/ulpi.h>
 
 #include <linux/mtd/physmap.h>
 
@@ -39,6 +41,7 @@
 #include <mach/iomux-mx35.h>
 #include <mach/irqs.h>
 #include <mach/3ds_debugboard.h>
+#include <mach/ulpi.h>
 
 #include "devices-imx35.h"
 #include "devices.h"

arch/arm/mach-mx3/mach-mx35_3ds.c static const struct fsl_usb2_platform_data usb_otg_pdata __initconst = { · line 136

Quoted 9 lines
arch/arm/mach-mx3/mach-mx35_3ds.c +6 -0
@@ -125,12 +128,34 @@ static const struct fsl_usb2_platform_data usb_otg_pdata __initconst = {
 	.phy_mode	= FSL_USB2_PHY_UTMI_WIDE,
 };
 
+#if defined(CONFIG_USB_ULPI)
+static struct mxc_usbh_platform_data otg_pdata __initdata = {
+	.portsc	= MXC_EHCI_MODE_UTMI,
+	.flags	= MXC_EHCI_INTERNAL_PHY,
+};
+

I don't know much about mx3, but the above looks confusing. A typo?

Quoted 43 lines
arch/arm/mach-mx3/mach-mx35_3ds.c +23 -2
 /* USB HOST config */
 static const struct mxc_usbh_platform_data usb_host_pdata __initconst = {
 	.portsc		= MXC_EHCI_MODE_SERIAL,
 	.flags		= MXC_EHCI_INTERFACE_SINGLE_UNI |
 			  MXC_EHCI_INTERNAL_PHY,
 };
+#endif
+
+static int otg_mode_host;
+
+static int __init mx35_3ds_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=", mx35_3ds_otg_mode);
 
 /*
  * Board specific initialization.
@@ -144,10 +169,15 @@ static void __init mxc_board_init(void)
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 
 	imx35_add_imx_uart0(&uart_pdata);
-
-	imx35_add_fsl_usb2_udc(&usb_otg_pdata);
+
+#if defined(CONFIG_USB_ULPI)
+	if (otg_mode_host)
+		imx35_add_mxc_ehci_otg(&otg_pdata);
 
 	imx35_add_mxc_ehci_hs(&usb_host_pdata);
+#endif
+	if (!otg_mode_host)
+		imx35_add_fsl_usb2_udc(&usb_otg_pdata);
 
 	imx35_add_mxc_nand(&mx35pdk_nand_board_info);
 	imx35_add_sdhci_esdhc_imx(0, NULL);
Signature · 2 lines
Regards,
Igor.
reviewer
#5 lore raw

PATCH 1/3 ARM: mx3/mx35_3ds: Add USB OTG Host mode

Hi Igor,

On Wed, Dec 22, 2010 at 5:03 AM, Igor Grinberg <[email protected]> wrote:
...

Quoted 8 lines

arch/arm/mach-mx3/mach-mx35_3ds.c static const struct fsl_usb2_platform_data usb_otg_pdata __initconst = { · line 136

Quoted 6 lines
arch/arm/mach-mx3/mach-mx35_3ds.c +6 -0
+#if defined(CONFIG_USB_ULPI)
+static struct mxc_usbh_platform_data otg_pdata __initdata = {
+ ? ? .portsc = MXC_EHCI_MODE_UTMI,
+ ? ? .flags ?= MXC_EHCI_INTERNAL_PHY,
+};
+

I don't know much about mx3, but the above looks confusing. A typo?

You are right. It does not depend on ULPI. Will remove the ULPI dependencies.

Same applies for the other patch you commented.

Thanks,

Fabio Estevam