Merge remote-tracking branch 'regmap/fix/cache' into regmap-linus
[firefly-linux-kernel-4.4.55.git] / arch / mips / loongson / common / reset.c
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, zhangfx@lemote.com
9  * Copyright (C) 2009 Lemote, Inc.
10  * Author: Zhangjin Wu, wuzhangjin@gmail.com
11  */
12 #include <linux/init.h>
13 #include <linux/pm.h>
14
15 #include <asm/idle.h>
16 #include <asm/reboot.h>
17
18 #include <loongson.h>
19
20 static inline void loongson_reboot(void)
21 {
22 #ifndef CONFIG_CPU_JUMP_WORKAROUNDS
23         ((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) ();
24 #else
25         void (*func)(void);
26
27         func = (void *)ioremap_nocache(LOONGSON_BOOT_BASE, 4);
28
29         __asm__ __volatile__(
30         "       .set    noat                                            \n"
31         "       jr      %[func]                                         \n"
32         "       .set    at                                              \n"
33         : /* No outputs */
34         : [func] "r" (func));
35 #endif
36 }
37
38 static void loongson_restart(char *command)
39 {
40         /* do preparation for reboot */
41         mach_prepare_reboot();
42
43         /* reboot via jumping to boot base address */
44         loongson_reboot();
45 }
46
47 static void loongson_poweroff(void)
48 {
49         mach_prepare_shutdown();
50         unreachable();
51 }
52
53 static void loongson_halt(void)
54 {
55         pr_notice("\n\n** You can safely turn off the power now **\n\n");
56         while (1) {
57                 if (cpu_wait)
58                         cpu_wait();
59         }
60 }
61
62 static int __init mips_reboot_setup(void)
63 {
64         _machine_restart = loongson_restart;
65         _machine_halt = loongson_halt;
66         pm_power_off = loongson_poweroff;
67
68         return 0;
69 }
70
71 arch_initcall(mips_reboot_setup);