1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Sleep helper for Loongson-3 sleep mode.
5 * Author: Huacai Chen <chenhuacai@loongson.cn>
6 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
10 #include <asm/asmmacro.h>
11 #include <asm/addrspace.h>
12 #include <asm/loongarch.h>
13 #include <asm/stackframe.h>
15 /* preparatory stuff */
17 addi.d sp, sp, -PT_SIZE
34 la.pcrel t0, acpi_saved_sp
59 /* Sleep/wakeup code for Loongson-3 */
60 SYM_FUNC_START(loongarch_suspend_enter)
64 /* Pass RA and SP to BIOS */
66 la.pcrel a0, loongarch_wakeup_start
67 la.pcrel t0, loongarch_suspend_addr
69 jirl a0, t0, 0 /* Call BIOS's STR sleep routine */
72 * This is where we return upon wakeup.
73 * Reload all of the registers and return.
75 SYM_INNER_LABEL(loongarch_wakeup_start, SYM_L_GLOBAL)
76 li.d t0, CSR_DMW0_INIT # UC, PLV0
77 csrwr t0, LOONGARCH_CSR_DMWIN0
78 li.d t0, CSR_DMW1_INIT # CA, PLV0
79 csrwr t0, LOONGARCH_CSR_DMWIN1
84 li.w t0, 0xb0 # PLV=0, IE=0, PG=1
85 csrwr t0, LOONGARCH_CSR_CRMD
87 la.pcrel t0, acpi_saved_sp
90 addi.d sp, sp, PT_SIZE
92 SYM_FUNC_END(loongarch_suspend_enter)