Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Written by: Garry Forsgren, Unisys Corporation |
| 3 | * Natalie Protasevich, Unisys Corporation |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * This file contains the code to configure and interface |
| 6 | * with Unisys ES7000 series hardware system manager. |
| 7 | * |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 8 | * Copyright (c) 2003 Unisys Corporation. |
| 9 | * Copyright (C) 2009, Red Hat, Inc., Ingo Molnar |
| 10 | * |
| 11 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify it |
| 14 | * under the terms of version 2 of the GNU General Public License as |
| 15 | * published by the Free Software Foundation. |
| 16 | * |
| 17 | * This program is distributed in the hope that it would be useful, but |
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along |
| 22 | * with this program; if not, write the Free Software Foundation, Inc., 59 |
| 23 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. |
| 24 | * |
| 25 | * Contact information: Unisys Corporation, Township Line & Union Meeting |
| 26 | * Roads-A, Unisys Way, Blue Bell, Pennsylvania, 19424, or: |
| 27 | * |
| 28 | * http://www.unisys.com |
| 29 | */ |
Joe Perches | 5cd476e | 2009-12-09 10:45:33 -0800 | [diff] [blame] | 30 | |
| 31 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <linux/notifier.h> |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 34 | #include <linux/spinlock.h> |
| 35 | #include <linux/cpumask.h> |
| 36 | #include <linux/threads.h> |
| 37 | #include <linux/kernel.h> |
| 38 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include <linux/reboot.h> |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 40 | #include <linux/string.h> |
| 41 | #include <linux/types.h> |
| 42 | #include <linux/errno.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | #include <linux/acpi.h> |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 44 | #include <linux/init.h> |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 45 | #include <linux/nmi.h> |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 46 | #include <linux/smp.h> |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 47 | #include <linux/io.h> |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 48 | |
| 49 | #include <asm/apicdef.h> |
| 50 | #include <asm/atomic.h> |
| 51 | #include <asm/fixmap.h> |
| 52 | #include <asm/mpspec.h> |
| 53 | #include <asm/setup.h> |
| 54 | #include <asm/apic.h> |
| 55 | #include <asm/ipi.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | /* |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 58 | * ES7000 chipsets |
| 59 | */ |
| 60 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 61 | #define NON_UNISYS 0 |
| 62 | #define ES7000_CLASSIC 1 |
| 63 | #define ES7000_ZORRO 2 |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 64 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 65 | #define MIP_REG 1 |
| 66 | #define MIP_PSAI_REG 4 |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 67 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 68 | #define MIP_BUSY 1 |
| 69 | #define MIP_SPIN 0xf0000 |
| 70 | #define MIP_VALID 0x0100000000000000ULL |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 71 | #define MIP_SW_APIC 0x1020b |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 72 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 73 | #define MIP_PORT(val) ((val >> 32) & 0xffff) |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 74 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 75 | #define MIP_RD_LO(val) (val & 0xffffffff) |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 76 | |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 77 | struct mip_reg { |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 78 | unsigned long long off_0x00; |
| 79 | unsigned long long off_0x08; |
| 80 | unsigned long long off_0x10; |
| 81 | unsigned long long off_0x18; |
| 82 | unsigned long long off_0x20; |
| 83 | unsigned long long off_0x28; |
| 84 | unsigned long long off_0x30; |
| 85 | unsigned long long off_0x38; |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 88 | struct mip_reg_info { |
| 89 | unsigned long long mip_info; |
| 90 | unsigned long long delivery_info; |
| 91 | unsigned long long host_reg; |
| 92 | unsigned long long mip_reg; |
| 93 | }; |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 94 | |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 95 | struct psai { |
| 96 | unsigned long long entry_type; |
| 97 | unsigned long long addr; |
| 98 | unsigned long long bep_addr; |
| 99 | }; |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 100 | |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 101 | #ifdef CONFIG_ACPI |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 102 | |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 103 | struct es7000_oem_table { |
| 104 | struct acpi_table_header Header; |
| 105 | u32 OEMTableAddr; |
| 106 | u32 OEMTableSize; |
| 107 | }; |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 108 | |
| 109 | static unsigned long oem_addrX; |
| 110 | static unsigned long oem_size; |
| 111 | |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 112 | #endif |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 113 | |
Yinghai Lu | 1625324 | 2008-08-27 23:01:16 -0700 | [diff] [blame] | 114 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | * ES7000 Globals |
| 116 | */ |
| 117 | |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 118 | static volatile unsigned long *psai; |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 119 | static struct mip_reg *mip_reg; |
| 120 | static struct mip_reg *host_reg; |
| 121 | static int mip_port; |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 122 | static unsigned long mip_addr; |
| 123 | static unsigned long host_addr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 125 | int es7000_plat; |
Alexey Starikovskiy | 32c5061 | 2008-05-14 19:02:51 +0400 | [diff] [blame] | 126 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | /* |
| 128 | * GSI override for ES7000 platforms. |
| 129 | */ |
| 130 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 131 | static unsigned int base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | static int |
| 134 | es7000_rename_gsi(int ioapic, int gsi) |
| 135 | { |
Natalie.Protasevich@unisys.com | 9338316 | 2005-10-30 14:59:38 -0800 | [diff] [blame] | 136 | if (es7000_plat == ES7000_ZORRO) |
| 137 | return gsi; |
| 138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | if (!base) { |
| 140 | int i; |
| 141 | for (i = 0; i < nr_ioapics; i++) |
| 142 | base += nr_ioapic_registers[i]; |
| 143 | } |
| 144 | |
Yinghai Lu | c7e7964 | 2008-07-25 02:17:33 -0700 | [diff] [blame] | 145 | if (!ioapic && (gsi < 16)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | gsi += base; |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 147 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | return gsi; |
| 149 | } |
| 150 | |
Cyrill Gorcunov | 667c529 | 2009-04-19 11:43:11 +0400 | [diff] [blame] | 151 | static int __cpuinit wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip) |
Yinghai Lu | 569712b | 2008-11-16 03:12:49 -0800 | [diff] [blame] | 152 | { |
| 153 | unsigned long vect = 0, psaival = 0; |
| 154 | |
| 155 | if (psai == NULL) |
| 156 | return -1; |
| 157 | |
| 158 | vect = ((unsigned long)__pa(eip)/0x1000) << 16; |
| 159 | psaival = (0x1000000 | vect | cpu); |
| 160 | |
| 161 | while (*psai & 0x1000000) |
| 162 | ; |
| 163 | |
| 164 | *psai = psaival; |
| 165 | |
| 166 | return 0; |
| 167 | } |
Yinghai Lu | 54ac14a | 2008-11-17 15:19:53 -0800 | [diff] [blame] | 168 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 169 | static int es7000_apic_is_cluster(void) |
Yinghai Lu | 54ac14a | 2008-11-17 15:19:53 -0800 | [diff] [blame] | 170 | { |
Yinghai Lu | b5fe363 | 2008-11-18 08:14:14 -0800 | [diff] [blame] | 171 | /* MPENTIUMIII */ |
| 172 | if (boot_cpu_data.x86 == 6 && |
Roel Kluin | 005155b | 2009-08-25 15:35:12 +0200 | [diff] [blame] | 173 | (boot_cpu_data.x86_model >= 7 && boot_cpu_data.x86_model <= 11)) |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 174 | return 1; |
Yinghai Lu | b5fe363 | 2008-11-18 08:14:14 -0800 | [diff] [blame] | 175 | |
Yinghai Lu | 54ac14a | 2008-11-17 15:19:53 -0800 | [diff] [blame] | 176 | return 0; |
| 177 | } |
Yinghai Lu | 569712b | 2008-11-16 03:12:49 -0800 | [diff] [blame] | 178 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 179 | static void setup_unisys(void) |
Natalie.Protasevich@unisys.com | 56f1d5d | 2005-09-03 15:56:34 -0700 | [diff] [blame] | 180 | { |
| 181 | /* |
| 182 | * Determine the generation of the ES7000 currently running. |
| 183 | * |
| 184 | * es7000_plat = 1 if the machine is a 5xx ES7000 box |
| 185 | * es7000_plat = 2 if the machine is a x86_64 ES7000 box |
| 186 | * |
| 187 | */ |
| 188 | if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2)) |
Natalie.Protasevich@unisys.com | 9338316 | 2005-10-30 14:59:38 -0800 | [diff] [blame] | 189 | es7000_plat = ES7000_ZORRO; |
Natalie.Protasevich@unisys.com | 56f1d5d | 2005-09-03 15:56:34 -0700 | [diff] [blame] | 190 | else |
Natalie.Protasevich@unisys.com | 9338316 | 2005-10-30 14:59:38 -0800 | [diff] [blame] | 191 | es7000_plat = ES7000_CLASSIC; |
Natalie.Protasevich@unisys.com | 56f1d5d | 2005-09-03 15:56:34 -0700 | [diff] [blame] | 192 | ioapic_renumber_irq = es7000_rename_gsi; |
| 193 | } |
| 194 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | /* |
Ingo Molnar | d3185b3 | 2009-02-17 15:13:05 +0100 | [diff] [blame] | 196 | * Parse the OEM Table: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | */ |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 198 | static int parse_unisys_oem(char *oemptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | { |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 200 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | int success = 0; |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 202 | unsigned char type, size; |
| 203 | unsigned long val; |
| 204 | char *tp = NULL; |
| 205 | struct psai *psaip = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | struct mip_reg_info *mi; |
| 207 | struct mip_reg *host, *mip; |
| 208 | |
| 209 | tp = oemptr; |
| 210 | |
| 211 | tp += 8; |
| 212 | |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 213 | for (i = 0; i <= 6; i++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | type = *tp++; |
| 215 | size = *tp++; |
| 216 | tp -= 2; |
| 217 | switch (type) { |
| 218 | case MIP_REG: |
| 219 | mi = (struct mip_reg_info *)tp; |
| 220 | val = MIP_RD_LO(mi->host_reg); |
| 221 | host_addr = val; |
| 222 | host = (struct mip_reg *)val; |
| 223 | host_reg = __va(host); |
| 224 | val = MIP_RD_LO(mi->mip_reg); |
| 225 | mip_port = MIP_PORT(mi->mip_info); |
| 226 | mip_addr = val; |
| 227 | mip = (struct mip_reg *)val; |
| 228 | mip_reg = __va(mip); |
Joe Perches | 5cd476e | 2009-12-09 10:45:33 -0800 | [diff] [blame] | 229 | pr_debug("host_reg = 0x%lx\n", |
Thomas Gleixner | 5171c30 | 2008-07-21 21:58:34 +0200 | [diff] [blame] | 230 | (unsigned long)host_reg); |
Joe Perches | 5cd476e | 2009-12-09 10:45:33 -0800 | [diff] [blame] | 231 | pr_debug("mip_reg = 0x%lx\n", |
Thomas Gleixner | 5171c30 | 2008-07-21 21:58:34 +0200 | [diff] [blame] | 232 | (unsigned long)mip_reg); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | success++; |
| 234 | break; |
| 235 | case MIP_PSAI_REG: |
| 236 | psaip = (struct psai *)tp; |
| 237 | if (tp != NULL) { |
| 238 | if (psaip->addr) |
| 239 | psai = __va(psaip->addr); |
| 240 | else |
| 241 | psai = NULL; |
| 242 | success++; |
| 243 | } |
| 244 | break; |
| 245 | default: |
| 246 | break; |
| 247 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | tp += size; |
| 249 | } |
| 250 | |
Ingo Molnar | d3185b3 | 2009-02-17 15:13:05 +0100 | [diff] [blame] | 251 | if (success < 2) |
Natalie.Protasevich@unisys.com | 9338316 | 2005-10-30 14:59:38 -0800 | [diff] [blame] | 252 | es7000_plat = NON_UNISYS; |
Ingo Molnar | d3185b3 | 2009-02-17 15:13:05 +0100 | [diff] [blame] | 253 | else |
Natalie.Protasevich@unisys.com | 56f1d5d | 2005-09-03 15:56:34 -0700 | [diff] [blame] | 254 | setup_unisys(); |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 255 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | return es7000_plat; |
| 257 | } |
| 258 | |
Natalie.Protasevich@unisys.com | e5428ed | 2006-03-23 02:59:36 -0800 | [diff] [blame] | 259 | #ifdef CONFIG_ACPI |
Sam Ravnborg | b74d446 | 2009-05-09 15:35:10 +0600 | [diff] [blame] | 260 | static int __init find_unisys_acpi_oem_table(unsigned long *oem_addr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | { |
Alexey Starikovskiy | ceb6c46 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 262 | struct acpi_table_header *header = NULL; |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 263 | struct es7000_oem_table *table; |
Yinghai Lu | b825e6c | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 264 | acpi_size tbl_size; |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 265 | acpi_status ret; |
| 266 | int i = 0; |
Yinghai Lu | a73aaed | 2008-09-14 02:33:14 -0700 | [diff] [blame] | 267 | |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 268 | for (;;) { |
| 269 | ret = acpi_get_table_with_size("OEM1", i++, &header, &tbl_size); |
| 270 | if (!ACPI_SUCCESS(ret)) |
| 271 | return -1; |
Yinghai Lu | a73aaed | 2008-09-14 02:33:14 -0700 | [diff] [blame] | 272 | |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 273 | if (!memcmp((char *) &header->oem_id, "UNISYS", 6)) |
| 274 | break; |
Yinghai Lu | a73aaed | 2008-09-14 02:33:14 -0700 | [diff] [blame] | 275 | |
Yinghai Lu | b825e6c | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 276 | early_acpi_os_unmap_memory(header, tbl_size); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | } |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 278 | |
| 279 | table = (void *)header; |
| 280 | |
| 281 | oem_addrX = table->OEMTableAddr; |
| 282 | oem_size = table->OEMTableSize; |
| 283 | |
| 284 | early_acpi_os_unmap_memory(header, tbl_size); |
| 285 | |
| 286 | *oem_addr = (unsigned long)__acpi_map_table(oem_addrX, oem_size); |
| 287 | |
| 288 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | } |
Yinghai Lu | a73aaed | 2008-09-14 02:33:14 -0700 | [diff] [blame] | 290 | |
Sam Ravnborg | b74d446 | 2009-05-09 15:35:10 +0600 | [diff] [blame] | 291 | static void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr) |
Yinghai Lu | a73aaed | 2008-09-14 02:33:14 -0700 | [diff] [blame] | 292 | { |
Yinghai Lu | b825e6c | 2009-02-07 15:39:41 -0800 | [diff] [blame] | 293 | if (!oem_addr) |
| 294 | return; |
| 295 | |
| 296 | __acpi_unmap_table((char *)oem_addr, oem_size); |
Yinghai Lu | a73aaed | 2008-09-14 02:33:14 -0700 | [diff] [blame] | 297 | } |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 298 | |
| 299 | static int es7000_check_dsdt(void) |
| 300 | { |
| 301 | struct acpi_table_header header; |
| 302 | |
| 303 | if (ACPI_SUCCESS(acpi_get_table_header(ACPI_SIG_DSDT, 0, &header)) && |
| 304 | !strncmp(header.oem_id, "UNISYS", 6)) |
| 305 | return 1; |
| 306 | return 0; |
| 307 | } |
| 308 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 309 | static int es7000_acpi_ret; |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 310 | |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 311 | /* Hook from generic ACPI tables.c */ |
Sam Ravnborg | b74d446 | 2009-05-09 15:35:10 +0600 | [diff] [blame] | 312 | static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 313 | { |
| 314 | unsigned long oem_addr = 0; |
| 315 | int check_dsdt; |
| 316 | int ret = 0; |
| 317 | |
| 318 | /* check dsdt at first to avoid clear fix_map for oem_addr */ |
| 319 | check_dsdt = es7000_check_dsdt(); |
| 320 | |
| 321 | if (!find_unisys_acpi_oem_table(&oem_addr)) { |
| 322 | if (check_dsdt) { |
| 323 | ret = parse_unisys_oem((char *)oem_addr); |
| 324 | } else { |
| 325 | setup_unisys(); |
| 326 | ret = 1; |
| 327 | } |
| 328 | /* |
| 329 | * we need to unmap it |
| 330 | */ |
| 331 | unmap_unisys_acpi_oem_table(oem_addr); |
| 332 | } |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 333 | |
| 334 | es7000_acpi_ret = ret; |
| 335 | |
| 336 | return ret && !es7000_apic_is_cluster(); |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 337 | } |
Ingo Molnar | 3b900d4 | 2009-02-26 14:34:08 +0100 | [diff] [blame] | 338 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 339 | static int es7000_acpi_madt_oem_check_cluster(char *oem_id, char *oem_table_id) |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 340 | { |
| 341 | int ret = es7000_acpi_ret; |
| 342 | |
| 343 | return ret && es7000_apic_is_cluster(); |
| 344 | } |
| 345 | |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 346 | #else /* !CONFIG_ACPI: */ |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 347 | static int es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id) |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 348 | { |
| 349 | return 0; |
| 350 | } |
Ingo Molnar | 3b900d4 | 2009-02-26 14:34:08 +0100 | [diff] [blame] | 351 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 352 | static int es7000_acpi_madt_oem_check_cluster(char *oem_id, char *oem_table_id) |
Ingo Molnar | 3b900d4 | 2009-02-26 14:34:08 +0100 | [diff] [blame] | 353 | { |
| 354 | return 0; |
| 355 | } |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 356 | #endif /* !CONFIG_ACPI */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 358 | static void es7000_spin(int n) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | { |
| 360 | int i = 0; |
| 361 | |
| 362 | while (i++ < n) |
| 363 | rep_nop(); |
| 364 | } |
| 365 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 366 | static int es7000_mip_write(struct mip_reg *mip_reg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 | { |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 368 | int status = 0; |
| 369 | int spin; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | |
| 371 | spin = MIP_SPIN; |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 372 | while ((host_reg->off_0x38 & MIP_VALID) != 0) { |
| 373 | if (--spin <= 0) { |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 374 | WARN(1, "Timeout waiting for Host Valid Flag\n"); |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 375 | return -1; |
| 376 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | es7000_spin(MIP_SPIN); |
| 378 | } |
| 379 | |
| 380 | memcpy(host_reg, mip_reg, sizeof(struct mip_reg)); |
| 381 | outb(1, mip_port); |
| 382 | |
| 383 | spin = MIP_SPIN; |
| 384 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 385 | while ((mip_reg->off_0x38 & MIP_VALID) == 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | if (--spin <= 0) { |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 387 | WARN(1, "Timeout waiting for MIP Valid Flag\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | return -1; |
| 389 | } |
| 390 | es7000_spin(MIP_SPIN); |
| 391 | } |
| 392 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 393 | status = (mip_reg->off_0x00 & 0xffff0000000000ULL) >> 48; |
| 394 | mip_reg->off_0x38 &= ~MIP_VALID; |
| 395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | return status; |
| 397 | } |
| 398 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 399 | static void es7000_enable_apic_mode(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | { |
Ingo Molnar | b0b20e5 | 2009-01-28 13:15:06 +0100 | [diff] [blame] | 401 | struct mip_reg es7000_mip_reg; |
| 402 | int mip_status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | |
Ingo Molnar | b0b20e5 | 2009-01-28 13:15:06 +0100 | [diff] [blame] | 404 | if (!es7000_plat) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | return; |
Ingo Molnar | b0b20e5 | 2009-01-28 13:15:06 +0100 | [diff] [blame] | 406 | |
Joe Perches | 5cd476e | 2009-12-09 10:45:33 -0800 | [diff] [blame] | 407 | pr_info("Enabling APIC mode.\n"); |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 408 | memset(&es7000_mip_reg, 0, sizeof(struct mip_reg)); |
| 409 | es7000_mip_reg.off_0x00 = MIP_SW_APIC; |
| 410 | es7000_mip_reg.off_0x38 = MIP_VALID; |
Ingo Molnar | b0b20e5 | 2009-01-28 13:15:06 +0100 | [diff] [blame] | 411 | |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 412 | while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0) |
| 413 | WARN(1, "Command failed, status = %x\n", mip_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 415 | |
Rusty Russell | 73e907d | 2009-03-13 14:49:57 +1030 | [diff] [blame] | 416 | static void es7000_vector_allocation_domain(int cpu, struct cpumask *retmask) |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 417 | { |
| 418 | /* Careful. Some cpus do not strictly honor the set of cpus |
| 419 | * specified in the interrupt destination when using lowest |
| 420 | * priority interrupt delivery mode. |
| 421 | * |
| 422 | * In particular there was a hyperthreading cpu observed to |
| 423 | * deliver interrupts to the wrong hyperthread when only one |
| 424 | * hyperthread was specified in the interrupt desitination. |
| 425 | */ |
Rusty Russell | 5c6cb5e | 2009-03-13 14:49:56 +1030 | [diff] [blame] | 426 | cpumask_clear(retmask); |
| 427 | cpumask_bits(retmask)[0] = APIC_ALL_CPUS; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | |
| 431 | static void es7000_wait_for_init_deassert(atomic_t *deassert) |
| 432 | { |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 433 | while (!atomic_read(deassert)) |
| 434 | cpu_relax(); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | static unsigned int es7000_get_apic_id(unsigned long x) |
| 438 | { |
| 439 | return (x >> 24) & 0xFF; |
| 440 | } |
| 441 | |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 442 | static void es7000_send_IPI_mask(const struct cpumask *mask, int vector) |
| 443 | { |
Yinghai Lu | 43f3989 | 2009-01-29 19:31:49 -0800 | [diff] [blame] | 444 | default_send_IPI_mask_sequence_phys(mask, vector); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | static void es7000_send_IPI_allbutself(int vector) |
| 448 | { |
Yinghai Lu | 43f3989 | 2009-01-29 19:31:49 -0800 | [diff] [blame] | 449 | default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | static void es7000_send_IPI_all(int vector) |
| 453 | { |
| 454 | es7000_send_IPI_mask(cpu_online_mask, vector); |
| 455 | } |
| 456 | |
| 457 | static int es7000_apic_id_registered(void) |
| 458 | { |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 459 | return 1; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 460 | } |
| 461 | |
Rusty Russell | 73e907d | 2009-03-13 14:49:57 +1030 | [diff] [blame] | 462 | static const struct cpumask *target_cpus_cluster(void) |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 463 | { |
Rusty Russell | 101aaca | 2009-03-13 14:49:47 +1030 | [diff] [blame] | 464 | return cpu_all_mask; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 465 | } |
| 466 | |
Rusty Russell | 4f06289 | 2009-03-13 14:49:54 +1030 | [diff] [blame] | 467 | static const struct cpumask *es7000_target_cpus(void) |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 468 | { |
Rusty Russell | 4f06289 | 2009-03-13 14:49:54 +1030 | [diff] [blame] | 469 | return cpumask_of(smp_processor_id()); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 470 | } |
| 471 | |
Cyrill Gorcunov | 7abc075 | 2009-11-10 01:06:59 +0300 | [diff] [blame] | 472 | static unsigned long es7000_check_apicid_used(physid_mask_t *map, int apicid) |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 473 | { |
| 474 | return 0; |
| 475 | } |
Cyrill Gorcunov | 7abc075 | 2009-11-10 01:06:59 +0300 | [diff] [blame] | 476 | |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 477 | static unsigned long es7000_check_apicid_present(int bit) |
| 478 | { |
| 479 | return physid_isset(bit, phys_cpu_present_map); |
| 480 | } |
| 481 | |
| 482 | static unsigned long calculate_ldr(int cpu) |
| 483 | { |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 484 | unsigned long id = per_cpu(x86_bios_cpu_apicid, cpu); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 485 | |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 486 | return SET_APIC_LOGICAL_ID(id); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 487 | } |
| 488 | |
| 489 | /* |
| 490 | * Set up the logical destination ID. |
| 491 | * |
| 492 | * Intel recommends to set DFR, LdR and TPR before enabling |
| 493 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel |
| 494 | * document number 292116). So here it goes... |
| 495 | */ |
| 496 | static void es7000_init_apic_ldr_cluster(void) |
| 497 | { |
| 498 | unsigned long val; |
| 499 | int cpu = smp_processor_id(); |
| 500 | |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 501 | apic_write(APIC_DFR, APIC_DFR_CLUSTER); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 502 | val = calculate_ldr(cpu); |
| 503 | apic_write(APIC_LDR, val); |
| 504 | } |
| 505 | |
| 506 | static void es7000_init_apic_ldr(void) |
| 507 | { |
| 508 | unsigned long val; |
| 509 | int cpu = smp_processor_id(); |
| 510 | |
Ingo Molnar | 352887d | 2009-02-17 15:17:55 +0100 | [diff] [blame] | 511 | apic_write(APIC_DFR, APIC_DFR_FLAT); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 512 | val = calculate_ldr(cpu); |
| 513 | apic_write(APIC_LDR, val); |
| 514 | } |
| 515 | |
| 516 | static void es7000_setup_apic_routing(void) |
| 517 | { |
| 518 | int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id()); |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 519 | |
Joe Perches | 5cd476e | 2009-12-09 10:45:33 -0800 | [diff] [blame] | 520 | pr_info("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 521 | (apic_version[apic] == 0x14) ? |
| 522 | "Physical Cluster" : "Logical Cluster", |
Rusty Russell | 4f06289 | 2009-03-13 14:49:54 +1030 | [diff] [blame] | 523 | nr_ioapics, cpumask_bits(es7000_target_cpus())[0]); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | static int es7000_apicid_to_node(int logical_apicid) |
| 527 | { |
| 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | |
| 532 | static int es7000_cpu_present_to_apicid(int mps_cpu) |
| 533 | { |
| 534 | if (!mps_cpu) |
| 535 | return boot_cpu_physical_apicid; |
| 536 | else if (mps_cpu < nr_cpu_ids) |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 537 | return per_cpu(x86_bios_cpu_apicid, mps_cpu); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 538 | else |
| 539 | return BAD_APICID; |
| 540 | } |
| 541 | |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 542 | static int cpu_id; |
| 543 | |
Cyrill Gorcunov | 7abc075 | 2009-11-10 01:06:59 +0300 | [diff] [blame] | 544 | static void es7000_apicid_to_cpu_present(int phys_apicid, physid_mask_t *retmap) |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 545 | { |
Cyrill Gorcunov | 7abc075 | 2009-11-10 01:06:59 +0300 | [diff] [blame] | 546 | physid_set_mask_of_physid(cpu_id, retmap); |
Ingo Molnar | 7da18ed | 2009-02-17 15:29:30 +0100 | [diff] [blame] | 547 | ++cpu_id; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | /* Mapping from cpu number to logical apicid */ |
| 551 | static int es7000_cpu_to_logical_apicid(int cpu) |
| 552 | { |
| 553 | #ifdef CONFIG_SMP |
| 554 | if (cpu >= nr_cpu_ids) |
| 555 | return BAD_APICID; |
Ingo Molnar | 2f205bc | 2009-02-17 14:45:30 +0100 | [diff] [blame] | 556 | return cpu_2_logical_apicid[cpu]; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 557 | #else |
| 558 | return logical_smp_processor_id(); |
| 559 | #endif |
| 560 | } |
| 561 | |
Cyrill Gorcunov | 7abc075 | 2009-11-10 01:06:59 +0300 | [diff] [blame] | 562 | static void es7000_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap) |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 563 | { |
| 564 | /* For clustered we don't have a good way to do this yet - hack */ |
Cyrill Gorcunov | 7abc075 | 2009-11-10 01:06:59 +0300 | [diff] [blame] | 565 | physids_promote(0xFFL, retmap); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | static int es7000_check_phys_apicid_present(int cpu_physical_apicid) |
| 569 | { |
| 570 | boot_cpu_physical_apicid = read_apic_id(); |
Ingo Molnar | 2c4ce18 | 2009-02-17 14:57:16 +0100 | [diff] [blame] | 571 | return 1; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 572 | } |
| 573 | |
Rusty Russell | 73e907d | 2009-03-13 14:49:57 +1030 | [diff] [blame] | 574 | static unsigned int es7000_cpu_mask_to_apicid(const struct cpumask *cpumask) |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 575 | { |
Jiri Slaby | 0edc0b3 | 2009-03-02 10:53:57 +0100 | [diff] [blame] | 576 | unsigned int round = 0; |
| 577 | int cpu, uninitialized_var(apicid); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 578 | |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 579 | /* |
Jiri Slaby | 0edc0b3 | 2009-03-02 10:53:57 +0100 | [diff] [blame] | 580 | * The cpus in the mask must all be on the apic cluster. |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 581 | */ |
Jiri Slaby | 0edc0b3 | 2009-03-02 10:53:57 +0100 | [diff] [blame] | 582 | for_each_cpu(cpu, cpumask) { |
| 583 | int new_apicid = es7000_cpu_to_logical_apicid(cpu); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 584 | |
Jiri Slaby | 0edc0b3 | 2009-03-02 10:53:57 +0100 | [diff] [blame] | 585 | if (round && APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) { |
| 586 | WARN(1, "Not a valid mask!"); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 587 | |
Jiri Slaby | 0edc0b3 | 2009-03-02 10:53:57 +0100 | [diff] [blame] | 588 | return BAD_APICID; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 589 | } |
Jiri Slaby | 0edc0b3 | 2009-03-02 10:53:57 +0100 | [diff] [blame] | 590 | apicid = new_apicid; |
| 591 | round++; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 592 | } |
| 593 | return apicid; |
| 594 | } |
| 595 | |
| 596 | static unsigned int |
| 597 | es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask, |
| 598 | const struct cpumask *andmask) |
| 599 | { |
| 600 | int apicid = es7000_cpu_to_logical_apicid(0); |
| 601 | cpumask_var_t cpumask; |
| 602 | |
| 603 | if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC)) |
| 604 | return apicid; |
| 605 | |
| 606 | cpumask_and(cpumask, inmask, andmask); |
| 607 | cpumask_and(cpumask, cpumask, cpu_online_mask); |
| 608 | apicid = es7000_cpu_mask_to_apicid(cpumask); |
| 609 | |
| 610 | free_cpumask_var(cpumask); |
| 611 | |
| 612 | return apicid; |
| 613 | } |
| 614 | |
| 615 | static int es7000_phys_pkg_id(int cpuid_apic, int index_msb) |
| 616 | { |
| 617 | return cpuid_apic >> index_msb; |
| 618 | } |
| 619 | |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 620 | static int probe_es7000(void) |
| 621 | { |
| 622 | /* probed later in mptable/ACPI hooks */ |
| 623 | return 0; |
| 624 | } |
| 625 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 626 | static int es7000_mps_ret; |
| 627 | static int es7000_mps_oem_check(struct mpc_table *mpc, char *oem, |
| 628 | char *productid) |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 629 | { |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 630 | int ret = 0; |
| 631 | |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 632 | if (mpc->oemptr) { |
| 633 | struct mpc_oemtable *oem_table = |
| 634 | (struct mpc_oemtable *)mpc->oemptr; |
| 635 | |
| 636 | if (!strncmp(oem, "UNISYS", 6)) |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 637 | ret = parse_unisys_oem((char *)oem_table); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 638 | } |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 639 | |
| 640 | es7000_mps_ret = ret; |
| 641 | |
| 642 | return ret && !es7000_apic_is_cluster(); |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 643 | } |
| 644 | |
Jiri Slaby | 871d78c | 2009-03-02 11:34:27 +0100 | [diff] [blame] | 645 | static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem, |
| 646 | char *productid) |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 647 | { |
| 648 | int ret = es7000_mps_ret; |
| 649 | |
| 650 | return ret && es7000_apic_is_cluster(); |
| 651 | } |
| 652 | |
Rakib Mullick | 151586d | 2009-07-12 17:04:12 +0600 | [diff] [blame] | 653 | /* We've been warned by a false positive warning.Use __refdata to keep calm. */ |
| 654 | struct apic __refdata apic_es7000_cluster = { |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 655 | |
| 656 | .name = "es7000", |
| 657 | .probe = probe_es7000, |
| 658 | .acpi_madt_oem_check = es7000_acpi_madt_oem_check_cluster, |
| 659 | .apic_id_registered = es7000_apic_id_registered, |
| 660 | |
| 661 | .irq_delivery_mode = dest_LowestPrio, |
| 662 | /* logical delivery broadcast to all procs: */ |
| 663 | .irq_dest_mode = 1, |
| 664 | |
| 665 | .target_cpus = target_cpus_cluster, |
| 666 | .disable_esr = 1, |
| 667 | .dest_logical = 0, |
| 668 | .check_apicid_used = es7000_check_apicid_used, |
| 669 | .check_apicid_present = es7000_check_apicid_present, |
| 670 | |
| 671 | .vector_allocation_domain = es7000_vector_allocation_domain, |
| 672 | .init_apic_ldr = es7000_init_apic_ldr_cluster, |
| 673 | |
| 674 | .ioapic_phys_id_map = es7000_ioapic_phys_id_map, |
| 675 | .setup_apic_routing = es7000_setup_apic_routing, |
| 676 | .multi_timer_check = NULL, |
| 677 | .apicid_to_node = es7000_apicid_to_node, |
| 678 | .cpu_to_logical_apicid = es7000_cpu_to_logical_apicid, |
| 679 | .cpu_present_to_apicid = es7000_cpu_present_to_apicid, |
| 680 | .apicid_to_cpu_present = es7000_apicid_to_cpu_present, |
| 681 | .setup_portio_remap = NULL, |
| 682 | .check_phys_apicid_present = es7000_check_phys_apicid_present, |
| 683 | .enable_apic_mode = es7000_enable_apic_mode, |
| 684 | .phys_pkg_id = es7000_phys_pkg_id, |
| 685 | .mps_oem_check = es7000_mps_oem_check_cluster, |
| 686 | |
| 687 | .get_apic_id = es7000_get_apic_id, |
| 688 | .set_apic_id = NULL, |
| 689 | .apic_id_mask = 0xFF << 24, |
| 690 | |
Jiri Slaby | c2b20cb | 2009-03-02 10:53:56 +0100 | [diff] [blame] | 691 | .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 692 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, |
| 693 | |
| 694 | .send_IPI_mask = es7000_send_IPI_mask, |
| 695 | .send_IPI_mask_allbutself = NULL, |
| 696 | .send_IPI_allbutself = es7000_send_IPI_allbutself, |
| 697 | .send_IPI_all = es7000_send_IPI_all, |
| 698 | .send_IPI_self = default_send_IPI_self, |
| 699 | |
Ingo Molnar | 1f5bcab | 2009-02-26 13:51:40 +0100 | [diff] [blame] | 700 | .wakeup_secondary_cpu = wakeup_secondary_cpu_via_mip, |
Yinghai Lu | 2b6163b | 2009-02-25 20:50:49 -0800 | [diff] [blame] | 701 | |
| 702 | .trampoline_phys_low = 0x467, |
| 703 | .trampoline_phys_high = 0x469, |
| 704 | |
| 705 | .wait_for_init_deassert = NULL, |
| 706 | |
| 707 | /* Nothing to do for most platforms, since cleared by the INIT cycle: */ |
| 708 | .smp_callin_clear_local_apic = NULL, |
| 709 | .inquire_remote_apic = default_inquire_remote_apic, |
| 710 | |
| 711 | .read = native_apic_mem_read, |
| 712 | .write = native_apic_mem_write, |
| 713 | .icr_read = native_apic_icr_read, |
| 714 | .icr_write = native_apic_icr_write, |
| 715 | .wait_icr_idle = native_apic_wait_icr_idle, |
| 716 | .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, |
| 717 | }; |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 718 | |
Sam Ravnborg | b74d446 | 2009-05-09 15:35:10 +0600 | [diff] [blame] | 719 | struct apic __refdata apic_es7000 = { |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 720 | |
| 721 | .name = "es7000", |
| 722 | .probe = probe_es7000, |
| 723 | .acpi_madt_oem_check = es7000_acpi_madt_oem_check, |
| 724 | .apic_id_registered = es7000_apic_id_registered, |
| 725 | |
| 726 | .irq_delivery_mode = dest_Fixed, |
| 727 | /* phys delivery to target CPUs: */ |
| 728 | .irq_dest_mode = 0, |
| 729 | |
| 730 | .target_cpus = es7000_target_cpus, |
| 731 | .disable_esr = 1, |
| 732 | .dest_logical = 0, |
| 733 | .check_apicid_used = es7000_check_apicid_used, |
| 734 | .check_apicid_present = es7000_check_apicid_present, |
| 735 | |
| 736 | .vector_allocation_domain = es7000_vector_allocation_domain, |
| 737 | .init_apic_ldr = es7000_init_apic_ldr, |
| 738 | |
| 739 | .ioapic_phys_id_map = es7000_ioapic_phys_id_map, |
| 740 | .setup_apic_routing = es7000_setup_apic_routing, |
| 741 | .multi_timer_check = NULL, |
| 742 | .apicid_to_node = es7000_apicid_to_node, |
| 743 | .cpu_to_logical_apicid = es7000_cpu_to_logical_apicid, |
| 744 | .cpu_present_to_apicid = es7000_cpu_present_to_apicid, |
| 745 | .apicid_to_cpu_present = es7000_apicid_to_cpu_present, |
| 746 | .setup_portio_remap = NULL, |
| 747 | .check_phys_apicid_present = es7000_check_phys_apicid_present, |
| 748 | .enable_apic_mode = es7000_enable_apic_mode, |
| 749 | .phys_pkg_id = es7000_phys_pkg_id, |
| 750 | .mps_oem_check = es7000_mps_oem_check, |
| 751 | |
| 752 | .get_apic_id = es7000_get_apic_id, |
| 753 | .set_apic_id = NULL, |
| 754 | .apic_id_mask = 0xFF << 24, |
| 755 | |
| 756 | .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid, |
| 757 | .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and, |
| 758 | |
| 759 | .send_IPI_mask = es7000_send_IPI_mask, |
| 760 | .send_IPI_mask_allbutself = NULL, |
| 761 | .send_IPI_allbutself = es7000_send_IPI_allbutself, |
| 762 | .send_IPI_all = es7000_send_IPI_all, |
Ingo Molnar | 6b64ee0 | 2009-01-30 23:42:18 +0100 | [diff] [blame] | 763 | .send_IPI_self = default_send_IPI_self, |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 764 | |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 765 | .trampoline_phys_low = 0x467, |
| 766 | .trampoline_phys_high = 0x469, |
| 767 | |
| 768 | .wait_for_init_deassert = es7000_wait_for_init_deassert, |
| 769 | |
| 770 | /* Nothing to do for most platforms, since cleared by the INIT cycle: */ |
| 771 | .smp_callin_clear_local_apic = NULL, |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 772 | .inquire_remote_apic = default_inquire_remote_apic, |
Yinghai Lu | c1eeb2d | 2009-02-16 23:02:14 -0800 | [diff] [blame] | 773 | |
| 774 | .read = native_apic_mem_read, |
| 775 | .write = native_apic_mem_write, |
| 776 | .icr_read = native_apic_icr_read, |
| 777 | .icr_write = native_apic_icr_write, |
| 778 | .wait_icr_idle = native_apic_wait_icr_idle, |
| 779 | .safe_wait_icr_idle = native_safe_apic_wait_icr_idle, |
Ingo Molnar | 2e096df | 2009-01-28 19:01:05 +0100 | [diff] [blame] | 780 | }; |