drivers: remoteproc: PIL: Add support for hibernation callbacks

the PIL information is modified after hibernation exit.
This change is used to restore the PIL information.

Change-Id: I8973916aca64733fca1c5c18b0bbaa7990418999
Signed-off-by: Canfeng Zhuang <quic_czhuang@quicinc.com>
This commit is contained in:
Canfeng Zhuang 2023-08-29 17:33:40 +08:00 committed by Darshankumar Jagdishchandra Thakkar
parent c1fe2dbeef
commit db7f830c1c

View File

@ -8,6 +8,7 @@
#include <linux/mutex.h>
#include <linux/of_address.h>
#include "qcom_pil_info.h"
#include <linux/syscore_ops.h>
/*
* The PIL relocation information region is used to communicate memory regions
@ -29,6 +30,10 @@ static struct pil_reloc _reloc __read_mostly;
static DEFINE_MUTEX(pil_reloc_lock);
static bool timeouts_disabled;
#ifdef CONFIG_HIBERNATION
static bool hibernation;
#endif
/**
* qcom_pil_timeouts_disabled() - Check if pil timeouts are disabled in imem
*
@ -75,6 +80,23 @@ bool qcom_pil_timeouts_disabled(void)
}
EXPORT_SYMBOL(qcom_pil_timeouts_disabled);
#ifdef CONFIG_HIBERNATION
static void pil_reloc_restore_syscore_resume(void)
{
if (_reloc.base) {
mutex_lock(&pil_reloc_lock);
iounmap(_reloc.base);
_reloc.base = NULL;
mutex_unlock(&pil_reloc_lock);
} else
pr_info("The PIL relocation information region is not mapped\n");
}
static struct syscore_ops pil_reloc_restore_syscore_ops = {
.resume = pil_reloc_restore_syscore_resume,
};
#endif
static int qcom_pil_info_init(void)
{
struct device_node *np;
@ -82,6 +104,13 @@ static int qcom_pil_info_init(void)
void __iomem *base;
int ret;
#ifdef CONFIG_HIBERNATION
if (!hibernation) {
register_syscore_ops(&pil_reloc_restore_syscore_ops);
hibernation = true;
}
#endif
/* Already initialized? */
if (_reloc.base)
return 0;