Skip to content

Commit

Permalink
gpio: gpio_sch: error when configure for level triggers
Browse files Browse the repository at this point in the history
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 <daniel.leung@intel.com>
  • Loading branch information
dcpleung authored and galak committed Feb 7, 2019
1 parent d5afe27 commit 69d4d32
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/gpio/gpio_sch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 69d4d32

Please sign in to comment.