162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Hibernation support specific for LoongArch
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Author: Huacai Chen <chenhuacai@loongson.cn>
662306a36Sopenharmony_ci * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci#include <linux/linkage.h>
962306a36Sopenharmony_ci#include <asm/asm.h>
1062306a36Sopenharmony_ci#include <asm/asm-offsets.h>
1162306a36Sopenharmony_ci#include <asm/regdef.h>
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci.text
1462306a36Sopenharmony_ciSYM_FUNC_START(swsusp_asm_suspend)
1562306a36Sopenharmony_ci	la.pcrel	t0, saved_regs
1662306a36Sopenharmony_ci	PTR_S		ra, t0, PT_R1
1762306a36Sopenharmony_ci	PTR_S		tp, t0, PT_R2
1862306a36Sopenharmony_ci	PTR_S		sp, t0, PT_R3
1962306a36Sopenharmony_ci	PTR_S		u0, t0, PT_R21
2062306a36Sopenharmony_ci	PTR_S		fp, t0, PT_R22
2162306a36Sopenharmony_ci	PTR_S		s0, t0, PT_R23
2262306a36Sopenharmony_ci	PTR_S		s1, t0, PT_R24
2362306a36Sopenharmony_ci	PTR_S		s2, t0, PT_R25
2462306a36Sopenharmony_ci	PTR_S		s3, t0, PT_R26
2562306a36Sopenharmony_ci	PTR_S		s4, t0, PT_R27
2662306a36Sopenharmony_ci	PTR_S		s5, t0, PT_R28
2762306a36Sopenharmony_ci	PTR_S		s6, t0, PT_R29
2862306a36Sopenharmony_ci	PTR_S		s7, t0, PT_R30
2962306a36Sopenharmony_ci	PTR_S		s8, t0, PT_R31
3062306a36Sopenharmony_ci	b		swsusp_save
3162306a36Sopenharmony_ciSYM_FUNC_END(swsusp_asm_suspend)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciSYM_FUNC_START(swsusp_asm_resume)
3462306a36Sopenharmony_ci	la.pcrel	t0, restore_pblist
3562306a36Sopenharmony_ci	PTR_L		t0, t0, 0
3662306a36Sopenharmony_ci0:
3762306a36Sopenharmony_ci	PTR_L		t1, t0, PBE_ADDRESS  /* source */
3862306a36Sopenharmony_ci	PTR_L		t2, t0, PBE_ORIG_ADDRESS /* destination */
3962306a36Sopenharmony_ci	PTR_LI		t3, _PAGE_SIZE
4062306a36Sopenharmony_ci	PTR_ADD		t3, t3, t1
4162306a36Sopenharmony_ci1:
4262306a36Sopenharmony_ci	REG_L		t8, t1, 0
4362306a36Sopenharmony_ci	REG_S		t8, t2, 0
4462306a36Sopenharmony_ci	PTR_ADDI	t1, t1, SZREG
4562306a36Sopenharmony_ci	PTR_ADDI	t2, t2, SZREG
4662306a36Sopenharmony_ci	bne		t1, t3, 1b
4762306a36Sopenharmony_ci	PTR_L		t0, t0, PBE_NEXT
4862306a36Sopenharmony_ci	bnez		t0, 0b
4962306a36Sopenharmony_ci	la.pcrel	t0, saved_regs
5062306a36Sopenharmony_ci	PTR_L		ra, t0, PT_R1
5162306a36Sopenharmony_ci	PTR_L		tp, t0, PT_R2
5262306a36Sopenharmony_ci	PTR_L		sp, t0, PT_R3
5362306a36Sopenharmony_ci	PTR_L		u0, t0, PT_R21
5462306a36Sopenharmony_ci	PTR_L		fp, t0, PT_R22
5562306a36Sopenharmony_ci	PTR_L		s0, t0, PT_R23
5662306a36Sopenharmony_ci	PTR_L		s1, t0, PT_R24
5762306a36Sopenharmony_ci	PTR_L		s2, t0, PT_R25
5862306a36Sopenharmony_ci	PTR_L		s3, t0, PT_R26
5962306a36Sopenharmony_ci	PTR_L		s4, t0, PT_R27
6062306a36Sopenharmony_ci	PTR_L		s5, t0, PT_R28
6162306a36Sopenharmony_ci	PTR_L		s6, t0, PT_R29
6262306a36Sopenharmony_ci	PTR_L		s7, t0, PT_R30
6362306a36Sopenharmony_ci	PTR_L		s8, t0, PT_R31
6462306a36Sopenharmony_ci	PTR_LI		a0, 0x0
6562306a36Sopenharmony_ci	jirl		zero, ra, 0
6662306a36Sopenharmony_ciSYM_FUNC_END(swsusp_asm_resume)
67