1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2008-2017 Andes Technology Corporation
4 #include <linux/init.h>
5 #include <linux/suspend.h>
6 #include <linux/device.h>
7 #include <linux/printk.h>
8 #include <asm/suspend.h>
9 #include <nds32_intrinsic.h>
11 unsigned int resume_addr;
12 unsigned int *phy_addr_sp_tmp;
14 static void nds32_suspend2ram(void)
21 pgdv = (pgd_t *)__va((__nds32__mfsr(NDS32_SR_L1_PPTB) &
22 L1_PPTB_mskBASE)) + pgd_index((unsigned int)cpu_resume);
24 pudv = pud_offset(pgdv, (unsigned int)cpu_resume);
25 pmdv = pmd_offset(pudv, (unsigned int)cpu_resume);
26 ptev = pte_offset_map(pmdv, (unsigned int)cpu_resume);
28 resume_addr = ((*ptev) & TLB_DATA_mskPPN)
29 | ((unsigned int)cpu_resume & 0x00000fff);
34 static void nds32_suspend_cpu(void)
36 while (!(__nds32__mfsr(NDS32_SR_INT_PEND) & wake_mask))
37 __asm__ volatile ("standby no_wake_grant\n\t");
40 static int nds32_pm_valid(suspend_state_t state)
44 case PM_SUSPEND_STANDBY:
52 static int nds32_pm_enter(suspend_state_t state)
54 pr_debug("%s:state:%d\n", __func__, state);
56 case PM_SUSPEND_STANDBY:
67 static const struct platform_suspend_ops nds32_pm_ops = {
68 .valid = nds32_pm_valid,
69 .enter = nds32_pm_enter,
72 static int __init nds32_pm_init(void)
74 pr_debug("Enter %s\n", __func__);
75 suspend_set_ops(&nds32_pm_ops);
78 late_initcall(nds32_pm_init);