summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorMarek Vasut <marek.vasut+renesas@gmail.com>2019-08-22 17:53:04 +0200
committerMarek Vasut <marex@denx.de>2019-08-22 18:23:36 +0200
commit769a9cd4bbd7ae9b8170b3dd6ba54b84fde59224 (patch)
treee45209f18c5392a07d30d2892e1e5d2aba95cb37 /drivers/usb
parent8b5483015496100b3f5a790a58cc3019815654e0 (diff)
downloadu-boot-769a9cd4bbd7ae9b8170b3dd6ba54b84fde59224.tar.gz
usb: r8a66597: Add optional DM VBUS regulator support
Add DM regulator support for toggling VBUS, this is useful on boards which control the VBUS e.g. through GPIO. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Chris Brandt <chris.brandt@renesas.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/host/r8a66597-hcd.c29
-rw-r--r--drivers/usb/host/r8a66597.h1
2 files changed, 30 insertions, 0 deletions
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index 8b60ab2c6d..a37696d83f 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -11,6 +11,7 @@
#include <usb.h>
#include <asm/io.h>
#include <linux/iopoll.h>
+#include <power/regulator.h>
#include "r8a66597.h"
@@ -818,9 +819,27 @@ static int r8a66597_usb_probe(struct udevice *dev)
{
struct r8a66597 *priv = dev_get_priv(dev);
struct usb_bus_priv *bus_priv = dev_get_uclass_priv(dev);
+ int ret;
bus_priv->desc_before_addr = true;
+ if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+ ret = device_get_supply_regulator(dev, "vbus-supply",
+ &priv->vbus_supply);
+ if (ret) {
+ dev_err(dev,
+ "can't get VBUS supply\n");
+ return ret;
+ }
+
+ ret = regulator_set_enable(priv->vbus_supply, true);
+ if (ret) {
+ dev_err(dev,
+ "can't enable VBUS supply\n");
+ return ret;
+ }
+ }
+
disable_controller(priv);
mdelay(100);
@@ -838,9 +857,19 @@ static int r8a66597_usb_probe(struct udevice *dev)
static int r8a66597_usb_remove(struct udevice *dev)
{
struct r8a66597 *priv = dev_get_priv(dev);
+ int ret;
disable_controller(priv);
+ if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+ ret = regulator_set_enable(priv->vbus_supply, false);
+ if (ret) {
+ dev_err(dev,
+ "can't disable VBUS supply\n");
+ return ret;
+ }
+ }
+
return 0;
}
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
index 3077bc7999..b6110d6b3f 100644
--- a/drivers/usb/host/r8a66597.h
+++ b/drivers/usb/host/r8a66597.h
@@ -396,6 +396,7 @@ struct r8a66597 {
unsigned short port_change;
u16 speed; /* HSMODE or FSMODE or LSMODE */
unsigned char rh_devnum;
+ struct udevice *vbus_supply;
};
static inline u16 r8a66597_read(struct r8a66597 *r8a66597, unsigned long offset)