Switch PWM for Backlight

Colibri iMX6 is using PWM3 for LCD backlight control. But it conflicts with camera interface. SODIMM67/59 are configured as MX6QDL_PAD_EIM_A21__IPU1_CSI1_DATA16 and MX6QDL_PAD_EIM_A22__IPU1_CSI1_DATA17. 1 Multiplexed pins are set MX6QDL_PAD_SD4_DAT1__GPIO2_IO09 0x40 and MX6QDL_PAD_GPIO_1__GPIO1_IO01 0x40. There are only PWM1 and PWM4 are available. I try to use PWM1 as backlight and make some changes in device tree.

&backlight {
#if 0 /* PWM polarity: if 1 is brightest */
	pwms = <&pwm1 0 5000000 0>;
#if 0 /* Fusion 7 needs 10kHz PWM frequency */
	pwms = <&pwm1 0 100000 0>;
#endif
#else /* PWM polarity: if 0 is brightest */
	pwms = <&pwm1 0 5000000 1>;
#endif
	brightness-levels = <0 4 8 16 32 64 128 255>;
	default-brightness-level = <6>;
	status = "okay";
};

/*
#ifndef PCAP
&pwm1 {
	status = "okay";
};
#endif
*/

Video input is fine but LCD backlight is stiff off. There is not node with /sys/class/backlight/

What else should I modify to enable PWM1 as backlight?
Thanks very much!

Hi

If you comment this:

 #ifndef PCAP
 &pwm1 {
     status = "okay";
 };
 #endif

you actually keep the status for pwm1 in ‘disabled’ and thus the backlight property will not be able to claim pwm1 with ‘pwms = <&pwm1 0 5000000 1>;’. I expect that you see some kernel output to that effect.
What does dmesg | grep -i -e pwm -e backlight show?

Max

Hi Max
The backlight will be ok if pwm1’s status is set to ‘okay’. Meanwhile, camera input doesn’t work.

root@colibri-imx6:~# gst-launch-1.0 imxv4l2src ! deinterlace mode=1 ! autovideosink
====== IMXV4L2SRC: 4.1.4 build on Oct  4 2017 23:51:30. ======
Setting pipeline to PAUSED ...
display(/dev/fb0) resolution is (800x480).
====== OVERLAYSINK: 4.1.4 build [  871.615583] mxc_v4l2_output v4l2_out: Bypass IC.
on Oct  4 2017 23:51:36. ======
[  871.621736] mxc_v4l2_output v4l2_out: Bypass IC.
display(/dev/fb0) resolution is (800x480).
display(/dev/fb0) resolution is (800x480).
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[  881.708597] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  891.719730] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  901.730815] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  911.741874] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  921.772901] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  931.783888] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  941.794852] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  951.805791] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  961.816701] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0

ADV7280 only works when pwm1’s status is disabled. That is strange because SODIMM28 PWM1 is not used as camera input interface. SODIMM59 and SODIMM67 are correctly configured.

pinctrl_ipu1_csi0: ipu1grp-csi0 { /* parallel camera */
			fsl,pins = <
				MX6QDL_PAD_EIM_A17__IPU1_CSI1_DATA12    0xb0b1
				MX6QDL_PAD_EIM_A18__IPU1_CSI1_DATA13    0xb0b1
				MX6QDL_PAD_EIM_A19__IPU1_CSI1_DATA14    0xb0b1
				MX6QDL_PAD_EIM_A20__IPU1_CSI1_DATA15    0xb0b1
				MX6QDL_PAD_EIM_A21__IPU1_CSI1_DATA16    0xb0b1	/* SODIMM 67 */
				MX6QDL_PAD_EIM_A22__IPU1_CSI1_DATA17    0xb0b1	/* SODIMM 59 */
				MX6QDL_PAD_EIM_A23__IPU1_CSI1_DATA18    0xb0b1
				MX6QDL_PAD_EIM_A24__IPU1_CSI1_DATA19    0xb0b1
				MX6QDL_PAD_EIM_D17__IPU1_CSI1_PIXCLK    0xb0b1
				MX6QDL_PAD_EIM_EB3__IPU1_CSI1_HSYNC     0xb0b1
				MX6QDL_PAD_EIM_D29__IPU1_CSI1_VSYNC     0xb0b1

				MX6QDL_PAD_SD4_DAT1__GPIO2_IO09         0x40		/* SODIMM 59 disabled PWM pins on camera IF */
				MX6QDL_PAD_GPIO_1__GPIO1_IO01		0x40				/* SODIMM 67 */
			>;
		};

Hi Max, do you have any chance to have a look at this? Thanks!

@benjamin.tx: Max is not in office on Friday, he will answer your question on next Monday.

Hi Benjamin

I assume you are using the ACA together with a Colibri Evaluation Board.

I don’t believe that enabling pwm1 does have any effects on the camera interface.
My guess is that you have changes in the device tree sources, e.g. in the pinctrl_pwm1 node which now changes additional pins.

Could you provide a git diff of what you actually changed for all files in arch/arm/boot/dts/?

Max

okay, thanks.

Hoi Benjamin

I’m actually waiting for input on above questions from you…

Max

Hi Max. I am sorry for the delay. Since I have modified other files within dts folder, it is now way different from it should be. I will restore them and give the git diff.

Hi Max, here is the diff file.

diff --git a/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts b/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts
index aae9fd8..aa7dee5 100644
--- a/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts
+++ b/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts
@@ -84,12 +84,12 @@
 
 &backlight {
 #if 0 /* PWM polarity: if 1 is brightest */
-	pwms = <&pwm3 0 5000000 0>;
+	pwms = <&pwm1 0 5000000 0>;
 #if 0 /* Fusion 7 needs 10kHz PWM frequency */
-	pwms = <&pwm3 0 100000 0>;
+	pwms = <&pwm1 0 100000 0>;
 #endif
 #else /* PWM polarity: if 0 is brightest */
-	pwms = <&pwm3 0 5000000 1>;
+	pwms = <&pwm1 0 5000000 1>;
 #endif
 	brightness-levels = <0 4 8 16 32 64 128 255>;
 	default-brightness-level = <6>;
@@ -192,7 +192,7 @@
 		mclk = <24000000>;
 		mclk_source = <0>;
 		cvbs = <1>;
-		status = "okay";
+		status = "disabled";
 	};
 };

@max.tx , the default imx6dl-colibri-cam-eval-v3.dts sets pwm3(GPIO2_IO09) as backlight control and it is exported on SODIMM59. However, SODIMM59 is multiplexed with GPIO2_IO16 which is set to CIF_D_7 by pinctrl_ipu1_csi0. So there is a conflict on SODIMM59 and it makes LCD display and ACA not work at the same time with default imx6dl-colibri-cam-eval-v3.dtb.

When I set pwm1 as backlight control, ACA and LCD display can work together. However, there is not backlight sysfs.

root@colibri-imx6:/sys/class/backlight# ls -lha
drwxr-xr-x    2 root     root           0 Mar 21 13:07 .
drwxr-xr-x   49 root     root           0 Mar 21 13:07 ..
root@colibri-imx6:/sys/class/backlight# dmesg|grep pwm
root@colibri-imx6:/sys/class/backlight# dmesg|grep backlight
[    0.195857] backlight supply power not found, using dummy regulator
[    2.238996] backlight supply power not found, using dummy regulator
[    2.314375] backlight supply power not found, using dummy regulator
[    2.332497] backlight supply power not found, using dummy regulator
[    3.765445] backlight supply power not found, using dummy regulator
[    5.184664] backlight supply power not found, using dummy regulator
[    5.246261] backlight supply power not found, using dummy regulator

Here is the git diff

diff --git a/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts b/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts
index aae9fd814be3..d1909b1f88a5 100644
--- a/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts
+++ b/arch/arm/boot/dts/imx6dl-colibri-cam-eval-v3.dts
@@ -84,12 +84,12 @@
 
 &backlight {
 #if 0 /* PWM polarity: if 1 is brightest */
-	pwms = <&pwm3 0 5000000 0>;
+	pwms = <&pwm1 0 5000000 0>;
 #if 0 /* Fusion 7 needs 10kHz PWM frequency */
-	pwms = <&pwm3 0 100000 0>;
+	pwms = <&pwm1 0 100000 0>;
 #endif
 #else /* PWM polarity: if 0 is brightest */
-	pwms = <&pwm3 0 5000000 1>;
+	pwms = <&pwm1 0 5000000 1>;
 #endif
 	brightness-levels = <0 4 8 16 32 64 128 255>;
 	default-brightness-level = <6>;
@@ -244,9 +244,11 @@
 };
 
 #ifndef PCAP
+/*
 &pwm1 {
 	status = "okay";
 };
+*/
 #endif
 
 #ifndef PCAP

@max.tx , after enable pwm1 , there is backlight node in /sys/class/backlight

&pwm1 {
	status = "okay";
};

root@colibri-imx6:~# ls /sys/class/backlight/backlight
actual_brightness  brightness         max_brightness     subsystem          uevent
bl_power           device             power              type

But now, ACA fails to work with below error. X11.26 is removed to make sure that SOIDMM59 is connected to ACA module.

root@colibri-imx6:~# gst-launch-1.0 imxv4l2src ! imxv4l2sink
====== IMXV4L2SRC: 4.1.4 build on Oct  4 2017 23:51:30. ======
====== IMXV4L2SINK: 4.1.4 build on Oct  4 2017 23:51:30. ======
Setting pipeline to PAUSED ...
display(/dev/fb0) resolution is (800x480).
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[  322.144899] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0
[  332.155066] ERROR: v4l2 capture: mxc_v4l_dqueue timeout enc_counter 0

I had a quick look at it. It is the BL_ON GPIO which you forgot about. As long as the backlight’s PWM node was deactivated also the backlight on GPIO did not get activated but now with you having changed it to the really available PWM1 the backlight becomes activated and with it the BL_ON GPIO which is also shared with a camera signal.

SODIMM71 is shared between BL_ON and RESET of ADV7280. It will be pulled low before Linux desktop is launched. Unfortunately ADV7280 have been initialized then. The reset signal just cleans all ADV7280’ configuration via I2C. So one needs to reinstall ADV780 driver.

root@colibri-imx6:~# rmmod adv7280_tvin
root@colibri-imx6:~# modprobe adv7280_tvin