feat(ti): implement DM_MANAGED suspend
DM_MANAGED is the new mode to support a model where DM chooses the
suspend mode. Previously suspend always chose deep sleep. Now DM may
also choose other modes like IO+DDR or other modes in the future. DM has
more knowledge about constraints regarding wakeup latency or which parts
of the system need to work continuously, so it is better able to decide
what suspend mode should be used.
To support DM_MANAGED in TF-A the next system mode needs to be fetched
and passed to the enter sleep message. The new ti_sci command to fetch
the next system mode is added which is ti_sci_lpm_get_next_sys_mode().
DM_MANAGED is only enabled if the firmware capability is supported.
Change-Id: I7244e27793cc60e1673271990d7cd840294d6cc3
Signed-off-by: Markus Schneider-Pargmann <msp@baylibre.com>
diff --git a/plat/ti/k3/common/k3_psci.c b/plat/ti/k3/common/k3_psci.c
index e8d73db..df49f48 100644
--- a/plat/ti/k3/common/k3_psci.c
+++ b/plat/ti/k3/common/k3_psci.c
@@ -234,7 +234,7 @@
return PSCI_E_SUCCESS;
}
-static void k3_pwr_domain_suspend(const psci_power_state_t *target_state)
+static void k3_pwr_domain_suspend_to_mode(const psci_power_state_t *target_state, uint8_t mode)
{
unsigned int core, proc_id;
@@ -247,7 +247,25 @@
k3_pwr_domain_off(target_state);
- ti_sci_enter_sleep(proc_id, 0, k3_sec_entrypoint);
+ ti_sci_enter_sleep(proc_id, mode, k3_sec_entrypoint);
+}
+
+static void k3_pwr_domain_suspend_dm_managed(const psci_power_state_t *target_state)
+{
+ uint8_t mode = MSG_VALUE_SLEEP_MODE_DEEP_SLEEP;
+ int ret;
+
+ ret = ti_sci_lpm_get_next_sys_mode(&mode);
+ if (ret != 0) {
+ ERROR("Failed to fetch next system mode\n");
+ }
+
+ k3_pwr_domain_suspend_to_mode(target_state, mode);
+}
+
+static void k3_pwr_domain_suspend(const psci_power_state_t *target_state)
+{
+ k3_pwr_domain_suspend_to_mode(target_state, MSG_VALUE_SLEEP_MODE_DEEP_SLEEP);
}
static void k3_pwr_domain_suspend_finish(const psci_power_state_t *target_state)
@@ -301,6 +319,8 @@
k3_plat_psci_ops.pwr_domain_suspend = NULL;
k3_plat_psci_ops.pwr_domain_suspend_finish = NULL;
k3_plat_psci_ops.get_sys_suspend_power_state = NULL;
+ } else if (fw_caps & MSG_FLAG_CAPS_LPM_DM_MANAGED) {
+ k3_plat_psci_ops.pwr_domain_suspend = k3_pwr_domain_suspend_dm_managed;
}
*psci_ops = &k3_plat_psci_ops;