Pulse-width modulation (PWM) is a technique that modifies the duty cycle of a pulsing signal to encode information or to control the amount of energy provided to a charge. The TPM (Timer/PWM Module) is a channel timer that supports input capture, output compare, and the generation of PWM signals to control electrical motor and power management applications. The counter, compare, and capture registers are clocked by an asynchronous clock that can remain enabled in low power modes.
On the ConnectCore 91 system-on-module:
-
Has six TPM instances (from TPM1 to TPM6) with 4 channels each, most of them available from the i.MX91 system-on-chip (multiplexed with other signals).
On the ConnectCore 93 Development Kit:
-
TPM6 CH1 is available on the LVDS connector.
Kernel configuration
You can manage the i.MX91 PWM driver support through the following kernel configuration option:
-
i.MX TPM PWM support (
CONFIG_PWM_IMX_TPM)
This option is enabled as built-in on the default ConnectCore 91 kernel configuration file.
Kernel driver
The driver for the i.MX91 PWM is located at:
| File | Description |
|---|---|
PWM driver |
Device tree bindings and customization
The i.MX91 PWM interface is documented at Documentation/devicetree/bindings/pwm/imx-tpm-pwm.yaml.
i.MX91 PWM interfaces
The common i.MX91 CPU device tree file contains entries for all TPM instances.
tpm1: pwm@44310000 {
compatible = "fsl,imx7ulp-pwm";
reg = <0x44310000 0x1000>;
clocks = <&clk IMX91_CLK_TPM1_GATE>;
#pwm-cells = <3>;
status = "disabled";
};
tpm2: pwm@44320000 {
compatible = "fsl,imx7ulp-pwm";
reg = <0x44320000 0x1000>;
clocks = <&clk IMX91_CLK_TPM2_GATE>;
assigned-clocks = <&clk IMX91_CLK_TPM2>;
assigned-clock-parents = <&clk IMX91_CLK_24M>;
assigned-clock-rates = <24000000>;
#pwm-cells = <3>;
status = "disabled";
};
[...]
tpm3: pwm@424e0000 {
compatible = "fsl,imx7ulp-pwm";
reg = <0x424e0000 0x1000>;
clocks = <&clk IMX91_CLK_TPM3_GATE>;
#pwm-cells = <3>;
status = "disabled";
};
tpm4: pwm@424f0000 {
compatible = "fsl,imx7ulp-pwm";
reg = <0x424f0000 0x1000>;
clocks = <&clk IMX91_CLK_TPM4_GATE>;
assigned-clocks = <&clk IMX91_CLK_TPM4>;
assigned-clock-parents = <&clk IMX91_CLK_24M>;
assigned-clock-rates = <24000000>;
#pwm-cells = <3>;
status = "disabled";
};
tpm5: pwm@42500000 {
compatible = "fsl,imx7ulp-pwm";
reg = <0x42500000 0x1000>;
clocks = <&clk IMX91_CLK_TPM5_GATE>;
assigned-clocks = <&clk IMX91_CLK_TPM5>;
assigned-clock-parents = <&clk IMX91_CLK_24M>;
assigned-clock-rates = <24000000>;
#pwm-cells = <3>;
status = "disabled";
};
tpm6: pwm@42510000 {
compatible = "fsl,imx7ulp-pwm";
reg = <0x42510000 0x1000>;
clocks = <&clk IMX91_CLK_TPM6_GATE>;
assigned-clocks = <&clk IMX91_CLK_TPM6>;
assigned-clock-parents = <&clk IMX91_CLK_24M>;
assigned-clock-rates = <24000000>;
#pwm-cells = <3>;
status = "disabled";
};
IOMUX configuration
You must configure the pads that are to be used as i.MX91 PWMs. See Pin multiplexing (IOMUX).
| i.MX91 pads should only have one IOMUX configuration. Remove other configurations for those pads, like GPIO, when configuring them as PWMs. |
Depending on the frequency of the PWM signal and the hardware around it, you must carefully select the pad settings (the numerical values following the IOMUX definition on the device tree).
See Documentation/devicetree/bindings/pinctrl/fsl,imx93-pinctrl.yaml
for information about the different values.
Also see the NXP application note AN5078 Influence of pin setting on system function and performance for additional information.
Example: enable TPM6 CH1 on ConnectCore 93 Development Kit
For example, to enable TPM6 CH1 you must:
-
Configure the pad GPIO2_IO23 IOMUX as TPM6_CH1.
-
Enable the TPM node.
&tpm6 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_tpm6>;
status = "okay";
};
&iomuxc {
pinctrl_tpm6: tpm6grp {
fsl,pins = <
MX91_PAD_GPIO_IO23__TPM6_CH1 0x19e
>;
};
};
Use the PWM channels
Using Digi APIx library from a C application
An example application called apix-pwm-example is included in the dey-examples-digiapix recipe (part of dey-examples package) of the meta-digi layer.
This application shows how to generate a PWM signal using Digi APIx library on the ConnectCore 91 platform.
Go to GitHub to see the application instructions and source code.
See PWM API for more information about the PWM APIx.