blob: 4bd9c18b07a533c087d21f01276b43a65a592950 [file] [log] [blame]
Wu Zhangjin85749d22009-07-02 23:26:45 +08001/*
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.
6 *
7 * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
8 * Author: Fuxin Zhang, zhangfx@lemote.com
Wu Zhangjin6f320962010-01-04 17:16:45 +08009 * Copyright (C) 2009 Lemote, Inc.
Wu Zhangjinf7a904d2010-01-04 17:16:51 +080010 * Author: Zhangjin Wu, wuzhangjin@gmail.com
Wu Zhangjin85749d22009-07-02 23:26:45 +080011 */
12#include <linux/init.h>
13#include <linux/pm.h>
14
15#include <asm/reboot.h>
16
17#include <loongson.h>
18
19static void loongson_restart(char *command)
20{
21 /* do preparation for reboot */
22 mach_prepare_reboot();
23
24 /* reboot via jumping to boot base address */
Wu Zhangjine2fee572009-10-16 14:17:19 +080025 ((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) ();
Wu Zhangjin85749d22009-07-02 23:26:45 +080026}
27
Wu Zhangjinfc48c412010-01-27 22:39:46 +080028static void loongson_poweroff(void)
Wu Zhangjin85749d22009-07-02 23:26:45 +080029{
30 mach_prepare_shutdown();
Wu Zhangjin6f320962010-01-04 17:16:45 +080031 unreachable();
Wu Zhangjin85749d22009-07-02 23:26:45 +080032}
33
Wu Zhangjinfc48c412010-01-27 22:39:46 +080034static void loongson_halt(void)
35{
36 pr_notice("\n\n** You can safely turn off the power now **\n\n");
37 while (1) {
38 if (cpu_wait)
39 cpu_wait();
40 }
41}
42
Wu Zhangjin85749d22009-07-02 23:26:45 +080043static int __init mips_reboot_setup(void)
44{
45 _machine_restart = loongson_restart;
46 _machine_halt = loongson_halt;
Wu Zhangjinfc48c412010-01-27 22:39:46 +080047 pm_power_off = loongson_poweroff;
Wu Zhangjin85749d22009-07-02 23:26:45 +080048
49 return 0;
50}
51
52arch_initcall(mips_reboot_setup);