2 * Written by: Garry Forsgren, Unisys Corporation
3 * Natalie Protasevich, Unisys Corporation
4 * This file contains the code to configure and interface
5 * with Unisys ES7000 series hardware system manager.
7 * Copyright (c) 2003 Unisys Corporation. All Rights Reserved.
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it would be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write the Free Software Foundation, Inc., 59
19 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
21 * Contact information: Unisys Corporation, Township Line & Union Meeting
22 * Roads-A, Unisys Way, Blue Bell, Pennsylvania, 19424, or:
24 * http://www.unisys.com
27 #include <linux/module.h>
28 #include <linux/types.h>
29 #include <linux/kernel.h>
30 #include <linux/smp.h>
31 #include <linux/string.h>
32 #include <linux/spinlock.h>
33 #include <linux/errno.h>
34 #include <linux/notifier.h>
35 #include <linux/reboot.h>
36 #include <linux/init.h>
37 #include <linux/acpi.h>
41 #include <asm/apicdef.h>
42 #include <mach_mpparse.h>
49 #define ES7000_CLASSIC 1
50 #define ES7000_ZORRO 2
54 #define MIP_PSAI_REG 4
57 #define MIP_SPIN 0xf0000
58 #define MIP_VALID 0x0100000000000000ULL
59 #define MIP_PORT(VALUE) ((VALUE >> 32) & 0xffff)
61 #define MIP_RD_LO(VALUE) (VALUE & 0xffffffff)
64 unsigned long long mip_info;
65 unsigned long long delivery_info;
66 unsigned long long host_reg;
67 unsigned long long mip_reg;
73 unsigned char part_id;
74 unsigned char apic_mode;
82 unsigned long long entry_type;
83 unsigned long long addr;
84 unsigned long long bep_addr;
87 struct es7000_mem_info {
90 unsigned char resv[6];
91 unsigned long long start;
92 unsigned long long size;
95 struct es7000_oem_table {
96 unsigned long long hdr;
97 struct mip_reg_info mip;
99 struct es7000_mem_info shm;
106 struct acpi_table_header Header;
111 extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
112 extern void unmap_unisys_acpi_oem_table(unsigned long oem_addr);
116 unsigned long long off_0;
117 unsigned long long off_8;
118 unsigned long long off_10;
119 unsigned long long off_18;
120 unsigned long long off_20;
121 unsigned long long off_28;
122 unsigned long long off_30;
123 unsigned long long off_38;
126 #define MIP_SW_APIC 0x1020b
127 #define MIP_FUNC(VALUE) (VALUE & 0xff)
133 static volatile unsigned long *psai = NULL;
134 static struct mip_reg *mip_reg;
135 static struct mip_reg *host_reg;
137 static unsigned long mip_addr, host_addr;
142 * GSI override for ES7000 platforms.
145 static unsigned int base;
148 es7000_rename_gsi(int ioapic, int gsi)
150 if (es7000_plat == ES7000_ZORRO)
155 for (i = 0; i < nr_ioapics; i++)
156 base += nr_ioapic_registers[i];
159 if (!ioapic && (gsi < 16))
168 * Determine the generation of the ES7000 currently running.
170 * es7000_plat = 1 if the machine is a 5xx ES7000 box
171 * es7000_plat = 2 if the machine is a x86_64 ES7000 box
174 if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
175 es7000_plat = ES7000_ZORRO;
177 es7000_plat = ES7000_CLASSIC;
178 ioapic_renumber_irq = es7000_rename_gsi;
182 * Parse the OEM Table
186 parse_unisys_oem (char *oemptr)
190 unsigned char type, size;
193 struct psai *psaip = NULL;
194 struct mip_reg_info *mi;
195 struct mip_reg *host, *mip;
201 for (i=0; i <= 6; i++) {
207 mi = (struct mip_reg_info *)tp;
208 val = MIP_RD_LO(mi->host_reg);
210 host = (struct mip_reg *)val;
211 host_reg = __va(host);
212 val = MIP_RD_LO(mi->mip_reg);
213 mip_port = MIP_PORT(mi->mip_info);
215 mip = (struct mip_reg *)val;
217 pr_debug("es7000_mipcfg: host_reg = 0x%lx \n",
218 (unsigned long)host_reg);
219 pr_debug("es7000_mipcfg: mip_reg = 0x%lx \n",
220 (unsigned long)mip_reg);
224 psaip = (struct psai *)tp;
227 psai = __va(psaip->addr);
240 es7000_plat = NON_UNISYS;
247 static unsigned long oem_addrX;
248 static unsigned long oem_size;
249 int __init find_unisys_acpi_oem_table(unsigned long *oem_addr)
251 struct acpi_table_header *header = NULL;
254 while (ACPI_SUCCESS(acpi_get_table("OEM1", i++, &header))) {
255 if (!memcmp((char *) &header->oem_id, "UNISYS", 6)) {
256 struct oem_table *t = (struct oem_table *)header;
258 oem_addrX = t->OEMTableAddr;
259 oem_size = t->OEMTableSize;
261 *oem_addr = (unsigned long)__acpi_map_table(oem_addrX,
269 void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr)
284 es7000_mip_write(struct mip_reg *mip_reg)
290 while (((unsigned long long)host_reg->off_38 &
291 (unsigned long long)MIP_VALID) != 0) {
293 printk("es7000_mip_write: Timeout waiting for Host Valid Flag");
296 es7000_spin(MIP_SPIN);
299 memcpy(host_reg, mip_reg, sizeof(struct mip_reg));
304 while (((unsigned long long)mip_reg->off_38 &
305 (unsigned long long)MIP_VALID) == 0) {
307 printk("es7000_mip_write: Timeout waiting for MIP Valid Flag");
310 es7000_spin(MIP_SPIN);
313 status = ((unsigned long long)mip_reg->off_0 &
314 (unsigned long long)0xffff0000000000ULL) >> 48;
315 mip_reg->off_38 = ((unsigned long long)mip_reg->off_38 &
316 (unsigned long long)~MIP_VALID);
321 es7000_start_cpu(int cpu, unsigned long eip)
323 unsigned long vect = 0, psaival = 0;
328 vect = ((unsigned long)__pa(eip)/0x1000) << 16;
329 psaival = (0x1000000 | vect | cpu);
331 while (*psai & 0x1000000)
345 struct mip_reg es7000_mip_reg;
347 printk("ES7000: Enabling APIC mode.\n");
348 memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
349 es7000_mip_reg.off_0 = MIP_SW_APIC;
350 es7000_mip_reg.off_38 = (MIP_VALID);
351 while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0)
352 printk("es7000_sw_apic: command failed, status = %x\n",