From patchwork Thu Jul 17 16:39:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 4577361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66B33C0515 for ; Thu, 17 Jul 2014 16:42:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 976AA201BB for ; Thu, 17 Jul 2014 16:42:31 +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 B16982008F for ; Thu, 17 Jul 2014 16:42:30 +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 1X7ojq-0004S9-S9; Thu, 17 Jul 2014 16:40:58 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X7oj9-000313-1f for linux-arm-kernel@lists.infradead.org; Thu, 17 Jul 2014 16:40:15 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N8V00BQN7LZVN00@mailout2.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Thu, 17 Jul 2014 17:39:35 +0100 (BST) X-AuditID: cbfec7f4-b7fac6d000006cfe-c8-53c7fc58b201 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 2B.96.27902.85CF7C35; Thu, 17 Jul 2014 17:39:52 +0100 (BST) Received: from AMDC1227.digital.local ([106.116.147.199]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N8V00HDB7M9BP70@eusync3.samsung.com>; Thu, 17 Jul 2014 17:39:52 +0100 (BST) From: Tomasz Figa To: linux-samsung-soc@vger.kernel.org Subject: [PATCH v3 6/7] ARM: EXYNOS: Add support for non-secure L2X0 resume Date: Thu, 17 Jul 2014 18:39:01 +0200 Message-id: <1405615142-21426-7-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.9.3 In-reply-to: <1405615142-21426-1-git-send-email-t.figa@samsung.com> References: <1405615142-21426-1-git-send-email-t.figa@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCLMWRmVeSWpSXmKPExsVy+t/xq7oRf44HG6zZLWDxaP5jZoveBVfZ LLZ3zmC3mPJnOZPFpsfXWC0u75rDZjF7ST+LxYzz+5gsbl/mtTi3fQuLxdojd9ktXvetYbZY P+M1i8WqXX8YLfZf8XLg92hp7mHz+PZ1EovH5b5eJo9F37M8ds66y+5x59oeNo/NS+o9+ras YvQ4fmM7k8fnTXIBXFFcNimpOZllqUX6dglcGX3PXzIXrBerOPqxk7GB8YJQFyMnh4SAicSP X0eZIGwxiQv31rN1MXJxCAksZZRYO+kvK4TTxyQx+XMfG0gVm4CaxOeGR2C2iICqxOe2Bewg RcwCB5glLmx6wAKSEBbwltiw4TlYEQtQ0YTue2BxXgEnieur2pgh1slJ9G57A2ZzCjhLzN3/ GKxeCKhmS9sCpgmMvAsYGVYxiqaWJhcUJ6XnGuoVJ+YWl+al6yXn525ihIT0lx2Mi49ZHWIU 4GBU4uHt/HwsWIg1say4MvcQowQHs5IIb/b948FCvCmJlVWpRfnxRaU5qcWHGJk4OKUaGEXd P59ZcqZ2Tzh/392nRj7LLnvVPtv6WuR5jw9T9NlFr69/s9nW6lgtcJS/d+WjpKnqbpOV+5qm 7b1WrVrLvfXlAuuz26/xhnDFdM/zWCz7oe3bzobDpzW2X3nDGL44q0Xqc+hnE9dJh9O/vk+T vHJw5jLmDewWBZyRmeGVzDMY5txftyt1S6wSS3FGoqEWc1FxIgAFMjiSRwIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140717_094015_228005_2AF608F3 X-CRM114-Status: UNSURE ( 9.94 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.0 (-----) Cc: Kukjin Kim , lauraa@codeaurora.org, tony@atomide.com, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, drake@endlessm.com, loeliger@gmail.com, santosh.shilimkar@ti.com, Russell King - ARM Linux , linux-omap@vger.kernel.org, Tomasz Figa , Tomasz Figa , linux-arm-kernel@lists.infradead.org, Marek Szyprowski 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 On Exynos SoCs it is necessary to resume operation of L2C early in assembly code, because otherwise certain systems will crash. This patch adds necessary code to non-secure resume handler. Signed-off-by: Tomasz Figa --- arch/arm/mach-exynos/common.h | 1 + arch/arm/mach-exynos/firmware.c | 2 ++ arch/arm/mach-exynos/sleep.S | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h index a3f3061..2540827 100644 --- a/arch/arm/mach-exynos/common.h +++ b/arch/arm/mach-exynos/common.h @@ -113,6 +113,7 @@ IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK) extern u32 cp15_save_diag; extern u32 cp15_save_power; +extern unsigned long l2x0_regs_phys; extern void __iomem *sysram_ns_base_addr; extern void __iomem *sysram_base_addr; diff --git a/arch/arm/mach-exynos/firmware.c b/arch/arm/mach-exynos/firmware.c index 554b350..09131d3 100644 --- a/arch/arm/mach-exynos/firmware.c +++ b/arch/arm/mach-exynos/firmware.c @@ -103,6 +103,8 @@ static int exynos_suspend(void) writel(virt_to_phys(exynos_cpu_resume_ns), sysram_ns_base_addr + EXYNOS_BOOT_ADDR); + l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs); + return cpu_suspend(0, exynos_cpu_suspend); } diff --git a/arch/arm/mach-exynos/sleep.S b/arch/arm/mach-exynos/sleep.S index e3c3730..b8ce8f0 100644 --- a/arch/arm/mach-exynos/sleep.S +++ b/arch/arm/mach-exynos/sleep.S @@ -16,6 +16,8 @@ */ #include +#include +#include #include "smc.h" #define CPU_MASK 0xff0ffff0 @@ -74,6 +76,40 @@ ENTRY(exynos_cpu_resume_ns) mov r0, #SMC_CMD_C15RESUME dsb smc #0 +#ifdef CONFIG_CACHE_L2X0 + adr r0, l2x0_regs_phys + ldr r0, [r0] + cmp r0, #0 + beq skip_l2x0 + + ldr r1, [r0, #L2X0_R_PHY_BASE] + ldr r2, [r1, #L2X0_CTRL] + tst r2, #0x1 + bne skip_l2x0 + + ldr r1, [r0, #L2X0_R_TAG_LATENCY] + ldr r2, [r0, #L2X0_R_DATA_LATENCY] + ldr r3, [r0, #L2X0_R_PREFETCH_CTRL] + mov r0, #SMC_CMD_L2X0SETUP1 + smc #0 + + /* Reload saved regs pointer because smc corrupts registers. */ + adr r0, l2x0_regs_phys + ldr r0, [r0] + + ldr r1, [r0, #L2X0_R_PWR_CTRL] + ldr r2, [r0, #L2X0_R_AUX_CTRL] + mov r0, #SMC_CMD_L2X0SETUP2 + smc #0 + + mov r0, #SMC_CMD_L2X0INVALL + smc #0 + + mov r1, #1 + mov r0, #SMC_CMD_L2X0CTRL + smc #0 +skip_l2x0: +#endif /* CONFIG_CACHE_L2X0 */ skip_cp15: b cpu_resume ENDPROC(exynos_cpu_resume_ns) @@ -83,3 +119,8 @@ cp15_save_diag: .globl cp15_save_power cp15_save_power: .long 0 @ cp15 power control +#ifdef CONFIG_CACHE_L2X0 + .globl l2x0_regs_phys +l2x0_regs_phys: + .long 0 @ phys address of l2x0 save struct +#endif /* CONFIG_CACHE_L2X0 */