xref: /linux/arch/mips/sni/reset.c (revision c861519fcf95b2d46cb4275903423b43ae150a40)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  *  linux/arch/mips/sni/process.c
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  *  Reset a SNI machine.
51da177e4SLinus Torvalds  */
6*c861519fSRalf Baechle #include <linux/delay.h>
7*c861519fSRalf Baechle 
81da177e4SLinus Torvalds #include <asm/io.h>
91da177e4SLinus Torvalds #include <asm/reboot.h>
101da177e4SLinus Torvalds #include <asm/sni.h>
111da177e4SLinus Torvalds 
121da177e4SLinus Torvalds /*
131da177e4SLinus Torvalds  * This routine reboots the machine by asking the keyboard
141da177e4SLinus Torvalds  * controller to pulse the reset-line low. We try that for a while,
151da177e4SLinus Torvalds  * and if it doesn't work, we do some other stupid things.
161da177e4SLinus Torvalds  */
17c066a32aSThomas Bogendoerfer static inline void kb_wait(void)
181da177e4SLinus Torvalds {
191da177e4SLinus Torvalds 	int i;
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds 	for (i = 0; i < 0x10000; i++)
221da177e4SLinus Torvalds 		if ((inb_p(0x64) & 0x02) == 0)
231da177e4SLinus Torvalds 			break;
241da177e4SLinus Torvalds }
251da177e4SLinus Torvalds 
261da177e4SLinus Torvalds /* XXX This ends up at the ARC firmware prompt ...  */
271da177e4SLinus Torvalds void sni_machine_restart(char *command)
281da177e4SLinus Torvalds {
291da177e4SLinus Torvalds 	int i, j;
301da177e4SLinus Torvalds 
311da177e4SLinus Torvalds 	/* This does a normal via the keyboard controller like a PC.
321da177e4SLinus Torvalds 	   We can do that easier ...  */
331da177e4SLinus Torvalds 	local_irq_disable();
341da177e4SLinus Torvalds 	for (;;) {
351da177e4SLinus Torvalds 		for (i = 0; i < 100; i++) {
361da177e4SLinus Torvalds 			kb_wait();
37*c861519fSRalf Baechle 			udelay(50);
381da177e4SLinus Torvalds 			outb_p(0xfe, 0x64);	 /* pulse reset low */
39*c861519fSRalf Baechle 			udelay(50);
401da177e4SLinus Torvalds 		}
411da177e4SLinus Torvalds 	}
421da177e4SLinus Torvalds }
431da177e4SLinus Torvalds 
441da177e4SLinus Torvalds void sni_machine_power_off(void)
451da177e4SLinus Torvalds {
461da177e4SLinus Torvalds 	*(volatile unsigned char *)PCIMT_CSWCSM = 0xfd;
471da177e4SLinus Torvalds }
48