drivers: power_domain: introduce nrf_gpio_pad_group

Introduce the NRF GPIO Pad Group device driver and binding. The
pad group device represents the GPIO pads (pins), contrary to a
GPIO controller, which is one of the many devices which can be
muxed to pads in the pad group.

The pad group belong to a power domain, which is not neccesarily the
same power domain as devices being muxed to the pads, like GPIO or
UART. If no ACTIVE device is using any of the pads in the pad
group, the pad groups power domain may be SUSPENDED. Before the pad
groups power domain is SUSPENDED, pad config retention must be
enabled to prevent the pads from loosing their state. That's what
this device driver manages. Once retained, the pad configs and
outputs are locked, even when their power domain is SUSPENDED.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
This commit is contained in:
Bjarki Arge Andreasen 2025-07-02 22:23:43 +02:00 committed by Chris Friedt
parent 0ec81c5fdf
commit 3a8651ac82
5 changed files with 134 additions and 0 deletions

View File

@ -8,5 +8,6 @@ zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_GPIO_MONITOR power_domain_gpio_
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_INTEL_ADSP power_domain_intel_adsp.c)
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_NXP_SCU power_domain_nxp_scu.c)
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_NRFS_GDPWR power_domain_nrfs_gdpwr.c)
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_NRF_GPIO_PAD_GROUP power_domain_nrf_gpio_pad_group.c)
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_SOC_PM_STATE power_domain_soc_state_change.c)
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_TISCI power_domain_tisci.c)

View File

@ -124,5 +124,6 @@ config SOC_POWER_DOMAIN_INIT
endif #POWER_DOMAIN_TISCI
rsource "Kconfig.nrfs_gdpwr"
rsource "Kconfig.nrf_gpio_pad_group"
endif

View File

@ -0,0 +1,7 @@
# Copyright 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
config POWER_DOMAIN_NRF_GPIO_PAD_GROUP
bool "NRFS Global Domain Power Request driver"
depends on DT_HAS_NORDIC_NRF_GPIO_PAD_GROUP_ENABLED
default y

View File

@ -0,0 +1,82 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#define DT_DRV_COMPAT nordic_nrf_gpio_pad_group
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/pm/device.h>
#include <zephyr/logging/log.h>
#include <hal/nrf_gpio.h>
LOG_MODULE_REGISTER(nrf_gpio_pad_group, CONFIG_POWER_DOMAIN_LOG_LEVEL);
struct nrf_port_retain_config {
NRF_GPIO_Type *regs;
uint32_t retain_mask;
};
static void nrf_port_retain_driver_turn_off(const struct device *dev)
{
const struct nrf_port_retain_config *dev_config = dev->config;
LOG_DBG("%s pads 0x%08x retain %s", dev->name, dev_config->retain_mask, "enable");
nrf_gpio_port_retain_enable(dev_config->regs, dev_config->retain_mask);
}
static void nrf_port_retain_driver_turn_on(const struct device *dev)
{
const struct nrf_port_retain_config *dev_config = dev->config;
LOG_DBG("%s pads 0x%08x retain %s", dev->name, dev_config->retain_mask, "disable");
nrf_gpio_port_retain_disable(dev_config->regs, dev_config->retain_mask);
}
static int nrf_port_retain_driver_pm_action(const struct device *dev,
enum pm_device_action action)
{
switch (action) {
case PM_DEVICE_ACTION_TURN_OFF:
nrf_port_retain_driver_turn_off(dev);
break;
case PM_DEVICE_ACTION_TURN_ON:
nrf_port_retain_driver_turn_on(dev);
break;
default:
break;
};
return 0;
}
static int nrf_port_retain_driver_init(const struct device *dev)
{
return pm_device_driver_init(dev, nrf_port_retain_driver_pm_action);
}
#define NRF_GPIO_PAD_GROUP_DEFINE(inst) \
static const struct nrf_port_retain_config _CONCAT(config, inst) = { \
.regs = (NRF_GPIO_Type *)DT_REG_ADDR(DT_INST_PARENT(inst)), \
.retain_mask = DT_PROP_OR(inst, retain_mask, UINT32_MAX), \
}; \
\
PM_DEVICE_DT_INST_DEFINE(inst, nrf_port_retain_driver_pm_action); \
\
DEVICE_DT_INST_DEFINE( \
inst, \
nrf_port_retain_driver_init, \
PM_DEVICE_DT_INST_GET(inst), \
NULL, \
&_CONCAT(config, inst), \
PRE_KERNEL_1, \
UTIL_INC(CONFIG_GPIO_INIT_PRIORITY), \
NULL \
);
DT_INST_FOREACH_STATUS_OKAY(NRF_GPIO_PAD_GROUP_DEFINE)

View File

@ -0,0 +1,43 @@
# Copyright 2025 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
description: |
Nordic nRF GPIO pad group.
The GPIO pad group describes the pads (package
pins of the SoC) the GPIO controller manages.
The pads may be in a different power domain than
the GPIO controller, and may require enabling
retention to preserve the GPIO configuration if
the power domain is suspended.
The GPIO pad group is a child node of the GPIO
controller which manages the pad group, named
pad-group. The pad group's nodelabel is named
gpio_pad_group<GPIO number>.
Example layout:
gpio0: gpio@938000 {
compatible = "nordic,nrf-gpio";
...
gpio_pad_group0: pad-group {
compatible = "nordic,nrf-gpio-pad-group";
power-domains = <&gdpwr_slow_main>;
retain-mask = <0xFFF>;
};
};
compatible: "nordic,nrf-gpio-pad-group"
include: base.yaml
properties:
retain-mask:
type: int
description: |
Mask of pins which shall be retained if pad
group's power domain is powered off.