Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Joshua Henderson <joshua.henderson@microchip.com>
0004  * Copyright (C) 2015 Microchip Technology Inc.  All rights reserved.
0005  */
0006 #include <linux/init.h>
0007 #include <linux/pm.h>
0008 #include <asm/reboot.h>
0009 #include <asm/mach-pic32/pic32.h>
0010 
0011 #define PIC32_RSWRST        0x10
0012 
0013 static void pic32_halt(void)
0014 {
0015     while (1) {
0016         __asm__(".set push;\n"
0017             ".set arch=r4000;\n"
0018             "wait;\n"
0019             ".set pop;\n"
0020         );
0021     }
0022 }
0023 
0024 static void pic32_machine_restart(char *command)
0025 {
0026     void __iomem *reg =
0027         ioremap(PIC32_BASE_RESET + PIC32_RSWRST, sizeof(u32));
0028 
0029     pic32_syskey_unlock();
0030 
0031     /* magic write/read */
0032     __raw_writel(1, reg);
0033     (void)__raw_readl(reg);
0034 
0035     pic32_halt();
0036 }
0037 
0038 static void pic32_machine_halt(void)
0039 {
0040     local_irq_disable();
0041 
0042     pic32_halt();
0043 }
0044 
0045 static int __init mips_reboot_setup(void)
0046 {
0047     _machine_restart = pic32_machine_restart;
0048     _machine_halt = pic32_machine_halt;
0049     pm_power_off = pic32_machine_halt;
0050 
0051     return 0;
0052 }
0053 
0054 arch_initcall(mips_reboot_setup);