summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorNikita Kiryanov <nikita@compulab.co.il>2014-08-20 15:09:03 +0300
committerStefano Babic <sbabic@denx.de>2014-09-09 15:37:08 +0200
commit0f3effb99fdabf41e6152e5aec2e5fceee7616f9 (patch)
treef3c8ed7b1a77449ca9df0efbb917c9dfad1cd098 /board
parent02b1343e4a1430dc9ed750b95ed7cd961f06a456 (diff)
arm: mx6: cm_fx6: add usb support
Add USB and USB OTG host support for Compulab CM-FX6 CoM. Cc: Igor Grinberg <grinberg@compulab.co.il> Cc: Stefano Babic <sbabic@denx.de> Cc: Tom Rini <trini@ti.com> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Diffstat (limited to 'board')
-rw-r--r--board/compulab/cm_fx6/cm_fx6.c76
-rw-r--r--board/compulab/cm_fx6/common.h3
2 files changed, 79 insertions, 0 deletions
diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index 681b1eeb49f..26f04171eed 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -15,12 +15,88 @@
#include <fdt_support.h>
#include <asm/arch/crm_regs.h>
#include <asm/arch/sys_proto.h>
+#include <asm/arch/iomux.h>
#include <asm/io.h>
#include <asm/gpio.h>
#include "common.h"
DECLARE_GLOBAL_DATA_PTR;
+#ifdef CONFIG_USB_EHCI_MX6
+#define WEAK_PULLDOWN (PAD_CTL_PUS_100K_DOWN | \
+ PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
+ PAD_CTL_HYS | PAD_CTL_SRE_SLOW)
+
+static int cm_fx6_usb_hub_reset(void)
+{
+ int err;
+
+ err = gpio_request(CM_FX6_USB_HUB_RST, "usb hub rst");
+ if (err) {
+ printf("USB hub rst gpio request failed: %d\n", err);
+ return -1;
+ }
+
+ SETUP_IOMUX_PAD(PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL));
+ gpio_direction_output(CM_FX6_USB_HUB_RST, 0);
+ udelay(10);
+ gpio_direction_output(CM_FX6_USB_HUB_RST, 1);
+ mdelay(1);
+
+ return 0;
+}
+
+static int cm_fx6_init_usb_otg(void)
+{
+ int ret;
+ struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
+
+ ret = gpio_request(SB_FX6_USB_OTG_PWR, "usb-pwr");
+ if (ret) {
+ printf("USB OTG pwr gpio request failed: %d\n", ret);
+ return ret;
+ }
+
+ SETUP_IOMUX_PAD(PAD_EIM_D22__GPIO3_IO22 | MUX_PAD_CTRL(NO_PAD_CTRL));
+ SETUP_IOMUX_PAD(PAD_ENET_RX_ER__USB_OTG_ID |
+ MUX_PAD_CTRL(WEAK_PULLDOWN));
+ clrbits_le32(&iomux->gpr[1], IOMUXC_GPR1_OTG_ID_MASK);
+ /* disable ext. charger detect, or it'll affect signal quality at dp. */
+ return gpio_direction_output(SB_FX6_USB_OTG_PWR, 0);
+}
+
+#define MX6_USBNC_BASEADDR 0x2184800
+#define USBNC_USB_H1_PWR_POL (1 << 9)
+int board_ehci_hcd_init(int port)
+{
+ u32 *usbnc_usb_uh1_ctrl = (u32 *)(MX6_USBNC_BASEADDR + 4);
+
+ switch (port) {
+ case 0:
+ return cm_fx6_init_usb_otg();
+ case 1:
+ SETUP_IOMUX_PAD(PAD_GPIO_0__USB_H1_PWR |
+ MUX_PAD_CTRL(NO_PAD_CTRL));
+
+ /* Set PWR polarity to match power switch's enable polarity */
+ setbits_le32(usbnc_usb_uh1_ctrl, USBNC_USB_H1_PWR_POL);
+ return cm_fx6_usb_hub_reset();
+ default:
+ break;
+ }
+
+ return 0;
+}
+
+int board_ehci_power(int port, int on)
+{
+ if (port == 0)
+ return gpio_direction_output(SB_FX6_USB_OTG_PWR, on);
+
+ return 0;
+}
+#endif
+
#ifdef CONFIG_FEC_MXC
#define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
diff --git a/board/compulab/cm_fx6/common.h b/board/compulab/cm_fx6/common.h
index 1b19f16b2e2..f841c90c549 100644
--- a/board/compulab/cm_fx6/common.h
+++ b/board/compulab/cm_fx6/common.h
@@ -16,6 +16,9 @@
#define CM_FX6_ECSPI_BUS0_CS0 IMX_GPIO_NR(2, 30)
#define CM_FX6_GREEN_LED IMX_GPIO_NR(2, 31)
#define CM_FX6_ENET_NRST IMX_GPIO_NR(2, 8)
+#define CM_FX6_ENET_NRST IMX_GPIO_NR(2, 8)
+#define CM_FX6_USB_HUB_RST IMX_GPIO_NR(7, 8)
+#define SB_FX6_USB_OTG_PWR IMX_GPIO_NR(3, 22)
void cm_fx6_set_usdhc_iomux(void);
void cm_fx6_set_ecspi_iomux(void);