[PATCH] i386: fall back to sensible CPU model name
[linux-block.git] / arch / i386 / mach-es7000 / es7000plat.c
CommitLineData
1da177e4
LT
1/*
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.
6 *
7 * Copyright (c) 2003 Unisys Corporation. All Rights Reserved.
8 *
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.
12 *
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.
16 *
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.
20 *
21 * Contact information: Unisys Corporation, Township Line & Union Meeting
22 * Roads-A, Unisys Way, Blue Bell, Pennsylvania, 19424, or:
23 *
24 * http://www.unisys.com
25 */
26
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>
38#include <asm/io.h>
39#include <asm/nmi.h>
40#include <asm/smp.h>
41#include <asm/apicdef.h>
42#include "es7000.h"
43
44/*
45 * ES7000 Globals
46 */
47
48volatile unsigned long *psai = NULL;
49struct mip_reg *mip_reg;
50struct mip_reg *host_reg;
51int mip_port;
52unsigned long mip_addr, host_addr;
53
8466361a 54#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI)
1da177e4
LT
55
56/*
57 * GSI override for ES7000 platforms.
58 */
59
60static unsigned int base;
61
62static int
63es7000_rename_gsi(int ioapic, int gsi)
64{
9338316c
NP
65 if (es7000_plat == ES7000_ZORRO)
66 return gsi;
67
1da177e4
LT
68 if (!base) {
69 int i;
70 for (i = 0; i < nr_ioapics; i++)
71 base += nr_ioapic_registers[i];
72 }
73
74 if (!ioapic && (gsi < 16))
75 gsi += base;
76 return gsi;
77}
78
8466361a 79#endif /* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */
1da177e4 80
56f1d5d5 81void __init
9338316c 82setup_unisys(void)
56f1d5d5
NP
83{
84 /*
85 * Determine the generation of the ES7000 currently running.
86 *
87 * es7000_plat = 1 if the machine is a 5xx ES7000 box
88 * es7000_plat = 2 if the machine is a x86_64 ES7000 box
89 *
90 */
91 if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
9338316c 92 es7000_plat = ES7000_ZORRO;
56f1d5d5 93 else
9338316c 94 es7000_plat = ES7000_CLASSIC;
56f1d5d5
NP
95 ioapic_renumber_irq = es7000_rename_gsi;
96}
97
1da177e4
LT
98/*
99 * Parse the OEM Table
100 */
101
102int __init
56f1d5d5 103parse_unisys_oem (char *oemptr)
1da177e4
LT
104{
105 int i;
106 int success = 0;
107 unsigned char type, size;
108 unsigned long val;
109 char *tp = NULL;
110 struct psai *psaip = NULL;
111 struct mip_reg_info *mi;
112 struct mip_reg *host, *mip;
113
114 tp = oemptr;
115
116 tp += 8;
117
56f1d5d5 118 for (i=0; i <= 6; i++) {
1da177e4
LT
119 type = *tp++;
120 size = *tp++;
121 tp -= 2;
122 switch (type) {
123 case MIP_REG:
124 mi = (struct mip_reg_info *)tp;
125 val = MIP_RD_LO(mi->host_reg);
126 host_addr = val;
127 host = (struct mip_reg *)val;
128 host_reg = __va(host);
129 val = MIP_RD_LO(mi->mip_reg);
130 mip_port = MIP_PORT(mi->mip_info);
131 mip_addr = val;
132 mip = (struct mip_reg *)val;
133 mip_reg = __va(mip);
134 Dprintk("es7000_mipcfg: host_reg = 0x%lx \n",
135 (unsigned long)host_reg);
136 Dprintk("es7000_mipcfg: mip_reg = 0x%lx \n",
137 (unsigned long)mip_reg);
138 success++;
139 break;
140 case MIP_PSAI_REG:
141 psaip = (struct psai *)tp;
142 if (tp != NULL) {
143 if (psaip->addr)
144 psai = __va(psaip->addr);
145 else
146 psai = NULL;
147 success++;
148 }
149 break;
150 default:
151 break;
152 }
1da177e4
LT
153 tp += size;
154 }
155
156 if (success < 2) {
9338316c 157 es7000_plat = NON_UNISYS;
56f1d5d5
NP
158 } else
159 setup_unisys();
1da177e4
LT
160 return es7000_plat;
161}
162
163int __init
56f1d5d5 164find_unisys_acpi_oem_table(unsigned long *oem_addr)
1da177e4
LT
165{
166 struct acpi_table_rsdp *rsdp = NULL;
167 unsigned long rsdp_phys = 0;
168 struct acpi_table_header *header = NULL;
169 int i;
170 struct acpi_table_sdt sdt;
171
172 rsdp_phys = acpi_find_rsdp();
173 rsdp = __va(rsdp_phys);
174 if (rsdp->rsdt_address) {
175 struct acpi_table_rsdt *mapped_rsdt = NULL;
176 sdt.pa = rsdp->rsdt_address;
177
178 header = (struct acpi_table_header *)
179 __acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
180 if (!header)
181 return -ENODEV;
182
183 sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
184 mapped_rsdt = (struct acpi_table_rsdt *)
185 __acpi_map_table(sdt.pa, header->length);
186 if (!mapped_rsdt)
187 return -ENODEV;
188
189 header = &mapped_rsdt->header;
190
191 for (i = 0; i < sdt.count; i++)
192 sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
193 };
194 for (i = 0; i < sdt.count; i++) {
195
196 header = (struct acpi_table_header *)
197 __acpi_map_table(sdt.entry[i].pa,
198 sizeof(struct acpi_table_header));
199 if (!header)
200 continue;
201 if (!strncmp((char *) &header->signature, "OEM1", 4)) {
202 if (!strncmp((char *) &header->oem_id, "UNISYS", 6)) {
203 void *addr;
204 struct oem_table *t;
205 acpi_table_print(header, sdt.entry[i].pa);
206 t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
207 addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
1da177e4
LT
208 *oem_addr = (unsigned long) addr;
209 return 0;
210 }
211 }
212 }
1da177e4
LT
213 return -1;
214}
215
216static void
217es7000_spin(int n)
218{
219 int i = 0;
220
221 while (i++ < n)
222 rep_nop();
223}
224
225static int __init
226es7000_mip_write(struct mip_reg *mip_reg)
227{
228 int status = 0;
229 int spin;
230
231 spin = MIP_SPIN;
232 while (((unsigned long long)host_reg->off_38 &
233 (unsigned long long)MIP_VALID) != 0) {
234 if (--spin <= 0) {
235 printk("es7000_mip_write: Timeout waiting for Host Valid Flag");
236 return -1;
237 }
238 es7000_spin(MIP_SPIN);
239 }
240
241 memcpy(host_reg, mip_reg, sizeof(struct mip_reg));
242 outb(1, mip_port);
243
244 spin = MIP_SPIN;
245
246 while (((unsigned long long)mip_reg->off_38 &
247 (unsigned long long)MIP_VALID) == 0) {
248 if (--spin <= 0) {
249 printk("es7000_mip_write: Timeout waiting for MIP Valid Flag");
250 return -1;
251 }
252 es7000_spin(MIP_SPIN);
253 }
254
255 status = ((unsigned long long)mip_reg->off_0 &
256 (unsigned long long)0xffff0000000000ULL) >> 48;
257 mip_reg->off_38 = ((unsigned long long)mip_reg->off_38 &
258 (unsigned long long)~MIP_VALID);
259 return status;
260}
261
262int
263es7000_start_cpu(int cpu, unsigned long eip)
264{
265 unsigned long vect = 0, psaival = 0;
266
267 if (psai == NULL)
268 return -1;
269
270 vect = ((unsigned long)__pa(eip)/0x1000) << 16;
271 psaival = (0x1000000 | vect | cpu);
272
273 while (*psai & 0x1000000)
274 ;
275
276 *psai = psaival;
277
278 return 0;
279
280}
281
282int
283es7000_stop_cpu(int cpu)
284{
285 int startup;
286
287 if (psai == NULL)
288 return -1;
289
290 startup= (0x1000000 | cpu);
291
292 while ((*psai & 0xff00ffff) != startup)
293 ;
294
295 startup = (*psai & 0xff0000) >> 16;
296 *psai &= 0xffffff;
297
298 return 0;
299
300}
301
302void __init
303es7000_sw_apic()
304{
305 if (es7000_plat) {
306 int mip_status;
307 struct mip_reg es7000_mip_reg;
308
309 printk("ES7000: Enabling APIC mode.\n");
310 memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
311 es7000_mip_reg.off_0 = MIP_SW_APIC;
312 es7000_mip_reg.off_38 = (MIP_VALID);
313 while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0)
314 printk("es7000_sw_apic: command failed, status = %x\n",
315 mip_status);
316 return;
317 }
318}