Enable Backlight for Verdin imx8mm

Hi,

I am using the Verdin development board with imx8m-mini and I would like to adjust the backlight of a display I have connected with my development board. I have connected PWM_3_DSI to a display PWM input. But when I try to access the root@verdin-imx8mm-06898930:/sys/class/backlight#

The directory is empty by default.

How can I access adjusting the brightness as the example in the following link:
https://developer.toradex.com/knowledge-base/backlight-linux#DSI_1_BKL_EN

when I type:

root@verdin-imx8mm-06898930:~# cat /sys/kernel/debug/pwm

this is my respond.

platform/30680000.pwm, 1 PWM device
pwm-0 ((null) ): period: 2730667 ns duty: 0 ns polarity: normal

platform/30670000.pwm, 1 PWM device
pwm-0 ((null) ): period: 2730667 ns duty: 0 ns polarity: normal

Hence, pwm-0 is not connected to the backlight. I have tried connecting it using a patch file, but it is not connecting/ enabling adjustments of brightness with pwm-control.

Thanks for your help,
Astrid Lindstedt

Hello @Astrid ,

Could you also tell me which display, interface, and adapter are you using?

BR, Janani

Hi,

I am using this type of display: https://www.newhavendisplay.com/specs/NHD-1.8-128160EF-SSXN-F.pdf

The communication to the display is through the spidev1.0, which is working. I would like to enable the class backlight to connect the PWM_3_DSI to a PWM-input to the display.

I have a patch file and a defconfig that I am including with a linux-toradex_%.bbappend -file.

I am running the following commands:

$ bitbake -c clean virtual/kernel
$ bitbake -c clean tdx-reference-minimal-image
$ bitbake virtual/kernel
$ bitbake tdx-reference-minimal-image

Then I extract the minimal image .tar file, put it on a USB and connect it to the dev board. But it seems that my .patch did not affect the availability of the class backlight since the directory is empty.

Am I doing anything wrong in the build process?

This is my linux-toradex_%.bbappend -file:

FILEEXTRAPATHS_prepend := “${THISDIR}/linux-toradex:”

unset KBUILD_DECONFIG

SRC_URI += "file://0001-display2.patch
file://defconfig
"
This is my defconfig file:

CONFIG_BACKLIGHT_GENERIC=m
CONFIG_BACKLIGHT_PWM=y
CONFIG_BACKLIGHT_GPIO=y
CONFIG_COMMON_CLK_PWM=y
CONFIG_PWM=y
CONFIG_PWM_BCM2835=m
CONFIG_PWM_CROS_EC=m
CONFIG_PWM_FSL_FTM=y
CONFIG_PWM_IMX=y

This is my patchfile:

diff --git a/imx8mm-verdin-wifi-dev.dts.orig b/imx8mm-verdin-wifi-dev.dts.astrid
index ae71a5d…4fa49d3 100755
— a/imx8mm-verdin-wifi-dev.dts
+++ b/imx8mm-verdin-wifi-dev.dts
@@ -16,3 +16,45 @@
“toradex,verdin-imx8mm”,
“fsl,imx8mm”;
};
+

+ aliases {
+ backlight_mipi = &backlight_mipi;
+ fb_mipi = &fb_mipi;
+ lcdif = &lcdif;
+ mipi = &fb_mipi;
+ mipi_cmds_ltk0680ytmdb = &mipi_cmds_ltk0680ytmdb;
+ mipi_cmds_ltk080a60a004t = &mipi_cmds_ltk080a60a004t;
+ mipi_cmds_m101nwwb = &mipi_cmds_ltk080a60a004t; /* Same commands work for both /
+ mipi_dsi = &mipi_dsi;
+ mipi_to_lvds = &mipi_to_lvds;
+ pinctrl_ltk0680ytmdb = &pinctrl_ltk0680ytmdb;
+ pinctrl_ltk080a60a004t = &pinctrl_ltk080a60a004t;
+ t_mipi = &t_mipi;
+ };
+
+
+ backlight_mipi: backlight-mipi {
+ brightness-levels = <0 1 2 3 4 5 6 7 8 9 10>;
+ compatible = “pwm-backlight”;
+ default-brightness-level = <8>;
+ display = <&display_subsystem>;
+ pwms = <&pwm3 0 30000>; /
33.3 Khz /
+ status = “okay”;
+ };
+
+
+&ecspi2 {
+ pinctrl-names = “default”;
+ pinctrl-0 = <&pinctrl_ecspi2>;
+ fsl,spi-num-chipselects = <1>;
+ cs-gpios = GP_ECSPI2_CS0;
+ status = “okay”;
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ spidev@0 {
+ compatible = “spidev”;
+ spi-max-frequency = <2000000>;
+ reg = <0>;
+ };
+};
+ backlight: backlight {
+ compatible = “pwm-backlight”;
+ brightness-levels = <0 45 63 88 119 158 203 255>;
+ default-brightness-level = <4>;
+ /
Verdin I2S_2_D_OUT (DSI_1_BKL_EN/DSI_1_BKL_EN_LVDS, SODIMM 46) /
+ enable-gpios = <&gpio3 24 GPIO_ACTIVE_HIGH>;
+ pinctrl-names = “default”;
+ pinctrl-0 = <&pinctrl_i2s_2_d_out_dsi_1_bkl_en>;
+ power-supply = <&reg_3p3v>;
+ /
Verdin PWM_3_DSI/PWM_3_DSI_LVDS (SODIMM 19) /
+ pwms = <&pwm1 0 6666667 PWM_POLARITY_INVERTED>;
- status = “disabled”;
+ status = “okay”;
+ };
+/
Verdin PWM_3_DSI */
+&pwm1 {
+ pinctrl-names = “default”;
+ pinctrl-0 = <&pinctrl_pwm_1>;
+ #pwm-cells = <3>;
+ status = “okay”;
+};

Here is a tree of how I put the files under my meta-layer.

Thank you very much for the support,

Astrid

Hello @Astrid,

Thank you for your detailed message.

A couple of things that caught my attention.

First off, you seem to be building a “minimal image” that is devoid completely of all the graphical features. If you intend to use the Graphical stack (such as for your display), you would need to be using the
tdx-reference-multimedia-image. You can see what’s included in both of these images here.

Secondly, for patching your file, I would suggest that you modify the kernel sources instead and patch the device tree, as modifying and re-building an image with Yocto every time would be super time-consuming at the development stage (probably for the final implementation, Yocto would be the way to go)

Furthermore, you can find this backlight section in arch/arm64/boot/dts/freescale/imx8mm-verdin.dtsi, which you can modify as per your wish.

backlight: backlight {
		compatible = "pwm-backlight";
		brightness-levels = <0 45 63 88 119 158 203 255>;
		default-brightness-level = <4>;
		/* Verdin I2S_2_D_OUT (DSI_1_BKL_EN/DSI_1_BKL_EN_LVDS, SODIMM 46) */
		enable-gpios = <&gpio3 24 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_i2s_2_d_out_dsi_1_bkl_en>;
		power-supply = <&reg_3p3v>;
		/* Verdin PWM_3_DSI/PWM_3_DSI_LVDS (SODIMM 19) */
		pwms = <&pwm1 0 6666667 PWM_POLARITY_INVERTED>;
		status = "disabled";
	};

And if one does everything right, you must find the mention of backlight somewhere in the dmesg.log .

I hope these help!

BR,
Janani

Thank you for the reply,

I will not use the graphical features, I will just write simple text to the display and will therefore handle the graphics directly in a cpp file. However, now I have another problem. My ~/oe-core/build/tmp/work-shared/verdin-imx8mm/kernel-source is empty. It has not been empty before.

I have tried

oe-core$ repo sync
oe-core$ . export
oe-core/build$ bitbake tdx-reference-minimal-image

But the directory is still empty. Is there any easy way to grab the kernel-source files? Do you have any clue of what mistake generated this problem?

Sincerely,

Astrid

Hi again,

I solved the last issue by deleting oe-core and redownloading and rebuilding it again. I’m still not sure what I did to delete the kernel-source and it happened to me twice.

However, I changed the device tree directly as you suggested, as:

But my backlight class is still empty:

Screenshot from 2021-11-22 08-37-26

I would still like to change the brightness.

my commands are still:

$ bitbake -c clean tdx-reference-minimal-image
$ bitbake virtual/kernel
$ bitbake tdx-reference-minimal-image

Then I unzip the tdx-reference-minimal-image- tar file and put it on my USB and run it on my device. Is the change of the kernel-source included when I build the minimal image?

Thank you in advance,

Astrid

Hello @Astrid ,

Could you also please check if the dsi to lvds overlay has been enabled?

And please find detailed documentation on kernel sources here. Maybe this will also help you cross-verify your previous steps to identify why the kernel -sources were deleted.

I think your changes to your device tree must be included. Could you maybe re-check them again?

Best Regards,
Janani

Hi,

My overlays are the following.

Hence, verdin-imx8mm_lt8912_overlay.dtbo should be enabled which refers to Verdin DSI to HDMI Adapter according to: Device Tree Overlays (Linux)

When I type
$ bitbake-layers show-appends

My .bbappend file is not present on the list. Futhermore, in the following directory at my board
**# /sys/module **

backlight is not present.

Do you have any further debugging tips according to this issue?
How can I see if my changes to my device tree are included?

Sincerely,

Astrid

Hello @Astrid ,

I am closing this conversation as we moved to other channels for this discussion.

Best regards,
Janani