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) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
7 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
8 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
14 #include <linux/reset-controller.h>
16 #include <asm/reboot.h>
18 #include <asm/mach-ralink/ralink_regs.h>
21 #define SYSC_REG_RESET_CTRL 0x034
22 #define RSTCTL_RESET_SYSTEM BIT(0)
24 static int ralink_assert_device(struct reset_controller_dev
*rcdev
,
32 val
= rt_sysc_r32(SYSC_REG_RESET_CTRL
);
34 rt_sysc_w32(val
, SYSC_REG_RESET_CTRL
);
39 static int ralink_deassert_device(struct reset_controller_dev
*rcdev
,
47 val
= rt_sysc_r32(SYSC_REG_RESET_CTRL
);
49 rt_sysc_w32(val
, SYSC_REG_RESET_CTRL
);
54 static int ralink_reset_device(struct reset_controller_dev
*rcdev
,
57 ralink_assert_device(rcdev
, id
);
58 return ralink_deassert_device(rcdev
, id
);
61 static struct reset_control_ops reset_ops
= {
62 .reset
= ralink_reset_device
,
63 .assert = ralink_assert_device
,
64 .deassert
= ralink_deassert_device
,
67 static struct reset_controller_dev reset_dev
= {
71 .of_reset_n_cells
= 1,
74 void ralink_rst_init(void)
76 reset_dev
.of_node
= of_find_compatible_node(NULL
, NULL
,
77 "ralink,rt2880-reset");
78 if (!reset_dev
.of_node
)
79 pr_err("Failed to find reset controller node");
81 reset_controller_register(&reset_dev
);
84 static void ralink_restart(char *command
)
87 rt_sysc_w32(RSTCTL_RESET_SYSTEM
, SYSC_REG_RESET_CTRL
);
91 static void ralink_halt(void)
97 static int __init
mips_reboot_setup(void)
99 _machine_restart
= ralink_restart
;
100 _machine_halt
= ralink_halt
;
101 pm_power_off
= ralink_halt
;
106 arch_initcall(mips_reboot_setup
);