aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/mach-es7000
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/i386/mach-es7000
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/i386/mach-es7000')
-rw-r--r--arch/i386/mach-es7000/Makefile6
-rw-r--r--arch/i386/mach-es7000/es7000.h110
-rw-r--r--arch/i386/mach-es7000/es7000plat.c316
3 files changed, 432 insertions, 0 deletions
diff --git a/arch/i386/mach-es7000/Makefile b/arch/i386/mach-es7000/Makefile
new file mode 100644
index 000000000000..69dd4da218dc
--- /dev/null
+++ b/arch/i386/mach-es7000/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for the linux kernel.
3#
4
5obj-$(CONFIG_X86_ES7000) := es7000plat.o
6obj-$(CONFIG_X86_GENERICARCH) := es7000plat.o
diff --git a/arch/i386/mach-es7000/es7000.h b/arch/i386/mach-es7000/es7000.h
new file mode 100644
index 000000000000..70691f0c4ce2
--- /dev/null
+++ b/arch/i386/mach-es7000/es7000.h
@@ -0,0 +1,110 @@
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#define MIP_REG 1
28#define MIP_PSAI_REG 4
29
30#define MIP_BUSY 1
31#define MIP_SPIN 0xf0000
32#define MIP_VALID 0x0100000000000000ULL
33#define MIP_PORT(VALUE) ((VALUE >> 32) & 0xffff)
34
35#define MIP_RD_LO(VALUE) (VALUE & 0xffffffff)
36
37struct mip_reg_info {
38 unsigned long long mip_info;
39 unsigned long long delivery_info;
40 unsigned long long host_reg;
41 unsigned long long mip_reg;
42};
43
44struct part_info {
45 unsigned char type;
46 unsigned char length;
47 unsigned char part_id;
48 unsigned char apic_mode;
49 unsigned long snum;
50 char ptype[16];
51 char sname[64];
52 char pname[64];
53};
54
55struct psai {
56 unsigned long long entry_type;
57 unsigned long long addr;
58 unsigned long long bep_addr;
59};
60
61struct es7000_mem_info {
62 unsigned char type;
63 unsigned char length;
64 unsigned char resv[6];
65 unsigned long long start;
66 unsigned long long size;
67};
68
69struct es7000_oem_table {
70 unsigned long long hdr;
71 struct mip_reg_info mip;
72 struct part_info pif;
73 struct es7000_mem_info shm;
74 struct psai psai;
75};
76
77struct acpi_table_sdt {
78 unsigned long pa;
79 unsigned long count;
80 struct {
81 unsigned long pa;
82 enum acpi_table_id id;
83 unsigned long size;
84 } entry[50];
85};
86
87struct oem_table {
88 struct acpi_table_header Header;
89 u32 OEMTableAddr;
90 u32 OEMTableSize;
91};
92
93struct mip_reg {
94 unsigned long long off_0;
95 unsigned long long off_8;
96 unsigned long long off_10;
97 unsigned long long off_18;
98 unsigned long long off_20;
99 unsigned long long off_28;
100 unsigned long long off_30;
101 unsigned long long off_38;
102};
103
104#define MIP_SW_APIC 0x1020b
105#define MIP_FUNC(VALUE) (VALUE & 0xff)
106
107extern int parse_unisys_oem (char *oemptr, int oem_entries);
108extern int find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length);
109extern int es7000_start_cpu(int cpu, unsigned long eip);
110extern void es7000_sw_apic(void);
diff --git a/arch/i386/mach-es7000/es7000plat.c b/arch/i386/mach-es7000/es7000plat.c
new file mode 100644
index 000000000000..d5936d500479
--- /dev/null
+++ b/arch/i386/mach-es7000/es7000plat.c
@@ -0,0 +1,316 @@
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
54#if defined(CONFIG_X86_IO_APIC) && (defined(CONFIG_ACPI_INTERPRETER) || defined(CONFIG_ACPI_BOOT))
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{
65 if (!base) {
66 int i;
67 for (i = 0; i < nr_ioapics; i++)
68 base += nr_ioapic_registers[i];
69 }
70
71 if (!ioapic && (gsi < 16))
72 gsi += base;
73 return gsi;
74}
75
76#endif // (CONFIG_X86_IO_APIC) && (CONFIG_ACPI_INTERPRETER || CONFIG_ACPI_BOOT)
77
78/*
79 * Parse the OEM Table
80 */
81
82int __init
83parse_unisys_oem (char *oemptr, int oem_entries)
84{
85 int i;
86 int success = 0;
87 unsigned char type, size;
88 unsigned long val;
89 char *tp = NULL;
90 struct psai *psaip = NULL;
91 struct mip_reg_info *mi;
92 struct mip_reg *host, *mip;
93
94 tp = oemptr;
95
96 tp += 8;
97
98 for (i=0; i <= oem_entries; i++) {
99 type = *tp++;
100 size = *tp++;
101 tp -= 2;
102 switch (type) {
103 case MIP_REG:
104 mi = (struct mip_reg_info *)tp;
105 val = MIP_RD_LO(mi->host_reg);
106 host_addr = val;
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);
111 mip_addr = val;
112 mip = (struct mip_reg *)val;
113 mip_reg = __va(mip);
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);
118 success++;
119 break;
120 case MIP_PSAI_REG:
121 psaip = (struct psai *)tp;
122 if (tp != NULL) {
123 if (psaip->addr)
124 psai = __va(psaip->addr);
125 else
126 psai = NULL;
127 success++;
128 }
129 break;
130 default:
131 break;
132 }
133 if (i == 6) break;
134 tp += size;
135 }
136
137 if (success < 2) {
138 es7000_plat = 0;
139 } else {
140 printk("\nEnabling ES7000 specific features...\n");
141 /*
142 * Determine the generation of the ES7000 currently running.
143 *
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
147 *
148 */
149 if (!(boot_cpu_data.x86 <= 15 && boot_cpu_data.x86_model <= 2))
150 es7000_plat = 2;
151 else
152 es7000_plat = 1;
153
154 ioapic_renumber_irq = es7000_rename_gsi;
155 }
156 return es7000_plat;
157}
158
159int __init
160find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length)
161{
162 struct acpi_table_rsdp *rsdp = NULL;
163 unsigned long rsdp_phys = 0;
164 struct acpi_table_header *header = NULL;
165 int i;
166 struct acpi_table_sdt sdt;
167
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;
173
174 header = (struct acpi_table_header *)
175 __acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
176 if (!header)
177 return -ENODEV;
178
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);
182 if (!mapped_rsdt)
183 return -ENODEV;
184
185 header = &mapped_rsdt->header;
186
187 for (i = 0; i < sdt.count; i++)
188 sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
189 };
190 for (i = 0; i < sdt.count; i++) {
191
192 header = (struct acpi_table_header *)
193 __acpi_map_table(sdt.entry[i].pa,
194 sizeof(struct acpi_table_header));
195 if (!header)
196 continue;
197 if (!strncmp((char *) &header->signature, "OEM1", 4)) {
198 if (!strncmp((char *) &header->oem_id, "UNISYS", 6)) {
199 void *addr;
200 struct oem_table *t;
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;
206 return 0;
207 }
208 }
209 }
210 Dprintk("ES7000: did not find Unisys ACPI OEM table!\n");
211 return -1;
212}
213
214static void
215es7000_spin(int n)
216{
217 int i = 0;
218
219 while (i++ < n)
220 rep_nop();
221}
222
223static int __init
224es7000_mip_write(struct mip_reg *mip_reg)
225{
226 int status = 0;
227 int spin;
228
229 spin = MIP_SPIN;
230 while (((unsigned long long)host_reg->off_38 &
231 (unsigned long long)MIP_VALID) != 0) {
232 if (--spin <= 0) {
233 printk("es7000_mip_write: Timeout waiting for Host Valid Flag");
234 return -1;
235 }
236 es7000_spin(MIP_SPIN);
237 }
238
239 memcpy(host_reg, mip_reg, sizeof(struct mip_reg));
240 outb(1, mip_port);
241
242 spin = MIP_SPIN;
243
244 while (((unsigned long long)mip_reg->off_38 &
245 (unsigned long long)MIP_VALID) == 0) {
246 if (--spin <= 0) {
247 printk("es7000_mip_write: Timeout waiting for MIP Valid Flag");
248 return -1;
249 }
250 es7000_spin(MIP_SPIN);
251 }
252
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);
257 return status;
258}
259
260int
261es7000_start_cpu(int cpu, unsigned long eip)
262{
263 unsigned long vect = 0, psaival = 0;
264
265 if (psai == NULL)
266 return -1;
267
268 vect = ((unsigned long)__pa(eip)/0x1000) << 16;
269 psaival = (0x1000000 | vect | cpu);
270
271 while (*psai & 0x1000000)
272 ;
273
274 *psai = psaival;
275
276 return 0;
277
278}
279
280int
281es7000_stop_cpu(int cpu)
282{
283 int startup;
284
285 if (psai == NULL)
286 return -1;
287
288 startup= (0x1000000 | cpu);
289
290 while ((*psai & 0xff00ffff) != startup)
291 ;
292
293 startup = (*psai & 0xff0000) >> 16;
294 *psai &= 0xffffff;
295
296 return 0;
297
298}
299
300void __init
301es7000_sw_apic()
302{
303 if (es7000_plat) {
304 int mip_status;
305 struct mip_reg es7000_mip_reg;
306
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",
313 mip_status);
314 return;
315 }
316}