From patchwork Fri Feb 22 17:59: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: 10826769 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 15ECC1575 for ; Fri, 22 Feb 2019 18:05:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0831E32109 for ; Fri, 22 Feb 2019 18:05:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE694329C3; Fri, 22 Feb 2019 18:05:09 +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 7DDAE3283B for ; Fri, 22 Feb 2019 18:05:09 +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=t49lm/InClJYQG aNP5o7sC37xOdIYDDnMyKEqt4kbjsB3y3KhRNkB+1mSKS3QcKMJw4DEMfrihSFZTTKPwV/iHOc+QS 1aAGiArcRF+4ftM7l/+vhgdQfWoO4Xut5V631ogP/5QiNyPYmH6rYk+xr7tbVhVMmIns5gehizAFp YR7GQPTysGuRVd8EHIbhExfjDnwHbl1JfBo4Dlfm+1XkkXkqEhAMy9FvVVmsywjYnnSA5VWqHhgoK GvmrMIxGc/WDCLYCyuvi1/8OYI3WBz2vCh6tlBLbdjltu0K6xfwc3cplkD35uELev5qlbekqL9WEC AJpwVtYW3v47+uisUWcQ==; 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 1gxFBy-0007EW-MT; Fri, 22 Feb 2019 18:04:58 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gxFBY-0006jH-Nq for linux-arm-kernel@lists.infradead.org; Fri, 22 Feb 2019 18:04:35 +0000 Received: by mail-lf1-x144.google.com with SMTP id j1so2374819lfb.10 for ; Fri, 22 Feb 2019 10:04:32 -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=cZbgRusd72a50mwccguM+uOvw3Sh1jFcugmBmVOvqcHFb5L4VIL5dGYibZUnzArU/G QD/ZyCmle0YjHRq1HeIaWbcSLLin0BaAcMmdnXXNWpvsJTd2/ItBw1KbbSnzdSX6Ori5 e3uLRt9+xrocHbXJhDSyo58n0KWO8DPqi0Jf/PA9HMQ6+VOZlRzcC/syIuEAR7JlHI4M n/ADzEfAX7CfgUmJ2w1KQO2aQ2L9LwLtU6eTvm0VhfP9OAwjz+srAHvq7LNY8i4AeE15 E8KftaYB0MvtbW9WEzHDR1ogWYXhN52F1G8bbGYgQ3GIjoPdOq98Fs7cgFplR43hV9ET Xyeg== 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=hhDzZfBfjTN9jqO/Um8qTedSHYHj5O00rbEpsVrY0iMdNrc2zr04QGUhiTHVncH/aj pQ4rdWYGLf9CZPboGao18I/9cL0ntYyIyyjr6lj1DoIDAk4ykw9NLfOwiIwOL4Ix/5r2 ZVhi96KS23cntUmpxWw9tk9IyR8Rzcw9XM/5SM3LrRmuADlUHzzsGwOVVHoEB5vNdmGB SEbKWYb4b9t89F8wjId/DIrmjG29CJ1FrZNoedhY84oEWzYgSZ+0yufI/2K9Hn2lhclC 7+t5i4p84VMcHc32f7qFGX9qJqICvzet2MO1BLNVn8QEk2SEhO81HAgKyXFWBi9m/vNP WPdg== X-Gm-Message-State: AHQUAuYky3TvvaeOeyNrShMsSJiM3F1CGqXnhPs4F29AZyuY5WZ988KK RCizgkev5fbIW6BdScVE8qU= X-Google-Smtp-Source: AHgI3IYnQ6oD50qOsv9TnBC67tgizIQXZFjPCspSSkQrz6HVU+af+EDGWwunpKr/XgULKo3ALiXkaA== X-Received: by 2002:a19:ae0b:: with SMTP id f11mr3399373lfc.104.1550858670524; Fri, 22 Feb 2019 10:04:30 -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 j12sm721202lfg.47.2019.02.22.10.04.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 10:04:29 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v5 1/8] ARM: trusted_foundations: Implement L2 cache initialization callback Date: Fri, 22 Feb 2019 20:59:19 +0300 Message-Id: <20190222175926.23366-2-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222175926.23366-1-digetx@gmail.com> References: <20190222175926.23366-1-digetx@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190222_100432_770702_48E9A128 X-CRM114-Status: GOOD ( 14.74 ) 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)