From b40a467783e5911f97d6e92ebdeb34ca2f005552 Mon Sep 17 00:00:00 2001 From: Dave Gerlach Date: Fri, 7 Jan 2022 08:12:39 -0600 Subject: [PATCH] feat(ti): add gic save and restore calls Add functions to save and restore GICv3 redist and dist contexts during low power mode and then call these during the suspend entry and finish psci handlers. Change-Id: I26c2c0f3b7fc925de3b349499fa42d2405441577 Signed-off-by: Dave Gerlach --- plat/ti/k3/common/k3_gicv3.c | 23 +++++++++++++++++++++++ plat/ti/k3/include/k3_gicv3.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/plat/ti/k3/common/k3_gicv3.c b/plat/ti/k3/common/k3_gicv3.c index 1932eaae5..019982261 100644 --- a/plat/ti/k3/common/k3_gicv3.c +++ b/plat/ti/k3/common/k3_gicv3.c @@ -19,6 +19,11 @@ /* The GICv3 driver only needs to be initialized in EL3 */ uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT]; +#if K3_PM_SYSTEM_SUSPEND +static gicv3_redist_ctx_t rdist_ctx[PLATFORM_CORE_COUNT]; +static gicv3_dist_ctx_t dist_ctx; +#endif + static const interrupt_prop_t k3_interrupt_props[] = { PLAT_ARM_G1S_IRQ_PROPS(INTR_GROUP1S), PLAT_ARM_G0_IRQ_PROPS(INTR_GROUP0) @@ -88,3 +93,21 @@ void k3_gic_pcpu_init(void) { gicv3_rdistif_init(plat_my_core_pos()); } + +#if K3_PM_SYSTEM_SUSPEND +void k3_gic_save_context(void) +{ + for (unsigned int i = 0U; i < PLATFORM_CORE_COUNT; i++) { + gicv3_rdistif_save(i, &rdist_ctx[i]); + } + gicv3_distif_save(&dist_ctx); +} + +void k3_gic_restore_context(void) +{ + gicv3_distif_init_restore(&dist_ctx); + for (unsigned int i = 0U; i < PLATFORM_CORE_COUNT; i++) { + gicv3_rdistif_init_restore(i, &rdist_ctx[i]); + } +} +#endif diff --git a/plat/ti/k3/include/k3_gicv3.h b/plat/ti/k3/include/k3_gicv3.h index 2329a16e5..2c68a7518 100644 --- a/plat/ti/k3/include/k3_gicv3.h +++ b/plat/ti/k3/include/k3_gicv3.h @@ -14,5 +14,7 @@ void k3_gic_init(void); void k3_gic_cpuif_enable(void); void k3_gic_cpuif_disable(void); void k3_gic_pcpu_init(void); +void k3_gic_save_context(void); +void k3_gic_restore_context(void); #endif /* K3_GICV3_H */