Date: Thu, 2 Feb 2023 11:20:22 GMT From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 2908718700b5 - stable/13 - dwc3: Handle optional clocks Message-ID: <202302021120.312BKMsR085857@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=2908718700b5890dc733c2bd7a741048b0656f31 commit 2908718700b5890dc733c2bd7a741048b0656f31 Author: Emmanuel Vadot <manu@FreeBSD.org> AuthorDate: 2022-11-15 08:58:30 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2023-02-02 11:17:26 +0000 dwc3: Handle optional clocks Usually dwc3 needs a glue node that contain the SoC specific clocks/resets. For some reason the RK3328 DTS doesn't have this glue node and the clocks are specified in the dwc3 node directly. The bindings says that it is allowed but doesn't specified some strict names for them. Add a specific case for RK3328 based on the compatible string. Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D37392 Sponsored by: Beckhoff Automation GmbH & Co. KG (cherry picked from commit 0a5f342aa5a0ddd5d173bdfc856c6a81d1c12c6c) --- sys/dev/usb/controller/dwc3.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/sys/dev/usb/controller/dwc3.c b/sys/dev/usb/controller/dwc3.c index 2e8f868bc47b..eaea4d57a764 100644 --- a/sys/dev/usb/controller/dwc3.c +++ b/sys/dev/usb/controller/dwc3.c @@ -86,6 +86,11 @@ struct snps_dwc3_softc { bus_space_tag_t bst; bus_space_handle_t bsh; uint32_t snpsid; +#ifdef FDT + clk_t clk_ref; + clk_t clk_suspend; + clk_t clk_bus; +#endif }; #define DWC3_WRITE(_sc, _off, _val) \ @@ -394,9 +399,32 @@ snps_dwc3_common_attach(device_t dev, bool is_fdt) if (!is_fdt) goto skip_phys; - /* Get the phys */ node = ofw_bus_get_node(dev); + /* Get the clocks if any */ + if (ofw_bus_is_compatible(dev, "rockchip,rk3328-dwc3") == 1) { + if (clk_get_by_ofw_name(dev, node, "ref_clk", &sc->clk_ref) != 0) + device_printf(dev, "Cannot get ref_clk\n"); + if (clk_get_by_ofw_name(dev, node, "suspend_clk", &sc->clk_suspend) != 0) + device_printf(dev, "Cannot get suspend_clk\n"); + if (clk_get_by_ofw_name(dev, node, "bus_clk", &sc->clk_bus) != 0) + device_printf(dev, "Cannot get bus_clk\n"); + } + + if (sc->clk_ref != NULL) { + if (clk_enable(sc->clk_ref) != 0) + device_printf(dev, "Cannot enable ref_clk\n"); + } + if (sc->clk_suspend != NULL) { + if (clk_enable(sc->clk_suspend) != 0) + device_printf(dev, "Cannot enable suspend_clk\n"); + } + if (sc->clk_bus != NULL) { + if (clk_enable(sc->clk_bus) != 0) + device_printf(dev, "Cannot enable bus_clk\n"); + } + + /* Get the phys */ usb2_phy = usb3_phy = NULL; error = phy_get_by_ofw_name(dev, node, "usb2-phy", &usb2_phy); if (error == 0 && usb2_phy != NULL) @@ -427,6 +455,16 @@ skip_phys: snsp_dwc3_dump_regs(sc, "Post XHCI init"); #endif +#ifdef FDT + if (error) { + if (sc->clk_ref != NULL) + clk_disable(sc->clk_ref); + if (sc->clk_suspend != NULL) + clk_disable(sc->clk_suspend); + if (sc->clk_bus != NULL) + clk_disable(sc->clk_bus); + } +#endif return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302021120.312BKMsR085857>