Linus Walleij | 3c702e9 | 2015-10-21 15:29:53 +0200 | [diff] [blame] | 1 | /* |
| 2 | * <linux/gpio.h> - userspace ABI for the GPIO character devices |
| 3 | * |
| 4 | * Copyright (C) 2015 Linus Walleij |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published by |
| 8 | * the Free Software Foundation. |
| 9 | */ |
| 10 | #ifndef _UAPI_GPIO_H_ |
| 11 | #define _UAPI_GPIO_H_ |
| 12 | |
| 13 | #include <linux/ioctl.h> |
| 14 | #include <linux/types.h> |
| 15 | |
| 16 | /** |
| 17 | * struct gpiochip_info - Information about a certain GPIO chip |
Linus Walleij | 214338e | 2016-02-25 21:01:48 +0100 | [diff] [blame^] | 18 | * @name: the Linux kernel name of this GPIO chip |
| 19 | * @label: a functional name for this GPIO chip, such as a product |
| 20 | * number, may be NULL |
Linus Walleij | 3c702e9 | 2015-10-21 15:29:53 +0200 | [diff] [blame] | 21 | * @lines: number of GPIO lines on this chip |
| 22 | */ |
| 23 | struct gpiochip_info { |
| 24 | char name[32]; |
Linus Walleij | df4878e | 2016-02-12 14:48:23 +0100 | [diff] [blame] | 25 | char label[32]; |
Linus Walleij | 3c702e9 | 2015-10-21 15:29:53 +0200 | [diff] [blame] | 26 | __u32 lines; |
| 27 | }; |
| 28 | |
Linus Walleij | 521a2ad | 2016-02-12 22:25:22 +0100 | [diff] [blame] | 29 | /* Line is in use by the kernel */ |
| 30 | #define GPIOLINE_FLAG_KERNEL (1UL << 0) |
| 31 | #define GPIOLINE_FLAG_IS_OUT (1UL << 1) |
| 32 | #define GPIOLINE_FLAG_ACTIVE_LOW (1UL << 2) |
| 33 | #define GPIOLINE_FLAG_OPEN_DRAIN (1UL << 3) |
| 34 | #define GPIOLINE_FLAG_OPEN_SOURCE (1UL << 4) |
| 35 | |
| 36 | /** |
| 37 | * struct gpioline_info - Information about a certain GPIO line |
Linus Walleij | 214338e | 2016-02-25 21:01:48 +0100 | [diff] [blame^] | 38 | * @line_offset: the local offset on this GPIO device, fill this in when |
| 39 | * requesting the line information from the kernel |
Linus Walleij | 521a2ad | 2016-02-12 22:25:22 +0100 | [diff] [blame] | 40 | * @flags: various flags for this line |
Linus Walleij | 214338e | 2016-02-25 21:01:48 +0100 | [diff] [blame^] | 41 | * @name: the name of this GPIO line, such as the output pin of the line on the |
| 42 | * chip, a rail or a pin header name on a board, as specified by the gpio |
| 43 | * chip, may be NULL |
| 44 | * @consumer: a functional name for the consumer of this GPIO line as set by |
| 45 | * whatever is using it, will be NULL if there is no current user but may |
| 46 | * also be NULL if the consumer doesn't set this up |
Linus Walleij | 521a2ad | 2016-02-12 22:25:22 +0100 | [diff] [blame] | 47 | */ |
| 48 | struct gpioline_info { |
| 49 | __u32 line_offset; |
| 50 | __u32 flags; |
| 51 | char name[32]; |
Linus Walleij | 214338e | 2016-02-25 21:01:48 +0100 | [diff] [blame^] | 52 | char consumer[32]; |
Linus Walleij | 521a2ad | 2016-02-12 22:25:22 +0100 | [diff] [blame] | 53 | }; |
| 54 | |
Linus Walleij | 3c702e9 | 2015-10-21 15:29:53 +0200 | [diff] [blame] | 55 | #define GPIO_GET_CHIPINFO_IOCTL _IOR('o', 0x01, struct gpiochip_info) |
Linus Walleij | 521a2ad | 2016-02-12 22:25:22 +0100 | [diff] [blame] | 56 | #define GPIO_GET_LINEINFO_IOCTL _IOWR('o', 0x02, struct gpioline_info) |
Linus Walleij | 3c702e9 | 2015-10-21 15:29:53 +0200 | [diff] [blame] | 57 | |
| 58 | #endif /* _UAPI_GPIO_H_ */ |