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