From patchwork Fri Feb 22 19:34:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 10826855 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 0335F922 for ; Fri, 22 Feb 2019 19:35:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8AD932C31 for ; Fri, 22 Feb 2019 19:35:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC86332C77; Fri, 22 Feb 2019 19:35:49 +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 8749732C31 for ; Fri, 22 Feb 2019 19:35:49 +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=kt62aS8QgoRLK0 elKWxXTpN+MDylMJPmsPCMaZrUDUiLpPWr5YA7KzXYuSyJqjXwMn8wvsYkZruwjVOV6CLAzmpkVLn s6Q785hzncgeNdKKz/AIug6WrqkW9XnOm4fXS5Rdjyo3iNxJmcJVN6iHvB4n6FtbpYzubLdc1VX4D aJ6mCWZAS9xok1xFxTZcAoav+fmj3U4HqH1SP4S0pay8jRyImNSS38fLPblfyMu8/oz67+8+Yr1dc kxi+hv7ukAJ/TeiwIlDxKTX9RKg7/n7JvQqwPTT/Tm/ROTD8iUKclKkHoHmQwdz60TIXvdeSyjjKl UV6w5FnubkXdeiRAKtgg==; 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 1gxGbr-0003df-S6; Fri, 22 Feb 2019 19:35:47 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gxGbg-0003PR-QM for linux-arm-kernel@lists.infradead.org; Fri, 22 Feb 2019 19:35:41 +0000 Received: by mail-pg1-x544.google.com with SMTP id h8so1057440pgp.6 for ; Fri, 22 Feb 2019 11:35:36 -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=Bc2z/mZZ2PJ4XrRMfHMO32ZStzZd+1hYC5yRGRn77t6veG2OoL5m0uLia5spAabPB+ 9JD5OA0TakMPnRtqcYTTIKd0JXiYIkAD4B63SfDNd2T9MuWwfZZLbqbmJ6wfis8L3iuY 4vIqGaONLeXz/rPRT6GxMAFPFcSm29vs+uPik97x5m/SjDIqv+KwSaSlJkxpKpGwOL+F +hy8FPTkGcfTJ2bOpn/ViCBC+uioWVxDsYjvO2sCQ9rqphXkEBK3qk58rJ6UeSEjpZdd Ls7d6rPlqNeB7KLcok6I0ujqZsIBImtAnT5i3Yr4icwCjP2ivEeYSPcXt2+b0+og+uXV bTTg== 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=oojuFhO+492tFXLCpkYD+ZZDNVVXyIYz94oJApmeEqqmQTFyGZ2uNMswY+pEnPBKe+ vONy14wFHsJjv1R0z0IJ2bIrerJzWB5J3yIqoMPT27wh1PwQjDgS59nCU4F6qbNFtIGz x5VgN+dRksSzVRH+pep6/jlLoswukbzaZrzn5jnALuvXBRks+GQUsIlKIsQ7smlgvudP 3MCfHneqlB4Xb3drGx3c6Lh05oKv7e0+chlNiO65mZma8PaksV0QQNPh9aEL815R72uh bWnBzF5uZt8GGGQz6PNMN8Z/KyS8FKPBEhZZl344VoJOGrzbAZFjYXcthlWOiUtV8wdS l6KA== X-Gm-Message-State: AHQUAuYHFxSywVrLl+9kJwg8oxB+emFjfAWcCif4fQ7j/7+8EWyDd6K1 WOrdz2tUfihd9Imyfqi/KFc= X-Google-Smtp-Source: AHgI3IYAV/BUgcnx+2e0YNF+UIlsi3IMuvr4ov+kFk3ReW9IxrOtUMWmFj+PAM2xyua2dyi4BKH8jw== X-Received: by 2002:a63:8f45:: with SMTP id r5mr5418223pgn.222.1550864136209; Fri, 22 Feb 2019 11:35:36 -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 e21sm7687190pfh.45.2019.02.22.11.35.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 11:35:35 -0800 (PST) From: Dmitry Osipenko To: Russell King , Thierry Reding , Jonathan Hunter , Robert Yang , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v6 1/7] ARM: trusted_foundations: Implement L2 cache initialization callback Date: Fri, 22 Feb 2019 22:34:20 +0300 Message-Id: <20190222193426.10747-2-digetx@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190222193426.10747-1-digetx@gmail.com> References: <20190222193426.10747-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_113537_247814_6AC130B2 X-CRM114-Status: GOOD ( 14.32 ) 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)