summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-06-17 13:15:29 -0600
committerCommit Bot <commit-bot@chromium.org>2021-06-17 23:26:48 +0000
commit4fb0165b58bf216a4db876a1dc2b992e00d93e93 (patch)
treeee743f79338602d8907bc20177a4bbb58aec524e
parent3ab3288aace37f659841eb362478c5ce249530bf (diff)
downloadchrome-ec-4fb0165b58bf216a4db876a1dc2b992e00d93e93.tar.gz
zephyr: Update power policy to support v2.6
Update power_policy.c to support API changes in v2.6. BRANCH=none BUG=b:190731415 TEST=build brya with both 2.5 and 2.6 Change-Id: I757b465e03f8da30e1f00d6bde8234e1434e90db Signed-off-by: Yuval Peress <peress@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2970988 Reviewed-by: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--zephyr/shim/chip/npcx/power_policy.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/zephyr/shim/chip/npcx/power_policy.c b/zephyr/shim/chip/npcx/power_policy.c
index e3f280438f..ff3efaf84a 100644
--- a/zephyr/shim/chip/npcx/power_policy.c
+++ b/zephyr/shim/chip/npcx/power_policy.c
@@ -4,12 +4,20 @@
*/
#include <zephyr.h>
-#include <power/power.h>
#include <soc.h>
#include "console.h"
+#include "cros_version.h"
#include "system.h"
+#if IS_ZEPHYR_VERSION(2, 6)
+#include <pm/pm.h>
+#elif IS_ZEPHYR_VERSION(2, 5)
+#include <power/power.h>
+#else
+#error "Unsupported Zephyr version"
+#endif
+
static const struct pm_state_info pm_min_residency[] =
PM_STATE_INFO_DT_ITEMS_LIST(DT_NODELABEL(cpu0));
@@ -35,5 +43,23 @@ struct pm_state_info pm_policy_next_state(int32_t ticks)
/* CROS PM device policy handler */
bool pm_policy_low_power_devices(enum pm_state state)
{
+#if IS_ZEPHYR_VERSION(2, 6)
+ bool ret = true;
+
+ switch (state) {
+ case PM_STATE_RUNTIME_IDLE:
+ __fallthrough;
+ case PM_STATE_SUSPEND_TO_IDLE:
+ __fallthrough;
+ case PM_STATE_STANDBY:
+ break;
+ default:
+ ret = false;
+ break;
+ }
+
+ return ret;
+#elif IS_ZEPHYR_VERSION(2, 5)
return pm_is_sleep_state(state);
+#endif
}