Set GPIO pin as low by default

Hi everyone,

I’m trying to set pin #49 (GPIO 119) by default as low. From what I understand, this needs to be done through dts. I wrote the following dts:


#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/rockchip.h>

/ {
    metadata {
        title = "Set GPIO0_C5 to Low";
        compatible = "radxa,cm3-io", "radxa,cm3-rpi-cm4-io";
        category = "misc";
        exclusive = "GPIO0_C5";
        description = "Set GPIO0_C5 to Low.\nOn Radxa CM3 IO this is pin 5.\nOn Radxa CM3 RPI CM4 IO this is pin 5.";

    fragment@0 {
        target-path = "/";

        __overlay__ {
            gpio0_c5_low: gpio0_c5_low {
                compatible = "gpio-leds";
                gpios = <&gpio0 RK_PC5 GPIO_ACTIVE_LOW>; // Note: GPIO_ACTIVE_LOW to set it to low
                default-state = "off"; // Setting default-state to "off" ensures it starts as low

I compiled it and activated it with rsetup. However, when I check the state of the pin with:

sudo cat /sys/kernel/debug/gpio

I always get that the pin is high. Can someone please help me troubleshoot this? I checked dmesg, but there weren’t any error messages. I’m not sure what else to try.

1 Like

For those who are interested, after further investigation, I discovered that it’s not possible to set the default value using the device tree source (DTS). Instead, I was able to achieve this by recompiling U-Boot and setting the values in the U-Boot prompt console.