1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor, Inc.
8 #ifndef CONFIG_ARMV7_NONSEC
9 #error " Deep sleep needs non-secure mode support. "
11 #include <asm/secure.h>
13 #include <asm/armv7.h>
15 #if defined(CONFIG_ARCH_LS1021A)
16 #include <asm/arch/immap_ls102xa.h>
24 DECLARE_GLOBAL_DATA_PTR;
26 void __weak board_mem_sleep_setup(void)
30 void __weak board_sleep_prepare(void)
34 bool is_warm_boot(void)
36 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
38 if (in_be32(&gur->crstsr) & DCFG_CCSR_CRSTSR_WDRFR)
44 void fsl_dp_disable_console(void)
46 gd->flags |= GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE;
50 * When wakeup from deep sleep, the first 128 bytes space
51 * will be used to do DDR training which corrupts the data
52 * in there. This function will restore them.
54 static void dp_ddr_restore(void)
58 struct ccsr_scfg __iomem *scfg = (void *)CONFIG_SYS_FSL_SCFG_ADDR;
60 /* get the address of ddr date from SPARECR3 */
61 src = (u64 *)in_le32(&scfg->sparecr[2]);
62 dst = (u64 *)CONFIG_SYS_SDRAM_BASE;
64 for (i = 0; i < DDR_BUFF_LEN / 8; i++)
68 #if defined(CONFIG_ARMV7_PSCI) && defined(CONFIG_ARCH_LS1021A)
69 void ls1_psci_resume_fixup(void)
72 struct ccsr_scfg __iomem *scfg = (void *)CONFIG_SYS_FSL_SCFG_ADDR;
75 void *qixis_base = (void *)QIXIS_BASE;
77 /* Pull on PCIe RST# */
78 out_8(qixis_base + QIXIS_RST_FORCE_3, 0);
80 /* disable deep sleep signals in FPGA */
81 tmp = in_8(qixis_base + QIXIS_PWR_CTL2);
82 tmp &= ~QIXIS_PWR_CTL2_PCTL;
83 out_8(qixis_base + QIXIS_PWR_CTL2, tmp);
86 /* Disable wakeup interrupt during deep sleep */
87 out_be32(&scfg->pmcintecr, 0);
88 /* Clear PMC interrupt status */
89 out_be32(&scfg->pmcintsr, 0xffffffff);
91 /* Disable Warm Device Reset */
92 tmp = in_be32(&scfg->dpslpcr);
93 tmp &= ~SCFG_DPSLPCR_WDRR_EN;
94 out_be32(&scfg->dpslpcr, tmp);
98 static void dp_resume_prepare(void)
101 board_sleep_prepare();
106 #if defined(CONFIG_ARMV7_PSCI) && defined(CONFIG_ARCH_LS1021A)
107 ls1_psci_resume_fixup();
111 int fsl_dp_resume(void)
114 void (*kernel_resume)(void);
115 struct ccsr_scfg __iomem *scfg = (void *)CONFIG_SYS_FSL_SCFG_ADDR;
122 /* Get the entry address and jump to kernel */
123 start_addr = in_le32(&scfg->sparecr[3]);
124 debug("Entry address is 0x%08x\n", start_addr);
125 kernel_resume = (void (*)(void))start_addr;
126 secure_ram_addr(_do_nonsec_entry)(kernel_resume, 0, 0, 0);