diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-07-10 09:50:37 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-10 12:55:42 -0400 |
commit | 652536367b727251bfeba72189a17a040accbc2d (patch) | |
tree | e61b24b2089bf949906c5badcf13f2f4a89cbca8 /arch | |
parent | 078c0bba55b3dc751881d40cf170c002eafc048d (diff) |
x86, VisWS: turn into generic arch, copy visws files
copy arch/x86/mach-visws/setup_visws.c, apic_visws.c and traps_visws.c
files to arch/x86/kernel/, in preparation of the switchover to a
non-subarch setup for VISWS.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/kernel/apic_visws.c | 295 | ||||
-rw-r--r-- | arch/x86/kernel/setup_visws.c | 331 | ||||
-rw-r--r-- | arch/x86/kernel/traps_visws.c | 71 |
3 files changed, 697 insertions, 0 deletions
diff --git a/arch/x86/kernel/apic_visws.c b/arch/x86/kernel/apic_visws.c new file mode 100644 index 000000000000..6c02c8d09932 --- /dev/null +++ b/arch/x86/kernel/apic_visws.c | |||
@@ -0,0 +1,295 @@ | |||
1 | /* | ||
2 | * Copyright (C) 1999 Bent Hagemark, Ingo Molnar | ||
3 | * | ||
4 | * SGI Visual Workstation interrupt controller | ||
5 | * | ||
6 | * The Cobalt system ASIC in the Visual Workstation contains a "Cobalt" APIC | ||
7 | * which serves as the main interrupt controller in the system. Non-legacy | ||
8 | * hardware in the system uses this controller directly. Legacy devices | ||
9 | * are connected to the PIIX4 which in turn has its 8259(s) connected to | ||
10 | * a of the Cobalt APIC entry. | ||
11 | * | ||
12 | * 09/02/2000 - Updated for 2.4 by jbarnes@sgi.com | ||
13 | * | ||
14 | * 25/11/2002 - Updated for 2.5 by Andrey Panin <pazke@orbita1.ru> | ||
15 | */ | ||
16 | |||
17 | #include <linux/kernel_stat.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/init.h> | ||
20 | |||
21 | #include <asm/io.h> | ||
22 | #include <asm/apic.h> | ||
23 | #include <asm/i8259.h> | ||
24 | #include <asm/irq_vectors.h> | ||
25 | #include <asm/visws/cobalt.h> | ||
26 | |||
27 | static DEFINE_SPINLOCK(cobalt_lock); | ||
28 | |||
29 | /* | ||
30 | * Set the given Cobalt APIC Redirection Table entry to point | ||
31 | * to the given IDT vector/index. | ||
32 | */ | ||
33 | static inline void co_apic_set(int entry, int irq) | ||
34 | { | ||
35 | co_apic_write(CO_APIC_LO(entry), CO_APIC_LEVEL | (irq + FIRST_EXTERNAL_VECTOR)); | ||
36 | co_apic_write(CO_APIC_HI(entry), 0); | ||
37 | } | ||
38 | |||
39 | /* | ||
40 | * Cobalt (IO)-APIC functions to handle PCI devices. | ||
41 | */ | ||
42 | static inline int co_apic_ide0_hack(void) | ||
43 | { | ||
44 | extern char visws_board_type; | ||
45 | extern char visws_board_rev; | ||
46 | |||
47 | if (visws_board_type == VISWS_320 && visws_board_rev == 5) | ||
48 | return 5; | ||
49 | return CO_APIC_IDE0; | ||
50 | } | ||
51 | |||
52 | static int is_co_apic(unsigned int irq) | ||
53 | { | ||
54 | if (IS_CO_APIC(irq)) | ||
55 | return CO_APIC(irq); | ||
56 | |||
57 | switch (irq) { | ||
58 | case 0: return CO_APIC_CPU; | ||
59 | case CO_IRQ_IDE0: return co_apic_ide0_hack(); | ||
60 | case CO_IRQ_IDE1: return CO_APIC_IDE1; | ||
61 | default: return -1; | ||
62 | } | ||
63 | } | ||
64 | |||
65 | |||
66 | /* | ||
67 | * This is the SGI Cobalt (IO-)APIC: | ||
68 | */ | ||
69 | |||
70 | static void enable_cobalt_irq(unsigned int irq) | ||
71 | { | ||
72 | co_apic_set(is_co_apic(irq), irq); | ||
73 | } | ||
74 | |||
75 | static void disable_cobalt_irq(unsigned int irq) | ||
76 | { | ||
77 | int entry = is_co_apic(irq); | ||
78 | |||
79 | co_apic_write(CO_APIC_LO(entry), CO_APIC_MASK); | ||
80 | co_apic_read(CO_APIC_LO(entry)); | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * "irq" really just serves to identify the device. Here is where we | ||
85 | * map this to the Cobalt APIC entry where it's physically wired. | ||
86 | * This is called via request_irq -> setup_irq -> irq_desc->startup() | ||
87 | */ | ||
88 | static unsigned int startup_cobalt_irq(unsigned int irq) | ||
89 | { | ||
90 | unsigned long flags; | ||
91 | |||
92 | spin_lock_irqsave(&cobalt_lock, flags); | ||
93 | if ((irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS | IRQ_WAITING))) | ||
94 | irq_desc[irq].status &= ~(IRQ_DISABLED | IRQ_INPROGRESS | IRQ_WAITING); | ||
95 | enable_cobalt_irq(irq); | ||
96 | spin_unlock_irqrestore(&cobalt_lock, flags); | ||
97 | return 0; | ||
98 | } | ||
99 | |||
100 | static void ack_cobalt_irq(unsigned int irq) | ||
101 | { | ||
102 | unsigned long flags; | ||
103 | |||
104 | spin_lock_irqsave(&cobalt_lock, flags); | ||
105 | disable_cobalt_irq(irq); | ||
106 | apic_write(APIC_EOI, APIC_EIO_ACK); | ||
107 | spin_unlock_irqrestore(&cobalt_lock, flags); | ||
108 | } | ||
109 | |||
110 | static void end_cobalt_irq(unsigned int irq) | ||
111 | { | ||
112 | unsigned long flags; | ||
113 | |||
114 | spin_lock_irqsave(&cobalt_lock, flags); | ||
115 | if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) | ||
116 | enable_cobalt_irq(irq); | ||
117 | spin_unlock_irqrestore(&cobalt_lock, flags); | ||
118 | } | ||
119 | |||
120 | static struct irq_chip cobalt_irq_type = { | ||
121 | .typename = "Cobalt-APIC", | ||
122 | .startup = startup_cobalt_irq, | ||
123 | .shutdown = disable_cobalt_irq, | ||
124 | .enable = enable_cobalt_irq, | ||
125 | .disable = disable_cobalt_irq, | ||
126 | .ack = ack_cobalt_irq, | ||
127 | .end = end_cobalt_irq, | ||
128 | }; | ||
129 | |||
130 | |||
131 | /* | ||
132 | * This is the PIIX4-based 8259 that is wired up indirectly to Cobalt | ||
133 | * -- not the manner expected by the code in i8259.c. | ||
134 | * | ||
135 | * there is a 'master' physical interrupt source that gets sent to | ||
136 | * the CPU. But in the chipset there are various 'virtual' interrupts | ||
137 | * waiting to be handled. We represent this to Linux through a 'master' | ||
138 | * interrupt controller type, and through a special virtual interrupt- | ||
139 | * controller. Device drivers only see the virtual interrupt sources. | ||
140 | */ | ||
141 | static unsigned int startup_piix4_master_irq(unsigned int irq) | ||
142 | { | ||
143 | init_8259A(0); | ||
144 | |||
145 | return startup_cobalt_irq(irq); | ||
146 | } | ||
147 | |||
148 | static void end_piix4_master_irq(unsigned int irq) | ||
149 | { | ||
150 | unsigned long flags; | ||
151 | |||
152 | spin_lock_irqsave(&cobalt_lock, flags); | ||
153 | enable_cobalt_irq(irq); | ||
154 | spin_unlock_irqrestore(&cobalt_lock, flags); | ||
155 | } | ||
156 | |||
157 | static struct irq_chip piix4_master_irq_type = { | ||
158 | .typename = "PIIX4-master", | ||
159 | .startup = startup_piix4_master_irq, | ||
160 | .ack = ack_cobalt_irq, | ||
161 | .end = end_piix4_master_irq, | ||
162 | }; | ||
163 | |||
164 | |||
165 | static struct irq_chip piix4_virtual_irq_type = { | ||
166 | .typename = "PIIX4-virtual", | ||
167 | .shutdown = disable_8259A_irq, | ||
168 | .enable = enable_8259A_irq, | ||
169 | .disable = disable_8259A_irq, | ||
170 | }; | ||
171 | |||
172 | |||
173 | /* | ||
174 | * PIIX4-8259 master/virtual functions to handle interrupt requests | ||
175 | * from legacy devices: floppy, parallel, serial, rtc. | ||
176 | * | ||
177 | * None of these get Cobalt APIC entries, neither do they have IDT | ||
178 | * entries. These interrupts are purely virtual and distributed from | ||
179 | * the 'master' interrupt source: CO_IRQ_8259. | ||
180 | * | ||
181 | * When the 8259 interrupts its handler figures out which of these | ||
182 | * devices is interrupting and dispatches to its handler. | ||
183 | * | ||
184 | * CAREFUL: devices see the 'virtual' interrupt only. Thus disable/ | ||
185 | * enable_irq gets the right irq. This 'master' irq is never directly | ||
186 | * manipulated by any driver. | ||
187 | */ | ||
188 | static irqreturn_t piix4_master_intr(int irq, void *dev_id) | ||
189 | { | ||
190 | int realirq; | ||
191 | irq_desc_t *desc; | ||
192 | unsigned long flags; | ||
193 | |||
194 | spin_lock_irqsave(&i8259A_lock, flags); | ||
195 | |||
196 | /* Find out what's interrupting in the PIIX4 master 8259 */ | ||
197 | outb(0x0c, 0x20); /* OCW3 Poll command */ | ||
198 | realirq = inb(0x20); | ||
199 | |||
200 | /* | ||
201 | * Bit 7 == 0 means invalid/spurious | ||
202 | */ | ||
203 | if (unlikely(!(realirq & 0x80))) | ||
204 | goto out_unlock; | ||
205 | |||
206 | realirq &= 7; | ||
207 | |||
208 | if (unlikely(realirq == 2)) { | ||
209 | outb(0x0c, 0xa0); | ||
210 | realirq = inb(0xa0); | ||
211 | |||
212 | if (unlikely(!(realirq & 0x80))) | ||
213 | goto out_unlock; | ||
214 | |||
215 | realirq = (realirq & 7) + 8; | ||
216 | } | ||
217 | |||
218 | /* mask and ack interrupt */ | ||
219 | cached_irq_mask |= 1 << realirq; | ||
220 | if (unlikely(realirq > 7)) { | ||
221 | inb(0xa1); | ||
222 | outb(cached_slave_mask, 0xa1); | ||
223 | outb(0x60 + (realirq & 7), 0xa0); | ||
224 | outb(0x60 + 2, 0x20); | ||
225 | } else { | ||
226 | inb(0x21); | ||
227 | outb(cached_master_mask, 0x21); | ||
228 | outb(0x60 + realirq, 0x20); | ||
229 | } | ||
230 | |||
231 | spin_unlock_irqrestore(&i8259A_lock, flags); | ||
232 | |||
233 | desc = irq_desc + realirq; | ||
234 | |||
235 | /* | ||
236 | * handle this 'virtual interrupt' as a Cobalt one now. | ||
237 | */ | ||
238 | kstat_cpu(smp_processor_id()).irqs[realirq]++; | ||
239 | |||
240 | if (likely(desc->action != NULL)) | ||
241 | handle_IRQ_event(realirq, desc->action); | ||
242 | |||
243 | if (!(desc->status & IRQ_DISABLED)) | ||
244 | enable_8259A_irq(realirq); | ||
245 | |||
246 | return IRQ_HANDLED; | ||
247 | |||
248 | out_unlock: | ||
249 | spin_unlock_irqrestore(&i8259A_lock, flags); | ||
250 | return IRQ_NONE; | ||
251 | } | ||
252 | |||
253 | static struct irqaction master_action = { | ||
254 | .handler = piix4_master_intr, | ||
255 | .name = "PIIX4-8259", | ||
256 | }; | ||
257 | |||
258 | static struct irqaction cascade_action = { | ||
259 | .handler = no_action, | ||
260 | .name = "cascade", | ||
261 | }; | ||
262 | |||
263 | |||
264 | void init_VISWS_APIC_irqs(void) | ||
265 | { | ||
266 | int i; | ||
267 | |||
268 | for (i = 0; i < CO_IRQ_APIC0 + CO_APIC_LAST + 1; i++) { | ||
269 | irq_desc[i].status = IRQ_DISABLED; | ||
270 | irq_desc[i].action = 0; | ||
271 | irq_desc[i].depth = 1; | ||
272 | |||
273 | if (i == 0) { | ||
274 | irq_desc[i].chip = &cobalt_irq_type; | ||
275 | } | ||
276 | else if (i == CO_IRQ_IDE0) { | ||
277 | irq_desc[i].chip = &cobalt_irq_type; | ||
278 | } | ||
279 | else if (i == CO_IRQ_IDE1) { | ||
280 | irq_desc[i].chip = &cobalt_irq_type; | ||
281 | } | ||
282 | else if (i == CO_IRQ_8259) { | ||
283 | irq_desc[i].chip = &piix4_master_irq_type; | ||
284 | } | ||
285 | else if (i < CO_IRQ_APIC0) { | ||
286 | irq_desc[i].chip = &piix4_virtual_irq_type; | ||
287 | } | ||
288 | else if (IS_CO_APIC(i)) { | ||
289 | irq_desc[i].chip = &cobalt_irq_type; | ||
290 | } | ||
291 | } | ||
292 | |||
293 | setup_irq(CO_IRQ_8259, &master_action); | ||
294 | setup_irq(2, &cascade_action); | ||
295 | } | ||
diff --git a/arch/x86/kernel/setup_visws.c b/arch/x86/kernel/setup_visws.c new file mode 100644 index 000000000000..e95e9499c8cd --- /dev/null +++ b/arch/x86/kernel/setup_visws.c | |||
@@ -0,0 +1,331 @@ | |||
1 | /* | ||
2 | * Unmaintained SGI Visual Workstation support. | ||
3 | * Split out from setup.c by davej@suse.de | ||
4 | */ | ||
5 | |||
6 | #include <linux/interrupt.h> | ||
7 | #include <linux/module.h> | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/smp.h> | ||
10 | |||
11 | #include <asm/visws/cobalt.h> | ||
12 | #include <asm/visws/piix4.h> | ||
13 | #include <asm/arch_hooks.h> | ||
14 | #include <asm/fixmap.h> | ||
15 | #include <asm/reboot.h> | ||
16 | #include <asm/setup.h> | ||
17 | #include <asm/e820.h> | ||
18 | #include <asm/smp.h> | ||
19 | #include <asm/io.h> | ||
20 | |||
21 | #include <mach_ipi.h> | ||
22 | |||
23 | #include "mach_apic.h" | ||
24 | |||
25 | #include <linux/init.h> | ||
26 | #include <linux/smp.h> | ||
27 | |||
28 | char visws_board_type = -1; | ||
29 | char visws_board_rev = -1; | ||
30 | |||
31 | int is_visws_box(void) | ||
32 | { | ||
33 | return visws_board_type >= 0; | ||
34 | } | ||
35 | |||
36 | static int __init visws_time_init_quirk(void) | ||
37 | { | ||
38 | printk(KERN_INFO "Starting Cobalt Timer system clock\n"); | ||
39 | |||
40 | /* Set the countdown value */ | ||
41 | co_cpu_write(CO_CPU_TIMEVAL, CO_TIME_HZ/HZ); | ||
42 | |||
43 | /* Start the timer */ | ||
44 | co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) | CO_CTRL_TIMERUN); | ||
45 | |||
46 | /* Enable (unmask) the timer interrupt */ | ||
47 | co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) & ~CO_CTRL_TIMEMASK); | ||
48 | |||
49 | /* | ||
50 | * Zero return means the generic timer setup code will set up | ||
51 | * the standard vector: | ||
52 | */ | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | static int __init visws_pre_intr_init_quirk(void) | ||
57 | { | ||
58 | init_VISWS_APIC_irqs(); | ||
59 | |||
60 | /* | ||
61 | * We dont want ISA irqs to be set up by the generic code: | ||
62 | */ | ||
63 | return 1; | ||
64 | } | ||
65 | |||
66 | /* Quirk for machine specific memory setup. */ | ||
67 | |||
68 | #define MB (1024 * 1024) | ||
69 | |||
70 | unsigned long sgivwfb_mem_phys; | ||
71 | unsigned long sgivwfb_mem_size; | ||
72 | EXPORT_SYMBOL(sgivwfb_mem_phys); | ||
73 | EXPORT_SYMBOL(sgivwfb_mem_size); | ||
74 | |||
75 | long long mem_size __initdata = 0; | ||
76 | |||
77 | static char * __init visws_memory_setup_quirk(void) | ||
78 | { | ||
79 | long long gfx_mem_size = 8 * MB; | ||
80 | |||
81 | mem_size = boot_params.alt_mem_k; | ||
82 | |||
83 | if (!mem_size) { | ||
84 | printk(KERN_WARNING "Bootloader didn't set memory size, upgrade it !\n"); | ||
85 | mem_size = 128 * MB; | ||
86 | } | ||
87 | |||
88 | /* | ||
89 | * this hardcodes the graphics memory to 8 MB | ||
90 | * it really should be sized dynamically (or at least | ||
91 | * set as a boot param) | ||
92 | */ | ||
93 | if (!sgivwfb_mem_size) { | ||
94 | printk(KERN_WARNING "Defaulting to 8 MB framebuffer size\n"); | ||
95 | sgivwfb_mem_size = 8 * MB; | ||
96 | } | ||
97 | |||
98 | /* | ||
99 | * Trim to nearest MB | ||
100 | */ | ||
101 | sgivwfb_mem_size &= ~((1 << 20) - 1); | ||
102 | sgivwfb_mem_phys = mem_size - gfx_mem_size; | ||
103 | |||
104 | e820_add_region(0, LOWMEMSIZE(), E820_RAM); | ||
105 | e820_add_region(HIGH_MEMORY, mem_size - sgivwfb_mem_size - HIGH_MEMORY, E820_RAM); | ||
106 | e820_add_region(sgivwfb_mem_phys, sgivwfb_mem_size, E820_RESERVED); | ||
107 | |||
108 | return "PROM"; | ||
109 | } | ||
110 | |||
111 | static void visws_machine_emergency_restart(void) | ||
112 | { | ||
113 | /* | ||
114 | * Visual Workstations restart after this | ||
115 | * register is poked on the PIIX4 | ||
116 | */ | ||
117 | outb(PIIX4_RESET_VAL, PIIX4_RESET_PORT); | ||
118 | } | ||
119 | |||
120 | static void visws_machine_power_off(void) | ||
121 | { | ||
122 | unsigned short pm_status; | ||
123 | /* extern unsigned int pci_bus0; */ | ||
124 | |||
125 | while ((pm_status = inw(PMSTS_PORT)) & 0x100) | ||
126 | outw(pm_status, PMSTS_PORT); | ||
127 | |||
128 | outw(PM_SUSPEND_ENABLE, PMCNTRL_PORT); | ||
129 | |||
130 | mdelay(10); | ||
131 | |||
132 | #define PCI_CONF1_ADDRESS(bus, devfn, reg) \ | ||
133 | (0x80000000 | (bus << 16) | (devfn << 8) | (reg & ~3)) | ||
134 | |||
135 | /* outl(PCI_CONF1_ADDRESS(pci_bus0, SPECIAL_DEV, SPECIAL_REG), 0xCF8); */ | ||
136 | outl(PIIX_SPECIAL_STOP, 0xCFC); | ||
137 | } | ||
138 | |||
139 | static int __init visws_get_smp_config_quirk(unsigned int early) | ||
140 | { | ||
141 | /* | ||
142 | * Prevent MP-table parsing by the generic code: | ||
143 | */ | ||
144 | return 1; | ||
145 | } | ||
146 | |||
147 | extern unsigned int __cpuinitdata maxcpus; | ||
148 | |||
149 | /* | ||
150 | * The Visual Workstation is Intel MP compliant in the hardware | ||
151 | * sense, but it doesn't have a BIOS(-configuration table). | ||
152 | * No problem for Linux. | ||
153 | */ | ||
154 | |||
155 | static void __init MP_processor_info (struct mpc_config_processor *m) | ||
156 | { | ||
157 | int ver, logical_apicid; | ||
158 | physid_mask_t apic_cpus; | ||
159 | |||
160 | if (!(m->mpc_cpuflag & CPU_ENABLED)) | ||
161 | return; | ||
162 | |||
163 | logical_apicid = m->mpc_apicid; | ||
164 | printk(KERN_INFO "%sCPU #%d %u:%u APIC version %d\n", | ||
165 | m->mpc_cpuflag & CPU_BOOTPROCESSOR ? "Bootup " : "", | ||
166 | m->mpc_apicid, | ||
167 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, | ||
168 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, | ||
169 | m->mpc_apicver); | ||
170 | |||
171 | if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) | ||
172 | boot_cpu_physical_apicid = m->mpc_apicid; | ||
173 | |||
174 | ver = m->mpc_apicver; | ||
175 | if ((ver >= 0x14 && m->mpc_apicid >= 0xff) || m->mpc_apicid >= 0xf) { | ||
176 | printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n", | ||
177 | m->mpc_apicid, MAX_APICS); | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | apic_cpus = apicid_to_cpu_present(m->mpc_apicid); | ||
182 | physids_or(phys_cpu_present_map, phys_cpu_present_map, apic_cpus); | ||
183 | /* | ||
184 | * Validate version | ||
185 | */ | ||
186 | if (ver == 0x0) { | ||
187 | printk(KERN_ERR "BIOS bug, APIC version is 0 for CPU#%d! " | ||
188 | "fixing up to 0x10. (tell your hw vendor)\n", | ||
189 | m->mpc_apicid); | ||
190 | ver = 0x10; | ||
191 | } | ||
192 | apic_version[m->mpc_apicid] = ver; | ||
193 | } | ||
194 | |||
195 | int __init visws_find_smp_config_quirk(unsigned int reserve) | ||
196 | { | ||
197 | struct mpc_config_processor *mp = phys_to_virt(CO_CPU_TAB_PHYS); | ||
198 | unsigned short ncpus = readw(phys_to_virt(CO_CPU_NUM_PHYS)); | ||
199 | |||
200 | if (ncpus > CO_CPU_MAX) { | ||
201 | printk(KERN_WARNING "find_visws_smp: got cpu count of %d at %p\n", | ||
202 | ncpus, mp); | ||
203 | |||
204 | ncpus = CO_CPU_MAX; | ||
205 | } | ||
206 | |||
207 | if (ncpus > maxcpus) | ||
208 | ncpus = maxcpus; | ||
209 | |||
210 | #ifdef CONFIG_X86_LOCAL_APIC | ||
211 | smp_found_config = 1; | ||
212 | #endif | ||
213 | while (ncpus--) | ||
214 | MP_processor_info(mp++); | ||
215 | |||
216 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; | ||
217 | |||
218 | return 1; | ||
219 | } | ||
220 | |||
221 | extern int visws_trap_init_quirk(void); | ||
222 | |||
223 | void __init visws_early_detect(void) | ||
224 | { | ||
225 | int raw; | ||
226 | |||
227 | visws_board_type = (char)(inb_p(PIIX_GPI_BD_REG) & PIIX_GPI_BD_REG) | ||
228 | >> PIIX_GPI_BD_SHIFT; | ||
229 | |||
230 | if (visws_board_type < 0) | ||
231 | return; | ||
232 | |||
233 | /* | ||
234 | * Install special quirks for timer, interrupt and memory setup: | ||
235 | */ | ||
236 | arch_time_init_quirk = visws_time_init_quirk; | ||
237 | arch_pre_intr_init_quirk = visws_pre_intr_init_quirk; | ||
238 | arch_memory_setup_quirk = visws_memory_setup_quirk; | ||
239 | |||
240 | /* | ||
241 | * Fall back to generic behavior for traps: | ||
242 | */ | ||
243 | arch_intr_init_quirk = NULL; | ||
244 | arch_trap_init_quirk = visws_trap_init_quirk; | ||
245 | |||
246 | /* | ||
247 | * Install reboot quirks: | ||
248 | */ | ||
249 | pm_power_off = visws_machine_power_off; | ||
250 | machine_ops.emergency_restart = visws_machine_emergency_restart; | ||
251 | |||
252 | /* | ||
253 | * Do not use broadcast IPIs: | ||
254 | */ | ||
255 | no_broadcast = 0; | ||
256 | |||
257 | /* | ||
258 | * Override generic MP-table parsing: | ||
259 | */ | ||
260 | mach_get_smp_config_quirk = visws_get_smp_config_quirk; | ||
261 | mach_find_smp_config_quirk = visws_find_smp_config_quirk; | ||
262 | |||
263 | /* | ||
264 | * Get Board rev. | ||
265 | * First, we have to initialize the 307 part to allow us access | ||
266 | * to the GPIO registers. Let's map them at 0x0fc0 which is right | ||
267 | * after the PIIX4 PM section. | ||
268 | */ | ||
269 | outb_p(SIO_DEV_SEL, SIO_INDEX); | ||
270 | outb_p(SIO_GP_DEV, SIO_DATA); /* Talk to GPIO regs. */ | ||
271 | |||
272 | outb_p(SIO_DEV_MSB, SIO_INDEX); | ||
273 | outb_p(SIO_GP_MSB, SIO_DATA); /* MSB of GPIO base address */ | ||
274 | |||
275 | outb_p(SIO_DEV_LSB, SIO_INDEX); | ||
276 | outb_p(SIO_GP_LSB, SIO_DATA); /* LSB of GPIO base address */ | ||
277 | |||
278 | outb_p(SIO_DEV_ENB, SIO_INDEX); | ||
279 | outb_p(1, SIO_DATA); /* Enable GPIO registers. */ | ||
280 | |||
281 | /* | ||
282 | * Now, we have to map the power management section to write | ||
283 | * a bit which enables access to the GPIO registers. | ||
284 | * What lunatic came up with this shit? | ||
285 | */ | ||
286 | outb_p(SIO_DEV_SEL, SIO_INDEX); | ||
287 | outb_p(SIO_PM_DEV, SIO_DATA); /* Talk to GPIO regs. */ | ||
288 | |||
289 | outb_p(SIO_DEV_MSB, SIO_INDEX); | ||
290 | outb_p(SIO_PM_MSB, SIO_DATA); /* MSB of PM base address */ | ||
291 | |||
292 | outb_p(SIO_DEV_LSB, SIO_INDEX); | ||
293 | outb_p(SIO_PM_LSB, SIO_DATA); /* LSB of PM base address */ | ||
294 | |||
295 | outb_p(SIO_DEV_ENB, SIO_INDEX); | ||
296 | outb_p(1, SIO_DATA); /* Enable PM registers. */ | ||
297 | |||
298 | /* | ||
299 | * Now, write the PM register which enables the GPIO registers. | ||
300 | */ | ||
301 | outb_p(SIO_PM_FER2, SIO_PM_INDEX); | ||
302 | outb_p(SIO_PM_GP_EN, SIO_PM_DATA); | ||
303 | |||
304 | /* | ||
305 | * Now, initialize the GPIO registers. | ||
306 | * We want them all to be inputs which is the | ||
307 | * power on default, so let's leave them alone. | ||
308 | * So, let's just read the board rev! | ||
309 | */ | ||
310 | raw = inb_p(SIO_GP_DATA1); | ||
311 | raw &= 0x7f; /* 7 bits of valid board revision ID. */ | ||
312 | |||
313 | if (visws_board_type == VISWS_320) { | ||
314 | if (raw < 0x6) { | ||
315 | visws_board_rev = 4; | ||
316 | } else if (raw < 0xc) { | ||
317 | visws_board_rev = 5; | ||
318 | } else { | ||
319 | visws_board_rev = 6; | ||
320 | } | ||
321 | } else if (visws_board_type == VISWS_540) { | ||
322 | visws_board_rev = 2; | ||
323 | } else { | ||
324 | visws_board_rev = raw; | ||
325 | } | ||
326 | |||
327 | printk(KERN_INFO "Silicon Graphics Visual Workstation %s (rev %d) detected\n", | ||
328 | (visws_board_type == VISWS_320 ? "320" : | ||
329 | (visws_board_type == VISWS_540 ? "540" : | ||
330 | "unknown")), visws_board_rev); | ||
331 | } | ||
diff --git a/arch/x86/kernel/traps_visws.c b/arch/x86/kernel/traps_visws.c new file mode 100644 index 000000000000..e5e6492c2676 --- /dev/null +++ b/arch/x86/kernel/traps_visws.c | |||
@@ -0,0 +1,71 @@ | |||
1 | /* VISWS traps */ | ||
2 | |||
3 | #include <linux/sched.h> | ||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/init.h> | ||
6 | #include <linux/pci.h> | ||
7 | #include <linux/pci_ids.h> | ||
8 | |||
9 | #include <asm/io.h> | ||
10 | #include <asm/apic.h> | ||
11 | #include <asm/arch_hooks.h> | ||
12 | #include <asm/visws/cobalt.h> | ||
13 | #include <asm/visws/lithium.h> | ||
14 | |||
15 | |||
16 | #define A01234 (LI_INTA_0 | LI_INTA_1 | LI_INTA_2 | LI_INTA_3 | LI_INTA_4) | ||
17 | #define BCD (LI_INTB | LI_INTC | LI_INTD) | ||
18 | #define ALLDEVS (A01234 | BCD) | ||
19 | |||
20 | static __init void lithium_init(void) | ||
21 | { | ||
22 | set_fixmap(FIX_LI_PCIA, LI_PCI_A_PHYS); | ||
23 | set_fixmap(FIX_LI_PCIB, LI_PCI_B_PHYS); | ||
24 | |||
25 | if ((li_pcia_read16(PCI_VENDOR_ID) != PCI_VENDOR_ID_SGI) || | ||
26 | (li_pcia_read16(PCI_DEVICE_ID) != PCI_DEVICE_ID_SGI_LITHIUM)) { | ||
27 | printk(KERN_EMERG "Lithium hostbridge %c not found\n", 'A'); | ||
28 | /* panic("This machine is not SGI Visual Workstation 320/540"); */ | ||
29 | } | ||
30 | |||
31 | if ((li_pcib_read16(PCI_VENDOR_ID) != PCI_VENDOR_ID_SGI) || | ||
32 | (li_pcib_read16(PCI_DEVICE_ID) != PCI_DEVICE_ID_SGI_LITHIUM)) { | ||
33 | printk(KERN_EMERG "Lithium hostbridge %c not found\n", 'B'); | ||
34 | /* panic("This machine is not SGI Visual Workstation 320/540"); */ | ||
35 | } | ||
36 | |||
37 | li_pcia_write16(LI_PCI_INTEN, ALLDEVS); | ||
38 | li_pcib_write16(LI_PCI_INTEN, ALLDEVS); | ||
39 | } | ||
40 | |||
41 | static __init void cobalt_init(void) | ||
42 | { | ||
43 | /* | ||
44 | * On normal SMP PC this is used only with SMP, but we have to | ||
45 | * use it and set it up here to start the Cobalt clock | ||
46 | */ | ||
47 | set_fixmap(FIX_APIC_BASE, APIC_DEFAULT_PHYS_BASE); | ||
48 | setup_local_APIC(); | ||
49 | printk(KERN_INFO "Local APIC Version %#x, ID %#x\n", | ||
50 | (unsigned int)apic_read(APIC_LVR), | ||
51 | (unsigned int)apic_read(APIC_ID)); | ||
52 | |||
53 | set_fixmap(FIX_CO_CPU, CO_CPU_PHYS); | ||
54 | set_fixmap(FIX_CO_APIC, CO_APIC_PHYS); | ||
55 | printk(KERN_INFO "Cobalt Revision %#lx, APIC ID %#lx\n", | ||
56 | co_cpu_read(CO_CPU_REV), co_apic_read(CO_APIC_ID)); | ||
57 | |||
58 | /* Enable Cobalt APIC being careful to NOT change the ID! */ | ||
59 | co_apic_write(CO_APIC_ID, co_apic_read(CO_APIC_ID) | CO_APIC_ENABLE); | ||
60 | |||
61 | printk(KERN_INFO "Cobalt APIC enabled: ID reg %#lx\n", | ||
62 | co_apic_read(CO_APIC_ID)); | ||
63 | } | ||
64 | |||
65 | int __init visws_trap_init_quirk(void) | ||
66 | { | ||
67 | lithium_init(); | ||
68 | cobalt_init(); | ||
69 | |||
70 | return 1; | ||
71 | } | ||