Skip to content

Commit 5453843

Browse files
committed
drivers: gpio: cc23x0: Add power management to GPIO
Add PM support to cc23x0 GPIO driver. Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
1 parent fdd02c5 commit 5453843

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

drivers/gpio/gpio_cc23x0.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <zephyr/irq.h>
1313
#include <zephyr/drivers/gpio.h>
1414
#include <zephyr/drivers/gpio/gpio_utils.h>
15+
#include <zephyr/pm/device.h>
1516

1617
#include <driverlib/clkctl.h>
1718
#include <driverlib/gpio.h>
@@ -49,6 +50,10 @@ static int gpio_cc23x0_config(const struct device *port, gpio_pin_t pin, gpio_fl
4950
config |= IOC_IOC0_PULLCTL_PULL_DIS;
5051
}
5152

53+
if (flags & GPIO_INT_WAKEUP) {
54+
config |= IOC_IOC0_WUENSB;
55+
}
56+
5257
if (!(flags & GPIO_SINGLE_ENDED)) {
5358
config |= IOC_IOC0_IOMODE_NORMAL;
5459
} else {
@@ -242,6 +247,24 @@ static void gpio_cc23x0_isr(const struct device *dev)
242247
gpio_fire_callbacks(&data->callbacks, dev, status);
243248
}
244249

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+
245268
static int gpio_cc23x0_init(const struct device *dev)
246269
{
247270
/* Enable GPIO domain clock */
@@ -277,5 +300,8 @@ static const struct gpio_cc23x0_config gpio_cc23x0_config_0 = {
277300

278301
static struct gpio_cc23x0_data gpio_cc23x0_data_0;
279302

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

Comments
 (0)