From patchwork Fri Jan 6 06:59:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 9500145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51A9F60413 for ; Fri, 6 Jan 2017 07:03:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F4E628426 for ; Fri, 6 Jan 2017 07:03:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 343D62842C; Fri, 6 Jan 2017 07:03:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DB8E128426 for ; Fri, 6 Jan 2017 07:03:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cPOYk-00019n-6H; Fri, 06 Jan 2017 07:03:30 +0000 Received: from nasmtp01.atmel.com ([192.199.1.246] helo=ussmtp01.atmel.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cPOYc-0000rx-UG for linux-arm-kernel@lists.infradead.org; Fri, 06 Jan 2017 07:03:25 +0000 Received: from apsmtp01.atmel.com (10.168.254.30) by DVREDG02.corp.atmel.com (10.42.103.31) with Microsoft SMTP Server (TLS) id 14.3.235.1; Fri, 6 Jan 2017 00:02:55 -0700 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.3.235.1; Fri, 6 Jan 2017 15:05:52 +0800 From: Wenyou Yang To: Alexandre Belloni , Russell King , Nicolas Ferre , "Rob Herring" , Mark Rutland Subject: [PATCH 1/3] ARM: at91: flush the L2 cache before entering cpu idle Date: Fri, 6 Jan 2017 14:59:45 +0800 Message-ID: <20170106065947.30631-2-wenyou.yang@atmel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170106065947.30631-1-wenyou.yang@atmel.com> References: <20170106065947.30631-1-wenyou.yang@atmel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170105_230323_115474_4B4EA35D X-CRM114-Status: UNSURE ( 8.87 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Wenyou Yang , Wenyou Yang Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP For the SoCs such as SAMA5D2 and SAMA5D4 which have L2 cache, flush the L2 cache first before entering the cpu idle. Signed-off-by: Wenyou Yang --- arch/arm/mach-at91/pm.c | 19 +++++++++++++++++++ drivers/memory/atmel-sdramc.c | 1 + 2 files changed, 20 insertions(+) diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c index b4332b727e9c..1a60dede1a01 100644 --- a/arch/arm/mach-at91/pm.c +++ b/arch/arm/mach-at91/pm.c @@ -289,6 +289,24 @@ static void at91_ddr_standby(void) at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); } +static void at91_ddr_cache_standby(void) +{ + u32 saved_lpr; + + flush_cache_all(); + outer_disable(); + + saved_lpr = at91_ramc_read(0, AT91_DDRSDRC_LPR); + at91_ramc_write(0, AT91_DDRSDRC_LPR, (saved_lpr & + (~AT91_DDRSDRC_LPCB)) | AT91_DDRSDRC_LPCB_SELF_REFRESH); + + cpu_do_idle(); + + at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr); + + outer_resume(); +} + /* We manage both DDRAM/SDRAM controllers, we need more than one value to * remember. */ @@ -324,6 +342,7 @@ static const struct of_device_id const ramc_ids[] __initconst = { { .compatible = "atmel,at91sam9260-sdramc", .data = at91sam9_sdram_standby }, { .compatible = "atmel,at91sam9g45-ddramc", .data = at91_ddr_standby }, { .compatible = "atmel,sama5d3-ddramc", .data = at91_ddr_standby }, + { .compatible = "atmel,sama5d4-ddramc", .data = at91_ddr_cache_standby }, { /*sentinel*/ } }; diff --git a/drivers/memory/atmel-sdramc.c b/drivers/memory/atmel-sdramc.c index b418b39af180..7e5c5c6c1348 100644 --- a/drivers/memory/atmel-sdramc.c +++ b/drivers/memory/atmel-sdramc.c @@ -48,6 +48,7 @@ static const struct of_device_id atmel_ramc_of_match[] = { { .compatible = "atmel,at91sam9260-sdramc", .data = &at91rm9200_caps, }, { .compatible = "atmel,at91sam9g45-ddramc", .data = &at91sam9g45_caps, }, { .compatible = "atmel,sama5d3-ddramc", .data = &sama5d3_caps, }, + { .compatible = "atmel,sama5d4-ddramc", .data = &sama5d3_caps, }, {}, };