gpio: add device config helpers
Change-Id: I8af573484934a02893a395bb0d19551b5c9d0291 Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
This commit is contained in:
parent
8fed55f640
commit
661c5eb676
1 changed files with 26 additions and 0 deletions
|
@ -437,6 +437,32 @@ static inline int gpio_port_disable_callback(struct device *port)
|
|||
return api->disable_callback(port, GPIO_ACCESS_BY_PORT, 0);
|
||||
}
|
||||
|
||||
struct gpio_pin_config {
|
||||
char *gpio_controller;
|
||||
uint32_t gpio_pin;
|
||||
};
|
||||
|
||||
#define GPIO_DECLARE_PIN_CONFIG_IDX(_idx) \
|
||||
struct gpio_pin_config gpio_pin_ ##_idx
|
||||
#define GPIO_DECLARE_PIN_CONFIG \
|
||||
GPIO_DECLARE_PIN_CONFIG_IDX()
|
||||
|
||||
#define GPIO_PIN_IDX(_idx, _controller, _pin) \
|
||||
.gpio_pin_ ##_idx = { \
|
||||
.gpio_controller = (_controller),\
|
||||
.gpio_pin = (_pin), \
|
||||
}
|
||||
#define GPIO_PIN(_controller, _pin) \
|
||||
GPIO_PIN_IDX(, _controller, _pin)
|
||||
|
||||
#define GPIO_GET_CONTROLLER_IDX(_idx, _conf) \
|
||||
((_conf)->gpio_pin_ ##_idx.gpio_controller)
|
||||
#define GPIO_GET_PIN_IDX(_idx, _conf) \
|
||||
((_conf)->gpio_pin_ ##_idx.gpio_pin)
|
||||
|
||||
#define GPIO_GET_CONTROLLER(_conf) GPIO_GET_CONTROLLER_IDX(, _conf)
|
||||
#define GPIO_GET_PIN(_conf) GPIO_GET_PIN_IDX(, _conf)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue