Dealing with the GPIO controller interface
The GPIO controller interface is designed around a single data structure, struct gpio_chip
. This data structure provides a set of functions, among which are methods to establish GPIO direction (input and output), methods used to access GPIO values (get and set), methods to map a given GPIO to IRQ and return the associated Linux interrupt number, and the debugfs
dump method (showing extra state like pull-up config). Apart from these functions, that data structure provides a flag to determine the nature of the controller, that is, to allow checking whether this controller's accessors may sleep or not. Still from within this data structure, the driver can set the GPIO base number, from which GPIO numbering should start.
Back to the code, a GPIO controller is represented as an instance of struct gpio_chip
, defined in <linux/gpio/driver.h>
as follows:
struct gpio_chip { const char ...