1*04dc82e1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 22572f00dSJoshua Henderson /* 32572f00dSJoshua Henderson * Joshua Henderson <joshua.henderson@microchip.com> 42572f00dSJoshua Henderson * Copyright (C) 2015 Microchip Technology Inc. All rights reserved. 52572f00dSJoshua Henderson */ 62572f00dSJoshua Henderson #include <linux/init.h> 72572f00dSJoshua Henderson #include <linux/pm.h> 82572f00dSJoshua Henderson #include <asm/reboot.h> 92572f00dSJoshua Henderson #include <asm/mach-pic32/pic32.h> 102572f00dSJoshua Henderson 112572f00dSJoshua Henderson #define PIC32_RSWRST 0x10 122572f00dSJoshua Henderson 132572f00dSJoshua Henderson static void pic32_halt(void) 142572f00dSJoshua Henderson { 152572f00dSJoshua Henderson while (1) { 162572f00dSJoshua Henderson __asm__(".set push;\n" 172572f00dSJoshua Henderson ".set arch=r4000;\n" 182572f00dSJoshua Henderson "wait;\n" 192572f00dSJoshua Henderson ".set pop;\n" 202572f00dSJoshua Henderson ); 212572f00dSJoshua Henderson } 222572f00dSJoshua Henderson } 232572f00dSJoshua Henderson 242572f00dSJoshua Henderson static void pic32_machine_restart(char *command) 252572f00dSJoshua Henderson { 262572f00dSJoshua Henderson void __iomem *reg = 272572f00dSJoshua Henderson ioremap(PIC32_BASE_RESET + PIC32_RSWRST, sizeof(u32)); 282572f00dSJoshua Henderson 292572f00dSJoshua Henderson pic32_syskey_unlock(); 302572f00dSJoshua Henderson 312572f00dSJoshua Henderson /* magic write/read */ 322572f00dSJoshua Henderson __raw_writel(1, reg); 332572f00dSJoshua Henderson (void)__raw_readl(reg); 342572f00dSJoshua Henderson 352572f00dSJoshua Henderson pic32_halt(); 362572f00dSJoshua Henderson } 372572f00dSJoshua Henderson 382572f00dSJoshua Henderson static void pic32_machine_halt(void) 392572f00dSJoshua Henderson { 402572f00dSJoshua Henderson local_irq_disable(); 412572f00dSJoshua Henderson 422572f00dSJoshua Henderson pic32_halt(); 432572f00dSJoshua Henderson } 442572f00dSJoshua Henderson 452572f00dSJoshua Henderson static int __init mips_reboot_setup(void) 462572f00dSJoshua Henderson { 472572f00dSJoshua Henderson _machine_restart = pic32_machine_restart; 482572f00dSJoshua Henderson _machine_halt = pic32_machine_halt; 492572f00dSJoshua Henderson pm_power_off = pic32_machine_halt; 502572f00dSJoshua Henderson 512572f00dSJoshua Henderson return 0; 522572f00dSJoshua Henderson } 532572f00dSJoshua Henderson 542572f00dSJoshua Henderson arch_initcall(mips_reboot_setup); 55