Add support for resuming from suspend in board_init_f for J722S.
The resume state of the SOC is identified and lpm resume
sequence is followed accordingly:

First, set LPM core bus path and compatible needed by extract_lpm_region
to find lpm-metadata memory region (at boot and at resume time)

Then:
   - Extract context address from devicetree
   - Power on the rproc cluster power domain.
   - Ask TIFS to authenticate the certificates attached to saved images
     of ATF, OPTEE and DM and apply the firewalls in it.
   - Send the context address to TIFS.
   - Ask TIFS to firewall the context address area.
   - Ask TIFS to decrypt and restore TFA.
   - Ask TIFS to resume TFA.
   - Power on the rproc power domain.
   - Jump to DM firmware.
(All those steps are done in do_resume())

Moreover, ctrl_mmr_unlock() needs to be called again after the TIFS
version message, otherwise the pmic calls in j7xx_board_is_resuming()
are failling.
Just moving ctrl_mmr_unlock() is not enough, since in this case, TFA
fails to start on J722S HS-FS device.

Signed-off-by: Richard Genoud (TI) <[email protected]>
---
 arch/arm/mach-k3/j722s/j722s_init.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/mach-k3/j722s/j722s_init.c 
b/arch/arm/mach-k3/j722s/j722s_init.c
index 1180c75f551d..99517fe0a29c 100644
--- a/arch/arm/mach-k3/j722s/j722s_init.c
+++ b/arch/arm/mach-k3/j722s/j722s_init.c
@@ -14,6 +14,7 @@
 
 #include "../sysfw-loader.h"
 #include "../common.h"
+#include "../lpm-common.h"
 
 struct fwl_data cbass_main_fwls[] = {
        { "FSS_DAT_REG3", 7, 8 },
@@ -151,6 +152,8 @@ static void k3_spl_init(void)
        /* Output System Firmware version info */
        k3_sysfw_print_ver();
 
+       ctrl_mmr_unlock();
+
        /* Output DM Firmware version info */
        if (IS_ENABLED(CONFIG_ARM64))
                k3_dm_print_ver();
@@ -165,6 +168,8 @@ static void k3_mem_init(void)
                ret = uclass_get_device(UCLASS_RAM, 0, &dev);
                if (ret)
                        panic("DRAM init failed: %d\n", ret);
+               k3_set_lpm_core_bus_node_path("/bus@f0000/bus@b00000");
+               k3_set_lpm_core_compatible("ti,am62-r5f");
        }
 
        spl_enable_cache();
@@ -186,6 +191,9 @@ void board_init_f(ulong dummy)
 
        k3_spl_init();
        k3_mem_init();
+       if (j7xx_board_is_resuming())
+               do_resume(); /* no return */
+
        setup_qos();
 
        if (IS_ENABLED(CONFIG_ESM_K3)) {
-- 
2.55.0

Reply via email to