blob: a8344ba6ea15064cd4898423c9b3fcd8183b25e1 [file] [log] [blame]
Yinghai Luedb181a2008-07-25 02:17:55 -07001#ifndef __ASM_NUMAQ_APIC_H
2#define __ASM_NUMAQ_APIC_H
Linus Torvalds1da177e2005-04-16 15:20:36 -07003
4#include <asm/io.h>
5#include <linux/mmzone.h>
6#include <linux/nodemask.h>
7
8#define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
9
10static inline cpumask_t target_cpus(void)
11{
12 return CPU_MASK_ALL;
13}
14
15#define TARGET_CPUS (target_cpus())
16
17#define NO_BALANCE_IRQ (1)
18#define esr_disable (1)
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#define INT_DELIVERY_MODE dest_LowestPrio
21#define INT_DEST_MODE 0 /* physical delivery on LOCAL quad */
22
Yinghai Lud49c4282008-06-08 18:31:54 -070023static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
24{
25 return physid_isset(apicid, bitmap);
26}
27static inline unsigned long check_apicid_present(int bit)
28{
29 return physid_isset(bit, phys_cpu_present_map);
30}
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#define apicid_cluster(apicid) (apicid & 0xF0)
32
33static inline int apic_id_registered(void)
34{
35 return 1;
36}
37
38static inline void init_apic_ldr(void)
39{
40 /* Already done in NUMA-Q firmware */
41}
42
Ingo Molnar3c43f032007-05-02 19:27:04 +020043static inline void setup_apic_routing(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
45 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
46 "NUMA-Q", nr_ioapics);
47}
48
49/*
50 * Skip adding the timer int on secondary nodes, which causes
51 * a small but painful rift in the time-space continuum.
52 */
53static inline int multi_timer_check(int apic, int irq)
54{
55 return apic != 0 && irq == 0;
56}
57
58static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
59{
60 /* We don't have a good way to do this yet - hack */
61 return physids_promote(0xFUL);
62}
63
64/* Mapping from cpu number to logical apicid */
65extern u8 cpu_2_logical_apicid[];
66static inline int cpu_to_logical_apicid(int cpu)
67{
68 if (cpu >= NR_CPUS)
69 return BAD_APICID;
70 return (int)cpu_2_logical_apicid[cpu];
71}
72
73/*
74 * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
75 * cpu to APIC ID relation to properly interact with the intelligent
76 * mode of the cluster controller.
77 */
78static inline int cpu_present_to_apicid(int mps_cpu)
79{
80 if (mps_cpu < 60)
81 return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
82 else
83 return BAD_APICID;
84}
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086static inline int apicid_to_node(int logical_apicid)
87{
88 return logical_apicid >> 4;
89}
90
91static inline physid_mask_t apicid_to_cpu_present(int logical_apicid)
92{
93 int node = apicid_to_node(logical_apicid);
94 int cpu = __ffs(logical_apicid & 0xf);
95
96 return physid_mask_of_physid(cpu + 4*node);
97}
98
Andi Kleenc7e844f2008-02-04 16:48:03 +010099extern void *xquad_portio;
100
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101static inline void setup_portio_remap(void)
102{
103 int num_quads = num_online_nodes();
104
105 if (num_quads <= 1)
106 return;
107
108 printk("Remapping cross-quad port I/O for %d quads\n", num_quads);
109 xquad_portio = ioremap(XQUAD_PORTIO_BASE, num_quads*XQUAD_PORTIO_QUAD);
110 printk("xquad_portio vaddr 0x%08lx, len %08lx\n",
111 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
112}
113
114static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
115{
116 return (1);
117}
118
119static inline void enable_apic_mode(void)
120{
121}
122
123/*
124 * We use physical apicids here, not logical, so just return the default
125 * physical broadcast to stop people from breaking us
126 */
127static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
128{
129 return (int) 0xF;
130}
131
132/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
133static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
134{
135 return cpuid_apic >> index_msb;
136}
137
Yinghai Luedb181a2008-07-25 02:17:55 -0700138#endif /* __ASM_NUMAQ_APIC_H */