From patchwork Thu Jan 16 07:36:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 23255 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C478B20555 for ; Thu, 16 Jan 2014 07:36:11 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id z10sf4709205pdj.1 for ; Wed, 15 Jan 2014 23:36:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:subject:message-id :references:mime-version:in-reply-to:user-agent:cc:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-disposition :content-type:content-transfer-encoding; bh=OtGzSlqNEXUF+G8VlLu3MBasA2UWxw4Z80uHm5+IYn4=; b=b1EpGH5AoEogiFd2zyBB5jjhLiQSGYj3cz42/DhnyxQUt0z6IVfzIkIbZ0X831PSdT S5kppnD5KU7LgkZRrgM4P20iyw8e35KwvB0LeDtbjgg0lH8kwLasFAz4d03eI1t4LoS8 uXu2FM2H3rrExer1eW7HIAskrwcmICritiWhMQFxMgGh2Dr49B+wMAokfM8Ea+9CcDSL RBpN9mhWe1yle4UB7sBNiVVMNPwbc3MjxwdUMJeaoQXYEctg9nBcY+pLKhE7PzqpgOR5 1OSYK4ZN4cBnV6HycIO4BXtIFoN3JzvgNWZLuRcmkDrY5CYwz+GrWPFbqeP3iOQkAjKz qu2w== X-Gm-Message-State: ALoCoQkWZErykY7pRbKro+7cUBQk2WgXIa72HvfVHbhfQrPgQd8vEPmUZLvlzaS7FAWaULDKJVxv X-Received: by 10.66.222.105 with SMTP id ql9mr2933817pac.9.1389857771047; Wed, 15 Jan 2014 23:36:11 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.85.169 with SMTP id n38ls115316qgd.96.gmail; Wed, 15 Jan 2014 23:36:10 -0800 (PST) X-Received: by 10.220.145.75 with SMTP id c11mr115849vcv.30.1389857770865; Wed, 15 Jan 2014 23:36:10 -0800 (PST) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id w5si2942504vcn.26.2014.01.15.23.36.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 Jan 2014 23:36:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.176; Received: by mail-vc0-f176.google.com with SMTP id la4so808949vcb.7 for ; Wed, 15 Jan 2014 23:36:10 -0800 (PST) X-Received: by 10.221.26.10 with SMTP id rk10mr5432199vcb.0.1389857770765; Wed, 15 Jan 2014 23:36:10 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp327930ved; Wed, 15 Jan 2014 23:36:10 -0800 (PST) X-Received: by 10.180.98.199 with SMTP id ek7mr6430025wib.21.1389857769589; Wed, 15 Jan 2014 23:36:09 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id ur6si5185631wjc.38.2014.01.15.23.36.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jan 2014 23:36:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W3hUT-0002DP-9n; Thu, 16 Jan 2014 07:35:49 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W3hUQ-0006ru-W7; Thu, 16 Jan 2014 07:35:47 +0000 Received: from va3ehsobe006.messaging.microsoft.com ([216.32.180.16] helo=va3outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W3hUO-0006rV-2n for linux-arm-kernel@lists.infradead.org; Thu, 16 Jan 2014 07:35:45 +0000 Received: from mail6-va3-R.bigfish.com (10.7.14.234) by VA3EHSOBE008.bigfish.com (10.7.40.28) with Microsoft SMTP Server id 14.1.225.22; Thu, 16 Jan 2014 07:35:22 +0000 Received: from mail6-va3 (localhost [127.0.0.1]) by mail6-va3-R.bigfish.com (Postfix) with ESMTP id 18750460380; Thu, 16 Jan 2014 07:35:22 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: -2 X-BigFish: VS-2(zz98dI1432Izz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah1fc6hzzz2dh87h2a8h839h944hd25hf0ah1220h1288h12a5h12a9h12bdh137ah13b6h1441h1504h1537h153bh162dh1631h1758h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1fe8h1ff5h209eh2216h22d0h2336h2438h2461h2487h1151h1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail6-va3 (localhost.localdomain [127.0.0.1]) by mail6-va3 (MessageSwitch) id 1389857719325696_30560; Thu, 16 Jan 2014 07:35:19 +0000 (UTC) Received: from VA3EHSMHS040.bigfish.com (unknown [10.7.14.228]) by mail6-va3.bigfish.com (Postfix) with ESMTP id 2C68D2004B; Thu, 16 Jan 2014 07:35:19 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS040.bigfish.com (10.7.99.50) with Microsoft SMTP Server (TLS) id 14.16.227.3; Thu, 16 Jan 2014 07:35:19 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Thu, 16 Jan 2014 07:35:18 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.143]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s0G7ZEbj002338; Thu, 16 Jan 2014 00:35:15 -0700 Date: Thu, 16 Jan 2014 15:36:56 +0800 From: Shawn Guo To: Anson Huang Subject: Re: [PATCH V6 3/3] ARM: imx: add suspend in ocram support for i.mx6sl Message-ID: <20140116073655.GC4049@S2101-09.ap.freescale.net> References: <1389840105-17625-1-git-send-email-b20788@freescale.com> <1389840105-17625-3-git-send-email-b20788@freescale.com> MIME-Version: 1.0 In-Reply-To: <1389840105-17625-3-git-send-email-b20788@freescale.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-OriginatorOrg: sigmatel.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140116_023544_184625_F31C940A X-CRM114-Status: GOOD ( 12.37 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 UNRESOLVED_TEMPLATE Headers contain an unresolved template -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [216.32.180.16 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux@arm.linux.org.uk, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shawn.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Content-Disposition: inline On Thu, Jan 16, 2014 at 10:41:45AM +0800, Anson Huang wrote: > @@ -119,6 +120,31 @@ > > .endm > > + .macro reset_mmdc_read_fifo > + > + /* reset read FIFO, RST_RD_FIFO */ > + ldr r7, =MX6Q_MMDC_MPDGCTRL0 > + ldr r6, [r11, r7] > + orr r6, r6, #(1 << 31) > + str r6, [r11, r7] > +1: > + ldr r6, [r11, r7] > + and r6, r6, #(1 << 31) > + cmp r6, #0 Use 'ands' to save the 'cmp'. > + bne 1b > + > + /* reset FIFO a second time */ > + ldr r6, [r11, r7] > + orr r6, r6, #(1 << 31) > + str r6, [r11, r7] > +2: > + ldr r6, [r11, r7] > + and r6, r6, #(1 << 31) > + cmp r6, #0 Ditto > + bne 2b > + > + .endm > + > ENTRY(imx6_suspend) > ldr r1, [r0, #PM_INFO_PBASE_OFFSET] > ldr r2, [r0, #PM_INFO_RESUME_ADDR_OFFSET] > @@ -286,6 +335,14 @@ resume: > restore_mmdc_io > > ldr r11, [r0, #PM_INFO_MX6Q_MMDC_P_OFFSET] > + > + ldr r3, [r0, #PM_INFO_CPU_TYPE_OFFSET] > + cmp r3, #MXC_CPU_IMX6SL > + bne dsm_restore_mmdc_io_done > + > + reset_mmdc_read_fifo > +dsm_restore_mmdc_io_done: > + > enable_mmdc_access > > mov pc, lr Instead of creating 3 macros, restore_mmdc_io, reset_mmdc_read_fifo and enable_mmdc_access, I was actually suggesting to do all the mmdc resume work in one macro. We will need to tell the macro whether we're running at virtual or physical space. For you reference, the following changes are what I made on top of yours. Shawn ---8<------- diff --git a/arch/arm/mach-imx/suspend-imx6.S b/arch/arm/mach-imx/suspend-imx6.S index 570fede..1ba8fc8 100644 --- a/arch/arm/mach-imx/suspend-imx6.S +++ b/arch/arm/mach-imx/suspend-imx6.S @@ -18,8 +18,8 @@ * * Better to follow below rules to use ARM registers: * r0: pm_info structure address; - * r1 ~ r5: for saving pm_info members; - * r6 ~ r10: free registers; + * r1 ~ r4: for saving pm_info members; + * r5 ~ r10: free registers; * r11: io base address. * * suspend ocram space layout: @@ -87,9 +87,13 @@ .endm - .macro restore_mmdc_io + .macro resume_mmdc + + /* restore MMDC IO */ + cmp r5, #0 + ldreq r11, [r0, #PM_INFO_MX6Q_IOMUXC_V_OFFSET] + ldrne r11, [r0, #PM_INFO_MX6Q_IOMUXC_P_OFFSET] - /* r11 must be the MMDC IO address before calling it */ ldr r6, [r0, #PM_INFO_MMDC_IO_NUM_OFFSET] ldr r7, =PM_INFO_MMDC_IO_VAL_OFFSET add r7, r7, r0 @@ -100,48 +104,45 @@ subs r6, r6, #0x1 bne 1b - .endm - - .macro enable_mmdc_access + cmp r5, #0 + ldreq r11, [r0, #PM_INFO_MX6Q_MMDC_V_OFFSET] + ldrne r11, [r0, #PM_INFO_MX6Q_MMDC_P_OFFSET] - /* let DDR out of self-refresh */ - ldr r7, [r11, #MX6Q_MMDC_MAPSR] - bic r7, r7, #(1 << 21) - str r7, [r11, #MX6Q_MMDC_MAPSR] - -1: - ldr r7, [r11, #MX6Q_MMDC_MAPSR] - ands r7, r7, #(1 << 25) - bne 1b - /* enable DDR auto power saving */ - ldr r7, [r11, #MX6Q_MMDC_MAPSR] - bic r7, r7, #0x1 - str r7, [r11, #MX6Q_MMDC_MAPSR] - - .endm - - .macro reset_mmdc_read_fifo + cmp r3, #MXC_CPU_IMX6SL + bne 4f /* reset read FIFO, RST_RD_FIFO */ ldr r7, =MX6Q_MMDC_MPDGCTRL0 ldr r6, [r11, r7] orr r6, r6, #(1 << 31) str r6, [r11, r7] -1: +2: ldr r6, [r11, r7] - and r6, r6, #(1 << 31) - cmp r6, #0 - bne 1b + ands r6, r6, #(1 << 31) + bne 2b /* reset FIFO a second time */ ldr r6, [r11, r7] orr r6, r6, #(1 << 31) str r6, [r11, r7] -2: +3: ldr r6, [r11, r7] - and r6, r6, #(1 << 31) - cmp r6, #0 - bne 2b + ands r6, r6, #(1 << 31) + bne 3b + +4: + /* let DDR out of self-refresh */ + ldr r7, [r11, #MX6Q_MMDC_MAPSR] + bic r7, r7, #(1 << 21) + str r7, [r11, #MX6Q_MMDC_MAPSR] +5: + ldr r7, [r11, #MX6Q_MMDC_MAPSR] + ands r7, r7, #(1 << 25) + bne 5b + /* enable DDR auto power saving */ + ldr r7, [r11, #MX6Q_MMDC_MAPSR] + bic r7, r7, #0x1 + str r7, [r11, #MX6Q_MMDC_MAPSR] .endm @@ -281,8 +282,7 @@ set_mmdc_io_lpm_done: */ ldr r6, =2000 rbc_loop: - sub r6, r6, #0x1 - cmp r6, #0x0 + subs r6, r6, #0x1 bne rbc_loop /* Zzz, enter stop mode */ @@ -297,18 +297,8 @@ rbc_loop: * wakeup source, system should auto * resume, we need to restore MMDC IO first */ - ldr r11, [r0, #PM_INFO_MX6Q_IOMUXC_V_OFFSET] - restore_mmdc_io - - ldr r11, [r0, #PM_INFO_MX6Q_MMDC_V_OFFSET] - - cmp r3, #MXC_CPU_IMX6SL - bne restore_mmdc_io_done - - reset_mmdc_read_fifo -restore_mmdc_io_done: - - enable_mmdc_access + mov r5, #0 + resume_mmdc /* return to suspend finish */ mov pc, lr @@ -331,19 +321,9 @@ resume: str r7, [r11, #MX6Q_SRC_GPR1] str r7, [r11, #MX6Q_SRC_GPR2] - ldr r11, [r0, #PM_INFO_MX6Q_IOMUXC_P_OFFSET] - restore_mmdc_io - - ldr r11, [r0, #PM_INFO_MX6Q_MMDC_P_OFFSET] - ldr r3, [r0, #PM_INFO_CPU_TYPE_OFFSET] - cmp r3, #MXC_CPU_IMX6SL - bne dsm_restore_mmdc_io_done - - reset_mmdc_read_fifo -dsm_restore_mmdc_io_done: - - enable_mmdc_access + mov r5, #1 + resume_mmdc mov pc, lr ENDPROC(imx6_suspend)