From nobody Mon May 16 15:33:32 2022 X-Original-To: dev-commits-src-all@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 34E301AE651F; Mon, 16 May 2022 15:33:33 +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 4L23Ds0mhnz3rjR; Mon, 16 May 2022 15:33:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652715213; 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=Lq1vusisTFL62mEMovFno0RqGAtshaeJrLn/9fDg7KE=; b=MnQDyOKAbgdvhfTD03qrhddFQidz3DlBd4DOP7gdF+/Y1zhb1Hkvio9sGrJ6ueX1y9ot/u M3fgLi2Ueq4P9tiIAungY/S5RE7h8zVhaBT+92oWD3un1Iwh3hnqi2mtOOdzcRqT27iLET tfm7rV0MfIO0G11gYmG6BW0HjNfGJkRdw+ojuoQ/0Cru6MeTSMvO6EOLDUZ5DA53n7Ok6q Oovjms1v5w1SVTql11I4Tx6aUvN70mreso8r+U3EHiW4XVpKTUvNi9rFOEdBmsP1q90kn1 a8A8i/+Y7N1IlXo+rORyf80zPR4NZd7Vjg9zQbuz0jeXZSs5EpcbE7/LUmY91g== 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 EE19222D9A; Mon, 16 May 2022 15:33:32 +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 24GFXWFQ020122; Mon, 16 May 2022 15:33:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24GFXWnp020121; Mon, 16 May 2022 15:33:32 GMT (envelope-from git) Date: Mon, 16 May 2022 15:33:32 GMT Message-Id: <202205161533.24GFXWnp020121@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: 1547924e5377 - stable/13 - arm64: rockchip: clk_mux: Add support for mux in GRF type clock List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 1547924e537772d2b6a5bb76375c1739deeaccc5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652715213; 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=Lq1vusisTFL62mEMovFno0RqGAtshaeJrLn/9fDg7KE=; b=S958gP65nSsifdvJjByQAOrNbHfOTNQtYmE/KnXEjPqeHBdeiS2B5BIM8AYmRgaesurd2Y 1JiLffNEa/M9LDycQnp1q62tPKtopyZC03V+nFgwVt7b05TvhO8iUi2cFeVCJbBMc42x/z bGsuMpWfqd8lgFWLALeinhzQJUvYclMzhCjwtCWhAAIlxL8/OnXFp9/PoEjN3fvFDohjXs 5VxGGlY7fxUjl52wz0G4ssmcDO75OO+SJrDCuyEkpOYUPRwo18Q/c1hCQvp0OLv4fTckH8 c5yJge0OaFQy7T8CNtGFFrTzMIfbNzGde0vwG7pX3/0taauCxwkTkzmvS8zpBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652715213; a=rsa-sha256; cv=none; b=Vt/NTfhyEPuKjnvuGFJHu9o5J+O6OLhTXo6p8LstJrzLn1fBMVl+jsuOXW2B9kD8jAeb62 L45O89enmEPpr+U/QcmS+bI1JB5WfDGiLRCc4ledvlC061yRMaPTluxpiVsKLRL93dWQnZ efZnJ7s1aKMZk+Rh6yiS3cvJmazeu3ygxWFbkW5RbfBdTPEayXYh1sg6RNRZjFDIP7J8v4 C+8vMVN/TtXKph/NDC0jmT5vbZCLiCDeq3xqgiZtRfCoX8+hyKjcnVLjzQPQ3cPZtEG4Fb iAXfZGepr2fWsvavproBFdsWKAJowiiMTwB5kYWml1gS7GfWkoW7nu4uelFuFg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=1547924e537772d2b6a5bb76375c1739deeaccc5 commit 1547924e537772d2b6a5bb76375c1739deeaccc5 Author: Emmanuel Vadot AuthorDate: 2021-09-09 16:24:33 +0000 Commit: Emmanuel Vadot CommitDate: 2022-05-16 15:27:23 +0000 arm64: rockchip: clk_mux: Add support for mux in GRF type clock Some clocks have their mux register in the GRF and not in the CRU. Add support for that in the rk_clk_mux clock type. (cherry picked from commit 731e418bd748f6602bb184ca3a35bab8af241cf1) --- sys/arm64/rockchip/clk/rk_clk_mux.c | 50 ++++++++++++++++++++++++++++++++++--- sys/arm64/rockchip/clk/rk_clk_mux.h | 1 + sys/arm64/rockchip/clk/rk_cru.h | 17 +++++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/sys/arm64/rockchip/clk/rk_clk_mux.c b/sys/arm64/rockchip/clk/rk_clk_mux.c index eb3cdeb99f4b..20e612b8c764 100644 --- a/sys/arm64/rockchip/clk/rk_clk_mux.c +++ b/sys/arm64/rockchip/clk/rk_clk_mux.c @@ -38,11 +38,13 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include "clkdev_if.h" +#include "syscon_if.h" #define WR4(_clk, off, val) \ CLKDEV_WRITE_4(clknode_get_device(_clk), off, val) @@ -72,6 +74,7 @@ struct rk_clk_mux_sc { uint32_t shift; uint32_t mask; int mux_flags; + struct syscon *grf; }; static clknode_method_t rk_clk_mux_methods[] = { @@ -84,6 +87,25 @@ static clknode_method_t rk_clk_mux_methods[] = { DEFINE_CLASS_1(rk_clk_mux, rk_clk_mux_class, rk_clk_mux_methods, sizeof(struct rk_clk_mux_sc), clknode_class); +static struct syscon * +rk_clk_mux_get_grf(struct clknode *clk) +{ + device_t dev; + phandle_t node; + struct syscon *grf; + + grf = NULL; + dev = clknode_get_device(clk); + node = ofw_bus_get_node(dev); + if (OF_hasprop(node, "rockchip,grf") && + syscon_get_by_ofw_property(dev, node, + "rockchip,grf", &grf) != 0) { + return (NULL); + } + + return (grf); +} + static int rk_clk_mux_init(struct clknode *clk, device_t dev) { @@ -93,8 +115,19 @@ rk_clk_mux_init(struct clknode *clk, device_t dev) sc = clknode_get_softc(clk); + if ((sc->mux_flags & RK_CLK_MUX_GRF) != 0) { + sc->grf = rk_clk_mux_get_grf(clk); + if (sc->grf == NULL) + panic("clock %s has GRF flag set but no syscon is available", + clknode_get_name(clk)); + } + DEVICE_LOCK(clk); - rv = RD4(clk, sc->offset, ®); + if (sc->grf) { + reg = SYSCON_READ_4(sc->grf, sc->offset); + rv = 0; + } else + rv = RD4(clk, sc->offset, ®); DEVICE_UNLOCK(clk); if (rv != 0) { return (rv); @@ -114,13 +147,18 @@ rk_clk_mux_set_mux(struct clknode *clk, int idx) sc = clknode_get_softc(clk); DEVICE_LOCK(clk); - rv = MD4(clk, sc->offset, sc->mask << sc->shift, - ((idx & sc->mask) << sc->shift) | RK_CLK_MUX_MASK); + if (sc->grf) + rv = SYSCON_MODIFY_4(sc->grf, sc->offset, sc->mask << sc->shift, + ((idx & sc->mask) << sc->shift) | RK_CLK_MUX_MASK); + else + rv = MD4(clk, sc->offset, sc->mask << sc->shift, + ((idx & sc->mask) << sc->shift) | RK_CLK_MUX_MASK); if (rv != 0) { DEVICE_UNLOCK(clk); return (rv); } - RD4(clk, sc->offset, ®); + if (sc->grf == NULL) + RD4(clk, sc->offset, ®); DEVICE_UNLOCK(clk); return(0); @@ -138,6 +176,10 @@ rk_clk_mux_set_freq(struct clknode *clk, uint64_t fparent, uint64_t *fout, sc = clknode_get_softc(clk); + if ((sc->mux_flags & RK_CLK_MUX_GRF) != 0) { + *stop = 1; + return (ENOTSUP); + } if ((sc->mux_flags & RK_CLK_MUX_REPARENT) == 0) { *stop = 0; return (0); diff --git a/sys/arm64/rockchip/clk/rk_clk_mux.h b/sys/arm64/rockchip/clk/rk_clk_mux.h index 7825f8892ac3..c2b5f9cdad69 100644 --- a/sys/arm64/rockchip/clk/rk_clk_mux.h +++ b/sys/arm64/rockchip/clk/rk_clk_mux.h @@ -42,6 +42,7 @@ struct rk_clk_mux_def { #define RK_CLK_MUX_MASK 0xFFFF0000 #define RK_CLK_MUX_REPARENT (1 << 0) +#define RK_CLK_MUX_GRF (1 << 1) int rk_clk_mux_register(struct clkdom *clkdom, struct rk_clk_mux_def *clkdef); diff --git a/sys/arm64/rockchip/clk/rk_cru.h b/sys/arm64/rockchip/clk/rk_cru.h index 0d1c49f01290..1c749d1d2c87 100644 --- a/sys/arm64/rockchip/clk/rk_cru.h +++ b/sys/arm64/rockchip/clk/rk_cru.h @@ -186,6 +186,23 @@ }, \ } +/* Complex clock without divider (multiplexer only in GRF). */ +#define MUXGRF(_id, _name, _pn, _f, _mo, _ms, _mw) \ +{ \ + .type = RK_CLK_MUX, \ + .clk.mux = &(struct rk_clk_mux_def) { \ + .clkdef.id = _id, \ + .clkdef.name = _name, \ + .clkdef.parent_names = _pn, \ + .clkdef.parent_cnt = nitems(_pn), \ + .clkdef.flags = CLK_NODE_STATIC_STRINGS, \ + .offset = _mo, \ + .shift = _ms, \ + .width = _mw, \ + .mux_flags = RK_CLK_MUX_GRF | _f, \ + }, \ +} + struct rk_cru_gate { const char *name; const char *parent_name;