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 SMT SOM:

  • One or more channels of all six TPM instances (from TPM1 to TPM6) are available on the castellated pads and the LGA pads (multiplexed with other signals).

On the ConnectCore 95 SMARC SOM:

  • TPM4 CH0 is routed to LCD0_BKLT_PWM of the SMARC connector.

  • TPM3 CH0 is routed to LCD1_BKLT_PWM of the SMARC connector.

  • TPM3 CH3 is routed to GPIO5 / PWM_OUT of the SMARC connector.

  • Additional channels of different TPMs are available in other pads of the SMARC connector, multiplexed with other functionality (outside of the SMARC specification).

On the ConnectCore 95 Development Kit:

  • TPM4 CH0 is used as LVDS0 PWM backlight.

  • TPM3 CH0 is used as LVDS1 PWM backlight.

  • TPM3 CH3 (GPIO5/PWM_OUT of the SMARC) is routed to LVDS0 interrupt and cannot be used in parallel with LVDS0.

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";
		};

[...]

		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.

ccimx95-dvk_lvds0-g101evn010.dtso device tree overlay enables TPM4 CH0 as LVDS0 backlight.

ccimx95-dvk_lvds1-g101evn010.dtso device tree overlya enables TPM3 CH0 as LVDS1 backlight.

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