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 | */ |
Yoichi Yuasa | cc50b67 | 2007-03-06 21:34:44 +0900 | [diff] [blame] | 11 | #include <linux/jiffies.h> |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/reboot.h> |
Yoichi Yuasa | cc50b67 | 2007-03-06 21:34:44 +0900 | [diff] [blame] | 15 | |
| 16 | #include <cobalt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | void cobalt_machine_halt(void) |
| 19 | { |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 20 | int state, last, diff; |
| 21 | unsigned long mark; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 23 | /* |
| 24 | * turn off bar on Qube, flash power off LED on RaQ (0.5Hz) |
| 25 | * |
| 26 | * restart if ENTER and SELECT are pressed |
| 27 | */ |
| 28 | |
| 29 | last = COBALT_KEY_PORT; |
| 30 | |
| 31 | for (state = 0;;) { |
| 32 | |
| 33 | state ^= COBALT_LED_POWER_OFF; |
| 34 | COBALT_LED_PORT = state; |
| 35 | |
| 36 | diff = COBALT_KEY_PORT ^ last; |
| 37 | last ^= diff; |
| 38 | |
| 39 | if((diff & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)) && !(~last & (COBALT_KEY_ENTER | COBALT_KEY_SELECT))) |
| 40 | COBALT_LED_PORT = COBALT_LED_RESET; |
| 41 | |
| 42 | for (mark = jiffies; jiffies - mark < HZ;) |
| 43 | ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
Ralf Baechle | c4ed38a | 2005-02-21 16:18:36 +0000 | [diff] [blame] | 47 | void cobalt_machine_restart(char *command) |
| 48 | { |
| 49 | COBALT_LED_PORT = COBALT_LED_RESET; |
| 50 | |
| 51 | /* we should never get here */ |
| 52 | cobalt_machine_halt(); |
| 53 | } |
| 54 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | /* |
| 56 | * This triggers the luser mode device driver for the power switch ;-) |
| 57 | */ |
| 58 | void cobalt_machine_power_off(void) |
| 59 | { |
| 60 | printk("You can switch the machine off now.\n"); |
| 61 | cobalt_machine_halt(); |
| 62 | } |