linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Dinh.Nguyen@freescale.com (Dinh Nguyen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv1 2.6.34-rc6 3/3] mx5: enable usb gadget for freescale mx51 babbage board
Date: Wed,  5 May 2010 17:56:11 -0500	[thread overview]
Message-ID: <1273100171-3235-4-git-send-email-Dinh.Nguyen@freescale.com> (raw)
In-Reply-To: <1273100171-3235-3-git-send-email-Dinh.Nguyen@freescale.com>

This patch enables usb gadget for freescale mx51 babbage hw. It adds
a kconfig condition for enabling either host or gadget on the OTG
port.

Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
 arch/arm/mach-mx5/board-mx51_babbage.c |   11 +++++++++++
 arch/arm/mach-mx5/clock-mx51.c         |    2 ++
 arch/arm/mach-mx5/devices.c            |   12 ++++++++++++
 arch/arm/mach-mx5/devices.h            |    1 +
 drivers/usb/host/Kconfig               |    8 ++++++++
 5 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 99f7ea9..fac8ce0 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -15,6 +15,7 @@
 #include <linux/gpio.h>
 #include <linux/delay.h>
 #include <linux/io.h>
+#include <linux/fsl_devices.h>
 
 #include <mach/common.h>
 #include <mach/hardware.h>
@@ -179,6 +180,11 @@ static struct mxc_usbh_platform_data dr_utmi_config = {
 	.flags	= MXC_EHCI_INTERNAL_PHY,
 };
 
+static struct fsl_usb2_platform_data usb_pdata = {
+	.operating_mode	= FSL_USB2_DR_DEVICE,
+	.phy_mode	= FSL_USB2_PHY_UTMI_WIDE,
+};
+
 static struct mxc_usbh_platform_data usbh1_config = {
 	.init		= initialize_usbh1_port,
 	.portsc	= MXC_EHCI_MODE_ULPI,
@@ -197,7 +203,12 @@ static void __init mxc_board_init(void)
 	mxc_init_imx_uart();
 	platform_add_devices(devices, ARRAY_SIZE(devices));
 
+#if defined(CONFIG_USB_EHCI_MXC_OTG)
 	mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);
+#elif defined(CONFIG_USB_GADGET_FSL_USB2)
+	initialize_otg_port(NULL);
+	mxc_register_device(&mxc_usbdr_udc_device, &usb_pdata);
+#endif
 
 	gpio_usbh1_active();
 	mxc_register_device(&mxc_usbh1_device, &usbh1_config);
diff --git a/arch/arm/mach-mx5/clock-mx51.c b/arch/arm/mach-mx5/clock-mx51.c
index 933c0d1..ff15424 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -786,6 +786,8 @@ static struct clk_lookup lookups[] = {
 	_REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", ahb_clk)
 	_REGISTER_CLOCK("mxc-ehci.1", "usb", usboh3_clk)
 	_REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", ahb_clk)
+	_REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
+	_REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
 };
 
 static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices.c b/arch/arm/mach-mx5/devices.c
index e6262f3..23850e6 100644
--- a/arch/arm/mach-mx5/devices.c
+++ b/arch/arm/mach-mx5/devices.c
@@ -107,6 +107,18 @@ static struct resource usbotg_resources[] = {
 	},
 };
 
+/* OTG gadget device */
+struct platform_device mxc_usbdr_udc_device = {
+	.name		= "fsl-usb2-udc",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(usbotg_resources),
+	.resource	= usbotg_resources,
+	.dev		= {
+		.dma_mask		= &usb_dma_mask,
+		.coherent_dma_mask	= DMA_BIT_MASK(32),
+	},
+};
+
 struct platform_device mxc_usbdr_host_device = {
 	.name = "mxc-ehci",
 	.id = 0,
diff --git a/arch/arm/mach-mx5/devices.h b/arch/arm/mach-mx5/devices.h
index 95c45f9..0494d6b 100644
--- a/arch/arm/mach-mx5/devices.h
+++ b/arch/arm/mach-mx5/devices.h
@@ -4,3 +4,4 @@ extern struct platform_device mxc_uart_device2;
 extern struct platform_device mxc_fec_device;
 extern struct platform_device mxc_usbdr_host_device;
 extern struct platform_device mxc_usbh1_device;
+extern struct platform_device mxc_usbdr_udc_device;
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 8d3df03..da58a2e 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -123,6 +123,14 @@ config USB_EHCI_MXC
 	---help---
 	  Variation of ARC USB block used in some Freescale chips.
 
+config USB_EHCI_MXC_OTG
+	bool "Support for DR host port on Freescale controller"
+	depends on USB_EHCI_MXC	&& (ARCH_MX51)
+	---help---
+	  Enable support for the USB OTG port in HS/FS Host mode.
+	  NOTE: Unless the OTG feature is enabled, EHCI and Gadget feature
+	  for the OTG port should be mutually exclusive.
+
 config USB_EHCI_HCD_PPC_OF
 	bool "EHCI support for PPC USB controller on OF platform bus"
 	depends on USB_EHCI_HCD && PPC_OF
-- 
1.6.0.4

  reply	other threads:[~2010-05-05 22:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-05 22:56 PATCHv1 2.6.34-rc6 0/3-Enable usb gadget on freescale mx51 babbage hw Dinh Nguyen
2010-05-05 22:56 ` [PATCHv1 2.6.34-rc6 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core Dinh Nguyen
2010-05-05 22:56   ` [PATCHv1 2.6.34-rc6 2/3] mx5: change usb clock source from pll3 to pll2 Dinh Nguyen
2010-05-05 22:56     ` Dinh Nguyen [this message]
2010-05-06  7:27       ` [PATCHv1 2.6.34-rc6 3/3] mx5: enable usb gadget for freescale mx51 babbage board Sascha Hauer
2010-05-06  7:14     ` [PATCHv1 2.6.34-rc6 2/3] mx5: change usb clock source from pll3 to pll2 Sascha Hauer
2010-05-06 18:33   ` [PATCHv1 2.6.34-rc6 1/3] mxc: gadget: remove 60mhz clock requirement for freescale mx51 usb core Fabio Estevam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1273100171-3235-4-git-send-email-Dinh.Nguyen@freescale.com \
    --to=dinh.nguyen@freescale.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).