diff options
author | Ley Foon Tan <ley.foon.tan@intel.com> | 2018-08-29 00:08:48 +0800 |
---|---|---|
committer | Marek Vasut <marex@denx.de> | 2018-08-29 03:10:30 +0200 |
commit | 88c34b8da62cfb4188ff9a59acb32f88ce9ed1b0 (patch) | |
tree | 8ae0c22adb4132c5e179b5d0e7677e769a7986dc /drivers | |
parent | 1335e7745f77f122cf4196b8da2aa2fc5edad475 (diff) | |
download | u-boot-88c34b8da62cfb4188ff9a59acb32f88ce9ed1b0.tar.gz u-boot-88c34b8da62cfb4188ff9a59acb32f88ce9ed1b0.tar.xz u-boot-88c34b8da62cfb4188ff9a59acb32f88ce9ed1b0.zip |
usb: dwc2: Add reset ctrl to driver
Add code to reset all reset signals as in usb DT node. A reset property
is an optional feature, so only print out a warning and do not fail if a
reset property is not present.
If a reset property is discovered, then use it to deassert, thus
bringing the IP out of reset.
Signed-off-by: Ley Foon Tan <ley.foon.tan@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/host/dwc2.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index cbe065bbaf..b6f008a400 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -15,6 +15,7 @@ #include <wait_bit.h> #include <asm/io.h> #include <power/regulator.h> +#include <reset.h> #include "dwc2.h" @@ -49,6 +50,8 @@ struct dwc2_priv { */ bool hnp_srp_disable; bool oc_disable; + + struct reset_ctl_bulk resets; }; #ifndef CONFIG_DM_USB @@ -1124,11 +1127,43 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, } } +static int dwc2_reset(struct udevice *dev) +{ + int ret; + struct dwc2_priv *priv = dev_get_priv(dev); + + ret = reset_get_bulk(dev, &priv->resets); + if (ret) { + dev_warn(dev, "Can't get reset: %d\n", ret); + /* Return 0 if error due to !CONFIG_DM_RESET and reset + * DT property is not present. + */ + if (ret == -ENOENT || ret == -ENOTSUPP) + return 0; + else + return ret; + } + + ret = reset_deassert_bulk(&priv->resets); + if (ret) { + reset_release_bulk(&priv->resets); + dev_err(dev, "Failed to reset: %d\n", ret); + return ret; + } + + return 0; +} + static int dwc2_init_common(struct udevice *dev, struct dwc2_priv *priv) { struct dwc2_core_regs *regs = priv->regs; uint32_t snpsid; int i, j; + int ret; + + ret = dwc2_reset(dev); + if (ret) + return ret; snpsid = readl(®s->gsnpsid); dev_info(dev, "Core Release: %x.%03x\n", @@ -1303,6 +1338,8 @@ static int dwc2_usb_remove(struct udevice *dev) dwc2_uninit_common(priv->regs); + reset_release_bulk(&priv->resets); + return 0; } |