From 4adce6599e6f53bc55576fdea2656fdf8fa80f45 Mon Sep 17 00:00:00 2001
From: Oliver Ford <oliford@NervousEnergy.(none)>
Date: Sat, 3 May 2008 14:34:24 +0100
Subject: [PATCH] Resume recovery testing: Flash and re-suspend on first resume (via RTC storage).

---
 src/irq.cpp |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/src/irq.cpp b/src/irq.cpp
index 607328b..18659e5 100644
--- a/src/irq.cpp
+++ b/src/irq.cpp
@@ -217,6 +217,45 @@ report_resume(irqData *, const char *header, traceitem *item)
 extern "C" void __irq
 resume_handler(struct irqData *data, struct irqregs *regs)
 {
+	uint32 *store1 = (uint32 *)0x4090002c;
+
+    uint32 *setGPIO = (uint32 *)0x40e00018;
+    uint32 *clearGPIO = (uint32 *)0x40e00024;    
+    uint32 *dirGPIO = (uint32 *)0x40e0000c;    
+    uint32 *mfprGPIO3 = (uint32 *)0x40e1027c;    
+    uint32 *mfprGPIO3_2 = (uint32 *)0x40e102e0;    
+
+    *mfprGPIO3 = 0x0844;
+    __asm ( "nop\n nop\n nop" : : );
+    *mfprGPIO3_2 = 0x8C40;
+     __asm ( "nop\n nop\n nop" : : );
+    
+    *dirGPIO |= 0x08;
+   
+    for(int i=0;i<10;i++){
+        *setGPIO = 0x08;
+	for(int j=0;j<8000000;j++){
+		__asm ( "nop" : : );
+	}
+	*clearGPIO=0x08;
+	for(int j=0;j<8000000;j++){
+		__asm ( "nop" : : );
+	}	
+    }
+    *setGPIO = 8; 
+
+	if(*store1 == 0x01){
+		*store1 = 0x02;
+		//go back under
+		__asm(
+		"mov	r0, #0x06\n"		// S2D3C4 mode
+		"mcr	p14, 0, r0, c7, c0, 0\n"	// enter sleep
+	"death:\n "
+		"b 	death\n"
+		);
+		
+	}
+
     int isPXA = data->isPXA;
     getClock(data, isPXA);
 
-- 
1.5.2.5

