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