Merge remote-tracking branch 'leds/for-mm'
[linux-2.6/next.git] / arch / mips / loongson / common / reset.c
blob9e10d6225d9bca134931d2da11d0ba63da784972
1 /*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
7 * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
8 * Author: Fuxin Zhang, zhangfx@lemote.com
9 * Copyright (C) 2009 Lemote, Inc.
10 * Author: Zhangjin Wu, wuzhangjin@gmail.com
12 #include <linux/init.h>
13 #include <linux/pm.h>
15 #include <asm/reboot.h>
17 #include <loongson.h>
19 static inline void loongson_reboot(void)
21 #ifndef CONFIG_CPU_JUMP_WORKAROUNDS
22 ((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) ();
23 #else
24 void (*func)(void);
26 func = (void *)ioremap_nocache(LOONGSON_BOOT_BASE, 4);
28 __asm__ __volatile__(
29 " .set noat \n"
30 " jr %[func] \n"
31 " .set at \n"
32 : /* No outputs */
33 : [func] "r" (func));
34 #endif
37 static void loongson_restart(char *command)
39 /* do preparation for reboot */
40 mach_prepare_reboot();
42 /* reboot via jumping to boot base address */
43 loongson_reboot();
46 static void loongson_poweroff(void)
48 mach_prepare_shutdown();
49 unreachable();
52 static void loongson_halt(void)
54 pr_notice("\n\n** You can safely turn off the power now **\n\n");
55 while (1) {
56 if (cpu_wait)
57 cpu_wait();
61 static int __init mips_reboot_setup(void)
63 _machine_restart = loongson_restart;
64 _machine_halt = loongson_halt;
65 pm_power_off = loongson_poweroff;
67 return 0;
70 arch_initcall(mips_reboot_setup);