Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / drivers / usb / host / xhci-rockchip.c
index da21bc7ae84a0fcd964ec4ede445c39f8f11ebb7..b1f98842739735e08e086dae2d0f70752a0e7ba1 100644 (file)
@@ -6,8 +6,6 @@
  */
 #include <common.h>
 #include <dm.h>
-#include <fdtdec.h>
-#include <libfdt.h>
 #include <malloc.h>
 #include <usb.h>
 #include <watchdog.h>
@@ -46,9 +44,9 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
        /*
         * Get the base address for XHCI controller from the device node
         */
-       plat->hcd_base = devfdt_get_addr(dev);
+       plat->hcd_base = dev_read_addr(dev);
        if (plat->hcd_base == FDT_ADDR_T_NONE) {
-               debug("Can't get the XHCI register base address\n");
+               pr_err("Can't get the XHCI register base address\n");
                return -ENXIO;
        }
 
@@ -62,17 +60,15 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
        }
 
        if (plat->phy_base == FDT_ADDR_T_NONE) {
-               debug("Can't get the usbphy register address\n");
+               pr_err("Can't get the usbphy register address\n");
                return -ENXIO;
        }
 
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR)
        /* Vbus regulator */
        ret = device_get_supply_regulator(dev, "vbus-supply",
                                          &plat->vbus_supply);
        if (ret)
-               debug("Can't get vbus supply\n");
-#endif
+               debug("Can't get VBus regulator!\n");
 
        return 0;
 }
@@ -121,7 +117,7 @@ static int rockchip_xhci_core_init(struct rockchip_xhci *rkxhci,
 
        ret = dwc3_core_init(rkxhci->dwc3_reg);
        if (ret) {
-               debug("failed to initialize core\n");
+               pr_err("failed to initialize core\n");
                return ret;
        }
 
@@ -150,15 +146,17 @@ static int xhci_usb_probe(struct udevice *dev)
        hcor = (struct xhci_hcor *)((uint64_t)ctx->hcd +
                        HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase)));
 
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR)
-       ret = regulator_set_enable(plat->vbus_supply, true);
-       if (ret)
-               debug("XHCI: Failed to enable vbus supply\n");
-#endif
+       if (plat->vbus_supply) {
+               ret = regulator_set_enable(plat->vbus_supply, true);
+               if (ret) {
+                       pr_err("XHCI: failed to set VBus supply\n");
+                       return ret;
+               }
+       }
 
        ret = rockchip_xhci_core_init(ctx, dev);
        if (ret) {
-               debug("XHCI: failed to initialize controller\n");
+               pr_err("XHCI: failed to initialize controller\n");
                return ret;
        }
 
@@ -178,13 +176,13 @@ static int xhci_usb_remove(struct udevice *dev)
        if (ret)
                return ret;
 
-#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR)
-       ret = regulator_set_enable(plat->vbus_supply, false);
-       if (ret)
-               debug("XHCI: Failed to disable vbus supply\n");
-#endif
+       if (plat->vbus_supply) {
+               ret = regulator_set_enable(plat->vbus_supply, false);
+               if (ret)
+                       pr_err("XHCI: failed to set VBus supply\n");
+       }
 
-       return 0;
+       return ret;
 }
 
 static const struct udevice_id xhci_usb_ids[] = {