From: Dinh Nguyen <Dinh.Nguyen@freescale.com>
This patch is part of enabling USB for Freescale MX51 Babbage HW. This
patch updates the iomux pins for USB, and gpio line for reset the
USB hub on the MX51 Babbage HW.
This patch applies to 2.6.34-rc4.
Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
---
arch/arm/plat-mxc/ehci.c | 4 +++
arch/arm/plat-mxc/include/mach/iomux-mx51.h | 33 ++++++++++++++++----------
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/arch/arm/plat-mxc/ehci.c b/arch/arm/plat-mxc/ehci.c
index cb0b638..20eaddc 100644
--- a/arch/arm/plat-mxc/ehci.c
+++ b/arch/arm/plat-mxc/ehci.c
@@ -186,6 +186,10 @@ int mxc_set_usbcontrol(int port, unsigned int flags)
return 0;
}
#endif /* CONFIG_MACH_MX27 */
+#ifdef CONFIG_ARCH_MX5
+ /* Nothing needs to be done for MX5 here */
+ return 0;
+#endif
printk(KERN_WARNING
"%s() unable to setup USBCONTROL for this CPU\n", __func__);
return -EINVAL;
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx51.h b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
index b4f975e..99de3b3 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx51.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx51.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009-2010 Amit Kucheria <amit.kucheria@canonical.com>
+ * Copyright (C) 2010 Freescale Semiconductor, Inc. All Rights Reserved.
*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
@@ -37,6 +38,11 @@ typedef enum iomux_config {
PAD_CTL_SRE_FAST)
#define MX51_UART3_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_DSE_HIGH | \
PAD_CTL_SRE_FAST)
+#define MX51_USBH1_PAD_CTRL (PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | \
+ PAD_CTL_PUS_100K_UP | PAD_CTL_PUE | \
+ PAD_CTL_PKE | PAD_CTL_HYS)
+#define MX51_GPIO_PAD_CTRL ( PAD_CTL_DSE_HIGH | PAD_CTL_PKE | \
+ PAD_CTL_SRE_FAST)
/*
* The naming convention for the pad modes is MX51_PAD_<padname>__<padmode>
@@ ...From: Dinh Nguyen <Dinh.Nguyen@freescale.com> This patch is part of enabling USB for Freescale MX51 Babbage HW. This patch performs some platform specific USB HW initialization, and adds the necessary defines. This patch applies to 2.6.34-rc4. Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com> --- arch/arm/plat-mxc/Makefile | 2 +- arch/arm/plat-mxc/include/mach/mxc_ehci.h | 48 +++++++ arch/arm/plat-mxc/usb_common.c | 190 +++++++++++++++++++++++++++++ 3 files changed, 239 insertions(+), 1 deletions(-) create mode 100644 arch/arm/plat-mxc/usb_common.c diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile index 895bc3c..fa8ed78 100644 --- a/arch/arm/plat-mxc/Makefile +++ b/arch/arm/plat-mxc/Makefile @@ -3,7 +3,7 @@ # # Common support -obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o system.o +obj-y := irq.o clock.o gpio.o time.o devices.o cpu.o system.o usb_common.o # MX51 uses the TZIC interrupt controller, older platforms use AVIC (irq.o) obj-$(CONFIG_MXC_TZIC) += tzic.o diff --git a/arch/arm/plat-mxc/include/mach/mxc_ehci.h b/arch/arm/plat-mxc/include/mach/mxc_ehci.h index 4b9b836..6edf8d7 100644 --- a/arch/arm/plat-mxc/include/mach/mxc_ehci.h +++ b/arch/arm/plat-mxc/include/mach/mxc_ehci.h @@ -1,6 +1,30 @@ #ifndef __INCLUDE_ASM_ARCH_MXC_EHCI_H #define __INCLUDE_ASM_ARCH_MXC_EHCI_H +#define USBOTG_OFFSET 0 +#define USBH1_OFFSET 0x200 +#define USBH2_OFFSET 0x400 +#define USBH3_OFFSET 0x600 +#define USBOTHER_REGS_OFFSET 0x800 + +#define USBCMD_OFFSET 0x140 + +#define ULPI_VIEWPORT_OFFSET 0x170 +#define PORTSC_OFFSET 0x184 +#define USBMODE_OFFSET 0x1a8 +#define USBMODE_CM_HOST 3 + +#define USBCTRL_OFFSET 0 +#define USB_PHY_CTR_FUNC_OFFSET 0x8 +#define USB_PHY_CTR_FUNC2_OFFSET 0xc +#define USB_CTRL_1_OFFSET 0x10 + + +/* USBCMD */ +#define UCMD_RUN_STOP (1 << 0) /* controller run/stop */ +#define UCMD_RESET (1 << 1) /* controller reset ...
There are several general problems with this. The functions you implement here are not at all common but purely specific to mx51, so the name of the file and functions as well as the location in the tree is plainly wrong. Also, this code also completely ignores all the work that has been done You shouldn't mix declarations and code like this. The compiler should This isn't good. If the above condition will never become true, the kernel hangs in an endless loop. There should be a timeout and a call to These are all settings specific to the actual board implementation, and these cases are exactly what the abstract layer was invented for. In general, the code above should be made a lot more versatile and also be put in plat-mxc/ehci.c. Look at the implementations of mx2 and mx3 The second half of the file is just a copy of the first, and it is just there because things are not abstracted but hard-coded. --
This needs a cpu_is_mx5() condition. For now that's just nit-picking, but once another platform is added, the statement will return where it shouldn't. Daniel --
The naming convention is MX51_PAD_<padname>__<function> with padname being the name in the datasheet, so this pad should be named MX51_PAD_USBH1_CLK__USBH1_CLK, or if used as gpio MX51_PAD_USBH1_CLK__GPIO_1_25. This is not your fault, it was wrong before and I haven't recognized it. We should fix this before these definitions actually get used. Sascha -- 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 | --
