@@ -26,9 +26,15 @@
#include <asm/arch/mmc_host_def.h>
#include <asm/arch/clocks.h>
#include <asm/arch/gpio.h>
+#include <asm/gpio.h>
#include "panda_mux_data.h"
+#ifdef CONFIG_USB_EHCI
+#include <usb.h>
+#include <asm/ehci-omap.h>
+#endif
+
#define PANDA_ULPI_PHY_TYPE_GPIO 182
DECLARE_GLOBAL_DATA_PTR;
@@ -177,6 +183,70 @@ int board_mmc_init(bd_t *bis)
}
#endif
+#ifdef CONFIG_USB_EHCI
+
+#define GPIO_ETH_POWER 1
+#define GPIO_HUB_NRESET 62
+
+static struct omap_usbhs_board_data usbhs_bdata = {
+ .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
+ .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
+ .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED
+};
+
+int ehci_hcd_init(void)
+{
+ int rc;
+ unsigned int utmi_clk;
+
+ /* disable the power to the usb hub prior to init */
+ rc = gpio_request(GPIO_ETH_POWER, "");
+ if (rc < 0) {
+ printf("Could not request gpio %d\n", GPIO_ETH_POWER);
+ return rc;
+ }
+
+ rc = gpio_request(GPIO_HUB_NRESET, "");
+ if (rc < 0) {
+ printf("Could not request gpio %d\n", GPIO_HUB_NRESET);
+ gpio_free(GPIO_ETH_POWER);
+ return rc;
+ }
+
+ gpio_direction_output(GPIO_ETH_POWER, 0);
+ gpio_set_value(GPIO_ETH_POWER, 0);
+ gpio_direction_output(GPIO_HUB_NRESET, 0);
+ gpio_set_value(GPIO_HUB_NRESET, 0);
+ gpio_set_value(GPIO_HUB_NRESET, 1);
+
+ /* Now we can enable our port clocks after HUB reset */
+ utmi_clk = readl((void *)CM_L3INIT_HSUSBHOST_CLKCTRL);
+ utmi_clk |= HSUSBHOST_CLKCTRL_CLKSEL_UTMI_P1_MASK;
+ sr32((void *)CM_L3INIT_HSUSBHOST_CLKCTRL, 0, 32, utmi_clk);
+
+ rc = omap_ehci_hcd_init(&usbhs_bdata);
+ if (rc < 0)
+ return rc;
+
+ gpio_set_value(GPIO_ETH_POWER, 1);
+ return 0;
+}
+
+int ehci_hcd_stop(void)
+{
+ int ret;
+
+ ret = omap_ehci_hcd_stop();
+
+ gpio_set_value(GPIO_ETH_POWER, 0);
+ gpio_set_value(GPIO_HUB_NRESET, 0);
+ gpio_free(GPIO_ETH_POWER);
+ gpio_free(GPIO_HUB_NRESET);
+
+ return ret;
+}
+#endif
+
/*
* get_board_rev() - get board revision
*/