acpi.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _ASM_X86_ACPI_H
  3. #define _ASM_X86_ACPI_H
  4. /*
  5. * Copyright (C) 2001 Paul Diefenbaugh <[email protected]>
  6. * Copyright (C) 2001 Patrick Mochel <[email protected]>
  7. */
  8. #include <acpi/pdc_intel.h>
  9. #include <asm/numa.h>
  10. #include <asm/fixmap.h>
  11. #include <asm/processor.h>
  12. #include <asm/mmu.h>
  13. #include <asm/mpspec.h>
  14. #include <asm/x86_init.h>
  15. #include <asm/cpufeature.h>
  16. #ifdef CONFIG_ACPI_APEI
  17. # include <asm/pgtable_types.h>
  18. #endif
  19. #ifdef CONFIG_ACPI
  20. extern int acpi_lapic;
  21. extern int acpi_ioapic;
  22. extern int acpi_noirq;
  23. extern int acpi_strict;
  24. extern int acpi_disabled;
  25. extern int acpi_pci_disabled;
  26. extern int acpi_skip_timer_override;
  27. extern int acpi_use_timer_override;
  28. extern int acpi_fix_pin2_polarity;
  29. extern int acpi_disable_cmcff;
  30. extern u8 acpi_sci_flags;
  31. extern u32 acpi_sci_override_gsi;
  32. void acpi_pic_sci_set_trigger(unsigned int, u16);
  33. struct device;
  34. extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
  35. int trigger, int polarity);
  36. extern void (*__acpi_unregister_gsi)(u32 gsi);
  37. static inline void disable_acpi(void)
  38. {
  39. acpi_disabled = 1;
  40. acpi_pci_disabled = 1;
  41. acpi_noirq = 1;
  42. }
  43. extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
  44. static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
  45. static inline void acpi_disable_pci(void)
  46. {
  47. acpi_pci_disabled = 1;
  48. acpi_noirq_set();
  49. }
  50. /* Low-level suspend routine. */
  51. extern int (*acpi_suspend_lowlevel)(void);
  52. /* Physical address to resume after wakeup */
  53. unsigned long acpi_get_wakeup_address(void);
  54. static inline bool acpi_skip_set_wakeup_address(void)
  55. {
  56. return cpu_feature_enabled(X86_FEATURE_XENPV);
  57. }
  58. #define acpi_skip_set_wakeup_address acpi_skip_set_wakeup_address
  59. /*
  60. * Check if the CPU can handle C2 and deeper
  61. */
  62. static inline unsigned int acpi_processor_cstate_check(unsigned int max_cstate)
  63. {
  64. /*
  65. * Early models (<=5) of AMD Opterons are not supposed to go into
  66. * C2 state.
  67. *
  68. * Steppings 0x0A and later are good
  69. */
  70. if (boot_cpu_data.x86 == 0x0F &&
  71. boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
  72. boot_cpu_data.x86_model <= 0x05 &&
  73. boot_cpu_data.x86_stepping < 0x0A)
  74. return 1;
  75. else if (boot_cpu_has(X86_BUG_AMD_APIC_C1E))
  76. return 1;
  77. else
  78. return max_cstate;
  79. }
  80. static inline bool arch_has_acpi_pdc(void)
  81. {
  82. struct cpuinfo_x86 *c = &cpu_data(0);
  83. return (c->x86_vendor == X86_VENDOR_INTEL ||
  84. c->x86_vendor == X86_VENDOR_CENTAUR);
  85. }
  86. static inline void arch_acpi_set_pdc_bits(u32 *buf)
  87. {
  88. struct cpuinfo_x86 *c = &cpu_data(0);
  89. buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
  90. if (cpu_has(c, X86_FEATURE_EST))
  91. buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
  92. if (cpu_has(c, X86_FEATURE_ACPI))
  93. buf[2] |= ACPI_PDC_T_FFH;
  94. /*
  95. * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
  96. */
  97. if (!cpu_has(c, X86_FEATURE_MWAIT))
  98. buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
  99. }
  100. static inline bool acpi_has_cpu_in_madt(void)
  101. {
  102. return !!acpi_lapic;
  103. }
  104. #define ACPI_HAVE_ARCH_SET_ROOT_POINTER
  105. static inline void acpi_arch_set_root_pointer(u64 addr)
  106. {
  107. x86_init.acpi.set_root_pointer(addr);
  108. }
  109. #define ACPI_HAVE_ARCH_GET_ROOT_POINTER
  110. static inline u64 acpi_arch_get_root_pointer(void)
  111. {
  112. return x86_init.acpi.get_root_pointer();
  113. }
  114. void acpi_generic_reduced_hw_init(void);
  115. void x86_default_set_root_pointer(u64 addr);
  116. u64 x86_default_get_root_pointer(void);
  117. #else /* !CONFIG_ACPI */
  118. #define acpi_lapic 0
  119. #define acpi_ioapic 0
  120. #define acpi_disable_cmcff 0
  121. static inline void acpi_noirq_set(void) { }
  122. static inline void acpi_disable_pci(void) { }
  123. static inline void disable_acpi(void) { }
  124. static inline void acpi_generic_reduced_hw_init(void) { }
  125. static inline void x86_default_set_root_pointer(u64 addr) { }
  126. static inline u64 x86_default_get_root_pointer(void)
  127. {
  128. return 0;
  129. }
  130. #endif /* !CONFIG_ACPI */
  131. #define ARCH_HAS_POWER_INIT 1
  132. #ifdef CONFIG_ACPI_NUMA
  133. extern int x86_acpi_numa_init(void);
  134. #endif /* CONFIG_ACPI_NUMA */
  135. struct cper_ia_proc_ctx;
  136. #ifdef CONFIG_ACPI_APEI
  137. static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr)
  138. {
  139. /*
  140. * We currently have no way to look up the EFI memory map
  141. * attributes for a region in a consistent way, because the
  142. * memmap is discarded after efi_free_boot_services(). So if
  143. * you call efi_mem_attributes() during boot and at runtime,
  144. * you could theoretically see different attributes.
  145. *
  146. * We are yet to see any x86 platforms that require anything
  147. * other than PAGE_KERNEL (some ARM64 platforms require the
  148. * equivalent of PAGE_KERNEL_NOCACHE). Additionally, if SME
  149. * is active, the ACPI information will not be encrypted,
  150. * so return PAGE_KERNEL_NOENC until we know differently.
  151. */
  152. return PAGE_KERNEL_NOENC;
  153. }
  154. int arch_apei_report_x86_error(struct cper_ia_proc_ctx *ctx_info,
  155. u64 lapic_id);
  156. #else
  157. static inline int arch_apei_report_x86_error(struct cper_ia_proc_ctx *ctx_info,
  158. u64 lapic_id)
  159. {
  160. return -EINVAL;
  161. }
  162. #endif
  163. #define ACPI_TABLE_UPGRADE_MAX_PHYS (max_low_pfn_mapped << PAGE_SHIFT)
  164. #endif /* _ASM_X86_ACPI_H */