Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / i386 / mach-visws / setup.c
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
10 #include <asm/fixmap.h>
11 #include <asm/arch_hooks.h>
12 #include <asm/io.h>
13 #include "cobalt.h"
14 #include "piix4.h"
15
16 int no_broadcast;
17
18 char visws_board_type = -1;
19 char visws_board_rev = -1;
20
21 void __init visws_get_board_type_and_rev(void)
22 {
23         int raw;
24
25         visws_board_type = (char)(inb_p(PIIX_GPI_BD_REG) & PIIX_GPI_BD_REG)
26                                                          >> PIIX_GPI_BD_SHIFT;
27         /*
28          * Get Board rev.
29          * First, we have to initialize the 307 part to allow us access
30          * to the GPIO registers.  Let's map them at 0x0fc0 which is right
31          * after the PIIX4 PM section.
32          */
33         outb_p(SIO_DEV_SEL, SIO_INDEX);
34         outb_p(SIO_GP_DEV, SIO_DATA);   /* Talk to GPIO regs. */
35
36         outb_p(SIO_DEV_MSB, SIO_INDEX);
37         outb_p(SIO_GP_MSB, SIO_DATA);   /* MSB of GPIO base address */
38
39         outb_p(SIO_DEV_LSB, SIO_INDEX);
40         outb_p(SIO_GP_LSB, SIO_DATA);   /* LSB of GPIO base address */
41
42         outb_p(SIO_DEV_ENB, SIO_INDEX);
43         outb_p(1, SIO_DATA);            /* Enable GPIO registers. */
44
45         /*
46          * Now, we have to map the power management section to write
47          * a bit which enables access to the GPIO registers.
48          * What lunatic came up with this shit?
49          */
50         outb_p(SIO_DEV_SEL, SIO_INDEX);
51         outb_p(SIO_PM_DEV, SIO_DATA);   /* Talk to GPIO regs. */
52
53         outb_p(SIO_DEV_MSB, SIO_INDEX);
54         outb_p(SIO_PM_MSB, SIO_DATA);   /* MSB of PM base address */
55
56         outb_p(SIO_DEV_LSB, SIO_INDEX);
57         outb_p(SIO_PM_LSB, SIO_DATA);   /* LSB of PM base address */
58
59         outb_p(SIO_DEV_ENB, SIO_INDEX);
60         outb_p(1, SIO_DATA);            /* Enable PM registers. */
61
62         /*
63          * Now, write the PM register which enables the GPIO registers.
64          */
65         outb_p(SIO_PM_FER2, SIO_PM_INDEX);
66         outb_p(SIO_PM_GP_EN, SIO_PM_DATA);
67
68         /*
69          * Now, initialize the GPIO registers.
70          * We want them all to be inputs which is the
71          * power on default, so let's leave them alone.
72          * So, let's just read the board rev!
73          */
74         raw = inb_p(SIO_GP_DATA1);
75         raw &= 0x7f;    /* 7 bits of valid board revision ID. */
76
77         if (visws_board_type == VISWS_320) {
78                 if (raw < 0x6) {
79                         visws_board_rev = 4;
80                 } else if (raw < 0xc) {
81                         visws_board_rev = 5;
82                 } else {
83                         visws_board_rev = 6;
84                 }
85         } else if (visws_board_type == VISWS_540) {
86                         visws_board_rev = 2;
87                 } else {
88                         visws_board_rev = raw;
89                 }
90
91         printk(KERN_INFO "Silicon Graphics Visual Workstation %s (rev %d) detected\n",
92                (visws_board_type == VISWS_320 ? "320" :
93                (visws_board_type == VISWS_540 ? "540" :
94                 "unknown")), visws_board_rev);
95 }
96
97 void __init pre_intr_init_hook(void)
98 {
99         init_VISWS_APIC_irqs();
100 }
101
102 void __init intr_init_hook(void)
103 {
104 #ifdef CONFIG_X86_LOCAL_APIC
105         apic_intr_init();
106 #endif
107 }
108
109 void __init pre_setup_arch_hook()
110 {
111         visws_get_board_type_and_rev();
112 }
113
114 static struct irqaction irq0 = {
115         .handler =      timer_interrupt,
116         .flags =        SA_INTERRUPT,
117         .name =         "timer",
118 };
119
120 void __init time_init_hook(void)
121 {
122         printk(KERN_INFO "Starting Cobalt Timer system clock\n");
123
124         /* Set the countdown value */
125         co_cpu_write(CO_CPU_TIMEVAL, CO_TIME_HZ/HZ);
126
127         /* Start the timer */
128         co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) | CO_CTRL_TIMERUN);
129
130         /* Enable (unmask) the timer interrupt */
131         co_cpu_write(CO_CPU_CTRL, co_cpu_read(CO_CPU_CTRL) & ~CO_CTRL_TIMEMASK);
132
133         /* Wire cpu IDT entry to s/w handler (and Cobalt APIC to IDT) */
134         setup_irq(0, &irq0);
135 }