aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDinh Nguyen <Dinh.Nguyen@freescale.com>2010-05-10 14:45:59 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2010-05-11 02:49:54 -0400
commit2ba5a2c0d8e0f62916a885170f28786141f08f76 (patch)
treee321c91bbb82a90aa39ebd026d62a7ada6cd36b3 /arch
parentc79504e73a0e84c4db7a2315dcdd6987b0c52566 (diff)
mx5: enable usb gadget for freescale mx51 babbage board
This patch enables usb gadget for freescale mx51 babbage hw. By default, the OTG port will be in device mode. To put the OTG port into Host mode, pass "otg_mode=host" in the exec command. This patch applies to 2.6.34-rc7. Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-mx5/board-mx51_babbage.c28
-rw-r--r--arch/arm/mach-mx5/clock-mx51.c2
-rw-r--r--arch/arm/mach-mx5/devices.c12
-rw-r--r--arch/arm/mach-mx5/devices.h1
4 files changed, 42 insertions, 1 deletions
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c
index 99f7ea903a51..dacf506f18ba 100644
--- a/arch/arm/mach-mx5/board-mx51_babbage.c
+++ b/arch/arm/mach-mx5/board-mx51_babbage.c
@@ -15,6 +15,7 @@
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <linux/fsl_devices.h>
18 19
19#include <mach/common.h> 20#include <mach/common.h>
20#include <mach/hardware.h> 21#include <mach/hardware.h>
@@ -179,12 +180,32 @@ static struct mxc_usbh_platform_data dr_utmi_config = {
179 .flags = MXC_EHCI_INTERNAL_PHY, 180 .flags = MXC_EHCI_INTERNAL_PHY,
180}; 181};
181 182
183static struct fsl_usb2_platform_data usb_pdata = {
184 .operating_mode = FSL_USB2_DR_DEVICE,
185 .phy_mode = FSL_USB2_PHY_UTMI_WIDE,
186};
187
182static struct mxc_usbh_platform_data usbh1_config = { 188static struct mxc_usbh_platform_data usbh1_config = {
183 .init = initialize_usbh1_port, 189 .init = initialize_usbh1_port,
184 .portsc = MXC_EHCI_MODE_ULPI, 190 .portsc = MXC_EHCI_MODE_ULPI,
185 .flags = (MXC_EHCI_POWER_PINS_ENABLED | MXC_EHCI_ITC_NO_THRESHOLD), 191 .flags = (MXC_EHCI_POWER_PINS_ENABLED | MXC_EHCI_ITC_NO_THRESHOLD),
186}; 192};
187 193
194static int otg_mode_host;
195
196static int __init babbage_otg_mode(char *options)
197{
198 if (!strcmp(options, "host"))
199 otg_mode_host = 1;
200 else if (!strcmp(options, "device"))
201 otg_mode_host = 0;
202 else
203 pr_info("otg_mode neither \"host\" nor \"device\". "
204 "Defaulting to device\n");
205 return 0;
206}
207__setup("otg_mode=", babbage_otg_mode);
208
188/* 209/*
189 * Board specific initialization. 210 * Board specific initialization.
190 */ 211 */
@@ -197,7 +218,12 @@ static void __init mxc_board_init(void)
197 mxc_init_imx_uart(); 218 mxc_init_imx_uart();
198 platform_add_devices(devices, ARRAY_SIZE(devices)); 219 platform_add_devices(devices, ARRAY_SIZE(devices));
199 220
200 mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config); 221 if (otg_mode_host)
222 mxc_register_device(&mxc_usbdr_host_device, &dr_utmi_config);
223 else {
224 initialize_otg_port(NULL);
225 mxc_register_device(&mxc_usbdr_udc_device, &usb_pdata);
226 }
201 227
202 gpio_usbh1_active(); 228 gpio_usbh1_active();
203 mxc_register_device(&mxc_usbh1_device, &usbh1_config); 229 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 566cfda6185e..9b93de36cf25 100644
--- a/arch/arm/mach-mx5/clock-mx51.c
+++ b/arch/arm/mach-mx5/clock-mx51.c
@@ -818,6 +818,8 @@ static struct clk_lookup lookups[] = {
818 _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", ahb_clk) 818 _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", ahb_clk)
819 _REGISTER_CLOCK("mxc-ehci.1", "usb", usboh3_clk) 819 _REGISTER_CLOCK("mxc-ehci.1", "usb", usboh3_clk)
820 _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", ahb_clk) 820 _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", ahb_clk)
821 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usboh3_clk)
822 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", ahb_clk)
821}; 823};
822 824
823static void clk_tree_init(void) 825static void clk_tree_init(void)
diff --git a/arch/arm/mach-mx5/devices.c b/arch/arm/mach-mx5/devices.c
index e6262f31ed8f..23850e637dc3 100644
--- a/arch/arm/mach-mx5/devices.c
+++ b/arch/arm/mach-mx5/devices.c
@@ -107,6 +107,18 @@ static struct resource usbotg_resources[] = {
107 }, 107 },
108}; 108};
109 109
110/* OTG gadget device */
111struct platform_device mxc_usbdr_udc_device = {
112 .name = "fsl-usb2-udc",
113 .id = -1,
114 .num_resources = ARRAY_SIZE(usbotg_resources),
115 .resource = usbotg_resources,
116 .dev = {
117 .dma_mask = &usb_dma_mask,
118 .coherent_dma_mask = DMA_BIT_MASK(32),
119 },
120};
121
110struct platform_device mxc_usbdr_host_device = { 122struct platform_device mxc_usbdr_host_device = {
111 .name = "mxc-ehci", 123 .name = "mxc-ehci",
112 .id = 0, 124 .id = 0,
diff --git a/arch/arm/mach-mx5/devices.h b/arch/arm/mach-mx5/devices.h
index 95c45f9e46ca..0494d6bbcc5f 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;
4extern struct platform_device mxc_fec_device; 4extern struct platform_device mxc_fec_device;
5extern struct platform_device mxc_usbdr_host_device; 5extern struct platform_device mxc_usbdr_host_device;
6extern struct platform_device mxc_usbh1_device; 6extern struct platform_device mxc_usbh1_device;
7extern struct platform_device mxc_usbdr_udc_device;