/sys/class/gpio vs. DTB

I configure a few GPIOs for my application. Is this something that can be accomplished entirely via DTB?

  # cd /sys/class/gpio
  
  # echo 50 > export
  # echo 115 > export
  # echo out > gpio50/direction
  # echo out > gpio115/direction

  # echo 1 > gpio50/value
  # echo 1 > gpio115/value
  
  # echo 0 > gpio50/value
  # echo 0 > gpio115/value

That is, setting which GPIOs are enabled, setting their direction, and setting their output state?

Thanks,

Why not do it in your applications?

http://derekmolloy.ie/kernel-gpio-programming-buttons-and-leds/

Regards,
John

configure a few GPIOs for my application. Is this something that can be accomplished entirely via DTB?

# cd /sys/class/gpio

# echo 50 > export
# echo 115 > export
# echo out > gpio50/direction
# echo out > gpio115/direction

# echo 1 > gpio50/value
# echo 1 > gpio115/value

# echo 0 > gpio50/value
# echo 0 > gpio115/value

That is, setting which GPIOs are enabled, setting their direction, and setting their output state?

Thanks,

Yes, it can be done. I thought you had all this down before ? You can configure what mode the pin is actually used for - The several different peripheral types per pin, or GPIO + pull up/down or neither, and pin direction.

Sorry, I haven't been able to touch this since last summer, and I don't always remember what I figured out. I do recall that I can set up the pin, but I've never figured out for sure how to set the output state.

Also, I've never succeeded in getting a full DTB working (one that sets up my pins, ADC, PRU, and audio). I'm hoping enough progress has been made in the kernels that I can finally get there. And I'm getting closer, just not quite there yet.

Here Rick, maybe this will refresh you on the subject. http://stackoverflow.com/questions/16872763/configuring-pins-mode-beaglebone second answer I think talks about device tree files, while the first one talks about some crazy script method . . .

But essentially, and I’m no expert here, and from the second answer . . .

pinctrl-single,pins = <
                                    0x070 0x2f /* P9_11 30 INPUT MODE7 none */
                                    0x074 0x2f /* P9_13 31 INPUT MODE7 none */
                                    0x040 0x2f /* P9_15 48 INPUT MODE7 none */
                                    0x15c 0x2f /* P9_17 05 INPUT MODE7 none */
                            >;

This in it’s self does a lot of explaining here. Check out the comments for each pin, and mode.

Yeah, as I was saying, I actually do remember how to do that, and successfully did. I still end up having to do the export and then other sysfs stuff to set the values.

Which, as I think about it, setting the values in the DTB is not so useful.* I do need to turn things on and off only under software control. But it'd be nice to get rid of the export step.

*There are a couple of GPIOs that turn regulators on and enable some of my audio circuitry. In theory, I can build the device tree including those, and then the audio APIs turn them on automatically when audio is enabled. But I've had limited success with getting that right.