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 95 system-on-module:

  • Has six TPM instances (from TPM1 to TPM6) with 4 channels each, most of them available from the i.MX95 system-on-chip (multiplexed with other signals).

On the ConnectCore 95 Development Kit:

  • TPM3 CH3 is available on the mikroBUS™ socket.

  • TPM5 CH1 is used as LVDS0 PWM backlight.

  • TPM6 CH1 is used as LVDS1 PWM backlight.

Kernel configuration

You can manage the i.MX95 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 95 kernel configuration file.

Kernel driver

The driver for the i.MX95 PWM is located at:

File Description

drivers/pwm/pwm-imx-tpm.c

PWM driver

Device tree bindings and customization

The i.MX95 PWM interface is documented at Documentation/devicetree/bindings/pwm/imx-tpm-pwm.yaml.

i.MX95 PWM interfaces

The common i.MX95 CPU device tree file contains entries for all TPM instances.

i.MX95 device tree
		tpm1: pwm@44310000 {
			compatible = "fsl,imx7ulp-pwm";
			reg = <0x44310000 0x1000>;
			clocks = <&scmi_clk IMX95_CLK_BUSAON>;
			#pwm-cells = <3>;
			status = "disabled";
		};

		tpm2: pwm@44320000 {
			compatible = "fsl,imx7ulp-pwm";
			reg = <0x44320000 0x1000>;
			clocks = <&scmi_clk IMX95_CLK_TPM2>;
			assigned-clocks = <&scmi_clk IMX95_CLK_TPM2>;
			assigned-clock-parents = <&scmi_clk IMX95_CLK_24M>;
			assigned-clock-rates = <24000000>;
			#pwm-cells = <3>;
			status = "disabled";
		};
[...]
		tpm3: pwm@424e0000 {
			compatible = "fsl,imx7ulp-pwm";
			reg = <0x424e0000 0x1000>;
			clocks = <&scmi_clk IMX95_CLK_BUSWAKEUP>;
			#pwm-cells = <3>;
			status = "disabled";
		};

		tpm4: pwm@424f0000 {
			compatible = "fsl,imx7ulp-pwm";
			reg = <0x424f0000 0x1000>;
			clocks = <&scmi_clk IMX95_CLK_TPM4>;
			#pwm-cells = <3>;
			status = "disabled";
		};

		tpm5: pwm@42500000 {
			compatible = "fsl,imx7ulp-pwm";
			reg = <0x42500000 0x1000>;
			clocks = <&scmi_clk IMX95_CLK_TPM5>;
			#pwm-cells = <3>;
			status = "disabled";
		};

		tpm6: pwm@42510000 {
			compatible = "fsl,imx7ulp-pwm";
			reg = <0x42510000 0x1000>;
			clocks = <&scmi_clk IMX95_CLK_TPM6>;
			#pwm-cells = <3>;
			status = "disabled";
		};

IOMUX configuration

You must configure the pads that are to be used as i.MX95 PWMs. See Pin multiplexing (IOMUX).

i.MX95 pads should only have one IOMUX configuration. Remove other configurations for those pads, like GPIO, when configuring them as PWMs.

The default device tree enables TPM3 CH3, available on the ConnectCore 95 Development Kit J39 mikroBUS™ socket:

  • TPM3 CH3 corresponds to pad GPIO2_IO24.

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 TPM3 CH3 on ConnectCore 95 Development Kit

For example, to enable TPM3 CH3 you must:

  • Configure the pad GPIO2_IO24 IOMUX as TPM3_CH3.

  • Enable the TPM node.

ConnectCore 95 Development Kit device tree

&tpm3 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_tpm3>;
	status = "okay";
};

&scmi_iomuxc {
	pinctrl_tpm3: tpm3grp {
		fsl,pins = <
			IMX95_PAD_GPIO_IO24__TPM3_CH3		0x51e
		>;
	};
};

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 95 platform.

Go to GitHub to see the application instructions and source code.

See PWM API for more information about the PWM APIx.

See also