.. | .. |
---|
6 | 6 | #include <linux/list.h> |
---|
7 | 7 | |
---|
8 | 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), |
---|
| 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, |
---|
15 | 19 | }; |
---|
16 | 20 | |
---|
17 | 21 | /** |
---|
18 | 22 | * 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 |
---|
| 23 | + * @key: either the name of the chip the GPIO belongs to, or the GPIO line name |
---|
| 24 | + * Note that GPIO line names are not guaranteed to be globally unique, |
---|
| 25 | + * so this will use the first match found! |
---|
| 26 | + * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO, or |
---|
| 27 | + * U16_MAX to indicate that @key is a GPIO line name |
---|
21 | 28 | * @con_id: name of the GPIO from the device's point of view |
---|
22 | 29 | * @idx: index of the GPIO in case several GPIOs share the same name |
---|
23 | | - * @flags: mask of GPIO_* values |
---|
| 30 | + * @flags: bitmask of gpio_lookup_flags GPIO_* values |
---|
24 | 31 | * |
---|
25 | 32 | * gpiod_lookup is a lookup table for associating GPIOs to specific devices and |
---|
26 | 33 | * functions using platform data. |
---|
27 | 34 | */ |
---|
28 | 35 | struct gpiod_lookup { |
---|
29 | | - const char *chip_label; |
---|
| 36 | + const char *key; |
---|
30 | 37 | u16 chip_hwnum; |
---|
31 | 38 | const char *con_id; |
---|
32 | 39 | unsigned int idx; |
---|
33 | | - enum gpio_lookup_flags flags; |
---|
| 40 | + unsigned long flags; |
---|
34 | 41 | }; |
---|
35 | 42 | |
---|
36 | 43 | struct gpiod_lookup_table { |
---|
.. | .. |
---|
44 | 51 | * @chip_label: name of the chip the GPIO belongs to |
---|
45 | 52 | * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO |
---|
46 | 53 | * @line_name: consumer name for the hogged line |
---|
47 | | - * @lflags: mask of GPIO lookup flags |
---|
| 54 | + * @lflags: bitmask of gpio_lookup_flags GPIO_* values |
---|
48 | 55 | * @dflags: GPIO flags used to specify the direction and value |
---|
49 | 56 | */ |
---|
50 | 57 | struct gpiod_hog { |
---|
.. | .. |
---|
52 | 59 | const char *chip_label; |
---|
53 | 60 | u16 chip_hwnum; |
---|
54 | 61 | const char *line_name; |
---|
55 | | - enum gpio_lookup_flags lflags; |
---|
| 62 | + unsigned long lflags; |
---|
56 | 63 | int dflags; |
---|
57 | 64 | }; |
---|
58 | 65 | |
---|
59 | 66 | /* |
---|
60 | 67 | * Simple definition of a single GPIO under a con_id |
---|
61 | 68 | */ |
---|
62 | | -#define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \ |
---|
63 | | - GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags) |
---|
| 69 | +#define GPIO_LOOKUP(_key, _chip_hwnum, _con_id, _flags) \ |
---|
| 70 | + GPIO_LOOKUP_IDX(_key, _chip_hwnum, _con_id, 0, _flags) |
---|
64 | 71 | |
---|
65 | 72 | /* |
---|
66 | 73 | * Use this macro if you need to have several GPIOs under the same con_id. |
---|
67 | 74 | * Each GPIO needs to use a different index and can be accessed using |
---|
68 | 75 | * gpiod_get_index() |
---|
69 | 76 | */ |
---|
70 | | -#define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \ |
---|
| 77 | +#define GPIO_LOOKUP_IDX(_key, _chip_hwnum, _con_id, _idx, _flags) \ |
---|
71 | 78 | { \ |
---|
72 | | - .chip_label = _chip_label, \ |
---|
| 79 | + .key = _key, \ |
---|
73 | 80 | .chip_hwnum = _chip_hwnum, \ |
---|
74 | 81 | .con_id = _con_id, \ |
---|
75 | 82 | .idx = _idx, \ |
---|
.. | .. |
---|
93 | 100 | void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n); |
---|
94 | 101 | void gpiod_remove_lookup_table(struct gpiod_lookup_table *table); |
---|
95 | 102 | void gpiod_add_hogs(struct gpiod_hog *hogs); |
---|
96 | | -#else |
---|
| 103 | +#else /* ! CONFIG_GPIOLIB */ |
---|
97 | 104 | static inline |
---|
98 | 105 | void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {} |
---|
99 | 106 | static inline |
---|
.. | .. |
---|
101 | 108 | static inline |
---|
102 | 109 | void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {} |
---|
103 | 110 | static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {} |
---|
104 | | -#endif |
---|
| 111 | +#endif /* CONFIG_GPIOLIB */ |
---|
105 | 112 | |
---|
106 | 113 | #endif /* __LINUX_GPIO_MACHINE_H */ |
---|