Tegra186: implement CPU_OFF handler
authorVarun Wadekar <vwadekar@nvidia.com>
Tue, 5 Jan 2016 23:17:41 +0000 (15:17 -0800)
committerVarun Wadekar <vwadekar@nvidia.com>
Mon, 20 Mar 2017 16:12:57 +0000 (09:12 -0700)
This patch implements the CPU_OFF handler for powering down
a CPU using the MCE driver.

Change-Id: I8d455005d0b547cc61cc7778bfe9eb84b7e5480c
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
plat/nvidia/tegra/soc/t186/plat_psci_handlers.c

index 42f6d89b969015568d8c0ada8e2d9eced267ce76..02119d3597c43905a28fdafbf5cda1133f50993c 100644 (file)
 
 #include <arch.h>
 #include <arch_helpers.h>
+#include <assert.h>
+#include <bl_common.h>
+#include <context.h>
+#include <context_mgmt.h>
 #include <debug.h>
 #include <mce.h>
 #include <psci.h>
@@ -88,11 +92,22 @@ int tegra_soc_prepare_cpu_on_finish(unsigned long mpidr)
 
 int tegra_soc_prepare_cpu_off(unsigned long mpidr)
 {
+       cpu_context_t *ctx = cm_get_context(NON_SECURE);
+       gp_regs_t *gp_regs = get_gpregs_ctx(ctx);
+
+       assert(ctx);
+       assert(gp_regs);
+
        /* Turn off wake_mask */
-       mce_command_handler(MCE_CMD_UPDATE_CSTATE_INFO, 0, 0, 1);
+       write_ctx_reg(gp_regs, CTX_GPREG_X4, 0);
+       write_ctx_reg(gp_regs, CTX_GPREG_X5, 0);
+       write_ctx_reg(gp_regs, CTX_GPREG_X6, 1);
+       mce_command_handler(MCE_CMD_UPDATE_CSTATE_INFO, TEGRA_ARI_CLUSTER_CC7,
+               0, TEGRA_ARI_SYSTEM_SC7);
 
        /* Turn off CPU */
-       return mce_command_handler(MCE_CMD_ENTER_CSTATE, ~0, 0, 0);
+       return mce_command_handler(MCE_CMD_ENTER_CSTATE, TEGRA_ARI_CORE_C7,
+                       ~0, 0);
 }
 
 __dead2 void tegra_soc_prepare_system_off(void)