xref: /openbmc/linux/arch/x86/include/asm/acpi.h (revision bee7f9c8)
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>
34bb898558SAl Viro 
35bb898558SAl Viro #define COMPILER_DEPENDENT_INT64   long long
36bb898558SAl Viro #define COMPILER_DEPENDENT_UINT64  unsigned long long
37bb898558SAl Viro 
38bb898558SAl Viro /*
39bb898558SAl Viro  * Calling conventions:
40bb898558SAl Viro  *
41bb898558SAl Viro  * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
42bb898558SAl Viro  * ACPI_EXTERNAL_XFACE      - External ACPI interfaces
43bb898558SAl Viro  * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
44bb898558SAl Viro  * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
45bb898558SAl Viro  */
46bb898558SAl Viro #define ACPI_SYSTEM_XFACE
47bb898558SAl Viro #define ACPI_EXTERNAL_XFACE
48bb898558SAl Viro #define ACPI_INTERNAL_XFACE
49bb898558SAl Viro #define ACPI_INTERNAL_VAR_XFACE
50bb898558SAl Viro 
51bb898558SAl Viro /* Asm macros */
52bb898558SAl Viro 
53bb898558SAl Viro #define ACPI_FLUSH_CPU_CACHE()	wbinvd()
54bb898558SAl Viro 
55bb898558SAl Viro int __acpi_acquire_global_lock(unsigned int *lock);
56bb898558SAl Viro int __acpi_release_global_lock(unsigned int *lock);
57bb898558SAl Viro 
58bb898558SAl Viro #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
59bb898558SAl Viro 	((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
60bb898558SAl Viro 
61bb898558SAl Viro #define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
62bb898558SAl Viro 	((Acq) = __acpi_release_global_lock(&facs->global_lock))
63bb898558SAl Viro 
64bb898558SAl Viro /*
65bb898558SAl Viro  * Math helper asm macros
66bb898558SAl Viro  */
67bb898558SAl Viro #define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
68bb898558SAl Viro 	asm("divl %2;"				     \
69bb898558SAl Viro 	    : "=a"(q32), "=d"(r32)		     \
70bb898558SAl Viro 	    : "r"(d32),				     \
71bb898558SAl Viro 	     "0"(n_lo), "1"(n_hi))
72bb898558SAl Viro 
73bb898558SAl Viro 
74bb898558SAl Viro #define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
75bb898558SAl Viro 	asm("shrl   $1,%2	;"	\
76bb898558SAl Viro 	    "rcrl   $1,%3;"		\
77bb898558SAl Viro 	    : "=r"(n_hi), "=r"(n_lo)	\
78bb898558SAl Viro 	    : "0"(n_hi), "1"(n_lo))
79bb898558SAl Viro 
80bb898558SAl Viro #ifdef CONFIG_ACPI
81bb898558SAl Viro extern int acpi_lapic;
82bb898558SAl Viro extern int acpi_ioapic;
83bb898558SAl Viro extern int acpi_noirq;
84bb898558SAl Viro extern int acpi_strict;
85bb898558SAl Viro extern int acpi_disabled;
86bb898558SAl Viro extern int acpi_pci_disabled;
87bb898558SAl Viro extern int acpi_skip_timer_override;
88bb898558SAl Viro extern int acpi_use_timer_override;
897f74f8f2SAndreas Herrmann extern int acpi_fix_pin2_polarity;
909ad95879SNaveen N. Rao extern int acpi_disable_cmcff;
91bb898558SAl Viro 
92bb898558SAl Viro extern u8 acpi_sci_flags;
93bb898558SAl Viro extern int acpi_sci_override_gsi;
94bb898558SAl Viro void acpi_pic_sci_set_trigger(unsigned int, u16);
95bb898558SAl Viro 
9690f6881eSJeremy Fitzhardinge extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
9790f6881eSJeremy Fitzhardinge 				  int trigger, int polarity);
9890f6881eSJeremy Fitzhardinge 
99bb898558SAl Viro static inline void disable_acpi(void)
100bb898558SAl Viro {
101bb898558SAl Viro 	acpi_disabled = 1;
102bb898558SAl Viro 	acpi_pci_disabled = 1;
103bb898558SAl Viro 	acpi_noirq = 1;
104bb898558SAl Viro }
105bb898558SAl Viro 
106bb898558SAl Viro extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
107bb898558SAl Viro 
108bb898558SAl Viro static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
109bb898558SAl Viro static inline void acpi_disable_pci(void)
110bb898558SAl Viro {
111bb898558SAl Viro 	acpi_pci_disabled = 1;
112bb898558SAl Viro 	acpi_noirq_set();
113bb898558SAl Viro }
114bb898558SAl Viro 
115f1a2003eSRafael J. Wysocki /* Low-level suspend routine. */
116d6a77eadSKonrad Rzeszutek Wilk extern int (*acpi_suspend_lowlevel)(void);
117bb898558SAl Viro 
118319b6ffcSH. Peter Anvin /* Physical address to resume after wakeup */
119319b6ffcSH. Peter Anvin #define acpi_wakeup_address ((unsigned long)(real_mode_header->wakeup_start))
120bb898558SAl Viro 
121bb898558SAl Viro /*
122bb898558SAl Viro  * Check if the CPU can handle C2 and deeper
123bb898558SAl Viro  */
124bb898558SAl Viro static inline unsigned int acpi_processor_cstate_check(unsigned int max_cstate)
125bb898558SAl Viro {
126bb898558SAl Viro 	/*
127bb898558SAl Viro 	 * Early models (<=5) of AMD Opterons are not supposed to go into
128bb898558SAl Viro 	 * C2 state.
129bb898558SAl Viro 	 *
130bb898558SAl Viro 	 * Steppings 0x0A and later are good
131bb898558SAl Viro 	 */
132bb898558SAl Viro 	if (boot_cpu_data.x86 == 0x0F &&
133bb898558SAl Viro 	    boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
134bb898558SAl Viro 	    boot_cpu_data.x86_model <= 0x05 &&
135bb898558SAl Viro 	    boot_cpu_data.x86_mask < 0x0A)
136bb898558SAl Viro 		return 1;
13702c68a02SLen Brown 	else if (amd_e400_c1e_detected)
138bb898558SAl Viro 		return 1;
139bb898558SAl Viro 	else
140bb898558SAl Viro 		return max_cstate;
141bb898558SAl Viro }
142bb898558SAl Viro 
1431d9cb470SAlex Chiang static inline bool arch_has_acpi_pdc(void)
1441d9cb470SAlex Chiang {
1451d9cb470SAlex Chiang 	struct cpuinfo_x86 *c = &cpu_data(0);
1461d9cb470SAlex Chiang 	return (c->x86_vendor == X86_VENDOR_INTEL ||
1471d9cb470SAlex Chiang 		c->x86_vendor == X86_VENDOR_CENTAUR);
1481d9cb470SAlex Chiang }
1491d9cb470SAlex Chiang 
1506c5807d7SAlex Chiang static inline void arch_acpi_set_pdc_bits(u32 *buf)
1516c5807d7SAlex Chiang {
1526c5807d7SAlex Chiang 	struct cpuinfo_x86 *c = &cpu_data(0);
1536c5807d7SAlex Chiang 
1546c5807d7SAlex Chiang 	buf[2] |= ACPI_PDC_C_CAPABILITY_SMP;
1556c5807d7SAlex Chiang 
1566c5807d7SAlex Chiang 	if (cpu_has(c, X86_FEATURE_EST))
1576c5807d7SAlex Chiang 		buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
1586c5807d7SAlex Chiang 
1596c5807d7SAlex Chiang 	if (cpu_has(c, X86_FEATURE_ACPI))
1606c5807d7SAlex Chiang 		buf[2] |= ACPI_PDC_T_FFH;
1616c5807d7SAlex Chiang 
1626c5807d7SAlex Chiang 	/*
1636c5807d7SAlex Chiang 	 * If mwait/monitor is unsupported, C2/C3_FFH will be disabled
1646c5807d7SAlex Chiang 	 */
1656c5807d7SAlex Chiang 	if (!cpu_has(c, X86_FEATURE_MWAIT))
1666c5807d7SAlex Chiang 		buf[2] &= ~(ACPI_PDC_C_C2C3_FFH);
1676c5807d7SAlex Chiang }
1686c5807d7SAlex Chiang 
169bb898558SAl Viro #else /* !CONFIG_ACPI */
170bb898558SAl Viro 
171bb898558SAl Viro #define acpi_lapic 0
172bb898558SAl Viro #define acpi_ioapic 0
1739ad95879SNaveen N. Rao #define acpi_disable_cmcff 0
174bb898558SAl Viro static inline void acpi_noirq_set(void) { }
175bb898558SAl Viro static inline void acpi_disable_pci(void) { }
176bb898558SAl Viro static inline void disable_acpi(void) { }
177bb898558SAl Viro 
178bb898558SAl Viro #endif /* !CONFIG_ACPI */
179bb898558SAl Viro 
180bb898558SAl Viro #define ARCH_HAS_POWER_INIT	1
181bb898558SAl Viro 
182bb898558SAl Viro #ifdef CONFIG_ACPI_NUMA
183bb898558SAl Viro extern int acpi_numa;
184a9aec56aSTejun Heo extern int x86_acpi_numa_init(void);
1854e76f4e6SDavid Rientjes #endif /* CONFIG_ACPI_NUMA */
186bb898558SAl Viro 
187bb898558SAl Viro #define acpi_unlazy_tlb(x)	leave_mm(x)
188bb898558SAl Viro 
1891965aae3SH. Peter Anvin #endif /* _ASM_X86_ACPI_H */
190