Skip to content

Commit 64042c2

Browse files
sremmind
authored andcommitted
clk: rockchip: rk3588: make gate linked clocks critical
RK3588 has a couple of hardware blocks called Native Interface Unit (NIU) that gate the clocks to devices behind them. Effectively this means that some clocks require two parent clocks being enabled. Downstream implemented this by using a separate clock driver ("clk-link") for them, which enables the second clock using PM framework. In the upstream kernel we are currently missing support for the second parent. The information about it is in the GATE_LINK() macro as linkname, but that is not used. Thus the second parent clock is not properly enabled. So far this did not really matter, since these clocks are mostly required for the more advanced IP blocks, that are not yet supported upstream. As this is about to change we need a fix. There are three options available: 1. Properly implement support for having two parent clocks in the clock framework. 2. Mark the affected clocks CLK_IGNORE_UNUSED, so that they are not disabled. This wastes some power, but keeps the hack contained within the clock driver. Going from this to the first solution is easy once that has been implemented. 3. Enabling the extra clock in the consumer driver. This leaks some implementation details into DT. This patch implements the second option as an intermediate solution until the first one is available. I used an alias for CLK_IS_CRITICAL, so that it's easy to see which clocks are not really critical once the clock framework supports a better way to implement this. Tested-by: Vincent Legoll <vincent.legoll@gmail.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Link: https://lore.kernel.org/r/20230403193250.108693-2-sebastian.reichel@collabora.com Signed-off-by: Heiko Stuebner <heiko@sntech.de>
1 parent 933bf36 commit 64042c2

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

drivers/clk/rockchip/clk-rk3588.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,25 @@
1313
#include "clk.h"
1414

1515
/*
16-
* GATE with additional linked clock. Downstream enables the linked clock
17-
* (via runtime PM) whenever the gate is enabled. The downstream implementation
18-
* does this via separate clock nodes for each of the linked gate clocks,
19-
* which leaks parts of the clock tree into DT. It is unclear why this is
20-
* actually needed and things work without it for simple use cases. Thus
21-
* the linked clock is ignored for now.
16+
* Recent Rockchip SoCs have a new hardware block called Native Interface
17+
* Unit (NIU), which gates clocks to devices behind them. These effectively
18+
* need two parent clocks.
19+
*
20+
* Downstream enables the linked clock via runtime PM whenever the gate is
21+
* enabled. This implementation uses separate clock nodes for each of the
22+
* linked gate clocks, which leaks parts of the clock tree into DT.
23+
*
24+
* The GATE_LINK macro instead takes the second parent via 'linkname', but
25+
* ignores the information. Once the clock framework is ready to handle it, the
26+
* information should be passed on here. But since these clocks are required to
27+
* access multiple relevant IP blocks, such as PCIe or USB, we mark all linked
28+
* clocks critical until a better solution is available. This will waste some
29+
* power, but avoids leaking implementation details into DT or hanging the
30+
* system.
2231
*/
2332
#define GATE_LINK(_id, cname, pname, linkname, f, o, b, gf) \
2433
GATE(_id, cname, pname, f, o, b, gf)
34+
#define RK3588_LINKED_CLK CLK_IS_CRITICAL
2535

2636

2737
#define RK3588_GRF_SOC_STATUS0 0x600
@@ -1446,7 +1456,7 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
14461456
COMPOSITE_NODIV(HCLK_NVM_ROOT, "hclk_nvm_root", mux_200m_100m_50m_24m_p, 0,
14471457
RK3588_CLKSEL_CON(77), 0, 2, MFLAGS,
14481458
RK3588_CLKGATE_CON(31), 0, GFLAGS),
1449-
COMPOSITE(ACLK_NVM_ROOT, "aclk_nvm_root", gpll_cpll_p, 0,
1459+
COMPOSITE(ACLK_NVM_ROOT, "aclk_nvm_root", gpll_cpll_p, RK3588_LINKED_CLK,
14501460
RK3588_CLKSEL_CON(77), 7, 1, MFLAGS, 2, 5, DFLAGS,
14511461
RK3588_CLKGATE_CON(31), 1, GFLAGS),
14521462
GATE(ACLK_EMMC, "aclk_emmc", "aclk_nvm_root", 0,
@@ -1675,13 +1685,13 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
16751685
RK3588_CLKGATE_CON(42), 9, GFLAGS),
16761686

16771687
/* vdpu */
1678-
COMPOSITE(ACLK_VDPU_ROOT, "aclk_vdpu_root", gpll_cpll_aupll_p, 0,
1688+
COMPOSITE(ACLK_VDPU_ROOT, "aclk_vdpu_root", gpll_cpll_aupll_p, RK3588_LINKED_CLK,
16791689
RK3588_CLKSEL_CON(98), 5, 2, MFLAGS, 0, 5, DFLAGS,
16801690
RK3588_CLKGATE_CON(44), 0, GFLAGS),
16811691
COMPOSITE_NODIV(ACLK_VDPU_LOW_ROOT, "aclk_vdpu_low_root", mux_400m_200m_100m_24m_p, 0,
16821692
RK3588_CLKSEL_CON(98), 7, 2, MFLAGS,
16831693
RK3588_CLKGATE_CON(44), 1, GFLAGS),
1684-
COMPOSITE_NODIV(HCLK_VDPU_ROOT, "hclk_vdpu_root", mux_200m_100m_50m_24m_p, 0,
1694+
COMPOSITE_NODIV(HCLK_VDPU_ROOT, "hclk_vdpu_root", mux_200m_100m_50m_24m_p, RK3588_LINKED_CLK,
16851695
RK3588_CLKSEL_CON(98), 9, 2, MFLAGS,
16861696
RK3588_CLKGATE_CON(44), 2, GFLAGS),
16871697
COMPOSITE(ACLK_JPEG_DECODER_ROOT, "aclk_jpeg_decoder_root", gpll_cpll_aupll_spll_p, 0,
@@ -1732,9 +1742,9 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
17321742
COMPOSITE(ACLK_RKVENC0_ROOT, "aclk_rkvenc0_root", gpll_cpll_npll_p, 0,
17331743
RK3588_CLKSEL_CON(102), 7, 2, MFLAGS, 2, 5, DFLAGS,
17341744
RK3588_CLKGATE_CON(47), 1, GFLAGS),
1735-
GATE(HCLK_RKVENC0, "hclk_rkvenc0", "hclk_rkvenc0_root", 0,
1745+
GATE(HCLK_RKVENC0, "hclk_rkvenc0", "hclk_rkvenc0_root", RK3588_LINKED_CLK,
17361746
RK3588_CLKGATE_CON(47), 4, GFLAGS),
1737-
GATE(ACLK_RKVENC0, "aclk_rkvenc0", "aclk_rkvenc0_root", 0,
1747+
GATE(ACLK_RKVENC0, "aclk_rkvenc0", "aclk_rkvenc0_root", RK3588_LINKED_CLK,
17381748
RK3588_CLKGATE_CON(47), 5, GFLAGS),
17391749
COMPOSITE(CLK_RKVENC0_CORE, "clk_rkvenc0_core", gpll_cpll_aupll_npll_p, 0,
17401750
RK3588_CLKSEL_CON(102), 14, 2, MFLAGS, 9, 5, DFLAGS,
@@ -1744,10 +1754,10 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
17441754
RK3588_CLKGATE_CON(48), 6, GFLAGS),
17451755

17461756
/* vi */
1747-
COMPOSITE(ACLK_VI_ROOT, "aclk_vi_root", gpll_cpll_npll_aupll_spll_p, 0,
1757+
COMPOSITE(ACLK_VI_ROOT, "aclk_vi_root", gpll_cpll_npll_aupll_spll_p, RK3588_LINKED_CLK,
17481758
RK3588_CLKSEL_CON(106), 5, 3, MFLAGS, 0, 5, DFLAGS,
17491759
RK3588_CLKGATE_CON(49), 0, GFLAGS),
1750-
COMPOSITE_NODIV(HCLK_VI_ROOT, "hclk_vi_root", mux_200m_100m_50m_24m_p, 0,
1760+
COMPOSITE_NODIV(HCLK_VI_ROOT, "hclk_vi_root", mux_200m_100m_50m_24m_p, RK3588_LINKED_CLK,
17511761
RK3588_CLKSEL_CON(106), 8, 2, MFLAGS,
17521762
RK3588_CLKGATE_CON(49), 1, GFLAGS),
17531763
COMPOSITE_NODIV(PCLK_VI_ROOT, "pclk_vi_root", mux_100m_50m_24m_p, 0,
@@ -1919,10 +1929,10 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
19191929
COMPOSITE(ACLK_VOP_ROOT, "aclk_vop_root", gpll_cpll_dmyaupll_npll_spll_p, 0,
19201930
RK3588_CLKSEL_CON(110), 5, 3, MFLAGS, 0, 5, DFLAGS,
19211931
RK3588_CLKGATE_CON(52), 0, GFLAGS),
1922-
COMPOSITE_NODIV(ACLK_VOP_LOW_ROOT, "aclk_vop_low_root", mux_400m_200m_100m_24m_p, 0,
1932+
COMPOSITE_NODIV(ACLK_VOP_LOW_ROOT, "aclk_vop_low_root", mux_400m_200m_100m_24m_p, RK3588_LINKED_CLK,
19231933
RK3588_CLKSEL_CON(110), 8, 2, MFLAGS,
19241934
RK3588_CLKGATE_CON(52), 1, GFLAGS),
1925-
COMPOSITE_NODIV(HCLK_VOP_ROOT, "hclk_vop_root", mux_200m_100m_50m_24m_p, 0,
1935+
COMPOSITE_NODIV(HCLK_VOP_ROOT, "hclk_vop_root", mux_200m_100m_50m_24m_p, RK3588_LINKED_CLK,
19261936
RK3588_CLKSEL_CON(110), 10, 2, MFLAGS,
19271937
RK3588_CLKGATE_CON(52), 2, GFLAGS),
19281938
COMPOSITE_NODIV(PCLK_VOP_ROOT, "pclk_vop_root", mux_100m_50m_24m_p, 0,
@@ -2425,7 +2435,7 @@ static struct rockchip_clk_branch rk3588_clk_branches[] __initdata = {
24252435

24262436
GATE_LINK(ACLK_ISP1_PRE, "aclk_isp1_pre", "aclk_isp1_root", "aclk_vi_root", 0, RK3588_CLKGATE_CON(26), 6, GFLAGS),
24272437
GATE_LINK(HCLK_ISP1_PRE, "hclk_isp1_pre", "hclk_isp1_root", "hclk_vi_root", 0, RK3588_CLKGATE_CON(26), 8, GFLAGS),
2428-
GATE_LINK(HCLK_NVM, "hclk_nvm", "hclk_nvm_root", "aclk_nvm_root", 0, RK3588_CLKGATE_CON(31), 2, GFLAGS),
2438+
GATE_LINK(HCLK_NVM, "hclk_nvm", "hclk_nvm_root", "aclk_nvm_root", RK3588_LINKED_CLK, RK3588_CLKGATE_CON(31), 2, GFLAGS),
24292439
GATE_LINK(ACLK_USB, "aclk_usb", "aclk_usb_root", "aclk_vo1usb_top_root", 0, RK3588_CLKGATE_CON(42), 2, GFLAGS),
24302440
GATE_LINK(HCLK_USB, "hclk_usb", "hclk_usb_root", "hclk_vo1usb_top_root", 0, RK3588_CLKGATE_CON(42), 3, GFLAGS),
24312441
GATE_LINK(ACLK_JPEG_DECODER_PRE, "aclk_jpeg_decoder_pre", "aclk_jpeg_decoder_root", "aclk_vdpu_root", 0, RK3588_CLKGATE_CON(44), 7, GFLAGS),

0 commit comments

Comments
 (0)