Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / arch / arm / mach-sunxi / usb_phy.c
index b258ce4443cb5eaa98fe0d5bbd385795cee60497..2f1cad1aad9e5dc14b4666bf02317a5fea7363aa 100644 (file)
 #include <asm/io.h>
 #include <errno.h>
 
-#define SUNXI_USB_PMU_IRQ_ENABLE       0x800
-#ifdef CONFIG_MACH_SUN8I_A33
-#define SUNXI_USB_CSR                  0x410
-#else
+#if defined(CONFIG_MACH_SUN4I) ||                 \
+       defined(CONFIG_MACH_SUN5I) ||              \
+       defined(CONFIG_MACH_SUN6I) ||              \
+       defined(CONFIG_MACH_SUN7I) ||              \
+       defined(CONFIG_MACH_SUN8I_A23) ||          \
+       defined(CONFIG_MACH_SUN9I)
 #define SUNXI_USB_CSR                  0x404
+#else
+#define SUNXI_USB_CSR                  0x410
 #endif
+
+#define SUNXI_USB_PMU_IRQ_ENABLE       0x800
 #define SUNXI_USB_PASSBY_EN            1
 
 #define SUNXI_EHCI_AHB_ICHR8_EN                (1 << 10)
@@ -85,6 +91,8 @@ static struct sunxi_usb_phy {
 #endif
 };
 
+static int initial_usb_scan_delay = CONFIG_INITIAL_USB_SCAN_DELAY;
+
 static int get_vbus_gpio(int index)
 {
        switch (index) {
@@ -144,12 +152,13 @@ __maybe_unused static void usb_phy_write(struct sunxi_usb_phy *phy, int addr,
        }
 }
 
-#if defined CONFIG_MACH_SUN8I_H3
+#if defined(CONFIG_MACH_SUNXI_H3_H5) || defined(CONFIG_MACH_SUN50I)
 static void sunxi_usb_phy_config(struct sunxi_usb_phy *phy)
 {
+#if defined CONFIG_MACH_SUNXI_H3_H5
        if (phy->id == 0)
                clrbits_le32(SUNXI_USBPHY_BASE + REG_PHY_UNK_H3, 0x01);
-
+#endif
        clrbits_le32(phy->base + REG_PMU_UNK_H3, 0x02);
 }
 #elif defined CONFIG_MACH_SUN8I_A83T
@@ -269,6 +278,11 @@ void sunxi_usb_phy_power_on(int index)
 {
        struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
 
+       if (initial_usb_scan_delay) {
+               mdelay(initial_usb_scan_delay);
+               initial_usb_scan_delay = 0;
+       }
+
        phy->power_on_count++;
        if (phy->power_on_count != 1)
                return;
@@ -289,13 +303,6 @@ void sunxi_usb_phy_power_off(int index)
                gpio_set_value(phy->gpio_vbus, 0);
 }
 
-int sunxi_usb_phy_power_is_on(int index)
-{
-       struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];
-
-       return phy->power_on_count > 0;
-}
-
 int sunxi_usb_phy_vbus_detect(int index)
 {
        struct sunxi_usb_phy *phy = &sunxi_usb_phy[index];