iMX8QXP Colibri and CONFIG_POWER_RESET_GPIO for powering off the board

Greetings,
I am making an application based on the Colibri imx8 and evaluation board, I am using Docker and Torizon (very ;-} customer). I got stuck again and need to ask another dumb question.

The application requirements desire the hardware to be able to shutdown completely.

Now I notice the board does not shutdown as supplied, but there is a solution in:

https://developer.toradex.com/knowledge-base/gpio-linux#GPIO_PowerOff

  1. Implementing a GPIO output to FORCE_OFF# that goes low on shutdown and switches off the LTC2954
  2. A driver “gpio-poweroff” does that task, and mux will set the pin so it goes to GND just before shutdown
  3. Switch on a kernel option editor which enables “CONFIG_POWER_RESET_GPIO”.

The first 2 are easy with a wire strap and Torizon and were done in seconds, but then I came a bit unstuck.

Item 3 looks like I need to revert back to OE/Yocto, fish out all of the Torizon sources and run the nconfig menu and then compile the whole distribution just to add this option. I must be wrong, but I cant see how else to do this? Is this only way to enable the CONFIG_POWER_RESET_GPIO option ?

Is there something in Torizoncore-builder that allows me to patch in the kernel option?

All the best!

FatLinux

Greetings @FatLinux,

As of the moment if you want to add additional kernel configs you will indeed need to rebuild the sources and add your config. Unfortunately torizoncore-builder is incapable of this functionality. Since building the kernel like this separately and out of sync with the rest of the image could lead to some strange issues, which we rather avoid.

Let me do this. Let me ask internally if we can just include the CONFIG_POWER_RESET_GPIO option by default in our kernel. This should resolve it for you and others in the long term.

I’ll get back to you whether this is something we can do.

Best Regards,
Jeremias

Hi Jeremias,

That would be very helpful indeed. It would mean, to implement a sensible and simple power management on the Colibri IMX8 on evaluation board will take everyone just few minutes.

Hi @FatLinux,

The requested configs were added to our kernel config cache here: https://github.com/toradex/toradex-kernel-cache/commit/3ade7cf22bf21323e75ed245ba57eaa73510f2fd

This cache is used to build the build kernel config for our images. This config should start appearing in our nightly builds within the next couple of days. Please try it out when you get a chance.

Best Regards,
Jeremias

Dear Jeremias,

Well, it took a little longer than I hoped to get to use this fix. I left it to the last thing on my development.

  1. I have a board design ready to build which has SODIMM pin 105 (or GPIOCHIP3 line 19) linked to the KILL# on my power button controller. This is ready to go low and switch off the DCDC converter feeding the module.

I have paid for some extra support from Toradex to do that design, and I think it has been quite a success. Its just this bit now that spoils the fun.

  1. I used torizon core to adjust my Mux changing the 0x20 to 0x21 to make it active low

imx8x-colibri.dtsi

I used the example to guide what I did: GPIO (Linux) (toradex.com)

pinctrl_hog1: hog1grp {
fsl,pins = <
IMX8QXP_CSI_D07_CI_PI_D09 0x61 /* SODIMM 65 /
IMX8QXP_QSPI0A_DATA2_LSIO_GPIO3_IO11 0x20 /
SODIMM 69 /
IMX8QXP_SAI0_TXC_LSIO_GPIO0_IO26 0x20 /
SODIMM 79 /
IMX8QXP_CSI_D02_CI_PI_D04 0x61 /
SODIMM 79 /
IMX8QXP_ENET0_RGMII_RXC_LSIO_GPIO5_IO03 0x06000020 /
SODIMM 85 /
IMX8QXP_CSI_D06_CI_PI_D08 0x61 /
SODIMM 85 /
IMX8QXP_SAI0_RXD_LSIO_GPIO0_IO27 0x20 /
SODIMM 97 /
IMX8QXP_CSI_D03_CI_PI_D05 0x61 /
SODIMM 97 /
IMX8QXP_SAI0_TXFS_LSIO_GPIO0_IO28 0x20 /
SODIMM 101 /
IMX8QXP_CSI_D00_CI_PI_D02 0x61 /
SODIMM 101 /
IMX8QXP_SAI0_TXD_LSIO_GPIO0_IO25 0x20 /
SODIMM 103 /
IMX8QXP_CSI_D01_CI_PI_D03 0x61 /
SODIMM 103 */

                            IMX8QXP_QSPI0B_DATA1_LSIO_GPIO3_IO19            0x21            /* SODIMM 105 */

                            IMX8QXP_USB_SS3_TC2_LSIO_GPIO4_IO05             0x20            /* SODIMM 127 */
                            IMX8QXP_USB_SS3_TC3_LSIO_GPIO4_IO06             0x20            /* SODIMM 131 */
                            IMX8QXP_USB_SS3_TC1_LSIO_GPIO4_IO04             0x20            /* SODIMM 133 */
                            IMX8QXP_CSI_PCLK_LSIO_GPIO3_IO00                0x20            /* SODIMM  96 */
                            IMX8QXP_QSPI0B_DATA3_LSIO_GPIO3_IO21            0x20            /* SODIMM  98 */
                            IMX8QXP_SAI1_RXFS_LSIO_GPIO0_IO31               0x20            /* SODIMM 100 */
                            IMX8QXP_QSPI0B_DQS_LSIO_GPIO3_IO22              0x20            /* SODIMM 102 */
                            IMX8QXP_QSPI0B_SS0_B_LSIO_GPIO3_IO23            0x20            /* SODIMM 104 */
                    >;
            };
  1. Now map the gpio-power off device onto that pin

/* load poweroff driver */
gpio-poweroff {
compatible = “gpio-poweroff”;
gpios = <&gpio3 19 GPIO_ACTIVE_LOW>;
};

  1. apply the change, add the display overlays and update my board. Drink a coffee, done.

torizoncore-builder dt apply device-trees/dts-arm64/imx8qxp-colibri-eval-v3.dts

Unfortunately, I can’t make it work. I get syntax error in my device tree build, which seems to be coming from the compatible=“gpio-poweroff”.

I must be doing something badly wrong, it just refuses to compile.

Do you have any ideas, suggestions to what I am doing wrong and how I can get it working?

Kind regards

Fatlinux

I don’t see anything immediately wrong with the syntax you shared. Could you provide the full overlay you are trying to compile so that I can try a test on my side?

Unfortunately, I can’t make it work. I get syntax error in my device tree build, which seems to be coming from the compatible=“gpio-poweroff”.

Also what’s the exact error message you receive here? Just so I know what to look out for on my side.

Best Regards,
Jeremias

Hi Jeremias,

Thanks for getting back so quickly.

Just to get this working quickly, so it can be checked out I am modifying the design tree directly.

So for the moment, I am using the evaluation board, so I am editing “imx8x-colibri-eval-v3.dtsi”

step 1. check out the tree

source tcb-env-setup.sh
torizoncore-builder dt checkout

step 2. edit my imx8x-colibri.dtsi

So I am going to nominate SODIMM105 or GPIO3 line 19 as the ACTIVE LOW output, so I find and edit it

            pinctrl_hog1: hog1grp {
                    fsl,pins = <
                            IMX8QXP_CSI_D07_CI_PI_D09                       0x61            /* SODIMM  65 */
                            IMX8QXP_QSPI0A_DATA2_LSIO_GPIO3_IO11            0x20            /* SODIMM  69 */
                            IMX8QXP_SAI0_TXC_LSIO_GPIO0_IO26                0x20            /* SODIMM  79 */
                            IMX8QXP_CSI_D02_CI_PI_D04                       0x61            /* SODIMM  79 */
                            IMX8QXP_ENET0_RGMII_RXC_LSIO_GPIO5_IO03         0x06000020      /* SODIMM  85 */
                            IMX8QXP_CSI_D06_CI_PI_D08                       0x61            /* SODIMM  85 */
                            IMX8QXP_SAI0_RXD_LSIO_GPIO0_IO27                0x20            /* SODIMM  97 */
                            IMX8QXP_CSI_D03_CI_PI_D05                       0x61            /* SODIMM  97 */
                            IMX8QXP_SAI0_TXFS_LSIO_GPIO0_IO28               0x20            /* SODIMM 101 */
                            IMX8QXP_CSI_D00_CI_PI_D02                       0x61            /* SODIMM 101 */
                            IMX8QXP_SAI0_TXD_LSIO_GPIO0_IO25                0x20            /* SODIMM 103 */
                            IMX8QXP_CSI_D01_CI_PI_D03                       0x61            /* SODIMM 103 */

                            **IMX8QXP_QSPI0B_DATA1_LSIO_GPIO3_IO19            0x21            /* SODIMM 105 */**

                            IMX8QXP_USB_SS3_TC2_LSIO_GPIO4_IO05             0x20            /* SODIMM 127 */
                            IMX8QXP_USB_SS3_TC3_LSIO_GPIO4_IO06             0x20            /* SODIMM 131 */
                            IMX8QXP_USB_SS3_TC1_LSIO_GPIO4_IO04             0x20            /* SODIMM 133 */
                            IMX8QXP_CSI_PCLK_LSIO_GPIO3_IO00                0x20            /* SODIMM  96 */

step 3. do a test apply to see if this throws an error

torizoncore-builder dt apply device-trees/dts-arm64/imx8qxp-colibri-eval-v3.dts

Result: No error

step 4. edit the imx8x-colibri-eval-v3.dtsi file , and add in the gpio-poweroff driver.

/* Colibri UART_A */
&lpuart3 {
status= “okay”;
};

/ load poweroff driver /
gpio-poweroff {
compatible = “gpio-poweroff”;
gpios = <&gpio3 19 GPIO_ACTIVE_LOW>;
};

&lsio_gpio3 {
/*
* Add GPIO3_10 as a wakeup source:
* Pin: 157 SC_P_QSPI0A_DATA1 (SODIMM_45)
* Type: 6 SC_PAD_WAKEUP_RISE_EDGE
* Line: 10 GPIO3_IO10
*/
pad-wakeup = <IMX8QXP_QSPI0A_DATA1 6 10>;
pad-wakeup-num = <1>;
};

step 5. do another test apply to see if this throws an error

torizoncore-builder dt apply device-trees/dts-arm64/imx8qxp-colibri-eval-v3.dts

this time…

Error: device-trees/dts-arm64/imx8x-colibri-eval-v3.dtsi:126.1-14 syntax error
FATAL ERROR: Unable to parse input tree
error: cannot apply device-trees/dts-arm64/imx8qxp-colibri-eval-v3.dts.

By commenting out the line gpios = <&gpio3 19 GPIO_ACTIVE_LOW>; the problem seems to be with

compatible = “gpio-poweroff”;

I had assumed with the kernel modifications, this would be accessible without doing much more.
Cannot find much more information than GPIO (Linux) (toradex.com)

Any ideas are gratefully received.

Fatlinux

Alright, I did some tests and I think I got it. So here’s the diff of my code changes:

diff --git a/dts-arm64/imx8x-colibri.dtsi b/dts-arm64/imx8x-colibri.dtsi
index 5e5e057..88a3e24 100644
--- a/dts-arm64/imx8x-colibri.dtsi
+++ b/dts-arm64/imx8x-colibri.dtsi
@@ -6,6 +6,13 @@
 #include "dt-bindings/pwm/pwm.h"
 
 / {
+
+        gpio-poweroff {
+                compatible= "gpio-poweroff";
+                pinctrl-0 = <&pinctrl_pwroff>;
+                gpios = <&lsio_gpio3 19 GPIO_ACTIVE_LOW>;
+        };
+
        backlight: backlight {
                compatible = "pwm-backlight";
                pinctrl-names = "default";
@@ -528,6 +535,13 @@
                    <&pinctrl_ext_io0>, <&pinctrl_lpspi2_cs2>;
 
        colibri-imx8qxp {
+
+                pinctrl_pwroff: pwroff {
+                        fsl,pins = <
+                                IMX8QXP_QSPI0B_DATA1_LSIO_GPIO3_IO19            0x20            /* SODIMM 105 */
+                        >;
+                };
+
                /* On-module touch pen-down interrupt */
                pinctrl_ad7879_int: ad7879-int {
                        fsl,pins = <
@@ -695,7 +709,6 @@
                                IMX8QXP_CSI_D00_CI_PI_D02                       0x61            /* SODIMM 101 */
                                IMX8QXP_SAI0_TXD_LSIO_GPIO0_IO25                0x20            /* SODIMM 103 */
                                IMX8QXP_CSI_D01_CI_PI_D03                       0x61            /* SODIMM 103 */
-                               IMX8QXP_QSPI0B_DATA1_LSIO_GPIO3_IO19            0x20            /* SODIMM 105 */
                                IMX8QXP_USB_SS3_TC2_LSIO_GPIO4_IO05             0x20            /* SODIMM 127 */
                                IMX8QXP_USB_SS3_TC3_LSIO_GPIO4_IO06             0x20            /* SODIMM 131 */
                                IMX8QXP_USB_SS3_TC1_LSIO_GPIO4_IO04             0x20            /* SODIMM 133 */

Please note that this compiles successfully but I have not tested whether the device tree. Just a quick summary of the differences in my changes compared to yours:

  • The gpio-poweroff node is a new device tree node so it needs to be defined under / in the device tree.
  • In the node itself GPIOs on the i.MX8X need to be described with lsio_gpio* instead of just gpio.
  • Furthermore it seems a new pinctrl group needs to be made with the GPIO we can’t just pass it to gpios.

I hope this helps clear things up.

Best Regards,
Jeremias

Hi Jeremias,

Thank you for that. I tested this out with a multimeter on SODIM105 on my Colibri Evaluation Board

It works perfectly.

Pin 105 goes from 3.3V to 0V when you issue the #poweroff command

So if I connect that to the Kill# on the LTC2954CTS8-1 power button driver on my new board, it will switch the power off to my module. I will go and order my hardware now and test it out!

Thank you again, your help is very much appreciated

Regards

Fatlinux

Glad I could help! Device tree works sometimes ends up in a bit of a “check and guess”.

Best Regards,
Jeremias