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: 1047087 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kt62aS8Q"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Bc2z/mZZ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 445hQf4qsFz9sMp for ; Sat, 23 Feb 2019 06:35:54 +1100 (AEDT) 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 1gxGbs-0003df-Om; Fri, 22 Feb 2019 19:35:48 +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-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:544 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (digetx[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list 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+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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)