2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-11-21 03:17:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Freescale Semiconductor, Inc.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2014-11-21 03:17:15 +00:00
|
|
|
#include <asm/immap_85xx.h>
|
|
|
|
#include "sleep.h"
|
2015-03-25 09:02:59 +00:00
|
|
|
#ifdef CONFIG_U_QE
|
2016-02-18 05:01:59 +00:00
|
|
|
#include <fsl_qe.h>
|
2015-03-25 09:02:59 +00:00
|
|
|
#endif
|
2014-11-21 03:17:15 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
void __weak board_mem_sleep_setup(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void __weak board_sleep_prepare(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_warm_boot(void)
|
|
|
|
{
|
2022-10-29 00:27:12 +00:00
|
|
|
struct ccsr_gur __iomem *gur = (void *)CFG_SYS_MPC85xx_GUTS_ADDR;
|
2014-11-21 03:17:15 +00:00
|
|
|
|
|
|
|
if (in_be32(&gur->scrtsr[0]) & DCFG_CCSR_CRSTSR_WDRFR)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void fsl_dp_disable_console(void)
|
|
|
|
{
|
|
|
|
gd->flags |= GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When wakeup from deep sleep, the first 128 bytes space
|
|
|
|
* will be used to do DDR training which corrupts the data
|
|
|
|
* in there. This function will restore them.
|
|
|
|
*/
|
|
|
|
static void dp_ddr_restore(void)
|
|
|
|
{
|
2015-04-20 03:16:56 +00:00
|
|
|
u64 *src, *dst;
|
2014-11-21 03:17:15 +00:00
|
|
|
int i;
|
2022-10-29 00:27:12 +00:00
|
|
|
struct ccsr_scfg __iomem *scfg = (void *)CFG_SYS_MPC85xx_SCFG;
|
2014-11-21 03:17:15 +00:00
|
|
|
|
|
|
|
/* get the address of ddr date from SPARECR3 */
|
2015-04-20 03:16:56 +00:00
|
|
|
src = (u64 *)(in_be32(&scfg->sparecr[2]) + DDR_BUFF_LEN - 8);
|
|
|
|
dst = (u64 *)(CONFIG_SYS_SDRAM_BASE + DDR_BUFF_LEN - 8);
|
2014-11-21 03:17:15 +00:00
|
|
|
|
|
|
|
for (i = 0; i < DDR_BUFF_LEN / 8; i++)
|
2015-04-20 03:16:56 +00:00
|
|
|
*dst-- = *src--;
|
2014-11-21 03:17:15 +00:00
|
|
|
|
|
|
|
flush_dcache();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dp_resume_prepare(void)
|
|
|
|
{
|
|
|
|
dp_ddr_restore();
|
|
|
|
|
|
|
|
board_sleep_prepare();
|
|
|
|
|
|
|
|
l2cache_init();
|
|
|
|
#if defined(CONFIG_RAMBOOT_PBL)
|
|
|
|
disable_cpc_sram();
|
|
|
|
#endif
|
|
|
|
enable_cpc();
|
2015-03-25 09:02:59 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_U_QE
|
|
|
|
u_qe_resume();
|
|
|
|
#endif
|
|
|
|
|
2014-11-21 03:17:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int fsl_dp_resume(void)
|
|
|
|
{
|
|
|
|
u32 start_addr;
|
|
|
|
void (*kernel_resume)(void);
|
2022-10-29 00:27:12 +00:00
|
|
|
struct ccsr_scfg __iomem *scfg = (void *)CFG_SYS_MPC85xx_SCFG;
|
2014-11-21 03:17:15 +00:00
|
|
|
|
|
|
|
if (!is_warm_boot())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
dp_resume_prepare();
|
|
|
|
|
|
|
|
/* Get the entry address and jump to kernel */
|
|
|
|
start_addr = in_be32(&scfg->sparecr[1]);
|
|
|
|
debug("Entry address is 0x%08x\n", start_addr);
|
|
|
|
kernel_resume = (void (*)(void))start_addr;
|
|
|
|
kernel_resume();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|