Debian Codegraph @

arch/mips/pic32/common/reset.c

raw
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Joshua Henderson <[email protected]>
4 * Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
5 */
6 #include <linux/init.h>
7 #include <linux/io.h>
8 #include <linux/platform_data/pic32.h>
9 #include <linux/pm.h>
10 #include <asm/reboot.h>
11
12 #define PIC32_RSWRST 0x10
13
14 static void pic32_halt(void)
15 {
16 while (1) {
17 __asm__(".set push;\n"
18 ".set arch=r4000;\n"
19 "wait;\n"
20 ".set pop;\n"
21 );
22 }
23 }
24
25 static void pic32_machine_restart(char *command)
26 {
27 void __iomem *reg =
28 ioremap(PIC32_BASE_RESET + PIC32_RSWRST, sizeof(u32));
29
30 pic32_syskey_unlock();
31
32 /* magic write/read */
33 __raw_writel(1, reg);
34 (void)__raw_readl(reg);
35
36 pic32_halt();
37 }
38
39 static void pic32_machine_halt(void)
40 {
41 local_irq_disable();
42
43 pic32_halt();
44 }
45
46 static int __init mips_reboot_setup(void)
47 {
48 _machine_restart = pic32_machine_restart;
49 _machine_halt = pic32_machine_halt;
50 pm_power_off = pic32_machine_halt;
51
52 return 0;
53 }
54
55 arch_initcall(mips_reboot_setup);