1 From 1748dc7b4974109040d0249ac1fc322c120eb528 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Fri, 16 Mar 2012 15:49:32 +0100
4 Subject: [PATCH 62/70] MIPS: cleanup reset code
7 arch/mips/lantiq/xway/reset.c | 59 ++++++++++++++++++++++++++++++++++------
8 1 files changed, 50 insertions(+), 9 deletions(-)
10 diff --git a/arch/mips/lantiq/xway/reset.c b/arch/mips/lantiq/xway/reset.c
11 index ca2212a..8a5dff1 100644
12 --- a/arch/mips/lantiq/xway/reset.c
13 +++ b/arch/mips/lantiq/xway/reset.c
15 #include <linux/ioport.h>
17 #include <linux/export.h>
18 +#include <linux/delay.h>
19 #include <asm/reboot.h>
21 #include <lantiq_soc.h>
23 #define ltq_rcu_w32(x, y) ltq_w32((x), ltq_rcu_membase + (y))
24 #define ltq_rcu_r32(x) ltq_r32(ltq_rcu_membase + (x))
26 -/* register definitions */
27 -#define LTQ_RCU_RST 0x0010
28 -#define LTQ_RCU_RST_ALL 0x40000000
30 -#define LTQ_RCU_RST_STAT 0x0014
31 -#define LTQ_RCU_STAT_SHIFT 26
32 +/* reset request register */
33 +#define RCU_RST_REQ 0x0010
34 +/* reset status register */
35 +#define RCU_RST_STAT 0x0014
38 +#define RCU_STAT_SHIFT 26
39 +/* Global SW Reset */
40 +#define RCU_RD_SRST BIT(30)
41 +/* Memory Controller */
42 +#define RCU_RD_MC BIT(14)
44 +#define RCU_RD_PCI BIT(13)
46 +#define RCU_RD_DFE_AFE BIT(12)
48 +#define RCU_RD_DSL_AFE BIT(11)
50 +#define RCU_RD_SDIO BIT(10)
52 +#define RCU_RD_DMA BIT(9)
54 +#define RCU_RD_PPE BIT(8)
56 +#define RCU_RD_ARC_DFE BIT(7)
58 +#define RCU_RD_AHB BIT(6)
60 +#define RCU_RD_ENET_MAC1 BIT(5)
61 +/* USB and Phy core */
62 +#define RCU_RD_USB BIT(4)
64 +#define RCU_RD_CPU1 BIT(3)
66 +#define RCU_RD_FPI BIT(2)
68 +#define RCU_RD_CPU0 BIT(1)
69 +/* HW reset via HRST pin */
70 +#define RCU_RD_HRST BIT(0)
72 static struct resource ltq_rcu_resource =
73 MEM_RES("rcu", LTQ_RCU_BASE_ADDR, LTQ_RCU_SIZE);
74 @@ -36,16 +70,23 @@ static void __iomem *ltq_rcu_membase;
75 /* This function is used by the watchdog driver */
76 int ltq_reset_cause(void)
78 - u32 val = ltq_rcu_r32(LTQ_RCU_RST_STAT);
79 - return val >> LTQ_RCU_STAT_SHIFT;
80 + u32 val = ltq_rcu_r32(RCU_RST_STAT);
81 + return val >> RCU_STAT_SHIFT;
83 EXPORT_SYMBOL_GPL(ltq_reset_cause);
85 +void ltq_reset_once(unsigned int module, ulong usec)
87 + ltq_rcu_w32(ltq_rcu_r32(RCU_RST_REQ) | module, RCU_RST_REQ);
89 + ltq_rcu_w32(ltq_rcu_r32(RCU_RST_REQ) & ~module, RCU_RST_REQ);
92 static void ltq_machine_restart(char *command)
94 pr_notice("System restart\n");
96 - ltq_rcu_w32(ltq_rcu_r32(LTQ_RCU_RST) | LTQ_RCU_RST_ALL, LTQ_RCU_RST);
97 + ltq_rcu_w32(ltq_rcu_r32(RCU_RST_REQ) | RCU_RD_SRST, RCU_RST_REQ);