GPIO Mapping on Variscite board

I’m using Variscite board with DART-MX8M-MINI
When I run the command cat /sys/kernel/debug/gpio I get the following output:

root@6c1fd38:/sys/devices/platform/gpio-keys/input/input2/event1# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-31, parent: platform/30200000.gpio, 30200000.gpio:
 gpio-7   (                    |eth_phy_pwr         ) out lo
 gpio-9   (                    |phy-reset           ) out hi
 gpio-11  (                    |sysfs               ) out lo
 gpio-12  (                    |spi_imx             ) out hi

gpiochip1: GPIOs 32-63, parent: platform/30210000.gpio, 30210000.gpio:
 gpio-38  (                    |sysfs               ) out hi
 gpio-39  (                    |sysfs               ) out hi
 gpio-42  (                    |sysfs               ) out hi
 gpio-43  (                    |enable              ) out hi
 gpio-44  (                    |cd                  ) in  hi IRQ
 gpio-51  (                    |VSD_3V3             ) out lo
 gpio-52  (                    |sysfs               ) out lo

gpiochip2: GPIOs 64-95, parent: platform/30220000.gpio, 30220000.gpio:

gpiochip3: GPIOs 96-127, parent: platform/30230000.gpio, 30230000.gpio:
 gpio-102 (                    |Back                ) in  hi IRQ
 gpio-109 (                    |Home                ) in  hi IRQ
 gpio-110 (                    |sysfs               ) out lo
 gpio-111 (                    |Down                ) in  hi IRQ
 gpio-112 (                    |sysfs               ) in  lo
 gpio-113 (                    |eMMC                ) out lo
 gpio-114 (                    |Up                  ) in  hi IRQ

gpiochip4: GPIOs 128-159, parent: platform/30240000.gpio, 30240000.gpio:
 gpio-133 (                    |sysfs               ) out lo

gpio-109 is a button on my dev board and it marked as “Home”, I need it to be under sysfs, is it possible? (I can access it via /dev/input/event1)
If yes, what about ONOFF gpio (available under /dev/input/event0)?

Thanks.

Hi @Tovi,

There are a couple ways to do this.

The gpio keys are defined in the device tree, in the kernel source fsl-imx8mm-var-dart.dts you’ll see the mapping for gpio-keys node:

            back {
                    label = "Back";
                    gpios = <&gpio4 6 GPIO_ACTIVE_LOW>;
                    linux,code = <KEY_BACK>;
            };

First option is that you modify the device-tree source fsl-imx8mm-var-dart.dts and rebuild it, then copy the final dtb on the device in the hostOS in /mnt/boot/fsl-imx8mm-var-dart.dtb

Second option is you copy the existing dtb to your PC, decompile it, remove the ‘Home’ node, recompile it and put it back on the target. For instance, you first get the dtb from the target, it is located in /mnt/boot/fsl-imx8mm-var-dart.dtb

Then, on your Linux PC:

dtc -I dtb fsl-imx8mm-var-dart.dtb -O dts -o source_dts.txt

Remove the ‘home key’ mapping from nodes handled by gpio_keys module:

  home {
  	label = "Home";
  	gpios = <0x24 0xd 0x1>;
  	linux,code = <0x66>;
  };

Then recompile,

dtc -I dts source_dts.txt -O dtb -o fsl-imx8mm-var-dart.dtb

place it back on the target in the hostOS in the same path and re-boot the board.

The third and also the most simple option is you do:

rmmod gpio_keys

To check the button values, regardless of which option of the above you chose, you can

echo 109 > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio109/direction

Hold / release the button and check the value:

cat /sys/class/gpio/gpio109/value

For the on/off button you need to check the schematic for the carrier board to see where it is connected.

1 Like