From: "Govindraj.R" <govindraj.r...@ti.com>

Add ehci_hcd_init and thus enable ehci support for panda board.
On panda board ehci port1 is connected to a smsc3220 hub,
and ethernet is connected to GPIO_1 and hub reset is through GPIO_62.
ethernt lan9500 chip is connted to hub.

Signed-off-by: Govindraj.R <govindraj.r...@ti.com>
---
 board/ti/panda/panda.c |   70 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/board/ti/panda/panda.c b/board/ti/panda/panda.c
index fc8c0b4..adf906e 100644
--- a/board/ti/panda/panda.c
+++ b/board/ti/panda/panda.c
@@ -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
  */
-- 
1.7.5.4

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to