public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Sonic Zhang <sonic.adi@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 11/11] Blackfin: bf60x: add resume from hibernate
Date: Thu, 7 Feb 2013 15:47:38 +0800	[thread overview]
Message-ID: <1360223258-6945-12-git-send-email-sonic.adi@gmail.com> (raw)
In-Reply-To: <1360223258-6945-1-git-send-email-sonic.adi@gmail.com>

From: Steven Miao <realmz6@gmail.com>

Add Bf60x resume from hibernate support

Signed-off-by: Steven Miao <realmz6@gmail.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
 arch/blackfin/cpu/initcode.c |   44 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/arch/blackfin/cpu/initcode.c b/arch/blackfin/cpu/initcode.c
index 5ee2203..1d293cc 100644
--- a/arch/blackfin/cpu/initcode.c
+++ b/arch/blackfin/cpu/initcode.c
@@ -509,6 +509,11 @@ maybe_self_refresh(ADI_BOOT_DATA *bs)
 		return false;
 
 #ifdef __ADSPBF60x__
+	/* resume from hibernate, return false let ddr initialize */
+	if ((bfin_read32(DPM0_STAT) & 0xF0) == 0x50) {
+		serial_putc('b');
+		return false;
+	}
 
 #else /* __ADSPBF60x__ */
 
@@ -823,6 +828,7 @@ program_memory_controller(ADI_BOOT_DATA *bs, bool put_into_srfs)
 	while (!(bfin_read_DMC0_STAT() & DLLCALDONE))
 		continue;
 	serial_putc('!');
+
 #else /* __ADSPBF60x__ */
 
 	/* Program the external memory controller before we come out of
@@ -890,7 +896,44 @@ check_hibernation(ADI_BOOT_DATA *bs, u16 vr_ctl, bool put_into_srfs)
 		return;
 
 	serial_putc('b');
+#ifdef __ADSPBF60x__
+	if (bfin_read32(DPM0_RESTORE0) != 0) {
+		uint32_t reg = bfin_read_DMC0_CTL();
+		reg &= ~0x8;
+		bfin_write_DMC0_CTL(reg);
+
+		while ((bfin_read_DMC0_STAT() & 0x8))
+			continue;
+		while (!(bfin_read_DMC0_STAT() & 0x1))
+			continue;
 
+		serial_putc('z');
+		uint32_t *hibernate_magic = bfin_read32(DPM0_RESTORE4);
+		SSYNC(); /* make sure memory controller is done */
+		if (hibernate_magic[0] == 0xDEADBEEF) {
+			serial_putc('c');
+			SSYNC();
+			bfin_write_EVT15(hibernate_magic[1]);
+			bfin_write_IMASK(EVT_IVG15);
+			__asm__ __volatile__ (
+				/* load reti early to avoid anomaly 281 */
+				"reti = %2;"
+				/* clear hibernate magic */
+				"[%0] = %1;"
+				/* load stack pointer */
+				"SP = [%0 + 8];"
+				/* lower ourselves from reset ivg to ivg15 */
+				"raise 15;"
+				"nop;nop;nop;"
+				"rti;"
+				:
+				: "p"(hibernate_magic), "d"(0x2000 /* jump.s 0 */), "d"(0xffa00000)
+			);
+		}
+
+
+	}
+#else
 	/* Are we coming out of hibernate (suspend to memory) ?
 	 * The memory layout is:
 	 * 0x0: hibernate magic for anomaly 307 (0xDEADBEEF)
@@ -922,6 +965,7 @@ check_hibernation(ADI_BOOT_DATA *bs, u16 vr_ctl, bool put_into_srfs)
 		}
 		serial_putc('d');
 	}
+#endif
 
 	serial_putc('e');
 }
-- 
1.7.0.4

  parent reply	other threads:[~2013-02-07  7:47 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-07  7:47 [U-Boot] [PATCH 00/11] Add BF60x processor support to Blackfin architecture Sonic Zhang
2013-02-07  7:47 ` [U-Boot] [PATCH 01/11] Blackfin: bf60x: new processor header files Sonic Zhang
2013-02-07  7:47 ` [U-Boot] [PATCH 02/11] Blackfin: bf60x: Port blackfin core architecture code to boot on bf60x Sonic Zhang
2013-02-07 10:21   ` Wolfgang Denk
2013-02-08  4:31     ` Sonic Zhang
2013-02-07  7:47 ` [U-Boot] [PATCH 03/11] Blackfin: bf60x: add serial support Sonic Zhang
2013-02-07 10:15   ` Wolfgang Denk
2013-02-08  4:20     ` Sonic Zhang
2013-02-07  7:47 ` [U-Boot] [PATCH 04/11] Blackfin: bf60x: add dma support Sonic Zhang
2013-02-07 10:11   ` Wolfgang Denk
2013-02-08  4:17     ` Sonic Zhang
2013-02-07  7:47 ` [U-Boot] [PATCH 05/11] Blackfin: bf60x: support big cplb page Sonic Zhang
2013-02-07 10:33   ` Wolfgang Denk
2013-02-08  4:22     ` Sonic Zhang
2013-02-18  2:43     ` Bob Liu
2013-02-18  7:41       ` Sonic Zhang
2013-02-07  7:47 ` [U-Boot] [PATCH 06/11] Blackfin: bf60x: add gpio support Sonic Zhang
2013-02-07  7:47 ` [U-Boot] [PATCH 07/11] blackfin: bf609: add board and headers files to support bf609 Sonic Zhang
2013-02-07 10:26   ` Wolfgang Denk
2013-02-08  4:26     ` Sonic Zhang
2013-02-08  6:29     ` Sonic Zhang
2013-02-08  8:29     ` Sonic Zhang
2013-02-17 20:13       ` Wolfgang Denk
2013-02-07  7:47 ` [U-Boot] [PATCH 08/11] Blackfin: bf60x: add rsi/sdh support Sonic Zhang
2013-02-07 10:17   ` Wolfgang Denk
2013-02-08  4:33     ` Sonic Zhang
2013-02-08  8:35     ` Sonic Zhang
2013-02-17 20:15       ` Wolfgang Denk
2013-02-18  7:38         ` Sonic Zhang
2013-03-04 11:21           ` Wolfgang Denk
2013-03-05  2:22             ` Sonic Zhang
2013-02-07  7:47 ` [U-Boot] [PATCH 09/11] Blackfin: spi: add bf6xx spi driver Sonic Zhang
2013-02-07 10:23   ` Wolfgang Denk
2013-02-08  6:50     ` Sonic Zhang
2013-02-17 20:12       ` Wolfgang Denk
2013-02-07  7:47 ` [U-Boot] [PATCH 10/11] Blackfin: bf60x: add hw watchdog support Sonic Zhang
2013-02-07  7:47 ` Sonic Zhang [this message]
2013-02-07 10:22   ` [U-Boot] [PATCH 11/11] Blackfin: bf60x: add resume from hibernate Wolfgang Denk
2013-02-07 10:04 ` [U-Boot] [PATCH 00/11] Add BF60x processor support to Blackfin architecture Wolfgang Denk
2013-02-07 12:28   ` Albert ARIBAUD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1360223258-6945-12-git-send-email-sonic.adi@gmail.com \
    --to=sonic.adi@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox