Browse Source

drivers: power_domain: Power domain TISCI driver support

Support added for power domain regulation using TISCI added for
devices using the binding ti,sci-pm-domain.
This driver relies on the TISCI layer to make calls to the
device manager core to perform power management.

Signed-off-by: Dave Joseph <d-joseph@ti.com>
pull/91688/head
Dave Joseph 2 months ago committed by Daniel DeGrasse
parent
commit
76905a8e54
  1. 1
      drivers/power_domain/CMakeLists.txt
  2. 26
      drivers/power_domain/Kconfig
  3. 105
      drivers/power_domain/power_domain_tisci.c
  4. 25
      dts/bindings/power-domain/ti,sci-pm-domain.yaml

1
drivers/power_domain/CMakeLists.txt

@ -8,3 +8,4 @@ zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_GPIO_MONITOR power_domain_gpio_ @@ -8,3 +8,4 @@ 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_SOC_PM_STATE power_domain_soc_state_change.c)
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_TISCI power_domain_tisci.c)

26
drivers/power_domain/Kconfig

@ -97,6 +97,30 @@ config POWER_DOMAIN_SOC_PM_STATE @@ -97,6 +97,30 @@ config POWER_DOMAIN_SOC_PM_STATE
select DEVICE_DEPS
help
Generic power domain control to turn on/off devices when the
PM subsystem transitions in and out certain power states.
PM subsystem transitions in and out of certain power states.
config POWER_DOMAIN_TISCI
bool "TISCI managed power domain"
default y
depends on DT_HAS_TI_SCI_PM_DOMAIN_ENABLED
help
TISCI managed power domain control to turn on/off devices when the
PM subsystem transitions in and out of certain power states.
if POWER_DOMAIN_TISCI
config POWER_DOMAIN_TISCI_INIT_PRIORITY
int "TISCI managed power domain init priority"
default 10
help
TISCI managed power domain initialization priority.
config SOC_POWER_DOMAIN_INIT
bool "Power domain initialization"
default y
help
Power domain initialization for the SoC.
endif #POWER_DOMAIN_TISCI
endif

105
drivers/power_domain/power_domain_tisci.c

@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
/*
* Copyright 2025 Texas Instruments
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdbool.h>
#include <zephyr/pm/device_runtime.h>
#include <zephyr/pm/device.h>
#include <zephyr/logging/log.h>
#include <zephyr/device.h>
#include <zephyr/drivers/firmware/tisci/tisci.h>
LOG_MODULE_REGISTER(tisci_pd);
#define DT_DRV_COMPAT ti_sci_pm_domain
const struct device *dmsc = DEVICE_DT_GET_OR_NULL(DT_NODELABEL(dmsc));
struct power_domain {
uint32_t devid;
bool mode;
};
static int tisci_power_domain_on(const struct power_domain *pd)
{
int ret;
if (pd->mode) {
ret = tisci_cmd_get_device_exclusive(dmsc, pd->devid);
} else {
ret = tisci_cmd_get_device(dmsc, pd->devid);
}
if (ret) {
LOG_ERR("TISCI PM: get_device(%u) failed (%d)\n", pd->devid, ret);
}
return ret;
}
static int tisci_power_domain_off(const struct power_domain *pd)
{
int ret = tisci_cmd_put_device(dmsc, pd->devid);
if (ret) {
LOG_ERR("TISCI PM: put_device(%u) failed (%d)\n", pd->devid, ret);
}
return ret;
}
static int tisci_pd_pm_action(const struct device *dev, enum pm_device_action action)
{
const struct power_domain *data = dev->config;
LOG_DBG("TISCI PM action %d on devid %d, mode %d", action, data->devid, data->mode);
int ret;
switch (action) {
case PM_DEVICE_ACTION_RESUME:
ret = tisci_power_domain_on(data);
return ret;
case PM_DEVICE_ACTION_SUSPEND:
ret = tisci_power_domain_off(data);
return ret;
case PM_DEVICE_ACTION_TURN_ON:
return 0;
case PM_DEVICE_ACTION_TURN_OFF:
return 0;
default:
return -ENOTSUP;
}
return 0;
}
static int tisci_pd_init(const struct device *dev)
{
int ret;
if (dmsc == NULL) {
LOG_ERR("DMSC device not found");
return -ENODEV;
}
ret = pm_device_driver_init(dev, tisci_pd_pm_action);
if (ret < 0) {
LOG_ERR("Failed to enable runtime PM: %d", ret);
return ret;
}
return 0;
}
#define TISCI_PD_DEVICE_DEFINE(inst) \
static struct power_domain power_domain_data_##inst = { \
.devid = DT_INST_PROP(inst, tisci_device_id), \
.mode = DT_INST_ENUM_IDX(inst, tisci_device_mode), \
}; \
PM_DEVICE_DT_INST_DEFINE(inst, tisci_pd_pm_action); \
DEVICE_DT_INST_DEFINE(inst, tisci_pd_init, PM_DEVICE_DT_INST_GET(inst), NULL, \
&power_domain_data_##inst, PRE_KERNEL_1, \
CONFIG_POWER_DOMAIN_TISCI_INIT_PRIORITY, NULL);
DT_INST_FOREACH_STATUS_OKAY(TISCI_PD_DEVICE_DEFINE);

25
dts/bindings/power-domain/ti,sci-pm-domain.yaml

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
# Copyright 2025 Texas Instruments Incorporated
# SPDX-License-Identifier: Apache-2.0
description: TISCI-managed power domain
compatible: "ti,sci-pm-domain"
include: base.yaml
properties:
tisci,device-id:
type: int
required: true
description: |
The device ID of the power domain as defined in the TISCI documentation.
tisci,device-mode:
type: string
required: true
enum:
- "SHARED"
- "EXCLUSIVE"
description: |
The device mode of the power domain as defined in the TISCI documentation.
"#power-domain-cells":
const: 0
Loading…
Cancel
Save