1 /* Copyright (C) 1999,2001
3 * Author: J.E.J.Bottomley@HansenPartnership.com
5 * This file contains all the voyager specific routines for getting
6 * initialisation of the architecture to function. For additional
9 * voyager_cat.c - Voyager CAT bus interface
10 * voyager_smp.c - Voyager SMP hal (emulates linux smp.c)
13 #include <linux/module.h>
14 #include <linux/types.h>
15 #include <linux/sched.h>
16 #include <linux/ptrace.h>
17 #include <linux/ioport.h>
18 #include <linux/interrupt.h>
19 #include <linux/init.h>
20 #include <linux/delay.h>
21 #include <linux/reboot.h>
22 #include <linux/sysrq.h>
23 #include <linux/smp.h>
24 #include <linux/nodemask.h>
26 #include <asm/voyager.h>
29 #include <asm/tlbflush.h>
30 #include <asm/arch_hooks.h>
31 #include <asm/i8253.h>
34 * Power off function, if any
36 void (*pm_power_off) (void);
37 EXPORT_SYMBOL(pm_power_off);
39 int voyager_level = 0;
41 struct voyager_SUS *voyager_SUS = NULL;
44 static void voyager_dump(int dummy1, struct tty_struct *dummy3)
46 /* get here via a sysrq */
50 static struct sysrq_key_op sysrq_voyager_dump_op = {
51 .handler = voyager_dump,
52 .help_msg = "Voyager",
53 .action_msg = "Dump Voyager Status",
57 void voyager_detect(struct voyager_bios_info *bios)
59 if (bios->len != 0xff) {
60 int class = (bios->class_1 << 8)
61 | (bios->class_2 & 0xff);
63 printk("Voyager System detected.\n"
64 " Class %x, Revision %d.%d\n",
65 class, bios->major, bios->minor);
66 if (class == VOYAGER_LEVEL4)
68 else if (class < VOYAGER_LEVEL5_AND_ABOVE)
72 printk(" Architecture Level %d\n", voyager_level);
73 if (voyager_level < 4)
75 ("\n**WARNING**: Voyager HAL only supports Levels 4 and 5 Architectures at the moment\n\n");
76 /* install the power off handler */
77 pm_power_off = voyager_power_off;
79 register_sysrq_key('v', &sysrq_voyager_dump_op);
82 printk("\n\n**WARNING**: No Voyager Subsystem Found\n");
86 void voyager_system_interrupt(int cpl, void *dev_id)
88 printk("Voyager: detected system interrupt\n");
91 /* Routine to read information from the extended CMOS area */
92 __u8 voyager_extended_cmos_read(__u16 addr)
94 outb(addr & 0xff, 0x74);
95 outb((addr >> 8) & 0xff, 0x75);
99 /* internal definitions for the SUS Click Map of memory */
101 #define CLICK_ENTRIES 16
102 #define CLICK_SIZE 4096 /* click to byte conversion for Length */
104 typedef struct ClickMap {
108 } Entry[CLICK_ENTRIES];
111 /* This routine is pretty much an awful hack to read the bios clickmap by
112 * mapping it into page 0. There are usually three regions in the map:
115 * zero length marker for end of map
117 * Returns are 0 for failure and 1 for success on extracting region.
119 int __init voyager_memory_detect(int region, __u32 * start, __u32 * length)
125 unsigned long map_addr;
128 if (region >= CLICK_ENTRIES) {
129 printk("Voyager: Illegal ClickMap region %d\n", region);
133 for (i = 0; i < sizeof(cmos); i++)
135 voyager_extended_cmos_read(VOYAGER_MEMORY_CLICKMAP + i);
137 map_addr = *(unsigned long *)cmos;
139 /* steal page 0 for this */
141 pg0[0] = ((map_addr & PAGE_MASK) | _PAGE_RW | _PAGE_PRESENT);
143 /* now clear everything out but page 0 */
144 map = (ClickMap_t *) (map_addr & (~PAGE_MASK));
146 /* zero length is the end of the clickmap */
147 if (map->Entry[region].Length != 0) {
148 *length = map->Entry[region].Length * CLICK_SIZE;
149 *start = map->Entry[region].Address;
153 /* replace the mapping */
159 /* voyager specific handling code for timer interrupts. Used to hand
160 * off the timer tick to the SMP code, since the VIC doesn't have an
161 * internal timer (The QIC does, but that's another story). */
162 void voyager_timer_interrupt(void)
164 if ((jiffies & 0x3ff) == 0) {
166 /* There seems to be something flaky in either
167 * hardware or software that is resetting the timer 0
168 * count to something much higher than it should be
169 * This seems to occur in the boot sequence, just
170 * before root is mounted. Therefore, every 10
171 * seconds or so, we sanity check the timer zero count
172 * and kick it back to where it should be.
174 * FIXME: This is the most awful hack yet seen. I
175 * should work out exactly what is interfering with
176 * the timer count settings early in the boot sequence
177 * and swiftly introduce it to something sharp and
181 spin_lock(&i8253_lock);
185 val |= inb(0x40) << 8;
186 spin_unlock(&i8253_lock);
190 ("\nVOYAGER: countdown timer value too high (%d), resetting\n\n",
192 spin_lock(&i8253_lock);
194 outb_p(LATCH & 0xff, 0x40); /* LSB */
195 outb(LATCH >> 8, 0x40); /* MSB */
196 spin_unlock(&i8253_lock);
200 smp_vic_timer_interrupt();
204 void voyager_power_off(void)
206 printk("VOYAGER Power Off\n");
208 if (voyager_level == 5) {
209 voyager_cat_power_off();
210 } else if (voyager_level == 4) {
211 /* This doesn't apparently work on most L4 machines,
212 * but the specs say to do this to get automatic power
213 * off. Unfortunately, if it doesn't power off the
214 * machine, it ends up doing a cold restart, which
215 * isn't really intended, so comment out the code */
219 /* enable the voyager Configuration Space */
220 outb((inb(VOYAGER_MC_SETUP) & 0xf0) | 0x8, VOYAGER_MC_SETUP);
221 /* the port for the power off flag is an offset from the
223 port = (inb(VOYAGER_SSPB_RELOCATION_PORT) << 8) + 0x21;
224 /* set the power off flag */
225 outb(inb(port) | 0x1, port);
228 /* and wait for it to happen */
234 /* copied from process.c */
235 static inline void kb_wait(void)
239 for (i = 0; i < 0x10000; i++)
240 if ((inb_p(0x64) & 0x02) == 0)
244 void machine_shutdown(void)
246 /* Architecture specific shutdown needed before a kexec */
249 void machine_restart(char *cmd)
251 printk("Voyager Warm Restart\n");
254 if (voyager_level == 5) {
255 /* write magic values to the RTC to inform system that
256 * shutdown is beginning */
261 outb(0xfe, 0x64); /* pull reset low */
262 } else if (voyager_level == 4) {
263 __u16 catbase = inb(VOYAGER_SSPB_RELOCATION_PORT) << 8;
264 __u8 basebd = inb(VOYAGER_MC_SETUP);
266 outb(basebd | 0x08, VOYAGER_MC_SETUP);
267 outb(0x02, catbase + 0x21);
274 void machine_emergency_restart(void)
276 /*for now, just hook this to a warm restart */
277 machine_restart(NULL);
280 void mca_nmi_hook(void)
282 __u8 dumpval __maybe_unused = inb(0xf823);
283 __u8 swnmi __maybe_unused = inb(0xf813);
285 /* FIXME: assume dump switch pressed */
286 /* check to see if the dump switch was pressed */
287 VDEBUG(("VOYAGER: dumpval = 0x%x, swnmi = 0x%x\n", dumpval, swnmi));
290 /* tell SUS to ignore dump */
291 if (voyager_level == 5 && voyager_SUS != NULL) {
292 if (voyager_SUS->SUS_mbox == VOYAGER_DUMP_BUTTON_NMI) {
293 voyager_SUS->kernel_mbox = VOYAGER_NO_COMMAND;
294 voyager_SUS->kernel_flags |= VOYAGER_OS_IN_PROGRESS;
296 voyager_SUS->kernel_mbox = VOYAGER_IGNORE_DUMP;
297 voyager_SUS->kernel_flags &= ~VOYAGER_OS_IN_PROGRESS;
301 "VOYAGER: Dump switch pressed, printing CPU%d tracebacks\n",
303 show_stack(NULL, NULL);
307 void machine_halt(void)
309 /* treat a halt like a power off */
313 void machine_power_off(void)