* [PATCH] Fix IMX PWM period setting
[not found] <20251030084727.4098222-1-user@jenkins>
@ 2025-10-30 8:51 ` Krebs, Olaf
2025-10-30 10:40 ` Russell King (Oracle)
0 siblings, 1 reply; 4+ messages in thread
From: Krebs, Olaf @ 2025-10-30 8:51 UTC (permalink / raw)
To: Uwe Kleine-König, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, open list:PWM SUBSYSTEM,
open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
open list
From: Olaf krebs <olaf.krebs@emh-metering.com>
We use 3 PWM channels to control an RGB LED. Without this patch we get an error:
[ 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
Our 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>;
};
};
};
...
Signed-off-by: Olaf krebs <olaf.krebs@emh-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..82db43f56da8 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) && (tmp->real_period != 0))
return -EBUSY;
val = readl(tpm->base + PWM_IMX_TPM_SC);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix IMX PWM period setting
2025-10-30 8:51 ` [PATCH] Fix IMX PWM period setting Krebs, Olaf
@ 2025-10-30 10:40 ` Russell King (Oracle)
0 siblings, 0 replies; 4+ messages in thread
From: Russell King (Oracle) @ 2025-10-30 10:40 UTC (permalink / raw)
To: Krebs, Olaf
Cc: Uwe Kleine-König, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, open list:PWM SUBSYSTEM,
open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
open list
On Thu, Oct 30, 2025 at 08:51:20AM +0000, Krebs, Olaf wrote:
> From: Olaf krebs <olaf.krebs@emh-metering.com>
>
> We use 3 PWM channels to control an RGB LED. Without this patch we get an error:
Not build-tested.
> - if (tpm->user_count > 1)
> + if ((tpm->user_count > 1) && (tmp->real_period != 0))
"tmp" vs "tpm". As there's no variable called "tmp" in this function...
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Fix IMX PWM period setting
[not found] <20251030114641.4109598-1-user@jenkins>
@ 2025-10-30 11:53 ` Krebs, Olaf
2025-10-30 17:13 ` Uwe Kleine-König
0 siblings, 1 reply; 4+ messages in thread
From: Krebs, Olaf @ 2025-10-30 11:53 UTC (permalink / raw)
To: Uwe Kleine-König, Shawn Guo, Sascha Hauer,
Pengutronix Kernel Team, Fabio Estevam, open list:PWM SUBSYSTEM,
open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
open list
From: Olaf Krebs <okr@smgw.emh-meter.de>
We use 3 PWM channels to control an RGB LED. 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
Our 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>;
};
};
};
...
Signed-off-by: Olaf krebs <olaf.krebs@emh-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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix IMX PWM period setting
2025-10-30 11:53 ` Krebs, Olaf
@ 2025-10-30 17:13 ` Uwe Kleine-König
0 siblings, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2025-10-30 17:13 UTC (permalink / raw)
To: Krebs, Olaf
Cc: Shawn Guo, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
open list:PWM SUBSYSTEM,
open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE,
open list
[-- Attachment #1: Type: text/plain, Size: 2673 bytes --]
Hello,
please version your patch revision, i.e. you should have put "v2" in the
subject. The easiest way to achieve that is by passing -v2 to `git
format-patch` (or `git send-email` if you use that directly). So for the
next revision use -v3.
On Thu, Oct 30, 2025 at 11:53:27AM +0000, Krebs, Olaf wrote:
> From: Olaf Krebs <okr@smgw.emh-meter.de>
>
> We use 3 PWM channels to control an RGB LED. 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
>
> Our 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>;
> };
> };
> };
> ...
I would prefer something like the following text here:
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.
> Signed-off-by: Olaf krebs <olaf.krebs@emh-metering.com>
S-o-b missmatch. Do you know checkpatch? That one also wails:
WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
> ---
> 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;
Please drop the added parenthesis.
Thinking about the error here, I wonder if a saner check would involve
enable_count instead of user_count.
> val = readl(tpm->base + PWM_IMX_TPM_SC);
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-30 17:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251030084727.4098222-1-user@jenkins>
2025-10-30 8:51 ` [PATCH] Fix IMX PWM period setting Krebs, Olaf
2025-10-30 10:40 ` Russell King (Oracle)
[not found] <20251030114641.4109598-1-user@jenkins>
2025-10-30 11:53 ` Krebs, Olaf
2025-10-30 17:13 ` Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).