1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * linux/arch/mips/sni/process.c 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Reset a SNI machine. 61da177e4SLinus Torvalds */ 7c861519fSRalf Baechle #include <linux/delay.h> 8c861519fSRalf Baechle 91da177e4SLinus Torvalds #include <asm/io.h> 101da177e4SLinus Torvalds #include <asm/reboot.h> 111da177e4SLinus Torvalds #include <asm/sni.h> 121da177e4SLinus Torvalds 131da177e4SLinus Torvalds /* 141da177e4SLinus Torvalds * This routine reboots the machine by asking the keyboard 151da177e4SLinus Torvalds * controller to pulse the reset-line low. We try that for a while, 161da177e4SLinus Torvalds * and if it doesn't work, we do some other stupid things. 171da177e4SLinus Torvalds */ kb_wait(void)18c066a32aSThomas Bogendoerferstatic inline void kb_wait(void) 191da177e4SLinus Torvalds { 201da177e4SLinus Torvalds int i; 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds for (i = 0; i < 0x10000; i++) 231da177e4SLinus Torvalds if ((inb_p(0x64) & 0x02) == 0) 241da177e4SLinus Torvalds break; 251da177e4SLinus Torvalds } 261da177e4SLinus Torvalds 271da177e4SLinus Torvalds /* XXX This ends up at the ARC firmware prompt ... */ sni_machine_restart(char * command)281da177e4SLinus Torvaldsvoid sni_machine_restart(char *command) 291da177e4SLinus Torvalds { 30ec7b9720SRalf Baechle int i; 311da177e4SLinus Torvalds 321da177e4SLinus Torvalds /* This does a normal via the keyboard controller like a PC. 331da177e4SLinus Torvalds We can do that easier ... */ 341da177e4SLinus Torvalds local_irq_disable(); 351da177e4SLinus Torvalds for (;;) { 361da177e4SLinus Torvalds for (i = 0; i < 100; i++) { 371da177e4SLinus Torvalds kb_wait(); 38c861519fSRalf Baechle udelay(50); 391da177e4SLinus Torvalds outb_p(0xfe, 0x64); /* pulse reset low */ 40c861519fSRalf Baechle udelay(50); 411da177e4SLinus Torvalds } 421da177e4SLinus Torvalds } 431da177e4SLinus Torvalds } 441da177e4SLinus Torvalds sni_machine_power_off(void)451da177e4SLinus Torvaldsvoid sni_machine_power_off(void) 461da177e4SLinus Torvalds { 471da177e4SLinus Torvalds *(volatile unsigned char *)PCIMT_CSWCSM = 0xfd; 481da177e4SLinus Torvalds } 49