ARM: tegra: Add firmware calls required for suspend-resume
authorDmitry Osipenko <digetx@gmail.com>
Thu, 23 Aug 2018 19:35:30 +0000 (22:35 +0300)
committerDmitry Osipenko <digetx@gmail.com>
Sat, 9 Feb 2019 19:15:34 +0000 (22:15 +0300)
In order to resume CPU from suspend via trusted Foundations firmware,
the LP1/LP2 boot vectors shall be specified using the firmware calls.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
arch/arm/mach-tegra/pm.c
arch/arm/mach-tegra/reset-handler.S

index 66c8cd6..12341ff 100644 (file)
@@ -33,6 +33,7 @@
 #include <soc/tegra/pmc.h>
 
 #include <asm/cacheflush.h>
+#include <asm/firmware.h>
 #include <asm/idmap.h>
 #include <asm/proc-fns.h>
 #include <asm/smp_plat.h>
@@ -150,6 +151,10 @@ bool tegra_set_cpu_in_lp2(void)
                tegra20_cpu_set_resettable_soon();
 
        spin_unlock(&tegra_lp2_lock);
+
+       if (last_cpu)
+               call_firmware_op(prepare_idle, TF_PM_MODE_LP2);
+
        return last_cpu;
 }
 
@@ -316,6 +321,8 @@ static void tegra_suspend_enter_lp1(void)
                tegra_lp1_iram.start_addr, iram_save_size);
 
        *((u32 *)tegra_cpu_lp1_mask) = 1;
+
+       call_firmware_op(prepare_idle, TF_PM_MODE_LP1);
 }
 
 static void tegra_suspend_exit_lp1(void)
index 33ab6af..24fb375 100644 (file)
@@ -77,6 +77,7 @@ ENTRY(tegra_resume)
        orr     r1, r1, #1
        str     r1, [r0]
 #endif
+       bl      tegra_resume_trusted_foundations
 
 #ifdef CONFIG_CACHE_L2X0
        /* L2 cache resume & re-enable */
@@ -89,6 +90,30 @@ end_ca9_scu_l2_resume:
 
        b       cpu_resume
 ENDPROC(tegra_resume)
+
+/*
+ *     tegra_resume_trusted_foundations
+ *
+ *       Trusted Foundations firmware initialization.
+ *
+ *     Doesn't return if firmware presents.
+ *     Corrupted registers: r1, r2
+ */
+ENTRY(tegra_resume_trusted_foundations)
+       /* Check whether Trusted Foundations firmware presents. */
+       mov32   r2, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET
+       ldr     r1, =__tegra_cpu_reset_handler_data_offset + \
+                                                       RESET_DATA(TF_PRESENT)
+       ldr     r1, [r2, r1]
+       cmp     r1, #0
+       reteq   lr
+
+ .arch_extension sec
+       /* First call after suspend wakes firmware. No arguments required. */
+       smc     #0
+
+       b       cpu_resume
+ENDPROC(tegra_resume_trusted_foundations)
 #endif
 
        .align L1_CACHE_SHIFT