diff options
Diffstat (limited to 'arch/x86/mach-visws')
-rw-r--r-- | arch/x86/mach-visws/Makefile | 8 | ||||
-rw-r--r-- | arch/x86/mach-visws/mpparse.c | 88 | ||||
-rw-r--r-- | arch/x86/mach-visws/reboot.c | 55 | ||||
-rw-r--r-- | arch/x86/mach-visws/setup.c | 183 | ||||
-rw-r--r-- | arch/x86/mach-visws/traps.c | 69 | ||||
-rw-r--r-- | arch/x86/mach-visws/visws_apic.c | 297 |
6 files changed, 0 insertions, 700 deletions
diff --git a/arch/x86/mach-visws/Makefile b/arch/x86/mach-visws/Makefile deleted file mode 100644 index 835fd96ad768..000000000000 --- a/arch/x86/mach-visws/Makefile +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | # | ||
2 | # Makefile for the linux kernel. | ||
3 | # | ||
4 | |||
5 | obj-y := setup.o traps.o reboot.o | ||
6 | |||
7 | obj-$(CONFIG_X86_VISWS_APIC) += visws_apic.o | ||
8 | obj-$(CONFIG_X86_LOCAL_APIC) += mpparse.o | ||
diff --git a/arch/x86/mach-visws/mpparse.c b/arch/x86/mach-visws/mpparse.c deleted file mode 100644 index 57484e91ab90..000000000000 --- a/arch/x86/mach-visws/mpparse.c +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | |||
2 | #include <linux/init.h> | ||
3 | #include <linux/smp.h> | ||
4 | |||
5 | #include <asm/smp.h> | ||
6 | #include <asm/io.h> | ||
7 | |||
8 | #include "cobalt.h" | ||
9 | #include "mach_apic.h" | ||
10 | |||
11 | /* Have we found an MP table */ | ||
12 | int smp_found_config; | ||
13 | |||
14 | int pic_mode; | ||
15 | |||
16 | extern unsigned int __cpuinitdata maxcpus; | ||
17 | |||
18 | /* | ||
19 | * The Visual Workstation is Intel MP compliant in the hardware | ||
20 | * sense, but it doesn't have a BIOS(-configuration table). | ||
21 | * No problem for Linux. | ||
22 | */ | ||
23 | |||
24 | static void __init MP_processor_info (struct mpc_config_processor *m) | ||
25 | { | ||
26 | int ver, logical_apicid; | ||
27 | physid_mask_t apic_cpus; | ||
28 | |||
29 | if (!(m->mpc_cpuflag & CPU_ENABLED)) | ||
30 | return; | ||
31 | |||
32 | logical_apicid = m->mpc_apicid; | ||
33 | printk(KERN_INFO "%sCPU #%d %u:%u APIC version %d\n", | ||
34 | m->mpc_cpuflag & CPU_BOOTPROCESSOR ? "Bootup " : "", | ||
35 | m->mpc_apicid, | ||
36 | (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, | ||
37 | (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, | ||
38 | m->mpc_apicver); | ||
39 | |||
40 | if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) | ||
41 | boot_cpu_physical_apicid = m->mpc_apicid; | ||
42 | |||
43 | ver = m->mpc_apicver; | ||
44 | if ((ver >= 0x14 && m->mpc_apicid >= 0xff) || m->mpc_apicid >= 0xf) { | ||
45 | printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n", | ||
46 | m->mpc_apicid, MAX_APICS); | ||
47 | return; | ||
48 | } | ||
49 | |||
50 | apic_cpus = apicid_to_cpu_present(m->mpc_apicid); | ||
51 | physids_or(phys_cpu_present_map, phys_cpu_present_map, apic_cpus); | ||
52 | /* | ||
53 | * Validate version | ||
54 | */ | ||
55 | if (ver == 0x0) { | ||
56 | printk(KERN_ERR "BIOS bug, APIC version is 0 for CPU#%d! " | ||
57 | "fixing up to 0x10. (tell your hw vendor)\n", | ||
58 | m->mpc_apicid); | ||
59 | ver = 0x10; | ||
60 | } | ||
61 | apic_version[m->mpc_apicid] = ver; | ||
62 | } | ||
63 | |||
64 | void __init find_smp_config(void) | ||
65 | { | ||
66 | struct mpc_config_processor *mp = phys_to_virt(CO_CPU_TAB_PHYS); | ||
67 | unsigned short ncpus = readw(phys_to_virt(CO_CPU_NUM_PHYS)); | ||
68 | |||
69 | if (ncpus > CO_CPU_MAX) { | ||
70 | printk(KERN_WARNING "find_visws_smp: got cpu count of %d at %p\n", | ||
71 | ncpus, mp); | ||
72 | |||
73 | ncpus = CO_CPU_MAX; | ||
74 | } | ||
75 | |||
76 | if (ncpus > maxcpus) | ||
77 | ncpus = maxcpus; | ||
78 | |||
79 | smp_found_config = 1; | ||
80 | while (ncpus--) | ||
81 | MP_processor_info(mp++); | ||
82 | |||
83 | mp_lapic_addr = APIC_DEFAULT_PHYS_BASE; | ||
84 | } | ||
85 | |||
86 | void __init get_smp_config (void) | ||
87 | { | ||
88 | } | ||
diff --git a/arch/x86/mach-visws/reboot.c b/arch/x86/mach-visws/reboot.c deleted file mode 100644 index 99332abfad42..000000000000 --- a/arch/x86/mach-visws/reboot.c +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <linux/smp.h> | ||
3 | #include <linux/delay.h> | ||
4 | |||
5 | #include <asm/io.h> | ||
6 | #include "piix4.h" | ||
7 | |||
8 | void (*pm_power_off)(void); | ||
9 | EXPORT_SYMBOL(pm_power_off); | ||
10 | |||
11 | void machine_shutdown(void) | ||
12 | { | ||
13 | #ifdef CONFIG_SMP | ||
14 | smp_send_stop(); | ||
15 | #endif | ||
16 | } | ||
17 | |||
18 | void machine_emergency_restart(void) | ||
19 | { | ||
20 | /* | ||
21 | * Visual Workstations restart after this | ||
22 | * register is poked on the PIIX4 | ||
23 | */ | ||
24 | outb(PIIX4_RESET_VAL, PIIX4_RESET_PORT); | ||
25 | } | ||
26 | |||
27 | void machine_restart(char * __unused) | ||
28 | { | ||
29 | machine_shutdown(); | ||
30 | machine_emergency_restart(); | ||
31 | } | ||
32 | |||
33 | void machine_power_off(void) | ||
34 | { | ||
35 | unsigned short pm_status; | ||
36 | extern unsigned int pci_bus0; | ||
37 | |||
38 | while ((pm_status = inw(PMSTS_PORT)) & 0x100) | ||
39 | outw(pm_status, PMSTS_PORT); | ||
40 | |||
41 | outw(PM_SUSPEND_ENABLE, PMCNTRL_PORT); | ||
42 | |||
43 | mdelay(10); | ||
44 | |||
45 | #define PCI_CONF1_ADDRESS(bus, devfn, reg) \ | ||
46 | (0x80000000 | (bus << 16) | (devfn << 8) | (reg & ~3)) | ||
47 | |||
48 | outl(PCI_CONF1_ADDRESS(pci_bus0, SPECIAL_DEV, SPECIAL_REG), 0xCF8); | ||
49 | outl(PIIX_SPECIAL_STOP, 0xCFC); | ||
50 | } | ||
51 | |||
52 | void machine_halt(void) | ||
53 | { | ||
54 | } | ||
55 | |||
diff --git a/arch/x86/mach-visws/setup.c b/arch/x86/mach-visws/setup.c deleted file mode 100644 index de4c9dbd086f..000000000000 --- a/arch/x86/mach-visws/setup.c +++ /dev/null | |||
@@ -1,183 +0,0 @@ | |||
1 | /* | ||
2 | * Unmaintained SGI Visual Workstation support. | ||
3 | * Split out from setup.c by davej@suse.de | ||
4 | */ | ||
5 | |||
6 | #include <linux/smp.h> | ||
7 | #include <linux/init.h> | ||
8 | #include <linux/interrupt.h> | ||
9 | #include <linux/module.h> | ||
10 | |||
11 | #include <asm/fixmap.h> | ||
12 | #include <asm/arch_hooks.h> | ||
13 | #include <asm/io.h> | ||
14 | #include <asm/e820.h> | ||
15 | #include <asm/setup.h> | ||
16 | #include "cobalt.h" | ||
17 | #include "piix4.h" | ||
18 | |||
19 | int no_broadcast; | ||
20 | |||
21 | char visws_board_type = -1; | ||
22 | char visws_board_rev = -1; | ||
23 | |||
24 | void __init visws_get_board_type_and_rev(void) | ||
25 | { | ||
26 | int raw; | ||
27 | |||
28 | visws_board_type = (char)(inb_p(PIIX_GPI_BD_REG) & PIIX_GPI_BD_REG) | ||
29 | >> PIIX_GPI_BD_SHIFT; | ||
30 | /* | ||
31 | * Get Board rev. | ||
32 | * First, we have to initialize the 307 part to allow us access | ||
33 | * to the GPIO registers. Let's map them at 0x0fc0 which is right | ||
34 | * after the PIIX4 PM section. | ||
35 | */ | ||
36 | outb_p(SIO_DEV_SEL, SIO_INDEX); | ||
37 | outb_p(SIO_GP_DEV, SIO_DATA); /* Talk to GPIO regs. */ | ||
38 | |||
39 | outb_p(SIO_DEV_MSB, SIO_INDEX); | ||
40 | outb_p(SIO_GP_MSB, SIO_DATA); /* MSB of GPIO base address */ | ||
41 | |||
42 | outb_p(SIO_DEV_LSB, SIO_INDEX); | ||
43 | outb_p(SIO_GP_LSB, SIO_DATA); /* LSB of GPIO base address */ | ||
44 | |||
45 | outb_p(SIO_DEV_ENB, SIO_INDEX); | ||
46 | outb_p(1, SIO_DATA); /* Enable GPIO registers. */ | ||
47 | |||
48 | /* | ||
49 | * Now, we have to map the power management section to write | ||
50 | * a bit which enables access to the GPIO registers. | ||
51 | * What lunatic came up with this shit? | ||
52 | */ | ||
53 | outb_p(SIO_DEV_SEL, SIO_INDEX); | ||
54 | outb_p(SIO_PM_DEV, SIO_DATA); /* Talk to GPIO regs. */ | ||
55 | |||
56 | outb_p(SIO_DEV_MSB, SIO_INDEX); | ||
57 | outb_p(SIO_PM_MSB, SIO_DATA); /* MSB of PM base address */ | ||
58 | |||
59 | outb_p(SIO_DEV_LSB, SIO_INDEX); | ||
60 | outb_p(SIO_PM_LSB, SIO_DATA); /* LSB of PM base address */ | ||
61 | |||
62 | outb_p(SIO_DEV_ENB, SIO_INDEX); | ||
63 | outb_p(1, SIO_DATA); /* Enable PM registers. */ | ||
64 | |||
65 | /* | ||
66 | * Now, write the PM register which enables the GPIO registers. | ||
67 | */ | ||
68 | outb_p(SIO_PM_FER2, SIO_PM_INDEX); | ||
69 | outb_p(SIO_PM_GP_EN, SIO_PM_DATA); | ||
70 | |||
71 | /* | ||
72 | * Now, initialize the GPIO registers. | ||
73 | * We want them all to be inputs which is the | ||
74 | * power on default, so let's leave them alone. | ||
75 | * So, let's just read the board rev! | ||
76 | */ | ||
77 | raw = inb_p(SIO_GP_DATA1); | ||
78 | raw &= 0x7f; /* 7 bits of valid board revision ID. */ | ||
79 | |||
80 | if (visws_board_type == VISWS_320) { | ||
81 | if (raw < 0x6) { | ||
82 | visws_board_rev = 4; | ||
83 | } else if (raw < 0xc) { | ||
84 | visws_board_rev = 5; | ||
85 | } else { | ||
86 | visws_board_rev = 6; | ||
87 | } | ||
88 | } else if (visws_board_type == VISWS_540) { | ||
89 | visws_board_rev = 2; | ||
90 | } else { | ||
91 | visws_board_rev = raw; | ||
92 | } | ||
93 | |||
94 | printk(KERN_INFO "Silicon Graphics Visual Workstation %s (rev %d) detected\n", | ||
95 | (visws_board_type == VISWS_320 ? "320" : | ||
96 | (visws_board_type == VISWS_540 ? "540" : | ||
97 | "unknown")), visws_board_rev); | ||
98 | } | ||
99 | |||
100 | void __init pre_intr_init_hook(void) | ||
101 | { | ||
102 | init_VISWS_APIC_irqs(); | ||
103 | } | ||
104 | |||
105 | void __init intr_init_hook(void) | ||
106 | { | ||
107 | #ifdef CONFIG_X86_LOCAL_APIC | ||
108 | apic_intr_init(); | ||
109 | #endif | ||
110 | } | ||
111 | |||
112 | void __init pre_setup_arch_hook() | ||
113 | { | ||
114 | visws_get_board_type_and_rev(); | ||
115 | } | ||
116 | |||
117 | static struct irqaction irq0 = { | ||
118 | .handler = timer_interrupt, | ||
119 | .flags = IRQF_DISABLED | IRQF_IRQPOLL, | ||
120 | .name = "timer", | ||
121 | }; | ||
122 | |||
123 | void __init time_init_hook(void) | ||
124 | { | ||
125 | printk(KERN_INFO "Starting Cobalt Timer system clock\n"); | ||
126 | |||
127 | /* Set the countdown value */ | ||
128 | co_cpu_write(CO_CPU_TIMEVAL, CO_TIME_HZ/HZ); | ||
129 | |||
130 | /* Start the timer */ | ||
131 | co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) | CO_CTRL_TIMERUN); | ||
132 | |||
133 | /* Enable (unmask) the timer interrupt */ | ||
134 | co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) & ~CO_CTRL_TIMEMASK); | ||
135 | |||
136 | /* Wire cpu IDT entry to s/w handler (and Cobalt APIC to IDT) */ | ||
137 | setup_irq(0, &irq0); | ||
138 | } | ||
139 | |||
140 | /* Hook for machine specific memory setup. */ | ||
141 | |||
142 | #define MB (1024 * 1024) | ||
143 | |||
144 | unsigned long sgivwfb_mem_phys; | ||
145 | unsigned long sgivwfb_mem_size; | ||
146 | EXPORT_SYMBOL(sgivwfb_mem_phys); | ||
147 | EXPORT_SYMBOL(sgivwfb_mem_size); | ||
148 | |||
149 | long long mem_size __initdata = 0; | ||
150 | |||
151 | char * __init machine_specific_memory_setup(void) | ||
152 | { | ||
153 | long long gfx_mem_size = 8 * MB; | ||
154 | |||
155 | mem_size = boot_params.alt_mem_k; | ||
156 | |||
157 | if (!mem_size) { | ||
158 | printk(KERN_WARNING "Bootloader didn't set memory size, upgrade it !\n"); | ||
159 | mem_size = 128 * MB; | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * this hardcodes the graphics memory to 8 MB | ||
164 | * it really should be sized dynamically (or at least | ||
165 | * set as a boot param) | ||
166 | */ | ||
167 | if (!sgivwfb_mem_size) { | ||
168 | printk(KERN_WARNING "Defaulting to 8 MB framebuffer size\n"); | ||
169 | sgivwfb_mem_size = 8 * MB; | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Trim to nearest MB | ||
174 | */ | ||
175 | sgivwfb_mem_size &= ~((1 << 20) - 1); | ||
176 | sgivwfb_mem_phys = mem_size - gfx_mem_size; | ||
177 | |||
178 | add_memory_region(0, LOWMEMSIZE(), E820_RAM); | ||
179 | add_memory_region(HIGH_MEMORY, mem_size - sgivwfb_mem_size - HIGH_MEMORY, E820_RAM); | ||
180 | add_memory_region(sgivwfb_mem_phys, sgivwfb_mem_size, E820_RESERVED); | ||
181 | |||
182 | return "PROM"; | ||
183 | } | ||
diff --git a/arch/x86/mach-visws/traps.c b/arch/x86/mach-visws/traps.c deleted file mode 100644 index bfac6ba10f8a..000000000000 --- a/arch/x86/mach-visws/traps.c +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
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/arch_hooks.h> | ||
11 | #include <asm/apic.h> | ||
12 | #include "cobalt.h" | ||
13 | #include "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 | void __init trap_init_hook(void) | ||
66 | { | ||
67 | lithium_init(); | ||
68 | cobalt_init(); | ||
69 | } | ||
diff --git a/arch/x86/mach-visws/visws_apic.c b/arch/x86/mach-visws/visws_apic.c deleted file mode 100644 index cef9cb1d15ac..000000000000 --- a/arch/x86/mach-visws/visws_apic.c +++ /dev/null | |||
@@ -1,297 +0,0 @@ | |||
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 | |||
25 | #include "cobalt.h" | ||
26 | #include "irq_vectors.h" | ||
27 | |||
28 | |||
29 | static DEFINE_SPINLOCK(cobalt_lock); | ||
30 | |||
31 | /* | ||
32 | * Set the given Cobalt APIC Redirection Table entry to point | ||
33 | * to the given IDT vector/index. | ||
34 | */ | ||
35 | static inline void co_apic_set(int entry, int irq) | ||
36 | { | ||
37 | co_apic_write(CO_APIC_LO(entry), CO_APIC_LEVEL | (irq + FIRST_EXTERNAL_VECTOR)); | ||
38 | co_apic_write(CO_APIC_HI(entry), 0); | ||
39 | } | ||
40 | |||
41 | /* | ||
42 | * Cobalt (IO)-APIC functions to handle PCI devices. | ||
43 | */ | ||
44 | static inline int co_apic_ide0_hack(void) | ||
45 | { | ||
46 | extern char visws_board_type; | ||
47 | extern char visws_board_rev; | ||
48 | |||
49 | if (visws_board_type == VISWS_320 && visws_board_rev == 5) | ||
50 | return 5; | ||
51 | return CO_APIC_IDE0; | ||
52 | } | ||
53 | |||
54 | static int is_co_apic(unsigned int irq) | ||
55 | { | ||
56 | if (IS_CO_APIC(irq)) | ||
57 | return CO_APIC(irq); | ||
58 | |||
59 | switch (irq) { | ||
60 | case 0: return CO_APIC_CPU; | ||
61 | case CO_IRQ_IDE0: return co_apic_ide0_hack(); | ||
62 | case CO_IRQ_IDE1: return CO_APIC_IDE1; | ||
63 | default: return -1; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | |||
68 | /* | ||
69 | * This is the SGI Cobalt (IO-)APIC: | ||
70 | */ | ||
71 | |||
72 | static void enable_cobalt_irq(unsigned int irq) | ||
73 | { | ||
74 | co_apic_set(is_co_apic(irq), irq); | ||
75 | } | ||
76 | |||
77 | static void disable_cobalt_irq(unsigned int irq) | ||
78 | { | ||
79 | int entry = is_co_apic(irq); | ||
80 | |||
81 | co_apic_write(CO_APIC_LO(entry), CO_APIC_MASK); | ||
82 | co_apic_read(CO_APIC_LO(entry)); | ||
83 | } | ||
84 | |||
85 | /* | ||
86 | * "irq" really just serves to identify the device. Here is where we | ||
87 | * map this to the Cobalt APIC entry where it's physically wired. | ||
88 | * This is called via request_irq -> setup_irq -> irq_desc->startup() | ||
89 | */ | ||
90 | static unsigned int startup_cobalt_irq(unsigned int irq) | ||
91 | { | ||
92 | unsigned long flags; | ||
93 | |||
94 | spin_lock_irqsave(&cobalt_lock, flags); | ||
95 | if ((irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS | IRQ_WAITING))) | ||
96 | irq_desc[irq].status &= ~(IRQ_DISABLED | IRQ_INPROGRESS | IRQ_WAITING); | ||
97 | enable_cobalt_irq(irq); | ||
98 | spin_unlock_irqrestore(&cobalt_lock, flags); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static void ack_cobalt_irq(unsigned int irq) | ||
103 | { | ||
104 | unsigned long flags; | ||
105 | |||
106 | spin_lock_irqsave(&cobalt_lock, flags); | ||
107 | disable_cobalt_irq(irq); | ||
108 | apic_write(APIC_EOI, APIC_EIO_ACK); | ||
109 | spin_unlock_irqrestore(&cobalt_lock, flags); | ||
110 | } | ||
111 | |||
112 | static void end_cobalt_irq(unsigned int irq) | ||
113 | { | ||
114 | unsigned long flags; | ||
115 | |||
116 | spin_lock_irqsave(&cobalt_lock, flags); | ||
117 | if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) | ||
118 | enable_cobalt_irq(irq); | ||
119 | spin_unlock_irqrestore(&cobalt_lock, flags); | ||
120 | } | ||
121 | |||
122 | static struct irq_chip cobalt_irq_type = { | ||
123 | .typename = "Cobalt-APIC", | ||
124 | .startup = startup_cobalt_irq, | ||
125 | .shutdown = disable_cobalt_irq, | ||
126 | .enable = enable_cobalt_irq, | ||
127 | .disable = disable_cobalt_irq, | ||
128 | .ack = ack_cobalt_irq, | ||
129 | .end = end_cobalt_irq, | ||
130 | }; | ||
131 | |||
132 | |||
133 | /* | ||
134 | * This is the PIIX4-based 8259 that is wired up indirectly to Cobalt | ||
135 | * -- not the manner expected by the code in i8259.c. | ||
136 | * | ||
137 | * there is a 'master' physical interrupt source that gets sent to | ||
138 | * the CPU. But in the chipset there are various 'virtual' interrupts | ||
139 | * waiting to be handled. We represent this to Linux through a 'master' | ||
140 | * interrupt controller type, and through a special virtual interrupt- | ||
141 | * controller. Device drivers only see the virtual interrupt sources. | ||
142 | */ | ||
143 | static unsigned int startup_piix4_master_irq(unsigned int irq) | ||
144 | { | ||
145 | init_8259A(0); | ||
146 | |||
147 | return startup_cobalt_irq(irq); | ||
148 | } | ||
149 | |||
150 | static void end_piix4_master_irq(unsigned int irq) | ||
151 | { | ||
152 | unsigned long flags; | ||
153 | |||
154 | spin_lock_irqsave(&cobalt_lock, flags); | ||
155 | enable_cobalt_irq(irq); | ||
156 | spin_unlock_irqrestore(&cobalt_lock, flags); | ||
157 | } | ||
158 | |||
159 | static struct irq_chip piix4_master_irq_type = { | ||
160 | .typename = "PIIX4-master", | ||
161 | .startup = startup_piix4_master_irq, | ||
162 | .ack = ack_cobalt_irq, | ||
163 | .end = end_piix4_master_irq, | ||
164 | }; | ||
165 | |||
166 | |||
167 | static struct irq_chip piix4_virtual_irq_type = { | ||
168 | .typename = "PIIX4-virtual", | ||
169 | .shutdown = disable_8259A_irq, | ||
170 | .enable = enable_8259A_irq, | ||
171 | .disable = disable_8259A_irq, | ||
172 | }; | ||
173 | |||
174 | |||
175 | /* | ||
176 | * PIIX4-8259 master/virtual functions to handle interrupt requests | ||
177 | * from legacy devices: floppy, parallel, serial, rtc. | ||
178 | * | ||
179 | * None of these get Cobalt APIC entries, neither do they have IDT | ||
180 | * entries. These interrupts are purely virtual and distributed from | ||
181 | * the 'master' interrupt source: CO_IRQ_8259. | ||
182 | * | ||
183 | * When the 8259 interrupts its handler figures out which of these | ||
184 | * devices is interrupting and dispatches to its handler. | ||
185 | * | ||
186 | * CAREFUL: devices see the 'virtual' interrupt only. Thus disable/ | ||
187 | * enable_irq gets the right irq. This 'master' irq is never directly | ||
188 | * manipulated by any driver. | ||
189 | */ | ||
190 | static irqreturn_t piix4_master_intr(int irq, void *dev_id) | ||
191 | { | ||
192 | int realirq; | ||
193 | irq_desc_t *desc; | ||
194 | unsigned long flags; | ||
195 | |||
196 | spin_lock_irqsave(&i8259A_lock, flags); | ||
197 | |||
198 | /* Find out what's interrupting in the PIIX4 master 8259 */ | ||
199 | outb(0x0c, 0x20); /* OCW3 Poll command */ | ||
200 | realirq = inb(0x20); | ||
201 | |||
202 | /* | ||
203 | * Bit 7 == 0 means invalid/spurious | ||
204 | */ | ||
205 | if (unlikely(!(realirq & 0x80))) | ||
206 | goto out_unlock; | ||
207 | |||
208 | realirq &= 7; | ||
209 | |||
210 | if (unlikely(realirq == 2)) { | ||
211 | outb(0x0c, 0xa0); | ||
212 | realirq = inb(0xa0); | ||
213 | |||
214 | if (unlikely(!(realirq & 0x80))) | ||
215 | goto out_unlock; | ||
216 | |||
217 | realirq = (realirq & 7) + 8; | ||
218 | } | ||
219 | |||
220 | /* mask and ack interrupt */ | ||
221 | cached_irq_mask |= 1 << realirq; | ||
222 | if (unlikely(realirq > 7)) { | ||
223 | inb(0xa1); | ||
224 | outb(cached_slave_mask, 0xa1); | ||
225 | outb(0x60 + (realirq & 7), 0xa0); | ||
226 | outb(0x60 + 2, 0x20); | ||
227 | } else { | ||
228 | inb(0x21); | ||
229 | outb(cached_master_mask, 0x21); | ||
230 | outb(0x60 + realirq, 0x20); | ||
231 | } | ||
232 | |||
233 | spin_unlock_irqrestore(&i8259A_lock, flags); | ||
234 | |||
235 | desc = irq_desc + realirq; | ||
236 | |||
237 | /* | ||
238 | * handle this 'virtual interrupt' as a Cobalt one now. | ||
239 | */ | ||
240 | kstat_cpu(smp_processor_id()).irqs[realirq]++; | ||
241 | |||
242 | if (likely(desc->action != NULL)) | ||
243 | handle_IRQ_event(realirq, desc->action); | ||
244 | |||
245 | if (!(desc->status & IRQ_DISABLED)) | ||
246 | enable_8259A_irq(realirq); | ||
247 | |||
248 | return IRQ_HANDLED; | ||
249 | |||
250 | out_unlock: | ||
251 | spin_unlock_irqrestore(&i8259A_lock, flags); | ||
252 | return IRQ_NONE; | ||
253 | } | ||
254 | |||
255 | static struct irqaction master_action = { | ||
256 | .handler = piix4_master_intr, | ||
257 | .name = "PIIX4-8259", | ||
258 | }; | ||
259 | |||
260 | static struct irqaction cascade_action = { | ||
261 | .handler = no_action, | ||
262 | .name = "cascade", | ||
263 | }; | ||
264 | |||
265 | |||
266 | void init_VISWS_APIC_irqs(void) | ||
267 | { | ||
268 | int i; | ||
269 | |||
270 | for (i = 0; i < CO_IRQ_APIC0 + CO_APIC_LAST + 1; i++) { | ||
271 | irq_desc[i].status = IRQ_DISABLED; | ||
272 | irq_desc[i].action = 0; | ||
273 | irq_desc[i].depth = 1; | ||
274 | |||
275 | if (i == 0) { | ||
276 | irq_desc[i].chip = &cobalt_irq_type; | ||
277 | } | ||
278 | else if (i == CO_IRQ_IDE0) { | ||
279 | irq_desc[i].chip = &cobalt_irq_type; | ||
280 | } | ||
281 | else if (i == CO_IRQ_IDE1) { | ||
282 | irq_desc[i].chip = &cobalt_irq_type; | ||
283 | } | ||
284 | else if (i == CO_IRQ_8259) { | ||
285 | irq_desc[i].chip = &piix4_master_irq_type; | ||
286 | } | ||
287 | else if (i < CO_IRQ_APIC0) { | ||
288 | irq_desc[i].chip = &piix4_virtual_irq_type; | ||
289 | } | ||
290 | else if (IS_CO_APIC(i)) { | ||
291 | irq_desc[i].chip = &cobalt_irq_type; | ||
292 | } | ||
293 | } | ||
294 | |||
295 | setup_irq(CO_IRQ_8259, &master_action); | ||
296 | setup_irq(2, &cascade_action); | ||
297 | } | ||