2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License version 2 as published
4 * by the Free Software Foundation.
6 * Copyright (C) 2011 Thomas Langer <thomas.langer@lantiq.com>
7 * Copyright (C) 2011 John Crispin <blogic@openwrt.org>
10 #include <linux/init.h>
13 #include <asm/reboot.h>
14 #include <linux/export.h>
16 #include <lantiq_soc.h>
18 /* CPU0 Reset Source Register */
19 #define LTQ_SYS1_CPU0RS 0x0040
20 /* reset cause mask */
21 #define LTQ_CPU0RS_MASK 0x0003
26 return ltq_sys1_r32(LTQ_SYS1_CPU0RS) & LTQ_CPU0RS_MASK;
28 EXPORT_SYMBOL_GPL(ltq_reset_cause);
30 #define BOOT_REG_BASE (KSEG1 | 0x1F200000)
31 #define BOOT_PW1_REG (BOOT_REG_BASE | 0x20)
32 #define BOOT_PW2_REG (BOOT_REG_BASE | 0x24)
33 #define BOOT_PW1 0x4C545100
34 #define BOOT_PW2 0x0051544C
36 #define WDT_REG_BASE (KSEG1 | 0x1F8803F0)
37 #define WDT_PW1 0x00BE0000
38 #define WDT_PW2 0x00DC0000
41 ltq_machine_restart(char *command)
43 pr_notice("System restart\n");
47 ltq_w32(BOOT_PW1, (void *)BOOT_PW1_REG); /* 'LTQ\0' */
48 ltq_w32(BOOT_PW2, (void *)BOOT_PW2_REG); /* '\0QTL' */
49 ltq_w32(0, (void *)BOOT_REG_BASE); /* reset Bootreg RVEC */
52 ltq_w32(WDT_PW1, (void *)WDT_REG_BASE);
54 (0x3 << 26) | /* PWL */
55 (0x2 << 24) | /* CLKDIV */
56 (0x1 << 31) | /* enable */
58 (void *)WDT_REG_BASE);
63 ltq_machine_halt(void)
65 pr_notice("System halted.\n");
71 ltq_machine_power_off(void)
73 pr_notice("Please turn off the power now.\n");
79 mips_reboot_setup(void)
81 _machine_restart = ltq_machine_restart;
82 _machine_halt = ltq_machine_halt;
83 pm_power_off = ltq_machine_power_off;
87 arch_initcall(mips_reboot_setup);