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
48 volatile unsigned long *psai = NULL;
49 struct mip_reg *mip_reg;
50 struct mip_reg *host_reg;
51 int mip_port;
52 unsigned 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
60 static unsigned int base;
61
62 static int
63 es7000_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
82 int __init
83 parse_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 es7000_plat = 1;
142 ioapic_renumber_irq = es7000_rename_gsi;
143 }
144 return es7000_plat;
145 }
146
147 int __init
148 find_unisys_acpi_oem_table(unsigned long *oem_addr, int *length)
149 {
150 struct acpi_table_rsdp *rsdp = NULL;
151 unsigned long rsdp_phys = 0;
152 struct acpi_table_header *header = NULL;
153 int i;
154 struct acpi_table_sdt sdt;
155
156 rsdp_phys = acpi_find_rsdp();
157 rsdp = __va(rsdp_phys);
158 if (rsdp->rsdt_address) {
159 struct acpi_table_rsdt *mapped_rsdt = NULL;
160 sdt.pa = rsdp->rsdt_address;
161
162 header = (struct acpi_table_header *)
163 __acpi_map_table(sdt.pa, sizeof(struct acpi_table_header));
164 if (!header)
165 return -ENODEV;
166
167 sdt.count = (header->length - sizeof(struct acpi_table_header)) >> 3;
168 mapped_rsdt = (struct acpi_table_rsdt *)
169 __acpi_map_table(sdt.pa, header->length);
170 if (!mapped_rsdt)
171 return -ENODEV;
172
173 header = &mapped_rsdt->header;
174
175 for (i = 0; i < sdt.count; i++)
176 sdt.entry[i].pa = (unsigned long) mapped_rsdt->entry[i];
177 };
178 for (i = 0; i < sdt.count; i++) {
179
180 header = (struct acpi_table_header *)
181 __acpi_map_table(sdt.entry[i].pa,
182 sizeof(struct acpi_table_header));
183 if (!header)
184 continue;
185 if (!strncmp((char *) &header->signature, "OEM1", 4)) {
186 if (!strncmp((char *) &header->oem_id, "UNISYS", 6)) {
187 void *addr;
188 struct oem_table *t;
189 acpi_table_print(header, sdt.entry[i].pa);
190 t = (struct oem_table *) __acpi_map_table(sdt.entry[i].pa, header->length);
191 addr = (void *) __acpi_map_table(t->OEMTableAddr, t->OEMTableSize);
192 *length = header->length;
193 *oem_addr = (unsigned long) addr;
194 return 0;
195 }
196 }
197 }
198 Dprintk("ES7000: did not find Unisys ACPI OEM table!\n");
199 return -1;
200 }
201
202 static void
203 es7000_spin(int n)
204 {
205 int i = 0;
206
207 while (i++ < n)
208 rep_nop();
209 }
210
211 static int __init
212 es7000_mip_write(struct mip_reg *mip_reg)
213 {
214 int status = 0;
215 int spin;
216
217 spin = MIP_SPIN;
218 while (((unsigned long long)host_reg->off_38 &
219 (unsigned long long)MIP_VALID) != 0) {
220 if (--spin <= 0) {
221 printk("es7000_mip_write: Timeout waiting for Host Valid Flag");
222 return -1;
223 }
224 es7000_spin(MIP_SPIN);
225 }
226
227 memcpy(host_reg, mip_reg, sizeof(struct mip_reg));
228 outb(1, mip_port);
229
230 spin = MIP_SPIN;
231
232 while (((unsigned long long)mip_reg->off_38 &
233 (unsigned long long)MIP_VALID) == 0) {
234 if (--spin <= 0) {
235 printk("es7000_mip_write: Timeout waiting for MIP Valid Flag");
236 return -1;
237 }
238 es7000_spin(MIP_SPIN);
239 }
240
241 status = ((unsigned long long)mip_reg->off_0 &
242 (unsigned long long)0xffff0000000000ULL) >> 48;
243 mip_reg->off_38 = ((unsigned long long)mip_reg->off_38 &
244 (unsigned long long)~MIP_VALID);
245 return status;
246 }
247
248 int
249 es7000_start_cpu(int cpu, unsigned long eip)
250 {
251 unsigned long vect = 0, psaival = 0;
252
253 if (psai == NULL)
254 return -1;
255
256 vect = ((unsigned long)__pa(eip)/0x1000) << 16;
257 psaival = (0x1000000 | vect | cpu);
258
259 while (*psai & 0x1000000)
260 ;
261
262 *psai = psaival;
263
264 return 0;
265
266 }
267
268 int
269 es7000_stop_cpu(int cpu)
270 {
271 int startup;
272
273 if (psai == NULL)
274 return -1;
275
276 startup= (0x1000000 | cpu);
277
278 while ((*psai & 0xff00ffff) != startup)
279 ;
280
281 startup = (*psai & 0xff0000) >> 16;
282 *psai &= 0xffffff;
283
284 return 0;
285
286 }
287
288 void __init
289 es7000_sw_apic()
290 {
291 if (es7000_plat) {
292 int mip_status;
293 struct mip_reg es7000_mip_reg;
294
295 printk("ES7000: Enabling APIC mode.\n");
296 memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
297 es7000_mip_reg.off_0 = MIP_SW_APIC;
298 es7000_mip_reg.off_38 = (MIP_VALID);
299 while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0)
300 printk("es7000_sw_apic: command failed, status = %x\n",
301 mip_status);
302 return;
303 }
304 }
305
|
This page was automatically generated by the
LXR engine.
|