From patchwork Wed Nov 14 10:24:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Liu X-Patchwork-Id: 198868 X-Patchwork-Delegate: sonic.adi@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4A5CB2C007E for ; Wed, 14 Nov 2012 21:42:14 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ED6764A129; Wed, 14 Nov 2012 11:41:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v0a4KoRc5GVf; Wed, 14 Nov 2012 11:41:42 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8EA0C4A141; Wed, 14 Nov 2012 11:41:14 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E51F94A088 for ; Wed, 14 Nov 2012 11:40:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NFXW0LqQk-ZS for ; Wed, 14 Nov 2012 11:40:55 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from va3outboundpool.messaging.microsoft.com (va3ehsobe010.messaging.microsoft.com [216.32.180.30]) by theia.denx.de (Postfix) with ESMTPS id 2061B4A052 for ; Wed, 14 Nov 2012 11:40:39 +0100 (CET) Received: from mail21-va3-R.bigfish.com (10.7.14.247) by VA3EHSOBE008.bigfish.com (10.7.40.28) with Microsoft SMTP Server id 14.1.225.23; Wed, 14 Nov 2012 10:25:31 +0000 Received: from mail21-va3 (localhost [127.0.0.1]) by mail21-va3-R.bigfish.com (Postfix) with ESMTP id 2F1B640081; Wed, 14 Nov 2012 10:25:31 +0000 (UTC) X-Forefront-Antispam-Report: CIP:137.71.25.57; KIP:(null); UIP:(null); IPV:NLI; H:nwd2mta2.analog.com; RD:nwd2mail11.analog.com; EFVD:NLI X-SpamScore: 17 X-BigFish: VS17(zzzz1ce5h1202h1d1ah1cabh1d2ahzz8275bhz2ei87h2a8h668h839hd24he5bh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h13eah1441h14ddh1504h1537h15a8hff4m129fs1155h) Received-SPF: neutral (mail21-va3: 137.71.25.57 is neither permitted nor denied by domain of gmail.com) client-ip=137.71.25.57; envelope-from=lliubbo@gmail.com; helo=nwd2mta2.analog.com ; 2.analog.com ; X-FB-DOMAIN-IP-MATCH: fail Received: from mail21-va3 (localhost.localdomain [127.0.0.1]) by mail21-va3 (MessageSwitch) id 1352888729422256_30359; Wed, 14 Nov 2012 10:25:29 +0000 (UTC) Received: from VA3EHSMHS027.bigfish.com (unknown [10.7.14.246]) by mail21-va3.bigfish.com (Postfix) with ESMTP id 58B63600E7; Wed, 14 Nov 2012 10:25:29 +0000 (UTC) Received: from nwd2mta2.analog.com (137.71.25.57) by VA3EHSMHS027.bigfish.com (10.7.99.37) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 14 Nov 2012 10:25:28 +0000 Received: from NWD2HUBCAS1.ad.analog.com (nwd2hubcas1.ad.analog.com [10.64.73.29]) by nwd2mta2.analog.com (8.13.8/8.13.8) with ESMTP id qAEBYBP5016177 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 14 Nov 2012 06:34:11 -0500 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS1.ad.analog.com (10.64.73.29) with Microsoft SMTP Server id 8.3.83.0; Wed, 14 Nov 2012 05:25:28 -0500 Received: from linux.site ([10.99.22.20]) by zeus.spd.analog.com (8.14.5/8.14.5) with ESMTP id qAEAPQIo032333; Wed, 14 Nov 2012 05:25:27 -0500 Received: from bob-OptiPlex-760.analog.com (unknown [10.99.24.84]) by linux.site (Postfix) with ESMTP id 48F0842CC153; Tue, 13 Nov 2012 19:54:05 -0700 (MST) From: Bob Liu To: Date: Wed, 14 Nov 2012 18:24:46 +0800 Message-ID: <1352888686-9868-13-git-send-email-lliubbo@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352888686-9868-1-git-send-email-lliubbo@gmail.com> References: <1352888686-9868-1-git-send-email-lliubbo@gmail.com> MIME-Version: 1.0 Cc: u-boot-devel@blackfin.uclinux.org, Steven Miao , trini@ti.com, sonic.zhang@analog.com Subject: [U-Boot] [PATCH V3 12/12] Blackfin: bf60x: add resume from hibernate X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Steven Miao Add Bf60x resume from hibernate support Signed-off-by: Steven Miao Signed-off-by: Sonic Zhang Signed-off-by: Bob Liu --- arch/blackfin/cpu/initcode.c | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/arch/blackfin/cpu/initcode.c b/arch/blackfin/cpu/initcode.c index 6740e34..3fd6d84 100644 --- a/arch/blackfin/cpu/initcode.c +++ b/arch/blackfin/cpu/initcode.c @@ -504,6 +504,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__ */ @@ -818,6 +823,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 @@ -885,7 +891,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) @@ -917,6 +960,7 @@ check_hibernation(ADI_BOOT_DATA *bs, u16 vr_ctl, bool put_into_srfs) } serial_putc('d'); } +#endif serial_putc('e'); }