The i.MX 8M SOM provides all 4 i.MX 8M PWM interfaces on the module connectors. Specific allocation of the PWM interfaces is as follows:
IMX8M PWM |
IMX8M Pad |
Starter Kit Interface |
Default Linux Configuration |
PWM1 |
GPIO1_IO01 |
P3.53 (LCD Backlight Control) |
|
SPDIF_EXT_CLK |
RPi P1.7 (SPDIF_TX) |
Y |
I2C4_SDA |
RPi P1.29 (I2C4_SDA) |
|
PWM2 |
GPIO1_IO13 |
R85 (LED2) |
|
SPDIF_RX |
RPi P1.32 (SPDIF_RX) |
Y |
I2C4_SCL |
RPi P1.26 (I2C4_SCL) |
|
PWM3 |
GPIO1_IO14 |
D16 (MIPI Camera 25MHz Clock) |
|
SPDIF_TX |
RPi P1.33 (SPDIF_TX) |
Y |
I2C3_SDA |
RPi P1.3 (I2C3_SDA) |
|
PWM4 |
GPIO1_IO15 |
R132 (RGMII Ethernet 25MHz clock) |
|
I2C3_SCL |
RPi P1.5 (I2C3_SCL) |
Y |
Linux software configures the i.MX 8M PWM1-3 signals as PWM in the Linux .dts file. For PWM4, it's possible to enable it on the RPI header, on the pins which are configured as I2C3 by default. To do this, comment out the I2C3_ENABLE definition in meta-emcraft/recipes-kernel/linux/linux-imx/imx8m-som.dts:
/* #define I2C3_ENABLE */
...
&pwm4 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm4>;
#ifdef I2C3_ENABLE
status = "disabled";
#else
status = "okay";
#endif
};
Linux provides the standard PWM API for control of the i.MX 8M PWM interfaces. As an example, the following Linux user-space commands create a 1ms period and 0.5ms duty meander on each of the 4 PWM interfaces:
root@imx8m-som:~# cd /sys/class/pwm/pwmchip0
echo 0 > export && echo 1000000 > pwm0/period && echo 500000 > pwm0/duty_cycle && echo 1 > pwm0/enable
root@imx8m-som:~# cd /sys/class/pwm/pwmchip1
echo 0 > export && echo 1000000 > pwm0/period && echo 500000 > pwm0/duty_cycle && echo 1 > pwm0/enable
root@imx8m-som:~# cd /sys/class/pwm/pwmchip2
echo 0 > export && echo 1000000 > pwm0/period && echo 500000 > pwm0/duty_cycle && echo 1 > pwm0/enable
root@imx8m-som:~# cd /sys/class/pwm/pwmchip3
echo 0 > export && echo 1000000 > pwm0/period && echo 500000 > pwm0/duty_cycle && echo 1 > pwm0/enable