Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

GPIO and sysfs

The sysfs GPIO interface lets people manage and control GPIOs through sets or files. It is located under /sys/class/gpio. The device model is heavily used here, and there are three kinds of entry available:

  • /sys/class/gpio/: This is where everything begins. This directory contains two special files, export and unexport:
    • export: This allow us to ask the kernel to export control of a given GPIO to the user space by writing its number to this file. An example is echo 21 > export, which will create a GPIO21 node for GPIO #21, if that's not requested by the kernel code.
    • unexport: This reverses the effect of exporting to user space. Example: echo 21 > unexport will remove any GPIO21 node exported using the export file.
  • /sys/class/gpio/gpioN/ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content