From patchwork Mon Feb 18 00:17:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10817247 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 5B1E51399 for ; Mon, 18 Feb 2019 00:19:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4663229EF4 for ; Mon, 18 Feb 2019 00:19:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3669E29EFE; Mon, 18 Feb 2019 00:19:55 +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 8A9C929EF4 for ; Mon, 18 Feb 2019 00:19:54 +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=FatyJJmGQZO1i9dvN+dnWT3eWFTgH755QezZJrlCb+Y=; b=j8O+e6+ZxY/Tg8 geCkVC1Y3Z9ek4WazCPxdfSbClhRPU0OkGWrWICiGb+CqFJa4cZAOPeWiQQBv2JUwBEwMUYuQK+u4 j4usmLqHC7hNqIHpSPdFytYhwjU+bMuvpDvbbA5ghwPfj0XlJx/Gajc1DlndynmdqZ9ExPr/f+3S7 73biuOvWD9RSFNnTushPi+bGzCkzc3g8YXvFQaC6R/A+aOeYeFvKJ4uFEdH8HuGqZLuqYOFm4+aML cAiAxE3tA0vHbiHilDiucirIowebIdF3snulUGO14j08E4fxNBN4X0VcpTqhZQhfc/nTC+egx9o7c ZC630+KQJOcQtrKntzxw==; 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 1gvWey-0001oH-1S; Mon, 18 Feb 2019 00:19:48 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gvWec-0001Iu-LJ for linux-arm-kernel@lists.infradead.org; Mon, 18 Feb 2019 00:19:28 +0000 Received: by mail-pl1-x642.google.com with SMTP id r14so7805758pls.12 for ; Sun, 17 Feb 2019 16:19:26 -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=Ef/pjs0sC4GxqdxxxUgy0sbHhpRnX1Oqj7kTNWdGqgw=; b=c8/B3ioT16kwbIY57ldLRWsLeuksRs6DL7eObvDSD7CIYQDr4mo1jA7eC5a5IYos3J CK0e+wFmVeDzvYhZK7uh6rbtvbTJacNO7x6DTfNaKUWFNTAfPGbgM0t53hhtwG7ZMy/G 46RNrn08ANjrWs4C5f7snzDtFGMG9Wo9mJnuUCWv87EDlD3EjDquDVKR9+z9I+ONElHP eoO1lrEja2TA4omz13wup+lnnHi5QYNoZjxOw53v35otFUdlidKkpuBmS4RdcDLQDspA gMms3I5BrWgB0rEwsahmHQu/TKGsNqIa/YtFVVMPAO9mwXQOL5fWzdjW2qXXybvyfh0D 9EKg== 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=Ef/pjs0sC4GxqdxxxUgy0sbHhpRnX1Oqj7kTNWdGqgw=; b=NtmZvZen3QXzueIo7IiFyDXrSj19Dq/w33iHkMrt7nUgj/gzl3qoFbiBshmQX3K2y6 r7T9pDLCwLKnAc9fvoTQG7l/fS1Pshddui4r0+NvCHMwPddP3BqpFPM2GTnM7CuKdR81 +9Tf5ySalV3/+W7EotKMndzLKlOn0xnq1rpkpYB+AavTq4pj2AjNU/deDyiKQps680T+ wCo0OuWyE00w3RiZ/O2MkNcXvvjuB5pT27GCDc4paLEESUJAGgkLA9kU7B0RcLrB+Bg4 4dukkSTht9LyXrbkimkrfmloMkG4B+aF++5tWBR87GIwVmP/soa/ZQzzbzeTN8zacCMp 3E8Q== X-Gm-Message-State: AHQUAuagO6W1F3ZAN2HPUpeizpyYNRaIYfNa5kGwgF6x1oazcwOX9otM DIAQTUVY0VaKE+x8GA1glAw= X-Google-Smtp-Source: AHgI3IavcXNoo+tvv02/VjCX7nswKHG9gUmWMgJhu/m3mD9L83zn/gjNjqRlZOm/3F0YEj2sNtbjDw== X-Received: by 2002:a17:902:29ab:: with SMTP id h40mr22405596plb.238.1550449166237; Sun, 17 Feb 2019 16:19:26 -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.19.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Feb 2019 16:19:25 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v4 1/8] ARM: trusted_foundations: Implement L2 cache initialization callback Date: Mon, 18 Feb 2019 03:17:19 +0300 Message-Id: <20190218001726.16785-2-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_161926_700443_5CE601E0 X-CRM114-Status: GOOD ( 14.93 ) 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 Implement L2 cache initialization firmware callback that should be invoked early during boot in order to set up the required outer cache driver's callbacks. Partially based on work done by Michał Mirosław [1]. [1] https://www.spinics.net/lists/arm-kernel/msg594765.html Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index 689e6565abfc..3bf61a5933b9 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -18,8 +18,15 @@ #include #include #include +#include +#include #include +#define TF_CACHE_MAINT 0xfffff100 + +#define TF_CACHE_ENABLE 1 +#define TF_CACHE_DISABLE 2 + #define TF_SET_CPU_BOOT_ADDR_SMC 0xfffff200 #define TF_CPU_PM 0xfffffffc @@ -67,9 +74,48 @@ static int tf_prepare_idle(void) return 0; } +#ifdef CONFIG_CACHE_L2X0 +static void tf_cache_write_sec(unsigned long val, unsigned int reg) +{ + static u32 l2x0_way_mask = 0xff; + static u32 l2x0_aux_ctrl = 0; + + switch (reg) { + case L2X0_AUX_CTRL: + l2x0_aux_ctrl = val; + + if (l2x0_aux_ctrl & BIT(16)) + l2x0_way_mask = 0xffff; + break; + + case L2X0_CTRL: + if (val == L2X0_CTRL_EN) + tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_ENABLE, + l2x0_aux_ctrl); + else + tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_DISABLE, + l2x0_way_mask); + break; + + default: + break; + } +} + +static int tf_init_cache(void) +{ + outer_cache.write_sec = tf_cache_write_sec; + + return 0; +} +#endif /* CONFIG_CACHE_L2X0 */ + static const struct firmware_ops trusted_foundations_ops = { .set_cpu_boot_addr = tf_set_cpu_boot_addr, .prepare_idle = tf_prepare_idle, +#ifdef CONFIG_CACHE_L2X0 + .l2x0_init = tf_init_cache, +#endif }; void register_trusted_foundations(struct trusted_foundations_platform_data *pd)