Skip to content

Add Power Management support to GPIO for TI cc23x0 SoC #91609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions drivers/gpio/gpio_cc23x0.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <zephyr/irq.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/gpio/gpio_utils.h>
#include <zephyr/pm/device.h>

#include <driverlib/clkctl.h>
#include <driverlib/gpio.h>
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);