Skip to contentSkip to conversation

R-Car X5H CPG/MDLC support

PATCH In review Geert Uytterhoeven 7 participants 27 messages Jul 8 – Jul 16

Subsystems (5)
lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

v2 cover R-Car X5H CPG/MDLC support

Hi all,

This patch series adds minimal support for the Renesas R-Car X5H Clock Pulse Generator (CPG) and Module Controller (MDLC), to aim for replacing the dummy clocks in r8a78000.dtsi with proper hardware description. These two components are closely related, in the sense that they are both supposed to be accessed through the ARM System Control and Management Interface (SCMI) on the Ironhide development board.

This series consists of three parts:
1. Patches 1-2 add DT bindings and DT binding definitions,
2. Patches 3-4 add minimal CPG and MDLC drivers,
3. Patches 5-6 update the DTS.

Some of these patches have been sent before as part of "[PATCH/RFC 00/14] R-Car X5H Ironhide SCMI CPG/MDLC remapping"[1], hence the v2. However, this series does not use or rely on SCMI in any way.

Major changes compared to v1[1] (more detail in the individual patches):
- Add default support not using SCMI,
- Drop everything related to SCMI.

SCMI remapping support will be added in a subsequent series[2]. Full hardware support without using SCMI could be added, too, if anyone would care about that use case.

For testing, I have pushed this series plus additional work to[3].

Thanks for your comments!

[1] "[PATCH/RFC 00/14] R-Car X5H Ironhide SCMI CPG/MDLC remapping"

    https://lore.kernel.org/[email protected]
[2] "[PATCH v2 00/10] R-Car X5H Ironhide CPG/MDLC SCMI remapping support"
    https://lore.kernel.org/[email protected]

[3] topic/rcar-x5h-ironhide-scmi-cpg-mdlc-remapping-v2 branch of
https://git.kernel.org/pub/scm/linux/kernel/git/geert/renesas-drivers.git

Geert Uytterhoeven (6):
dt-bindings: clock: Document Renesas R-Car X5H Clock Pulse Generator
dt-bindings: power: Document Renesas R-Car X5H Module Controller
clk: renesas: Add R-Car X5H CPG driver
pmdomain: renesas: Add R-Car X5H MDLC driver
arm64: dts: renesas: r8a78000: Add CPG node
arm64: dts: renesas: r8a78000: Add MDLC nodes

 .../bindings/clock/renesas,r8a78000-cpg.yaml  |  55 +++
 .../bindings/power/renesas,r8a78000-mdlc.yaml |  61 ++++
 arch/arm64/boot/dts/renesas/r8a78000.dtsi     | 300 ++++++++++++++--
 drivers/clk/renesas/Kconfig                   |   4 +
 drivers/clk/renesas/Makefile                  |   1 +
 drivers/clk/renesas/r8a78000-cpg.c            | 216 ++++++++++++
 drivers/pmdomain/renesas/Kconfig              |   4 +
 drivers/pmdomain/renesas/Makefile             |   1 +
 drivers/pmdomain/renesas/r8a78000-mdlc.c      | 329 ++++++++++++++++++
 drivers/soc/renesas/Kconfig                   |   1 +
 .../dt-bindings/clock/renesas,r8a78000-cpg.h  |  14 +
 .../dt-bindings/power/renesas,r8a78000-mdlc.h |  15 +
 12 files changed, 976 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/renesas,r8a78000-cpg.yaml
 create mode 100644 Documentation/devicetree/bindings/power/renesas,r8a78000-mdlc.yaml
 create mode 100644 drivers/clk/renesas/r8a78000-cpg.c
 create mode 100644 drivers/pmdomain/renesas/r8a78000-mdlc.c
 create mode 100644 include/dt-bindings/clock/renesas,r8a78000-cpg.h
 create mode 100644 include/dt-bindings/power/renesas,r8a78000-mdlc.h
Signature · 12 lines
2.43.0

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds
author maintainer
#1 lore raw

PATCH v2 1/6 dt-bindings: clock: Document Renesas R-Car X5H Clock Pulse Generator

Document support for the Renesas R-Car X5H Clock Pulse Generator, and add binding definitions for a limited initial set of clocks.

---
v2:
- Add Reviewed-by, Tested-by,
- Drop preliminary,
- Expand CPG acronym,
- Drop R8A78000_CPG_MSOCK_PERW_BUS,
- Add R8A78000_CPG_SGASYNCD8_PERW_BUS, to avoid holes in the SGASYNCDn_PERW_BUS sequence,
- Drop firmware property.

---
 .../bindings/clock/renesas,r8a78000-cpg.yaml  | 55 +++++++++++++++++++
 .../dt-bindings/clock/renesas,r8a78000-cpg.h  | 14 +++++
 2 files changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/renesas,r8a78000-cpg.yaml
 create mode 100644 include/dt-bindings/clock/renesas,r8a78000-cpg.h
Documentation/devicetree/bindings/clock/renesas,r8a78000-cpg.yaml new file +55 -0
new file mode 100644
index 0000000000000000..4e23bba334382346
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/renesas,r8a78000-cpg.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas R-Car X5H Clock Pulse Generator
+
+maintainers:
+  - Geert Uytterhoeven <[email protected]>
+
+description:
+  The R-Car X5H Clock Pulse Generator (CLK CONTROL) consists of oscillators,
+  PLL circuits, clock dividers and clock control circuits.  It provides various
+  clocks for other modules.
+
+properties:
+  compatible:
+    const: renesas,r8a78000-cpg
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 2
+
+  clock-names:
+    items:
+      - const: extal
+      - const: extalr
+
+  '#clock-cells':
+    description:
+      The single clock specifier cell must be the clock number, as defined in
+      <dt-bindings/clock/renesas,r8a78000-cpg.h>.
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@c1320000 {
+            compatible = "renesas,r8a78000-cpg";
+            reg = <0xc1320000 0x10000>;
+            clocks = <&extal_clk>, <&extalr_clk>;
+            clock-names = "extal", "extalr";
+            #clock-cells = <1>;
+    };
include/dt-bindings/clock/renesas,r8a78000-cpg.h new file +14 -0
new file mode 100644
index 0000000000000000..7fd09a3fb353d952
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) 2026 Glider bv
+ */
+#ifndef __DT_BINDINGS_CLOCK_RENESAS_R8A78000_CPG_H__
+#define __DT_BINDINGS_CLOCK_RENESAS_R8A78000_CPG_H__
+
+/* R-Car X5H Clock Pulse Generator Clocks */
+
+#define R8A78000_CPG_SGASYNCD4_PERW_BUS		0
+#define R8A78000_CPG_SGASYNCD8_PERW_BUS		1
+#define R8A78000_CPG_SGASYNCD16_PERW_BUS	2
+
+#endif /* __DT_BINDINGS_CLOCK_RENESAS_R8A78000_CPG_H__ */
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v2 2/6 dt-bindings: power: Document Renesas R-Car X5H Module Controller

In reply to Geert Uytterhoeven

Document support for Renesas R-Car X5H Module Controllers, and add binding definitions for power domains not backed by registers.

---
v2:
- Clarify the meaning of the two power domain cells and the reset cell,
- Drop R8A78000_MDLC_PD_CMN, as CMN is backed by MDPG bits,
- Expand MDLC acronym,
- Add a comment stating that all R8A78000_MDLC_PD_* definitions are for always-on power domains,
- Drop firmware property.

---
 .../bindings/power/renesas,r8a78000-mdlc.yaml | 61 +++++++++++++++++++
 .../dt-bindings/power/renesas,r8a78000-mdlc.h | 15 +++++
 2 files changed, 76 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/renesas,r8a78000-mdlc.yaml
 create mode 100644 include/dt-bindings/power/renesas,r8a78000-mdlc.h
Documentation/devicetree/bindings/power/renesas,r8a78000-mdlc.yaml new file +61 -0
new file mode 100644
index 0000000000000000..1dba1e1b1c5b52d0
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/renesas,r8a78000-mdlc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Renesas R-Car X5H Module Controller
+
+maintainers:
+  - Geert Uytterhoeven <[email protected]>
+
+description:
+  Each instance of the R-Car X5H Module Controller (MODULE CONTROL) provides
+  Power Gating for up to 64 Power Domains, and Module Standby and Reset for up
+  to 256 modules in the Power Domain of each Module hierarchy.
+
+properties:
+  compatible:
+    const: renesas,r8a78000-mdlc
+
+  reg:
+    maxItems: 1
+
+  '#power-domain-cells':
+    description: |
+      - The first power domain specifier cell is the power domain part, and
+        must be either the Module Power Domain Gating (MPDG) register index
+        (0x00-0x3f) from the datasheet, for power domains which are backed by
+        MPDG bits and which can be controlled in that manner,  or a Power
+        Domain number, as defined in
+        <dt-bindings/power/renesas,r8a78000-mdlc.h>, for power domains which
+        are always on, and for which there are no MPDG bits to control them.
+
+      - The second power domain specifier cell is the module standby part, and
+        must be the module number (0x00-0xff), composed of the Module System
+        Reset (MSRES) register index in the high nibble, and the Module Reset
+        Destination bitfield index in the low nibble.
+    const: 2
+
+  '#reset-cells':
+    description:
+      The single reset specifier cell must be the module number (0x00-0xff),
+      and thus identical to the second power domain specifier cell.
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - '#power-domain-cells'
+  - '#reset-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    system-controller@c3060000 {
+            compatible = "renesas,r8a78000-mdlc";
+            reg = <0xc3060000 0x1000>;
+            #power-domain-cells = <2>;
+            #reset-cells = <1>;
+    };
include/dt-bindings/power/renesas,r8a78000-mdlc.h new file +15 -0
new file mode 100644
index 0000000000000000..6f3d1ae23648e55b
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (C) 2026 Glider bv
+ */
+#ifndef __DT_BINDINGS_POWER_RENESAS_R8A78000_MDLC_H__
+#define __DT_BINDINGS_POWER_RENESAS_R8A78000_MDLC_H__
+
+/* R-Car X5H Module Controller Always-On Power Domains */
+
+#define R8A78000_MDLC_PD_AON			0x40
+#define R8A78000_MDLC_PD_SCP			0x41
+#define R8A78000_MDLC_PD_APL			0x42
+#define R8A78000_MDLC_PD_ACL			0x43
+
+#endif /* __DT_BINDINGS_POWER_RENESAS_R8A78000_MDLC_H__ */
Signature · 1 line
2.43.0
author maintainer
#6 lore raw

PATCH v2 3/6 clk: renesas: Add R-Car X5H CPG driver

In reply to Geert Uytterhoeven

Add a minimal Clock Pulse Generator driver for the R-Car X5H (R8A78000) SoC. For now this supports just the few fixed-rate clocks that are needed by the current minimal DTS.

---
v2:
- Spin off from "clk: renesas: Add R-Car X5H CPG SCMI remapping driver",
- Add default support not using SCMI,
- Drop all SCMI remapping support,
- Document use of -1 as a sentinel,
- Document use of FIXED_CLK() IDs.

---
 drivers/clk/renesas/Kconfig        |   4 +
 drivers/clk/renesas/Makefile       |   1 +
 drivers/clk/renesas/r8a78000-cpg.c | 216 +++++++++++++++++++++++++++++
 3 files changed, 221 insertions(+)
 create mode 100644 drivers/clk/renesas/r8a78000-cpg.c
drivers/clk/renesas/Kconfig +4 -0
index 0203ecbb38825f13..f0482bdfc4616cfa 100644
@@ -34,6 +34,7 @@ config CLK_RENESAS
 	select CLK_R8A779F0 if ARCH_R8A779F0
 	select CLK_R8A779G0 if ARCH_R8A779G0
 	select CLK_R8A779H0 if ARCH_R8A779H0
+	select CLK_R8A78000 if ARCH_R8A78000
 	select CLK_R9A06G032 if ARCH_R9A06G032
 	select CLK_R9A07G043 if ARCH_R9A07G043
 	select CLK_R9A07G044 if ARCH_R9A07G044
@@ -176,6 +177,9 @@ config CLK_R8A779H0
 	bool "R-Car V4M clock support" if COMPILE_TEST
 	select CLK_RCAR_GEN4_CPG
 
+config CLK_R8A78000
+	bool "R-Car X5H clock support" if COMPILE_TEST
+
 config CLK_R9A06G032
 	bool "RZ/N1D clock support" if COMPILE_TEST
 
drivers/clk/renesas/Makefile +1 -0
index bd2bed91ab291d72..4f76f8c402ffe9a3 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_CLK_R8A779A0)		+= r8a779a0-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A779F0)		+= r8a779f0-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A779G0)		+= r8a779g0-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A779H0)		+= r8a779h0-cpg-mssr.o
+obj-$(CONFIG_CLK_R8A78000)		+= r8a78000-cpg.o
 obj-$(CONFIG_CLK_R9A06G032)		+= r9a06g032-clocks.o
 obj-$(CONFIG_CLK_R9A07G043)		+= r9a07g043-cpg.o
 obj-$(CONFIG_CLK_R9A07G044)		+= r9a07g044-cpg.o
drivers/clk/renesas/r8a78000-cpg.c new file +216 -0

216 lines not on this page · raw message

Signature · 1 line
2.43.0
#7 lore raw

Re: [PATCH v2 3/6] clk: renesas: Add R-Car X5H CPG driver

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Memory and clock registration leak if `devm_kasprintf()` fails during fixed clock registration. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Memory and clock registration leak if devm_kasprintf() fails during fixed clock registration. --

--- Patch [3]: [PATCH v2 3/6] clk: renesas: Add R-Car X5H CPG driver --- commit 1d0eaa24ed7151f3cc9ee126c74cd79bec68356e

Author: Geert Uytterhoeven <[email protected]>
Date:   Wed Jul 8 10:15:08 2026 +0000

clk: renesas: Add R-Car X5H CPG driver

This patch adds a minimal Clock Pulse Generator driver for the R-Car X5H (R8A78000) SoC. It provides support for the fixed-rate clocks needed by the current minimal DTS.

Quoted 4 lines
drivers/clk/renesas/r8a78000-cpg.c new file +0 -0
new file mode 100644

[ ... ]

drivers/clk/renesas/r8a78000-cpg.c line 118

Quoted 12 lines
drivers/clk/renesas/r8a78000-cpg.c new file +12 -0
+static int register_fixed_clks(struct r8a78000_cpg_priv *priv)
+{
+	struct device *dev = priv->dev;
+	unsigned long rate;
+	struct clk_hw *hw;
+	const char *name;
+
+	for (unsigned int i = 0; i < ARRAY_SIZE(fixed_clk_rates); i++) {
+		rate = fixed_clk_rates[i];
+		name = devm_kasprintf(dev, GFP_KERNEL, "cpg-%lu", rate);
+		if (!name)
+			return -ENOMEM;

[Severity: Medium]
If devm_kasprintf() fails on a later iteration, does this return statement leak the clocks that were successfully registered in previous iterations?

The cleanup loop for clk_hw_unregister_fixed_rate() is only executed if clk_hw_register_fixed_rate() fails, and the devres action to unregister the clocks is not added until the end of the function.

Quoted 13 lines
drivers/clk/renesas/r8a78000-cpg.c new file +13 -0
+
+		hw = clk_hw_register_fixed_rate(dev, name, NULL, 0, rate);
+		if (IS_ERR(hw)) {
+			while (i-- > 0)
+				clk_hw_unregister_fixed_rate(priv->fixed_hws[i]);
+			return PTR_ERR(hw);
+		}
+
+		priv->fixed_hws[i] = hw;
+	}
+
+	return devm_add_action_or_reset(dev, unregister_fixed_clks, priv);
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#8 lore raw

Re: [PATCH v2 3/6] clk: renesas: Add R-Car X5H CPG driver

In reply to Geert Uytterhoeven

On 7/8/26 12:15 PM, Geert Uytterhoeven wrote:

[...]

Quoted 4 lines
drivers/clk/renesas/r8a78000-cpg.c new file +4 -0
+static int register_fixed_clks(struct r8a78000_cpg_priv *priv)
+{
+	struct device *dev = priv->dev;
+	unsigned long rate;

drivers/clk/renesas/r8a78000-cpg.c line 120

Quoted 10 lines
drivers/clk/renesas/r8a78000-cpg.c new file +10 -0
+	struct clk_hw *hw;
+	const char *name;
+
+	for (unsigned int i = 0; i < ARRAY_SIZE(fixed_clk_rates); i++) {
+		rate = fixed_clk_rates[i];
+		name = devm_kasprintf(dev, GFP_KERNEL, "cpg-%lu", rate);
+		if (!name)
+			return -ENOMEM;
+
+		hw = clk_hw_register_fixed_rate(dev, name, NULL, 0, rate);

Would it be viable to use devm_clk_hw_register_fixed_rate() here ?

Quoted 11 lines
drivers/clk/renesas/r8a78000-cpg.c new file +11 -0
+		if (IS_ERR(hw)) {
+			while (i-- > 0)
+				clk_hw_unregister_fixed_rate(priv->fixed_hws[i]);
+			return PTR_ERR(hw);
+		}
+
+		priv->fixed_hws[i] = hw;
+	}
+
+	return devm_add_action_or_reset(dev, unregister_fixed_clks, priv);
+}

[...]

#9 lore raw

Re: [PATCH v2 3/6] clk: renesas: Add R-Car X5H CPG driver

Hi Marek,

Quoted 17 lines · Marek Vasut
Quoted 4 lines · Geert Uytterhoeven
drivers/clk/renesas/r8a78000-cpg.c new file +4 -0
+static int register_fixed_clks(struct r8a78000_cpg_priv *priv)
+{
+     struct device *dev = priv->dev;
+     unsigned long rate;

drivers/clk/renesas/r8a78000-cpg.c line 120

Quoted 10 lines
drivers/clk/renesas/r8a78000-cpg.c new file +10 -0
+     struct clk_hw *hw;
+     const char *name;
+
+     for (unsigned int i = 0; i < ARRAY_SIZE(fixed_clk_rates); i++) {
+             rate = fixed_clk_rates[i];
+             name = devm_kasprintf(dev, GFP_KERNEL, "cpg-%lu", rate);
+             if (!name)
+                     return -ENOMEM;
+
+             hw = clk_hw_register_fixed_rate(dev, name, NULL, 0, rate);

Would it be viable to use devm_clk_hw_register_fixed_rate() here ?

Yes, I think so; thanks!

Quoted 10 lines

drivers/clk/renesas/r8a78000-cpg.c line 130

Quoted 10 lines
drivers/clk/renesas/r8a78000-cpg.c new file +10 -0
+             if (IS_ERR(hw)) {
+                     while (i-- > 0)
+                             clk_hw_unregister_fixed_rate(priv->fixed_hws[i]);
+                     return PTR_ERR(hw);
+             }
+
+             priv->fixed_hws[i] = hw;
+     }
+
+     return devm_add_action_or_reset(dev, unregister_fixed_clks, priv);

And then this, and unregister_fixed_clks() can go, and r8a78000_cpg_priv.fixed_hws[] is no longer needed after probe.

Quoted 1 line
Quoted 1 line

+}

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#10 lore raw

Re: [PATCH v2 3/6] clk: renesas: Add R-Car X5H CPG driver

In reply to Geert Uytterhoeven

Hello Geert,

Quoted 1 line · Geert Uytterhoeven

+#include <linux/mod_devicetable.h>

Please don't add new users for this header file. Only use those <linux/device-id/*.h> that you actually need (if any).

Ditto for patch 4.

Thanks
Uwe

#11 lore raw

Re: [PATCH v2 3/6] clk: renesas: Add R-Car X5H CPG driver

Hi Uwe,

Quoted 7 lines · Uwe Kleine-König
Quoted 1 line · Geert Uytterhoeven

+#include <linux/mod_devicetable.h>

Please don't add new users for this header file. Only use those <linux/device-id/*.h> that you actually need (if any).

Ditto for patch 4.

Thanks, will do after the rebase to v7.2-rc3 ;-)

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author maintainer
#12 lore raw

PATCH v2 4/6 pmdomain: renesas: Add R-Car X5H MDLC driver

In reply to Geert Uytterhoeven

Add a minimal Module Controller driver for the R-Car X5H (R8A78000) SoC. For now this just supports the always-on power domains, and dummy clocks and resets for the serial console (which is enabled by the boot loader).

---
Calling genpd_add_provider() instead of of_genpd_add_provider_onecell() would be sufficient, but the former is private.

v2:
- Spin off from "pmdomain: renesas: Add R-Car X5H MDLC SCMI remapping driver",
- Add default support not using SCMI,
- Drop all SCMI remapping support,
- Document use of -1 as a sentinel,
- Rename struct r8a78000_mdlc_info to mdlc_info,
- Print HW IDs in hexadecimal,
- Reduce log level for unsupported MDLC instances from warn to dbg,

---
 drivers/pmdomain/renesas/Kconfig         |   4 +
 drivers/pmdomain/renesas/Makefile        |   1 +
 drivers/pmdomain/renesas/r8a78000-mdlc.c | 329 +++++++++++++++++++++++
 drivers/soc/renesas/Kconfig              |   1 +
 4 files changed, 335 insertions(+)
 create mode 100644 drivers/pmdomain/renesas/r8a78000-mdlc.c
drivers/pmdomain/renesas/Kconfig +4 -0
index b507c3e0d723efc6..f2f52d3c29a083f1 100644
@@ -13,6 +13,10 @@ config SYSC_RMOBILE
 	bool "System Controller support for R-Mobile" if COMPILE_TEST
 
 # SoC
+config MDLC_R8A78000
+	bool "Module Controller support for R8A78000 (R-Car X5H)" if COMPILE_TEST
+	select RESET_CONTROLLER
+
 config SYSC_R8A7742
 	bool "System Controller support for R8A7742 (RZ/G1H)" if COMPILE_TEST
 	select SYSC_RCAR
drivers/pmdomain/renesas/Makefile +1 -0
index 0391e6e67440a786..17849aad37a5ac4f 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # SoC
+obj-$(CONFIG_MDLC_R8A78000)	+= r8a78000-mdlc.o
 obj-$(CONFIG_SYSC_R8A7742)	+= r8a7742-sysc.o
 obj-$(CONFIG_SYSC_R8A7743)	+= r8a7743-sysc.o
 obj-$(CONFIG_SYSC_R8A7745)	+= r8a7745-sysc.o
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +329 -0

329 lines not on this page · raw message

drivers/soc/renesas/Kconfig +1 -0
index 2ab150d04bb1f1ef..d4055250de72f1fe 100644
@@ -358,6 +358,7 @@ config ARCH_R8A78000
 	default y if ARCH_RENESAS
 	default ARCH_RENESAS
 	select ARCH_RCAR_GEN5
+	select MDLC_R8A78000
 	help
 	  This enables support for the Renesas R-Car X5H SoC.
 
Signature · 1 line
2.43.0
#13 lore raw

Re: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider: - [High] Hardcoded index `0` in `of_parse_phandle_with_args()` breaks consumer devices attached to multiple…

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Hardcoded index 0 in of_parse_phandle_with_args() breaks consumer devices attached to multiple power domains.
- [High] Use-After-Free of priv due to premature release of r8a78000_mdlc_lock.
- [High] AB-BA deadlock (lockdep splat) between r8a78000_mdlc_lock and the global gpd_list_lock.
- [Medium] Missing dummy clocks despite claims in the commit message.
--

--- Patch [4]: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver --- commit 1970ea51b8c9b00b6533ff3db2920ecb99d83f17
Author: Geert Uytterhoeven <[email protected]>

pmdomain: renesas: Add R-Car X5H MDLC driver

This adds a minimal Module Controller driver for the R-Car X5H (R8A78000) SoC. It provides support for always-on power domains and dummy resets for the serial console.

Quoted 2 lines

For now this just supports the always-on power domains, and dummy clocks and resets for the serial console (which is enabled by the boot loader).

[Severity: Medium]
The commit message mentions adding dummy clocks, but looking at r8a78000_mdlc_probe(), it appears only the genpd and reset controller providers are registered. Will consumers defer indefinitely if they attempt to use this driver as a clock provider?

Quoted 5 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +0 -0
new file mode 100644
index 0000000000000..ed367e921a334

[ ... ]

drivers/pmdomain/renesas/r8a78000-mdlc.c line 147

Quoted 12 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +12 -0
+static int r8a78000_mdlc_attach_dev(struct generic_pm_domain *domain,
+				    struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+	struct r8a78000_mdlc_priv *priv;
+	struct of_phandle_args pd_spec;
+	const struct mod_map *map;
+	unsigned int id;
+	int ret;
+
+	ret = of_parse_phandle_with_args(np, "power-domains",
+					 "#power-domain-cells", 0, &pd_spec);

[Severity: High]
Is it possible for a consumer device to have multiple power domains configured in its device tree (e.g., <&sysc 1>, <&mdlc 2>)? If the MDLC domain is not the first one in the property, won't this hardcoded index of 0 fail to find the correct provider and cause the consumer probe to fail with -ENODEV?

Quoted 15 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +15 -0
+	if (ret < 0)
+		return ret;
+
+	if (pd_spec.args_count != 2) {
+		of_node_put(pd_spec.np);
+		return -EINVAL;
+	}
+
+	scoped_guard(mutex, &r8a78000_mdlc_lock) {
+		hlist_for_each_entry(priv, &r8a78000_mdlc_list, link) {
+			if (priv->np == pd_spec.np)
+				break;
+		}
+	}
+

drivers/pmdomain/renesas/r8a78000-mdlc.c line 172

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+	if (!priv) {
+		dev_err(dev, "%s: MDLC %pOF not found\n", __func__, pd_spec.np);
+		of_node_put(pd_spec.np);
+		return -ENODEV;
+	}
+
+	id = pd_spec.args[1];
+	of_node_put(pd_spec.np);
+
+	map = mod_map_find(priv->mod_map, id);

[Severity: High]
Could priv be freed before we dereference it here? The lock protecting the r8a78000_mdlc_list is released at the end of the scoped_guard() block above.

If the provider's probe fails or the driver is unbound concurrently, r8a78000_mdlc_unlink() will acquire the lock, remove priv from the list, and free the memory. Since we access priv->mod_map here without holding the lock, does this introduce a use-after-free window?

Quoted 4 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +4 -0
+	if (!map) {
+		dev_err(dev, "Unknown module 0x%x\n", id);
+		return -ENOENT;
+	}

[ ... ]

Quoted 8 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +8 -0
+static int r8a78000_genpd_always_on_singleton(struct device *dev)
+{
+	struct generic_pm_domain *genpd;
+	int ret;
+
+	guard(mutex)(&r8a78000_mdlc_lock);
+
+	if (r8a78000_genpd_always_on)

drivers/pmdomain/renesas/r8a78000-mdlc.c line 213

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+		return 0;
+
+	genpd = kzalloc_obj(*genpd);
+	if (!genpd)
+		return -ENOMEM;
+
+	genpd->name = "always-on";
+	genpd->attach_dev = r8a78000_mdlc_attach_dev;
+
+	ret = pm_genpd_init(genpd, &pm_domain_always_on_gov, false);

[Severity: High]
Will this sequence trigger a lockdep splat?

During this first probe, r8a78000_genpd_always_on_singleton() acquires r8a78000_mdlc_lock and calls pm_genpd_init(), which acquires the global gpd_list_lock. This establishes r8a78000_mdlc_lock -> gpd_list_lock.

Later, when a consumer device attaches, the PM domain core calls r8a78000_mdlc_attach_dev() with gpd_list_lock held. That function then acquires r8a78000_mdlc_lock via the scoped_guard() block, completing an inverse lock order.

Should pm_genpd_init() be called outside the r8a78000_mdlc_lock critical section to avoid this?

Quoted 9 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +9 -0
+	if (ret) {
+		kfree(genpd);
+		return dev_err_probe(dev, ret,
+				     "Failed to create always-on domain\n");
+	}
+
+	r8a78000_genpd_always_on = genpd;
+	return 0;
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#14 lore raw

Re: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver

In reply to Geert Uytterhoeven

On 7/8/26 12:15 PM, Geert Uytterhoeven wrote:

[...]

drivers/soc/renesas/Kconfig config ARCH_R8A78000 · line 359

Quoted 7 lines
drivers/soc/renesas/Kconfig +0 -0
index 2ab150d04bb1f1ef..d4055250de72f1fe 100644
@@ -358,6 +358,7 @@ config ARCH_R8A78000
  	default y if ARCH_RENESAS
  	default ARCH_RENESAS

I know this ^ is not related to this patch, but is the "default y" and "default ARCH_RENESAS" above valid ? I can find exactly one such use of Kconfig in the tree.

Quoted 5 lines
drivers/soc/renesas/Kconfig +1 -0
  	select ARCH_RCAR_GEN5
+	select MDLC_R8A78000
  	help
  	  This enables support for the Renesas R-Car X5H SoC.
 
#15 lore raw

Re: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver

Hi Marek,

Quoted 10 lines · Marek Vasut

drivers/soc/renesas/Kconfig config ARCH_R8A78000 · line 359

Quoted 5 lines · Geert Uytterhoeven
drivers/soc/renesas/Kconfig +0 -0
@@ -358,6 +358,7 @@ config ARCH_R8A78000
      default y if ARCH_RENESAS
      default ARCH_RENESAS

I know this ^ is not related to this patch, but is the "default y" and "default ARCH_RENESAS" above valid ? I can find exactly one such use of Kconfig in the tree.

Thanks, both are valid, but sort of duplicates.
I will send a patch to drop the latter, and restore consistency.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#16 lore raw

Re: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver

In reply to Geert Uytterhoeven
Quoted 9 lines · Geert Uytterhoeven

Add a minimal Module Controller driver for the R-Car X5H (R8A78000) SoC. For now this just supports the always-on power domains, and dummy clocks and resets for the serial console (which is enabled by the boot loader).

---
Calling genpd_add_provider() instead of of_genpd_add_provider_onecell() would be sufficient, but the former is private.

Right. Callers that need their own xlate callback should just assign it before calling of_genpd_add_provider_onecell(), as the below code does.

Quoted 108 lines

v2:
- Spin off from "pmdomain: renesas: Add R-Car X5H MDLC SCMI remapping driver",
- Add default support not using SCMI,
- Drop all SCMI remapping support,
- Document use of -1 as a sentinel,
- Rename struct r8a78000_mdlc_info to mdlc_info,
- Print HW IDs in hexadecimal,
- Reduce log level for unsupported MDLC instances from warn to dbg,

---
 drivers/pmdomain/renesas/Kconfig         |   4 +
 drivers/pmdomain/renesas/Makefile        |   1 +
 drivers/pmdomain/renesas/r8a78000-mdlc.c | 329 +++++++++++++++++++++++
 drivers/soc/renesas/Kconfig              |   1 +
 4 files changed, 335 insertions(+)
 create mode 100644 drivers/pmdomain/renesas/r8a78000-mdlc.c
drivers/pmdomain/renesas/Kconfig +4 -0
index b507c3e0d723efc6..f2f52d3c29a083f1 100644
@@ -13,6 +13,10 @@ config SYSC_RMOBILE
        bool "System Controller support for R-Mobile" if COMPILE_TEST
 
 # SoC
+config MDLC_R8A78000
+       bool "Module Controller support for R8A78000 (R-Car X5H)" if COMPILE_TEST
+       select RESET_CONTROLLER
+
 config SYSC_R8A7742
        bool "System Controller support for R8A7742 (RZ/G1H)" if COMPILE_TEST
        select SYSC_RCAR
drivers/pmdomain/renesas/Makefile +1 -0
index 0391e6e67440a786..17849aad37a5ac4f 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # SoC
+obj-$(CONFIG_MDLC_R8A78000)    += r8a78000-mdlc.o
 obj-$(CONFIG_SYSC_R8A7742)     += r8a7742-sysc.o
 obj-$(CONFIG_SYSC_R8A7743)     += r8a7743-sysc.o
 obj-$(CONFIG_SYSC_R8A7745)     += r8a7745-sysc.o
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +58 -0
new file mode 100644
index 0000000000000000..ed367e921a3341a7
@@ -0,0 +1,329 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * R-Car X5H Module Controller
+ *
+ * Copyright (C) 2026 Glider bv
+ */
+
+#include <linux/dev_printk.h>
+#include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_domain.h>
+#include <linux/reset-controller.h>
+#include <linux/slab.h>
+
+#include <dt-bindings/power/renesas,r8a78000-mdlc.h>
+
+struct mod_map {
+       int hw_id;              /* Hardware module ID or -1 sentinel */
+};
+
+struct mdlc_info {
+       u32 base;
+       const struct mod_map *mod_map;
+};
+
+/**
+ * struct r8a78000_mdlc_priv - Module Controller Private Data
+ *
+ * @link: Link into list of MDLC instances
+ * @genpd_data: PM domain provider data
+ * @rcdev: Reset controller entity
+ * @dev: MDLC device
+ * @np: Device node in DT representing the MDLC
+ * @mod_map: Mapping from hardware module IDs
+ */
+struct r8a78000_mdlc_priv {
+       struct hlist_node link;
+       struct genpd_onecell_data genpd_data;
+       struct reset_controller_dev rcdev;
+       struct device *dev;
+       struct device_node *np;
+       const struct mod_map *mod_map;
+};
+
+static struct generic_pm_domain *r8a78000_genpd_always_on;
+static HLIST_HEAD(r8a78000_mdlc_list);
+static DEFINE_MUTEX(r8a78000_mdlc_lock);       /* protects the two above */
+
+static struct generic_pm_domain *r8a78000_genpd_xlate(
+                       const struct of_phandle_args *spec, void *data)
+{
+       struct r8a78000_mdlc_priv *priv = container_of(data,
+                                       struct r8a78000_mdlc_priv, genpd_data);
+       struct device *dev = priv->dev;
+       u32 id;
+

drivers/pmdomain/renesas/r8a78000-mdlc.c line 68

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+       if (spec->args_count != 2)
+               return ERR_PTR(-EINVAL);
+
+       id = spec->args[0];
+
+       if (id >= R8A78000_MDLC_PD_AON) {
+               dev_dbg(dev,
+                       "Mapping HW power domain 0x%x to always-on domain\n",
+                       id);
+               return r8a78000_genpd_always_on;

This looks odd, but perhaps it's just a temporary mapping that you intend to change later, no?

Quoted 5 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +5 -0
+       }
+
+       dev_err(dev, "Unknown power domain 0x%x\n", id);
+       return ERR_PTR(-ENOENT);
+}

[...]

Quoted 6 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +6 -0
+
+static void r8a78000_genpd_del_provider(void *data)
+{
+       of_genpd_del_provider(data);
+}
+

drivers/pmdomain/renesas/r8a78000-mdlc.c line 205

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+static int r8a78000_genpd_always_on_singleton(struct device *dev)
+{
+       struct generic_pm_domain *genpd;
+       int ret;
+
+       guard(mutex)(&r8a78000_mdlc_lock);
+
+       if (r8a78000_genpd_always_on)
+               return 0;
+

I guess the mutex is used to protect the global r8a78000_genpd_always_on, but it looks like that isn't really needed based upon how things are being called during the probe.

Quoted 78 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +78 -0
+       genpd = kzalloc_obj(*genpd);
+       if (!genpd)
+               return -ENOMEM;
+
+       genpd->name = "always-on";
+       genpd->attach_dev = r8a78000_mdlc_attach_dev;
+
+       ret = pm_genpd_init(genpd, &pm_domain_always_on_gov, false);
+       if (ret) {
+               kfree(genpd);
+               return dev_err_probe(dev, ret,
+                                    "Failed to create always-on domain\n");
+       }
+
+       r8a78000_genpd_always_on = genpd;
+       return 0;
+}
+
+static int r8a78000_mdlc_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *np = dev->of_node;
+       struct r8a78000_mdlc_priv *priv;
+       const struct mdlc_info *info;
+       struct resource *res;
+       int ret;
+
+       ret = r8a78000_genpd_always_on_singleton(dev);
+       if (ret)
+               return ret;
+
+       info = of_device_get_match_data(dev);
+       if (!info)
+               return -ENODEV;
+
+       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->dev = dev;
+       priv->np = np;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res)
+               return -ENODEV;
+
+       for (; info->base; info++) {
+               if (info->base == res->start)
+                       break;
+       }
+
+       if (!info->base) {
+               dev_dbg(dev, "Unsupported MDLC instance 0x%pa\n", &res->start);
+               return -ENODEV;
+       }
+
+       priv->mod_map = info->mod_map;
+
+       scoped_guard(mutex, &r8a78000_mdlc_lock) {
+               hlist_add_head(&priv->link, &r8a78000_mdlc_list);
+       }
+
+       ret = devm_add_action_or_reset(dev, r8a78000_mdlc_unlink, priv);
+       if (ret)
+               return dev_err_probe(dev, ret, "failed to add action\n");
+
+       /* Note that no actual domains are registered, just need translation */
+       priv->genpd_data.xlate = r8a78000_genpd_xlate;
+       ret = of_genpd_add_provider_onecell(np, &priv->genpd_data);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to register genpd provider\n");
+
+       ret = devm_add_action_or_reset(dev, r8a78000_genpd_del_provider, np);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "failed to add unregister action\n");
+

drivers/pmdomain/renesas/r8a78000-mdlc.c line 293

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+       priv->rcdev.ops = &r8a78000_mdlc_reset_ops;
+       priv->rcdev.of_node = np;
+       priv->rcdev.of_reset_n_cells = 1;
+       priv->rcdev.of_xlate = r8a78000_mdlc_reset_xlate;
+
+       ret = devm_reset_controller_register(dev, &priv->rcdev);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to register reset controller\n");
+

In some of the error paths above it looks like we end up leaking the data allocated for r8a78000_genpd_always_on. Perhaps clean up that somewhere here.

drivers/pmdomain/renesas/r8a78000-mdlc.c

Quoted 2 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +2 -0
+       return 0;
+}

[...]

In regards to the merge strategy, I intend to pick patch 2 (shared via the immutable dt branch) and $subject patch. Please let me know if there are any issues with that.

Kind regards
Uffe

#17 lore raw

Re: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver

Hi Ulf,

Quoted 25 lines · Ulf Hansson
Quoted 23 lines · Geert Uytterhoeven

Add a minimal Module Controller driver for the R-Car X5H (R8A78000) SoC. For now this just supports the always-on power domains, and dummy clocks and resets for the serial console (which is enabled by the boot loader).

drivers/pmdomain/renesas/r8a78000-mdlc.c new file +13 -0
 
+static struct generic_pm_domain *r8a78000_genpd_xlate(
+                       const struct of_phandle_args *spec, void *data)
+{
+       struct r8a78000_mdlc_priv *priv = container_of(data,
+                                       struct r8a78000_mdlc_priv, genpd_data);
+       struct device *dev = priv->dev;
+       u32 id;
+
+       if (spec->args_count != 2)
+               return ERR_PTR(-EINVAL);
+
+       id = spec->args[0];
+
Quoted 8 lines

drivers/pmdomain/renesas/r8a78000-mdlc.c line 68

Quoted 5 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +5 -0
+       if (id >= R8A78000_MDLC_PD_AON) {
+               dev_dbg(dev,
+                       "Mapping HW power domain 0x%x to always-on domain\n",
+                       id);
+               return r8a78000_genpd_always_on;

This looks odd, but perhaps it's just a temporary mapping that you intend to change later, no?

The hardware has multiple always-on domains, but on the software side, using only one is sufficient. When needed, it can be changed later. Other domains will be added later, in the else branch.

Quoted 6 lines
Quoted 5 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +5 -0
+       }
+
+       dev_err(dev, "Unknown power domain 0x%x\n", id);
+       return ERR_PTR(-ENOENT);
+}
Quoted 14 lines

drivers/pmdomain/renesas/r8a78000-mdlc.c line 205

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+static int r8a78000_genpd_always_on_singleton(struct device *dev)
+{
+       struct generic_pm_domain *genpd;
+       int ret;
+
+       guard(mutex)(&r8a78000_mdlc_lock);
+
+       if (r8a78000_genpd_always_on)
+               return 0;
+

I guess the mutex is used to protect the global r8a78000_genpd_always_on, but it looks like that isn't really needed based upon how things are being called during the probe.

Why would it not be needed? There are multiple instances of the MDLC device, but only one instance of the always-on domain.

Quoted 84 lines
Quoted 84 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +84 -0
+       genpd = kzalloc_obj(*genpd);
+       if (!genpd)
+               return -ENOMEM;
+
+       genpd->name = "always-on";
+       genpd->attach_dev = r8a78000_mdlc_attach_dev;
+
+       ret = pm_genpd_init(genpd, &pm_domain_always_on_gov, false);
+       if (ret) {
+               kfree(genpd);
+               return dev_err_probe(dev, ret,
+                                    "Failed to create always-on domain\n");
+       }
+
+       r8a78000_genpd_always_on = genpd;
+       return 0;
+}
+
+static int r8a78000_mdlc_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *np = dev->of_node;
+       struct r8a78000_mdlc_priv *priv;
+       const struct mdlc_info *info;
+       struct resource *res;
+       int ret;
+
+       ret = r8a78000_genpd_always_on_singleton(dev);
+       if (ret)
+               return ret;
+
+       info = of_device_get_match_data(dev);
+       if (!info)
+               return -ENODEV;
+
+       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->dev = dev;
+       priv->np = np;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res)
+               return -ENODEV;
+
+       for (; info->base; info++) {
+               if (info->base == res->start)
+                       break;
+       }
+
+       if (!info->base) {
+               dev_dbg(dev, "Unsupported MDLC instance 0x%pa\n", &res->start);
+               return -ENODEV;
+       }
+
+       priv->mod_map = info->mod_map;
+
+       scoped_guard(mutex, &r8a78000_mdlc_lock) {
+               hlist_add_head(&priv->link, &r8a78000_mdlc_list);
+       }
+
+       ret = devm_add_action_or_reset(dev, r8a78000_mdlc_unlink, priv);
+       if (ret)
+               return dev_err_probe(dev, ret, "failed to add action\n");
+
+       /* Note that no actual domains are registered, just need translation */
+       priv->genpd_data.xlate = r8a78000_genpd_xlate;
+       ret = of_genpd_add_provider_onecell(np, &priv->genpd_data);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to register genpd provider\n");
+
+       ret = devm_add_action_or_reset(dev, r8a78000_genpd_del_provider, np);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "failed to add unregister action\n");
+
+       priv->rcdev.ops = &r8a78000_mdlc_reset_ops;
+       priv->rcdev.of_node = np;
+       priv->rcdev.of_reset_n_cells = 1;
+       priv->rcdev.of_xlate = r8a78000_mdlc_reset_xlate;
+
+       ret = devm_reset_controller_register(dev, &priv->rcdev);
Quoted 8 lines

drivers/pmdomain/renesas/r8a78000-mdlc.c line 293

Quoted 4 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +4 -0
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to register reset controller\n");
+

In some of the error paths above it looks like we end up leaking the data allocated for r8a78000_genpd_always_on. Perhaps clean up that somewhere here.

That is intentional: the always-on domain is shared by all MDLC instances. If one MDLC fails to probe, the MDLC instances that did succeed still need the always-on domain.

Quoted 9 lines

drivers/pmdomain/renesas/r8a78000-mdlc.c

Quoted 3 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +2 -0
+       return 0;
+}

[...]

In regards to the merge strategy, I intend to pick patch 2 (shared via the immutable dt branch) and $subject patch. Please let me know if there are any issues with that.

That is fine, thanks!

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#18 lore raw

Re: [PATCH v2 4/6] pmdomain: renesas: Add R-Car X5H MDLC driver

Quoted 38 lines · Geert Uytterhoeven

Hi Ulf,

Quoted 25 lines · Ulf Hansson
Quoted 23 lines · Geert Uytterhoeven

Add a minimal Module Controller driver for the R-Car X5H (R8A78000) SoC. For now this just supports the always-on power domains, and dummy clocks and resets for the serial console (which is enabled by the boot loader).

drivers/pmdomain/renesas/r8a78000-mdlc.c new file +13 -0
 
+static struct generic_pm_domain *r8a78000_genpd_xlate(
+                       const struct of_phandle_args *spec, void *data)
+{
+       struct r8a78000_mdlc_priv *priv = container_of(data,
+                                       struct r8a78000_mdlc_priv, genpd_data);
+       struct device *dev = priv->dev;
+       u32 id;
+
+       if (spec->args_count != 2)
+               return ERR_PTR(-EINVAL);
+
+       id = spec->args[0];
+
Quoted 8 lines

drivers/pmdomain/renesas/r8a78000-mdlc.c line 68

Quoted 5 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +5 -0
+       if (id >= R8A78000_MDLC_PD_AON) {
+               dev_dbg(dev,
+                       "Mapping HW power domain 0x%x to always-on domain\n",
+                       id);
+               return r8a78000_genpd_always_on;

This looks odd, but perhaps it's just a temporary mapping that you intend to change later, no?

Quoted 3 lines

The hardware has multiple always-on domains, but on the software side, using only one is sufficient. When needed, it can be changed later. Other domains will be added later, in the else branch.

I see, perhaps add a comment about this in the code, to make this more clear?

Quoted 22 lines
Quoted 7 lines
Quoted 6 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +5 -0
+       }
+
+       dev_err(dev, "Unknown power domain 0x%x\n", id);
+       return ERR_PTR(-ENOENT);
+}
Quoted 14 lines

drivers/pmdomain/renesas/r8a78000-mdlc.c line 205

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+static int r8a78000_genpd_always_on_singleton(struct device *dev)
+{
+       struct generic_pm_domain *genpd;
+       int ret;
+
+       guard(mutex)(&r8a78000_mdlc_lock);
+
+       if (r8a78000_genpd_always_on)
+               return 0;
+

I guess the mutex is used to protect the global r8a78000_genpd_always_on, but it looks like that isn't really needed based upon how things are being called during the probe.

Quoted 2 lines

Why would it not be needed? There are multiple instances of the MDLC device, but only one instance of the always-on domain.

Aha, I see. Thanks for clarifying!

Quoted 94 lines
Quoted 85 lines
Quoted 85 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +84 -0
+       genpd = kzalloc_obj(*genpd);
+       if (!genpd)
+               return -ENOMEM;
+
+       genpd->name = "always-on";
+       genpd->attach_dev = r8a78000_mdlc_attach_dev;
+
+       ret = pm_genpd_init(genpd, &pm_domain_always_on_gov, false);
+       if (ret) {
+               kfree(genpd);
+               return dev_err_probe(dev, ret,
+                                    "Failed to create always-on domain\n");
+       }
+
+       r8a78000_genpd_always_on = genpd;
+       return 0;
+}
+
+static int r8a78000_mdlc_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *np = dev->of_node;
+       struct r8a78000_mdlc_priv *priv;
+       const struct mdlc_info *info;
+       struct resource *res;
+       int ret;
+
+       ret = r8a78000_genpd_always_on_singleton(dev);
+       if (ret)
+               return ret;
+
+       info = of_device_get_match_data(dev);
+       if (!info)
+               return -ENODEV;
+
+       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
+       priv->dev = dev;
+       priv->np = np;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       if (!res)
+               return -ENODEV;
+
+       for (; info->base; info++) {
+               if (info->base == res->start)
+                       break;
+       }
+
+       if (!info->base) {
+               dev_dbg(dev, "Unsupported MDLC instance 0x%pa\n", &res->start);
+               return -ENODEV;
+       }
+
+       priv->mod_map = info->mod_map;
+
+       scoped_guard(mutex, &r8a78000_mdlc_lock) {
+               hlist_add_head(&priv->link, &r8a78000_mdlc_list);
+       }
+
+       ret = devm_add_action_or_reset(dev, r8a78000_mdlc_unlink, priv);
+       if (ret)
+               return dev_err_probe(dev, ret, "failed to add action\n");
+
+       /* Note that no actual domains are registered, just need translation */
+       priv->genpd_data.xlate = r8a78000_genpd_xlate;
+       ret = of_genpd_add_provider_onecell(np, &priv->genpd_data);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to register genpd provider\n");
+
+       ret = devm_add_action_or_reset(dev, r8a78000_genpd_del_provider, np);
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "failed to add unregister action\n");
+
+       priv->rcdev.ops = &r8a78000_mdlc_reset_ops;
+       priv->rcdev.of_node = np;
+       priv->rcdev.of_reset_n_cells = 1;
+       priv->rcdev.of_xlate = r8a78000_mdlc_reset_xlate;
+
+       ret = devm_reset_controller_register(dev, &priv->rcdev);
Quoted 8 lines

drivers/pmdomain/renesas/r8a78000-mdlc.c line 293

Quoted 4 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +4 -0
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to register reset controller\n");
+

In some of the error paths above it looks like we end up leaking the data allocated for r8a78000_genpd_always_on. Perhaps clean up that somewhere here.

Quoted 3 lines

That is intentional: the always-on domain is shared by all MDLC instances. If one MDLC fails to probe, the MDLC instances that did succeed still need the always-on domain.

Okay, so perhaps we should add a reference counting of it, to make sure we don't leak the data?

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +2 -0
+       return 0;
+}
Quoted 7 lines
Quoted 5 lines

[...]

In regards to the merge strategy, I intend to pick patch 2 (shared via the immutable dt branch) and $subject patch. Please let me know if there are any issues with that.

That is fine, thanks!

Great, thanks!

Kind regards
Uffe

author maintainer
#19 lore raw

PATCH v2 5/6 arm64: dts: renesas: r8a78000: Add CPG node

In reply to Geert Uytterhoeven

Add a device node for the Clock Pulse Generator (CPG) on the R-Car X5H (R8A78000) SoC.

Convert all (H)SCIF serial ports from dummy to CPG clocks, removing the need for any dummy clocks.

---
v2:
- Split in separate CPG and MDLC patches.

---
 arch/arm64/boot/dts/renesas/r8a78000.dtsi | 59 +++++++++++++----------
 1 file changed, 34 insertions(+), 25 deletions(-)
arch/arm64/boot/dts/renesas/r8a78000.dtsi +34 -25
index fb71974ef390509d..1fe078c7822c01a5 100644
@@ -5,6 +5,7 @@
  * Copyright (C) 2025 Renesas Electronics Corp.
  */
 
+#include <dt-bindings/clock/renesas,r8a78000-cpg.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
 / {
@@ -668,23 +669,6 @@ L3_CA720_7: cache-controller-37 {
 		};
 	};
 
-	/*
-	 * In the early phase, there is no clock control support,
-	 * so assume that the clocks are enabled by default.
-	 * Therefore, dummy clocks are used.
-	 */
-	dummy_clk_sgasyncd16: dummy-clk-sgasyncd16 {
-		compatible = "fixed-clock";
-		#clock-cells = <0>;
-		clock-frequency = <66666000>;
-	};
-
-	dummy_clk_sgasyncd4: dummy-clk-sgasyncd4 {
-		compatible = "fixed-clock";
-		#clock-cells = <0>;
-		clock-frequency = <266660000>;
-	};
-
 	extal_clk: extal-clk {
 		compatible = "fixed-clock";
 		#clock-cells = <0>;
@@ -882,7 +866,9 @@ scif0: serial@c0700000 {
 				     "renesas,rcar-gen5-scif", "renesas,scif";
 			reg = <0 0xc0700000 0 0x40>;
 			interrupts = <GIC_ESPI 10 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&dummy_clk_sgasyncd16>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
+			clocks = <&cpg R8A78000_CPG_SGASYNCD16_PERW_BUS>,
+				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
 			status = "disabled";
 		};
@@ -892,7 +878,9 @@ scif1: serial@c0704000 {
 				     "renesas,rcar-gen5-scif", "renesas,scif";
 			reg = <0 0xc0704000 0 0x40>;
 			interrupts = <GIC_ESPI 11 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&dummy_clk_sgasyncd16>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
+			clocks = <&cpg R8A78000_CPG_SGASYNCD16_PERW_BUS>,
+				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
 			status = "disabled";
 		};
@@ -902,7 +890,9 @@ scif3: serial@c0708000 {
 				     "renesas,rcar-gen5-scif", "renesas,scif";
 			reg = <0 0xc0708000 0 0x40>;
 			interrupts = <GIC_ESPI 12 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&dummy_clk_sgasyncd16>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
+			clocks = <&cpg R8A78000_CPG_SGASYNCD16_PERW_BUS>,
+				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
 			status = "disabled";
 		};
@@ -912,7 +902,9 @@ scif4: serial@c070c000 {
 				     "renesas,rcar-gen5-scif", "renesas,scif";
 			reg = <0 0xc070c000 0 0x40>;
 			interrupts = <GIC_ESPI 13 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&dummy_clk_sgasyncd16>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
+			clocks = <&cpg R8A78000_CPG_SGASYNCD16_PERW_BUS>,
+				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
 			status = "disabled";
 		};
@@ -922,7 +914,9 @@ hscif0: serial@c0710000 {
 				     "renesas,rcar-gen5-hscif", "renesas,hscif";
 			reg = <0 0xc0710000 0 0x60>;
 			interrupts = <GIC_ESPI 14 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&dummy_clk_sgasyncd4>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
+			clocks = <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
 			status = "disabled";
 		};
@@ -932,7 +926,9 @@ hscif1: serial@c0714000 {
 				     "renesas,rcar-gen5-hscif", "renesas,hscif";
 			reg = <0 0xc0714000 0 0x60>;
 			interrupts = <GIC_ESPI 15 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&dummy_clk_sgasyncd4>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
+			clocks = <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
 			status = "disabled";
 		};
@@ -942,7 +938,9 @@ hscif2: serial@c0718000 {
 				     "renesas,rcar-gen5-hscif", "renesas,hscif";
 			reg = <0 0xc0718000 0 0x60>;
 			interrupts = <GIC_ESPI 16 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&dummy_clk_sgasyncd4>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
+			clocks = <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
 			status = "disabled";
 		};
@@ -952,7 +950,9 @@ hscif3: serial@c071c000 {
 				     "renesas,rcar-gen5-hscif", "renesas,hscif";
 			reg = <0 0xc071c000 0 0x60>;
 			interrupts = <GIC_ESPI 17 IRQ_TYPE_LEVEL_HIGH>;
-			clocks = <&dummy_clk_sgasyncd4>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
+			clocks = <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
+				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
 			status = "disabled";
 		};
@@ -965,6 +965,15 @@ stcm_transport: sram@c1060000 {
 			ranges = <0 0x0 0xc1060000 0x1c00>;
 			/* actual transport nodes must be set per board file */
 		};
+
+		cpg: clock-controller@c1320000 {
+			compatible = "renesas,r8a78000-cpg";
+			reg = <0 0xc1320000 0 0x10000>;
+			clocks = <&extal_clk>, <&extalr_clk>;
+			clock-names = "extal", "extalr";
+			#clock-cells = <1>;
+			bootph-all;
+		};
 	};
 
 	timer {
Signature · 1 line
2.43.0
author maintainer
#21 lore raw

PATCH v2 6/6 arm64: dts: renesas: r8a78000: Add MDLC nodes

In reply to Geert Uytterhoeven

Add device nodes for the Module Control (MDLC) blocks on the R-Car X5H (R8A78000) SoC.

Complete hardware desciption of all (H)SCIF serial ports, by linking them to an MDLC for power domains and resets.

---
v2:
- Split in separate CPG and MDLC patches.

---
 arch/arm64/boot/dts/renesas/r8a78000.dtsi | 241 ++++++++++++++++++++++
 1 file changed, 241 insertions(+)
arch/arm64/boot/dts/renesas/r8a78000.dtsi +241 -0
index 1fe078c7822c01a5..c256d7cf22872bbc 100644
@@ -6,6 +6,7 @@
  */
 
 #include <dt-bindings/clock/renesas,r8a78000-cpg.h>
+#include <dt-bindings/power/renesas,r8a78000-mdlc.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 
 / {
@@ -870,6 +871,8 @@ scif0: serial@c0700000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x40>;
+			resets = <&mdlc_perw 0x40>;
 			status = "disabled";
 		};
 
@@ -882,6 +885,8 @@ scif1: serial@c0704000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x41>;
+			resets = <&mdlc_perw 0x41>;
 			status = "disabled";
 		};
 
@@ -894,6 +899,8 @@ scif3: serial@c0708000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x42>;
+			resets = <&mdlc_perw 0x42>;
 			status = "disabled";
 		};
 
@@ -906,6 +913,8 @@ scif4: serial@c070c000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x43>;
+			resets = <&mdlc_perw 0x43>;
 			status = "disabled";
 		};
 
@@ -918,6 +927,8 @@ hscif0: serial@c0710000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x54>;
+			resets = <&mdlc_perw 0x54>;
 			status = "disabled";
 		};
 
@@ -930,6 +941,8 @@ hscif1: serial@c0714000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x55>;
+			resets = <&mdlc_perw 0x55>;
 			status = "disabled";
 		};
 
@@ -942,6 +955,8 @@ hscif2: serial@c0718000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x56>;
+			resets = <&mdlc_perw 0x56>;
 			status = "disabled";
 		};
 
@@ -954,6 +969,8 @@ hscif3: serial@c071c000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x57>;
+			resets = <&mdlc_perw 0x57>;
 			status = "disabled";
 		};
 
@@ -974,6 +991,230 @@ cpg: clock-controller@c1320000 {
 			#clock-cells = <1>;
 			bootph-all;
 		};
+
+		mdlc_vipn: system-controller@c3060000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc3060000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_vips: system-controller@c3460000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc3460000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_vio: system-controller@c5000000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc5000000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_pere: system-controller@c08f0000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc08f0000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_perw: system-controller@c05d0000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc05d0000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ddr0: system-controller@e8000000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8000000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ddr1: system-controller@e8080000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8080000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ddr2: system-controller@e8100000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8100000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ddr3: system-controller@e8180000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8180000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ddr4: system-controller@e8200000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8200000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ddr5: system-controller@e8280000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8280000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ddr6: system-controller@e8300000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8300000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ddr7: system-controller@e8380000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8380000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_hscn: system-controller@c9c90000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc9c90000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_rt: system-controller@19440000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0x19440000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_top: system-controller@c6480000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc6480000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_hscs: system-controller@de200000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xde200000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_imn: system-controller@c1990000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc1990000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_ims: system-controller@c1d90000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc1d90000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_gpc: system-controller@cb510000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xcb510000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_dsp: system-controller@cbe90000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xcbe90000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_mm: system-controller@e9980000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe9980000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_npu0: system-controller@d2c30000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xd2c30000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_npu1: system-controller@d6c30000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xd6c30000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_cmnn: system-controller@ca410000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xca410000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_cmns: system-controller@ca510000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xca510000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_scp: system-controller@c1330000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc1330000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_aon: system-controller@c1338000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc1338000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
 	};
 
 	timer {
Signature · 1 line
2.43.0
#22 lore raw

Re: [PATCH v2 6/6] arm64: dts: renesas: r8a78000: Add MDLC nodes

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Hardware mapping mismatch between MDLC driver and DT causes probe failure for hscif0. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Hardware mapping mismatch between MDLC driver and DT causes probe failure for hscif0. --

--- Patch [6]: [PATCH v2 6/6] arm64: dts: renesas: r8a78000: Add MDLC nodes --- commit f3c8aa0f294cd575595329194a9adf5e14b5f350
Author: Geert Uytterhoeven <[email protected]>

arm64: dts: renesas: r8a78000: Add MDLC nodes

This patch adds device nodes for the Module Control (MDLC) blocks on the R-Car X5H (R8A78000) SoC. It also links all (H)SCIF serial ports to an MDLC for power domains and resets to complete their hardware description.

Quoted 4 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +0 -0
index e22e307ce31fb..6ca1b1e95aef2 100644

[ ... ]

arch/arm64/boot/dts/renesas/r8a78000.dtsi hscif0: serial@c0710000 { · line 898

Quoted 5 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +1 -0
@@ -886,6 +895,8 @@ hscif0: serial@c0710000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x41>;

[Severity: Medium]
Is this the correct ID for hscif0?

The r8a78000-mdlc driver introduced earlier in this series restricts power domain attachment to module IDs in its allowlist.

The driver specifically defines ID 0x54 as HSCIF0.

Since 0x41 is not mapped to hscif0 in the driver's allowlist, will r8a78000_mdlc_attach_dev() return -ENOENT and permanently prevent hscif0 from successfully probing?

Quoted 3 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +1 -0
+			resets = <&mdlc_perw 0x41>;
 			status = "disabled";
 		};

[ ... ]

arch/arm64/boot/dts/renesas/r8a78000.dtsi hscif3: serial@c071c000 { · line 940

Quoted 5 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +1 -0
@@ -922,6 +937,8 @@ hscif3: serial@c071c000 {
 				 <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
 				 <&scif_clk>;
 			clock-names = "fck", "brg_int", "scif_clk";
+			power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x54>;

[Severity: Medium]
Will this conflict with the MDLC driver?

The driver explicitly maps ID 0x54 to HSCIF0, but here it is being assigned to hscif3.

Quoted 3 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +1 -0
+			resets = <&mdlc_perw 0x54>;
 			status = "disabled";
 		};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
#23 lore raw

Re: [PATCH v2 6/6] arm64: dts: renesas: r8a78000: Add MDLC nodes

Hi Sashiko,

Quoted 14 lines · On Wed, 8 Jul 2026 at 12:47, <[email protected]> wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Hardware mapping mismatch between MDLC driver and DT causes probe failure for hscif0. --

--- Patch [6]: [PATCH v2 6/6] arm64: dts: renesas: r8a78000: Add MDLC nodes --- commit f3c8aa0f294cd575595329194a9adf5e14b5f350
Author: Geert Uytterhoeven <[email protected]>

arm64: dts: renesas: r8a78000: Add MDLC nodes

This patch adds device nodes for the Module Control (MDLC) blocks on the R-Car X5H (R8A78000) SoC. It also links all (H)SCIF serial ports to an MDLC for power domains and resets to complete their hardware description.

Quoted 6 lines
Quoted 4 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +0 -0
index e22e307ce31fb..6ca1b1e95aef2 100644

[ ... ]

arch/arm64/boot/dts/renesas/r8a78000.dtsi hscif0: serial@c0710000 {

Quoted 1 line
arch/arm64/boot/dts/renesas/r8a78000.dtsi +0 -0
@@ -886,6 +895,8 @@ hscif0: serial@c0710000 {

You are hallucinating, as this line is not present in my patch.

Quoted 20 lines

arch/arm64/boot/dts/renesas/r8a78000.dtsi scif1: serial@c0704000 { · line 888

Quoted 4 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +1 -0
                               <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
                               <&scif_clk>;
                      clock-names = "fck", "brg_int", "scif_clk";
+                     power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x41>;

[Severity: Medium]
Is this the correct ID for hscif0?

The r8a78000-mdlc driver introduced earlier in this series restricts power domain attachment to module IDs in its allowlist.

The driver specifically defines ID 0x54 as HSCIF0.

Since 0x41 is not mapped to hscif0 in the driver's allowlist, will r8a78000_mdlc_attach_dev() return -ENOENT and permanently prevent hscif0 from successfully probing?

arch/arm64/boot/dts/renesas/r8a78000.dtsi scif1: serial@c0704000 { · line 891

Quoted 3 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +1 -0
+                     resets = <&mdlc_perw 0x41>;
                      status = "disabled";
              };
Quoted 6 lines

[ ... ]

arch/arm64/boot/dts/renesas/r8a78000.dtsi hscif3: serial@c071c000 { · line 940

Quoted 5 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +1 -0
@@ -922,6 +937,8 @@ hscif3: serial@c071c000 {
                               <&cpg R8A78000_CPG_SGASYNCD4_PERW_BUS>,
                               <&scif_clk>;
                      clock-names = "fck", "brg_int", "scif_clk";
+                     power-domains = <&mdlc_perw R8A78000_MDLC_PD_APL 0x54>;

You are hallucinating, as this line is not added in this hunk.

Quoted 6 lines

[Severity: Medium]
Will this conflict with the MDLC driver?

The driver explicitly maps ID 0x54 to HSCIF0, but here it is being assigned to hscif3.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Reviewed-by on v2 6/6
#24 lore raw

Re: [PATCH v2 6/6] arm64: dts: renesas: r8a78000: Add MDLC nodes

In reply to Geert Uytterhoeven
Quoted 7 lines · Geert Uytterhoeven

Add device nodes for the Module Control (MDLC) blocks on the R-Car X5H (R8A78000) SoC.

Complete hardware desciption of all (H)SCIF serial ports, by linking them to an MDLC for power domains and resets.

[...]

Quoted 7 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +7 -0
+		mdlc_ddr7: system-controller@e8380000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xe8380000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};

arch/arm64/boot/dts/renesas/r8a78000.dtsi cpg: clock-controller@c1320000 { · line 1107

Quoted 10 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +10 -0
+
+		mdlc_hscn: system-controller@c9c90000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc9c90000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};
+
+		mdlc_rt: system-controller@19440000 {

Please keep the list sorted (0x19440000 should be before 0xc9c90000).

arch/arm64/boot/dts/renesas/r8a78000.dtsi cpg: clock-controller@c1320000 { · line 1113

Quoted 6 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +6 -0
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0x19440000 0 0x1000>;
+			#power-domain-cells = <2>;
+			#reset-cells = <1>;
+			bootph-all;
+		};

With that fixed:

Thank you !

#25 lore raw

Re: [PATCH v2 6/6] arm64: dts: renesas: r8a78000: Add MDLC nodes

Hi Marek,

Quoted 22 lines · Marek Vasut
Quoted 7 lines · Geert Uytterhoeven

Add device nodes for the Module Control (MDLC) blocks on the R-Car X5H (R8A78000) SoC.

Complete hardware desciption of all (H)SCIF serial ports, by linking them to an MDLC for power domains and resets.

[...]

Quoted 11 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +11 -0
+             mdlc_ddr7: system-controller@e8380000 {
+                     compatible = "renesas,r8a78000-mdlc";
+                     reg = <0 0xe8380000 0 0x1000>;
+                     #power-domain-cells = <2>;
+                     #reset-cells = <1>;
+                     bootph-all;
+             };
+
+             mdlc_hscn: system-controller@c9c90000 {
+                     compatible = "renesas,r8a78000-mdlc";
+                     reg = <0 0xc9c90000 0 0x1000>;
Quoted 8 lines

arch/arm64/boot/dts/renesas/r8a78000.dtsi cpg: clock-controller@c1320000 { · line 1107

Quoted 6 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +6 -0
+                     #power-domain-cells = <2>;
+                     #reset-cells = <1>;
+                     bootph-all;
+             };
+
+             mdlc_rt: system-controller@19440000 {

Please keep the list sorted (0x19440000 should be before 0xc9c90000).

These are sorted by instance (Module Number), as per Table 18.1 ("Target Module hierarchy of Module Power Gating and Module Standby") in the documentation. This order is indeed a bit odd, as it differs from both alphabetical label order (unlike e.g. hscifN), and numerical unit address order...

Any guidance?

Quoted 9 lines

arch/arm64/boot/dts/renesas/r8a78000.dtsi cpg: clock-controller@c1320000 { · line 1113

Quoted 6 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +6 -0
+                     compatible = "renesas,r8a78000-mdlc";
+                     reg = <0 0x19440000 0 0x1000>;
+                     #power-domain-cells = <2>;
+                     #reset-cells = <1>;
+                     bootph-all;
+             };

With that fixed:

Thanks! ;-)

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#26 lore raw

Re: [PATCH v2 6/6] arm64: dts: renesas: r8a78000: Add MDLC nodes

On 7/9/26 12:24 PM, Geert Uytterhoeven wrote:

Hello Geert,

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +11 -0
+             mdlc_ddr7: system-controller@e8380000 {
+                     compatible = "renesas,r8a78000-mdlc";
+                     reg = <0 0xe8380000 0 0x1000>;
+                     #power-domain-cells = <2>;
+                     #reset-cells = <1>;
+                     bootph-all;
+             };
+
+             mdlc_hscn: system-controller@c9c90000 {
+                     compatible = "renesas,r8a78000-mdlc";
+                     reg = <0 0xc9c90000 0 0x1000>;
Quoted 8 lines

arch/arm64/boot/dts/renesas/r8a78000.dtsi cpg: clock-controller@c1320000 { · line 1107

Quoted 6 lines
arch/arm64/boot/dts/renesas/r8a78000.dtsi +6 -0
+                     #power-domain-cells = <2>;
+                     #reset-cells = <1>;
+                     bootph-all;
+             };
+
+             mdlc_rt: system-controller@19440000 {

Please keep the list sorted (0x19440000 should be before 0xc9c90000).

Quoted 7 lines

These are sorted by instance (Module Number), as per Table 18.1 ("Target Module hierarchy of Module Power Gating and Module Standby") in the documentation. This order is indeed a bit odd, as it differs from both alphabetical label order (unlike e.g. hscifN), and numerical unit address order...

Any guidance?

Do you think those MDLC instances might be on different sub-busses and we might need to model those busses using simple-bus in DT ?