mpc512x: Reset module

Submitted by Damien Dusha on Sept. 7, 2009, 12:06 a.m.

Details

Message ID c788c1220909061706i3c1c2c52rc1284e0ad416cb7@mail.gmail.com
State Changes Requested
Delegated to: Grant Likely
Headers show

Commit Message

Damien Dusha Sept. 7, 2009, 12:06 a.m.
Dear all,

I have written a small patch to get the software reset working on the
mpc5121.  It is similar to the reset driver found in
arch/powerpc/platforms/83xx/misc.c except it has been modified to look
for the reset node in the device tree before writing to the reset
module.

Comments are welcome.  It's my first patch to the mailing list, so
I'll apologise in advance for any problems with the submission
procedure.

Damien.

Patch hide | download patch | download mbox

diff --git a/arch/powerpc/platforms/512x/mpc5121_ads.c b/arch/powerpc/platforms/512x/mpc5121_ads.c
index a8976b4..16ca250 100644
--- a/arch/powerpc/platforms/512x/mpc5121_ads.c
+++ b/arch/powerpc/platforms/512x/mpc5121_ads.c
@@ -70,4 +70,5 @@  define_machine(mpc5121_ads) {
 	.init_IRQ		= mpc5121_ads_init_IRQ,
 	.get_irq		= ipic_get_irq,
 	.calibrate_decr		= generic_calibrate_decr,
+    .restart        = mpc512x_restart,
 };
diff --git a/arch/powerpc/platforms/512x/mpc512x.h b/arch/powerpc/platforms/512x/mpc512x.h
index f4db8a7..d77f0ab 100644
--- a/arch/powerpc/platforms/512x/mpc512x.h
+++ b/arch/powerpc/platforms/512x/mpc512x.h
@@ -14,5 +14,6 @@ 
 extern unsigned long mpc512x_find_ips_freq(struct device_node *node);
 extern void __init mpc512x_init_IRQ(void);
 extern void __init mpc512x_init_i2c(void);
+extern void mpc512x_restart(char *cmd);
 void __init mpc512x_declare_of_platform_devices(void);
 #endif				/* __MPC512X_H__ */
diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index 135fd6b..deddafc 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -22,6 +22,7 @@ 
 #include <asm/prom.h>
 #include <asm/time.h>
 
+#include <asm/mpc512x.h>
 #include "mpc512x.h"
 
 unsigned long
@@ -89,6 +90,33 @@  void __init mpc512x_init_i2c(void)
 	}
 }
 
+void mpc512x_restart(char *cmd)
+{
+    struct device_node *np;
+    struct mpc512x_reset_module *rm;
+
+    local_irq_disable();
+
+	np = of_find_compatible_node(NULL, NULL, "fsl,mpc5121-reset");
+
+	if (np) {
+
+        rm = of_iomap(np, 0);
+		if (rm) {
+
+            /* Enable software reset "RSTE" (in hex) */
+            out_be32( &(rm->rpr) , 0x52535445);
+
+            /* Set the software hard reset */
+            out_be32( &(rm->rcr), 0x2);
+        }
+	}
+
+    printk (KERN_EMERG "Error: Unable to map reset module, spinning forever!\n");
+    for(;;);
+}
+
+
 /*
  * Nodes to do bus probe on, soc and localbus
  */