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) 2010 John Crispin <blogic@openwrt.org>
9 #include <linux/init.h>
11 #include <linux/ioport.h>
13 #include <linux/module.h>
14 #include <asm/reboot.h>
16 #include <lantiq_soc.h>
17 #include "../machtypes.h"
23 static struct svip_reg_sys1 *const sys1 = (struct svip_reg_sys1 *)LTQ_SYS1_BASE;
24 static struct svip_reg_ebu *const ebu = (struct svip_reg_ebu *)LTQ_EBU_BASE;
26 #define CPLD_CMDREG3 ((volatile unsigned char*)(KSEG1 + 0x120000f3))
27 extern void switchip_reset(void);
29 static void ltq_machine_restart(char *command)
31 printk(KERN_NOTICE "System restart\n");
34 if (mips_machtype == LANTIQ_MACH_EASY33016 ||
35 mips_machtype == LANTIQ_MACH_EASY336) {
36 /* We just use the CPLD function to reset the entire system as a
37 workaround for the switch reset problem */
39 ebu_w32(0x120000f1, addr_sel_2);
40 ebu_w32(0x404027ff, con_2);
42 if (mips_machtype == LANTIQ_MACH_EASY336)
43 /* set bit 0 to reset SVIP */
44 *CPLD_CMDREG3 = (1<<0);
46 /* set bit 7 to reset SVIP, set bit 3 to reset xT */
47 *CPLD_CMDREG3 = (1<<7) | (1<<3);
49 *LTQ_BOOT_RVEC(0) = 0;
50 /* reset all except PER, SUBSYS and CPU0 */
51 sys1_w32(0x00043F3E, rreqr);
52 /* release WDT0 reset */
53 sys1_w32(0x00000100, rrlsr);
54 /* restore reset value for clock enables */
55 sys1_w32(~0x0c000040, clkclr);
56 /* reset SUBSYS (incl. DDR2) and CPU0 */
57 sys1_w32(0x00030001, rbtr);
64 static void ltq_machine_halt(void)
66 printk(KERN_NOTICE "System halted.\n");
72 static void ltq_machine_power_off(void)
74 printk(KERN_NOTICE "Please turn off the power now.\n");
80 /* This function is used by the watchdog driver */
81 int ltq_reset_cause(void)
85 EXPORT_SYMBOL_GPL(ltq_reset_cause);
87 static int __init mips_reboot_setup(void)
89 _machine_restart = ltq_machine_restart;
90 _machine_halt = ltq_machine_halt;
91 pm_power_off = ltq_machine_power_off;
95 arch_initcall(mips_reboot_setup);