1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * Reset a Jazz machine. 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * We don't trust the firmware so we do it the classic way by poking and 61da177e4SLinus Torvalds * stabbing at the keyboard controller ... 71da177e4SLinus Torvalds */ 81da177e4SLinus Torvalds #include <linux/jiffies.h> 91da177e4SLinus Torvalds #include <asm/jazz.h> 101da177e4SLinus Torvalds 111da177e4SLinus Torvalds #define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */ 121da177e4SLinus Torvalds jazz_write_output(unsigned char val)131da177e4SLinus Torvaldsstatic void jazz_write_output(unsigned char val) 141da177e4SLinus Torvalds { 151da177e4SLinus Torvalds int status; 161da177e4SLinus Torvalds 171da177e4SLinus Torvalds do { 181da177e4SLinus Torvalds status = jazz_kh->command; 191da177e4SLinus Torvalds } while (status & KBD_STAT_IBF); 201da177e4SLinus Torvalds jazz_kh->data = val; 211da177e4SLinus Torvalds } 221da177e4SLinus Torvalds jazz_write_command(unsigned char val)231da177e4SLinus Torvaldsstatic void jazz_write_command(unsigned char val) 241da177e4SLinus Torvalds { 251da177e4SLinus Torvalds int status; 261da177e4SLinus Torvalds 271da177e4SLinus Torvalds do { 281da177e4SLinus Torvalds status = jazz_kh->command; 291da177e4SLinus Torvalds } while (status & KBD_STAT_IBF); 301da177e4SLinus Torvalds jazz_kh->command = val; 311da177e4SLinus Torvalds } 321da177e4SLinus Torvalds jazz_read_status(void)331da177e4SLinus Torvaldsstatic unsigned char jazz_read_status(void) 341da177e4SLinus Torvalds { 351da177e4SLinus Torvalds return jazz_kh->command; 361da177e4SLinus Torvalds } 371da177e4SLinus Torvalds kb_wait(void)381da177e4SLinus Torvaldsstatic inline void kb_wait(void) 391da177e4SLinus Torvalds { 401da177e4SLinus Torvalds unsigned long start = jiffies; 411da177e4SLinus Torvalds unsigned long timeout = start + HZ/2; 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds do { 441da177e4SLinus Torvalds if (! (jazz_read_status() & 0x02)) 451da177e4SLinus Torvalds return; 461da177e4SLinus Torvalds } while (time_before_eq(jiffies, timeout)); 471da177e4SLinus Torvalds } 481da177e4SLinus Torvalds jazz_machine_restart(char * command)491da177e4SLinus Torvaldsvoid jazz_machine_restart(char *command) 501da177e4SLinus Torvalds { 511da177e4SLinus Torvalds while(1) { 521da177e4SLinus Torvalds kb_wait(); 531da177e4SLinus Torvalds jazz_write_command(0xd1); 541da177e4SLinus Torvalds kb_wait(); 551da177e4SLinus Torvalds jazz_write_output(0x00); 561da177e4SLinus Torvalds } 571da177e4SLinus Torvalds } 58