| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Cobalt Reset operations | 
|  | 3 | * | 
|  | 4 | * This file is subject to the terms and conditions of the GNU General Public | 
|  | 5 | * License.  See the file "COPYING" in the main directory of this archive | 
|  | 6 | * for more details. | 
|  | 7 | * | 
|  | 8 | * Copyright (C) 1995, 1996, 1997 by Ralf Baechle | 
|  | 9 | * Copyright (C) 2001 by Liam Davies (ldavies@agile.tv) | 
|  | 10 | */ | 
|  | 11 | #include <linux/sched.h> | 
|  | 12 | #include <linux/mm.h> | 
|  | 13 | #include <asm/cacheflush.h> | 
|  | 14 | #include <asm/io.h> | 
|  | 15 | #include <asm/processor.h> | 
|  | 16 | #include <asm/reboot.h> | 
|  | 17 | #include <asm/system.h> | 
|  | 18 | #include <asm/mipsregs.h> | 
| Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 19 | #include <asm/cobalt/cobalt.h> | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 |  | 
|  | 21 | void cobalt_machine_halt(void) | 
|  | 22 | { | 
| Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 23 | int state, last, diff; | 
|  | 24 | unsigned long mark; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 |  | 
| Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 26 | /* | 
|  | 27 | * turn off bar on Qube, flash power off LED on RaQ (0.5Hz) | 
|  | 28 | * | 
|  | 29 | * restart if ENTER and SELECT are pressed | 
|  | 30 | */ | 
|  | 31 |  | 
|  | 32 | last = COBALT_KEY_PORT; | 
|  | 33 |  | 
|  | 34 | for (state = 0;;) { | 
|  | 35 |  | 
|  | 36 | state ^= COBALT_LED_POWER_OFF; | 
|  | 37 | COBALT_LED_PORT = state; | 
|  | 38 |  | 
|  | 39 | diff = COBALT_KEY_PORT ^ last; | 
|  | 40 | last ^= diff; | 
|  | 41 |  | 
|  | 42 | if((diff & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)) && !(~last & (COBALT_KEY_ENTER | COBALT_KEY_SELECT))) | 
|  | 43 | COBALT_LED_PORT = COBALT_LED_RESET; | 
|  | 44 |  | 
|  | 45 | for (mark = jiffies; jiffies - mark < HZ;) | 
|  | 46 | ; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | } | 
|  | 48 | } | 
|  | 49 |  | 
| Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 50 | void cobalt_machine_restart(char *command) | 
|  | 51 | { | 
|  | 52 | COBALT_LED_PORT = COBALT_LED_RESET; | 
|  | 53 |  | 
|  | 54 | /* we should never get here */ | 
|  | 55 | cobalt_machine_halt(); | 
|  | 56 | } | 
|  | 57 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | /* | 
|  | 59 | * This triggers the luser mode device driver for the power switch ;-) | 
|  | 60 | */ | 
|  | 61 | void cobalt_machine_power_off(void) | 
|  | 62 | { | 
|  | 63 | printk("You can switch the machine off now.\n"); | 
|  | 64 | cobalt_machine_halt(); | 
|  | 65 | } |