Skip to contentSkip to conversation

pwm: rz-mtu3: Share parent device node to MTU3 PWM

PATCH In review Martyn Welch 3 participants 5 messages Oct 9, 2025 – Dec 24, 2025 PWM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pwm: rz-mtu3: Share parent device node to MTU3 PWM

The PWM currently functions, however if we try to utilise the pwn in a device tree, for example as a pwm-backlight:

        lcd_bl: backlight {
                compatible = "pwm-backlight";
                pwms = <&mtu3 3 833333>;
		...

This fails:

[   15.603948] platform backlight: deferred probe pending: pwm-backlight: unable to request PWM

The PWM driver forms part of the Renesas Multi-Function Timer Pulse Unit
3. The PWM does not have a DT node of it's own. Share the DT node of the parent MFD device, so that the PWM channels can be referenced via phandles.

---
 drivers/pwm/pwm-rz-mtu3.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pwm/pwm-rz-mtu3.c +6 -0
index ab39bd37edafc..5825875fa0128 100644
@@ -523,6 +523,12 @@ static int rz_mtu3_pwm_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
+	/*
+	 * There is only one DT node, get it from the parent MFD device, so
+	 * that the PWM channels can be referenced via phandles
+	 */
+	dev->of_node = dev->parent->of_node;
+
 	chip->ops = &rz_mtu3_pwm_ops;
 	ret = devm_pwmchip_add(&pdev->dev, chip);
 	if (ret)
Signature · 1 line
2.51.0
#1 lore raw

Hello,

[adding maintainers of drivers/of and Krzysztof to Cc:]

Quoted 28 lines · Martyn Welch

The PWM currently functions, however if we try to utilise the pwn in a device tree, for example as a pwm-backlight:

        lcd_bl: backlight {
                compatible = "pwm-backlight";
                pwms = <&mtu3 3 833333>;
		...

This fails:

[   15.603948] platform backlight: deferred probe pending: pwm-backlight: unable to request PWM

The PWM driver forms part of the Renesas Multi-Function Timer Pulse Unit
3. The PWM does not have a DT node of it's own. Share the DT node of the parent MFD device, so that the PWM channels can be referenced via phandles.

---
 drivers/pwm/pwm-rz-mtu3.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pwm/pwm-rz-mtu3.c +0 -0
index ab39bd37edafc..5825875fa0128 100644

drivers/pwm/pwm-rz-mtu3.c static int rz_mtu3_pwm_probe(struct platform_device *pdev) · line 531

Quoted 9 lines
drivers/pwm/pwm-rz-mtu3.c +6 -0
@@ -523,6 +523,12 @@ static int rz_mtu3_pwm_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
+	/*
+	 * There is only one DT node, get it from the parent MFD device, so
+	 * that the PWM channels can be referenced via phandles
+	 */
+	dev->of_node = dev->parent->of_node;
+

I (very quickly) talked to Krzysztof about this. He said that of_node_get() should probably be used here. I wonder if device_add_of_node() is the right function to use (which uses of_node_get(), also handles fwnode and implements some safeguards).

drivers/pwm/pwm-rz-mtu3.c static int rz_mtu3_pwm_probe(struct platform_device *pdev) · line 534

Quoted 3 lines
drivers/pwm/pwm-rz-mtu3.c +0 -0
 	chip->ops = &rz_mtu3_pwm_ops;
 	ret = devm_pwmchip_add(&pdev->dev, chip);
 	if (ret)

Best regards
Uwe

#2 lore raw
Quoted 8 lines · Uwe Kleine-König
Quoted 8 lines
drivers/pwm/pwm-rz-mtu3.c +0 -0
index ab39bd37edafc..5825875fa0128 100644
@@ -523,6 +523,12 @@ static int rz_mtu3_pwm_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
Quoted 11 lines

drivers/pwm/pwm-rz-mtu3.c static int rz_mtu3_pwm_probe(struct platform_device *pdev) · line 531

Quoted 6 lines
drivers/pwm/pwm-rz-mtu3.c +6 -0
+	/*
+	 * There is only one DT node, get it from the parent MFD device, so
+	 * that the PWM channels can be referenced via phandles
+	 */
+	dev->of_node = dev->parent->of_node;
+

I (very quickly) talked to Krzysztof about this. He said that of_node_get() should probably be used here. I wonder if device_add_of_node() is the right function to use (which uses of_node_get(), also handles fwnode and implements some safeguards).

I am not so sure about device_add_of_node(). You do not need to get_device(), because reference is already hold. Although setting dev->fwnode might make sense... But, not that important I think, works with me.

Best regards,
Krzysztof

#3 lore raw

Hello,

Quoted 22 lines · Krzysztof Kozlowski
Quoted 8 lines · Uwe Kleine-König
Quoted 8 lines
drivers/pwm/pwm-rz-mtu3.c +0 -0
index ab39bd37edafc..5825875fa0128 100644
@@ -523,6 +523,12 @@ static int rz_mtu3_pwm_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
Quoted 11 lines

drivers/pwm/pwm-rz-mtu3.c static int rz_mtu3_pwm_probe(struct platform_device *pdev) · line 531

Quoted 6 lines
drivers/pwm/pwm-rz-mtu3.c +6 -0
+	/*
+	 * There is only one DT node, get it from the parent MFD device, so
+	 * that the PWM channels can be referenced via phandles
+	 */
+	dev->of_node = dev->parent->of_node;
+

I (very quickly) talked to Krzysztof about this. He said that of_node_get() should probably be used here. I wonder if device_add_of_node() is the right function to use (which uses of_node_get(), also handles fwnode and implements some safeguards).

Quoted 4 lines

I am not so sure about device_add_of_node(). You do not need to get_device(), because reference is already hold. Although setting dev->fwnode might make sense... But, not that important I think, works with me.

Note that device_add_of_node() only holds the get_device() reference temporarily as it calls put_device() before returning. So that's only to assert that the device doesn't disappear in-flight. That "locking" might not be needed here, but it also doesn't do any harm (apart from a minor runtime overhead).

Best regards
Uwe

#4 lore raw
In reply to Martyn Welch

Hello,

Quoted 12 lines · Martyn Welch

The PWM currently functions, however if we try to utilise the pwn in a device tree, for example as a pwm-backlight:

        lcd_bl: backlight {
                compatible = "pwm-backlight";
                pwms = <&mtu3 3 833333>;
		...

This fails:

[   15.603948] platform backlight: deferred probe pending: pwm-backlight: unable to request PWM
Quoted 7 lines

The PWM driver forms part of the Renesas Multi-Function Timer Pulse Unit
3. The PWM does not have a DT node of it's own. Share the DT node of the parent MFD device, so that the PWM channels can be referenced via phandles.

This thread didn't see action for a time and the patch isn't suitable to go in as is. So I'm discarding this patch from patchwork and my inbox.

Best regards
Uwe