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 there are:
-
Four PWM signals (from PWM1 to PWM4) available from the i.MX6 system-on-chip.
-
Three PWM signals (PWM11, PWM14, PWM15) available from the DA9063 PMIC.
On the ConnectCore 6 Plus SBC:
-
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_IMX)
-
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.MX6 PWM driver is located at drivers/pwm/pwm-imx.c.
The DA9063 PMIC PWM LEDs driver is located at drivers/leds/leds-da9063.c.
Device tree bindings and customization
The i.MX6 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.MX6 PWM interfaces
The i.MX6 PWM interfaces are defined in the i.MX6 CPU device tree file.
pwm1: pwm@02080000 {
#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@02084000 {
#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@02088000 {
#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@0208c000 {
#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";
};
All i.MX6 PWM devices are enabled by default.
IOMUX configuration
Neither the ConnectCore 6 Plus nor the ConnectCore 6 Plus SBC use the i.MX6 PWM outputs, so no GPIO pins are specifically configured on the device tree for PWM functionality.
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)
&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";
};
};
};
};
PWM user space usage examples
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. |