platform.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. #include <asm/bootinfo.h>
  9. #include <asm/loongson.h>
  10. void enable_gpe_wakeup(void)
  11. {
  12. if (acpi_disabled)
  13. return;
  14. if (acpi_gbl_reduced_hardware)
  15. return;
  16. acpi_hw_enable_all_wakeup_gpes();
  17. }
  18. void enable_pci_wakeup(void)
  19. {
  20. if (acpi_disabled)
  21. return;
  22. if (acpi_gbl_reduced_hardware)
  23. return;
  24. acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_STATUS, 1);
  25. if (acpi_gbl_FADT.flags & ACPI_FADT_PCI_EXPRESS_WAKE)
  26. acpi_write_bit_register(ACPI_BITREG_PCIEXP_WAKE_DISABLE, 0);
  27. }
  28. static struct platform_device loongson3_cpufreq_device = {
  29. .name = "loongson3_cpufreq",
  30. .id = -1,
  31. };
  32. static int __init loongson_cpufreq_init(void)
  33. {
  34. if (!cpu_has_scalefreq)
  35. return -ENODEV;
  36. return platform_device_register(&loongson3_cpufreq_device);
  37. }
  38. arch_initcall(loongson_cpufreq_init);
  39. static void default_suspend_addr(void)
  40. {
  41. acpi_enter_sleep_state(ACPI_STATE_S3);
  42. }
  43. static int __init loongson3_acpi_suspend_init(void)
  44. {
  45. #ifdef CONFIG_ACPI
  46. acpi_status status;
  47. uint64_t suspend_addr = 0;
  48. if (acpi_disabled)
  49. return 0;
  50. if (!acpi_gbl_reduced_hardware)
  51. acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
  52. if (!acpi_sleep_state_supported(ACPI_STATE_S3))
  53. return 0;
  54. status = acpi_evaluate_integer(NULL, "\\SADR", NULL, &suspend_addr);
  55. if (ACPI_FAILURE(status) || !suspend_addr) {
  56. pr_info("ACPI S3 supported with hardware register default\n");
  57. loongson_sysconf.suspend_addr = (unsigned long)default_suspend_addr;
  58. } else {
  59. pr_info("ACPI S3 supported with Loongson ACPI SADR extension\n");
  60. loongson_sysconf.suspend_addr = (unsigned long)phys_to_virt(PHYSADDR(suspend_addr));
  61. }
  62. #endif
  63. return 0;
  64. }
  65. device_initcall(loongson3_acpi_suspend_init);