0001
0002
0003
0004
0005
0006 #include <linux/io.h>
0007 #include <linux/pm.h>
0008 #include <linux/sizes.h>
0009 #include <asm/idle.h>
0010 #include <asm/reboot.h>
0011
0012 #include <loongson1.h>
0013
0014 static void __iomem *wdt_reg_base;
0015
0016 static void ls1x_halt(void)
0017 {
0018 while (1) {
0019 if (cpu_wait)
0020 cpu_wait();
0021 }
0022 }
0023
0024 static void ls1x_restart(char *command)
0025 {
0026 __raw_writel(0x1, wdt_reg_base + WDT_EN);
0027 __raw_writel(0x1, wdt_reg_base + WDT_TIMER);
0028 __raw_writel(0x1, wdt_reg_base + WDT_SET);
0029
0030 ls1x_halt();
0031 }
0032
0033 static void ls1x_power_off(void)
0034 {
0035 ls1x_halt();
0036 }
0037
0038 static int __init ls1x_reboot_setup(void)
0039 {
0040 wdt_reg_base = ioremap(LS1X_WDT_BASE, (SZ_4 + SZ_8));
0041 if (!wdt_reg_base)
0042 panic("Failed to remap watchdog registers");
0043
0044 _machine_restart = ls1x_restart;
0045 _machine_halt = ls1x_halt;
0046 pm_power_off = ls1x_power_off;
0047
0048 return 0;
0049 }
0050
0051 arch_initcall(ls1x_reboot_setup);