Merge branch 'master' of git://git.denx.de/u-boot-video
[oweals/u-boot.git] / drivers / usb / host / ehci-omap.c
index 032d5e5ec25b327ce85fda684c1aac4563304c9b..c4ce4870875b14fbf0f9da97a680c1bcbe7617e7 100644 (file)
@@ -79,6 +79,7 @@ static void omap_usbhs_hsic_init(int port)
        writel(reg, &usbtll->channel_conf + port);
 }
 
+#ifdef CONFIG_USB_ULPI
 static void omap_ehci_soft_phy_reset(int port)
 {
        struct ulpi_viewport ulpi_vp;
@@ -88,15 +89,16 @@ static void omap_ehci_soft_phy_reset(int port)
 
        ulpi_reset(&ulpi_vp);
 }
-
-inline int __board_usb_init(void)
+#else
+static void omap_ehci_soft_phy_reset(int port)
 {
-       return 0;
+       return;
 }
-int board_usb_init(void) __attribute__((weak, alias("__board_usb_init")));
+#endif
 
 #if defined(CONFIG_OMAP_EHCI_PHY1_RESET_GPIO) || \
-       defined(CONFIG_OMAP_EHCI_PHY2_RESET_GPIO)
+       defined(CONFIG_OMAP_EHCI_PHY2_RESET_GPIO) || \
+       defined(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO)
 /* controls PHY(s) reset signal(s) */
 static inline void omap_ehci_phy_reset(int on, int delay)
 {
@@ -115,6 +117,10 @@ static inline void omap_ehci_phy_reset(int on, int delay)
        gpio_request(CONFIG_OMAP_EHCI_PHY2_RESET_GPIO, "USB PHY2 reset");
        gpio_direction_output(CONFIG_OMAP_EHCI_PHY2_RESET_GPIO, !on);
 #endif
+#ifdef CONFIG_OMAP_EHCI_PHY3_RESET_GPIO
+       gpio_request(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO, "USB PHY3 reset");
+       gpio_direction_output(CONFIG_OMAP_EHCI_PHY3_RESET_GPIO, !on);
+#endif
 
        /* Hold the PHY in RESET for enough time till DIR is high */
        /* Refer: ISSUE1 */
@@ -145,15 +151,15 @@ int omap_ehci_hcd_stop(void)
  * Based on "drivers/usb/host/ehci-omap.c" from Linux 3.1
  * See there for additional Copyrights.
  */
-int omap_ehci_hcd_init(struct omap_usbhs_board_data *usbhs_pdata,
-               struct ehci_hccr **hccr, struct ehci_hcor **hcor)
+int omap_ehci_hcd_init(int index, struct omap_usbhs_board_data *usbhs_pdata,
+                      struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
        int ret;
        unsigned int i, reg = 0, rev = 0;
 
        debug("Initializing OMAP EHCI\n");
 
-       ret = board_usb_init();
+       ret = board_usb_init(index, USB_INIT_HOST);
        if (ret < 0)
                return ret;
 
@@ -198,10 +204,27 @@ int omap_ehci_hcd_init(struct omap_usbhs_board_data *usbhs_pdata,
                else
                        setbits_le32(&reg, OMAP_UHH_HOSTCONFIG_ULPI_P3_BYPASS);
        } else if (rev == OMAP_USBHS_REV2) {
+
                clrsetbits_le32(&reg, (OMAP_P1_MODE_CLEAR | OMAP_P2_MODE_CLEAR),
                                        OMAP4_UHH_HOSTCONFIG_APP_START_CLK);
 
-               /* Clear port mode fields for PHY mode*/
+               /* Clear port mode fields for PHY mode */
+
+               if (is_ehci_hsic_mode(usbhs_pdata->port_mode[0]))
+                       setbits_le32(&reg, OMAP_P1_MODE_HSIC);
+
+               if (is_ehci_hsic_mode(usbhs_pdata->port_mode[1]))
+                       setbits_le32(&reg, OMAP_P2_MODE_HSIC);
+
+       } else if (rev == OMAP_USBHS_REV2_1) {
+
+               clrsetbits_le32(&reg,
+                               (OMAP_P1_MODE_CLEAR |
+                                OMAP_P2_MODE_CLEAR |
+                                OMAP_P3_MODE_CLEAR),
+                               OMAP4_UHH_HOSTCONFIG_APP_START_CLK);
+
+               /* Clear port mode fields for PHY mode */
 
                if (is_ehci_hsic_mode(usbhs_pdata->port_mode[0]))
                        setbits_le32(&reg, OMAP_P1_MODE_HSIC);