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/config.h>
16 #include <linux/module.h>
17 #include <linux/types.h>
18 #include <linux/sched.h>
19 #include <linux/ptrace.h>
20 #include <linux/ioport.h>
21 #include <linux/interrupt.h>
22 #include <linux/init.h>
23 #include <linux/delay.h>
24 #include <linux/reboot.h>
25 #include <linux/sysrq.h>
26 #include <linux/smp.h>
27 #include <linux/nodemask.h>
29 #include <asm/voyager.h>
32 #include <asm/tlbflush.h>
33 #include <asm/arch_hooks.h>
34 #include <asm/i8253.h>
37 * Power off function, if any
39 void (*pm_power_off)(void);
40 EXPORT_SYMBOL(pm_power_off);
42 int voyager_level = 0;
44 struct voyager_SUS *voyager_SUS = NULL;
48 voyager_dump(int dummy1, struct pt_regs *dummy2, struct tty_struct *dummy3)
50 /* get here via a sysrq */
54 static struct sysrq_key_op sysrq_voyager_dump_op = {
55 .handler = voyager_dump,
56 .help_msg = "Voyager",
57 .action_msg = "Dump Voyager Status",
62 voyager_detect(struct voyager_bios_info *bios)
64 if(bios->len != 0xff) {
65 int class = (bios->class_1 << 8)
66 | (bios->class_2 & 0xff);
68 printk("Voyager System detected.\n"
69 " Class %x, Revision %d.%d\n",
70 class, bios->major, bios->minor);
71 if(class == VOYAGER_LEVEL4)
73 else if(class < VOYAGER_LEVEL5_AND_ABOVE)
77 printk(" Architecture Level %d\n", voyager_level);
79 printk("\n**WARNING**: Voyager HAL only supports Levels 4 and 5 Architectures at the moment\n\n");
80 /* install the power off handler */
81 pm_power_off = voyager_power_off;
83 register_sysrq_key('v', &sysrq_voyager_dump_op);
86 printk("\n\n**WARNING**: No Voyager Subsystem Found\n");
91 voyager_system_interrupt(int cpl, void *dev_id, struct pt_regs *regs)
93 printk("Voyager: detected system interrupt\n");
96 /* Routine to read information from the extended CMOS area */
98 voyager_extended_cmos_read(__u16 addr)
100 outb(addr & 0xff, 0x74);
101 outb((addr >> 8) & 0xff, 0x75);
105 /* internal definitions for the SUS Click Map of memory */
107 #define CLICK_ENTRIES 16
108 #define CLICK_SIZE 4096 /* click to byte conversion for Length */
110 typedef struct ClickMap {
114 } Entry[CLICK_ENTRIES];
118 /* This routine is pretty much an awful hack to read the bios clickmap by
119 * mapping it into page 0. There are usually three regions in the map:
122 * zero length marker for end of map
124 * Returns are 0 for failure and 1 for success on extracting region.
127 voyager_memory_detect(int region, __u32 *start, __u32 *length)
133 unsigned long map_addr;
136 if(region >= CLICK_ENTRIES) {
137 printk("Voyager: Illegal ClickMap region %d\n", region);
141 for(i = 0; i < sizeof(cmos); i++)
142 cmos[i] = voyager_extended_cmos_read(VOYAGER_MEMORY_CLICKMAP + i);
144 map_addr = *(unsigned long *)cmos;
146 /* steal page 0 for this */
148 pg0[0] = ((map_addr & PAGE_MASK) | _PAGE_RW | _PAGE_PRESENT);
150 /* now clear everything out but page 0 */
151 map = (ClickMap_t *)(map_addr & (~PAGE_MASK));
153 /* zero length is the end of the clickmap */
154 if(map->Entry[region].Length != 0) {
155 *length = map->Entry[region].Length * CLICK_SIZE;
156 *start = map->Entry[region].Address;
160 /* replace the mapping */
166 /* voyager specific handling code for timer interrupts. Used to hand
167 * off the timer tick to the SMP code, since the VIC doesn't have an
168 * internal timer (The QIC does, but that's another story). */
170 voyager_timer_interrupt(struct pt_regs *regs)
172 if((jiffies & 0x3ff) == 0) {
174 /* There seems to be something flaky in either
175 * hardware or software that is resetting the timer 0
176 * count to something much higher than it should be
177 * This seems to occur in the boot sequence, just
178 * before root is mounted. Therefore, every 10
179 * seconds or so, we sanity check the timer zero count
180 * and kick it back to where it should be.
182 * FIXME: This is the most awful hack yet seen. I
183 * should work out exactly what is interfering with
184 * the timer count settings early in the boot sequence
185 * and swiftly introduce it to something sharp and
189 spin_lock(&i8253_lock);
193 val |= inb(0x40) << 8;
194 spin_unlock(&i8253_lock);
197 printk("\nVOYAGER: countdown timer value too high (%d), resetting\n\n", val);
198 spin_lock(&i8253_lock);
200 outb_p(LATCH & 0xff , 0x40); /* LSB */
201 outb(LATCH >> 8 , 0x40); /* MSB */
202 spin_unlock(&i8253_lock);
206 smp_vic_timer_interrupt(regs);
211 voyager_power_off(void)
213 printk("VOYAGER Power Off\n");
215 if(voyager_level == 5) {
216 voyager_cat_power_off();
217 } else if(voyager_level == 4) {
218 /* This doesn't apparently work on most L4 machines,
219 * but the specs say to do this to get automatic power
220 * off. Unfortunately, if it doesn't power off the
221 * machine, it ends up doing a cold restart, which
222 * isn't really intended, so comment out the code */
227 /* enable the voyager Configuration Space */
228 outb((inb(VOYAGER_MC_SETUP) & 0xf0) | 0x8,
230 /* the port for the power off flag is an offset from the
232 port = (inb(VOYAGER_SSPB_RELOCATION_PORT) << 8) + 0x21;
233 /* set the power off flag */
234 outb(inb(port) | 0x1, port);
237 /* and wait for it to happen */
243 /* copied from process.c */
249 for (i=0; i<0x10000; i++)
250 if ((inb_p(0x64) & 0x02) == 0)
255 machine_shutdown(void)
257 /* Architecture specific shutdown needed before a kexec */
261 machine_restart(char *cmd)
263 printk("Voyager Warm Restart\n");
266 if(voyager_level == 5) {
267 /* write magic values to the RTC to inform system that
268 * shutdown is beginning */
273 outb(0xfe,0x64); /* pull reset low */
274 } else if(voyager_level == 4) {
275 __u16 catbase = inb(VOYAGER_SSPB_RELOCATION_PORT)<<8;
276 __u8 basebd = inb(VOYAGER_MC_SETUP);
278 outb(basebd | 0x08, VOYAGER_MC_SETUP);
279 outb(0x02, catbase + 0x21);
287 machine_emergency_restart(void)
289 /*for now, just hook this to a warm restart */
290 machine_restart(NULL);
296 __u8 dumpval __attribute__((unused)) = inb(0xf823);
297 __u8 swnmi __attribute__((unused)) = inb(0xf813);
299 /* FIXME: assume dump switch pressed */
300 /* check to see if the dump switch was pressed */
301 VDEBUG(("VOYAGER: dumpval = 0x%x, swnmi = 0x%x\n", dumpval, swnmi));
304 /* tell SUS to ignore dump */
305 if(voyager_level == 5 && voyager_SUS != NULL) {
306 if(voyager_SUS->SUS_mbox == VOYAGER_DUMP_BUTTON_NMI) {
307 voyager_SUS->kernel_mbox = VOYAGER_NO_COMMAND;
308 voyager_SUS->kernel_flags |= VOYAGER_OS_IN_PROGRESS;
310 voyager_SUS->kernel_mbox = VOYAGER_IGNORE_DUMP;
311 voyager_SUS->kernel_flags &= ~VOYAGER_OS_IN_PROGRESS;
314 printk(KERN_ERR "VOYAGER: Dump switch pressed, printing CPU%d tracebacks\n", smp_processor_id());
315 show_stack(NULL, NULL);
324 /* treat a halt like a power off */
328 void machine_power_off(void)