From patchwork Tue Aug 21 05:27:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Liu X-Patchwork-Id: 178966 X-Patchwork-Delegate: vapier@gentoo.org 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 0E39D2C009F for ; Tue, 21 Aug 2012 15:30:53 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A0DD4280E1; Tue, 21 Aug 2012 07:30:51 +0200 (CEST) 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 rw06bF6ILW+E; Tue, 21 Aug 2012 07:30:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6C1BD2809C; Tue, 21 Aug 2012 07:30:50 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A721B2829B for ; Tue, 21 Aug 2012 07:27:20 +0200 (CEST) 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 n2y-TzXId6-p for ; Tue, 21 Aug 2012 07:27:18 +0200 (CEST) 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 am1outboundpool.messaging.microsoft.com (am1ehsobe005.messaging.microsoft.com [213.199.154.208]) by theia.denx.de (Postfix) with ESMTPS id D01B92817F for ; Tue, 21 Aug 2012 07:27:13 +0200 (CEST) Received: from mail88-am1-R.bigfish.com (10.3.201.248) by AM1EHSOBE003.bigfish.com (10.3.204.23) with Microsoft SMTP Server id 14.1.225.23; Tue, 21 Aug 2012 05:27:11 +0000 Received: from mail88-am1 (localhost [127.0.0.1]) by mail88-am1-R.bigfish.com (Postfix) with ESMTP id 9E910802C4; Tue, 21 Aug 2012 05:27:11 +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: 8 X-BigFish: VS8(zzzz1202h1cabhzz8275bhz2ei87h2a8h668h839hd24he5bhe96h107ahff4o1155h1151h) Received-SPF: neutral (mail88-am1: 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 mail88-am1 (localhost.localdomain [127.0.0.1]) by mail88-am1 (MessageSwitch) id 134552683066780_32490; Tue, 21 Aug 2012 05:27:10 +0000 (UTC) Received: from AM1EHSMHS012.bigfish.com (unknown [10.3.201.231]) by mail88-am1.bigfish.com (Postfix) with ESMTP id 03D40480043; Tue, 21 Aug 2012 05:27:10 +0000 (UTC) Received: from nwd2mta2.analog.com (137.71.25.57) by AM1EHSMHS012.bigfish.com (10.3.207.112) with Microsoft SMTP Server (TLS) id 14.1.225.23; Tue, 21 Aug 2012 05:27:09 +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 q7L6VQMP013436 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Tue, 21 Aug 2012 02:31:26 -0400 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; Tue, 21 Aug 2012 01:27:08 -0400 Received: from linux.site ([10.99.22.20]) by zeus.spd.analog.com (8.14.5/8.14.5) with ESMTP id q7L5R7uk009716; Tue, 21 Aug 2012 01:27:07 -0400 Received: from bob-OptiPlex-760.analog.com (unknown [10.99.24.84]) by linux.site (Postfix) with ESMTP id 4950A42CB7CC; Mon, 20 Aug 2012 15:53:15 -0600 (MDT) From: Bob Liu To: , , Date: Tue, 21 Aug 2012 13:27:12 +0800 Message-ID: <1345526833-10804-12-git-send-email-lliubbo@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1345526833-10804-1-git-send-email-lliubbo@gmail.com> References: <1345526833-10804-1-git-send-email-lliubbo@gmail.com> MIME-Version: 1.0 Cc: u-boot-devel@blackfin.uclinux.org, sonic.zhang@analog.com, Steven Miao Subject: [U-Boot] [PATCH 12/13] 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 | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/arch/blackfin/cpu/initcode.c b/arch/blackfin/cpu/initcode.c index fc6e77b..b4bbc37 100644 --- a/arch/blackfin/cpu/initcode.c +++ b/arch/blackfin/cpu/initcode.c @@ -506,6 +506,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__ */ @@ -820,6 +825,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 @@ -887,7 +893,46 @@ 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'); + volatile uint32_t *hibernate_magic = bfin_read32(DPM0_RESTORE4); + __builtin_bfin_ssync(); /* make sure memory controller is done */ + if (hibernate_magic[0] == 0xDEADBEEF) { + serial_putc('c'); + + __builtin_bfin_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) @@ -919,6 +964,7 @@ check_hibernation(ADI_BOOT_DATA *bs, u16 vr_ctl, bool put_into_srfs) } serial_putc('d'); } +#endif serial_putc('e'); }