Skip to contentSkip to conversation

R-Car X5H CPG/MDLC support

PATCH Superseded Geert Uytterhoeven 6 participants 17 messages Aug 5 – Aug 11

Subsystems (5)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Geert Uytterhoeven

author maintainer
#0 lore raw

v3 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.
Note that this series depends on v7.2-rc2, due to the use of <linux/device-id/of.h>.

Changes compared to v2[1]:
- Add Acked-by, Reviewed-by,
- Add fixed-rate clocks to kerneldoc of r8a78000_cpg_priv.map,
- Use devm_clk_hw_register_fixed_rate(), drop unregister_fixed_clks(),
- Drop fill_clk_map(), as it is not really needed until SCMI remapping support is added later,
- Replace <linux/mod_devicetable.h> by more specific

    <linux/device-id/of.h> in v7.2-rc2,

- Add a comment to document only always-on domains are supported,
- Consistently use /* sentinel */ for zero sentinels,
- Drop trailing commas from sentinels,
- Sort MDLC nodes (alphabetically, by label).

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

Note that this series does not use or rely on SCMI in any way. SCMI remapping support will be added in a subsequent series (old version at [3]).
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 (including a rebased and updated version of [3]) to [4].

While I know it is getting late in the cycle, this work (especially the DT bindings) are a dependency for about any R-Car X5H progress, so it would be good to have it included in v7.3.
Hence I plan to queue the clock patches (1, 3) in renesas-clk for v7.3 (Stephen still hasn't merged my earlier PR for v7.3 anyway).
Ulf: It would be great if you could take the pmdomain patches (2, 4). The DTS changes (5-6) can wait for v7.4; they have a hard dependency on the presence of both drivers anyway.

Thanks for your comments!

[1] "[PATCH v2 0/6] R-Car X5H CPG/MDLC support"

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

[4] topic/rcar-x5h-ironhide-scmi-cpg-mdlc-remapping-v3-wip 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            | 166 +++++++++
 drivers/pmdomain/renesas/Kconfig              |   4 +
 drivers/pmdomain/renesas/Makefile             |   1 +
 drivers/pmdomain/renesas/r8a78000-mdlc.c      | 330 ++++++++++++++++++
 drivers/soc/renesas/Kconfig                   |   1 +
 .../dt-bindings/clock/renesas,r8a78000-cpg.h  |  14 +
 .../dt-bindings/power/renesas,r8a78000-mdlc.h |  15 +
 12 files changed, 927 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 v3 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.

---
v3:
- Add Acked-by,

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
#2 lore raw

PATCH v3 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.

---
v3:
- Add Reviewed-by, Acked-by,

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
#3 lore raw

PATCH v3 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.

---
v3:
- Add fixed-rate clocks to kerneldoc of r8a78000_cpg_priv.map,
- Use devm_clk_hw_register_fixed_rate(), drop unregister_fixed_clks(),
- Drop fill_clk_map(), as it is not really needed until SCMI remapping support is added later,
- Replace <linux/mod_devicetable.h> by more specific

    <linux/device-id/of.h> in v7.2-rc2,

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 | 166 +++++++++++++++++++++++++++++
 3 files changed, 171 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 +166 -0

166 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#5 lore raw

PATCH v3 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 module clocks and resets for the serial console (which is enabled by the boot loader).

---
v3:
- Replace <linux/mod_devicetable.h> by more specific

    <linux/device-id/of.h> in v7.2-rc2,

- Add a comment to document only always-on domains are supported,
- Consistently use /* sentinel */ for zero sentinels,
- Drop trailing commas from sentinels,

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 | 330 +++++++++++++++++++++++
 drivers/soc/renesas/Kconfig              |   1 +
 4 files changed, 336 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 +330 -0

330 lines not on this page · raw message

drivers/soc/renesas/Kconfig +1 -0
index fdf18ed2dfc2186d..eb8ac0d47d9d42b1 100644
@@ -357,6 +357,7 @@ config ARCH_R8A78000
 	bool "ARM64 Platform support for R8A78000 (R-Car X5H)"
 	default y if 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
#6 lore raw

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

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The attach_dev callback hardcodes index 0 when parsing the 'power-domains' property, breaking…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The attach_dev callback hardcodes index 0 when parsing the 'power-domains' property, breaking support for devices with multiple power domains.
- [High] Unprotected access to the provider's private data (priv) outside r8a78000_mdlc_lock in r8a78000_mdlc_attach_dev leads to a potential Use-After-Free. --

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

pmdomain: renesas: Add R-Car X5H MDLC driver

This commit adds a minimal Module Controller driver for the R-Car X5H SoC. It currently supports always-on power domains along with dummy module clocks and resets for the serial console.

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

[ ... ]

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

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]
Does this hardcode the index to 0 when parsing the power-domains property?

If a consumer device specifies multiple power domains in its device tree and the MDLC domain is not the first one, the genpd framework calling r8a78000_mdlc_attach_dev() will still parse index 0. Would this result in an unmatched node pointer, causing attach_dev to erroneously reject the attachment with -ENODEV?

Could the module ID validation perhaps be performed inside r8a78000_genpd_xlate() instead, where the exact spec is readily available without needing to parse the device tree again?

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 173

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]
Can this lead to a use-after-free on the priv pointer?

The scoped_guard block above locates the priv pointer but releases r8a78000_mdlc_lock as soon as the block ends.

If the MDLC provider probe fails later (e.g. in devm_reset_controller_register) or is unbound, devres unwinds and calls r8a78000_mdlc_unlink() to remove priv from the list, then frees it.

If a consumer attaches to the singleton domain and races with this unbind, could it dereference priv->mod_map here after priv has already been freed?

Quoted 8 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +8 -0
+	if (!map) {
+		dev_err(dev, "Unknown module 0x%x\n", id);
+		return -ENOENT;
+	}
+
+	dev_dbg(dev, "Ignoring HW module 0x%x\n", id);
+	return 0;
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
#7 lore raw

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

In reply to Geert Uytterhoeven

On 8/5/26 5:20 PM, Geert Uytterhoeven wrote:

Hello Geert,

[...]

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

Quoted 11 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +11 -0
+DEFINE_MDLC_RESET_WRAPPER(reset)
+DEFINE_MDLC_RESET_WRAPPER(assert)
+DEFINE_MDLC_RESET_WRAPPER(deassert)
+DEFINE_MDLC_RESET_WRAPPER(status)
+
+static const struct reset_control_ops r8a78000_mdlc_reset_ops = {
+	.reset = r8a78000_mdlc_reset,
+	.assert = r8a78000_mdlc_assert,
+	.deassert = r8a78000_mdlc_deassert,
+	.status = r8a78000_mdlc_status,
+};

Please keep the list sorted alphabetically.

Quoted 7 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +7 -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;

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

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+	unsigned int id;
+	int ret;
+
+	ret = of_parse_phandle_with_args(np, "power-domains",
+					 "#power-domain-cells", 0, &pd_spec);
+	if (ret < 0)
+		return ret;
+
+	if (pd_spec.args_count != 2) {
+		of_node_put(pd_spec.np);

Maybe some "goto error" fail path which does of_node_put() wouldn't hurt here, since the of_node_put() is duplicated in here multiple times.

Quoted 28 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +28 -0
+		return -EINVAL;
+	}
+
+	scoped_guard(mutex, &r8a78000_mdlc_lock) {
+		hlist_for_each_entry(priv, &r8a78000_mdlc_list, link) {
+			if (priv->np == pd_spec.np)
+				break;
+		}
+	}
+
+	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);
+	if (!map) {
+		dev_err(dev, "Unknown module 0x%x\n", id);
+		return -ENOENT;
+	}
+
+	dev_dbg(dev, "Ignoring HW module 0x%x\n", id);
+	return 0;
+}

[...]

Quoted 25 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +25 -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);

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

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -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 dev_err_probe() might be more appropriate here, even if that would be more chatty until the support for various MDLC nodes lands.

Some dev_info_probe() would be even better, but we don't have that.

[...]

#8 lore raw

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

Hi Marek,

Thanks for your comments!

Quoted 14 lines · Marek Vasut

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

Quoted 11 lines · Geert Uytterhoeven
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +11 -0
+DEFINE_MDLC_RESET_WRAPPER(reset)
+DEFINE_MDLC_RESET_WRAPPER(assert)
+DEFINE_MDLC_RESET_WRAPPER(deassert)
+DEFINE_MDLC_RESET_WRAPPER(status)
+
+static const struct reset_control_ops r8a78000_mdlc_reset_ops = {
+     .reset = r8a78000_mdlc_reset,
+     .assert = r8a78000_mdlc_assert,
+     .deassert = r8a78000_mdlc_deassert,
+     .status = r8a78000_mdlc_status,
+};

Please keep the list sorted alphabetically.

This matches the order in which the members of struct reset_control_ops are defined.

Quoted 12 lines
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);
Quoted 8 lines

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

Quoted 5 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +5 -0
+     if (ret < 0)
+             return ret;
+
+     if (pd_spec.args_count != 2) {
+             of_node_put(pd_spec.np);

Maybe some "goto error" fail path which does of_node_put() wouldn't hurt here, since the of_node_put() is duplicated in here multiple times.

I'd rather keep it like this, as of_node_put() must not be called in all error paths. Moreover, SCMI remapping will add more error paths, and multiple fail* labels.

Quoted 32 lines
Quoted 29 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +28 -0
+             return -EINVAL;
+     }
+
+     scoped_guard(mutex, &r8a78000_mdlc_lock) {
+             hlist_for_each_entry(priv, &r8a78000_mdlc_list, link) {
+                     if (priv->np == pd_spec.np)
+                             break;
+             }
+     }
+
+     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);
+     if (!map) {
+             dev_err(dev, "Unknown module 0x%x\n", id);
+             return -ENOENT;
+     }
+
+     dev_dbg(dev, "Ignoring HW module 0x%x\n", id);
+     return 0;
+}

[...]

Quoted 8 lines

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

Quoted 5 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +4 -0
+static int r8a78000_mdlc_probe(struct platform_device *pdev)
+{
 
+     if (!info->base) {
+             dev_dbg(dev, "Unsupported MDLC instance 0x%pa\n", &res->start);

return dev_err_probe() might be more appropriate here, even if that would be more chatty until the support for various MDLC nodes lands.

Indeed, it would be very chatty, and may confuse users, that's why I used dev_dbg(). We can revisit that later.

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
#9 lore raw

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

On 8/6/26 9:49 AM, Geert Uytterhoeven wrote:

Hello Geert,

Quoted 8 lines
Quoted 5 lines

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

Quoted 2 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +2 -0
+     if (!info->base) {
+             dev_dbg(dev, "Unsupported MDLC instance 0x%pa\n", &res->start);

return dev_err_probe() might be more appropriate here, even if that would be more chatty until the support for various MDLC nodes lands.

Indeed, it would be very chatty, and may confuse users, that's why I used dev_dbg(). We can revisit that later.

All right.

Signature · 2 lines
Best regards,
Marek Vasut
#10 lore raw

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

In reply to Geert Uytterhoeven
Quoted 37 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 module clocks and resets for the serial console (which is enabled by the boot loader).

---
v3:
- Replace <linux/mod_devicetable.h> by more specific

    <linux/device-id/of.h> in v7.2-rc2,

- Add a comment to document only always-on domains are supported,
- Consistently use /* sentinel */ for zero sentinels,
- Drop trailing commas from sentinels,

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 | 330 +++++++++++++++++++++++
 drivers/soc/renesas/Kconfig              |   1 +
 4 files changed, 336 insertions(+)
 create mode 100644 drivers/pmdomain/renesas/r8a78000-mdlc.c
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +0 -0
new file mode 100644
index 0000000000000000..5c8acead7cff9bdd
@@ -0,0 +1,330 @@

[...]

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+#define DEFINE_MDLC_RESET_WRAPPER(op)					    \
+	static int r8a78000_mdlc_ ## op(struct reset_controller_dev *rcdev, \
+					unsigned long id)		    \
+	{								    \
+		struct r8a78000_mdlc_priv *priv = rcdev_to_priv(rcdev);	    \
+									    \
+		dev_dbg(priv->dev, "%s: Ignoring\n", __func__);		    \
+		return 0;						    \
+	}
+

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

Quoted 10 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +10 -0
+DEFINE_MDLC_RESET_WRAPPER(reset)
+DEFINE_MDLC_RESET_WRAPPER(assert)
+DEFINE_MDLC_RESET_WRAPPER(deassert)
+DEFINE_MDLC_RESET_WRAPPER(status)
+
+static const struct reset_control_ops r8a78000_mdlc_reset_ops = {
+	.reset = r8a78000_mdlc_reset,
+	.assert = r8a78000_mdlc_assert,
+	.deassert = r8a78000_mdlc_deassert,
+	.status = r8a78000_mdlc_status,

Are .reset and .status needed by any consumers?
I'd leave them -ENOTSUPP otherwise.

regards
Philipp

#11 lore raw

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

Hi Philipp,

Quoted 54 lines · Philipp Zabel
Quoted 37 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 module clocks and resets for the serial console (which is enabled by the boot loader).

---
v3:
- Replace <linux/mod_devicetable.h> by more specific

    <linux/device-id/of.h> in v7.2-rc2,

- Add a comment to document only always-on domains are supported,
- Consistently use /* sentinel */ for zero sentinels,
- Drop trailing commas from sentinels,

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 | 330 +++++++++++++++++++++++
 drivers/soc/renesas/Kconfig              |   1 +
 4 files changed, 336 insertions(+)
 create mode 100644 drivers/pmdomain/renesas/r8a78000-mdlc.c
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +0 -0
new file mode 100644
index 0000000000000000..5c8acead7cff9bdd
@@ -0,0 +1,330 @@

[...]

Quoted 15 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +15 -0
+#define DEFINE_MDLC_RESET_WRAPPER(op)                                            \
+     static int r8a78000_mdlc_ ## op(struct reset_controller_dev *rcdev, \
+                                     unsigned long id)                   \
+     {                                                                   \
+             struct r8a78000_mdlc_priv *priv = rcdev_to_priv(rcdev);     \
+                                                                         \
+             dev_dbg(priv->dev, "%s: Ignoring\n", __func__);             \
+             return 0;                                                   \
+     }
+
+DEFINE_MDLC_RESET_WRAPPER(reset)
+DEFINE_MDLC_RESET_WRAPPER(assert)
+DEFINE_MDLC_RESET_WRAPPER(deassert)
+DEFINE_MDLC_RESET_WRAPPER(status)
+
Quoted 8 lines

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

Quoted 5 lines
drivers/pmdomain/renesas/r8a78000-mdlc.c new file +5 -0
+static const struct reset_control_ops r8a78000_mdlc_reset_ops = {
+     .reset = r8a78000_mdlc_reset,
+     .assert = r8a78000_mdlc_assert,
+     .deassert = r8a78000_mdlc_deassert,
+     .status = r8a78000_mdlc_status,

Are .reset and .status needed by any consumers?
I'd leave them -ENOTSUPP otherwise.

.reset is used by a variety of R-Car drivers. .status is used by the R-Car I2C and PCIe drivers.

So both will be used later.

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

---
v3:
- Add Reviewed-by,

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
#13 lore raw

PATCH v3 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.

---
v3:
- Add Reviewed-by,
- Sort MDLC nodes (alphabetically, by label),

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..9a07753b221541ed 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_aon: system-controller@c1338000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc1338000 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_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_dsp: system-controller@cbe90000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xcbe90000 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_hscn: system-controller@c9c90000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc9c90000 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_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_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_rt: system-controller@19440000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0x19440000 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_top: system-controller@c6480000 {
+			compatible = "renesas,r8a78000-mdlc";
+			reg = <0 0xc6480000 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_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;
+		};
 	};
 
 	timer {
Signature · 1 line
2.43.0
#14 lore raw
In reply to Geert Uytterhoeven
Quoted 43 lines · Geert Uytterhoeven

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.
Note that this series depends on v7.2-rc2, due to the use of <linux/device-id/of.h>.

Changes compared to v2[1]:
- Add Acked-by, Reviewed-by,
- Add fixed-rate clocks to kerneldoc of r8a78000_cpg_priv.map,
- Use devm_clk_hw_register_fixed_rate(), drop unregister_fixed_clks(),
- Drop fill_clk_map(), as it is not really needed until SCMI remapping support is added later,
- Replace <linux/mod_devicetable.h> by more specific

    <linux/device-id/of.h> in v7.2-rc2,

- Add a comment to document only always-on domains are supported,
- Consistently use /* sentinel */ for zero sentinels,
- Drop trailing commas from sentinels,
- Sort MDLC nodes (alphabetically, by label).

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

Note that this series does not use or rely on SCMI in any way. SCMI remapping support will be added in a subsequent series (old version at [3]).
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 (including a rebased and updated version of [3]) to [4].

Quoted 6 lines

While I know it is getting late in the cycle, this work (especially the DT bindings) are a dependency for about any R-Car X5H progress, so it would be good to have it included in v7.3.
Hence I plan to queue the clock patches (1, 3) in renesas-clk for v7.3 (Stephen still hasn't merged my earlier PR for v7.3 anyway).
Ulf: It would be great if you could take the pmdomain patches (2, 4).

Patch 2 applied for next, but I left patch4 for now as it didn't apply cleanly (drivers/soc/renesas/Kconfig had a conflict), thanks!

Quoted 3 lines

The DTS changes (5-6) can wait for v7.4; they have a hard dependency on the presence of both drivers anyway.

[...]

Kind regards
Uffe

#15 lore raw

Hi Ulf,

Quoted 42 lines · Ulf Hansson
Quoted 40 lines · Geert Uytterhoeven

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.
Note that this series depends on v7.2-rc2, due to the use of <linux/device-id/of.h>.

Changes compared to v2[1]:
- Add Acked-by, Reviewed-by,
- Add fixed-rate clocks to kerneldoc of r8a78000_cpg_priv.map,
- Use devm_clk_hw_register_fixed_rate(), drop unregister_fixed_clks(),
- Drop fill_clk_map(), as it is not really needed until SCMI remapping support is added later,
- Replace <linux/mod_devicetable.h> by more specific

    <linux/device-id/of.h> in v7.2-rc2,

- Add a comment to document only always-on domains are supported,
- Consistently use /* sentinel */ for zero sentinels,
- Drop trailing commas from sentinels,
- Sort MDLC nodes (alphabetically, by label).

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

Note that this series does not use or rely on SCMI in any way. SCMI remapping support will be added in a subsequent series (old version at [3]).
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 (including a rebased and updated version of [3]) to [4].

Quoted 8 lines
Quoted 6 lines

While I know it is getting late in the cycle, this work (especially the DT bindings) are a dependency for about any R-Car X5H progress, so it would be good to have it included in v7.3.
Hence I plan to queue the clock patches (1, 3) in renesas-clk for v7.3 (Stephen still hasn't merged my earlier PR for v7.3 anyway).
Ulf: It would be great if you could take the pmdomain patches (2, 4).

Patch 2 applied for next, but I left patch4 for now as it didn't apply

Thank you!

Quoted 1 line

cleanly (drivers/soc/renesas/Kconfig had a conflict), thanks!

I guess your tree still has the duplicate "default ARCH_RENESAS"? Patch 4 just adds a single line there, and the conflict should be easy to fix.

If you want to send me a new patch, please let me know.

Thanks again!

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

#16 lore raw

Hi Ulf,

Quoted 54 lines · Geert Uytterhoeven
Quoted 42 lines · Ulf Hansson
Quoted 40 lines · Geert Uytterhoeven

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.
Note that this series depends on v7.2-rc2, due to the use of <linux/device-id/of.h>.

Changes compared to v2[1]:
- Add Acked-by, Reviewed-by,
- Add fixed-rate clocks to kerneldoc of r8a78000_cpg_priv.map,
- Use devm_clk_hw_register_fixed_rate(), drop unregister_fixed_clks(),
- Drop fill_clk_map(), as it is not really needed until SCMI remapping support is added later,
- Replace <linux/mod_devicetable.h> by more specific

    <linux/device-id/of.h> in v7.2-rc2,

- Add a comment to document only always-on domains are supported,
- Consistently use /* sentinel */ for zero sentinels,
- Drop trailing commas from sentinels,
- Sort MDLC nodes (alphabetically, by label).

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

Note that this series does not use or rely on SCMI in any way. SCMI remapping support will be added in a subsequent series (old version at [3]).
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 (including a rebased and updated version of [3]) to [4].

Quoted 8 lines
Quoted 6 lines

While I know it is getting late in the cycle, this work (especially the DT bindings) are a dependency for about any R-Car X5H progress, so it would be good to have it included in v7.3.
Hence I plan to queue the clock patches (1, 3) in renesas-clk for v7.3 (Stephen still hasn't merged my earlier PR for v7.3 anyway).
Ulf: It would be great if you could take the pmdomain patches (2, 4).

Patch 2 applied for next, but I left patch4 for now as it didn't apply

Thank you!

Quoted 7 lines
Quoted 1 line

cleanly (drivers/soc/renesas/Kconfig had a conflict), thanks!

I guess your tree still has the duplicate "default ARCH_RENESAS"? Patch 4 just adds a single line there, and the conflict should be easy to fix.

If you want to send me a new patch, please let me know.

I have sent a v4 against pmdomain/next:
https://lore.kernel.org/all/d4bd0cc7f26c1bcdc260edb994b4971cb5dd3a10.1786438424.git.geert+renesas@glider.be/

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