From patchwork Mon Feb 18 00:17:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817259 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 7B91314E1 for ; Mon, 18 Feb 2019 00:21:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 665672A147 for ; Mon, 18 Feb 2019 00:21:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58E0D2A14A; Mon, 18 Feb 2019 00:21:11 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 024322A147 for ; Mon, 18 Feb 2019 00:21:11 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=vDTA7fazmetm61ArX44RTlL7z3VP5ZyUw7OHwsZqaII=; b=GgoIEMEv6DMkAj 3y6fznswwpwty2+pb3LvPB5d3YzB1+ieLjK3rvCFgRZY2g1psaPqSWxEW3vmOvtF07tz2GwgXzM1S zpwvUy/PR2W1ourZp/oH6DYRnDy3i1mjGpfN4yxacpEKdnorpYge68BalmIUOl4ybDvDIlQZcGWm9 OaaQX0sPW5pXlqYdChJW4QzNmz5gvNzYIbRgXFCAEuaFqvu6rXTjviL/8SorHjW5Qo+4HJLTdxn08 zGQEUL+3rv5uLsIWhJDIX0aJ/UaA4CtRPdhqY6PhQtaJuXwldUg1BNumUC8JGxiIixvQfz6lz3anD ImMM4r5QYhVOONTpxgaA==; 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 1gvWgF-0004ae-Ku; Mon, 18 Feb 2019 00:21:07 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWfL-0002ot-4y for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:20:24 +0000 Received: by mail-pg1-x543.google.com with SMTP id r124so7526102pgr.3 for ; Sun, 17 Feb 2019 16:20:10 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=BvZ9oj3/sW8iZFxRIUh2GML421I70F1BQFHxs/lpvMg=; b=TjfT5Ardm+nWAMMGW/qXxaRrMgEVjhMs3IxlxLDThMh5A1u4aKAzu91599vKGBccIR AClzIhZOJNcFOZecAGT+EAJ1sjbXh3giEmE9DvtZB4aQ1bWgVX4YlkT6u33X84/kBus4 BGl7F6Hyv7Vwu89H9bxGaYGijfZx8xXy3i3qYszLObQgazidbdtOX33PYgnUGR0Qdl5I BtxDRfhQwUNSwFjhcc7xkp5W9zjszbhDwM/SVXrzN4XUsGuavFlNnC0V6PtrfRxo+INj m4vm+Zpytzvu6W1bRIIoPZejTIboTNq9z3A0OScm7Gl9jpa2IefBPzmo6BP7/VVCK0pt IulQ== 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:mime-version:content-transfer-encoding; bh=BvZ9oj3/sW8iZFxRIUh2GML421I70F1BQFHxs/lpvMg=; b=q96zdMoJyr/wJ9bTc1UaJA7X0K2D73KsgBBm5rPfXvddkOHk6V9EG5vmY0L6vVf+6a YiyLi7ekYJq2bbBltzenFvtGSbdfsQubRvQbxtRx3KojEPElGTqRaWqsDEMJt6KZCp6t sIW6BAac3buq1bSMTl2PzRdt4ispcZ3VQ49ao6umE+Qzo8x0cEiiGsl4lZMmxJwxGNp+ No8snMpx3QEFDoA51RTZCrxIjX+KZzwGKBGW6TS3tT42zv+ULd71ubwOLoBb4oU2sEWP 67USUbGN+tK6NugEkDyXllrBrecFB6QHaojjjscj/JzD0I8D+zlSHwEBXbYbOYv6QC2v /vyg== X-Gm-Message-State: AHQUAuYIQznQ5Isz61XmHZ5JAsz/GPhn4b4WQJO1UYhLHawrQeprGG5e dQt3QhPPhK6V5+6aTdRG29w= X-Google-Smtp-Source: AHgI3IZFxXD8vvprhu2l4e5vhlmtcR4sxejpGHTL3Fp9T2bq/p4Yol+XqQX+5E8wjDFWzQJvtQWsSw== X-Received: by 2002:a63:2a96:: with SMTP id q144mr16028847pgq.338.1550449210513; Sun, 17 Feb 2019 16:20:10 -0800 (PST) Received: from localhost.localdomain (ppp91-79-175-49.pppoe.mtu-net.ru. [91.79.175.49]) by smtp.gmail.com with ESMTPSA id s73sm31518071pfi.124.2019.02.17.16.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:20:10 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 8/8] ARM: tegra: Add firmware calls required for suspend-resume Date: Mon, 18 Feb 2019 03:17:26 +0300 Message-Id: <20190218001726.16785-9-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218001726.16785-1-digetx@gmail.com> References: <20190218001726.16785-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190217_162011_831560_D055BA44 X-CRM114-Status: GOOD ( 12.91 ) 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 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 | 14 ++++++++++++++ arch/arm/mach-tegra/reset-handler.S | 26 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 66c8cd63dd86..97bdfffc244e 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 @@ -207,6 +208,8 @@ void tegra_idle_lp2_last(void) if (trusted_foundations_registered()) outer_disable(); + call_firmware_op(prepare_idle, TF_PM_MODE_LP2); + cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); /* @@ -368,6 +371,17 @@ static int tegra_suspend_enter(suspend_state_t state) if (trusted_foundations_registered()) outer_disable(); + switch (mode) { + case TEGRA_SUSPEND_LP1: + call_firmware_op(prepare_idle, TF_PM_MODE_LP1); + break; + case TEGRA_SUSPEND_LP2: + call_firmware_op(prepare_idle, TF_PM_MODE_LP2); + break; + default: + break; + } + cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, tegra_sleep_func); /* diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index c827b185d281..24fb375e11a9 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -76,6 +77,7 @@ ENTRY(tegra_resume) orr r1, r1, #1 str r1, [r0] #endif + bl tegra_resume_trusted_foundations #ifdef CONFIG_CACHE_L2X0 /* L2 cache resume & re-enable */ @@ -88,6 +90,30 @@ end_ca9_scu_l2_resume: 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