d36642e6d908c44b15093ee6871aeeb7927be090
[sfrench/cifs-2.6.git] / arch / x86 / mach-generic / es7000.c
1 /*
2  * APIC driver for the Unisys ES7000 chipset.
3  */
4 #define APIC_DEFINITION 1
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>
13 #include <linux/init.h>
14 #include <asm/es7000/apicdef.h>
15 #include <linux/smp.h>
16 #include <asm/es7000/apic.h>
17 #include <asm/es7000/ipi.h>
18 #include <asm/es7000/mpparse.h>
19 #include <asm/mach-default/mach_wakecpu.h>
20
21 void __init es7000_update_genapic_to_cluster(void)
22 {
23         apic->target_cpus = target_cpus_cluster;
24         apic->irq_delivery_mode = INT_DELIVERY_MODE_CLUSTER;
25         apic->irq_dest_mode = INT_DEST_MODE_CLUSTER;
26
27         apic->init_apic_ldr = es7000_init_apic_ldr_cluster;
28
29         apic->cpu_mask_to_apicid = es7000_cpu_mask_to_apicid_cluster;
30 }
31
32 static int probe_es7000(void)
33 {
34         /* probed later in mptable/ACPI hooks */
35         return 0;
36 }
37
38 static __init int
39 es7000_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
40 {
41         if (mpc->oemptr) {
42                 struct mpc_oemtable *oem_table =
43                         (struct mpc_oemtable *)mpc->oemptr;
44
45                 if (!strncmp(oem, "UNISYS", 6))
46                         return parse_unisys_oem((char *)oem_table);
47         }
48         return 0;
49 }
50
51 #ifdef CONFIG_ACPI
52 /* Hook from generic ACPI tables.c */
53 static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
54 {
55         unsigned long oem_addr = 0;
56         int check_dsdt;
57         int ret = 0;
58
59         /* check dsdt at first to avoid clear fix_map for oem_addr */
60         check_dsdt = es7000_check_dsdt();
61
62         if (!find_unisys_acpi_oem_table(&oem_addr)) {
63                 if (check_dsdt)
64                         ret = parse_unisys_oem((char *)oem_addr);
65                 else {
66                         setup_unisys();
67                         ret = 1;
68                 }
69                 /*
70                  * we need to unmap it
71                  */
72                 unmap_unisys_acpi_oem_table(oem_addr);
73         }
74         return ret;
75 }
76 #else
77 static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
78 {
79         return 0;
80 }
81 #endif
82
83 static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask)
84 {
85         /* Careful. Some cpus do not strictly honor the set of cpus
86          * specified in the interrupt destination when using lowest
87          * priority interrupt delivery mode.
88          *
89          * In particular there was a hyperthreading cpu observed to
90          * deliver interrupts to the wrong hyperthread when only one
91          * hyperthread was specified in the interrupt desitination.
92          */
93         *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
94 }
95
96 struct genapic apic_es7000 = {
97
98         .name                           = "es7000",
99         .probe                          = probe_es7000,
100         .acpi_madt_oem_check            = es7000_acpi_madt_oem_check,
101         .apic_id_registered             = es7000_apic_id_registered,
102
103         .irq_delivery_mode              = dest_Fixed,
104         /* phys delivery to target CPUs: */
105         .irq_dest_mode                  = 0,
106
107         .target_cpus                    = es7000_target_cpus,
108         .disable_esr                    = 1,
109         .dest_logical                   = 0,
110         .check_apicid_used              = es7000_check_apicid_used,
111         .check_apicid_present           = es7000_check_apicid_present,
112
113         .vector_allocation_domain       = es7000_vector_allocation_domain,
114         .init_apic_ldr                  = es7000_init_apic_ldr,
115
116         .ioapic_phys_id_map             = es7000_ioapic_phys_id_map,
117         .setup_apic_routing             = es7000_setup_apic_routing,
118         .multi_timer_check              = NULL,
119         .apicid_to_node                 = es7000_apicid_to_node,
120         .cpu_to_logical_apicid          = es7000_cpu_to_logical_apicid,
121         .cpu_present_to_apicid          = es7000_cpu_present_to_apicid,
122         .apicid_to_cpu_present          = es7000_apicid_to_cpu_present,
123         .setup_portio_remap             = NULL,
124         .check_phys_apicid_present      = es7000_check_phys_apicid_present,
125         .enable_apic_mode               = es7000_enable_apic_mode,
126         .phys_pkg_id                    = es7000_phys_pkg_id,
127         .mps_oem_check                  = es7000_mps_oem_check,
128
129         .get_apic_id                    = es7000_get_apic_id,
130         .set_apic_id                    = NULL,
131         .apic_id_mask                   = 0xFF << 24,
132
133         .cpu_mask_to_apicid             = es7000_cpu_mask_to_apicid,
134         .cpu_mask_to_apicid_and         = es7000_cpu_mask_to_apicid_and,
135
136         .send_IPI_mask                  = es7000_send_IPI_mask,
137         .send_IPI_mask_allbutself       = NULL,
138         .send_IPI_allbutself            = es7000_send_IPI_allbutself,
139         .send_IPI_all                   = es7000_send_IPI_all,
140         .send_IPI_self                  = NULL,
141
142         .wakeup_cpu                     = NULL,
143         .trampoline_phys_low            = TRAMPOLINE_PHYS_LOW,
144         .trampoline_phys_high           = TRAMPOLINE_PHYS_HIGH,
145         .wait_for_init_deassert         = wait_for_init_deassert,
146         .smp_callin_clear_local_apic    = smp_callin_clear_local_apic,
147         .store_NMI_vector               = store_NMI_vector,
148         .restore_NMI_vector             = restore_NMI_vector,
149         .inquire_remote_apic            = inquire_remote_apic,
150 };