diff --git a/drivers/ioexpander/gpio_lower_half.c b/drivers/ioexpander/gpio_lower_half.c index 3e9c22e5df..40fba20c91 100644 --- a/drivers/ioexpander/gpio_lower_half.c +++ b/drivers/ioexpander/gpio_lower_half.c @@ -113,6 +113,33 @@ static const uint32_t g_gplh_inttype[GPIO_NPINTYPES] = IOEXPANDER_VAL_RISING, /* GPIO_INTERRUPT_RISING_PIN */ IOEXPANDER_VAL_FALLING, /* GPIO_INTERRUPT_FALLING_PIN */ IOEXPANDER_VAL_BOTH, /* GPIO_INTERRUPT_BOTH_PIN */ + CONFIG_GPIO_LOWER_HALF_INTTYPE, /* GPIO_INTERRUPT_PIN_WAKEUP */ + IOEXPANDER_VAL_HIGH, /* GPIO_INTERRUPT_HIGH_PIN_WAKEUP */ + IOEXPANDER_VAL_LOW, /* GPIO_INTERRUPT_LOW_PIN_WAKEUP */ + IOEXPANDER_VAL_RISING, /* GPIO_INTERRUPT_RISING_PIN_WAKEUP */ + IOEXPANDER_VAL_FALLING, /* GPIO_INTERRUPT_FALLING_PIN_WAKEUP */ + IOEXPANDER_VAL_BOTH, /* GPIO_INTERRUPT_BOTH_PIN_WAKEUP */ +}; + +static const uint32_t g_gplh_wakeuptype[GPIO_NPINTYPES] = +{ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INPUT_PIN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INPUT_PIN_PULLUP */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INPUT_PIN_PULLDOWN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_OUTPUT_PIN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_OUTPUT_PIN_OPENDRAIN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INTERRUPT_PIN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INTERRUPT_HIGH_PIN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INTERRUPT_LOW_PIN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INTERRUPT_RISING_PIN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INTERRUPT_FALLING_PIN */ + IOEXPANDER_WAKEUP_DISABLE, /* GPIO_INTERRUPT_BOTH_PIN */ + IOEXPANDER_WAKEUP_ENABLE, /* GPIO_INTERRUPT_PIN_WAKEUP */ + IOEXPANDER_WAKEUP_ENABLE, /* GPIO_INTERRUPT_HIGH_PIN_WAKEUP */ + IOEXPANDER_WAKEUP_ENABLE, /* GPIO_INTERRUPT_LOW_PIN_WAKEUP */ + IOEXPANDER_WAKEUP_ENABLE, /* GPIO_INTERRUPT_RISING_PIN_WAKEUP */ + IOEXPANDER_WAKEUP_ENABLE, /* GPIO_INTERRUPT_FALLING_PIN_WAKEUP */ + IOEXPANDER_WAKEUP_ENABLE, /* GPIO_INTERRUPT_BOTH_PIN_WAKEUP */ }; /**************************************************************************** @@ -357,6 +384,9 @@ static int gplh_setpintype(FAR struct gpio_dev_s *gpio, IOEXP_SETOPTION(ioe, pin, IOEXPANDER_OPTION_INTCFG, (FAR void *)(uintptr_t)g_gplh_inttype[pintype]); + + IOEXP_SETOPTION(ioe, pin, IOEXPANDER_OPTION_WAKEUPCFG, + (FAR void *)(uintptr_t)g_gplh_wakeuptype[pintype]); } gpio->gp_pintype = pintype; diff --git a/include/nuttx/ioexpander/gpio.h b/include/nuttx/ioexpander/gpio.h index fcfc0f217f..bd1bd5cd03 100644 --- a/include/nuttx/ioexpander/gpio.h +++ b/include/nuttx/ioexpander/gpio.h @@ -100,6 +100,12 @@ enum gpio_pintype_e GPIO_INTERRUPT_RISING_PIN, GPIO_INTERRUPT_FALLING_PIN, GPIO_INTERRUPT_BOTH_PIN, + GPIO_INTERRUPT_PIN_WAKEUP, + GPIO_INTERRUPT_HIGH_PIN_WAKEUP, + GPIO_INTERRUPT_LOW_PIN_WAKEUP, + GPIO_INTERRUPT_RISING_PIN_WAKEUP, + GPIO_INTERRUPT_FALLING_PIN_WAKEUP, + GPIO_INTERRUPT_BOTH_PIN_WAKEUP, GPIO_NPINTYPES }; diff --git a/include/nuttx/ioexpander/ioexpander.h b/include/nuttx/ioexpander/ioexpander.h index 83e458c76f..17529f0ed9 100644 --- a/include/nuttx/ioexpander/ioexpander.h +++ b/include/nuttx/ioexpander/ioexpander.h @@ -77,6 +77,10 @@ * structure to expander driver. */ +#define IOEXPANDER_OPTION_WAKEUPCFG 5 /* Configure interrupt for a pin to wake up the Soc */ +#define IOEXPANDER_WAKEUP_DISABLE 0 /* Do not cfg the pin as wake up source */ +#define IOEXPANDER_WAKEUP_ENABLE 1 /* Cfg the pin as wake up source */ + /* Access macros ************************************************************/ /****************************************************************************