This source file includes following definitions.
- gpiod_add_lookup_table
- gpiod_add_lookup_tables
- gpiod_remove_lookup_table
- gpiod_add_hogs
1
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 GPIO_PULL_UP = (1 << 4),
16 GPIO_PULL_DOWN = (1 << 5),
17
18 GPIO_LOOKUP_FLAGS_DEFAULT = GPIO_ACTIVE_HIGH | GPIO_PERSISTENT,
19 };
20
21
22
23
24
25
26
27
28
29
30
31
32 struct gpiod_lookup {
33 const char *chip_label;
34 u16 chip_hwnum;
35 const char *con_id;
36 unsigned int idx;
37 unsigned long flags;
38 };
39
40 struct gpiod_lookup_table {
41 struct list_head list;
42 const char *dev_id;
43 struct gpiod_lookup table[];
44 };
45
46
47
48
49
50
51
52
53
54 struct gpiod_hog {
55 struct list_head list;
56 const char *chip_label;
57 u16 chip_hwnum;
58 const char *line_name;
59 unsigned long lflags;
60 int dflags;
61 };
62
63
64
65
66 #define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \
67 GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags)
68
69
70
71
72
73
74 #define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \
75 { \
76 .chip_label = _chip_label, \
77 .chip_hwnum = _chip_hwnum, \
78 .con_id = _con_id, \
79 .idx = _idx, \
80 .flags = _flags, \
81 }
82
83
84
85
86 #define GPIO_HOG(_chip_label, _chip_hwnum, _line_name, _lflags, _dflags) \
87 { \
88 .chip_label = _chip_label, \
89 .chip_hwnum = _chip_hwnum, \
90 .line_name = _line_name, \
91 .lflags = _lflags, \
92 .dflags = _dflags, \
93 }
94
95 #ifdef CONFIG_GPIOLIB
96 void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
97 void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n);
98 void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
99 void gpiod_add_hogs(struct gpiod_hog *hogs);
100 #else
101 static inline
102 void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}
103 static inline
104 void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {}
105 static inline
106 void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}
107 static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {}
108 #endif
109
110 #endif