From nobody Thu Feb 2 11:20:22 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P6xCp3pr2z3cxBW; Thu, 2 Feb 2023 11:20:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P6xCp34v2z47g2; Thu, 2 Feb 2023 11:20:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675336822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TPea1XmXfbid38r/d33INHg0rr3WH6h3n4D3qEPFnVU=; b=ew1IAWqgZt/YNf8LCstUKtlR8aoAfBChAWWRbRtQ2MowP6NQtXZIaKDrjSLuPGmBVExQGj QyjW2z+q0KN0S9kQTOU97ivD1QkU8FdppGoQliT3uzrs+TBNK5GnunNrtAxKjmvgG76+NT NnFNObtNUxc3qjW4CXaGPIGytN1lrQTSNjBVrJKp7ihu9JlYlWQr9yHihr3GeUVsNAfgxi J88rZC0tkUHkvDRSdfO8s1W7BsO7uVNRb5E714svUsi4SDWstyOdazXedID00kkqDFRPGq QXUg5Tt5yZCp6pb4lxx4eYq4GV+vr+aC9dT+E05azl80O7CyWFhlrpcyUtZDEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675336822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TPea1XmXfbid38r/d33INHg0rr3WH6h3n4D3qEPFnVU=; b=UgRUY490WSVyCUuZ8O1H/IrxAv9wOVM7pjOW1W7dPFfgfAs8UbhBbrXbgNIjfz5Siex6q2 IZGGTt1Td8U16bPKpehwmYP/kBq81wZIsyjDwgvCcwleWi0MP/aWyxzDRcK7fS9iuUA3hA kkXqEQdDK/p79lMOfoRMn0EBm4qbbWCarjLZU2ym0KLK/lO8+8rdnvjNZv0bPsmK8jLdRO fowsRifW5MEW4+VnMVjRDarWA4O66DsszhlrV+YyttmPCvI2bjL09bb12Sgocl4pIW+3Tv B/cxvJelrixeDme3PULGh4KuXPL+msq+34VxmCWDC0tx0hejiqMjfyTpp+fmwQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675336822; a=rsa-sha256; cv=none; b=qr5PPZQfb1fQENRAGxRCecw5JUQJv6kVl0jThO/Z/nG0+X6ZRF2jxpyX6pQaoOMfk8Et4t gHz/uHQZoqWR4OkRr38GTCkHDzRAa9VmtAXkzC8umabMTp+uMOrbfFoOfaV5AFjoYOp3pi N6fSaL9rChM7jMWXXtilJhA0mCeWOu2e+cU+uz2mWQdJR1hQxPJ5JNdTPgQLTVnj97zeoA wa/xS+4xi1v12vggg9Zzcc2PLSlmaKdErKhEfoLnw0B0umKrEcsiacvFYgYMZInWWrKRi/ WmXMKsuqAOKlOHpqZb+WaHosADI2TY01+LUtVIRPeRk9feTlWgyNrtyGkyepGg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P6xCp28lWzsLF; Thu, 2 Feb 2023 11:20:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 312BKMp5085858; Thu, 2 Feb 2023 11:20:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 312BKMsR085857; Thu, 2 Feb 2023 11:20:22 GMT (envelope-from git) Date: Thu, 2 Feb 2023 11:20:22 GMT Message-Id: <202302021120.312BKMsR085857@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 2908718700b5 - stable/13 - dwc3: Handle optional clocks List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2908718700b5890dc733c2bd7a741048b0656f31 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=2908718700b5890dc733c2bd7a741048b0656f31 commit 2908718700b5890dc733c2bd7a741048b0656f31 Author: Emmanuel Vadot AuthorDate: 2022-11-15 08:58:30 +0000 Commit: Emmanuel Vadot 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); }