From patchwork Thu Aug 30 18:04:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10582521 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7257D174A for ; Thu, 30 Aug 2018 18:11:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6264F2C1DD for ; Thu, 30 Aug 2018 18:11:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 564892C1FB; Thu, 30 Aug 2018 18:11:54 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A17722C1DD for ; Thu, 30 Aug 2018 18:11:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hqvv07ggEpJ5YOg1A1blG8t2uTZgMACAy4tpiBWLA2E=; b=AIxhd7tNt7Gq27LWwxAzjLojUn dAg7xXxjEWCkbIz6QcQIyOKjHi+fiPkDaPZNKsivK5dpy6zNvbWLsIOieyqucIsvjyF5k/HXDOSWT rLZhK29ohcLGCr+F0jb+t77LMpIE+4xHsC4UZlNBZv03OkICemM+c1RlMWpGt/uVV75RYrd7/T5za kBofFc8uCKyKK0ltgDrb5sKgjI8+VGhRNm58wmVimHugnTiByjyyEokaZvw5twQsOE18Ev7qwcWii JYEUOlvskgcHR2u9bdF5N7jUM/IRexnh0LUXOtkgYMRMNYrmJJ/7lTPt12wE0ns3MiML3P0bDLQ8Q DXlFftmg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRPv-0003ns-57; Thu, 30 Aug 2018 18:11:39 +0000 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvRK9-0008Ul-LZ for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 18:05:43 +0000 Received: by mail-lj1-x241.google.com with SMTP id q127-v6so8003945ljq.11 for ; Thu, 30 Aug 2018 11:05:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8oMFGxXF6QUlJj5F31ofFC/byB4gOQFq079DGk4vXTU=; b=WVF+g8T56Wa5yvSO7+HtBo/1wWJw2I+/Gt1i4ISB6wcx6pPaYrW5Mk5YrslapLh1XV RoyXYDloAFZb4EYqwmDJV4M9Ui7vvFW4LKb1oSO031/VQq8XnI0vkKc3JjXOW+rDCoG0 GRehMi0xhBYoBo2jet0h/k5GwJnak7lPjYSa8IQgPwQgWh2YDuIFmGQ96colrthjlnzO GdSNp5ZkszVDbqJYTsUr2yl+iGb5uwyHrTeY6ILIbxWsWnQu15oOzG3OEh5F2rk4iKoX yXTZJPGfzsfFhxAFS8D1PLzYbiJvh2KBz9TLr5Ug7OqXo2idlqv9fS/uX+hLWKlt/fpd R/Zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8oMFGxXF6QUlJj5F31ofFC/byB4gOQFq079DGk4vXTU=; b=MSBku+2qxXt8zn+WnWLWxw0uT1m8SpuvD1Jr0daf5JYJ8qLkinLnpyfp2qc+noBMkd +itRLGR+DP5k1ozxD6jXnZ8m72G5KqbCnnUD7iZysRzBbWdl1MGt18qsPi+y/156JDR0 TqzMghGpszrqJvqD3F3cPIj903GngZU2fKoSW2ULDyCsVoMkulrMYKIFfFwmlGIop85w BCUIEwaYRQQHT62CAnvSyQCCvgG+hLHOHEWLSt+WQxzoZk5zquxocLjbxTDrEFcd9Uez RWCeMFXi9I/MVtoujtyPWQy7k23bicNKpvvM0Rd0rVJBQAhCbfPD8noOG04tlP+EkVSm Nxqw== X-Gm-Message-State: APzg51BgnKYhpP49r3lWf64mLfPR5LaKEWyWoKzJ6FYRRA/RDpTeUh3M VjmI0rHwQNtBmfrCzUwAHpE= X-Google-Smtp-Source: ANB0VdbuSB/JaEZO4HXFI+IdiQJOsLmtRkKAAAwzNcz8e2DHekyQh9V3BpF4V53XDh+4HW8SBgCNaw== X-Received: by 2002:a2e:85d5:: with SMTP id h21-v6mr7864981ljj.103.1535652329646; Thu, 30 Aug 2018 11:05:29 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id 13-v6sm1420789lfy.87.2018.08.30.11.05.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 11:05:29 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Russell King Subject: [PATCH v3 8/8] ARM: tegra: Add firmware calls required for suspend-resume Date: Thu, 30 Aug 2018 21:04:21 +0300 Message-Id: <20180830180421.6415-9-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830180421.6415-1-digetx@gmail.com> References: <20180830180421.6415-1-digetx@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_110541_781862_4DBE2DB0 X-CRM114-Status: GOOD ( 14.73 ) 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-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 In order to resume CPU from suspend via trusted Foundations firmware, the LP1/LP2 boot vectors shall be specified using the firmware calls. Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/pm.c | 7 ++++++ arch/arm/mach-tegra/reset-handler.S | 33 +++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 66c8cd63dd86..12341ffabb99 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -150,6 +151,10 @@ bool tegra_set_cpu_in_lp2(void) tegra20_cpu_set_resettable_soon(); spin_unlock(&tegra_lp2_lock); + + if (last_cpu) + call_firmware_op(prepare_idle, TF_PM_MODE_LP2); + return last_cpu; } @@ -316,6 +321,8 @@ static void tegra_suspend_enter_lp1(void) tegra_lp1_iram.start_addr, iram_save_size); *((u32 *)tegra_cpu_lp1_mask) = 1; + + call_firmware_op(prepare_idle, TF_PM_MODE_LP1); } static void tegra_suspend_exit_lp1(void) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 4973ea053bd7..0e208b2e246e 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -69,7 +69,7 @@ ENTRY(tegra_resume) mov32 r9, 0xc09 cmp r8, r9 - bne end_ca9_scu_resume + bne end_ca9_scu_l2_resume #ifdef CONFIG_HAVE_ARM_SCU /* enable SCU */ mov32 r0, TEGRA_ARM_PERIF_BASE @@ -77,14 +77,43 @@ ENTRY(tegra_resume) orr r1, r1, #1 str r1, [r0] #endif + bl tegra_resume_trusted_foundations -end_ca9_scu_resume: +#ifdef CONFIG_CACHE_L2X0 + /* L2 cache resume & re-enable */ + bleq l2c310_early_resume @ No, resume cache early +#endif +end_ca9_scu_l2_resume: mov32 r9, 0xc0f cmp r8, r9 bleq tegra_init_l2_for_a15 b cpu_resume ENDPROC(tegra_resume) + +/* + * tegra_resume_trusted_foundations + * + * Trusted Foundations firmware initialization. + * + * Doesn't return if firmware presents. + * Corrupted registers: r1, r2 + */ +ENTRY(tegra_resume_trusted_foundations) + /* Check whether Trusted Foundations firmware presents. */ + mov32 r2, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET + ldr r1, =__tegra_cpu_reset_handler_data_offset + \ + RESET_DATA(TF_PRESENT) + ldr r1, [r2, r1] + cmp r1, #0 + reteq lr + + .arch_extension sec + /* First call after suspend wakes firmware. No arguments required. */ + smc #0 + + b cpu_resume +ENDPROC(tegra_resume_trusted_foundations) #endif .align L1_CACHE_SHIFT