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.

On the ConnectCore 6 Plus system-on-module there are:

  • Four PWM signals (from PWM1 to PWM4) available from the i.MX6QP system-on-chip.

  • Three PWM signals (PWM11, PWM14, PWM15) available from the DA9063 PMIC.

On the ConnectCore 6 Plus SBC:

  • PWM1 from i.MX6QP is available at parallel display connector.

  • PWM11 from DA9063 PMIC is used to drive the LVDS0 backlight.

  • PWM15 from DA9063 PMIC is used to drive the LVDS1 backlight.

Kernel configuration

You can manage the PWM driver support through the following kernel configuration options:

  • i.MX PWM support (CONFIG_PWM_IMX27)

  • Dialog DA9063 LEDS (CONFIG_LEDS_DA9063)

These options are enabled as built-in on the ConnectCore 6 Plus SBC kernel configuration file.

Digi Embedded Yocto only supports the Dialog DA9063 LEDs interface.

Kernel driver

The i.MX6QP PWM driver is located at drivers/pwm/pwm-imx27.c.

The DA9063 PMIC PWM LEDs driver is located at drivers/leds/leds-da9063.c.

Device tree bindings and customization

The i.MX6QP PWM interface device tree binding is documented at Documentation/devicetree/bindings/pwm/imx-pwm.txt.

The DA9063 PMIC’s leds binding is documented at Documentation/devicetree/bindings/leds/leds-da9063.txt.

For information about backlight control in Linux, refer to the kernel documentation at Documentation/ABI/testing/sysfs-class-led.

i.MX6QP PWM interfaces

The i.MX6QP PWM interfaces are defined in the common i.MX6QP CPU device tree file.

Common i.MX6QP device tree
pwm1: pwm@2080000 {
	#pwm-cells = <2>;
	compatible = "fsl,imx6q-pwm", "fsl,imx27-pwm";
	reg = <0x02080000 0x4000>;
	interrupts = <0 83 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&clks IMX6QDL_CLK_IPG>,
	         <&clks IMX6QDL_CLK_PWM1>;
	clock-names = "ipg", "per";
};
pwm2: pwm@2084000 {
	#pwm-cells = <2>;
	compatible = "fsl,imx6q-pwm", "fsl,imx27-pwm";
	reg = <0x02084000 0x4000>;
	interrupts = <0 84 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&clks IMX6QDL_CLK_IPG>,
	         <&clks IMX6QDL_CLK_PWM2>;
	clock-names = "ipg", "per";
};
pwm3: pwm@2088000 {
	#pwm-cells = <2>;
	compatible = "fsl,imx6q-pwm", "fsl,imx27-pwm";
	reg = <0x02088000 0x4000>;
	interrupts = <0 85 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&clks IMX6QDL_CLK_IPG>,
	         <&clks IMX6QDL_CLK_PWM3>;
	clock-names = "ipg", "per";
};
pwm4: pwm@208c000 {
	#pwm-cells = <2>;
	compatible = "fsl,imx6q-pwm", "fsl,imx27-pwm";
	reg = <0x0208c000 0x4000>;
	interrupts = <0 86 IRQ_TYPE_LEVEL_HIGH>;
	clocks = <&clks IMX6QDL_CLK_IPG>,
	         <&clks IMX6QDL_CLK_PWM4>;
	clock-names = "ipg", "per";
};

IOMUX configuration

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

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

The following external pads are configured as PWMs on the default device tree:

  • On the ConnectCore 6 Plus SBC parallel display connector:

    Pad Signal PWM

    10

    DISP0_DAT8

    PWM1

The ConnectCore 6 Plus SBC uses the DA9063 PMIC PWM interfaces to drive LVDS displays' backlights, but these require no IOMUX configuration.

DA9063 PMIC PWM interfaces

The DA9063 PMIC PWM interfaces are defined in the ConnectCore 6 Plus SBC device tree file.

PWM11 and PWM15 (LVDS0 and LVDS1 backlight)

ConnectCore 6 Plus SBC device tree
&i2c2 {
	pmic_dialog: dialog@58 {
		leds {
			compatible = "dlg,da9063-leds";
			lvds0-backlight@0xc6 {
				dlg,led-gpio-reg = <0x1a 0xf0>;
				dlg,led-reg = <0xc6>;

				/*
				 * If using the latest Video Adapter Board
				 * uncomment to invert the backlight polarity
				 */
				//dlg,inverse-polarity
				linux,default-trigger = "backlight";
			};
			lvds1-backlight@0xc6 {
				dlg,led-gpio-reg = <0x1c 0xf0>;
				dlg,led-reg = <0xc8>;

				/*
				 * If using the latest Video Adapter Board
				 * uncomment to invert the backlight polarity
				 */
				//dlg,inverse-polarity
				linux,default-trigger = "backlight";
			};
		};
	};
};

Using the PWM channels

PWM LED for backlight control

You can access the PWM LED interface for backlight through the sysfs at /sys/class/leds/. A backlight interface typically contains two controls:

  • max_brightness: read-only parameter; integer value of maximum allowed brightness.

  • brightness: a read operation returns the current brightness value; a write operation sets the brightness value (from 0 to max_brightness).

Examples

To read the max allowed brightness of LVDS0 interface on ConnectCore 6 Plus SBC:

~# cat /sys/class/leds/lvds0-backlight/max_brightness
95

To set the brightness of LVDS0 interface on ConnectCore 6 Plus SBC to the maximum brightness:

~# echo 95 > /sys/class/leds/lvds0-backlight/brightness

To set the brightness of LVDS0 interface on ConnectCore 6 Plus SBC to the minimum brightness:

~# echo 0 > /sys/class/leds/lvds0-backlight/brightness
Depending on your LCD display and adapter board, the backlight polarity might be reversed. In that case, writing a 0 to the brightness descriptor would set the backlight to maximum brightness and vice versa. You can use the device tree property dlg,inverse-polarity of the PMIC PWM to adapt to your hardware.

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 meta-digi layer. This application shows how to generate a PWM signal using Digi APIx library on the ConnectCore 6 Plus platform.

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

See PWM API for more information about the PWM APIx.