From 9875806f82479edeb21557fd0ae21793b4f92357 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Tue, 5 Feb 2019 12:35:22 -0800 Subject: [PATCH] gpio: gpio_sch: error when configure for level triggers The GPIO controller only supports edge triggering according to the descriptions of the associated registers. So errors out when level trigger is requested. Also adds the option to do double edges triggering as the controller supports this. Fixes #12763 Signed-off-by: Daniel Leung --- drivers/gpio/gpio_sch.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio_sch.c b/drivers/gpio/gpio_sch.c index 80c40b82e08ac..cd1e528f8aba1 100644 --- a/drivers/gpio/gpio_sch.c +++ b/drivers/gpio/gpio_sch.c @@ -96,7 +96,10 @@ static void _gpio_pin_config(struct device *dev, u32_t pin, int flags) _set_bit_gio(info->regs, pin, !(flags & GPIO_DIR_MASK)); if (flags & GPIO_INT) { - if (flags & GPIO_INT_ACTIVE_HIGH) { + if (flags & GPIO_INT_DOUBLE_EDGE) { + active_high = 1U; + active_low = 1U; + } else if (flags & GPIO_INT_ACTIVE_HIGH) { active_high = 1U; } else { active_low = 1U; @@ -128,6 +131,12 @@ static int gpio_sch_config(struct device *dev, { const struct gpio_sch_config *info = dev->config->config_info; + /* Do some sanity check first */ + if (flags & (GPIO_INT | GPIO_INT_LEVEL)) { + /* controller does not support level trigger */ + return -EINVAL; + } + if (access_op == GPIO_ACCESS_BY_PIN) { if (pin >= info->bits) { return -EINVAL;