From patchwork Sun Mar 17 22:52:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10856649 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 007321390 for ; Sun, 17 Mar 2019 22:56:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFC1329211 for ; Sun, 17 Mar 2019 22:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3FB529250; Sun, 17 Mar 2019 22:56:05 +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 5A3BE29211 for ; Sun, 17 Mar 2019 22:56:05 +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=mrmWjHEJsJRB5SXaFX5f3yp7ahMG/bAeMvZz8IH3lEA=; b=JthoxV5udI6rTC UWoMJ/NrcKNfytOjwlyVQEL+0md3dbS4TmR90J5DpnVhKd/r5kLzI2SOYKcq/8RLHwNF2m9vLsf5i eUGBWKDoNzFU96sbcnyu3e1dj6/WVeBYBI4OJVQfX0p3aUtikD4XOn+R4+Qpri+pfv9/b7poabb+x SLfe9UeNdBSUM0R2gYh40cuiiE4Pp9Q3sqzfkPIHFn1XNd4TmbOq2/07t1E+dEvcl8tGvbwVTQjGH Ww09nTAbzWCmYjurKntxanmPIYPG+x1G4dAkCshXAW275A3PZfwEd1WyKbqoOb6jcmJe1IPzhWe3n HREhvS53sGijBiDogRIA==; 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 1h5ehH-0007J0-Ql; Sun, 17 Mar 2019 22:56:03 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h5egx-0006vh-0H for linux-arm-kernel@lists.infradead.org; Sun, 17 Mar 2019 22:55:45 +0000 Received: by mail-pf1-x442.google.com with SMTP id c8so3275601pfd.10 for ; Sun, 17 Mar 2019 15:55:42 -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 :mime-version:content-transfer-encoding; bh=GW0CJWrCEGpuTDu8JaGzJeC7YDvChX9uFBrKnKEZVBA=; b=sv+rK1y5xzW9mhrWvbgSjlJEXgHP20APMLfab+9HoNTt53IOXTXU2LpTsgzocI8r38 4f6H3BvW+B9BBfLrhZorTU6EiUjuDozASo9sdNH/cvKqQjRDRZPBFzL8xBQTAlMUCXLF TiyPz5zOt/iPgfA1Onz7vR4BAdpfTDRhrs9FydZsUuR2jnUvR3AdtDd2rAsdXNXPlOV9 4D6fjxwWlAg5rBAtMoZamrpCkWaMn8kASvyBsLmgi5sfzaCf8KUkdTPwBzr7MVfj4M1v vD0hzAx3Jkt8KkkHpfeToXStUzTbbzhmP0GQBps1LFpnDJS9xFgM5Os2CmRAA8RBNiAO Wpog== 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=GW0CJWrCEGpuTDu8JaGzJeC7YDvChX9uFBrKnKEZVBA=; b=ZJY92//7Taae24G2BL9T6lQ0befJkovDihZCUtIfkiPDdslqBKmJRulaK3MY4FwpXv R2cq4ZbDX2CWMH2uwr+L6jUlq4ji3P0e/5pgEymNi4htFWJuEmgW7JN3tMH3NSjryR3h SZoLQMPjRuLBeDcvpNZUHG3HEvVrsR2ayUuLzAs3Ab1SwsMWPDtF5xs1Dtcf0OOI58kF 6P8HAun0PZ1xPhcIsfI/79lyvhbs7xl6NYfVGwl1a7NEIAzMAIAInBn4FBdVc1jg1wVA pGKLWZ0oGb+TTYudoPi2bP8xeI7mXrYlJ39TBHwbG0Knoh/lT+iB2YID79Y1WKyvQKq7 cdtQ== X-Gm-Message-State: APjAAAU4UqwjgLOuJR7GftGK6UbhMWzv0/yOBbkyEp4BfddtezAr26ts CnaREOQ9ZST61xkONcfzS8A= X-Google-Smtp-Source: APXvYqzqktU5qj7d4vKKC7/iiSYG/lgW+0X+5nLieaLzGJ8atcp2XBicOQfYf9eDAZg4LSnzcgly1Q== X-Received: by 2002:a17:902:bd87:: with SMTP id q7mr16420755pls.227.1552863342532; Sun, 17 Mar 2019 15:55:42 -0700 (PDT) Received: from localhost.localdomain (ppp94-29-37-86.pppoe.spdop.ru. [94.29.37.86]) by smtp.gmail.com with ESMTPSA id v2sm13738838pfg.118.2019.03.17.15.55.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Mar 2019 15:55:41 -0700 (PDT) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v10 2/7] ARM: trusted_foundations: Make prepare_idle call to take mode argument Date: Mon, 18 Mar 2019 01:52:05 +0300 Message-Id: <20190317225211.23091-3-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190317225211.23091-1-digetx@gmail.com> References: <20190317225211.23091-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190317_155543_260537_75213793 X-CRM114-Status: GOOD ( 15.11 ) 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 The Trusted Foundations firmware call varies depending on the required suspend-mode. Make the firmware API to take the mode argument in order to expose all of the modes to firmware user. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c | 29 ++++++++++++++++++++-- arch/arm/include/asm/firmware.h | 2 +- arch/arm/include/asm/trusted_foundations.h | 6 +++++ arch/arm/mach-tegra/cpuidle-tegra114.c | 3 ++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index d7ac05103a52..720904a43c00 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -67,9 +67,34 @@ static int tf_set_cpu_boot_addr(int cpu, unsigned long boot_addr) return 0; } -static int tf_prepare_idle(void) +static int tf_prepare_idle(unsigned long mode) { - tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1_NOFLUSH_L2, cpu_boot_addr); + switch (mode) { + case TF_PM_MODE_LP0: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S3, cpu_boot_addr); + break; + + case TF_PM_MODE_LP1: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S2, cpu_boot_addr); + break; + + case TF_PM_MODE_LP1_NO_MC_CLK: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S2_NO_MC_CLK, + cpu_boot_addr); + break; + + case TF_PM_MODE_LP2: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1, cpu_boot_addr); + break; + + case TF_PM_MODE_LP2_NOFLUSH_L2: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1_NOFLUSH_L2, + cpu_boot_addr); + break; + + default: + return -EINVAL; + } return 0; } diff --git a/arch/arm/include/asm/firmware.h b/arch/arm/include/asm/firmware.h index 34c1d96ef46d..6698272bbcbf 100644 --- a/arch/arm/include/asm/firmware.h +++ b/arch/arm/include/asm/firmware.h @@ -24,7 +24,7 @@ struct firmware_ops { /* * Inform the firmware we intend to enter CPU idle mode */ - int (*prepare_idle)(void); + int (*prepare_idle)(unsigned long mode); /* * Enters CPU idle mode */ diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h index 9e6a41e9215e..201ceb259e71 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -35,6 +35,12 @@ #include #include +#define TF_PM_MODE_LP0 0 +#define TF_PM_MODE_LP1 1 +#define TF_PM_MODE_LP1_NO_MC_CLK 2 +#define TF_PM_MODE_LP2 3 +#define TF_PM_MODE_LP2_NOFLUSH_L2 4 + struct trusted_foundations_platform_data { unsigned int version_major; unsigned int version_minor; diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c index e3fbcfedf845..3b9af4766cdf 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra114.c +++ b/arch/arm/mach-tegra/cpuidle-tegra114.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "cpuidle.h" @@ -46,7 +47,7 @@ static int tegra114_idle_power_down(struct cpuidle_device *dev, tegra_set_cpu_in_lp2(); cpu_pm_enter(); - call_firmware_op(prepare_idle); + call_firmware_op(prepare_idle, TF_PM_MODE_LP2_NOFLUSH_L2); /* Do suspend by ourselves if the firmware does not implement it */ if (call_firmware_op(do_idle, 0) == -ENOSYS)