1 /*
2  *  Copyright (C) 1999 VA Linux Systems
3  *  Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
4  *  Copyright (C) 2000,2001 J.I. Lee <jung-ik.lee@intel.com>
5  *  Copyright (C) 2001,2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6  *
7  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24  */
25 
26 #ifndef _ASM_ACPI_H
27 #define _ASM_ACPI_H
28 
29 #ifdef __KERNEL__
30 
31 #include <acpi/pdc_intel.h>
32 
33 #include <linux/init.h>
34 #include <linux/numa.h>
35 #include <asm/system.h>
36 #include <asm/numa.h>
37 
38 #define COMPILER_DEPENDENT_INT64	long
39 #define COMPILER_DEPENDENT_UINT64	unsigned long
40 
41 /*
42  * Calling conventions:
43  *
44  * ACPI_SYSTEM_XFACE        - Interfaces to host OS (handlers, threads)
45  * ACPI_EXTERNAL_XFACE      - External ACPI interfaces
46  * ACPI_INTERNAL_XFACE      - Internal ACPI interfaces
47  * ACPI_INTERNAL_VAR_XFACE  - Internal variable-parameter list interfaces
48  */
49 #define ACPI_SYSTEM_XFACE
50 #define ACPI_EXTERNAL_XFACE
51 #define ACPI_INTERNAL_XFACE
52 #define ACPI_INTERNAL_VAR_XFACE
53 
54 /* Asm macros */
55 
56 #define ACPI_ASM_MACROS
57 #define BREAKPOINT3
58 #define ACPI_DISABLE_IRQS() local_irq_disable()
59 #define ACPI_ENABLE_IRQS()  local_irq_enable()
60 #define ACPI_FLUSH_CPU_CACHE()
61 
62 static inline int
ia64_acpi_acquire_global_lock(unsigned int * lock)63 ia64_acpi_acquire_global_lock (unsigned int *lock)
64 {
65 	unsigned int old, new, val;
66 	do {
67 		old = *lock;
68 		new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
69 		val = ia64_cmpxchg4_acq(lock, new, old);
70 	} while (unlikely (val != old));
71 	return (new < 3) ? -1 : 0;
72 }
73 
74 static inline int
ia64_acpi_release_global_lock(unsigned int * lock)75 ia64_acpi_release_global_lock (unsigned int *lock)
76 {
77 	unsigned int old, new, val;
78 	do {
79 		old = *lock;
80 		new = old & ~0x3;
81 		val = ia64_cmpxchg4_acq(lock, new, old);
82 	} while (unlikely (val != old));
83 	return old & 0x1;
84 }
85 
86 #define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq)				\
87 	((Acq) = ia64_acpi_acquire_global_lock(&facs->global_lock))
88 
89 #define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq)				\
90 	((Acq) = ia64_acpi_release_global_lock(&facs->global_lock))
91 
92 #ifdef	CONFIG_ACPI
93 #define acpi_disabled 0	/* ACPI always enabled on IA64 */
94 #define acpi_noirq 0	/* ACPI always enabled on IA64 */
95 #define acpi_pci_disabled 0 /* ACPI PCI always enabled on IA64 */
96 #define acpi_strict 1	/* no ACPI spec workarounds on IA64 */
97 #endif
98 #define acpi_processor_cstate_check(x) (x) /* no idle limits on IA64 :) */
disable_acpi(void)99 static inline void disable_acpi(void) { }
pci_acpi_crs_quirks(void)100 static inline void pci_acpi_crs_quirks(void) { }
101 
102 #ifdef CONFIG_IA64_GENERIC
103 const char *acpi_get_sysname (void);
104 #else
acpi_get_sysname(void)105 static inline const char *acpi_get_sysname (void)
106 {
107 # if defined (CONFIG_IA64_HP_SIM)
108 	return "hpsim";
109 # elif defined (CONFIG_IA64_HP_ZX1)
110 	return "hpzx1";
111 # elif defined (CONFIG_IA64_HP_ZX1_SWIOTLB)
112 	return "hpzx1_swiotlb";
113 # elif defined (CONFIG_IA64_SGI_SN2)
114 	return "sn2";
115 # elif defined (CONFIG_IA64_SGI_UV)
116 	return "uv";
117 # elif defined (CONFIG_IA64_DIG)
118 	return "dig";
119 # elif defined (CONFIG_IA64_XEN_GUEST)
120 	return "xen";
121 # elif defined(CONFIG_IA64_DIG_VTD)
122 	return "dig_vtd";
123 # else
124 #	error Unknown platform.  Fix acpi.c.
125 # endif
126 }
127 #endif
128 int acpi_request_vector (u32 int_type);
129 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
130 
131 /* Low-level suspend routine. */
132 extern int acpi_suspend_lowlevel(void);
133 
134 extern unsigned long acpi_wakeup_address;
135 
136 /*
137  * Record the cpei override flag and current logical cpu. This is
138  * useful for CPU removal.
139  */
140 extern unsigned int can_cpei_retarget(void);
141 extern unsigned int is_cpu_cpei_target(unsigned int cpu);
142 extern void set_cpei_target_cpu(unsigned int cpu);
143 extern unsigned int get_cpei_target_cpu(void);
144 extern void prefill_possible_map(void);
145 #ifdef CONFIG_ACPI_HOTPLUG_CPU
146 extern int additional_cpus;
147 #else
148 #define additional_cpus 0
149 #endif
150 
151 #ifdef CONFIG_ACPI_NUMA
152 #if MAX_NUMNODES > 256
153 #define MAX_PXM_DOMAINS MAX_NUMNODES
154 #else
155 #define MAX_PXM_DOMAINS (256)
156 #endif
157 extern int __devinitdata pxm_to_nid_map[MAX_PXM_DOMAINS];
158 extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
159 #endif
160 
arch_has_acpi_pdc(void)161 static inline bool arch_has_acpi_pdc(void) { return true; }
arch_acpi_set_pdc_bits(u32 * buf)162 static inline void arch_acpi_set_pdc_bits(u32 *buf)
163 {
164 	buf[2] |= ACPI_PDC_EST_CAPABILITY_SMP;
165 }
166 
167 #define acpi_unlazy_tlb(x)
168 
169 #ifdef CONFIG_ACPI_NUMA
170 extern cpumask_t early_cpu_possible_map;
171 #define for_each_possible_early_cpu(cpu)  \
172 	for_each_cpu_mask((cpu), early_cpu_possible_map)
173 
per_cpu_scan_finalize(int min_cpus,int reserve_cpus)174 static inline void per_cpu_scan_finalize(int min_cpus, int reserve_cpus)
175 {
176 	int low_cpu, high_cpu;
177 	int cpu;
178 	int next_nid = 0;
179 
180 	low_cpu = cpus_weight(early_cpu_possible_map);
181 
182 	high_cpu = max(low_cpu, min_cpus);
183 	high_cpu = min(high_cpu + reserve_cpus, NR_CPUS);
184 
185 	for (cpu = low_cpu; cpu < high_cpu; cpu++) {
186 		cpu_set(cpu, early_cpu_possible_map);
187 		if (node_cpuid[cpu].nid == NUMA_NO_NODE) {
188 			node_cpuid[cpu].nid = next_nid;
189 			next_nid++;
190 			if (next_nid >= num_online_nodes())
191 				next_nid = 0;
192 		}
193 	}
194 }
195 #endif /* CONFIG_ACPI_NUMA */
196 
197 #endif /*__KERNEL__*/
198 
199 #endif /*_ASM_ACPI_H*/
200