summaryrefslogtreecommitdiff
path: root/zephyr/shim/include/gpio/gpio.h
diff options
context:
space:
mode:
authorMichał Barnaś <mb@semihalf.com>2021-11-08 18:14:50 +0100
committerCommit Bot <commit-bot@chromium.org>2021-11-09 20:03:47 +0000
commit8f6f43ffe51bbebfe355bab6898368b4d105fb80 (patch)
treeaf9cd959bdd533d1f68c45c40514a5e3a022bed4 /zephyr/shim/include/gpio/gpio.h
parent01afc0fb674113c3ec59b7b19a071840e18a1888 (diff)
downloadchrome-ec-8f6f43ffe51bbebfe355bab6898368b4d105fb80.tar.gz
zephyr: extract common gpio logic
Remove static from functions that convert flags between zephyr and cros. Make them available to other source files on zephyr builds. Extract macro that verifies if specified flags are correct. BRANCH=main BUG=b:202701452 TEST=compile cros and zephyr ec Change-Id: I0a07471aa8d3df3d4a4eb226f37d495a9d0e4eda Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3270676 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'zephyr/shim/include/gpio/gpio.h')
-rw-r--r--zephyr/shim/include/gpio/gpio.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h
index 18089e8a8e..dabf1d375e 100644
--- a/zephyr/shim/include/gpio/gpio.h
+++ b/zephyr/shim/include/gpio/gpio.h
@@ -9,6 +9,21 @@
#include <device.h>
#include <devicetree.h>
+/*
+ * Validate interrupt flags are valid for the Zephyr GPIO driver.
+ */
+#define IS_GPIO_INTERRUPT_FLAG(flag, mask) ((flag & mask) == mask)
+#define VALID_GPIO_INTERRUPT_FLAG(flag) \
+ (IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_RISING) || \
+ IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_FALLING) || \
+ IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_BOTH) || \
+ IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_LEVEL_LOW) || \
+ IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_LEVEL_HIGH) || \
+ IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_TO_INACTIVE) || \
+ IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_TO_ACTIVE) || \
+ IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_LEVEL_INACTIVE) || \
+ IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_LEVEL_ACTIVE))
+
/* Information about each unused pin in the 'unused-pins' device tree node. */
struct unused_pin_config {
/* Device name of a unused gpio pin */