October 2017
Intermediate to advanced
586 pages
14h 8m
English
The driver here summarizes the concepts introduced in descriptor-based interfaces. The principle is the same, as are the GPIOs:
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/platform_device.h> /* For platform devices */ #include <linux/gpio/consumer.h> /* For GPIO Descriptor */ #include <linux/interrupt.h> /* For IRQ */ #include <linux/of.h> /* For DT*/ /* * Let us consider the below mapping in device tree: * * foo_device { * compatible = "packt,gpio-descriptor-sample"; * led-gpios = <&gpio2 15 GPIO_ACTIVE_HIGH>, // red * <&gpio2 16 GPIO_ACTIVE_HIGH>, // green * * btn1-gpios = <&gpio2 1 GPIO_ACTIVE_LOW>; * btn2-gpios = <&gpio2 31 GPIO_ACTIVE_LOW>; * }; */ static struct ...Read now
Unlock full access