1366bb35aSHuacai Chen // SPDX-License-Identifier: GPL-2.0 2366bb35aSHuacai Chen /* 3366bb35aSHuacai Chen * Author: Huacai Chen <chenhuacai@loongson.cn> 4366bb35aSHuacai Chen * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 5366bb35aSHuacai Chen */ 6366bb35aSHuacai Chen #include <linux/acpi.h> 7366bb35aSHuacai Chen #include <linux/platform_device.h> 8366bb35aSHuacai Chen 9366bb35aSHuacai Chen #include <asm/bootinfo.h> 10366bb35aSHuacai Chen #include <asm/loongson.h> 11366bb35aSHuacai Chen 12366bb35aSHuacai Chen void enable_gpe_wakeup(void) 13366bb35aSHuacai Chen { 14366bb35aSHuacai Chen if (acpi_disabled) 15366bb35aSHuacai Chen return; 16366bb35aSHuacai Chen 17366bb35aSHuacai Chen if (acpi_gbl_reduced_hardware) 18366bb35aSHuacai Chen return; 19366bb35aSHuacai Chen 20366bb35aSHuacai Chen acpi_enable_all_wakeup_gpes(); 21366bb35aSHuacai Chen } 22366bb35aSHuacai Chen 23366bb35aSHuacai Chen void enable_pci_wakeup(void) 24366bb35aSHuacai Chen { 25366bb35aSHuacai Chen if (acpi_disabled) 26366bb35aSHuacai Chen return; 27366bb35aSHuacai Chen 28366bb35aSHuacai Chen if (acpi_gbl_reduced_hardware) 29366bb35aSHuacai Chen return; 30366bb35aSHuacai Chen 31366bb35aSHuacai Chen acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_STATUS, 1); 32366bb35aSHuacai Chen 33366bb35aSHuacai Chen if (acpi_gbl_FADT.flags & ACPI_FADT_PCI_EXPRESS_WAKE) 34366bb35aSHuacai Chen acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_DISABLE, 0); 35366bb35aSHuacai Chen } 36366bb35aSHuacai Chen 37*f60d251bSHuacai Chen static struct platform_device loongson3_cpufreq_device = { 38*f60d251bSHuacai Chen .name = "loongson3_cpufreq", 39*f60d251bSHuacai Chen .id = -1, 40*f60d251bSHuacai Chen }; 41*f60d251bSHuacai Chen 42*f60d251bSHuacai Chen static int __init loongson_cpufreq_init(void) 43*f60d251bSHuacai Chen { 44*f60d251bSHuacai Chen if (!cpu_has_scalefreq) 45*f60d251bSHuacai Chen return -ENODEV; 46*f60d251bSHuacai Chen 47*f60d251bSHuacai Chen return platform_device_register(&loongson3_cpufreq_device); 48*f60d251bSHuacai Chen } 49*f60d251bSHuacai Chen 50*f60d251bSHuacai Chen arch_initcall(loongson_cpufreq_init); 51*f60d251bSHuacai Chen 52366bb35aSHuacai Chen static int __init loongson3_acpi_suspend_init(void) 53366bb35aSHuacai Chen { 54366bb35aSHuacai Chen #ifdef CONFIG_ACPI 55366bb35aSHuacai Chen acpi_status status; 56366bb35aSHuacai Chen uint64_t suspend_addr = 0; 57366bb35aSHuacai Chen 58366bb35aSHuacai Chen if (acpi_disabled || acpi_gbl_reduced_hardware) 59366bb35aSHuacai Chen return 0; 60366bb35aSHuacai Chen 61366bb35aSHuacai Chen acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1); 62366bb35aSHuacai Chen status = acpi_evaluate_integer(NULL, "\\SADR", NULL, &suspend_addr); 63366bb35aSHuacai Chen if (ACPI_FAILURE(status) || !suspend_addr) { 64366bb35aSHuacai Chen pr_err("ACPI S3 is not support!\n"); 65366bb35aSHuacai Chen return -1; 66366bb35aSHuacai Chen } 67366bb35aSHuacai Chen loongson_sysconf.suspend_addr = (u64)phys_to_virt(PHYSADDR(suspend_addr)); 68366bb35aSHuacai Chen #endif 69366bb35aSHuacai Chen return 0; 70366bb35aSHuacai Chen } 71366bb35aSHuacai Chen 72366bb35aSHuacai Chen device_initcall(loongson3_acpi_suspend_init); 73