Merge git://git.denx.de/u-boot-sunxi
[oweals/u-boot.git] / drivers / usb / host / xhci-mvebu.c
index 23c241a7c79e3dd5f4e58b0478a78a0a2b02c9b0..d880af1113131b7ed96c8ecfb274fddea0751849 100644 (file)
@@ -10,6 +10,7 @@
 #include <dm.h>
 #include <fdtdec.h>
 #include <usb.h>
+#include <power/regulator.h>
 #include <asm/gpio.h>
 
 #include "xhci.h"
@@ -44,23 +45,28 @@ static int xhci_usb_probe(struct udevice *dev)
        struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
        struct mvebu_xhci *ctx = dev_get_priv(dev);
        struct xhci_hcor *hcor;
-       int len;
+       int len, ret;
+       struct udevice *regulator;
 
        ctx->hcd = (struct xhci_hccr *)plat->hcd_base;
        len = HC_LENGTH(xhci_readl(&ctx->hcd->cr_capbase));
        hcor = (struct xhci_hcor *)((uintptr_t)ctx->hcd + len);
 
+       ret = device_get_supply_regulator(dev, "vbus-supply", &regulator);
+       if (!ret) {
+               ret = regulator_set_enable(regulator, true);
+               if (ret) {
+                       printf("Failed to turn ON the VBUS regulator\n");
+                       return ret;
+               }
+       }
+
        /* Enable USB xHCI (VBUS, reset etc) in board specific code */
        board_xhci_enable();
 
        return xhci_register(dev, ctx->hcd, hcor);
 }
 
-static int xhci_usb_remove(struct udevice *dev)
-{
-       return xhci_deregister(dev);
-}
-
 static int xhci_usb_ofdata_to_platdata(struct udevice *dev)
 {
        struct mvebu_xhci_platdata *plat = dev_get_platdata(dev);
@@ -89,7 +95,7 @@ U_BOOT_DRIVER(usb_xhci) = {
        .of_match = xhci_usb_ids,
        .ofdata_to_platdata = xhci_usb_ofdata_to_platdata,
        .probe = xhci_usb_probe,
-       .remove = xhci_usb_remove,
+       .remove = xhci_deregister,
        .ops    = &xhci_usb_ops,
        .platdata_auto_alloc_size = sizeof(struct mvebu_xhci_platdata),
        .priv_auto_alloc_size = sizeof(struct mvebu_xhci),