<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7651.59">
<TITLE>[PATCH] lite5200b: support wake from low-power mode</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Puts SDRAM out of self-refresh and transfers control to<BR>
address saved at physical 0x0.<BR>
<BR>
Used by Linux patches posted at<BR>
<A HREF="http://ozlabs.org/pipermail/linuxppc-embedded/2007-March/026242.html">http://ozlabs.org/pipermail/linuxppc-embedded/2007-March/026242.html</A><BR>
<BR>
Index: u-boot-of.git/board/icecube/icecube.c<BR>
===================================================================<BR>
--- u-boot-of.git.orig/board/icecube/icecube.c<BR>
+++ u-boot-of.git/board/icecube/icecube.c<BR>
@@ -42,6 +42,54 @@<BR>
#include "mt48lc16m16a2-75.h"<BR>
# endif<BR>
#endif<BR>
+<BR>
+#ifdef CONFIG_LITE5200B<BR>
+/* u-boot part of low-power mode implementation */<BR>
+#define SAVED_ADDR (*(void **)0x00000000)<BR>
+#define PSC2_4 0x02<BR>
+<BR>
+void lite5200b_wakeup(void)<BR>
+{<BR>
+ unsigned char wakeup_pin;<BR>
+ void (*linux_wakeup)(void);<BR>
+<BR>
+ /* check PSC2_4, if it's down "QT" is signaling we have a wakeup<BR>
+ * from low power mode */<BR>
+ *(vu_char *)MPC5XXX_WU_GPIO_ENABLE = PSC2_4;<BR>
+ __asm__ volatile ("sync");<BR>
+<BR>
+ wakeup_pin = *(vu_char *)MPC5XXX_WU_GPIO_DATA_I;<BR>
+ if (wakeup_pin & PSC2_4)<BR>
+ return;<BR>
+<BR>
+ /* acknowledge to "QT"<BR>
+ * by holding pin at 1 for 10 uS */<BR>
+ *(vu_char *)MPC5XXX_WU_GPIO_DIR = PSC2_4;<BR>
+ __asm__ volatile ("sync");<BR>
+ *(vu_char *)MPC5XXX_WU_GPIO_DATA = PSC2_4;<BR>
+ __asm__ volatile ("sync");<BR>
+ udelay(10);<BR>
+<BR>
+ /* put ram out of self-refresh */<BR>
+ *(vu_long *)MPC5XXX_SDRAM_CTRL |= 0x80000000; // mode_en<BR>
+ __asm__ volatile ("sync");<BR>
+ *(vu_long *)MPC5XXX_SDRAM_CTRL |= 0x50000000; // cke ref_en<BR>
+ __asm__ volatile ("sync");<BR>
+ *(vu_long *)MPC5XXX_SDRAM_CTRL &= ~0x80000000; // !mode_en<BR>
+ __asm__ volatile ("sync");<BR>
+ udelay(10); /* wait a bit */<BR>
+<BR>
+ /* jump back to linux kernel code */<BR>
+ linux_wakeup = SAVED_ADDR;<BR>
+ printf("\n\nLooks like we just woke, transferring control to 0x%08lx\n",<BR>
+ linux_wakeup);<BR>
+ linux_wakeup();<BR>
+}<BR>
+#else<BR>
+#define lite5200b_wakeup()<BR>
+#endif<BR>
+<BR>
+<BR>
#ifndef CFG_RAMBOOT<BR>
static void sdram_start (int hi_addr)<BR>
{<BR>
@@ -208,6 +256,8 @@ long int initdram (int board_type)<BR>
__asm__ volatile ("sync");<BR>
}<BR>
<BR>
+ lite5200b_wakeup();<BR>
+<BR>
return dramsize + dramsize2;<BR>
}<BR>
<BR>
Index: u-boot-of.git/include/mpc5xxx.h<BR>
===================================================================<BR>
--- u-boot-of.git.orig/include/mpc5xxx.h<BR>
+++ u-boot-of.git/include/mpc5xxx.h<BR>
@@ -189,6 +189,7 @@<BR>
#define MPC5XXX_WU_GPIO_ODE (MPC5XXX_WU_GPIO + 0x0004)<BR>
#define MPC5XXX_WU_GPIO_DIR (MPC5XXX_WU_GPIO + 0x0008)<BR>
#define MPC5XXX_WU_GPIO_DATA (MPC5XXX_WU_GPIO + 0x000c)<BR>
+#define MPC5XXX_WU_GPIO_DATA_I (MPC5XXX_WU_GPIO + 0x0020)<BR>
<BR>
/* PCI registers */<BR>
#define MPC5XXX_PCI_CMD (MPC5XXX_PCI + 0x04)<BR>
<BR>
</FONT>
</P>
</BODY>
</HTML>