|
12 | 12 | #include <zephyr/irq.h>
|
13 | 13 | #include <zephyr/drivers/gpio.h>
|
14 | 14 | #include <zephyr/drivers/gpio/gpio_utils.h>
|
| 15 | +#include <zephyr/pm/device.h> |
15 | 16 |
|
16 | 17 | #include <driverlib/clkctl.h>
|
17 | 18 | #include <driverlib/gpio.h>
|
@@ -49,6 +50,10 @@ static int gpio_cc23x0_config(const struct device *port, gpio_pin_t pin, gpio_fl
|
49 | 50 | config |= IOC_IOC0_PULLCTL_PULL_DIS;
|
50 | 51 | }
|
51 | 52 |
|
| 53 | + if (flags & GPIO_INT_WAKEUP) { |
| 54 | + config |= IOC_IOC0_WUENSB; |
| 55 | + } |
| 56 | + |
52 | 57 | if (!(flags & GPIO_SINGLE_ENDED)) {
|
53 | 58 | config |= IOC_IOC0_IOMODE_NORMAL;
|
54 | 59 | } else {
|
@@ -242,6 +247,24 @@ static void gpio_cc23x0_isr(const struct device *dev)
|
242 | 247 | gpio_fire_callbacks(&data->callbacks, dev, status);
|
243 | 248 | }
|
244 | 249 |
|
| 250 | +#ifdef CONFIG_PM_DEVICE |
| 251 | +static int gpio_cc23x0_pm_action(const struct device *dev, enum pm_device_action action) |
| 252 | +{ |
| 253 | + switch (action) { |
| 254 | + case PM_DEVICE_ACTION_RESUME: |
| 255 | + CLKCTLEnable(CLKCTL_BASE, CLKCTL_GPIO); |
| 256 | + break; |
| 257 | + case PM_DEVICE_ACTION_SUSPEND: |
| 258 | + CLKCTLDisable(CLKCTL_BASE, CLKCTL_GPIO); |
| 259 | + break; |
| 260 | + default: |
| 261 | + return -ENOTSUP; |
| 262 | + } |
| 263 | + |
| 264 | + return 0; |
| 265 | +} |
| 266 | +#endif /* CONFIG_PM_DEVICE */ |
| 267 | + |
245 | 268 | static int gpio_cc23x0_init(const struct device *dev)
|
246 | 269 | {
|
247 | 270 | /* Enable GPIO domain clock */
|
@@ -277,5 +300,8 @@ static const struct gpio_cc23x0_config gpio_cc23x0_config_0 = {
|
277 | 300 |
|
278 | 301 | static struct gpio_cc23x0_data gpio_cc23x0_data_0;
|
279 | 302 |
|
280 |
| -DEVICE_DT_INST_DEFINE(0, gpio_cc23x0_init, NULL, &gpio_cc23x0_data_0, &gpio_cc23x0_config_0, |
281 |
| - PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY, &gpio_cc23x0_driver_api); |
| 303 | +PM_DEVICE_DT_DEFINE(0, gpio_cc23x0_pm_action); |
| 304 | + |
| 305 | +DEVICE_DT_INST_DEFINE(0, gpio_cc23x0_init, PM_DEVICE_DT_GET(0), &gpio_cc23x0_data_0, |
| 306 | + &gpio_cc23x0_config_0, PRE_KERNEL_1, |
| 307 | + CONFIG_GPIO_INIT_PRIORITY, &gpio_cc23x0_driver_api); |
0 commit comments