Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
reset.c
Go to the documentation of this file.
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.
6  *
7  * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
8  * Author: Fuxin Zhang, [email protected]
9  * Copyright (C) 2009 Lemote, Inc.
10  * Author: Zhangjin Wu, [email protected]
11  */
12 #include <linux/init.h>
13 #include <linux/pm.h>
14 
15 #include <asm/reboot.h>
16 
17 #include <loongson.h>
18 
19 static inline void loongson_reboot(void)
20 {
21 #ifndef CONFIG_CPU_JUMP_WORKAROUNDS
23 #else
24  void (*func)(void);
25 
27 
28  __asm__ __volatile__(
29  " .set noat \n"
30  " jr %[func] \n"
31  " .set at \n"
32  : /* No outputs */
33  : [func] "r" (func));
34 #endif
35 }
36 
37 static void loongson_restart(char *command)
38 {
39  /* do preparation for reboot */
41 
42  /* reboot via jumping to boot base address */
43  loongson_reboot();
44 }
45 
46 static void loongson_poweroff(void)
47 {
49  unreachable();
50 }
51 
52 static void loongson_halt(void)
53 {
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();
58  }
59 }
60 
61 static int __init mips_reboot_setup(void)
62 {
63  _machine_restart = loongson_restart;
64  _machine_halt = loongson_halt;
65  pm_power_off = loongson_poweroff;
66 
67  return 0;
68 }
69 
70 arch_initcall(mips_reboot_setup);