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>
48 volatile unsigned long *psai = NULL;
49 struct mip_reg *mip_reg;
50 struct mip_reg *host_reg;
52 unsigned long mip_addr, host_addr;
54 #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI)
57 * GSI override for ES7000 platforms.
60 static unsigned int base;
63 es7000_rename_gsi(int ioapic, int gsi)
67 for (i = 0; i < nr_ioapics; i++)
68 base += nr_ioapic_registers[i];
71 if (!ioapic && (gsi < 16))
76 #endif /* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */
83 parse_unisys_oem (char *oemptr, int oem_entries)
87 unsigned char type, size;
90 struct psai *psaip = NULL;
91 struct mip_reg_info *mi;
92 struct mip_reg *host, *mip;
98 for (i=0; i <= oem_entries; i++) {
104 mi = (struct mip_reg_info *)tp;
105 val = MIP_RD_LO(mi->host_reg);
107 host = (struct mip_reg *)val;
108 host_reg = __va(host);
109 val = MIP_RD_LO(mi->mip_reg);
110 mip_port = MIP_PORT(mi->mip_info);
112 mip = (struct mip_reg *)val;
114 Dprintk("es7000_mipcfg: host_reg = 0x%lx \n",
115 (unsigned long)host_reg);
116 Dprintk("es7000_mipcfg: mip_reg = 0x%lx \n",
117 (unsigned long)mip_reg);
121 psaip = (struct psai *)tp;
124 psai = __va(psaip->addr);
140 printk("\nEnabling ES7000 specific features...\n");
142 * Determine the generation of the ES7000 currently running.
144 * es7000_plat = 0 if the machine is NOT a Unisys ES7000 box
145 * es7000_plat = 1 if the machine is a 5xx ES7000 box
146 * es7000_plat = 2 if the machine is a x86_64 ES7000 box
149 if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
154 ioapic_renumber_irq = es7000_rename_gsi;
160 find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length)
162 struct acpi_table_rsdp *rsdp = NULL;
163 unsigned long rsdp_phys = 0;
164 struct acpi_table_header *header = NULL;
166 struct acpi_table_sdt sdt;
168 rsdp_phys = acpi_find_rsdp();
169 rsdp = __va(rsdp_phys);
170 if (rsdp->rsdt_address) {
171 struct acpi_table_rsdt *mapped_rsdt = NULL;
172 sdt.pa = rsdp->rsdt_address;
174 header = (struct acpi_table_header *)
175 __acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
179 sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
180 mapped_rsdt = (struct acpi_table_rsdt *)
181 __acpi_map_table(sdt.pa, header->length);
185 header = &mapped_rsdt->header;
187 for (i = 0; i < sdt.count; i++)
188 sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
190 for (i = 0; i < sdt.count; i++) {
192 header = (struct acpi_table_header *)
193 __acpi_map_table(sdt.entry[i].pa,
194 sizeof(struct acpi_table_header));
197 if (!strncmp((char *) &header->signature, "OEM1", 4)) {
198 if (!strncmp((char *) &header->oem_id, "UNISYS", 6)) {
201 acpi_table_print(header, sdt.entry[i].pa);
202 t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
203 addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
204 *length = header->length;
205 *oem_addr = (unsigned long) addr;
210 Dprintk("ES7000: did not find Unisys ACPI OEM table!\n");
224 es7000_mip_write(struct mip_reg *mip_reg)
230 while (((unsigned long long)host_reg->off_38 &
231 (unsigned long long)MIP_VALID) != 0) {
233 printk("es7000_mip_write: Timeout waiting for Host Valid Flag");
236 es7000_spin(MIP_SPIN);
239 memcpy(host_reg, mip_reg, sizeof(struct mip_reg));
244 while (((unsigned long long)mip_reg->off_38 &
245 (unsigned long long)MIP_VALID) == 0) {
247 printk("es7000_mip_write: Timeout waiting for MIP Valid Flag");
250 es7000_spin(MIP_SPIN);
253 status = ((unsigned long long)mip_reg->off_0 &
254 (unsigned long long)0xffff0000000000ULL) >> 48;
255 mip_reg->off_38 = ((unsigned long long)mip_reg->off_38 &
256 (unsigned long long)~MIP_VALID);
261 es7000_start_cpu(int cpu, unsigned long eip)
263 unsigned long vect = 0, psaival = 0;
268 vect = ((unsigned long)__pa(eip)/0x1000) << 16;
269 psaival = (0x1000000 | vect | cpu);
271 while (*psai & 0x1000000)
281 es7000_stop_cpu(int cpu)
288 startup= (0x1000000 | cpu);
290 while ((*psai & 0xff00ffff) != startup)
293 startup = (*psai & 0xff0000) >> 16;
305 struct mip_reg es7000_mip_reg;
307 printk("ES7000: Enabling APIC mode.\n");
308 memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
309 es7000_mip_reg.off_0 = MIP_SW_APIC;
310 es7000_mip_reg.off_38 = (MIP_VALID);
311 while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0)
312 printk("es7000_sw_apic: command failed, status = %x\n",