From patchwork Mon Jan 26 10:06:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 5707681 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4F4E89F2ED for ; Mon, 26 Jan 2015 10:09:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A7FD20121 for ; Mon, 26 Jan 2015 10:09:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 81CBD2011E for ; Mon, 26 Jan 2015 10:09:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFgZY-0005i7-Ac; Mon, 26 Jan 2015 10:07:08 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFgZT-0005V0-1w for linux-arm-kernel@lists.infradead.org; Mon, 26 Jan 2015 10:07:03 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.2.347.0; Mon, 26 Jan 2015 11:06:39 +0100 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id 14.2.347.0; Mon, 26 Jan 2015 18:09:36 +0800 From: Wenyou Yang To: , Subject: [PATCH 2/7] pm: at91: pm_suspend: add the WFI support for ARMv7 Date: Mon, 26 Jan 2015 18:06:01 +0800 Message-ID: <1422266761-24487-1-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1422266617-24381-1-git-send-email-wenyou.yang@atmel.com> References: <1422266617-24381-1-git-send-email-wenyou.yang@atmel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150126_020703_326597_9F2E805D X-CRM114-Status: UNSURE ( 9.87 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) Cc: sylvain.rochet@finsecur.com, Patrice.VILCHEZ@atmel.com, linux-kernel@vger.kernel.org, wenyou.yang@atmel.com, alexandre.belloni@free-electrons.com, peda@axentia.se, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Wenyou Yang --- arch/arm/mach-at91/pm_suspend.S | 54 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-at91/pm_suspend.S b/arch/arm/mach-at91/pm_suspend.S index 122a3f1..e796722 100644 --- a/arch/arm/mach-at91/pm_suspend.S +++ b/arch/arm/mach-at91/pm_suspend.S @@ -53,6 +53,58 @@ mode .req r6 beq 1b .endm +/* + * Put the processor to enter the WFI state + */ + .macro _do_wfi + +#if defined(CONFIG_CPU_V7) + /* + * Execute an ISB instruction to flush the pipeline to ensure + * that all of operations have beem completed. + */ + isb + + /* + * Execute an ISB instruction to ensure that all of the + * CP15 register changes have been committed. + */ + dsb + dmb + + /* Disable the processor's clock */ + mov tmp1, #AT91_PMC_PCK + str tmp1, [pmc, #AT91_PMC_SCDR] + + /* Execute a WFI instruction */ + wfi @ Wait For Interrupt + + /* + * CPU can specualatively prefetch the instructions + * so add NOPs after WFI. Sixteen NOPs as Cortex-A5 pipeline. + */ + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop + nop +#else + mcr p15, 0, tmp1, c7, c0, 4 +#endif + + .endm + .text /* @@ -181,7 +233,7 @@ sdr_sr_done: skip_disable_main_clock: /* Wait for interrupt */ - mcr p15, 0, tmp1, c7, c0, 4 + _do_wfi tst mode, #AT91_PM_SLOW_CLOCK beq skip_enable_main_clock