xref: /openbmc/linux/arch/loongarch/power/platform.c (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
1*366bb35aSHuacai Chen // SPDX-License-Identifier: GPL-2.0
2*366bb35aSHuacai Chen /*
3*366bb35aSHuacai Chen  * Author: Huacai Chen <chenhuacai@loongson.cn>
4*366bb35aSHuacai Chen  * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
5*366bb35aSHuacai Chen  */
6*366bb35aSHuacai Chen #include <linux/acpi.h>
7*366bb35aSHuacai Chen #include <linux/platform_device.h>
8*366bb35aSHuacai Chen 
9*366bb35aSHuacai Chen #include <asm/bootinfo.h>
10*366bb35aSHuacai Chen #include <asm/loongson.h>
11*366bb35aSHuacai Chen 
enable_gpe_wakeup(void)12*366bb35aSHuacai Chen void enable_gpe_wakeup(void)
13*366bb35aSHuacai Chen {
14*366bb35aSHuacai Chen 	if (acpi_disabled)
15*366bb35aSHuacai Chen 	       return;
16*366bb35aSHuacai Chen 
17*366bb35aSHuacai Chen 	if (acpi_gbl_reduced_hardware)
18*366bb35aSHuacai Chen 	       return;
19*366bb35aSHuacai Chen 
20*366bb35aSHuacai Chen 	acpi_enable_all_wakeup_gpes();
21*366bb35aSHuacai Chen }
22*366bb35aSHuacai Chen 
enable_pci_wakeup(void)23*366bb35aSHuacai Chen void enable_pci_wakeup(void)
24*366bb35aSHuacai Chen {
25*366bb35aSHuacai Chen 	if (acpi_disabled)
26*366bb35aSHuacai Chen 	       return;
27*366bb35aSHuacai Chen 
28*366bb35aSHuacai Chen 	if (acpi_gbl_reduced_hardware)
29*366bb35aSHuacai Chen 	       return;
30*366bb35aSHuacai Chen 
31*366bb35aSHuacai Chen 	acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_STATUS, 1);
32*366bb35aSHuacai Chen 
33*366bb35aSHuacai Chen 	if (acpi_gbl_FADT.flags & ACPI_FADT_PCI_EXPRESS_WAKE)
34*366bb35aSHuacai Chen 		acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_DISABLE, 0);
35*366bb35aSHuacai Chen }
36*366bb35aSHuacai Chen 
loongson3_acpi_suspend_init(void)37*366bb35aSHuacai Chen static int __init loongson3_acpi_suspend_init(void)
38*366bb35aSHuacai Chen {
39*366bb35aSHuacai Chen #ifdef CONFIG_ACPI
40*366bb35aSHuacai Chen 	acpi_status status;
41*366bb35aSHuacai Chen 	uint64_t suspend_addr = 0;
42*366bb35aSHuacai Chen 
43*366bb35aSHuacai Chen 	if (acpi_disabled || acpi_gbl_reduced_hardware)
44*366bb35aSHuacai Chen 		return 0;
45*366bb35aSHuacai Chen 
46*366bb35aSHuacai Chen 	acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
47*366bb35aSHuacai Chen 	status = acpi_evaluate_integer(NULL, "\\SADR", NULL, &suspend_addr);
48*366bb35aSHuacai Chen 	if (ACPI_FAILURE(status) || !suspend_addr) {
49*366bb35aSHuacai Chen 		pr_err("ACPI S3 is not support!\n");
50*366bb35aSHuacai Chen 		return -1;
51*366bb35aSHuacai Chen 	}
52*366bb35aSHuacai Chen 	loongson_sysconf.suspend_addr = (u64)phys_to_virt(PHYSADDR(suspend_addr));
53*366bb35aSHuacai Chen #endif
54*366bb35aSHuacai Chen 	return 0;
55*366bb35aSHuacai Chen }
56*366bb35aSHuacai Chen 
57*366bb35aSHuacai Chen device_initcall(loongson3_acpi_suspend_init);
58