summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun Lin <CHLin56@nuvoton.com>2021-12-01 17:44:34 +0800
committerCommit Bot <commit-bot@chromium.org>2021-12-03 20:07:00 +0000
commitde76a1b2b604bae6ed25b8eebe3abef95fefff02 (patch)
tree7a27c097353702732d968ed4780300a82bdc1eff
parentddcd78caddb12f0ca8253e6221ca119c393f2b93 (diff)
downloadchrome-ec-de76a1b2b604bae6ed25b8eebe3abef95fefff02.tar.gz
zephyr: pm: npcx: add pm constraint check in PM policy
In PR:40802, the UART driver uses the pm_constraint counter to indicate if the UART Tx is still ongoing or not. The pm policy should check the counter with the pm_constraint_get function to determine if the system can enter the suspend state or stay in the active one. BUG=none BRANCH=none TEST=pass "zmake testall" TEST=build npcx9_evb and volteer with PR:40802, make sure they can boot up and enter deep sleep. Make sure the console messages don't break. Signed-off-by: Jun Lin <CHLin56@nuvoton.com> Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com> Change-Id: I0803d9bb8454825a7ae876abaac58c65e7db1550 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3306790 Tested-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/shim/chip/npcx/power_policy.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/zephyr/shim/chip/npcx/power_policy.c b/zephyr/shim/chip/npcx/power_policy.c
index 803ac51e9b..7e2dd63ef4 100644
--- a/zephyr/shim/chip/npcx/power_policy.c
+++ b/zephyr/shim/chip/npcx/power_policy.c
@@ -5,27 +5,34 @@
#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[] =
+static const struct pm_state_info residency_info[] =
PM_STATE_INFO_DT_ITEMS_LIST(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)
{
+ ARG_UNUSED(cpu);
+
/* 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--) {
+ 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];
}
}
}