aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/gpio/machine.h
diff options
context:
space:
mode:
authorBartosz Golaszewski <brgl@bgdev.pl>2018-04-10 16:30:28 -0400
committerLinus Walleij <linus.walleij@linaro.org>2018-05-16 08:35:24 -0400
commita411e81e61df24023f40255145d8f023402002c9 (patch)
tree9fce75978e1553b206fea79511034453a174b5b7 /include/linux/gpio/machine.h
parent192a35b1348275c8decf42452d382be21add938c (diff)
gpiolib: add hogs support for machine code
Board files constitute a significant part of the users of the legacy GPIO framework. In many cases they only export a line and set its desired value. We could use GPIO hogs for that like we do for DT and ACPI but there's no support for that in machine code. This patch proposes to extend the machine.h API with support for registering hog tables in board files. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'include/linux/gpio/machine.h')
-rw-r--r--include/linux/gpio/machine.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/linux/gpio/machine.h b/include/linux/gpio/machine.h
index b2f2dc638463..daa44eac9241 100644
--- a/include/linux/gpio/machine.h
+++ b/include/linux/gpio/machine.h
@@ -39,6 +39,23 @@ struct gpiod_lookup_table {
39 struct gpiod_lookup table[]; 39 struct gpiod_lookup table[];
40}; 40};
41 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 */
50struct 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
42/* 59/*
43 * Simple definition of a single GPIO under a con_id 60 * Simple definition of a single GPIO under a con_id
44 */ 61 */
@@ -59,10 +76,23 @@ struct gpiod_lookup_table {
59 .flags = _flags, \ 76 .flags = _flags, \
60} 77}
61 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
62#ifdef CONFIG_GPIOLIB 91#ifdef CONFIG_GPIOLIB
63void gpiod_add_lookup_table(struct gpiod_lookup_table *table); 92void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
64void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n); 93void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n);
65void gpiod_remove_lookup_table(struct gpiod_lookup_table *table); 94void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
95void gpiod_add_hogs(struct gpiod_hog *hogs);
66#else 96#else
67static inline 97static inline
68void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {} 98void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}
@@ -70,6 +100,7 @@ static inline
70void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {} 100void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {}
71static inline 101static inline
72void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {} 102void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}
103static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {}
73#endif 104#endif
74 105
75#endif /* __LINUX_GPIO_MACHINE_H */ 106#endif /* __LINUX_GPIO_MACHINE_H */