Skip to content

Commit 00da48a

Browse files
committed
soc: ti: Turns on power domains in soc layer
Turns on all the power domains for devices with a power-domain device tree property in the soc layer. Supported for the R5f0_0 core on the AM243x EVM. Signed-off-by: Dave Joseph <[email protected]>
1 parent bfdab16 commit 00da48a

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

boards/ti/am243x_evm/am243x_evm_am2434_r5f0_0_defconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ CONFIG_UART_CONSOLE=y
1515

1616
# Enable MPU
1717
CONFIG_ARM_MPU=y
18+
19+
#Enable runtime power management
20+
CONFIG_PM_DEVICE=y
21+
CONFIG_POWER_DOMAIN=y
22+
CONFIG_PM=y
23+
CONFIG_PM_DEVICE_RUNTIME=y

soc/ti/k3/am6x/r5/soc.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
#include <stdint.h>
88
#include <zephyr/fatal.h>
9-
9+
#include <zephyr/logging/log.h>
1010
#include "soc.h"
11+
#include <zephyr/device.h>
1112
#include <common/ctrl_partitions.h>
13+
#include <zephyr/pm/device_runtime.h>
14+
LOG_MODULE_REGISTER(soc, LOG_LEVEL_DBG);
1215

1316
unsigned int z_soc_irq_get_active(void)
1417
{
@@ -53,3 +56,31 @@ void soc_early_init_hook(void)
5356
{
5457
k3_unlock_all_ctrl_partitions();
5558
}
59+
60+
#if defined(CONFIG_POWER_DOMAIN)
61+
int soc_power_domain_init(void)
62+
{
63+
LOG_INF("Starting power domain initialization\n");
64+
65+
int error_count = 0;
66+
67+
#define CHECK_NODE_POWER_DOMAIN(child) \
68+
if (DT_NODE_HAS_PROP(child, power_domains)) { \
69+
const struct device *dev_##child = \
70+
DEVICE_DT_GET_OR_NULL(DT_PHANDLE(child, power_domains)); \
71+
if (dev_##child) { \
72+
LOG_INF("Turning on power domain: %s\n", dev_##child->name); \
73+
int err = pm_device_runtime_get(dev_##child); \
74+
if (err < 0) { \
75+
LOG_INF("Failed to get power domain: %s\n", dev_##child->name); \
76+
error_count++; \
77+
} \
78+
} \
79+
}
80+
81+
DT_FOREACH_CHILD(DT_ROOT, CHECK_NODE_POWER_DOMAIN);
82+
83+
return error_count;
84+
}
85+
SYS_INIT(soc_power_domain_init, APPLICATION, 99);
86+
#endif /* CONFIG_SOC_POWER_DOMAIN_INIT */

0 commit comments

Comments
 (0)