mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 22:51:37 +00:00
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>
This commit is contained in:
parent
192a35b134
commit
a411e81e61
3 changed files with 114 additions and 0 deletions
|
@ -39,6 +39,23 @@ struct gpiod_lookup_table {
|
|||
struct gpiod_lookup table[];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct gpiod_hog - GPIO line hog table
|
||||
* @chip_label: name of the chip the GPIO belongs to
|
||||
* @chip_hwnum: hardware number (i.e. relative to the chip) of the GPIO
|
||||
* @line_name: consumer name for the hogged line
|
||||
* @lflags: mask of GPIO lookup flags
|
||||
* @dflags: GPIO flags used to specify the direction and value
|
||||
*/
|
||||
struct gpiod_hog {
|
||||
struct list_head list;
|
||||
const char *chip_label;
|
||||
u16 chip_hwnum;
|
||||
const char *line_name;
|
||||
enum gpio_lookup_flags lflags;
|
||||
int dflags;
|
||||
};
|
||||
|
||||
/*
|
||||
* Simple definition of a single GPIO under a con_id
|
||||
*/
|
||||
|
@ -59,10 +76,23 @@ struct gpiod_lookup_table {
|
|||
.flags = _flags, \
|
||||
}
|
||||
|
||||
/*
|
||||
* Simple definition of a single GPIO hog in an array.
|
||||
*/
|
||||
#define GPIO_HOG(_chip_label, _chip_hwnum, _line_name, _lflags, _dflags) \
|
||||
{ \
|
||||
.chip_label = _chip_label, \
|
||||
.chip_hwnum = _chip_hwnum, \
|
||||
.line_name = _line_name, \
|
||||
.lflags = _lflags, \
|
||||
.dflags = _dflags, \
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GPIOLIB
|
||||
void gpiod_add_lookup_table(struct gpiod_lookup_table *table);
|
||||
void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n);
|
||||
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table);
|
||||
void gpiod_add_hogs(struct gpiod_hog *hogs);
|
||||
#else
|
||||
static inline
|
||||
void gpiod_add_lookup_table(struct gpiod_lookup_table *table) {}
|
||||
|
@ -70,6 +100,7 @@ static inline
|
|||
void gpiod_add_lookup_tables(struct gpiod_lookup_table **tables, size_t n) {}
|
||||
static inline
|
||||
void gpiod_remove_lookup_table(struct gpiod_lookup_table *table) {}
|
||||
static inline void gpiod_add_hogs(struct gpiod_hog *hogs) {}
|
||||
#endif
|
||||
|
||||
#endif /* __LINUX_GPIO_MACHINE_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue