mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/6] RK3576 OTP support
@ 2025-02-10 22:32 Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g Heiko Stuebner
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

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

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(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 2/6] nvmem: rockchip-otp: Move read-offset into variant-data Heiko Stuebner
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

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.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/clk/rockchip/clk-rk3576.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/rockchip/clk-rk3576.c b/drivers/clk/rockchip/clk-rk3576.c
index 595e010341f7..be703f250197 100644
--- a/drivers/clk/rockchip/clk-rk3576.c
+++ b/drivers/clk/rockchip/clk-rk3576.c
@@ -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),
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 2/6] nvmem: rockchip-otp: Move read-offset into variant-data
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names Heiko Stuebner
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

The 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.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/nvmem/rockchip-otp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c
index ebc3f0b24166..3edfbfc2d722 100644
--- a/drivers/nvmem/rockchip-otp.c
+++ b/drivers/nvmem/rockchip-otp.c
@@ -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,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 2/6] nvmem: rockchip-otp: Move read-offset into variant-data Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576 Heiko Stuebner
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel, Krzysztof Kozlowski

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 <krzk@kernel.org>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml b/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
index a44d44b32809..3201ff8f9334 100644
--- a/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
@@ -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:
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (2 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 5/6] nvmem: rockchip-otp: add rk3576 variant data Heiko Stuebner
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

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 <heiko@sntech.de>
---
 .../bindings/nvmem/rockchip,otp.yaml          | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml b/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
index 3201ff8f9334..dc89020b0950 100644
--- a/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
@@ -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:
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 5/6] nvmem: rockchip-otp: add rk3576 variant data
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (3 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576 Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 6/6] arm64: dts: rockchip: add rk3576 otp node Heiko Stuebner
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

The variant works very similar to the rk3588, just with a different
read-offset and size.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/nvmem/rockchip-otp.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c
index 3edfbfc2d722..d88f12c53242 100644
--- a/drivers/nvmem/rockchip-otp.c
+++ b/drivers/nvmem/rockchip-otp.c
@@ -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,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 6/6] arm64: dts: rockchip: add rk3576 otp node
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (4 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 5/6] nvmem: rockchip-otp: add rk3576 variant data Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

This adds the otp node to the rk3576 soc devicetree including the
individual fields we know about.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 arch/arm64/boot/dts/rockchip/rk3576.dtsi | 39 ++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3576.dtsi b/arch/arm64/boot/dts/rockchip/rk3576.dtsi
index 4dde954043ef..29b47799849a 100644
--- a/arch/arm64/boot/dts/rockchip/rk3576.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3576.dtsi
@@ -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>,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 0/6] RK3576 OTP support
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (5 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 6/6] arm64: dts: rockchip: add rk3576 otp node Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g Heiko Stuebner
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

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

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(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (6 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 2/6] nvmem: rockchip-otp: Move read-offset into variant-data Heiko Stuebner
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

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.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/clk/rockchip/clk-rk3576.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/clk/rockchip/clk-rk3576.c b/drivers/clk/rockchip/clk-rk3576.c
index 595e010341f7..be703f250197 100644
--- a/drivers/clk/rockchip/clk-rk3576.c
+++ b/drivers/clk/rockchip/clk-rk3576.c
@@ -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),
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 2/6] nvmem: rockchip-otp: Move read-offset into variant-data
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (7 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names Heiko Stuebner
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

The 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.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/nvmem/rockchip-otp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c
index ebc3f0b24166..3edfbfc2d722 100644
--- a/drivers/nvmem/rockchip-otp.c
+++ b/drivers/nvmem/rockchip-otp.c
@@ -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,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (8 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 2/6] nvmem: rockchip-otp: Move read-offset into variant-data Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576 Heiko Stuebner
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel, Krzysztof Kozlowski

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 <krzk@kernel.org>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml b/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
index a44d44b32809..3201ff8f9334 100644
--- a/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
@@ -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:
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (9 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 5/6] nvmem: rockchip-otp: add rk3576 variant data Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 6/6] arm64: dts: rockchip: add rk3576 otp node Heiko Stuebner
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

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 <heiko@sntech.de>
---
 .../bindings/nvmem/rockchip,otp.yaml          | 21 +++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml b/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
index 3201ff8f9334..dc89020b0950 100644
--- a/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
+++ b/Documentation/devicetree/bindings/nvmem/rockchip,otp.yaml
@@ -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:
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 5/6] nvmem: rockchip-otp: add rk3576 variant data
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (10 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576 Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  2025-02-10 22:32 ` [PATCH v2 6/6] arm64: dts: rockchip: add rk3576 otp node Heiko Stuebner
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

The variant works very similar to the rk3588, just with a different
read-offset and size.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/nvmem/rockchip-otp.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/nvmem/rockchip-otp.c b/drivers/nvmem/rockchip-otp.c
index 3edfbfc2d722..d88f12c53242 100644
--- a/drivers/nvmem/rockchip-otp.c
+++ b/drivers/nvmem/rockchip-otp.c
@@ -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,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v2 6/6] arm64: dts: rockchip: add rk3576 otp node
  2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
                   ` (11 preceding siblings ...)
  2025-02-10 22:32 ` [PATCH v2 5/6] nvmem: rockchip-otp: add rk3576 variant data Heiko Stuebner
@ 2025-02-10 22:32 ` Heiko Stuebner
  12 siblings, 0 replies; 14+ messages in thread
From: Heiko Stuebner @ 2025-02-10 22:32 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: robh, krzk+dt, conor+dt, heiko, devicetree, linux-arm-kernel,
	linux-rockchip, linux-kernel, linux-clk, detlev.casanova,
	sebastian.reichel

This adds the otp node to the rk3576 soc devicetree including the
individual fields we know about.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 arch/arm64/boot/dts/rockchip/rk3576.dtsi | 39 ++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3576.dtsi b/arch/arm64/boot/dts/rockchip/rk3576.dtsi
index 4dde954043ef..29b47799849a 100644
--- a/arch/arm64/boot/dts/rockchip/rk3576.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3576.dtsi
@@ -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>,
-- 
2.47.2


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-02-10 22:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-10 22:32 [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 2/6] nvmem: rockchip-otp: Move read-offset into variant-data Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576 Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 5/6] nvmem: rockchip-otp: add rk3576 variant data Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 6/6] arm64: dts: rockchip: add rk3576 otp node Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 0/6] RK3576 OTP support Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 1/6] clk: rockchip: rk3576: define clk_otp_phy_g Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 2/6] nvmem: rockchip-otp: Move read-offset into variant-data Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 3/6] dt-bindings: nvmem: rockchip,otp: add missing limits for clock-names Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 4/6] dt-bindings: nvmem: rockchip,otp: Add compatible for RK3576 Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 5/6] nvmem: rockchip-otp: add rk3576 variant data Heiko Stuebner
2025-02-10 22:32 ` [PATCH v2 6/6] arm64: dts: rockchip: add rk3576 otp node Heiko Stuebner

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®