1 /* 2 * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 3 * 4 * This program is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License as published by the 6 * Free Software Foundation; either version 2 of the License, or (at your 7 * option) any later version. 8 */ 9 10 #include <linux/io.h> 11 #include <linux/pm.h> 12 #include <asm/idle.h> 13 #include <asm/reboot.h> 14 15 #include <loongson1.h> 16 17 static void __iomem *wdt_base; 18 ls1x_halt(void)19static void ls1x_halt(void) 20 { 21 while (1) { 22 if (cpu_wait) 23 cpu_wait(); 24 } 25 } 26 ls1x_restart(char * command)27static void ls1x_restart(char *command) 28 { 29 __raw_writel(0x1, wdt_base + WDT_EN); 30 __raw_writel(0x1, wdt_base + WDT_TIMER); 31 __raw_writel(0x1, wdt_base + WDT_SET); 32 33 ls1x_halt(); 34 } 35 ls1x_power_off(void)36static void ls1x_power_off(void) 37 { 38 ls1x_halt(); 39 } 40 ls1x_reboot_setup(void)41static int __init ls1x_reboot_setup(void) 42 { 43 wdt_base = ioremap_nocache(LS1X_WDT_BASE, 0x0f); 44 if (!wdt_base) 45 panic("Failed to remap watchdog registers"); 46 47 _machine_restart = ls1x_restart; 48 _machine_halt = ls1x_halt; 49 pm_power_off = ls1x_power_off; 50 51 return 0; 52 } 53 54 arch_initcall(ls1x_reboot_setup); 55