1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _ASM_X86_ACPI_H
3 #define _ASM_X86_ACPI_H
9 #include <acpi/proc_cap_intel.h>
12 #include <asm/fixmap.h>
13 #include <asm/processor.h>
15 #include <asm/mpspec.h>
16 #include <asm/x86_init.h>
17 #include <asm/cpufeature.h>
18 #include <asm/irq_vectors.h>
19 #include <asm/xen/hypervisor.h>
23 #ifdef CONFIG_ACPI_APEI
24 # include <asm/pgtable_types.h>
28 extern int acpi_lapic;
29 extern int acpi_ioapic;
30 extern int acpi_noirq;
31 extern int acpi_strict;
32 extern int acpi_disabled;
33 extern int acpi_pci_disabled;
34 extern int acpi_skip_timer_override;
35 extern int acpi_use_timer_override;
36 extern int acpi_fix_pin2_polarity;
37 extern int acpi_disable_cmcff;
38 extern bool acpi_int_src_ovr[NR_IRQS_LEGACY];
40 extern u8 acpi_sci_flags;
41 extern u32 acpi_sci_override_gsi;
42 void acpi_pic_sci_set_trigger(unsigned int, u16);
46 extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
47 int trigger, int polarity);
48 extern void (*__acpi_unregister_gsi)(u32 gsi);
50 static inline void disable_acpi(void)
53 acpi_pci_disabled = 1;
57 extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
59 extern int acpi_blacklisted(void);
61 static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
62 static inline void acpi_disable_pci(void)
64 acpi_pci_disabled = 1;
68 /* Low-level suspend routine. */
69 extern int (*acpi_suspend_lowlevel)(void);
71 /* Physical address to resume after wakeup */
72 unsigned long acpi_get_wakeup_address(void);
74 static inline bool acpi_skip_set_wakeup_address(void)
76 return cpu_feature_enabled(X86_FEATURE_XENPV);
79 #define acpi_skip_set_wakeup_address acpi_skip_set_wakeup_address
82 * Check if the CPU can handle C2 and deeper
84 static inline unsigned int acpi_processor_cstate_check(unsigned int max_cstate)
87 * Early models (<=5) of AMD Opterons are not supposed to go into
90 * Steppings 0x0A and later are good
92 if (boot_cpu_data.x86 == 0x0F &&
93 boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
94 boot_cpu_data.x86_model <= 0x05 &&
95 boot_cpu_data.x86_stepping < 0x0A)
97 else if (boot_cpu_has(X86_BUG_AMD_APIC_C1E))
103 static inline bool arch_has_acpi_pdc(void)
105 struct cpuinfo_x86 *c = &cpu_data(0);
106 return (c->x86_vendor == X86_VENDOR_INTEL ||
107 c->x86_vendor == X86_VENDOR_CENTAUR);
110 static inline void arch_acpi_set_proc_cap_bits(u32 *cap)
112 struct cpuinfo_x86 *c = &cpu_data(0);
114 *cap |= ACPI_PROC_CAP_C_CAPABILITY_SMP;
116 /* Enable coordination with firmware's _TSD info */
117 *cap |= ACPI_PROC_CAP_SMP_T_SWCOORD;
119 if (cpu_has(c, X86_FEATURE_EST))
120 *cap |= ACPI_PROC_CAP_EST_CAPABILITY_SWSMP;
122 if (cpu_has(c, X86_FEATURE_ACPI))
123 *cap |= ACPI_PROC_CAP_T_FFH;
125 if (cpu_has(c, X86_FEATURE_HWP))
126 *cap |= ACPI_PROC_CAP_COLLAB_PROC_PERF;
129 * If mwait/monitor is unsupported, C_C1_FFH and
130 * C2/C3_FFH will be disabled.
132 if (!cpu_has(c, X86_FEATURE_MWAIT) ||
133 boot_option_idle_override == IDLE_NOMWAIT)
134 *cap &= ~(ACPI_PROC_CAP_C_C1_FFH | ACPI_PROC_CAP_C_C2C3_FFH);
136 if (xen_initial_domain()) {
138 * When Linux is running as Xen dom0, the hypervisor is the
139 * entity in charge of the processor power management, and so
140 * Xen needs to check the OS capabilities reported in the
141 * processor capabilities buffer matches what the hypervisor
144 xen_sanitize_proc_cap_bits(cap);
148 static inline bool acpi_has_cpu_in_madt(void)
153 #define ACPI_HAVE_ARCH_SET_ROOT_POINTER
154 static inline void acpi_arch_set_root_pointer(u64 addr)
156 x86_init.acpi.set_root_pointer(addr);
159 #define ACPI_HAVE_ARCH_GET_ROOT_POINTER
160 static inline u64 acpi_arch_get_root_pointer(void)
162 return x86_init.acpi.get_root_pointer();
165 void acpi_generic_reduced_hw_init(void);
167 void x86_default_set_root_pointer(u64 addr);
168 u64 x86_default_get_root_pointer(void);
170 #else /* !CONFIG_ACPI */
173 #define acpi_ioapic 0
174 #define acpi_disable_cmcff 0
175 static inline void acpi_noirq_set(void) { }
176 static inline void acpi_disable_pci(void) { }
177 static inline void disable_acpi(void) { }
179 static inline void acpi_generic_reduced_hw_init(void) { }
181 static inline void x86_default_set_root_pointer(u64 addr) { }
183 static inline u64 x86_default_get_root_pointer(void)
188 #endif /* !CONFIG_ACPI */
190 #define ARCH_HAS_POWER_INIT 1
192 #ifdef CONFIG_ACPI_NUMA
193 extern int x86_acpi_numa_init(void);
194 #endif /* CONFIG_ACPI_NUMA */
196 struct cper_ia_proc_ctx;
198 #ifdef CONFIG_ACPI_APEI
199 static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr)
202 * We currently have no way to look up the EFI memory map
203 * attributes for a region in a consistent way, because the
204 * memmap is discarded after efi_free_boot_services(). So if
205 * you call efi_mem_attributes() during boot and at runtime,
206 * you could theoretically see different attributes.
208 * We are yet to see any x86 platforms that require anything
209 * other than PAGE_KERNEL (some ARM64 platforms require the
210 * equivalent of PAGE_KERNEL_NOCACHE). Additionally, if SME
211 * is active, the ACPI information will not be encrypted,
212 * so return PAGE_KERNEL_NOENC until we know differently.
214 return PAGE_KERNEL_NOENC;
217 int arch_apei_report_x86_error(struct cper_ia_proc_ctx *ctx_info,
220 static inline int arch_apei_report_x86_error(struct cper_ia_proc_ctx *ctx_info,
227 #define ACPI_TABLE_UPGRADE_MAX_PHYS (max_low_pfn_mapped << PAGE_SHIFT)
229 #endif /* _ASM_X86_ACPI_H */