[PATCH 2/5] usb: dwc2: add clk dependency for probe via oftree
Michael Grzeschik
m.grzeschik at pengutronix.de
Wed Dec 16 15:45:31 EST 2020
The dwc2 controller at least needs one core clock which needs to be
enabled before it is able to address the core registers. This patch adds
the referenced clock in the devicetree to be used.
Signed-off-by: Michael Grzeschik <m.grzeschik at pengutronix.de>
---
drivers/usb/dwc2/core.h | 1 +
drivers/usb/dwc2/dwc2.c | 19 +++++++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index b9845b5524..780efb262c 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -467,6 +467,7 @@ struct dwc2 {
struct dwc2_core_params params;
struct phy *phy; /* optional */
+ struct clk *clk;
#ifdef CONFIG_USB_DWC2_HOST
struct usb_host host;
diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index 87d0ec7a5a..13455479ef 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -50,15 +50,26 @@ static int dwc2_probe(struct device_d *dev)
dwc2->regs = IOMEM(iores->start);
dwc2->dev = dev;
+ dwc2->clk = clk_get(dev, NULL);
+ if (IS_ERR(dwc2->clk)) {
+ ret = PTR_ERR(dwc2->clk);
+ dev_err(dev, "Failed to get USB clock %d\n", ret);
+ goto release_region;
+ }
+
+ ret = clk_enable(dwc2->clk);
+ if (ret)
+ goto clk_put;
+
dwc2->phy = phy_optional_get(dev, "usb2-phy");
if (IS_ERR(dwc2->phy)) {
ret = PTR_ERR(dwc2->phy);
- goto release_region;
+ goto clk_disable;
}
ret = phy_init(dwc2->phy);
if (ret)
- goto err_phy_init;
+ goto clk_disable;
ret = phy_power_on(dwc2->phy);
if (ret)
goto err_phy_power;
@@ -100,6 +111,10 @@ error:
phy_power_off(dwc2->phy);
err_phy_power:
phy_exit(dwc2->phy);
+clk_disable:
+ clk_disable(dwc2->clk);
+clk_put:
+ clk_put(dwc2->clk);
release_region:
release_region(iores);
--
2.29.2
More information about the barebox
mailing list