1 /* Copyright (C) 1999,2001
3 * Author: J.E.J.Bottomley@HansenPartnership.com
5 * linux/arch/i386/kernel/voyager.c
7 * This file contains all the voyager specific routines for getting
8 * initialisation of the architecture to function. For additional
11 * voyager_cat.c - Voyager CAT bus interface
12 * voyager_smp.c - Voyager SMP hal (emulates linux smp.c)
15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/sched.h>
18 #include <linux/ptrace.h>
19 #include <linux/ioport.h>
20 #include <linux/interrupt.h>
21 #include <linux/init.h>
22 #include <linux/delay.h>
23 #include <linux/reboot.h>
24 #include <linux/sysrq.h>
25 #include <linux/smp.h>
26 #include <linux/nodemask.h>
28 #include <asm/voyager.h>
31 #include <asm/tlbflush.h>
32 #include <asm/arch_hooks.h>
33 #include <asm/i8253.h>
36 * Power off function, if any
38 void (*pm_power_off
) (void);
39 EXPORT_SYMBOL(pm_power_off
);
41 int voyager_level
= 0;
43 struct voyager_SUS
*voyager_SUS
= NULL
;
46 static void voyager_dump(int dummy1
, struct tty_struct
*dummy3
)
48 /* get here via a sysrq */
52 static struct sysrq_key_op sysrq_voyager_dump_op
= {
53 .handler
= voyager_dump
,
54 .help_msg
= "Voyager",
55 .action_msg
= "Dump Voyager Status",
59 void voyager_detect(struct voyager_bios_info
*bios
)
61 if (bios
->len
!= 0xff) {
62 int class = (bios
->class_1
<< 8)
63 | (bios
->class_2
& 0xff);
65 printk("Voyager System detected.\n"
66 " Class %x, Revision %d.%d\n",
67 class, bios
->major
, bios
->minor
);
68 if (class == VOYAGER_LEVEL4
)
70 else if (class < VOYAGER_LEVEL5_AND_ABOVE
)
74 printk(" Architecture Level %d\n", voyager_level
);
75 if (voyager_level
< 4)
77 ("\n**WARNING**: Voyager HAL only supports Levels 4 and 5 Architectures at the moment\n\n");
78 /* install the power off handler */
79 pm_power_off
= voyager_power_off
;
81 register_sysrq_key('v', &sysrq_voyager_dump_op
);
84 printk("\n\n**WARNING**: No Voyager Subsystem Found\n");
88 void voyager_system_interrupt(int cpl
, void *dev_id
)
90 printk("Voyager: detected system interrupt\n");
93 /* Routine to read information from the extended CMOS area */
94 __u8
voyager_extended_cmos_read(__u16 addr
)
96 outb(addr
& 0xff, 0x74);
97 outb((addr
>> 8) & 0xff, 0x75);
101 /* internal definitions for the SUS Click Map of memory */
103 #define CLICK_ENTRIES 16
104 #define CLICK_SIZE 4096 /* click to byte conversion for Length */
106 typedef struct ClickMap
{
110 } Entry
[CLICK_ENTRIES
];
113 /* This routine is pretty much an awful hack to read the bios clickmap by
114 * mapping it into page 0. There are usually three regions in the map:
117 * zero length marker for end of map
119 * Returns are 0 for failure and 1 for success on extracting region.
121 int __init
voyager_memory_detect(int region
, __u32
* start
, __u32
* length
)
127 unsigned long map_addr
;
130 if (region
>= CLICK_ENTRIES
) {
131 printk("Voyager: Illegal ClickMap region %d\n", region
);
135 for (i
= 0; i
< sizeof(cmos
); i
++)
137 voyager_extended_cmos_read(VOYAGER_MEMORY_CLICKMAP
+ i
);
139 map_addr
= *(unsigned long *)cmos
;
141 /* steal page 0 for this */
143 pg0
[0] = ((map_addr
& PAGE_MASK
) | _PAGE_RW
| _PAGE_PRESENT
);
145 /* now clear everything out but page 0 */
146 map
= (ClickMap_t
*) (map_addr
& (~PAGE_MASK
));
148 /* zero length is the end of the clickmap */
149 if (map
->Entry
[region
].Length
!= 0) {
150 *length
= map
->Entry
[region
].Length
* CLICK_SIZE
;
151 *start
= map
->Entry
[region
].Address
;
155 /* replace the mapping */
161 /* voyager specific handling code for timer interrupts. Used to hand
162 * off the timer tick to the SMP code, since the VIC doesn't have an
163 * internal timer (The QIC does, but that's another story). */
164 void voyager_timer_interrupt(void)
166 if ((jiffies
& 0x3ff) == 0) {
168 /* There seems to be something flaky in either
169 * hardware or software that is resetting the timer 0
170 * count to something much higher than it should be
171 * This seems to occur in the boot sequence, just
172 * before root is mounted. Therefore, every 10
173 * seconds or so, we sanity check the timer zero count
174 * and kick it back to where it should be.
176 * FIXME: This is the most awful hack yet seen. I
177 * should work out exactly what is interfering with
178 * the timer count settings early in the boot sequence
179 * and swiftly introduce it to something sharp and
183 spin_lock(&i8253_lock
);
187 val
|= inb(0x40) << 8;
188 spin_unlock(&i8253_lock
);
192 ("\nVOYAGER: countdown timer value too high (%d), resetting\n\n",
194 spin_lock(&i8253_lock
);
196 outb_p(LATCH
& 0xff, 0x40); /* LSB */
197 outb(LATCH
>> 8, 0x40); /* MSB */
198 spin_unlock(&i8253_lock
);
202 smp_vic_timer_interrupt();
206 void voyager_power_off(void)
208 printk("VOYAGER Power Off\n");
210 if (voyager_level
== 5) {
211 voyager_cat_power_off();
212 } else if (voyager_level
== 4) {
213 /* This doesn't apparently work on most L4 machines,
214 * but the specs say to do this to get automatic power
215 * off. Unfortunately, if it doesn't power off the
216 * machine, it ends up doing a cold restart, which
217 * isn't really intended, so comment out the code */
221 /* enable the voyager Configuration Space */
222 outb((inb(VOYAGER_MC_SETUP
) & 0xf0) | 0x8, VOYAGER_MC_SETUP
);
223 /* the port for the power off flag is an offset from the
225 port
= (inb(VOYAGER_SSPB_RELOCATION_PORT
) << 8) + 0x21;
226 /* set the power off flag */
227 outb(inb(port
) | 0x1, port
);
230 /* and wait for it to happen */
236 /* copied from process.c */
237 static inline void kb_wait(void)
241 for (i
= 0; i
< 0x10000; i
++)
242 if ((inb_p(0x64) & 0x02) == 0)
246 void machine_shutdown(void)
248 /* Architecture specific shutdown needed before a kexec */
251 void machine_restart(char *cmd
)
253 printk("Voyager Warm Restart\n");
256 if (voyager_level
== 5) {
257 /* write magic values to the RTC to inform system that
258 * shutdown is beginning */
263 outb(0xfe, 0x64); /* pull reset low */
264 } else if (voyager_level
== 4) {
265 __u16 catbase
= inb(VOYAGER_SSPB_RELOCATION_PORT
) << 8;
266 __u8 basebd
= inb(VOYAGER_MC_SETUP
);
268 outb(basebd
| 0x08, VOYAGER_MC_SETUP
);
269 outb(0x02, catbase
+ 0x21);
276 void machine_emergency_restart(void)
278 /*for now, just hook this to a warm restart */
279 machine_restart(NULL
);
282 void mca_nmi_hook(void)
284 __u8 dumpval __maybe_unused
= inb(0xf823);
285 __u8 swnmi __maybe_unused
= inb(0xf813);
287 /* FIXME: assume dump switch pressed */
288 /* check to see if the dump switch was pressed */
289 VDEBUG(("VOYAGER: dumpval = 0x%x, swnmi = 0x%x\n", dumpval
, swnmi
));
292 /* tell SUS to ignore dump */
293 if (voyager_level
== 5 && voyager_SUS
!= NULL
) {
294 if (voyager_SUS
->SUS_mbox
== VOYAGER_DUMP_BUTTON_NMI
) {
295 voyager_SUS
->kernel_mbox
= VOYAGER_NO_COMMAND
;
296 voyager_SUS
->kernel_flags
|= VOYAGER_OS_IN_PROGRESS
;
298 voyager_SUS
->kernel_mbox
= VOYAGER_IGNORE_DUMP
;
299 voyager_SUS
->kernel_flags
&= ~VOYAGER_OS_IN_PROGRESS
;
303 "VOYAGER: Dump switch pressed, printing CPU%d tracebacks\n",
305 show_stack(NULL
, NULL
);
309 void machine_halt(void)
311 /* treat a halt like a power off */
315 void machine_power_off(void)