Skip to content

Commit 7207f98

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 6d9feca commit 7207f98

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

boards/ti/am243x_evm/am243x_evm_am2434_r5f0_0_defconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ 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
24+

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
#include <stdint.h>
88
#include <zephyr/fatal.h>
9+
#include <zephyr/logging/log.h>
910

1011
#include "soc.h"
12+
#include "zephyr/device.h"
1113
#include <common/ctrl_partitions.h>
14+
#include <zephyr/pm/device_runtime.h>
1215

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

0 commit comments

Comments
 (0)