1*2572f00dSJoshua Henderson /* 2*2572f00dSJoshua Henderson * Joshua Henderson <joshua.henderson@microchip.com> 3*2572f00dSJoshua Henderson * Copyright (C) 2015 Microchip Technology Inc. All rights reserved. 4*2572f00dSJoshua Henderson * 5*2572f00dSJoshua Henderson * This program is free software; you can distribute it and/or modify it 6*2572f00dSJoshua Henderson * under the terms of the GNU General Public License (Version 2) as 7*2572f00dSJoshua Henderson * published by the Free Software Foundation. 8*2572f00dSJoshua Henderson * 9*2572f00dSJoshua Henderson * This program is distributed in the hope it will be useful, but WITHOUT 10*2572f00dSJoshua Henderson * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11*2572f00dSJoshua Henderson * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12*2572f00dSJoshua Henderson * for more details. 13*2572f00dSJoshua Henderson */ 14*2572f00dSJoshua Henderson #include <linux/init.h> 15*2572f00dSJoshua Henderson #include <linux/pm.h> 16*2572f00dSJoshua Henderson #include <asm/reboot.h> 17*2572f00dSJoshua Henderson #include <asm/mach-pic32/pic32.h> 18*2572f00dSJoshua Henderson 19*2572f00dSJoshua Henderson #define PIC32_RSWRST 0x10 20*2572f00dSJoshua Henderson 21*2572f00dSJoshua Henderson static void pic32_halt(void) 22*2572f00dSJoshua Henderson { 23*2572f00dSJoshua Henderson while (1) { 24*2572f00dSJoshua Henderson __asm__(".set push;\n" 25*2572f00dSJoshua Henderson ".set arch=r4000;\n" 26*2572f00dSJoshua Henderson "wait;\n" 27*2572f00dSJoshua Henderson ".set pop;\n" 28*2572f00dSJoshua Henderson ); 29*2572f00dSJoshua Henderson } 30*2572f00dSJoshua Henderson } 31*2572f00dSJoshua Henderson 32*2572f00dSJoshua Henderson static void pic32_machine_restart(char *command) 33*2572f00dSJoshua Henderson { 34*2572f00dSJoshua Henderson void __iomem *reg = 35*2572f00dSJoshua Henderson ioremap(PIC32_BASE_RESET + PIC32_RSWRST, sizeof(u32)); 36*2572f00dSJoshua Henderson 37*2572f00dSJoshua Henderson pic32_syskey_unlock(); 38*2572f00dSJoshua Henderson 39*2572f00dSJoshua Henderson /* magic write/read */ 40*2572f00dSJoshua Henderson __raw_writel(1, reg); 41*2572f00dSJoshua Henderson (void)__raw_readl(reg); 42*2572f00dSJoshua Henderson 43*2572f00dSJoshua Henderson pic32_halt(); 44*2572f00dSJoshua Henderson } 45*2572f00dSJoshua Henderson 46*2572f00dSJoshua Henderson static void pic32_machine_halt(void) 47*2572f00dSJoshua Henderson { 48*2572f00dSJoshua Henderson local_irq_disable(); 49*2572f00dSJoshua Henderson 50*2572f00dSJoshua Henderson pic32_halt(); 51*2572f00dSJoshua Henderson } 52*2572f00dSJoshua Henderson 53*2572f00dSJoshua Henderson static int __init mips_reboot_setup(void) 54*2572f00dSJoshua Henderson { 55*2572f00dSJoshua Henderson _machine_restart = pic32_machine_restart; 56*2572f00dSJoshua Henderson _machine_halt = pic32_machine_halt; 57*2572f00dSJoshua Henderson pm_power_off = pic32_machine_halt; 58*2572f00dSJoshua Henderson 59*2572f00dSJoshua Henderson return 0; 60*2572f00dSJoshua Henderson } 61*2572f00dSJoshua Henderson 62*2572f00dSJoshua Henderson arch_initcall(mips_reboot_setup); 63