From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [RESEND PATCH v6 3/5] usb: host: dwc2: add clk support
Date: Mon, 27 Apr 2020 15:29:59 +0200 [thread overview]
Message-ID: <20200427133001.5557-4-patrick.delaunay@st.com> (raw)
In-Reply-To: <20200427133001.5557-1-patrick.delaunay@st.com>
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>
---
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
drivers/usb/host/dwc2.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index a8e64825b5..b1b79d0a18 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;
}
--
2.17.1
next prev parent reply other threads:[~2020-04-27 13:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 13:29 [RESEND PATCH v6 0/5] usb: host: dwc2: use driver model for PHY and CLOCK Patrick Delaunay
2020-04-27 13:29 ` [RESEND PATCH v6 1/5] dm: clk: add stub when CONFIG_CLK is deactivated Patrick Delaunay
2020-04-27 13:29 ` [RESEND PATCH v6 2/5] usb: host: dwc2: add phy support Patrick Delaunay
2020-04-27 13:29 ` Patrick Delaunay [this message]
2020-04-27 13:30 ` [RESEND PATCH v6 4/5] usb: host: dwc2: force reset assert Patrick Delaunay
2020-04-27 13:30 ` [RESEND PATCH v6 5/5] usb: host: dwc2: add trace to have clean usb start Patrick Delaunay
2020-04-27 13:37 ` [RESEND PATCH v6 0/5] usb: host: dwc2: use driver model for PHY and CLOCK Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200427133001.5557-4-patrick.delaunay@st.com \
--to=patrick.delaunay@st.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox