Skip to content

Commit e523a5a

Browse files
FlyGoatchenhuacai
authored andcommitted
LoongArch: Add ACPI standard hardware register based S3 support
Most LoongArch 64 machines are using custom "SADR" ACPI extension to perform ACPI S3 sleep. However the standard ACPI way to perform sleep is to write a value to ACPI PM1/SLEEP_CTL register, and this is never supported properly in kernel. Add standard S3 sleep by providing a default DoSuspend function which calls ACPI's acpi_enter_sleep_state() routine when SADR is not provided by the firmware. Also fix suspend assembly code so that ra is set properly before go into sleep routine. (Previously linked address of jirl was set to a0, some firmware do require return address in a0 but it's already set with la.pcrel before). Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent f60d251 commit e523a5a

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

arch/loongarch/power/platform.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,34 @@ static int __init loongson_cpufreq_init(void)
4949

5050
arch_initcall(loongson_cpufreq_init);
5151

52+
static void default_suspend_addr(void)
53+
{
54+
acpi_enter_sleep_state(ACPI_STATE_S3);
55+
}
56+
5257
static int __init loongson3_acpi_suspend_init(void)
5358
{
5459
#ifdef CONFIG_ACPI
5560
acpi_status status;
5661
uint64_t suspend_addr = 0;
5762

58-
if (acpi_disabled || acpi_gbl_reduced_hardware)
63+
if (acpi_disabled)
64+
return 0;
65+
66+
if (!acpi_gbl_reduced_hardware)
67+
acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
68+
69+
if (!acpi_sleep_state_supported(ACPI_STATE_S3))
5970
return 0;
6071

61-
acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
6272
status = acpi_evaluate_integer(NULL, "\\SADR", NULL, &suspend_addr);
6373
if (ACPI_FAILURE(status) || !suspend_addr) {
64-
pr_err("ACPI S3 is not support!\n");
65-
return -1;
74+
pr_info("ACPI S3 supported with hardware register default\n");
75+
loongson_sysconf.suspend_addr = (u64)default_suspend_addr;
76+
} else {
77+
pr_info("ACPI S3 supported with Loongson ACPI SADR extension\n");
78+
loongson_sysconf.suspend_addr = (u64)phys_to_virt(PHYSADDR(suspend_addr));
6679
}
67-
loongson_sysconf.suspend_addr = (u64)phys_to_virt(PHYSADDR(suspend_addr));
6880
#endif
6981
return 0;
7082
}

arch/loongarch/power/suspend_asm.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ SYM_FUNC_START(loongarch_suspend_enter)
6666
la.pcrel a0, loongarch_wakeup_start
6767
la.pcrel t0, loongarch_suspend_addr
6868
ld.d t0, t0, 0
69-
jirl a0, t0, 0 /* Call BIOS's STR sleep routine */
69+
jirl ra, t0, 0 /* Call BIOS's STR sleep routine */
7070

7171
/*
7272
* This is where we return upon wakeup.

0 commit comments

Comments
 (0)