~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/gpio/machine.h

Version: ~ [ linux-5.6 ] ~ [ linux-5.5.13 ] ~ [ linux-5.4.28 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.113 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.174 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.217 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.217 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.82 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 #ifndef __LINUX_GPIO_MACHINE_H
  3 #define __LINUX_GPIO_MACHINE_H
  4 
  5 #include <linux/types.h>
  6 #include <linux/list.h>
  7 
  8 enum gpio_lookup_flags {
  9         GPIO_ACTIVE_HIGH = (0 << 0),
 10         GPIO_ACTIVE_LOW = (1 << 0),
 11         GPIO_OPEN_DRAIN = (1 << 1),
 12         GPIO_OPEN_SOURCE = (1 << 2),
 13         GPIO_PERSISTENT = (0 << 3),
 14         GPIO_TRANSITORY = (1 << 3),
 15 };
 16 
 17 /**
 18  * struct gpiod_lookup - lookup table
 19  * @chip_label: name of the chip the GPIO belongs to
 20  * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
 21  * @con_id: name of the GPIO from the device's point of view
 22  * @idx: index of the GPIO in case several GPIOs share the same name
 23  * @flags: mask of GPIO_* values
 24  *
 25  * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
 26  * functions using platform data.
 27  */
 28 struct gpiod_lookup {
 29         const char *chip_label;
 30         u16 chip_hwnum;
 31         const char *con_id;
 32         unsigned int idx;
 33         enum gpio_lookup_flags flags;
 34 };
 35 
 36 struct gpiod_lookup_table {
 37         struct list_head list;
 38         const char *dev_id;
 39         struct gpiod_lookup table[];
 40 };
 41 
 42 /**
 43  * struct gpiod_hog - GPIO line hog table
 44  * @chip_label: name of the chip the GPIO belongs to
 45  * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
 46  * @line_name: consumer name for the hogged line
 47  * @lflags: mask of GPIO lookup flags
 48  * @dflags: GPIO flags used to specify the direction and value
 49  */
 50 struct gpiod_hog {
 51         struct list_head list;
 52         const char *chip_label;
 53         u16 chip_hwnum;
 54         const char *line_name;
 55         enum gpio_lookup_flags lflags;
 56         int dflags;
 57 };
 58 
 59 /*
 60  * Simple definition of a single GPIO under a con_id
 61  */
 62 #define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \
 63         GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags)
 64 
 65 /*
 66  * Use this macro if you need to have several GPIOs under the same con_id.
 67  * Each GPIO needs to use a different index and can be accessed using
 68  * gpiod_get_index()
 69  */
 70 #define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags)  \
 71 {                                                                         \
 72         .chip_label = _chip_label,                                        \
 73         .chip_hwnum = _chip_hwnum,                                        \
 74         .con_id = _con_id,                                                \
 75         .idx = _idx,                                                      \
 76         .flags = _flags,                                                  \
 77 }
 78 
 79 /*
 80  * Simple definition of a single GPIO hog in an array.
 81  */
 82 #define GPIO_HOG(_chip_label, _chip_hwnum, _line_name, _lflags, _dflags)  \
 83 {                                                                         \
 84         .chip_label = _chip_label,                                        \
 85         .chip_hwnum = _chip_hwnum,                                        \
 86         .line_name = _line_name,                                          \
 87         .lflags = _lflags,                                                \
 88         .dflags = _dflags,                                                \
 89 }
 90 
 91 #ifdef CONFIG_GPIOLIB
 92 void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
 93 void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n);
 94 void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
 95 void gpiod_add_hogs(struct gpiod_hog *hogs);
 96 #else
 97 static inline
 98 void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}
 99 static inline
100 void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {}
101 static inline
102 void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}
103 static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {}
104 #endif
105 
106 #endif /* __LINUX_GPIO_MACHINE_H */
107 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp