X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=drivers%2Fusb%2Fhost%2Fehci-mx6.c;h=55ac162a3c04c09dbf15a6e54770af459d5b1921;hb=81192b79661cf2763abecbf3c3b673142ef4a2cd;hp=18b7fc3c9520bb662667eef6e35e495327b179cd;hpb=cccbddc38c431a0afd7fd0b3e1d48e5326610084;p=u-boot diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 18b7fc3c95..55ac162a3c 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "ehci.h" @@ -388,6 +389,7 @@ int ehci_hcd_stop(int index) struct ehci_mx6_priv_data { struct ehci_ctrl ctrl; struct usb_ehci *ehci; + struct udevice *vbus_supply; enum usb_init_type init_type; int portnr; }; @@ -403,7 +405,15 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) if (ret) return ret; - board_ehci_power(priv->portnr, (type == USB_INIT_DEVICE) ? 0 : 1); + if (priv->vbus_supply) { + ret = regulator_set_enable(priv->vbus_supply, + (type == USB_INIT_DEVICE) ? + false : true); + if (ret) { + puts("Error enabling VBUS supply\n"); + return ret; + } + } if (type == USB_INIT_DEVICE) return 0; @@ -427,7 +437,7 @@ static int ehci_usb_phy_mode(struct udevice *dev) void *__iomem addr = (void *__iomem)dev_get_addr(dev); void *__iomem phy_ctrl, *__iomem phy_status; const void *blob = gd->fdt_blob; - int offset = dev->of_offset, phy_off; + int offset = dev_of_offset(dev), phy_off; u32 val; /* @@ -474,7 +484,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev) struct usb_platdata *plat = dev_get_platdata(dev); const char *mode; - mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "dr_mode", NULL); + mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "dr_mode", NULL); if (mode) { if (strcmp(mode, "peripheral") == 0) plat->init_type = USB_INIT_DEVICE; @@ -496,19 +506,33 @@ static int ehci_usb_probe(struct udevice *dev) struct usb_platdata *plat = dev_get_platdata(dev); struct usb_ehci *ehci = (struct usb_ehci *)dev_get_addr(dev); struct ehci_mx6_priv_data *priv = dev_get_priv(dev); + enum usb_init_type type = plat->init_type; struct ehci_hccr *hccr; struct ehci_hcor *hcor; int ret; priv->ehci = ehci; priv->portnr = dev->seq; - priv->init_type = plat->init_type; + priv->init_type = type; + + ret = device_get_supply_regulator(dev, "vbus-supply", + &priv->vbus_supply); + if (ret) + debug("%s: No vbus supply\n", dev->name); ret = ehci_mx6_common_init(ehci, priv->portnr); if (ret) return ret; - board_ehci_power(priv->portnr, (priv->init_type == USB_INIT_DEVICE) ? 0 : 1); + if (priv->vbus_supply) { + ret = regulator_set_enable(priv->vbus_supply, + (type == USB_INIT_DEVICE) ? + false : true); + if (ret) { + puts("Error enabling VBUS supply\n"); + return ret; + } + } if (priv->init_type == USB_INIT_HOST) { setbits_le32(&ehci->usbmode, CM_HOST);