* [PATCH] clk: rockchip: rk3588: keep the OTP gates shared with the secure world on
@ 2026-10-27 0:24 Nikolay Bryskin
2026-10-27 3:53 ` Chen-Yu Tsai
0 siblings, 1 reply; 2+ messages in thread
From: Nikolay Bryskin @ 2026-10-27 0:24 UTC (permalink / raw)
To: Heiko Stuebner, Stephen Boyd
Cc: Brian Masney, Jerome Brunet, linux-clk, linux-rockchip,
linux-arm-kernel, linux-kernel, Nikolay Bryskin
The secure OTP controller (OTPC_S) shares three clock gates in
CRU_CLKGATE_CON18 with the non-secure one: clk_otpc_arb,
clk_otpc_auto_rd_g and clk_otp_phy_g. The kernel treats them as ordinary
gates: clk_otpc_auto_rd_g is disabled as unused at the end of boot, and
the rockchip-otp nvmem driver enables clk_otpc_arb and clk_otp_phy_g
around each read and disables them again afterwards.
Firmware in the secure world (OP-TEE reads its hardware unique key and
the secure boot state from OTPC_S, and programs them) has no way to take
a reference on these clocks. Once Linux has gated them, every secure OTP
access times out, and a normal-world nvmem read on another CPU can gate
them in the middle of a secure access, including a fuse programming
cycle.
Mark the three gates critical so the normal world never turns them off.
They are 24 MHz gates for the OTP block only.
Link: https://github.com/OP-TEE/optee_os/pull/8034
Signed-off-by: Nikolay Bryskin <nbryskin@gmail.com>
---
drivers/clk/rockchip/clk-rk3588.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/rockchip/clk-rk3588.c b/drivers/clk/rockchip/clk-rk3588.c
index 24baa0ef9bf3..8e0f408fdfad 100644
--- a/drivers/clk/rockchip/clk-rk3588.c
+++ b/drivers/clk/rockchip/clk-rk3588.c
@@ -1158,11 +1158,11 @@ static struct rockchip_clk_branch rk3588_early_clk_branches[] __initdata = {
RK3588_CLKGATE_CON(18), 9, GFLAGS),
GATE(CLK_OTPC_NS, "clk_otpc_ns", "xin24m", 0,
RK3588_CLKGATE_CON(18), 10, GFLAGS),
- GATE(CLK_OTPC_ARB, "clk_otpc_arb", "xin24m", 0,
+ GATE(CLK_OTPC_ARB, "clk_otpc_arb", "xin24m", CLK_IS_CRITICAL,
RK3588_CLKGATE_CON(18), 11, GFLAGS),
- GATE(CLK_OTP_PHY_G, "clk_otp_phy_g", "xin24m", 0,
+ GATE(CLK_OTP_PHY_G, "clk_otp_phy_g", "xin24m", CLK_IS_CRITICAL,
RK3588_CLKGATE_CON(18), 13, GFLAGS),
- GATE(CLK_OTPC_AUTO_RD_G, "clk_otpc_auto_rd_g", "xin24m", 0,
+ GATE(CLK_OTPC_AUTO_RD_G, "clk_otpc_auto_rd_g", "xin24m", CLK_IS_CRITICAL,
RK3588_CLKGATE_CON(18), 12, GFLAGS),
GATE(PCLK_SARADC, "pclk_saradc", "pclk_top_root", 0,
--
2.56.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] clk: rockchip: rk3588: keep the OTP gates shared with the secure world on
2026-10-27 0:24 [PATCH] clk: rockchip: rk3588: keep the OTP gates shared with the secure world on Nikolay Bryskin
@ 2026-10-27 3:53 ` Chen-Yu Tsai
0 siblings, 0 replies; 2+ messages in thread
From: Chen-Yu Tsai @ 2026-10-27 3:53 UTC (permalink / raw)
To: Nikolay Bryskin
Cc: Heiko Stuebner, Stephen Boyd, Brian Masney, Jerome Brunet,
linux-clk, linux-rockchip, linux-arm-kernel, linux-kernel
On Tue, Oct 27, 2026 at 8:28 AM Nikolay Bryskin <nbryskin@gmail.com> wrote:
>
> The secure OTP controller (OTPC_S) shares three clock gates in
> CRU_CLKGATE_CON18 with the non-secure one: clk_otpc_arb,
> clk_otpc_auto_rd_g and clk_otp_phy_g. The kernel treats them as ordinary
> gates: clk_otpc_auto_rd_g is disabled as unused at the end of boot, and
> the rockchip-otp nvmem driver enables clk_otpc_arb and clk_otp_phy_g
> around each read and disables them again afterwards.
>
> Firmware in the secure world (OP-TEE reads its hardware unique key and
> the secure boot state from OTPC_S, and programs them) has no way to take
> a reference on these clocks. Once Linux has gated them, every secure OTP
> access times out, and a normal-world nvmem read on another CPU can gate
> them in the middle of a secure access, including a fuse programming
> cycle.
>
> Mark the three gates critical so the normal world never turns them off.
> They are 24 MHz gates for the OTP block only.
If OPTEE needs some resources kept online, maybe the OPTEE DT node should
have a reference to them?
Otherwise everyone is just playing whack-a-mole in each separate driver.
And for folks that don't have OPTEE, it's a potential waste of power.
ChenYu
> Link: https://github.com/OP-TEE/optee_os/pull/8034
> Signed-off-by: Nikolay Bryskin <nbryskin@gmail.com>
> ---
> drivers/clk/rockchip/clk-rk3588.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/clk/rockchip/clk-rk3588.c b/drivers/clk/rockchip/clk-rk3588.c
> index 24baa0ef9bf3..8e0f408fdfad 100644
> --- a/drivers/clk/rockchip/clk-rk3588.c
> +++ b/drivers/clk/rockchip/clk-rk3588.c
> @@ -1158,11 +1158,11 @@ static struct rockchip_clk_branch rk3588_early_clk_branches[] __initdata = {
> RK3588_CLKGATE_CON(18), 9, GFLAGS),
> GATE(CLK_OTPC_NS, "clk_otpc_ns", "xin24m", 0,
> RK3588_CLKGATE_CON(18), 10, GFLAGS),
> - GATE(CLK_OTPC_ARB, "clk_otpc_arb", "xin24m", 0,
> + GATE(CLK_OTPC_ARB, "clk_otpc_arb", "xin24m", CLK_IS_CRITICAL,
> RK3588_CLKGATE_CON(18), 11, GFLAGS),
> - GATE(CLK_OTP_PHY_G, "clk_otp_phy_g", "xin24m", 0,
> + GATE(CLK_OTP_PHY_G, "clk_otp_phy_g", "xin24m", CLK_IS_CRITICAL,
> RK3588_CLKGATE_CON(18), 13, GFLAGS),
> - GATE(CLK_OTPC_AUTO_RD_G, "clk_otpc_auto_rd_g", "xin24m", 0,
> + GATE(CLK_OTPC_AUTO_RD_G, "clk_otpc_auto_rd_g", "xin24m", CLK_IS_CRITICAL,
> RK3588_CLKGATE_CON(18), 12, GFLAGS),
>
> GATE(PCLK_SARADC, "pclk_saradc", "pclk_top_root", 0,
> --
> 2.56.0
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-27 3:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 0:24 [PATCH] clk: rockchip: rk3588: keep the OTP gates shared with the secure world on Nikolay Bryskin
2026-10-27 3:53 ` Chen-Yu Tsai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®