summaryrefslogtreecommitdiff
path: root/include/gpio.h
diff options
context:
space:
mode:
authorVlad Dogaru <vlad.dogaru@intel.com>2016-04-21 17:24:35 +0300
committerInaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>2016-06-22 16:47:16 +0000
commit661c5eb6760b1f3bb80910ea1dd7e797b40bdbb9 (patch)
treefeaef6d8a331fbe1adcfc0682e302e21f5f7d00b /include/gpio.h
parent8fed55f640563d358df119c029b6965794b5c7df (diff)
gpio: add device config helpers
Change-Id: I8af573484934a02893a395bb0d19551b5c9d0291 Signed-off-by: Vlad Dogaru <vlad.dogaru@intel.com>
Diffstat (limited to 'include/gpio.h')
-rw-r--r--include/gpio.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/gpio.h b/include/gpio.h
index 7477fd9fd..1af7b09f9 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -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