summaryrefslogtreecommitdiff
path: root/zephyr/shim/chip/npcx/power_policy.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/chip/npcx/power_policy.c')
-rw-r--r--zephyr/shim/chip/npcx/power_policy.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/zephyr/shim/chip/npcx/power_policy.c b/zephyr/shim/chip/npcx/power_policy.c
index 803ac51e9b..5c6b4dc309 100644
--- a/zephyr/shim/chip/npcx/power_policy.c
+++ b/zephyr/shim/chip/npcx/power_policy.c
@@ -5,27 +5,33 @@
#include <zephyr.h>
#include <pm/pm.h>
+#include <pm/policy.h>
#include <soc.h>
#include "console.h"
#include "cros_version.h"
#include "system.h"
-static const struct pm_state_info pm_min_residency[] =
- PM_STATE_INFO_DT_ITEMS_LIST(DT_NODELABEL(cpu0));
+static const struct pm_state_info residency_info[] =
+ PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0));
/* CROS PM policy handler */
-struct pm_state_info pm_policy_next_state(int32_t ticks)
+struct pm_state_info pm_policy_next_state(uint8_t cpu, int32_t ticks)
{
- /* Deep sleep is allowed and console is not in use. */
- if (DEEP_SLEEP_ALLOWED != 0 && !npcx_power_console_is_in_use()) {
- for (int i = ARRAY_SIZE(pm_min_residency) - 1; i >= 0; i--) {
+ ARG_UNUSED(cpu);
+
+ if (DEEP_SLEEP_ALLOWED) {
+ for (int i = ARRAY_SIZE(residency_info) - 1; i >= 0; i--) {
+ if (!pm_constraint_get(residency_info[i].state)) {
+ continue;
+ }
+
/* Find suitable power state by residency time */
if (ticks == K_TICKS_FOREVER ||
ticks >= k_us_to_ticks_ceil32(
- pm_min_residency[i]
+ residency_info[i]
.min_residency_us)) {
- return pm_min_residency[i];
+ return residency_info[i];
}
}
}