Repurposing GPIOs in Device Tree - Disable LCD

Hi,

I’m having trouble with repurposing GPIO Pins (to Output Pins), which are mapped/used by the Colibri IMX8X to/for the LCD display. I’m working with Bitbake and therefore I built my own device tree extension.
It seems like that it is a common problem, but I’m not getting it to work.

To disable the LCD, I deactivated the device driver in ther kernel config (menuconfig). I also disabled all nodes, which are related to the LCD. Next, I created a new iomux-config (see similar topic ).
You can see the the code below:

&backlight {
	status = "disabled";
};

&display_lcdif {
	status = "disabled";
};

&dpu_disp1_lcdif {
	status = "disabled";
};

&iomuxc {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio1>;

            pinctrl_gpio0: gpio0 {
				fsl,pins = <
						IMX8QXP_UART1_CTS_B_LSIO_GPIO0_IO24			0x20		/* SODIMM  61 */
						IMX8QXP_SPDIF0_EXT_CLK_LSIO_GPIO0_IO12		0x20		/* SODIMM  52 */
                    >;

            };
};

&lsio_gpio0 {
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_gpio0>;
	status = "okay";
};

But after booting the board with compiled DT and using for example gpioset gpiochip0 12=0 (libgpiod), I can see no change in the pin-status. Is there anything more to look at?

Thanks in advance for any advise!

Hi @KaiD

Thanks for writing to the Toradex Community!

Could you provide the version of the Hardware (including Carrier Board) and Software of the module?
Regarding your issue, please share the dmesg log and the output of ‘cat /sys/kernel/debug/gpio’?

Thanks and best regards,
Jaski

Hi, thanks for your answer.

I’m using a custom board with the Colibri IMX8XQP 2GB WB IT SOM.
BSP: Torizon (Yocto), Bitbake Image: torizon-core-docker, Machine: colibri-imx8x, Kernel: 5.3.0

I have attached the dmesg log, gpioinfo output and “cat …/gpio” output
dmesg.txt (31.7 KB)
gpioinfo.txt (19.4 KB)
debug gpio.txt (5.9 KB)

I did some changes in the iomux, but still it is not possible to control pin SODIMM 52 (for example)

&lsio_gpio0 {
	pinctrl-0 = <&pinctrl_additionalgpio>;
	enable-gpios = <&lsio_gpio0 12 GPIO_ACTIVE_HIGH>; /* LED Ch3 r ON */
	status = "okay";
 };

&iomuxc {
	pinctrl-names = "default";
	
	vf610-colibri {
		pinctrl_additionalgpio: additionalgpios {
			fsl,pins = <
				IMX8QXP_SPDIF0_EXT_CLK_LSIO_GPIO0_IO12		0x20
			>;
		};
	};

Best
Kai

In additon: I have also noticed that the pinctrl is not picked up correctly. It is not shown in

cat /sys/kernel/debug/pinctrl/pinctrl-handles

Hi @KaiD

I have some comments:

  1. Since you are using TorizonCore on your module, to manipulate the device tree, you don’t need to compile all the operating system using Yocto. TorizonCore was developed to make development easier. To accomplish this, you could use the TorizonCore Builder tool and apply a Device Tree Overlay that you can create.
  2. If you really need to customize TorizonCore at a level that TorizonCore Builder can’t help you, then you’ll really need to use Yocto. In this case, let’s go to your Device Tree changes.
    a. There is no need to modify the lsio_gpio0 node.
    b. vf610-colibri node shouldn’t be used since you are not using a Colibri VF61 module. This node should be colibri-imx8qxp. But, to be honest, this node is not needed, as you’ll see.

So, to specifically set the pin you want (IMX8QXP_SPDIF0_EXT_CLK) to GPIO function (IMX8QXP_SPDIF0_EXT_CLK_LSIO_GPIO0_IO12), you can apply the following patch.

diff --git a/arch/arm64/boot/dts/freescale/imx8qxp-colibri.dtsi b/arch/arm64/boot/dts/freescale/imx8qxp-colibri.dtsi
index 957f0da9604a..47e6fe8bd5d1 100644
--- a/arch/arm64/boot/dts/freescale/imx8qxp-colibri.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx8qxp-colibri.dtsi
@@ -682,6 +682,7 @@
 		pinctrl_hog0: hog0grp {
 			fsl,pins = <
 				IMX8QXP_COMP_CTL_GPIO_1V8_3V3_GPIORHB_PAD	0x000514a0 /* Use pads in 3.3V mode */
+				IMX8QXP_SPDIF0_EXT_CLK_LSIO_GPIO0_IO12		0x20		/* SODIMM  52 */
 			>;
 		

This patch assumes that both display_lcdif and adma_lcdif have their statuses disabled (this is true for the current toradex_5.4-2.3.x-imx branch).

Let me know if this helps you.

Best regards.

Hi @henrique.tx

thanks for your answer.

I got it working with pinctrl_hog1 earlier this week, even though I’m not sure why I have to use this pinctrl-group.
Since I had to deactive other devices as well (device drivers in the kernel) and to build additional software packages, I used Bitbake.

I was working with your wiki to customize the device tree. Regarding pin multiplexing and repurposing the GPIOs it may could be a little bit more clear on how to get it working step by step, using the right pinctrl-groups.

Best
Kai

Hi @KaiD

Good to know that you made it work :slight_smile:

About the groups: actually, you can use any pinctrl group you want. Indeed, you could also create your own pinctrl group with a name that makes sense to, so you can organize better your project.

Using the groups that already exist and are used under the pinctrl-0 that is useful for you is just a quick way to test and validate.

About the Developer article: I understand that woking with device tree can be a little hard when learning. In the article that you linked, we have a section talking about pinmuxing specifically for IMX8X.

What do you think that we could do better?

Best regards.