reset.c 1.3 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7 8 9 10
/*
 * Cobalt Reset operations
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1995, 1996, 1997 by Ralf Baechle
 * Copyright (C) 2001 by Liam Davies (ldavies@agile.tv)
 */
11
#include <linux/init.h>
12
#include <linux/io.h>
13
#include <linux/jiffies.h>
14
#include <linux/leds.h>
15 16

#include <cobalt.h>
L
Linus Torvalds 已提交
17

18 19 20
#define RESET_PORT	((void __iomem *)CKSEG1ADDR(0x1c000000))
#define RESET		0x0f

21 22 23 24 25 26 27 28 29
DEFINE_LED_TRIGGER(power_off_led_trigger);

static int __init ledtrig_power_off_init(void)
{
	led_trigger_register_simple("power-off", &power_off_led_trigger);
	return 0;
}
device_initcall(ledtrig_power_off_init);

R
Ralf Baechle 已提交
30
void cobalt_machine_halt(void)
L
Linus Torvalds 已提交
31
{
R
Ralf Baechle 已提交
32 33
	int state, last, diff;
	unsigned long mark;
L
Linus Torvalds 已提交
34 35

	/*
36
	 * turn on power off LED on RaQ
R
Ralf Baechle 已提交
37 38
	 *
	 * restart if ENTER and SELECT are pressed
L
Linus Torvalds 已提交
39 40
	 */

R
Ralf Baechle 已提交
41
	last = COBALT_KEY_PORT;
L
Linus Torvalds 已提交
42

43
	led_trigger_event(power_off_led_trigger, LED_FULL);
R
Ralf Baechle 已提交
44

45
	for (state = 0;;) {
R
Ralf Baechle 已提交
46 47
		diff = COBALT_KEY_PORT ^ last;
		last ^= diff;
L
Linus Torvalds 已提交
48

R
Ralf Baechle 已提交
49
		if((diff & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)) && !(~last & (COBALT_KEY_ENTER | COBALT_KEY_SELECT)))
50
			writeb(RESET, RESET_PORT);
R
Ralf Baechle 已提交
51 52 53

		for (mark = jiffies; jiffies - mark < HZ;)
			;
L
Linus Torvalds 已提交
54 55 56
	}
}

R
Ralf Baechle 已提交
57 58
void cobalt_machine_restart(char *command)
{
59
	writeb(RESET, RESET_PORT);
R
Ralf Baechle 已提交
60 61 62 63

	/* we should never get here */
	cobalt_machine_halt();
}