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 <asm/loongson.h> 11 enable_gpe_wakeup(void)12void enable_gpe_wakeup(void) 13 { 14 if (acpi_disabled) 15 return; 16 17 if (acpi_gbl_reduced_hardware) 18 return; 19 20 acpi_enable_all_wakeup_gpes(); 21 } 22 enable_pci_wakeup(void)23void enable_pci_wakeup(void) 24 { 25 if (acpi_disabled) 26 return; 27 28 if (acpi_gbl_reduced_hardware) 29 return; 30 31 acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_STATUS, 1); 32 33 if (acpi_gbl_FADT.flags & ACPI_FADT_PCI_EXPRESS_WAKE) 34 acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_DISABLE, 0); 35 } 36 37 static struct platform_device loongson3_cpufreq_device = { 38 .name = "loongson3_cpufreq", 39 .id = -1, 40 }; 41 loongson_cpufreq_init(void)42static int __init loongson_cpufreq_init(void) 43 { 44 if (!cpu_has_scalefreq) 45 return -ENODEV; 46 47 return platform_device_register(&loongson3_cpufreq_device); 48 } 49 50 arch_initcall(loongson_cpufreq_init); 51 default_suspend_addr(void)52static void default_suspend_addr(void) 53 { 54 acpi_enter_sleep_state(ACPI_STATE_S3); 55 } 56 loongson3_acpi_suspend_init(void)57static int __init loongson3_acpi_suspend_init(void) 58 { 59 #ifdef CONFIG_ACPI 60 acpi_status status; 61 uint64_t suspend_addr = 0; 62 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)) 70 return 0; 71 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)); 79 } 80 #endif 81 return 0; 82 } 83 84 device_initcall(loongson3_acpi_suspend_init); 85