11a59d1b8SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 21965aae3SH. Peter Anvin #ifndef _ASM_X86_ACPI_H 31965aae3SH. Peter Anvin #define _ASM_X86_ACPI_H 4bb898558SAl Viro 5bb898558SAl Viro /* 6bb898558SAl Viro * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> 7bb898558SAl Viro * Copyright (C) 2001 Patrick Mochel <mochel@osdl.org> 8bb898558SAl Viro */ 9bb898558SAl Viro #include <acpi/pdc_intel.h> 10bb898558SAl Viro 11bb898558SAl Viro #include <asm/numa.h> 12bee7f9c8SYinghai Lu #include <asm/fixmap.h> 13bb898558SAl Viro #include <asm/processor.h> 14bb898558SAl Viro #include <asm/mmu.h> 15bb898558SAl Viro #include <asm/mpspec.h> 16038bac2bSJuergen Gross #include <asm/x86_init.h> 17bb898558SAl Viro 18b40227fbSJonathan (Zhixiong) Zhang #ifdef CONFIG_ACPI_APEI 19b40227fbSJonathan (Zhixiong) Zhang # include <asm/pgtable_types.h> 20b40227fbSJonathan (Zhixiong) Zhang #endif 21b40227fbSJonathan (Zhixiong) Zhang 22bb898558SAl Viro #ifdef CONFIG_ACPI 23bb898558SAl Viro extern int acpi_lapic; 24bb898558SAl Viro extern int acpi_ioapic; 25bb898558SAl Viro extern int acpi_noirq; 26bb898558SAl Viro extern int acpi_strict; 27bb898558SAl Viro extern int acpi_disabled; 28bb898558SAl Viro extern int acpi_pci_disabled; 29bb898558SAl Viro extern int acpi_skip_timer_override; 30bb898558SAl Viro extern int acpi_use_timer_override; 317f74f8f2SAndreas Herrmann extern int acpi_fix_pin2_polarity; 329ad95879SNaveen N. Rao extern int acpi_disable_cmcff; 33bb898558SAl Viro 34bb898558SAl Viro extern u8 acpi_sci_flags; 354565c4f6SAndy Shevchenko extern u32 acpi_sci_override_gsi; 36bb898558SAl Viro void acpi_pic_sci_set_trigger(unsigned int, u16); 37bb898558SAl Viro 3899da1ffeSIngo Molnar struct device; 3999da1ffeSIngo Molnar 4090f6881eSJeremy Fitzhardinge extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi, 4190f6881eSJeremy Fitzhardinge int trigger, int polarity); 428abb850aSJiang Liu extern void (*__acpi_unregister_gsi)(u32 gsi); 4390f6881eSJeremy Fitzhardinge 44bb898558SAl Viro static inline void disable_acpi(void) 45bb898558SAl Viro { 46bb898558SAl Viro acpi_disabled = 1; 47bb898558SAl Viro acpi_pci_disabled = 1; 48bb898558SAl Viro acpi_noirq = 1; 49bb898558SAl Viro } 50bb898558SAl Viro 51bb898558SAl Viro extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); 52bb898558SAl Viro 53bb898558SAl Viro static inline void acpi_noirq_set(void) { acpi_noirq = 1; } 54bb898558SAl Viro static inline void acpi_disable_pci(void) 55bb898558SAl Viro { 56bb898558SAl Viro acpi_pci_disabled = 1; 57bb898558SAl Viro acpi_noirq_set(); 58bb898558SAl Viro } 59bb898558SAl Viro 60f1a2003eSRafael J. Wysocki /* Low-level suspend routine. */ 61d6a77eadSKonrad Rzeszutek Wilk extern int (*acpi_suspend_lowlevel)(void); 62bb898558SAl Viro 63319b6ffcSH. Peter Anvin /* Physical address to resume after wakeup */ 64*96078642SSean Christopherson unsigned long acpi_get_wakeup_address(void); 65bb898558SAl Viro 66bb898558SAl Viro /* 67bb898558SAl Viro * Check if the CPU can handle C2 and deeper 68bb898558SAl Viro */ 69bb898558SAl Viro static inline unsigned int acpi_processor_cstate_check(unsigned int max_cstate) 70bb898558SAl Viro { 71bb898558SAl Viro /* 72bb898558SAl Viro * Early models (<=5) of AMD Opterons are not supposed to go into 73bb898558SAl Viro * C2 state. 74bb898558SAl Viro * 75bb898558SAl Viro * Steppings 0x0A and later are good 76bb898558SAl Viro */ 77bb898558SAl Viro if (boot_cpu_data.x86 == 0x0F && 78bb898558SAl Viro boot_cpu_data.x86_vendor == X86_VENDOR_AMD && 79bb898558SAl Viro boot_cpu_data.x86_model <= 0x05 && 80b399151cSJia Zhang boot_cpu_data.x86_stepping < 0x0A) 81bb898558SAl Viro return 1; 8207c94a38SBorislav Petkov else if (boot_cpu_has(X86_BUG_AMD_APIC_C1E)) 83bb898558SAl Viro return 1; 84bb898558SAl Viro else 85bb898558SAl Viro return max_cstate; 86bb898558SAl Viro } 87bb898558SAl Viro 881d9cb470SAlex Chiang static inline bool arch_has_acpi_pdc(void) 891d9cb470SAlex Chiang { 901d9cb470SAlex Chiang struct cpuinfo_x86 *c = &cpu_data(0); 911d9cb470SAlex Chiang return (c->x86_vendor == X86_VENDOR_INTEL || 921d9cb470SAlex Chiang c->x86_vendor == X86_VENDOR_CENTAUR); 931d9cb470SAlex Chiang } 941d9cb470SAlex Chiang 956c5807d7SAlex Chiang static inline void arch_acpi_set_pdc_bits(u32 *buf) 966c5807d7SAlex Chiang { 976c5807d7SAlex Chiang struct cpuinfo_x86 *c = &cpu_data(0); 986c5807d7SAlex Chiang 996c5807d7SAlex Chiang buf[2] |= ACPI_PDC_C_CAPABILITY_SMP; 1006c5807d7SAlex Chiang 1016c5807d7SAlex Chiang if (cpu_has(c, X86_FEATURE_EST)) 1026c5807d7SAlex Chiang buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP; 1036c5807d7SAlex Chiang 1046c5807d7SAlex Chiang if (cpu_has(c, X86_FEATURE_ACPI)) 1056c5807d7SAlex Chiang buf[2] |= ACPI_PDC_T_FFH; 1066c5807d7SAlex Chiang 1076c5807d7SAlex Chiang /* 1086c5807d7SAlex Chiang * If mwait/monitor is unsupported, C2/C3_FFH will be disabled 1096c5807d7SAlex Chiang */ 1106c5807d7SAlex Chiang if (!cpu_has(c, X86_FEATURE_MWAIT)) 1116c5807d7SAlex Chiang buf[2] &= ~(ACPI_PDC_C_C2C3_FFH); 1126c5807d7SAlex Chiang } 1136c5807d7SAlex Chiang 114b50154d5SGraeme Gregory static inline bool acpi_has_cpu_in_madt(void) 115b50154d5SGraeme Gregory { 116b50154d5SGraeme Gregory return !!acpi_lapic; 117b50154d5SGraeme Gregory } 118b50154d5SGraeme Gregory 11941fa1ee9SJosh Boyer #define ACPI_HAVE_ARCH_SET_ROOT_POINTER 12041fa1ee9SJosh Boyer static inline void acpi_arch_set_root_pointer(u64 addr) 12141fa1ee9SJosh Boyer { 12241fa1ee9SJosh Boyer x86_init.acpi.set_root_pointer(addr); 12341fa1ee9SJosh Boyer } 12441fa1ee9SJosh Boyer 125038bac2bSJuergen Gross #define ACPI_HAVE_ARCH_GET_ROOT_POINTER 126038bac2bSJuergen Gross static inline u64 acpi_arch_get_root_pointer(void) 127038bac2bSJuergen Gross { 128038bac2bSJuergen Gross return x86_init.acpi.get_root_pointer(); 129038bac2bSJuergen Gross } 130038bac2bSJuergen Gross 13150beba07SAndy Shevchenko void acpi_generic_reduced_hw_init(void); 13250beba07SAndy Shevchenko 13341fa1ee9SJosh Boyer void x86_default_set_root_pointer(u64 addr); 134e7b66d16SJuergen Gross u64 x86_default_get_root_pointer(void); 135e7b66d16SJuergen Gross 136bb898558SAl Viro #else /* !CONFIG_ACPI */ 137bb898558SAl Viro 138bb898558SAl Viro #define acpi_lapic 0 139bb898558SAl Viro #define acpi_ioapic 0 1409ad95879SNaveen N. Rao #define acpi_disable_cmcff 0 141bb898558SAl Viro static inline void acpi_noirq_set(void) { } 142bb898558SAl Viro static inline void acpi_disable_pci(void) { } 143bb898558SAl Viro static inline void disable_acpi(void) { } 144bb898558SAl Viro 14550beba07SAndy Shevchenko static inline void acpi_generic_reduced_hw_init(void) { } 14650beba07SAndy Shevchenko 14741fa1ee9SJosh Boyer static inline void x86_default_set_root_pointer(u64 addr) { } 14841fa1ee9SJosh Boyer 149e7b66d16SJuergen Gross static inline u64 x86_default_get_root_pointer(void) 150e7b66d16SJuergen Gross { 151e7b66d16SJuergen Gross return 0; 152e7b66d16SJuergen Gross } 153e7b66d16SJuergen Gross 154bb898558SAl Viro #endif /* !CONFIG_ACPI */ 155bb898558SAl Viro 156bb898558SAl Viro #define ARCH_HAS_POWER_INIT 1 157bb898558SAl Viro 158bb898558SAl Viro #ifdef CONFIG_ACPI_NUMA 159a9aec56aSTejun Heo extern int x86_acpi_numa_init(void); 1604e76f4e6SDavid Rientjes #endif /* CONFIG_ACPI_NUMA */ 161bb898558SAl Viro 16267535736SAndy Lutomirski #define acpi_unlazy_tlb(x) leave_mm(x) 16367535736SAndy Lutomirski 164b40227fbSJonathan (Zhixiong) Zhang #ifdef CONFIG_ACPI_APEI 165b40227fbSJonathan (Zhixiong) Zhang static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr) 166b40227fbSJonathan (Zhixiong) Zhang { 167b40227fbSJonathan (Zhixiong) Zhang /* 168b40227fbSJonathan (Zhixiong) Zhang * We currently have no way to look up the EFI memory map 169b40227fbSJonathan (Zhixiong) Zhang * attributes for a region in a consistent way, because the 170b40227fbSJonathan (Zhixiong) Zhang * memmap is discarded after efi_free_boot_services(). So if 171b40227fbSJonathan (Zhixiong) Zhang * you call efi_mem_attributes() during boot and at runtime, 172b40227fbSJonathan (Zhixiong) Zhang * you could theoretically see different attributes. 173b40227fbSJonathan (Zhixiong) Zhang * 17457bd1905STom Lendacky * We are yet to see any x86 platforms that require anything 17557bd1905STom Lendacky * other than PAGE_KERNEL (some ARM64 platforms require the 17657bd1905STom Lendacky * equivalent of PAGE_KERNEL_NOCACHE). Additionally, if SME 17757bd1905STom Lendacky * is active, the ACPI information will not be encrypted, 17857bd1905STom Lendacky * so return PAGE_KERNEL_NOENC until we know differently. 179b40227fbSJonathan (Zhixiong) Zhang */ 18057bd1905STom Lendacky return PAGE_KERNEL_NOENC; 181b40227fbSJonathan (Zhixiong) Zhang } 182b40227fbSJonathan (Zhixiong) Zhang #endif 183b40227fbSJonathan (Zhixiong) Zhang 18484b06ca3SAleksey Makarov #define ACPI_TABLE_UPGRADE_MAX_PHYS (max_low_pfn_mapped << PAGE_SHIFT) 18584b06ca3SAleksey Makarov 1861965aae3SH. Peter Anvin #endif /* _ASM_X86_ACPI_H */ 187