1 // SPDX-License-Identifier: GPL-2.0
3 * Author: Huacai Chen <chenhuacai@loongson.cn>
4 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6 #include <linux/acpi.h>
7 #include <linux/platform_device.h>
9 #include <asm/bootinfo.h>
10 #include <asm/loongson.h>
12 void enable_gpe_wakeup(void)
17 if (acpi_gbl_reduced_hardware
)
20 acpi_enable_all_wakeup_gpes();
23 void enable_pci_wakeup(void)
28 if (acpi_gbl_reduced_hardware
)
31 acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_STATUS
, 1);
33 if (acpi_gbl_FADT
.flags
& ACPI_FADT_PCI_EXPRESS_WAKE
)
34 acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_DISABLE
, 0);
37 static struct platform_device loongson3_cpufreq_device
= {
38 .name
= "loongson3_cpufreq",
42 static int __init
loongson_cpufreq_init(void)
44 if (!cpu_has_scalefreq
)
47 return platform_device_register(&loongson3_cpufreq_device
);
50 arch_initcall(loongson_cpufreq_init
);
52 static void default_suspend_addr(void)
54 acpi_enter_sleep_state(ACPI_STATE_S3
);
57 static int __init
loongson3_acpi_suspend_init(void)
61 uint64_t suspend_addr
= 0;
66 if (!acpi_gbl_reduced_hardware
)
67 acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE
, 1);
69 if (!acpi_sleep_state_supported(ACPI_STATE_S3
))
72 status
= acpi_evaluate_integer(NULL
, "\\SADR", NULL
, &suspend_addr
);
73 if (ACPI_FAILURE(status
) || !suspend_addr
) {
74 pr_info("ACPI S3 supported with hardware register default\n");
75 loongson_sysconf
.suspend_addr
= (u64
)default_suspend_addr
;
77 pr_info("ACPI S3 supported with Loongson ACPI SADR extension\n");
78 loongson_sysconf
.suspend_addr
= (u64
)phys_to_virt(PHYSADDR(suspend_addr
));
84 device_initcall(loongson3_acpi_suspend_init
);