18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * linux/arch/mips/sni/process.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Reset a SNI machine. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#include <linux/delay.h> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <asm/io.h> 108c2ecf20Sopenharmony_ci#include <asm/reboot.h> 118c2ecf20Sopenharmony_ci#include <asm/sni.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * This routine reboots the machine by asking the keyboard 158c2ecf20Sopenharmony_ci * controller to pulse the reset-line low. We try that for a while, 168c2ecf20Sopenharmony_ci * and if it doesn't work, we do some other stupid things. 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_cistatic inline void kb_wait(void) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci int i; 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci for (i = 0; i < 0x10000; i++) 238c2ecf20Sopenharmony_ci if ((inb_p(0x64) & 0x02) == 0) 248c2ecf20Sopenharmony_ci break; 258c2ecf20Sopenharmony_ci} 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* XXX This ends up at the ARC firmware prompt ... */ 288c2ecf20Sopenharmony_civoid sni_machine_restart(char *command) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci int i; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci /* This does a normal via the keyboard controller like a PC. 338c2ecf20Sopenharmony_ci We can do that easier ... */ 348c2ecf20Sopenharmony_ci local_irq_disable(); 358c2ecf20Sopenharmony_ci for (;;) { 368c2ecf20Sopenharmony_ci for (i = 0; i < 100; i++) { 378c2ecf20Sopenharmony_ci kb_wait(); 388c2ecf20Sopenharmony_ci udelay(50); 398c2ecf20Sopenharmony_ci outb_p(0xfe, 0x64); /* pulse reset low */ 408c2ecf20Sopenharmony_ci udelay(50); 418c2ecf20Sopenharmony_ci } 428c2ecf20Sopenharmony_ci } 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_civoid sni_machine_power_off(void) 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci *(volatile unsigned char *)PCIMT_CSWCSM = 0xfd; 488c2ecf20Sopenharmony_ci} 49