xref: /openbmc/linux/arch/x86/include/asm/acpi.h (revision e7b66d16)
11965aae3SH. Peter Anvin #ifndef _ASM_X86_ACPI_H
21965aae3SH. Peter Anvin #define _ASM_X86_ACPI_H
3bb898558SAl Viro 
4bb898558SAl Viro /*
5bb898558SAl Viro  *  Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6bb898558SAl Viro  *  Copyright (C) 2001 Patrick Mochel <mochel@osdl.org>
7bb898558SAl Viro  *
8bb898558SAl Viro  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9bb898558SAl Viro  *
10bb898558SAl Viro  *  This program is free software; you can redistribute it and/or modify
11bb898558SAl Viro  *  it under the terms of the GNU General Public License as published by
12bb898558SAl Viro  *  the Free Software Foundation; either version 2 of the License, or
13bb898558SAl Viro  *  (at your option) any later version.
14bb898558SAl Viro  *
15bb898558SAl Viro  *  This program is distributed in the hope that it will be useful,
16bb898558SAl Viro  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17bb898558SAl Viro  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18bb898558SAl Viro  *  GNU General Public License for more details.
19bb898558SAl Viro  *
20bb898558SAl Viro  *  You should have received a copy of the GNU General Public License
21bb898558SAl Viro  *  along with this program; if not, write to the Free Software
22bb898558SAl Viro  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23bb898558SAl Viro  *
24bb898558SAl Viro  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25bb898558SAl Viro  */
26bb898558SAl Viro #include <acpi/pdc_intel.h>
27bb898558SAl Viro 
28bb898558SAl Viro #include <asm/numa.h>
29bee7f9c8SYinghai Lu #include <asm/fixmap.h>
30bb898558SAl Viro #include <asm/processor.h>
31bb898558SAl Viro #include <asm/mmu.h>
32bb898558SAl Viro #include <asm/mpspec.h>
33319b6ffcSH. Peter Anvin #include <asm/realmode.h>
34038bac2bSJuergen Gross #include <asm/x86_init.h>
35bb898558SAl Viro 
36b40227fbSJonathan (Zhixiong) Zhang #ifdef CONFIG_ACPI_APEI
37b40227fbSJonathan (Zhixiong) Zhang # include <asm/pgtable_types.h>
38b40227fbSJonathan (Zhixiong) Zhang #endif
39b40227fbSJonathan (Zhixiong) Zhang 
40bb898558SAl Viro #ifdef CONFIG_ACPI
41bb898558SAl Viro extern int acpi_lapic;
42bb898558SAl Viro extern int acpi_ioapic;
43bb898558SAl Viro extern int acpi_noirq;
44bb898558SAl Viro extern int acpi_strict;
45bb898558SAl Viro extern int acpi_disabled;
46bb898558SAl Viro extern int acpi_pci_disabled;
47bb898558SAl Viro extern int acpi_skip_timer_override;
48bb898558SAl Viro extern int acpi_use_timer_override;
497f74f8f2SAndreas Herrmann extern int acpi_fix_pin2_polarity;
509ad95879SNaveen N. Rao extern int acpi_disable_cmcff;
51bb898558SAl Viro 
52bb898558SAl Viro extern u8 acpi_sci_flags;
534565c4f6SAndy Shevchenko extern u32 acpi_sci_override_gsi;
54bb898558SAl Viro void acpi_pic_sci_set_trigger(unsigned int, u16);
55bb898558SAl Viro 
5699da1ffeSIngo Molnar struct device;
5799da1ffeSIngo Molnar 
5890f6881eSJeremy Fitzhardinge extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
5990f6881eSJeremy Fitzhardinge 				  int trigger, int polarity);
608abb850aSJiang Liu extern void (*__acpi_unregister_gsi)(u32 gsi);
6190f6881eSJeremy Fitzhardinge 
62bb898558SAl Viro static inline void disable_acpi(void)
63bb898558SAl Viro {
64bb898558SAl Viro 	acpi_disabled = 1;
65bb898558SAl Viro 	acpi_pci_disabled = 1;
66bb898558SAl Viro 	acpi_noirq = 1;
67bb898558SAl Viro }
68bb898558SAl Viro 
69bb898558SAl Viro extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
70bb898558SAl Viro 
71bb898558SAl Viro static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
72bb898558SAl Viro static inline void acpi_disable_pci(void)
73bb898558SAl Viro {
74bb898558SAl Viro 	acpi_pci_disabled = 1;
75bb898558SAl Viro 	acpi_noirq_set();
76bb898558SAl Viro }
77bb898558SAl Viro 
78f1a2003eSRafael J. Wysocki /* Low-level suspend routine. */
79d6a77eadSKonrad Rzeszutek Wilk extern int (*acpi_suspend_lowlevel)(void);
80bb898558SAl Viro 
81319b6ffcSH. Peter Anvin /* Physical address to resume after wakeup */
82319b6ffcSH. Peter Anvin #define acpi_wakeup_address ((unsigned long)(real_mode_header->wakeup_start))
83bb898558SAl Viro 
84bb898558SAl Viro /*
85bb898558SAl Viro  * Check if the CPU can handle C2 and deeper
86bb898558SAl Viro  */
87bb898558SAl Viro static inline unsigned int acpi_processor_cstate_check(unsigned int max_cstate)
88bb898558SAl Viro {
89bb898558SAl Viro 	/*
90bb898558SAl Viro 	 * Early models (<=5) of AMD Opterons are not supposed to go into
91bb898558SAl Viro 	 * C2 state.
92bb898558SAl Viro 	 *
93bb898558SAl Viro 	 * Steppings 0x0A and later are good
94bb898558SAl Viro 	 */
95bb898558SAl Viro 	if (boot_cpu_data.x86 == 0x0F &&
96bb898558SAl Viro 	    boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
97bb898558SAl Viro 	    boot_cpu_data.x86_model <= 0x05 &&
98b399151cSJia Zhang 	    boot_cpu_data.x86_stepping < 0x0A)
99bb898558SAl Viro 		return 1;
10007c94a38SBorislav Petkov 	else if (boot_cpu_has(X86_BUG_AMD_APIC_C1E))
101bb898558SAl Viro 		return 1;
102bb898558SAl Viro 	else
103bb898558SAl Viro 		return max_cstate;
104bb898558SAl Viro }
105bb898558SAl Viro 
1061d9cb470SAlex Chiang static inline bool arch_has_acpi_pdc(void)
1071d9cb470SAlex Chiang {
1081d9cb470SAlex Chiang 	struct cpuinfo_x86 *c = &cpu_data(0);
1091d9cb470SAlex Chiang 	return (c->x86_vendor == X86_VENDOR_INTEL ||
1101d9cb470SAlex Chiang 		c->x86_vendor == X86_VENDOR_CENTAUR);
1111d9cb470SAlex Chiang }
1121d9cb470SAlex Chiang 
1136c5807d7SAlex Chiang static inline void arch_acpi_set_pdc_bits(u32 *buf)
1146c5807d7SAlex Chiang {
1156c5807d7SAlex Chiang 	struct cpuinfo_x86 *c = &cpu_data(0);
1166c5807d7SAlex Chiang 
1176c5807d7SAlex Chiang 	buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
1186c5807d7SAlex Chiang 
1196c5807d7SAlex Chiang 	if (cpu_has(c, X86_FEATURE_EST))
1206c5807d7SAlex Chiang 		buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
1216c5807d7SAlex Chiang 
1226c5807d7SAlex Chiang 	if (cpu_has(c, X86_FEATURE_ACPI))
1236c5807d7SAlex Chiang 		buf[2] |= ACPI_PDC_T_FFH;
1246c5807d7SAlex Chiang 
1256c5807d7SAlex Chiang 	/*
1266c5807d7SAlex Chiang 	 * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
1276c5807d7SAlex Chiang 	 */
1286c5807d7SAlex Chiang 	if (!cpu_has(c, X86_FEATURE_MWAIT))
1296c5807d7SAlex Chiang 		buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
1306c5807d7SAlex Chiang }
1316c5807d7SAlex Chiang 
132b50154d5SGraeme Gregory static inline bool acpi_has_cpu_in_madt(void)
133b50154d5SGraeme Gregory {
134b50154d5SGraeme Gregory 	return !!acpi_lapic;
135b50154d5SGraeme Gregory }
136b50154d5SGraeme Gregory 
137038bac2bSJuergen Gross #define ACPI_HAVE_ARCH_GET_ROOT_POINTER
138038bac2bSJuergen Gross static inline u64 acpi_arch_get_root_pointer(void)
139038bac2bSJuergen Gross {
140038bac2bSJuergen Gross 	return x86_init.acpi.get_root_pointer();
141038bac2bSJuergen Gross }
142038bac2bSJuergen Gross 
14350beba07SAndy Shevchenko void acpi_generic_reduced_hw_init(void);
14450beba07SAndy Shevchenko 
145e7b66d16SJuergen Gross u64 x86_default_get_root_pointer(void);
146e7b66d16SJuergen Gross 
147bb898558SAl Viro #else /* !CONFIG_ACPI */
148bb898558SAl Viro 
149bb898558SAl Viro #define acpi_lapic 0
150bb898558SAl Viro #define acpi_ioapic 0
1519ad95879SNaveen N. Rao #define acpi_disable_cmcff 0
152bb898558SAl Viro static inline void acpi_noirq_set(void) { }
153bb898558SAl Viro static inline void acpi_disable_pci(void) { }
154bb898558SAl Viro static inline void disable_acpi(void) { }
155bb898558SAl Viro 
15650beba07SAndy Shevchenko static inline void acpi_generic_reduced_hw_init(void) { }
15750beba07SAndy Shevchenko 
158e7b66d16SJuergen Gross static inline u64 x86_default_get_root_pointer(void)
159e7b66d16SJuergen Gross {
160e7b66d16SJuergen Gross 	return 0;
161e7b66d16SJuergen Gross }
162e7b66d16SJuergen Gross 
163bb898558SAl Viro #endif /* !CONFIG_ACPI */
164bb898558SAl Viro 
165bb898558SAl Viro #define ARCH_HAS_POWER_INIT	1
166bb898558SAl Viro 
167bb898558SAl Viro #ifdef CONFIG_ACPI_NUMA
168a9aec56aSTejun Heo extern int x86_acpi_numa_init(void);
1694e76f4e6SDavid Rientjes #endif /* CONFIG_ACPI_NUMA */
170bb898558SAl Viro 
17167535736SAndy Lutomirski #define acpi_unlazy_tlb(x)	leave_mm(x)
17267535736SAndy Lutomirski 
173b40227fbSJonathan (Zhixiong) Zhang #ifdef CONFIG_ACPI_APEI
174b40227fbSJonathan (Zhixiong) Zhang static inline pgprot_t arch_apei_get_mem_attribute(phys_addr_t addr)
175b40227fbSJonathan (Zhixiong) Zhang {
176b40227fbSJonathan (Zhixiong) Zhang 	/*
177b40227fbSJonathan (Zhixiong) Zhang 	 * We currently have no way to look up the EFI memory map
178b40227fbSJonathan (Zhixiong) Zhang 	 * attributes for a region in a consistent way, because the
179b40227fbSJonathan (Zhixiong) Zhang 	 * memmap is discarded after efi_free_boot_services(). So if
180b40227fbSJonathan (Zhixiong) Zhang 	 * you call efi_mem_attributes() during boot and at runtime,
181b40227fbSJonathan (Zhixiong) Zhang 	 * you could theoretically see different attributes.
182b40227fbSJonathan (Zhixiong) Zhang 	 *
18357bd1905STom Lendacky 	 * We are yet to see any x86 platforms that require anything
18457bd1905STom Lendacky 	 * other than PAGE_KERNEL (some ARM64 platforms require the
18557bd1905STom Lendacky 	 * equivalent of PAGE_KERNEL_NOCACHE). Additionally, if SME
18657bd1905STom Lendacky 	 * is active, the ACPI information will not be encrypted,
18757bd1905STom Lendacky 	 * so return PAGE_KERNEL_NOENC until we know differently.
188b40227fbSJonathan (Zhixiong) Zhang 	 */
18957bd1905STom Lendacky 	return PAGE_KERNEL_NOENC;
190b40227fbSJonathan (Zhixiong) Zhang }
191b40227fbSJonathan (Zhixiong) Zhang #endif
192b40227fbSJonathan (Zhixiong) Zhang 
19384b06ca3SAleksey Makarov #define ACPI_TABLE_UPGRADE_MAX_PHYS (max_low_pfn_mapped << PAGE_SHIFT)
19484b06ca3SAleksey Makarov 
1951965aae3SH. Peter Anvin #endif /* _ASM_X86_ACPI_H */
196