Skip to content

Commit 76905a8

Browse files
Kronosblasterdanieldegrasse
authored andcommitted
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>
1 parent 558f26e commit 76905a8

File tree

4 files changed

+156
-1
lines changed

4 files changed

+156
-1
lines changed

drivers/power_domain/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_GPIO_MONITOR power_domain_gpio_
88
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_INTEL_ADSP power_domain_intel_adsp.c)
99
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_NXP_SCU power_domain_nxp_scu.c)
1010
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_SOC_PM_STATE power_domain_soc_state_change.c)
11+
zephyr_library_sources_ifdef(CONFIG_POWER_DOMAIN_TISCI power_domain_tisci.c)

drivers/power_domain/Kconfig

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,30 @@ config POWER_DOMAIN_SOC_PM_STATE
9797
select DEVICE_DEPS
9898
help
9999
Generic power domain control to turn on/off devices when the
100-
PM subsystem transitions in and out certain power states.
100+
PM subsystem transitions in and out of certain power states.
101+
102+
config POWER_DOMAIN_TISCI
103+
bool "TISCI managed power domain"
104+
default y
105+
depends on DT_HAS_TI_SCI_PM_DOMAIN_ENABLED
106+
help
107+
TISCI managed power domain control to turn on/off devices when the
108+
PM subsystem transitions in and out of certain power states.
109+
110+
if POWER_DOMAIN_TISCI
111+
112+
config POWER_DOMAIN_TISCI_INIT_PRIORITY
113+
int "TISCI managed power domain init priority"
114+
default 10
115+
help
116+
TISCI managed power domain initialization priority.
117+
118+
config SOC_POWER_DOMAIN_INIT
119+
bool "Power domain initialization"
120+
default y
121+
help
122+
Power domain initialization for the SoC.
123+
124+
endif #POWER_DOMAIN_TISCI
101125

102126
endif
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Copyright 2025 Texas Instruments
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <stdbool.h>
8+
#include <zephyr/pm/device_runtime.h>
9+
#include <zephyr/pm/device.h>
10+
#include <zephyr/logging/log.h>
11+
#include <zephyr/device.h>
12+
#include <zephyr/drivers/firmware/tisci/tisci.h>
13+
LOG_MODULE_REGISTER(tisci_pd);
14+
15+
#define DT_DRV_COMPAT ti_sci_pm_domain
16+
17+
const struct device *dmsc = DEVICE_DT_GET_OR_NULL(DT_NODELABEL(dmsc));
18+
19+
struct power_domain {
20+
uint32_t devid;
21+
bool mode;
22+
};
23+
24+
static int tisci_power_domain_on(const struct power_domain *pd)
25+
{
26+
int ret;
27+
28+
if (pd->mode) {
29+
ret = tisci_cmd_get_device_exclusive(dmsc, pd->devid);
30+
} else {
31+
ret = tisci_cmd_get_device(dmsc, pd->devid);
32+
}
33+
34+
if (ret) {
35+
LOG_ERR("TISCI PM: get_device(%u) failed (%d)\n", pd->devid, ret);
36+
}
37+
38+
return ret;
39+
}
40+
41+
static int tisci_power_domain_off(const struct power_domain *pd)
42+
{
43+
int ret = tisci_cmd_put_device(dmsc, pd->devid);
44+
45+
if (ret) {
46+
LOG_ERR("TISCI PM: put_device(%u) failed (%d)\n", pd->devid, ret);
47+
}
48+
49+
return ret;
50+
}
51+
52+
static int tisci_pd_pm_action(const struct device *dev, enum pm_device_action action)
53+
{
54+
const struct power_domain *data = dev->config;
55+
56+
LOG_DBG("TISCI PM action %d on devid %d, mode %d", action, data->devid, data->mode);
57+
int ret;
58+
59+
switch (action) {
60+
case PM_DEVICE_ACTION_RESUME:
61+
ret = tisci_power_domain_on(data);
62+
return ret;
63+
case PM_DEVICE_ACTION_SUSPEND:
64+
ret = tisci_power_domain_off(data);
65+
return ret;
66+
case PM_DEVICE_ACTION_TURN_ON:
67+
return 0;
68+
case PM_DEVICE_ACTION_TURN_OFF:
69+
return 0;
70+
default:
71+
return -ENOTSUP;
72+
}
73+
74+
return 0;
75+
}
76+
77+
static int tisci_pd_init(const struct device *dev)
78+
{
79+
int ret;
80+
81+
if (dmsc == NULL) {
82+
LOG_ERR("DMSC device not found");
83+
return -ENODEV;
84+
}
85+
86+
ret = pm_device_driver_init(dev, tisci_pd_pm_action);
87+
if (ret < 0) {
88+
LOG_ERR("Failed to enable runtime PM: %d", ret);
89+
return ret;
90+
}
91+
92+
return 0;
93+
}
94+
95+
#define TISCI_PD_DEVICE_DEFINE(inst) \
96+
static struct power_domain power_domain_data_##inst = { \
97+
.devid = DT_INST_PROP(inst, tisci_device_id), \
98+
.mode = DT_INST_ENUM_IDX(inst, tisci_device_mode), \
99+
}; \
100+
PM_DEVICE_DT_INST_DEFINE(inst, tisci_pd_pm_action); \
101+
DEVICE_DT_INST_DEFINE(inst, tisci_pd_init, PM_DEVICE_DT_INST_GET(inst), NULL, \
102+
&power_domain_data_##inst, PRE_KERNEL_1, \
103+
CONFIG_POWER_DOMAIN_TISCI_INIT_PRIORITY, NULL);
104+
105+
DT_INST_FOREACH_STATUS_OKAY(TISCI_PD_DEVICE_DEFINE);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Texas Instruments Incorporated
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: TISCI-managed power domain
5+
6+
compatible: "ti,sci-pm-domain"
7+
8+
include: base.yaml
9+
10+
properties:
11+
tisci,device-id:
12+
type: int
13+
required: true
14+
description: |
15+
The device ID of the power domain as defined in the TISCI documentation.
16+
tisci,device-mode:
17+
type: string
18+
required: true
19+
enum:
20+
- "SHARED"
21+
- "EXCLUSIVE"
22+
description: |
23+
The device mode of the power domain as defined in the TISCI documentation.
24+
"#power-domain-cells":
25+
const: 0

0 commit comments

Comments
 (0)