Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1#ifndef __LINUX_GPIO_MACHINE_H
2#define __LINUX_GPIO_MACHINE_H
3
4#include <linux/types.h>
5#include <linux/list.h>
6
7enum gpio_lookup_flags {
8 GPIO_ACTIVE_HIGH = (0 << 0),
9 GPIO_ACTIVE_LOW = (1 << 0),
10 GPIO_OPEN_DRAIN = (1 << 1),
11 GPIO_OPEN_SOURCE = (1 << 2),
12 GPIO_SLEEP_MAINTAIN_VALUE = (0 << 3),
13 GPIO_SLEEP_MAY_LOOSE_VALUE = (1 << 3),
14};
15
16/**
17 * struct gpiod_lookup - lookup table
18 * @chip_label: name of the chip the GPIO belongs to
19 * @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
20 * @con_id: name of the GPIO from the device's point of view
21 * @idx: index of the GPIO in case several GPIOs share the same name
22 * @flags: mask of GPIO_* values
23 *
24 * gpiod_lookup is a lookup table for associating GPIOs to specific devices and
25 * functions using platform data.
26 */
27struct gpiod_lookup {
28 const char *chip_label;
29 u16 chip_hwnum;
30 const char *con_id;
31 unsigned int idx;
32 enum gpio_lookup_flags flags;
33};
34
35struct gpiod_lookup_table {
36 struct list_head list;
37 const char *dev_id;
38 struct gpiod_lookup table[];
39};
40
41/*
42 * Simple definition of a single GPIO under a con_id
43 */
44#define GPIO_LOOKUP(_chip_label, _chip_hwnum, _con_id, _flags) \
45 GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, 0, _flags)
46
47/*
48 * Use this macro if you need to have several GPIOs under the same con_id.
49 * Each GPIO needs to use a different index and can be accessed using
50 * gpiod_get_index()
51 */
52#define GPIO_LOOKUP_IDX(_chip_label, _chip_hwnum, _con_id, _idx, _flags) \
53{ \
54 .chip_label = _chip_label, \
55 .chip_hwnum = _chip_hwnum, \
56 .con_id = _con_id, \
57 .idx = _idx, \
58 .flags = _flags, \
59}
60
61#ifdef CONFIG_GPIOLIB
62void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
63void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
64#else
65static inline
66void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}
67static inline
68void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}
69#endif
70
71#endif /* __LINUX_GPIO_MACHINE_H */