How to set GPIO to high by default in Kernel

Hi,

We have custom kernel for Beaglebone black with 7’inch LCD, we are configuring GPIO1_14(PIN 46) as gpio output high but when we boot, the gpio pin is not set to high.

We have tried these commands:
echo 46 > /sys/class/gpio/export

echo “out” > /sys/class/gpio/gpio46/direction

echo 1 > /sys/class/gpio/gpio46/value
or
echo 0 > /sys/class/gpio/gpio46/value
after entering this command, but the pin is unchanged.

For our application, we need the GPIO1_14 to be set to high by default. Attached
our dtsi file.

am335x-bone-common.dtsi (21.7 KB)

Thanks,
Anusha

How are you planning to use the pin? Does it need to always be high at startup (set and forget)… Are you planning to eventually toggle it? Is it the backlight/etc.

Regards,

Hi @RobertCNelson,

The GPIO is for enabling the backlight control pin. On bootup we want to enable the backlight and disable via our application.

Thanks,
Anusha

You are close here:

           /*bb_lcd_pwm_backlight_pins {
			//label = "beaglebone:green:usr2";
			gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
			//linux,default-trigger = "cpu0";
			//default-state = "on";
		};*/

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/leds/backlight/gpio-backlight.yaml?h=v6.3-rc5

    backlight: backlight {
        pinctrl-names = "default";
        pinctrl-0 = <&bb_lcd_pwm_backlight_pins>;
        compatible = "gpio-backlight";
        gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>;
        default-on;
    };

Regards,

Hi @RobertCNelson,

We are able to set the Backlight GPIO to high during bootup. Thanks for your help.

How we ca rotate the screen by 90 degree during bootup?

Thanks,
Anusha

Hi @RobertCNelson,

Could you please let us know how to enable GPIO in Kernel and use it via application to toggle. We have installed Adafurit BBIO library but unable to set or clear the GPIO.

Thanks,
Anusha

Since you’ve configured it as a backlight in the device tree, you should have access under /syc/class/backlight.

Regards,

How we can set or clear the GPIOs. We need to control the GPIOS through our application. With the default image we testing the GPIOs by installing the Adafruit_BBIO which was working.

Now when we install the Adafruit BBIO on custom Kernel its not working. Attached our dtsi file for reference.

am335x-bone-common.dtsi (22.6 KB)

Hi @Anusha as mentioned in my last post, you now already have local control of those gpio’s under /sys/class/backlight with your device tree changes.

Please run and report the output of:

tree /sys/class/backlight/*/

Then i’ll help you turn off and on the gpio…

Regards,