aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPatrick Delaunay2020-04-27 15:29:59 +0200
committerMarek Vasut2020-04-28 13:52:52 +0200
commit0bc632c9b189f0350b2ef81d6583704bd10cfdc9 (patch)
treed7e3ce453582f8c44e02ff7683caad6756ccf7b4 /drivers
parente17a4bf198510693967644c331ab621fc41ea8b5 (diff)
usb: host: dwc2: add clk support
Add support for clock with driver model. This patch don't added dependency because when CONFIG_CLK is not activated the clk function are stubbed. Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/host/dwc2.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index a8e64825b56..b1b79d0a180 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -5,14 +5,15 @@
*/
#include <common.h>
+#include <clk.h>
#include <cpu_func.h>
#include <dm.h>
#include <errno.h>
#include <generic-phy.h>
-#include <usb.h>
#include <malloc.h>
#include <memalign.h>
#include <phys2bus.h>
+#include <usb.h>
#include <usbroothubdes.h>
#include <wait_bit.h>
#include <asm/io.h>
@@ -39,6 +40,7 @@ struct dwc2_priv {
struct udevice *vbus_supply;
#endif
struct phy phy;
+ struct clk_bulk clks;
#else
uint8_t *aligned_buffer;
uint8_t *status_buffer;
@@ -1377,6 +1379,26 @@ static int dwc2_shutdown_phy(struct udevice *dev)
return 0;
}
+static int dwc2_clk_init(struct udevice *dev)
+{
+ struct dwc2_priv *priv = dev_get_priv(dev);
+ int ret;
+
+ ret = clk_get_bulk(dev, &priv->clks);
+ if (ret == -ENOSYS || ret == -ENOENT)
+ return 0;
+ if (ret)
+ return ret;
+
+ ret = clk_enable_bulk(&priv->clks);
+ if (ret) {
+ clk_release_bulk(&priv->clks);
+ return ret;
+ }
+
+ return 0;
+}
+
static int dwc2_usb_probe(struct udevice *dev)
{
struct dwc2_priv *priv = dev_get_priv(dev);
@@ -1385,6 +1407,10 @@ static int dwc2_usb_probe(struct udevice *dev)
bus_priv->desc_before_addr = true;
+ ret = dwc2_clk_init(dev);
+ if (ret)
+ return ret;
+
ret = dwc2_setup_phy(dev);
if (ret)
return ret;
@@ -1410,6 +1436,8 @@ static int dwc2_usb_remove(struct udevice *dev)
dwc2_uninit_common(priv->regs);
reset_release_bulk(&priv->resets);
+ clk_disable_bulk(&priv->clks);
+ clk_release_bulk(&priv->clks);
return 0;
}