RK3576 OTP support
Subsystems (4)
Heiko Stuebner
maintainerv2 cover RK3576 OTP support
This enables OTP support in the nvmem driver for rk3576.
I expect to pick the clock patch (patch1) and the arm64-dts patch (patch6) myself, after the nvmem-driver and -binding patches have been applied (patches 2-5).
But kept them together for people wanting to try this series.
changes in v2:
- fix register constant in clock definition (Diederik)
- add patch to set limits on variant-specific clock-names
- use correct limits for clocks + resets on rk3576 binding
RESEND, because I messed up my git-send-email which caused it to include the list of patches 2 times, duplicating everything :-( .
Heiko Stuebner (6):
clk: rockchip: rk3576: define clk_otp_phy_g
nvmem: rockchip-otp: Move read-offset into variant-data
dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names
dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576
nvmem: rockchip-otp: add rk3576 variant data
arm64: dts: rockchip: add rk3576 otp node
.../bindings/nvmem/rockchip,otp.yaml | 25 ++++++++++++ arch/arm64/boot/dts/rockchip/rk3576.dtsi | 39 +++++++++++++++++++ drivers/clk/rockchip/clk-rk3576.c | 2 + drivers/nvmem/rockchip-otp.c | 17 +++++++- 4 files changed, 81 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.2
Heiko Stuebner
maintainerPATCH RESEND v2 1/6 clk: rockchip: rk3576: define clk_otp_phy_g
The phy clock of the OTP block is also present, but was not defined so far. Though its clk-id already existed, so just define its location.
--- drivers/clk/rockchip/clk-rk3576.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/rockchip/clk-rk3576.c +2 -0
@@ -541,6 +541,8 @@ static struct rockchip_clk_branch rk3576_clk_branches[] __initdata = { RK3576_CLKGATE_CON(5), 14, GFLAGS),GATE (CLK_OTPC_AUTO_RD_G ,"clk_otpc_auto_rd_g" ,"xin24m" ,0 ,RK3576_CLKGATE_CON (5 ),15 ,GFLAGS ), +GATE (CLK_OTP_PHY_G ,"clk_otp_phy_g" ,"xin24m" ,0 , +RK3576_CLKGATE_CON (6 ),0 ,GFLAGS ),COMPOSITE (CLK_MIPI_CAMERAOUT_M0 ,"clk_mipi_cameraout_m0" , mux_24m_spll_gpll_cpll_p,0 ,RK3576_CLKSEL_CON (38 ),8 ,2 ,MFLAGS ,0 ,8 ,DFLAGS , RK3576_CLKGATE_CON(6), 3, GFLAGS),
Signature · 1 line
2.47.2
Heiko Stuebner
maintainerPATCH RESEND v2 2/6 nvmem: rockchip-otp: Move read-offset into variant-data
In reply to Heiko StuebnerThe RK3588 has an offset into the OTP area where the readable area begins and automatically adds this to the start address.
Other variants are very much similar to rk3588, just with a different offset, so move that value into variant-data.
To match the size in bytes, store this value also in bytes and not in number of blocks.
--- drivers/nvmem/rockchip-otp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/nvmem/rockchip-otp.c +3 -2
@@ -59,7 +59,6 @@#define RK3588_OTPC_AUTO_EN 0x08#define RK3588_OTPC_INT_ST 0x84#define RK3588_OTPC_DOUT0 0x20 -#define RK3588_NO_SECURE_OFFSET 0x300#define RK3588_NBYTES 4#define RK3588_BURST_NUM 1#define RK3588_BURST_SHIFT 8
@@ -69,6 +68,7 @@struct rockchip_data {int size; +int read_offset;const char *const *clks;int num_clks;nvmem_reg_read_t reg_read;
@@ -196,7 +196,7 @@ static int rk3588_otp_read(void *context, unsigned int offset, addr_start =round_down (offset,RK3588_NBYTES ) /RK3588_NBYTES ; addr_end =round_up (offset + bytes,RK3588_NBYTES ) /RK3588_NBYTES ; addr_len = addr_end - addr_start; - addr_start +=RK3588_NO_SECURE_OFFSET ; + addr_start += otp->data->read_offset /RK3588_NBYTES ; buf =kzalloc (array_size (addr_len,RK3588_NBYTES ),GFP_KERNEL );if (!buf)
@@ -280,6 +280,7 @@ static const char * const rk3588_otp_clocks[] = {static const struct rockchip_data rk3588_data = { .size =0x400 , + .read_offset =0xc00 , .clks = rk3588_otp_clocks, .num_clks =ARRAY_SIZE (rk3588_otp_clocks), .reg_read = rk3588_otp_read,
Signature · 1 line
2.47.2
Heiko Stuebner
maintainerPATCH RESEND v2 3/6 dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names
In reply to Heiko StuebnerThe clocks property correctly declares minItems and maxItems for its variants, but clock-names does not. Both properties are always used together, so should declare the same limits.
--- Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml +4 -0
@@ -62,6 +62,8 @@ allOf: properties: clocks: maxItems: 3 + clock-names: + maxItems: 3 resets: maxItems: 1 reset-names:
@@ -78,6 +80,8 @@ allOf: properties: clocks: minItems: 4 + clock-names: + minItems: 4 resets: minItems: 3 reset-names:
Signature · 1 line
2.47.2
Re: [PATCH RESEND v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names
Quoted 6 lines · Heiko Stuebner
The clocks property correctly declares minItems and maxItems for its variants, but clock-names does not. Both properties are always used together, so should declare the same limits.
Suggested-by Krzysztof Kozlowski <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>
Heiko Stuebner
maintainerPATCH RESEND v2 4/6 dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576
In reply to Heiko StuebnerDocument the OTP memory found on Rockchip RK3576 SoC.
The RK3576 uses the same set of clocks as the px30/rk3308 but has one reset more, so adapt the binding to handle this variant as well.
--- .../bindings/nvmem/rockchip,otp.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)
Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml +21 -0
@@ -14,6 +14,7 @@ properties: enum: - rockchip,px30-otp - rockchip,rk3308-otp + - rockchip,rk3576-otp - rockchip,rk3588-otp reg:
@@ -70,6 +71,26 @@ allOf: items: - const: phy + - if: + properties: + compatible: + contains: + enum: + - rockchip,rk3576-otp + then: + properties: + clocks: + maxItems: 3 + clock-names: + maxItems: 3 + resets: + minItems: 2 + maxItems: 2 + reset-names: + items: + - const: otp + - const: apb + - if: properties: compatible:
Signature · 1 line
2.47.2
Re: [PATCH RESEND v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576
Quoted 7 lines · Heiko Stuebner
Document the OTP memory found on Rockchip RK3576 SoC.
The RK3576 uses the same set of clocks as the px30/rk3308 but has one reset more, so adapt the binding to handle this variant as well.
Signed-off-by Heiko Stuebner <[email protected]>
Heiko Stuebner
maintainerPATCH RESEND v2 5/6 nvmem: rockchip-otp: add rk3576 variant data
In reply to Heiko StuebnerThe variant works very similar to the rk3588, just with a different read-offset and size.
--- drivers/nvmem/rockchip-otp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/nvmem/rockchip-otp.c +12 -0
@@ -274,6 +274,14 @@ static const struct rockchip_data px30_data = { .reg_read = px30_otp_read, }; +static const struct rockchip_data rk3576_data = { + .size =0x100 , + .read_offset =0x700 , + .clks = px30_otp_clocks, + .num_clks =ARRAY_SIZE (px30_otp_clocks), + .reg_read = rk3588_otp_read, +}; +static const char *const rk3588_otp_clocks[] = {"otp" ,"apb_pclk" ,"phy" ,"arb" , };
@@ -295,6 +303,10 @@ static const struct of_device_id rockchip_otp_match[] = { .compatible = "rockchip,rk3308-otp", .data = &px30_data, }, + { + .compatible = "rockchip,rk3576-otp", + .data = &rk3576_data, + }, { .compatible = "rockchip,rk3588-otp", .data = &rk3588_data,
Signature · 1 line
2.47.2
Heiko Stuebner
maintainerPATCH RESEND v2 6/6 arm64: dts: rockchip: add rk3576 otp node
In reply to Heiko StuebnerThis adds the otp node to the rk3576 soc devicetree including the individual fields we know about.
--- arch/arm64/boot/dts/rockchip/rk3576.dtsi | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
arch/arm64/boot/dts/rockchip/rk3576.dtsi +39 -0
@@ -1260,6 +1260,45 @@ sdhci: mmc@2a330000 { status = "disabled"; }; + otp: otp@2a580000 { + compatible = "rockchip,rk3576-otp"; + reg = <0x0 0x2a580000 0x0 0x400>; + #address-cells = <1>; + #size-cells = <1>; + clocks = <&cru CLK_OTPC_NS>, <&cru PCLK_OTPC_NS>, + <&cru CLK_OTP_PHY_G>; + clock-names = "otp", "apb_pclk", "phy"; + resets = <&cru SRST_OTPC_NS>, <&cru SRST_P_OTPC_NS>; + reset-names = "otp", "apb"; + + /* Data cells */ + cpu_code: cpu-code@2 { + reg = <0x02 0x2>; + }; + otp_cpu_version: cpu-version@5 { + reg = <0x05 0x1>; + bits = <3 3>; + }; + otp_id: id@a { + reg = <0x0a 0x10>; + }; + cpub_leakage: cpub-leakage@1e { + reg = <0x1e 0x1>; + }; + cpul_leakage: cpul-leakage@1f { + reg = <0x1f 0x1>; + }; + npu_leakage: npu-leakage@20 { + reg = <0x20 0x1>; + }; + gpu_leakage: gpu-leakage@21 { + reg = <0x21 0x1>; + }; + log_leakage: log-leakage@22 { + reg = <0x22 0x1>; + }; + }; + gic: interrupt-controller@2a701000 { compatible = "arm,gic-400"; reg = <0x0 0x2a701000 0 0x10000>,
Signature · 1 line
2.47.2
Quoted 25 lines · On Monday, 10 February 2025 23:45:04 Central European Standard Time Heiko…
This enables OTP support in the nvmem driver for rk3576.
I expect to pick the clock patch (patch1) and the arm64-dts patch (patch6) myself, after the nvmem-driver and -binding patches have been applied (patches 2-5).
But kept them together for people wanting to try this series.
changes in v2:
- fix register constant in clock definition (Diederik)
- add patch to set limits on variant-specific clock-names
- use correct limits for clocks + resets on rk3576 bindingRESEND, because I messed up my git-send-email which caused it to include the list of patches 2 times, duplicating everything :-( .
Heiko Stuebner (6):
clk: rockchip: rk3576: defineclk_otp_phy_g
nvmem: rockchip-otp: Move read-offset into variant-data
dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names
dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576
nvmem: rockchip-otp: add rk3576 variant data
arm64: dts: rockchip: add rk3576 otp node
Quoted 5 lines
.../bindings/nvmem/rockchip,otp.yaml | 25 ++++++++++++ arch/arm64/boot/dts/rockchip/rk3576.dtsi | 39 +++++++++++++++++++ drivers/clk/rockchip/clk-rk3576.c | 2 + drivers/nvmem/rockchip-otp.c | 17 +++++++- 4 files changed, 81 insertions(+), 2 deletions(-)
Hi Heiko,
for the entire series:
OTPs show up on my Sige5 RK3576 board and read fine. Also compared the OTP nodes to downstream and the values look consistent with that. The OTPs aren't documented in the TRM I have, so unfortunately I can't cross-reference that.
NB: patchwork's "Series" download for this series somehow lacks patch 2/6, which tripped me up at first. Not sure if that's a problem with patchwork or with how you sent the series out, but I thought I'd let others know who run into this.
Regards,
Nicolas Frattaroli
Heiko Stübner
maintainerAm Mittwoch, 12. Februar 2025, 13:44:15 MEZ schrieb Nicolas Frattaroli:
Quoted 35 lines
Quoted 25 lines · On Monday, 10 February 2025 23:45:04 Central European Standard Time Heiko…
This enables OTP support in the nvmem driver for rk3576.
I expect to pick the clock patch (patch1) and the arm64-dts patch (patch6) myself, after the nvmem-driver and -binding patches have been applied (patches 2-5).
But kept them together for people wanting to try this series.
changes in v2:
- fix register constant in clock definition (Diederik)
- add patch to set limits on variant-specific clock-names
- use correct limits for clocks + resets on rk3576 bindingRESEND, because I messed up my git-send-email which caused it to include the list of patches 2 times, duplicating everything :-( .
Heiko Stuebner (6):
clk: rockchip: rk3576: defineclk_otp_phy_g
nvmem: rockchip-otp: Move read-offset into variant-data
dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names
dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576
nvmem: rockchip-otp: add rk3576 variant data
arm64: dts: rockchip: add rk3576 otp nodeQuoted 5 lines
.../bindings/nvmem/rockchip,otp.yaml | 25 ++++++++++++ arch/arm64/boot/dts/rockchip/rk3576.dtsi | 39 +++++++++++++++++++ drivers/clk/rockchip/clk-rk3576.c | 2 + drivers/nvmem/rockchip-otp.c | 17 +++++++- 4 files changed, 81 insertions(+), 2 deletions(-)Hi Heiko,
Quoted 7 lines
for the entire series:
Tested-by Nicolas Frattaroli <[email protected]>OTPs show up on my Sige5 RK3576 board and read fine. Also compared the OTP nodes to downstream and the values look consistent with that. The OTPs aren't documented in the TRM I have, so unfortunately I can't cross-reference that.
thanks a lot for the testing :-)
Quoted 4 lines
NB: patchwork's "Series" download for this series somehow lacks patch 2/6, which tripped me up at first. Not sure if that's a problem with patchwork or with how you sent the series out, but I thought I'd let others know who run into this.
It looks like patchwork had a bigger hickup with my series. Looking at the cover-letter in the Rockchip area of patchwork, it is missing _all_ patches attached to it [0].
At least on the mainling list, everything seems to have arrived ok [1], so would assume that's a patchwork thing.
[0] https://patchwork.kernel.org/project/linux-rockchip/cover/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
Srinivas Kandagatla
AppliedRe: (subset) [PATCH RESEND v2 0/6] RK3576 OTP support
In reply to Heiko StuebnerQuoted 9 lines · Heiko Stuebner
This enables OTP support in the nvmem driver for rk3576.
I expect to pick the clock patch (patch1) and the arm64-dts patch (patch6) myself, after the nvmem-driver and -binding patches have been applied (patches 2-5).
But kept them together for people wanting to try this series.
[...]
Applied, thanks!
[1/6] clk: rockchip: rk3576: define clk_otp_phy_g
commit: 3e081aa132bbefe31ac95dd6dfc8d787ffa83d0b
[2/6] nvmem: rockchip-otp: Move read-offset into variant-data
commit: 024e21343f3cbcde0343473fcaf094d2c19cc7bf
[3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names
commit: a1bf00100d06ad69286154a63e548ae6f6ce8539
[4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576
commit: 8c94337ebbfb840944574f82df0cbe35930d8df8
[5/6] nvmem: rockchip-otp: add rk3576 variant data
commit: c5ebefe4e20d9fd99ae49cbfd1c18632cf338fa5Best regards,
Signature · 1 line
Srinivas Kandagatla <[email protected]>
Heiko Stübner
maintainerRe: (subset) [PATCH RESEND v2 0/6] RK3576 OTP support
Hi,
Am Montag, 17. Februar 2025, 10:53:16 MEZ schrieb Srinivas Kandagatla:
Quoted 8 lines · Heiko Stuebner
Quoted 6 lines
This enables OTP support in the nvmem driver for rk3576.
I expect to pick the clock patch (patch1) and the arm64-dts patch (patch6) myself, after the nvmem-driver and -binding patches have been applied (patches 2-5).
Quoted 8 lines
Quoted 3 lines
But kept them together for people wanting to try this series.
[...]
Applied, thanks!
[1/6] clk: rockchip: rk3576: define
clk_otp_phy_gcommit: 3e081aa132bbefe31ac95dd6dfc8d787ffa83d0b
the applied message says you picked the clock patch, but it's not in your tree - probably because you realized that it's a clock patch? :-)
So just to make sure it doesn't land in two trees, I should probably pick up the patch for the Rockchip clock driver, right?
Thanks a lot
Heiko
Quoted 11 lines
[2/6] nvmem: rockchip-otp: Move read-offset into variant-data
commit: 024e21343f3cbcde0343473fcaf094d2c19cc7bf [3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names commit: a1bf00100d06ad69286154a63e548ae6f6ce8539 [4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576 commit: 8c94337ebbfb840944574f82df0cbe35930d8df8 [5/6] nvmem: rockchip-otp: add rk3576 variant data commit: c5ebefe4e20d9fd99ae49cbfd1c18632cf338fa5Best regards,
Re: (subset) [PATCH RESEND v2 0/6] RK3576 OTP support
In reply to Heiko StuebnerQuoted 9 lines · Heiko Stuebner
This enables OTP support in the nvmem driver for rk3576.
I expect to pick the clock patch (patch1) and the arm64-dts patch (patch6) myself, after the nvmem-driver and -binding patches have been applied (patches 2-5).
But kept them together for people wanting to try this series.
[...]
Applied, thanks!
[6/6] arm64: dts: rockchip: add rk3576 otp node
Best regards,
Signature · 1 line
Heiko Stuebner <[email protected]>
Re: (subset) [PATCH RESEND v2 0/6] RK3576 OTP support
In reply to Heiko StuebnerQuoted 9 lines · Heiko Stuebner
This enables OTP support in the nvmem driver for rk3576.
I expect to pick the clock patch (patch1) and the arm64-dts patch (patch6) myself, after the nvmem-driver and -binding patches have been applied (patches 2-5).
But kept them together for people wanting to try this series.
[...]
Applied, thanks!
[1/6] clk: rockchip: rk3576: define clk_otp_phy_g
commit: d934a93bbcccd551c142206b8129903d18126261
While the original nvmem applied message [0] listed the clock patch, it was in fact not applied there - probable for being a clock patch.
So I've done that now, hopefully as fix for 6.15 to make the nvmem work in this timeframe.
[0] https://lore.kernel.org/linux-arm-kernel/[email protected]/
Best regards,
Signature · 1 line
Heiko Stuebner <[email protected]>