zephyr: Update power policy to support v2.6
Update power_policy.c to support API changes in v2.6.
BRANCH=none
TEST=build brya with both 2.5 and 2.6
*/
#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
}
