stm32mp157 盘古开发板 Linux内核版本4.19
目录
1、拜兔核i2SOM的wiki上关于gpio应用的说明
链接:http://wiki.i2som.com/pages/viewpage.action?pageId=22479311
以下是链接中的复制内容:
GPIO操作在Linux系统上是常用功能,STM32MP1芯片平台也同样支持。从Linux 4.8版本开始,Linux引入了新的gpio操作方式,GPIO字符设备。不再使用以前SYSFS方式在"/sys/class/gpio"目录下来操作GPIO,而是,基于"文件描述符"的字符设备,每个GPIO组在"/dev"下有一个对应的gpiochip文件,例如"/dev/gpiochip0, /dev/gpiochip1"。使用常规的LInux文件操作方式即可操作这些gpiochip文件,基本可以概括为open() + ioctl() + poll() + read() + close()。
STM32MP1平台的gpiochip文件描述
字符设备
描述
/dev/gpiochip0 GPIOA /dev/gpiochip1 GPIOB /dev/gpiochip2 GPIOC /dev/gpiochip3 GPIOD /dev/gpiochip4 GPIOE /dev/gpiochip5 GPIOF /dev/gpiochip6 GPIOG /dev/gpiochip7 GPIOH /dev/gpiochip8 GPIOI /dev/gpiochip9 GPIOJ /dev/gpiochip10 GPIOK /dev/gpiochip11 GPIOZ gpiochip 操作
gpio申请
flags: desired flags for the desired GPIO lines, such as GPIOHANDLE_REQUEST_OUTPUT, GPIOHANDLE_REQUEST_ACTIVE_LOW etc, OR:ed * together. Note that even if multiple lines are requested, the same flags * must be applicable to all of them, if you want lines with individual * flags set, request them one by one. It is possible to select * a batch of input or output lines, but they must all have the same * characteristics, i.e. all inputs or all outputs, all active low etc
lines: number of lines requested in this request, i.e. the number of valid fields in the above arrays, set to 1 to request a single line
struct gpiohandle_request {
__u32 lineoffsets[GPIOHANDLES_MAX];
__u32 flags;
__u8 default_values[GPIOHANDLES_MAX];
char consumer_label[32];
__u32 lines;
int fd;
};
#define GPIOHANDLES_MAX 64
#define GPIOHANDLE_REQUEST_INPUT (1UL << 0)
#define GPIOHANDLE_REQUEST_OUTPUT (1UL << 1)
#define GPIOHANDLE_REQUEST_ACTIVE_LOW (1UL << 2)
#define GPIOHANDLE_REQUEST_OPEN_DRAIN (1UL << 3)
#define GPIOHANDLE_REQUEST_OPEN_SOURCE (1UL << 4)
gpio 操作数据
stru