diff --git a/drivers/gpio/gpio_cc23x0.c b/drivers/gpio/gpio_cc23x0.c index e721a389d3273..cf233339a108f 100644 --- a/drivers/gpio/gpio_cc23x0.c +++ b/drivers/gpio/gpio_cc23x0.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -49,6 +50,10 @@ static int gpio_cc23x0_config(const struct device *port, gpio_pin_t pin, gpio_fl config |= IOC_IOC0_PULLCTL_PULL_DIS; } + if (flags & GPIO_INT_WAKEUP) { + config |= IOC_IOC0_WUENSB; + } + if (!(flags & GPIO_SINGLE_ENDED)) { config |= IOC_IOC0_IOMODE_NORMAL; } else { @@ -242,6 +247,24 @@ static void gpio_cc23x0_isr(const struct device *dev) gpio_fire_callbacks(&data->callbacks, dev, status); } +#ifdef CONFIG_PM_DEVICE +static int gpio_cc23x0_pm_action(const struct device *dev, enum pm_device_action action) +{ + switch (action) { + case PM_DEVICE_ACTION_RESUME: + CLKCTLEnable(CLKCTL_BASE, CLKCTL_GPIO); + break; + case PM_DEVICE_ACTION_SUSPEND: + CLKCTLDisable(CLKCTL_BASE, CLKCTL_GPIO); + break; + default: + return -ENOTSUP; + } + + return 0; +} +#endif /* CONFIG_PM_DEVICE */ + static int gpio_cc23x0_init(const struct device *dev) { /* Enable GPIO domain clock */ @@ -277,5 +300,8 @@ static const struct gpio_cc23x0_config gpio_cc23x0_config_0 = { static struct gpio_cc23x0_data gpio_cc23x0_data_0; -DEVICE_DT_INST_DEFINE(0, gpio_cc23x0_init, NULL, &gpio_cc23x0_data_0, &gpio_cc23x0_config_0, - PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY, &gpio_cc23x0_driver_api); +PM_DEVICE_DT_DEFINE(0, gpio_cc23x0_pm_action); + +DEVICE_DT_INST_DEFINE(0, gpio_cc23x0_init, PM_DEVICE_DT_GET(0), &gpio_cc23x0_data_0, + &gpio_cc23x0_config_0, PRE_KERNEL_1, + CONFIG_GPIO_INIT_PRIORITY, &gpio_cc23x0_driver_api);