2 * Copyright 2014 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
9 #if !defined(CONFIG_ARMV7_NONSEC) || !defined(CONFIG_ARMV7_VIRT)
10 #error " Deep sleep needs non-secure mode support. "
12 #include <asm/secure.h>
14 #include <asm/armv7.h>
15 #include <asm/cache.h>
17 #if defined(CONFIG_LS102XA)
18 #include <asm/arch/immap_ls102xa.h>
23 DECLARE_GLOBAL_DATA_PTR;
25 void __weak board_mem_sleep_setup(void)
29 void __weak board_sleep_prepare(void)
33 bool is_warm_boot(void)
35 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
37 if (in_be32(&gur->crstsr) & DCFG_CCSR_CRSTSR_WDRFR)
43 void fsl_dp_disable_console(void)
45 gd->flags |= GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE;
49 * When wakeup from deep sleep, the first 128 bytes space
50 * will be used to do DDR training which corrupts the data
51 * in there. This function will restore them.
53 static void dp_ddr_restore(void)
57 struct ccsr_scfg __iomem *scfg = (void *)CONFIG_SYS_FSL_SCFG_ADDR;
59 /* get the address of ddr date from SPARECR3 */
60 src = (u64 *)in_le32(&scfg->sparecr[2]);
61 dst = (u64 *)CONFIG_SYS_SDRAM_BASE;
63 for (i = 0; i < DDR_BUFF_LEN / 8; i++)
69 static void dp_resume_prepare(void)
72 board_sleep_prepare();
74 cleanup_before_linux();
77 int fsl_dp_resume(void)
80 void (*kernel_resume)(void);
81 struct ccsr_scfg __iomem *scfg = (void *)CONFIG_SYS_FSL_SCFG_ADDR;
88 /* Get the entry address and jump to kernel */
89 start_addr = in_le32(&scfg->sparecr[1]);
90 debug("Entry address is 0x%08x\n", start_addr);
91 kernel_resume = (void (*)(void))start_addr;
92 secure_ram_addr(_do_nonsec_entry)(kernel_resume, 0, 0, 0);