[U-Boot] [PATCH RFC] OMAP5: uEVM: Enable USB EHCI functionality (preliminary, not tested)

Lubomir Popov
2013-05-15T15:55:24Z

Prerequisites: appropriate patches to the USB EHCI and Eth
drivers, and to the OMAP5 clock register definitions.

Signed-off-by: Lubomir Popov <lpopov@mm-sol.com>
---
Assumption is that this code shall run on TI 750-2628-21X
hardware (also known as OMAP5432 ES2.0 PandaBoard5) - the
GPIOs that I used used for HSIC reset correspond to that
board. Looking at mux_data.h however, I'm somewhat concerned.
All the uevm board files are inherited from the sEVM, which
is a very different hardware platform, and I'm afraid that
only changing the file names might not be sufficient.

The patch is not tested yet due to lack of hardware. Tom,
I'm hoping for your assistance.

board/ti/omap5_uevm/evm.c | 59 +++++++++++++++++++++++++++++++++++++++++-
include/configs/omap5_uevm.h | 34 +++++++++++++++++++++++-
2 files changed, 91 insertions(+), 2 deletions(-)

diff --git a/board/ti/omap5_uevm/evm.c b/board/ti/omap5_uevm/evm.c
index 46db1bf..3144fba 100644
--- a/board/ti/omap5_uevm/evm.c
+++ b/board/ti/omap5_uevm/evm.c
@@ -26,13 +26,20 @@
#include <palmas.h>
#include <asm/arch/sys_proto.h>
#include <asm/arch/mmc_host_def.h>
+#include <asm/omap_common.h>

#include "mux_data.h"

+#ifdef CONFIG_USB_EHCI
+#include <usb.h>
+#include <asm/arch/ehci.h>
+#include <asm/ehci-omap.h>
+#endif
+
DECLARE_GLOBAL_DATA_PTR;

const struct omap_sysinfo sysinfo = {
- "Board: OMAP5430 EVM\n"
+ "Board: OMAP5432 uEVM\n"
};

/**
@@ -99,3 +106,53 @@ int board_mmc_init(bd_t *bis)
return 0;
}
#endif
+
+#ifdef CONFIG_USB_EHCI
+static struct omap_usbhs_board_data usbhs_bdata = {
+ .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
+ .port_mode[1] = OMAP_EHCI_PORT_MODE_HSIC, /* USB3503 hub */
+ .port_mode[2] = OMAP_EHCI_PORT_MODE_HSIC, /* LAN9730 Ethernet */
+};
+
+int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor)
+{
+ int ret;
+
+ /* Enbale USB ports 2 & 3 UHH, UTMI and HSIC clocks */
+ setbits_le32((*prcm)->cm_l3init_hsusbhost_clkctrl,
+ USB_HOST_HS_CLKCTRL_EN);
+ /* Enbale USB host ports TLL clocks */
+ setbits_le32((*prcm)->cm_l3init_hsusbtll_clkctrl,
+ USB_TLL_HS_CLKCTRL_EN);
+
+ /*
+ * The hub uses OMAP FREF_CLK1_OUT at 19.2 MHz. Use default source
+ * (SYS_CLK) and default divider of 1, so just turn it on.
+ */
+ setbits_le32((*prcm)->scrm_auxclk1, AUXCLK_ENABLE_MASK);
+ udelay(1000); /* Let PLL lock */
+
+ ret = omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
+int ehci_hcd_stop(void)
+{
+ int ret;
+
+ ret = omap_ehci_hcd_stop();
+
+ clrbits_le32((*prcm)->cm_l3init_hsusbhost_clkctrl,
+ USB_HOST_HS_CLKCTRL_EN);
+ clrbits_le32((*prcm)->cm_l3init_hsusbtll_clkctrl,
+ USB_TLL_HS_CLKCTRL_EN);
+
+ /* Stop FREF_CLK1_OUT */
+ clrbits_le32((*prcm)->scrm_auxclk1, AUXCLK_ENABLE_MASK);
+ return ret;
+}
+#endif /* CONFIG_USB_EHCI */
+
diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h
index c791789..e15dd99 100644
--- a/include/configs/omap5_uevm.h
+++ b/include/configs/omap5_uevm.h
@@ -52,7 +52,39 @@
#define CONFIG_PARTITION_UUIDS
#define CONFIG_CMD_PART

-#define CONFIG_SYS_PROMPT "OMAP5430 EVM # "
+/* USB UHH support options */
+#define CONFIG_CMD_USB
+#define CONFIG_USB_HOST
+#define CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_OMAP
+#define CONFIG_USB_STORAGE
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3
+
+/*
+ * Due to OMAP5 HSIC connect ussues, device reset is required
+ * upon applying port power. A GPIO is needed per HSIC device:
+ */
+#define CONFIG_OMAP_HSIC_PORT2_RESET_GPIO 80 /* USB 3-port hub */
+#define CONFIG_OMAP_HSIC_PORT3_RESET_GPIO 79 /* Ethernet Ctrlr */
+
+/*
+ * Enable bit fields for USB ports 2 & 3 HS clocks setup in regs
+ * cm_l3init_hsusbhost_clkctrl and cm_l3init_hsusbtll_clkctrl:
+ */
+#define USB_HOST_HS_CLKCTRL_EN 0x0000d6c0
+#define USB_TLL_HS_CLKCTRL_EN 0x00000600
+
+/* USB Networking options */
+#define CONFIG_USB_HOST_ETHER
+#define CONFIG_USB_ETHER_SMSC95XX
+
+/* Enabled commands */
+#define CONFIG_CMD_NET /* bootp, tftpboot, rarpboot */
+#define CONFIG_CMD_NFS /* NFS support */
+#define CONFIG_CMD_DHCP /* DHCP support */
+#define CONFIG_CMD_PING /* PING support */
+
+#define CONFIG_SYS_PROMPT "OMAP5432 uEVM # "

#define CONFIG_OMAP_PLATFORM_RESET_TIME_MAX_USEC 16296
#endif /* __CONFIG_OMAP5_EVM_H */
--
1.7.9.5