aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips')
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/mips/ralink/common.h2
-rw-r--r--arch/mips/ralink/of.c3
-rw-r--r--arch/mips/ralink/reset.c62
4 files changed, 69 insertions, 0 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 24727a082e19..a1a088b2d54d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -446,6 +446,8 @@ config RALINK
446 select SYS_HAS_EARLY_PRINTK 446 select SYS_HAS_EARLY_PRINTK
447 select HAVE_MACH_CLKDEV 447 select HAVE_MACH_CLKDEV
448 select CLKDEV_LOOKUP 448 select CLKDEV_LOOKUP
449 select ARCH_HAS_RESET_CONTROLLER
450 select RESET_CONTROLLER
449 451
450config SGI_IP22 452config SGI_IP22
451 bool "SGI IP22 (Indy/Indigo2)" 453 bool "SGI IP22 (Indy/Indigo2)"
diff --git a/arch/mips/ralink/common.h b/arch/mips/ralink/common.h
index 83144c3fc5ac..42dfd6100a2d 100644
--- a/arch/mips/ralink/common.h
+++ b/arch/mips/ralink/common.h
@@ -46,6 +46,8 @@ extern void ralink_of_remap(void);
46extern void ralink_clk_init(void); 46extern void ralink_clk_init(void);
47extern void ralink_clk_add(const char *dev, unsigned long rate); 47extern void ralink_clk_add(const char *dev, unsigned long rate);
48 48
49extern void ralink_rst_init(void);
50
49extern void prom_soc_init(struct ralink_soc_info *soc_info); 51extern void prom_soc_init(struct ralink_soc_info *soc_info);
50 52
51__iomem void *plat_of_remap_node(const char *node); 53__iomem void *plat_of_remap_node(const char *node);
diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c
index f25ea5b45051..ce38d11f9da5 100644
--- a/arch/mips/ralink/of.c
+++ b/arch/mips/ralink/of.c
@@ -110,6 +110,9 @@ static int __init plat_of_setup(void)
110 if (of_platform_populate(NULL, of_ids, NULL, NULL)) 110 if (of_platform_populate(NULL, of_ids, NULL, NULL))
111 panic("failed to populate DT\n"); 111 panic("failed to populate DT\n");
112 112
113 /* make sure ithat the reset controller is setup early */
114 ralink_rst_init();
115
113 return 0; 116 return 0;
114} 117}
115 118
diff --git a/arch/mips/ralink/reset.c b/arch/mips/ralink/reset.c
index 22120e512e7e..55c7ec59df3c 100644
--- a/arch/mips/ralink/reset.c
+++ b/arch/mips/ralink/reset.c
@@ -10,6 +10,8 @@
10 10
11#include <linux/pm.h> 11#include <linux/pm.h>
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/of.h>
14#include <linux/reset-controller.h>
13 15
14#include <asm/reboot.h> 16#include <asm/reboot.h>
15 17
@@ -19,6 +21,66 @@
19#define SYSC_REG_RESET_CTRL 0x034 21#define SYSC_REG_RESET_CTRL 0x034
20#define RSTCTL_RESET_SYSTEM BIT(0) 22#define RSTCTL_RESET_SYSTEM BIT(0)
21 23
24static int ralink_assert_device(struct reset_controller_dev *rcdev,
25 unsigned long id)
26{
27 u32 val;
28
29 if (id < 8)
30 return -1;
31
32 val = rt_sysc_r32(SYSC_REG_RESET_CTRL);
33 val |= BIT(id);
34 rt_sysc_w32(val, SYSC_REG_RESET_CTRL);
35
36 return 0;
37}
38
39static int ralink_deassert_device(struct reset_controller_dev *rcdev,
40 unsigned long id)
41{
42 u32 val;
43
44 if (id < 8)
45 return -1;
46
47 val = rt_sysc_r32(SYSC_REG_RESET_CTRL);
48 val &= ~BIT(id);
49 rt_sysc_w32(val, SYSC_REG_RESET_CTRL);
50
51 return 0;
52}
53
54static int ralink_reset_device(struct reset_controller_dev *rcdev,
55 unsigned long id)
56{
57 ralink_assert_device(rcdev, id);
58 return ralink_deassert_device(rcdev, id);
59}
60
61static struct reset_control_ops reset_ops = {
62 .reset = ralink_reset_device,
63 .assert = ralink_assert_device,
64 .deassert = ralink_deassert_device,
65};
66
67static struct reset_controller_dev reset_dev = {
68 .ops = &reset_ops,
69 .owner = THIS_MODULE,
70 .nr_resets = 32,
71 .of_reset_n_cells = 1,
72};
73
74void ralink_rst_init(void)
75{
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");
80 else
81 reset_controller_register(&reset_dev);
82}
83
22static void ralink_restart(char *command) 84static void ralink_restart(char *command)
23{ 85{
24 local_irq_disable(); 86 local_irq_disable();