The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v2 0/3] clk: renesas: r9a06g032: Add reset controller to clear resets for mii converter
@ 2026-11-20 21:16 Kyle Hendry via B4 Relay
  2026-11-20 21:16 ` [PATCH v2 1/3] dt-bindings: clock: r9a06g032-sysctrl: Document reset cells Kyle Hendry via B4 Relay
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kyle Hendry via B4 Relay @ 2026-11-20 21:16 UTC (permalink / raw)
  To: Geert Uytterhoeven, Stephen Boyd, Brian Masney, Jerome Brunet,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Magnus Damm,
	Fabrizio Castro, Philipp Zabel
  Cc: linux-renesas-soc, linux-clk, devicetree, linux-kernel,
	Kyle Hendry, Wolfram Sang

On the rzn1, there are two resets for the mii converter in the system
controller. If they are not cleared by the bootloader then the kernel needs
to do it. 

To handle this, I've added a reset controller interface to the clock
driver so the miic driver can deassert them.

---
Changes in v2:
- Drop patches for pcs-rzn1-miic to be submitted separately to netdev
- Add reset_controller_dev to r9a06g032_priv fix build error
- Use designated initializers for the reset bit definitions
- Change macro for getting priv data to static inline
- Drop unnecessary reset from controller ops
- Remove debugging argument from r9a06g032_reset_set
- Remove configuration of of_reset_n_cells 
- Add #reset-cells to required and example in schema
- Make r9a06g032_reset_status correctly return the active low status
- Move reset controller register earlier in probe to better handle failure
- Link to v1: https://lore.kernel.org/r/20261119-rzn1-miic-resets-v1-0-feee2bb28bb4@reliablecontrols.com

---
Kyle Hendry (3):
      dt-bindings: clock: r9a06g032-sysctrl: Document reset cells
      clk: renesas: r9a06g032: Add reset controller
      ARM: dts: renesas: r9a06g032: Add #reset-cells to system controller node

 .../bindings/clock/renesas,r9a06g032-sysctrl.yaml  |  5 ++
 arch/arm/boot/dts/renesas/r9a06g032.dtsi           |  1 +
 drivers/clk/renesas/r9a06g032-clocks.c             | 59 ++++++++++++++++++++++
 include/dt-bindings/clock/r9a06g032-sysctrl.h      |  3 ++
 4 files changed, 68 insertions(+)
---
base-commit: 662377fd1bb1d7cf4e97d312255fed868f56342d
change-id: 20261027-rzn1-miic-resets-8308515aa2c0

Best regards,
-- 
Kyle Hendry <khendry@reliablecontrols.com>



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

* [PATCH v2 1/3] dt-bindings: clock: r9a06g032-sysctrl: Document reset cells
  2026-11-20 21:16 [PATCH v2 0/3] clk: renesas: r9a06g032: Add reset controller to clear resets for mii converter Kyle Hendry via B4 Relay
@ 2026-11-20 21:16 ` Kyle Hendry via B4 Relay
  2026-11-20 21:16 ` [PATCH v2 2/3] clk: renesas: r9a06g032: Add reset controller Kyle Hendry via B4 Relay
  2026-11-20 21:16 ` [PATCH v2 3/3] ARM: dts: renesas: r9a06g032: Add #reset-cells to system controller node Kyle Hendry via B4 Relay
  2 siblings, 0 replies; 6+ messages in thread
From: Kyle Hendry via B4 Relay @ 2026-11-20 21:16 UTC (permalink / raw)
  To: Geert Uytterhoeven, Stephen Boyd, Brian Masney, Jerome Brunet,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Magnus Damm,
	Fabrizio Castro, Philipp Zabel
  Cc: linux-renesas-soc, linux-clk, devicetree, linux-kernel,
	Kyle Hendry

From: Kyle Hendry <khendry@reliablecontrols.com>

Update the rzn1 system controller to indicate it can be a reset controller
and add defines for miic resets

Signed-off-by: Kyle Hendry <khendry@reliablecontrols.com>
---
 .../devicetree/bindings/clock/renesas,r9a06g032-sysctrl.yaml         | 5 +++++
 include/dt-bindings/clock/r9a06g032-sysctrl.h                        | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/clock/renesas,r9a06g032-sysctrl.yaml b/Documentation/devicetree/bindings/clock/renesas,r9a06g032-sysctrl.yaml
index 26d94cedc871..70ccc315a10c 100644
--- a/Documentation/devicetree/bindings/clock/renesas,r9a06g032-sysctrl.yaml
+++ b/Documentation/devicetree/bindings/clock/renesas,r9a06g032-sysctrl.yaml
@@ -36,6 +36,9 @@ properties:
   '#clock-cells':
     const: 1
 
+  '#reset-cells':
+    const: 1
+
   '#power-domain-cells':
     const: 0
 
@@ -56,6 +59,7 @@ required:
   - clocks
   - clock-names
   - '#clock-cells'
+  - '#reset-cells'
   - '#power-domain-cells'
 
 additionalProperties: false
@@ -69,5 +73,6 @@ examples:
                      <&ext_rgmii_ref>;
             clock-names = "mclk", "rtc", "jtag", "rgmii_ref_ext";
             #clock-cells = <1>;
+            #reset-cells = <1>;
             #power-domain-cells = <0>;
     };
diff --git a/include/dt-bindings/clock/r9a06g032-sysctrl.h b/include/dt-bindings/clock/r9a06g032-sysctrl.h
index d9d7b8b4f426..e3059c50f7c3 100644
--- a/include/dt-bindings/clock/r9a06g032-sysctrl.h
+++ b/include/dt-bindings/clock/r9a06g032-sysctrl.h
@@ -146,4 +146,7 @@
 #define R9A06G032_CLK_UART6		152
 #define R9A06G032_CLK_UART7		153
 
+#define R9A06G032_RST_TS		1
+#define R9A06G032_RST_MIIC		2
+
 #endif /* __DT_BINDINGS_R9A06G032_SYSCTRL_H__ */

-- 
2.53.0



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

* [PATCH v2 2/3] clk: renesas: r9a06g032: Add reset controller
  2026-11-20 21:16 [PATCH v2 0/3] clk: renesas: r9a06g032: Add reset controller to clear resets for mii converter Kyle Hendry via B4 Relay
  2026-11-20 21:16 ` [PATCH v2 1/3] dt-bindings: clock: r9a06g032-sysctrl: Document reset cells Kyle Hendry via B4 Relay
@ 2026-11-20 21:16 ` Kyle Hendry via B4 Relay
  2026-11-20 22:17   ` Wolfram Sang
  2026-11-20 22:24   ` Wolfram Sang
  2026-11-20 21:16 ` [PATCH v2 3/3] ARM: dts: renesas: r9a06g032: Add #reset-cells to system controller node Kyle Hendry via B4 Relay
  2 siblings, 2 replies; 6+ messages in thread
From: Kyle Hendry via B4 Relay @ 2026-11-20 21:16 UTC (permalink / raw)
  To: Geert Uytterhoeven, Stephen Boyd, Brian Masney, Jerome Brunet,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Magnus Damm,
	Fabrizio Castro, Philipp Zabel
  Cc: linux-renesas-soc, linux-clk, devicetree, linux-kernel,
	Kyle Hendry

From: Kyle Hendry <khendry@reliablecontrols.com>

The rzn1 system controller has two resets that need to be cleared for the
mii converter to work. They are not directly associated with any clocks
so they need a reset controller to set them.

They are documented in the PWRCTRL_SWITCHCTRL (0x4000C188) register as:

Bit 3: RSTN_CLK25 - Active low Reset for Timestamp signal selection logic
Bit 4: RSTN_ETH - Active low Reset for RGMII/RMII Converter (50 MHz).

Add a reset controller and add resets for those bits.

Signed-off-by: Kyle Hendry <khendry@reliablecontrols.com>
---
 drivers/clk/renesas/r9a06g032-clocks.c | 59 ++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/drivers/clk/renesas/r9a06g032-clocks.c b/drivers/clk/renesas/r9a06g032-clocks.c
index 3df3f2b2c6de..a474302987aa 100644
--- a/drivers/clk/renesas/r9a06g032-clocks.c
+++ b/drivers/clk/renesas/r9a06g032-clocks.c
@@ -21,6 +21,7 @@
 #include <linux/pm_clock.h>
 #include <linux/pm_domain.h>
 #include <linux/reboot.h>
+#include <linux/reset-controller.h>
 #include <linux/slab.h>
 #include <linux/soc/renesas/r9a06g032-sysctrl.h>
 #include <linux/spinlock.h>
@@ -675,7 +676,13 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {
 		RB(0xec, 16), RB(0xec, 17), RB(0xec, 18), RB(0xec, 19)),
 };
 
+static const struct regbit r9a06g032_resets[] = {
+	[R9A06G032_RST_TS]	= RB(0x188, 3),
+	[R9A06G032_RST_MIIC]	= RB(0x188, 4),
+};
+
 struct r9a06g032_priv {
+	struct reset_controller_dev rcdev;
 	struct clk_onecell_data data;
 	spinlock_t lock; /* protects concurrent access to gates */
 	void __iomem *reg;
@@ -1307,6 +1314,51 @@ static void __init r9a06g032_init_h2mode(struct r9a06g032_priv *clocks)
 	writel(usb, clocks->reg + R9A06G032_SYSCTRL_USB);
 }
 
+static inline
+struct r9a06g032_priv *priv_from_rcdev(struct reset_controller_dev *resetdev)
+{
+	return container_of(resetdev, struct r9a06g032_priv, rcdev);
+}
+
+static int r9a06g032_reset_set(struct reset_controller_dev *rcdev,
+				bool set, unsigned long id)
+{
+	struct r9a06g032_priv *priv = priv_from_rcdev(rcdev);
+	unsigned long flags;
+
+	spin_lock_irqsave(&priv->lock, flags);
+	clk_rdesc_set(priv, r9a06g032_resets[id], set);
+	spin_unlock_irqrestore(&priv->lock, flags);
+
+	return 0;
+}
+
+static int r9a06g032_reset_assert(struct reset_controller_dev *rcdev,
+					unsigned long id)
+{
+	return r9a06g032_reset_set(rcdev, false, id);
+}
+
+static int r9a06g032_reset_deassert(struct reset_controller_dev *rcdev,
+					unsigned long id)
+{
+	return r9a06g032_reset_set(rcdev, true, id);
+}
+
+static int r9a06g032_reset_status(struct reset_controller_dev *rcdev,
+					unsigned long id)
+{
+	struct r9a06g032_priv *priv = priv_from_rcdev(rcdev);
+
+	return !clk_rdesc_get(priv, r9a06g032_resets[id]);
+}
+
+static const struct reset_control_ops r9a06g032_reset_ops = {
+	.assert = r9a06g032_reset_assert,
+	.deassert = r9a06g032_reset_deassert,
+	.status = r9a06g032_reset_status,
+};
+
 static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -1394,6 +1446,13 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
 	if (error)
 		return error;
 
+	clocks->rcdev.ops = &r9a06g032_reset_ops;
+	clocks->rcdev.of_node = np;
+	clocks->rcdev.nr_resets = ARRAY_SIZE(r9a06g032_resets);
+	error =  devm_reset_controller_register(dev, &clocks->rcdev);
+	if (error)
+		return error;
+
 	error = r9a06g032_add_clk_domain(dev);
 	if (error)
 		return error;

-- 
2.53.0



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

* [PATCH v2 3/3] ARM: dts: renesas: r9a06g032: Add #reset-cells to system controller node
  2026-11-20 21:16 [PATCH v2 0/3] clk: renesas: r9a06g032: Add reset controller to clear resets for mii converter Kyle Hendry via B4 Relay
  2026-11-20 21:16 ` [PATCH v2 1/3] dt-bindings: clock: r9a06g032-sysctrl: Document reset cells Kyle Hendry via B4 Relay
  2026-11-20 21:16 ` [PATCH v2 2/3] clk: renesas: r9a06g032: Add reset controller Kyle Hendry via B4 Relay
@ 2026-11-20 21:16 ` Kyle Hendry via B4 Relay
  2 siblings, 0 replies; 6+ messages in thread
From: Kyle Hendry via B4 Relay @ 2026-11-20 21:16 UTC (permalink / raw)
  To: Geert Uytterhoeven, Stephen Boyd, Brian Masney, Jerome Brunet,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Magnus Damm,
	Fabrizio Castro, Philipp Zabel
  Cc: linux-renesas-soc, linux-clk, devicetree, linux-kernel,
	Wolfram Sang, Kyle Hendry

From: Kyle Hendry <khendry@reliablecontrols.com>

Update the rzn1 system controller node with cells for the reset controller

Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Kyle Hendry <khendry@reliablecontrols.com>
---
 arch/arm/boot/dts/renesas/r9a06g032.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/renesas/r9a06g032.dtsi b/arch/arm/boot/dts/renesas/r9a06g032.dtsi
index 5455dccfbdd0..f2bf087f7ad2 100644
--- a/arch/arm/boot/dts/renesas/r9a06g032.dtsi
+++ b/arch/arm/boot/dts/renesas/r9a06g032.dtsi
@@ -146,6 +146,7 @@ sysctrl: system-controller@4000c000 {
 			compatible = "renesas,r9a06g032-sysctrl";
 			reg = <0x4000c000 0x1000>;
 			#clock-cells = <1>;
+			#reset-cells = <1>;
 			#power-domain-cells = <0>;
 
 			clocks = <&ext_mclk>, <&ext_rtc_clk>,

-- 
2.53.0



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

* Re: [PATCH v2 2/3] clk: renesas: r9a06g032: Add reset controller
  2026-11-20 21:16 ` [PATCH v2 2/3] clk: renesas: r9a06g032: Add reset controller Kyle Hendry via B4 Relay
@ 2026-11-20 22:17   ` Wolfram Sang
  2026-11-20 22:24   ` Wolfram Sang
  1 sibling, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2026-11-20 22:17 UTC (permalink / raw)
  To: khendry
  Cc: Geert Uytterhoeven, Stephen Boyd, Brian Masney, Jerome Brunet,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Magnus Damm,
	Fabrizio Castro, Philipp Zabel, linux-renesas-soc, linux-clk,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1283 bytes --]


> > +static const struct regbit r9a06g032_resets[] = {
> > +	[R9A06G032_RST_TS]	= RB(0x188, 3),
> > +	[R9A06G032_RST_MIIC]	= RB(0x188, 4),
> > +};
> 
> [Severity: Medium]
> Since R9A06G032_RST_TS is 1 and R9A06G032_RST_MIIC is 2, can reset ID 0 be
> requested and accepted even though r9a06g032_resets[0] is unpopulated?
> 
> ARRAY_SIZE(r9a06g032_resets) is 3, and without a custom xlate callback,
> fwnode_reset_simple_xlate() allows index 0.  If a consumer requests reset
> 0, assert and deassert silently become no-ops in clk_rdesc_set(), while
> r9a06g032_reset_status() calls clk_rdesc_get() with { .bit = 0, .reg = 0 }
> and reads bit 0 of offset 0x00 (R9A06G032_SYSCTRL_USB).
> 
> Either the reset IDs should be 0-based, or the driver should provide an
> xlate callback that rejects unpopulated entries where !reg && !bit.

Seems like starting from 0 is the better (and easier) option after all.

> [Severity: Medium]
> Should CLK_R9A06G032 select RESET_CONTROLLER in
> drivers/clk/renesas/Kconfig?
> 
> When CONFIG_RESET_CONTROLLER is disabled, devm_reset_controller_register()
> compiles to a no-op stub returning 0, so the reset controller is never
> registered and consumers such as pcs-rzn1-miic fail probe with
> -EOPNOTSUPP.

I agree.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH v2 2/3] clk: renesas: r9a06g032: Add reset controller
  2026-11-20 21:16 ` [PATCH v2 2/3] clk: renesas: r9a06g032: Add reset controller Kyle Hendry via B4 Relay
  2026-11-20 22:17   ` Wolfram Sang
@ 2026-11-20 22:24   ` Wolfram Sang
  1 sibling, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2026-11-20 22:24 UTC (permalink / raw)
  To: khendry
  Cc: Geert Uytterhoeven, Stephen Boyd, Brian Masney, Jerome Brunet,
	Rob Herring, Krzysztof Kozlowski, Conor Dooley, Magnus Damm,
	Fabrizio Castro, Philipp Zabel, linux-renesas-soc, linux-clk,
	devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 528 bytes --]


>  struct r9a06g032_priv {
> +	struct reset_controller_dev rcdev;

Minor: I would put it last. Wrt cache lines, this member is not so
important.

>  	struct clk_onecell_data data;
>  	spinlock_t lock; /* protects concurrent access to gates */
>  	void __iomem *reg;
> +static const struct reset_control_ops r9a06g032_reset_ops = {
> +	.assert = r9a06g032_reset_assert,
> +	.deassert = r9a06g032_reset_deassert,
> +	.status = r9a06g032_reset_status,
> +};

How do we ensure now the 5us recommended delay for reset propagation?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2026-11-20 22:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 21:16 [PATCH v2 0/3] clk: renesas: r9a06g032: Add reset controller to clear resets for mii converter Kyle Hendry via B4 Relay
2026-11-20 21:16 ` [PATCH v2 1/3] dt-bindings: clock: r9a06g032-sysctrl: Document reset cells Kyle Hendry via B4 Relay
2026-11-20 21:16 ` [PATCH v2 2/3] clk: renesas: r9a06g032: Add reset controller Kyle Hendry via B4 Relay
2026-11-20 22:17   ` Wolfram Sang
2026-11-20 22:24   ` Wolfram Sang
2026-11-20 21:16 ` [PATCH v2 3/3] ARM: dts: renesas: r9a06g032: Add #reset-cells to system controller node Kyle Hendry via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox