staging: erofs: fix warning Comparison to bool
[linux/fpc-iii.git] / arch / mips / loongson64 / common / reset.c
blobce39e918e4d5f775556cb5fe299a07665a971aa5
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
4 * Copyright (C) 2007 Lemote, Inc. & Institute of Computing Technology
5 * Author: Fuxin Zhang, zhangfx@lemote.com
6 * Copyright (C) 2009 Lemote, Inc.
7 * Author: Zhangjin Wu, wuzhangjin@gmail.com
8 */
9 #include <linux/init.h>
10 #include <linux/pm.h>
12 #include <asm/idle.h>
13 #include <asm/reboot.h>
15 #include <loongson.h>
16 #include <boot_param.h>
18 static inline void loongson_reboot(void)
20 #ifndef CONFIG_CPU_JUMP_WORKAROUNDS
21 ((void (*)(void))ioremap_nocache(LOONGSON_BOOT_BASE, 4)) ();
22 #else
23 void (*func)(void);
25 func = (void *)ioremap_nocache(LOONGSON_BOOT_BASE, 4);
27 __asm__ __volatile__(
28 " .set noat \n"
29 " jr %[func] \n"
30 " .set at \n"
31 : /* No outputs */
32 : [func] "r" (func));
33 #endif
36 static void loongson_restart(char *command)
38 #ifndef CONFIG_LEFI_FIRMWARE_INTERFACE
39 /* do preparation for reboot */
40 mach_prepare_reboot();
42 /* reboot via jumping to boot base address */
43 loongson_reboot();
44 #else
45 void (*fw_restart)(void) = (void *)loongson_sysconf.restart_addr;
47 fw_restart();
48 while (1) {
49 if (cpu_wait)
50 cpu_wait();
52 #endif
55 static void loongson_poweroff(void)
57 #ifndef CONFIG_LEFI_FIRMWARE_INTERFACE
58 mach_prepare_shutdown();
61 * It needs a wait loop here, but mips/kernel/reset.c already calls
62 * a generic delay loop, machine_hang(), so simply return.
64 return;
65 #else
66 void (*fw_poweroff)(void) = (void *)loongson_sysconf.poweroff_addr;
68 fw_poweroff();
69 while (1) {
70 if (cpu_wait)
71 cpu_wait();
73 #endif
76 static void loongson_halt(void)
78 pr_notice("\n\n** You can safely turn off the power now **\n\n");
79 while (1) {
80 if (cpu_wait)
81 cpu_wait();
85 static int __init mips_reboot_setup(void)
87 _machine_restart = loongson_restart;
88 _machine_halt = loongson_halt;
89 pm_power_off = loongson_poweroff;
91 return 0;
94 arch_initcall(mips_reboot_setup);