Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Reset a Jazz machine.
0004  *
0005  * We don't trust the firmware so we do it the classic way by poking and
0006  * stabbing at the keyboard controller ...
0007  */
0008 #include <linux/jiffies.h>
0009 #include <asm/jazz.h>
0010 
0011 #define KBD_STAT_IBF        0x02    /* Keyboard input buffer full */
0012 
0013 static void jazz_write_output(unsigned char val)
0014 {
0015     int status;
0016 
0017     do {
0018         status = jazz_kh->command;
0019     } while (status & KBD_STAT_IBF);
0020     jazz_kh->data = val;
0021 }
0022 
0023 static void jazz_write_command(unsigned char val)
0024 {
0025     int status;
0026 
0027     do {
0028         status = jazz_kh->command;
0029     } while (status & KBD_STAT_IBF);
0030     jazz_kh->command = val;
0031 }
0032 
0033 static unsigned char jazz_read_status(void)
0034 {
0035     return jazz_kh->command;
0036 }
0037 
0038 static inline void kb_wait(void)
0039 {
0040     unsigned long start = jiffies;
0041     unsigned long timeout = start + HZ/2;
0042 
0043     do {
0044         if (! (jazz_read_status() & 0x02))
0045             return;
0046     } while (time_before_eq(jiffies, timeout));
0047 }
0048 
0049 void jazz_machine_restart(char *command)
0050 {
0051     while(1) {
0052         kb_wait();
0053         jazz_write_command(0xd1);
0054         kb_wait();
0055         jazz_write_output(0x00);
0056     }
0057 }