[MIPS] Cobalt: Add Cobalt Raq LED platform register and power off trigger
[linux-2.6/verdex.git] / arch / mips / cobalt / reset.c
blobf503a0d04b3b5e5f0a0867bcbf88efe86b02f9a5
1 /*
2 * Cobalt Reset operations
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.
8 * Copyright (C) 1995, 1996, 1997 by Ralf Baechle
9 * Copyright (C) 2001 by Liam Davies (ldavies@agile.tv)
11 #include <linux/init.h>
12 #include <linux/jiffies.h>
13 #include <linux/leds.h>
15 #include <cobalt.h>
17 DEFINE_LED_TRIGGER(power_off_led_trigger);
19 static int __init ledtrig_power_off_init(void)
21 led_trigger_register_simple("power-off", &power_off_led_trigger);
22 return 0;
24 device_initcall(ledtrig_power_off_init);
26 void cobalt_machine_halt(void)
28 int state, last, diff;
29 unsigned long mark;
32 * turn on power off LED on RaQ
34 * restart if ENTER and SELECT are pressed
37 last = COBALT_KEY_PORT;
39 led_trigger_event(power_off_led_trigger, LED_FULL);
41 for (state = 0;;) {
42 diff = COBALT_KEY_PORT ^ last;
43 last ^= diff;
45 if((diff & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)) && !(~last & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)))
46 COBALT_LED_PORT = COBALT_LED_RESET;
48 for (mark = jiffies; jiffies - mark < HZ;)
53 void cobalt_machine_restart(char *command)
55 COBALT_LED_PORT = COBALT_LED_RESET;
57 /* we should never get here */
58 cobalt_machine_halt();
62 * This triggers the luser mode device driver for the power switch ;-)
64 void cobalt_machine_power_off(void)
66 printk("You can switch the machine off now.\n");
67 cobalt_machine_halt();