x86: clean up the APIC_DEST_LOGICAL logic
[linux-2.6-block.git] / arch / x86 / mach-generic / es7000.c
CommitLineData
1da177e4
LT
1/*
2 * APIC driver for the Unisys ES7000 chipset.
3 */
4#define APIC_DEFINITION 1
1da177e4
LT
5#include <linux/threads.h>
6#include <linux/cpumask.h>
7#include <asm/mpspec.h>
8#include <asm/genapic.h>
9#include <asm/fixmap.h>
10#include <asm/apicdef.h>
11#include <linux/kernel.h>
12#include <linux/string.h>
1da177e4 13#include <linux/init.h>
c7e7964c 14#include <asm/es7000/apicdef.h>
4696ca5b 15#include <linux/smp.h>
c7e7964c
YL
16#include <asm/es7000/apic.h>
17#include <asm/es7000/ipi.h>
18#include <asm/es7000/mpparse.h>
b5fe363b
YL
19#include <asm/mach-default/mach_wakecpu.h>
20
21void __init es7000_update_genapic_to_cluster(void)
22{
c8d46cf0 23 apic->target_cpus = target_cpus_cluster;
f8987a10
IM
24 apic->irq_delivery_mode = INT_DELIVERY_MODE_CLUSTER;
25 apic->irq_dest_mode = INT_DEST_MODE_CLUSTER;
c8d46cf0 26 apic->no_balance_irq = NO_BALANCE_IRQ_CLUSTER;
b5fe363b 27
c8d46cf0 28 apic->init_apic_ldr = init_apic_ldr_cluster;
b5fe363b 29
c8d46cf0 30 apic->cpu_mask_to_apicid = cpu_mask_to_apicid_cluster;
b5fe363b 31}
1da177e4 32
e96763d6 33static int probe_es7000(void)
1da177e4
LT
34{
35 /* probed later in mptable/ACPI hooks */
36 return 0;
37}
38
1833d6bc
VG
39extern void es7000_sw_apic(void);
40static void __init enable_apic_mode(void)
41{
42 es7000_sw_apic();
43 return;
44}
45
f29521e4
JSR
46static __init int
47mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
1833d6bc 48{
6c65da50 49 if (mpc->oemptr) {
b0e239ff 50 struct mpc_oemtable *oem_table =
6c65da50 51 (struct mpc_oemtable *)mpc->oemptr;
1833d6bc
VG
52 if (!strncmp(oem, "UNISYS", 6))
53 return parse_unisys_oem((char *)oem_table);
54 }
55 return 0;
56}
57
58#ifdef CONFIG_ACPI
59/* Hook from generic ACPI tables.c */
306db03b 60static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
1833d6bc 61{
a73aaedd
YL
62 unsigned long oem_addr = 0;
63 int check_dsdt;
64 int ret = 0;
65
66 /* check dsdt at first to avoid clear fix_map for oem_addr */
67 check_dsdt = es7000_check_dsdt();
68
1833d6bc 69 if (!find_unisys_acpi_oem_table(&oem_addr)) {
a73aaedd
YL
70 if (check_dsdt)
71 ret = parse_unisys_oem((char *)oem_addr);
1833d6bc
VG
72 else {
73 setup_unisys();
a73aaedd 74 ret = 1;
1833d6bc 75 }
a73aaedd
YL
76 /*
77 * we need to unmap it
78 */
79 unmap_unisys_acpi_oem_table(oem_addr);
1833d6bc 80 }
a73aaedd 81 return ret;
1833d6bc
VG
82}
83#else
306db03b 84static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
1833d6bc
VG
85{
86 return 0;
87}
88#endif
89
e7986739 90static void vector_allocation_domain(int cpu, cpumask_t *retmask)
497c9a19
YL
91{
92 /* Careful. Some cpus do not strictly honor the set of cpus
93 * specified in the interrupt destination when using lowest
94 * priority interrupt delivery mode.
95 *
96 * In particular there was a hyperthreading cpu observed to
97 * deliver interrupts to the wrong hyperthread when only one
98 * hyperthread was specified in the interrupt desitination.
99 */
e7986739 100 *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
497c9a19
YL
101}
102
fed53ebf
IM
103struct genapic apic_es7000 = {
104
105 .name = "es7000",
106 .probe = probe_es7000,
306db03b 107 .acpi_madt_oem_check = es7000_acpi_madt_oem_check,
7ed248da 108 .apic_id_registered = es7000_apic_id_registered,
fed53ebf 109
38bd77a6
IM
110 .irq_delivery_mode = dest_Fixed,
111 /* phys delivery to target CPUs: */
112 .irq_dest_mode = 0,
fed53ebf 113
0a9cc20b 114 .target_cpus = es7000_target_cpus,
08125d3e 115 .disable_esr = 1,
0b06e734 116 .apic_destination_logical = 0,
fed53ebf
IM
117 .check_apicid_used = check_apicid_used,
118 .check_apicid_present = check_apicid_present,
119
120 .no_balance_irq = NO_BALANCE_IRQ,
121 .no_ioapic_check = 0,
122
123 .vector_allocation_domain = vector_allocation_domain,
124 .init_apic_ldr = init_apic_ldr,
125
126 .ioapic_phys_id_map = ioapic_phys_id_map,
127 .setup_apic_routing = setup_apic_routing,
128 .multi_timer_check = multi_timer_check,
129 .apicid_to_node = apicid_to_node,
130 .cpu_to_logical_apicid = cpu_to_logical_apicid,
131 .cpu_present_to_apicid = cpu_present_to_apicid,
132 .apicid_to_cpu_present = apicid_to_cpu_present,
133 .setup_portio_remap = setup_portio_remap,
134 .check_phys_apicid_present = check_phys_apicid_present,
135 .enable_apic_mode = enable_apic_mode,
136 .phys_pkg_id = phys_pkg_id,
137 .mps_oem_check = mps_oem_check,
138
139 .get_apic_id = get_apic_id,
140 .set_apic_id = NULL,
141 .apic_id_mask = APIC_ID_MASK,
142
143 .cpu_mask_to_apicid = cpu_mask_to_apicid,
144 .cpu_mask_to_apicid_and = cpu_mask_to_apicid_and,
145
146 .send_IPI_mask = send_IPI_mask,
147 .send_IPI_mask_allbutself = NULL,
148 .send_IPI_allbutself = send_IPI_allbutself,
149 .send_IPI_all = send_IPI_all,
150 .send_IPI_self = NULL,
151
152 .wakeup_cpu = NULL,
153 .trampoline_phys_low = TRAMPOLINE_PHYS_LOW,
154 .trampoline_phys_high = TRAMPOLINE_PHYS_HIGH,
155 .wait_for_init_deassert = wait_for_init_deassert,
156 .smp_callin_clear_local_apic = smp_callin_clear_local_apic,
157 .store_NMI_vector = store_NMI_vector,
158 .restore_NMI_vector = restore_NMI_vector,
159 .inquire_remote_apic = inquire_remote_apic,
160};