Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / arch / loongarch / power / platform.c
blob0909729dc2e153905bff5bd1976feb2558cb439e
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>
9 #include <asm/bootinfo.h>
10 #include <asm/loongson.h>
12 void enable_gpe_wakeup(void)
14 if (acpi_disabled)
15 return;
17 if (acpi_gbl_reduced_hardware)
18 return;
20 acpi_enable_all_wakeup_gpes();
23 void enable_pci_wakeup(void)
25 if (acpi_disabled)
26 return;
28 if (acpi_gbl_reduced_hardware)
29 return;
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",
39 .id = -1,
42 static int __init loongson_cpufreq_init(void)
44 if (!cpu_has_scalefreq)
45 return -ENODEV;
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)
59 #ifdef CONFIG_ACPI
60 acpi_status status;
61 uint64_t suspend_addr = 0;
63 if (acpi_disabled)
64 return 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))
70 return 0;
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;
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));
80 #endif
81 return 0;
84 device_initcall(loongson3_acpi_suspend_init);