ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / mips / jazz / reset.c
1 /*
2  * Reset a Jazz machine.
3  *
4  * We don't trust the firmware so we do it the classic way by poking and
5  * stabbing at the keyboard controller ...
6  */
7 #include <linux/jiffies.h>
8 #include <asm/jazz.h>
9 #include <asm/io.h>
10 #include <asm/system.h>
11 #include <asm/reboot.h>
12 #include <asm/delay.h>
13
14 #define jazz_kh ((keyboard_hardware *) JAZZ_KEYBOARD_ADDRESS)
15
16 #define KBD_STAT_IBF            0x02    /* Keyboard input buffer full */
17
18 static void jazz_write_output(unsigned char val)
19 {
20         int status;
21
22         do {
23                 status = jazz_kh->command;
24         } while (status & KBD_STAT_IBF);
25         jazz_kh->data = val;
26 }
27
28 static void jazz_write_command(unsigned char val)
29 {
30         int status;
31
32         do {
33                 status = jazz_kh->command;
34         } while (status & KBD_STAT_IBF);
35         jazz_kh->command = val;
36 }
37
38 static unsigned char jazz_read_status(void)
39 {
40         return jazz_kh->command;
41 }
42
43 static inline void kb_wait(void)
44 {
45         unsigned long start = jiffies;
46         unsigned long timeout = start + HZ/2;
47
48         do {
49                 if (! (jazz_read_status() & 0x02))
50                         return;
51         } while (time_before_eq(jiffies, timeout));
52 }
53
54 void jazz_machine_restart(char *command)
55 {
56         while(1) {
57                 kb_wait();
58                 jazz_write_command (0xd1);
59                 kb_wait();
60                 jazz_write_output (0x00);
61         }
62 }
63
64 void jazz_machine_halt(void)
65 {
66 }
67
68 void jazz_machine_power_off(void)
69 {
70         /* Jazz machines don't have a software power switch */
71 }