[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1b071599b84c4519a81990fbfe09782b@emh-metering.com>
Date: Mon, 3 Nov 2025 06:50:20 +0000
From: "Krebs, Olaf" <Olaf.Krebs@...-metering.com>
To: Shawn Guo <shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>,
Pengutronix Kernel Team <kernel@...gutronix.de>, Fabio Estevam
<festevam@...il.com>, "open list:PWM SUBSYSTEM" <linux-pwm@...r.kernel.org>,
"open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" <imx@...ts.linux.dev>,
"moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
<linux-arm-kernel@...ts.infradead.org>, open list
<linux-kernel@...r.kernel.org>
Subject: [PATCH v3] Fix IMX PWM period setting
From: Olaf Krebs <okr@...w.emh-meter.de>
If a second PWM is requested by a driver before the first is configured, trying to configure any of these results in .user_count > 1 and thus the configuration fails.
Fix that by only erroring out by additionally checking if the period is actually configured.
Exapmle: Using of 3 PWM channels to control a RGB LED.
DTS-Config for an imx93-Board:
...
led-controller {
compatible = "pwm-leds-multicolor";
multi-led {
label = "RGBled";
color = <LED_COLOR_ID_RGB>;
function = LED_FUNCTION_INDICATOR;
max-brightness = <255>;
led-red {
pwms = <&tpm5 0 1000000 PWM_POLARITY_INVERTED>;
color = <LED_COLOR_ID_RED>;
};
led-green {
pwms = <&tpm6 2 1000000 PWM_POLARITY_INVERTED>;
color = <LED_COLOR_ID_GREEN>;
};
led-blue {
pwms = <&tpm5 1 1000000 PWM_POLARITY_INVERTED>;
color = <LED_COLOR_ID_BLUE>;
};
};
};
...
Without this patch, an BUSY-error message is generated during initialization.
[ 7.395326] leds_pwm_multicolor led-controller: error -EBUSY: failed to set led PWM value for (null)
[ 7.405167] leds_pwm_multicolor led-controller: probe with driver leds_pwm_multicolor failed with error -16
Signed-off-by: Olaf krebs <olaf.krebs@...-metering.com>
---
drivers/pwm/pwm-imx-tpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index 5b399de16d60..411daa7711f1 100644
--- a/drivers/pwm/pwm-imx-tpm.c
+++ b/drivers/pwm/pwm-imx-tpm.c
@@ -190,7 +190,7 @@ static int pwm_imx_tpm_apply_hw(struct pwm_chip *chip,
* there are multiple channels in use with different
* period settings.
*/
- if (tpm->user_count > 1)
+ if ((tpm->user_count > 1) && (tpm->real_period != 0))
return -EBUSY;
val = readl(tpm->base + PWM_IMX_TPM_SC);
--
2.47.3
Powered by blists - more mailing lists