intel: adsp: Simplify PM
Both idle and suspend states were just being used to set the cpu
idle. That is not necessary, if the pm policy does not find a suitable
power state the kernel automatically calls k_cpu_idle().
This remove unnecessary code and the weirdness of having
min-residency-us set to 0 and other arbitrary values.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
diff --git a/dts/xtensa/intel/intel_adsp_ace15_mtpm.dtsi b/dts/xtensa/intel/intel_adsp_ace15_mtpm.dtsi
index 82513d1..5c6d946 100644
--- a/dts/xtensa/intel/intel_adsp_ace15_mtpm.dtsi
+++ b/dts/xtensa/intel/intel_adsp_ace15_mtpm.dtsi
@@ -16,38 +16,25 @@
device_type = "cpu";
compatible = "cdns,tensilica-xtensa-lx7";
reg = <0>;
- cpu-power-states = <&idle &suspend &off>;
+ cpu-power-states = <&off>;
};
cpu1: cpu@1 {
device_type = "cpu";
compatible = "cdns,tensilica-xtensa-lx7";
reg = <1>;
- cpu-power-states = <&idle &suspend &off>;
+ cpu-power-states = <&off>;
};
cpu2: cpu@2 {
device_type = "cpu";
compatible = "cdns,tensilica-xtensa-lx7";
reg = <2>;
- cpu-power-states = <&idle &suspend &off>;
+ cpu-power-states = <&off>;
};
};
power-states {
- idle: idle {
- compatible = "zephyr,power-state";
- power-state-name = "runtime-idle";
- min-residency-us = <0>;
- exit-latency-us = <0>;
- };
- suspend: suspend {
- compatible = "zephyr,power-state";
- power-state-name = "suspend-to-idle";
- min-residency-us = <200>;
- exit-latency-us = <100>;
- };
-
/* PM_STATE_SOFT_OFF can be entered only by calling pm_state_force.
* The procedure is triggered by IPC from the HOST (SET_DX).
*/
diff --git a/soc/xtensa/intel_adsp/ace_v1x/power.c b/soc/xtensa/intel_adsp/ace_v1x/power.c
index 3eaa362..d8368d0 100644
--- a/soc/xtensa/intel_adsp/ace_v1x/power.c
+++ b/soc/xtensa/intel_adsp/ace_v1x/power.c
@@ -33,10 +33,10 @@
__weak void pm_state_set(enum pm_state state, uint8_t substate_id)
{
ARG_UNUSED(substate_id);
- uint32_t cpu = arch_proc_id();
- switch (state) {
- case PM_STATE_SOFT_OFF:/* D3 */
+ if (state == PM_STATE_SOFT_OFF) {
+ uint32_t cpu = arch_proc_id();
+
DFDSPBRCP.bootctl[cpu].bctl &= ~DFDSPBRCP_BCTL_WAITIPCG;
soc_cpus_active[cpu] = false;
z_xtensa_cache_flush_inv_all();
@@ -49,16 +49,8 @@
} else {
k_cpu_idle();
}
-
- break;
- case PM_STATE_SUSPEND_TO_IDLE: /* D0ix */
- __fallthrough;
- case PM_STATE_RUNTIME_IDLE:/* D0 */
- k_cpu_idle();
- break;
- default:
+ } else {
__ASSERT(false, "invalid argument - unsupported power state");
- break;
}
}
@@ -66,21 +58,15 @@
__weak void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
{
ARG_UNUSED(substate_id);
- uint32_t cpu = arch_proc_id();
- switch (state) {
- case PM_STATE_SOFT_OFF:/* D3 */
+ if (state == PM_STATE_SOFT_OFF) {
+ uint32_t cpu = arch_proc_id();
+
/* TODO: move clock gating prevent to imr restore vector when it will be ready. */
DFDSPBRCP.bootctl[cpu].bctl |= DFDSPBRCP_BCTL_WAITIPCG;
soc_cpus_active[cpu] = true;
z_xtensa_cache_flush_inv_all();
- __fallthrough;
- case PM_STATE_SUSPEND_TO_IDLE: /* D0ix */
- __fallthrough;
- case PM_STATE_RUNTIME_IDLE:/* D0 */
- break;
- default:
+ } else {
__ASSERT(false, "invalid argument - unsupported power state");
- break;
}
}