I was able to configure pin
MX93_PAD_GPIO_IO05__TPM4_CH0
following this thread: https://community.nxp.com/t5/i-MX-Processors/imx93-GPIO-to-use-as-output-PWM-signal/m-p/1975360
It worked as pwm with the /sys/class/pwm/pwmchipX/pwm0 handle.
However, I cannot configure pin
MX93_PAD_GPIO_IO04__TPM3_CH0
to behave the same way. I can create the same handle for channel 0 on a different pwmchip but the LED is lighted up full brightness after boot. With the same set of shell commands to control the /sys/class/pwm/pwmchipX/pwm0, the scope doesn't show any pwm waveforms from pin 7 of the J1001 connector which is wired to the green LED
Do I need to do anything special for pin GPIO_IO05 or something different than GPIO_IO05?
Hi @jc2025,
For that you should have pull down resistors to avoid turning on the LEDs.
Please try populating R1036, R1037 and R1038 or use the internal pull down resistor of the chip using the next values:
pinctrl_tpm3: tpm3grp {
fsl,pins = <
MX93_PAD_GPIO_IO04__TPM3_CH0 0x59e //0x02
MX93_PAD_GPIO_IO12__TPM3_CH2 0x59e //0x02
>;
};
pinctrl_tpm4: tpm4grp {
fsl,pins = <
MX93_PAD_GPIO_IO05__TPM4_CH0 0x59e //EXP_GPIO_IO05 J1001 29
MX93_PAD_GPIO_IO13__TPM4_CH2 0x59e //EXP_GPIO_IO13 J1001 29
>;
};
You are right. The update dts file worked. And I also try using the recommended way of including the original board dts from bsp in the new dts. It worked too. However the leds still came up bright white at the start. How do I make it zero or leds off? Do I tweak the pad configuration?
https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/iMX93-EVK-PWM-LED/ta-p/1978047
As shown in the iMX93-EVK-PWM_LED document, LEDs are controlled using PWM. The document also includes pictures.
Even better, after introducing PWM control of LED lights, the document also provides the final LED control method. The LED driver calls the PWM driver, so you only need to control the brightness, and the driver will automatically map to the corresponding PWM value.
BTW, the imx93-11x11-evk_tpm1234_103025a.dts file is not a good method for modification; the method in the document attachment is clearer. Moreover, if the BSP changes, this device file does not need to be modified. In fact, you don't need to do anything; just put imx93-11x11-evk-pwm.dts and imx93-11x11-evk-pwm-led.dts into the file and compile it. That's what I did.
imx93-11x11-evk-pwm.dts
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
* Copyright 2022 NXP
*/
#include "imx93-11x11-evk.dts"
&tpm3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_tpm3>;
status = "okay";
};
&tpm4 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_tpm4>;
status = "okay";
};
&iomuxc {
pinctrl_tpm3: tpm3grp {
fsl,pins = <
MX93_PAD_GPIO_IO04__TPM3_CH0 0x19e
MX93_PAD_GPIO_IO12__TPM3_CH2 0x19e
>;
};
pinctrl_tpm4: tpm4grp {
fsl,pins = <
MX93_PAD_GPIO_IO13__TPM4_CH2 0x19e
>;
};
};
imx93-11x11-evk-pwm-led.dts
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
* Copyright 2022 NXP
*/
#include
#include "imx93-11x11-evk-pwm.dts"
/ {
leds {
compatible = "pwm-leds";
led-g {
label = "Green::TPM3_CH0";
color = ;
pwms = <&tpm3 0 5000000 0>;
max-brightness = <255>;
};
led-b {
label = "Blue::TPM3_CH2";
color = ;
pwms = <&tpm3 2 5000000 0>;
max-brightness = <255>;
};
led-r {
label = "Red::TPM4_CH2";
pwms = <&tpm4 2 5000000 0>;
color = ;
max-brightness = <255>;
};
};
};
Hi @jc2025,
Thanks to your device tree, I was able to successfully enable the PWM channels.
Using the latest BSP along with your configuration, I executed the following commands:
cd /sys/class/pwm/pwmchip0/
# Configuring the Green LED
echo 0 > export
echo 2000000 > pwm0/period
echo 0 > pwm0/duty_cycle
echo 1 > pwm0/enable
# Configuring the Blue LED
echo 2 > export
echo 2000000 > pwm2/period
echo 0 > pwm2/duty_cycle
echo 1 > pwm2/enable
cd /sys/class/pwm/pwmchip1/
# Configuring the Red LED
echo 2 > export
echo 2000000 > pwm2/period
echo 0 > pwm2/duty_cycle
echo 1 > pwm2/enable
I’ve set the duty cycle to 0 to keep the LEDs turned off. You can adjust the duty cycle value as needed to control brightness or turn them on.
Best regards,
Chavira
I updated the dts and the led stay bright white. PWM has no effects. Attached here is the dts.
I found the following link which may be useful to you.
https://community.nxp.com/t5/i-MX-Processors-Knowledge-Base/iMX93-EVK-PWM-LED/ta-p/1978047
Hi @jc2025,
Could you please share your device tree?
Also, what BSP (Board Support Package) version are you currently using?
To enable support for TPM3, you’ll need to add the following configuration to your device tree:
&tpm3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_tpm3>;
status = "okay";
};
pinctrl_tpm3: tpm3grp {
fsl,pins = <
MX93_PAD_GPIO_IO04__TPM3_CH0 0x19e
>;
};
Once this is added, you should see a new PWM device appear. In a previous case, it showed up as pwmchip1. If both PWM channels are active, please check which pwmchip corresponds to the LED RGB.
If you encounter any issues or need further assistance, feel free to reach out.
Best Regards,
Chavira