CCMike
Posts: 4
Joined: Thu Mar 29, 2018 2:01 pm

Device Tree Overlays Using New libgpiod API?

Thu Mar 29, 2018 5:10 pm

Hi,

We're working on a new DTO and are curious if there has been any work on building overlays that use the new Linux Kernel libgpiod API. I understand that this is now the preferred approach, and that the old sysfs API may eventually be removed.

Has anyone tried to build an Overlay using libgpiod? I'm assuming that this would be more future proof but as far as I can see there aren't any existing Overlays that one could use as a starting point, and in fact figuring out just how to do this might be somewhat of a guessing game.

Happy to hear othewise though!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1829
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Device Tree Overlays Using New libgpiod API?

Thu Mar 29, 2018 7:12 pm

Both libgpiod and sysfs provide userspace access to gpios, but Device Tree is for instantiating kernel drivers - there really is no overlap that I can think of. Can you enlighten me?

tdicola
Posts: 9
Joined: Wed Sep 26, 2012 5:54 am

Re: Device Tree Overlays Using New libgpiod API?

Tue Apr 10, 2018 8:53 pm

I've been banging my head against this for hours now too and getting nowhere. It really is amazing how complicated some of this stuff appears to be--a simple example that works would help immensely. Sadly I don't have anything to add yet other than I can at least get libgpiod to compile and access the GPIOs (it's really slick) and even get a SWIG-based Python API wrapped around it. But assigning names and pin control state to pins with the device tree is proving to be extremely elusive with the BCM2835 module.

And to answer PhilE's question, check out this doc about the newer gpio interface: https://www.kernel.org/doc/Documentation/gpio/board.txt It mentions you can use the device tree to assign a name to pins (when calling gpiod_get_index). However I can't for the life of me sort out how to actually get the BCM2835 device tree config to set this name.

swahren
Posts: 22
Joined: Mon Sep 19, 2016 5:24 pm
Location: Germany

Re: Device Tree Overlays Using New libgpiod API?

Sun Apr 29, 2018 9:22 am

The new GPIO device is intended for userspace not devicetree. I'm not sure what you are trying to achieve, but this could be helpful links:

gpio-line-name definition in upstream RPI 1 B:
https://github.com/raspberrypi/linux/bl ... -b.dts#L29

GPIO binding document:
https://github.com/raspberrypi/linux/bl ... o/gpio.txt

Example applications:
https://github.com/raspberrypi/linux/tr ... tools/gpio

Talk about the API:
https://elinux.org/images/9/9b/GPIO_for ... Makers.pdf

Return to “Device Tree”

Who is online

Users browsing this forum: No registered users and 2 guests