mfd: twl4030-core irq simplification
[linux-2.6/mini2440.git] / include / asm-x86 / apic.h
blobd76a0839abe932c789738f0b0ec5b81c79f96b6c
1 #ifndef ASM_X86__APIC_H
2 #define ASM_X86__APIC_H
4 #include <linux/pm.h>
5 #include <linux/delay.h>
7 #include <asm/alternative.h>
8 #include <asm/fixmap.h>
9 #include <asm/apicdef.h>
10 #include <asm/processor.h>
11 #include <asm/system.h>
12 #include <asm/cpufeature.h>
13 #include <asm/msr.h>
15 #define ARCH_APICTIMER_STOPS_ON_C3 1
18 * Debugging macros
20 #define APIC_QUIET 0
21 #define APIC_VERBOSE 1
22 #define APIC_DEBUG 2
25 * Define the default level of output to be very little
26 * This can be turned up by using apic=verbose for more
27 * information and apic=debug for _lots_ of information.
28 * apic_verbosity is defined in apic.c
30 #define apic_printk(v, s, a...) do { \
31 if ((v) <= apic_verbosity) \
32 printk(s, ##a); \
33 } while (0)
36 extern void generic_apic_probe(void);
38 #ifdef CONFIG_X86_LOCAL_APIC
40 extern unsigned int apic_verbosity;
41 extern int local_apic_timer_c2_ok;
43 extern int ioapic_force;
45 extern int disable_apic;
47 * Basic functions accessing APICs.
49 #ifdef CONFIG_PARAVIRT
50 #include <asm/paravirt.h>
51 #else
52 #define setup_boot_clock setup_boot_APIC_clock
53 #define setup_secondary_clock setup_secondary_APIC_clock
54 #endif
56 extern int is_vsmp_box(void);
57 extern void xapic_wait_icr_idle(void);
58 extern u32 safe_xapic_wait_icr_idle(void);
59 extern u64 xapic_icr_read(void);
60 extern void xapic_icr_write(u32, u32);
61 extern int setup_profiling_timer(unsigned int);
63 static inline void native_apic_mem_write(u32 reg, u32 v)
65 volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg);
67 alternative_io("movl %0, %1", "xchgl %0, %1", X86_FEATURE_11AP,
68 ASM_OUTPUT2("=r" (v), "=m" (*addr)),
69 ASM_OUTPUT2("0" (v), "m" (*addr)));
72 static inline u32 native_apic_mem_read(u32 reg)
74 return *((volatile u32 *)(APIC_BASE + reg));
77 static inline void native_apic_msr_write(u32 reg, u32 v)
79 if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR ||
80 reg == APIC_LVR)
81 return;
83 wrmsr(APIC_BASE_MSR + (reg >> 4), v, 0);
86 static inline u32 native_apic_msr_read(u32 reg)
88 u32 low, high;
90 if (reg == APIC_DFR)
91 return -1;
93 rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
94 return low;
97 #ifndef CONFIG_X86_32
98 extern int x2apic, x2apic_preenabled;
99 extern void check_x2apic(void);
100 extern void enable_x2apic(void);
101 extern void enable_IR_x2apic(void);
102 extern void x2apic_icr_write(u32 low, u32 id);
103 #endif
105 struct apic_ops {
106 u32 (*read)(u32 reg);
107 void (*write)(u32 reg, u32 v);
108 u64 (*icr_read)(void);
109 void (*icr_write)(u32 low, u32 high);
110 void (*wait_icr_idle)(void);
111 u32 (*safe_wait_icr_idle)(void);
114 extern struct apic_ops *apic_ops;
116 #define apic_read (apic_ops->read)
117 #define apic_write (apic_ops->write)
118 #define apic_icr_read (apic_ops->icr_read)
119 #define apic_icr_write (apic_ops->icr_write)
120 #define apic_wait_icr_idle (apic_ops->wait_icr_idle)
121 #define safe_apic_wait_icr_idle (apic_ops->safe_wait_icr_idle)
123 extern int get_physical_broadcast(void);
125 #ifdef CONFIG_X86_64
126 static inline void ack_x2APIC_irq(void)
128 /* Docs say use 0 for future compatibility */
129 native_apic_msr_write(APIC_EOI, 0);
131 #endif
134 static inline void ack_APIC_irq(void)
137 * ack_APIC_irq() actually gets compiled as a single instruction
138 * ... yummie.
141 /* Docs say use 0 for future compatibility */
142 apic_write(APIC_EOI, 0);
145 extern int lapic_get_maxlvt(void);
146 extern void clear_local_APIC(void);
147 extern void connect_bsp_APIC(void);
148 extern void disconnect_bsp_APIC(int virt_wire_setup);
149 extern void disable_local_APIC(void);
150 extern void lapic_shutdown(void);
151 extern int verify_local_APIC(void);
152 extern void cache_APIC_registers(void);
153 extern void sync_Arb_IDs(void);
154 extern void init_bsp_APIC(void);
155 extern void setup_local_APIC(void);
156 extern void end_local_APIC_setup(void);
157 extern void init_apic_mappings(void);
158 extern void setup_boot_APIC_clock(void);
159 extern void setup_secondary_APIC_clock(void);
160 extern int APIC_init_uniprocessor(void);
161 extern void enable_NMI_through_LVT0(void);
164 * On 32bit this is mach-xxx local
166 #ifdef CONFIG_X86_64
167 extern void early_init_lapic_mapping(void);
168 extern int apic_is_clustered_box(void);
169 #else
170 static inline int apic_is_clustered_box(void)
172 return 0;
174 #endif
176 extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
177 extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
180 #else /* !CONFIG_X86_LOCAL_APIC */
181 static inline void lapic_shutdown(void) { }
182 #define local_apic_timer_c2_ok 1
183 static inline void init_apic_mappings(void) { }
185 #endif /* !CONFIG_X86_LOCAL_APIC */
187 #endif /* ASM_X86__APIC_H */