Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753277AbdL1JxC (ORCPT ); Thu, 28 Dec 2017 04:53:02 -0500 Received: from mail-ve1eur01on0059.outbound.protection.outlook.com ([104.47.1.59]:4672 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752894AbdL1JxB (ORCPT ); Thu, 28 Dec 2017 04:53:01 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; From: Peng Fan To: shawnguo@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, van.freenix@gmail.com, Peng Fan , Sascha Hauer , Fabio Estevam , Dong Aisheng Subject: [PATCH] ARM: imx: introduce imx_l2c310_write_sec Date: Thu, 28 Dec 2017 17:35:50 +0800 Message-Id: <1514453750-15479-1-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [123.151.195.53] X-ClientProxiedBy: HK2PR02CA0170.apcprd02.prod.outlook.com (2603:1096:201:1f::30) To VI1PR04MB3229.eurprd04.prod.outlook.com (2603:10a6:802:6::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 12dde0f1-0692-4f76-9965-08d54dd8c50e X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(48565401081)(2017052603307)(7153060);SRVR:VI1PR04MB3229; X-Microsoft-Exchange-Diagnostics: 1;VI1PR04MB3229;3:KF9lwOSDz57n8w8MjwB2ZXyvCCRVODInVuE5/pVXavm8LAGVvN4VyQDXRfiglZRqE1FhnjYB5JH3vYHQJviHeiUJYXjJQ8N8hIi5700ZG1vQ89c/gsZilp24knNCi76kirdpEOOQBHd/JK4G/STfLST6rp1/8i6t+hb79w+MST1HkDB1MJI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jc662Us2vOD/k6cxUWB8qDeokEEgH4RG2EUmlq98PL/E6jFPRa4CbIKexiARNEnVCWLKsX9OQb3KFrDMN3vbWaG05iVNcF8c+0RIXhyEShRvf7OPWbTBCqRw7PCs7dK3Dbokg2EuGpdIXwq/Y+vCHhCbUOK8WFoZGBGoALqtShkKP3grPuSWCkXT;4:iaJGxRFYIh7Zls5gIFWUqcdlto0uod1uqjK82RUEAS+rYvE7iDkt83zR6BBxCZ3BWvU9oYTbdgAR1qKswGvHLtAl4sgSo0DjpwD1QkGuKh86UGbv2kZ/S06ps/kT8IPOQxUCzXrDjQhnFOjmnIsDI6J2VUoxsVZFLOZnnLmYSU8Oo6DRf48c2ZwF9ImPLdO83hxjiXgJ1i+JupF8Dlco6IP9+pPR9EuiTZnIUAmvDL14DbY6Uwky8UvRgF98I+erUaYbEzmyORtbQqGJzW3Z2rq+N/NJGRFedTObZvKevuia7XIi5+URocqRb1tz22T7 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(944501075)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(6072148)(201708071742011);SRVR:VI1PR04MB3229;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:VI1PR04MB3229; X-Forefront-PRVS: 05352A48BE X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(39860400002)(346002)(39380400002)(376002)(366004)(396003)(199004)(189003)(106356001)(6486002)(2351001)(2361001)(105586002)(6512007)(47776003)(53936002)(97736004)(7736002)(66066001)(68736007)(39060400002)(52116002)(2906002)(51416003)(4326008)(48376002)(50466002)(305945005)(16586007)(15760500003)(316002)(54906003)(386003)(6506007)(25786009)(8936002)(8676002)(5660300001)(81156014)(6116002)(3846002)(86362001)(81166006)(16526018)(6916009)(36756003)(478600001)(50226002)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB3229;H:shlinux2.ap.freescale.net;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR04MB3229;23:1HcuKKWCfGjWIs1aq9gCXFGkBTEHCsqcv9HGZ0reG?= =?us-ascii?Q?aZnQIsGv4pDm2dVDywRMtAQ01sHkxblFcjnYm4tPOEX2mSykuJ0+nODeN63e?= =?us-ascii?Q?QmfUSrqf71yoWNHV07Xz0iQdxyBS3mqGPS9EIM+MIg1NOHr6xZPd0JkkVi2H?= =?us-ascii?Q?Me8dB8Q33+J9sE/uiXSvcXrIqbtefdgOKY9JJ6F9PYKakr4ouBWWFnrRALT2?= =?us-ascii?Q?LtC7WfIVag3Sg5Toyb5cF2w7RvtoBPdqdudvsjSNGtH8cSM1t70MWfkyoXtw?= =?us-ascii?Q?sbG6grLQfzCZ40VE8EkhdnLHJCBf4TeguTBoZ3xsq9G354UhkZeB5ihsrvew?= =?us-ascii?Q?161mBID0DPj5SVgpZkyMF0CrzMV3ZL/nV3ZoB778jNyUDG4W6O6XqjVCZ45R?= =?us-ascii?Q?LFK3XhcxxW8iIG8aLkOKLl8qut8xnyvEpnM2fBhO89JogfNutJoUYlc8z4cg?= =?us-ascii?Q?CGf1neyJvDHME8wS3j7gdarNaEEEM4+dnekZDPknwMLDIIr7ajofqXvMLdP+?= =?us-ascii?Q?0c6EI1RsdWmwvJBg6ilUTwxXwH7ItIwbXpFCtqn6VEC+BXdGK1hl8Nse2RLD?= =?us-ascii?Q?MFvpR5Au8xMOyQENV1cebUelPZtDPW8Hoe5bVpj4SetNtfMCQuO4cWujIm8c?= =?us-ascii?Q?N5dijqE5BckVhi2JhrckYevBJwYIXWX3wxW7lZ1/QcgrKzv5w8VMJT7/IHuA?= =?us-ascii?Q?xc4pd3zxuQZzp4IV2vRRT2K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9Fy2c0L14cCXguvNZBmL8=;24:kNrVpeAohlN6sEjzRnvlyyhYarw9aYJQhAJfV38mvN/WfxuDWkx1+vVqC4HCJP+2rAMnNYNTjUw3+BH+RKXdzhQ/UC22NLclhhfY0XWklbM=;7:ckS4c4uyQFgZ9DqzXDqgTAlRT7l4ub4m+Qz49Hdx6JqfNd0NgtUs6+9Jjh9N20FZQtlfdAP/MTzT9EpnTmm0de3kD2CvypqxlwknXcaFcpdI6HOl9pP2OOJM2Cp3RSX00Nl+lhtESOzoi9lGuc5zrbSYaKDREhxVm+QXSE6C6UN+0205zrbk4yrJtRYC7QQm/oITUiOG3d+xKg0cUB/Rr9uzr+halzFg94WXvs+JcP7p/4Aeb8vgtcgsg/V4cZun SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2017 09:52:52.6667 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 12dde0f1-0692-4f76-9965-08d54dd8c50e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB3229 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3077 Lines: 113 Some PL310 registers could only be wrote in secure world, so introduce imx_l2c310_write_sec to support Linux running in non-secure world. Signed-off-by: Peng Fan Cc: Shawn Guo Cc: Sascha Hauer Cc: Fabio Estevam Cc: Dong Aisheng --- arch/arm/mach-imx/system.c | 21 +++++++++++++++++++-- include/soc/imx/imx_sip_smc.h | 23 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 include/soc/imx/imx_sip_smc.h diff --git a/arch/arm/mach-imx/system.c b/arch/arm/mach-imx/system.c index c06af650e6b1..86ce9f590777 100644 --- a/arch/arm/mach-imx/system.c +++ b/arch/arm/mach-imx/system.c @@ -23,11 +23,13 @@ #include #include #include +#include #include #include #include #include +#include #include "common.h" #include "hardware.h" @@ -35,6 +37,9 @@ static void __iomem *wdog_base; static struct clk *wdog_clk; static int wcr_enable = (1 << 2); +#ifdef CONFIG_CACHE_L2X0 +static void __iomem *l2x0_base; +#endif /* * Reset the system. It is called by machine_restart(). @@ -92,9 +97,15 @@ void __init imx1_reset_init(void __iomem *base) #endif #ifdef CONFIG_CACHE_L2X0 +void imx_l2c310_write_sec(unsigned long val, unsigned int reg) +{ + struct arm_smccc_res res; + + arm_smccc_smc(IMX_SIP_SMC_L2C310, val, reg, 0, 0, 0, 0, 0, &res); +} + void __init imx_init_l2cache(void) { - void __iomem *l2x0_base; struct device_node *np; unsigned int val; @@ -102,6 +113,9 @@ void __init imx_init_l2cache(void) if (!np) return; + if (of_find_compatible_node(NULL, NULL, "linaro,optee-tz")) + outer_cache.write_sec = imx_l2c310_write_sec; + l2x0_base = of_iomap(np, 0); if (!l2x0_base) goto put_node; @@ -117,7 +131,10 @@ void __init imx_init_l2cache(void) val &= ~L310_PREFETCH_CTRL_OFFSET_MASK; val |= 15; - writel_relaxed(val, l2x0_base + L310_PREFETCH_CTRL); + if (outer_cache.write_sec) + outer_cache.write_sec(val, L310_PREFETCH_CTRL); + else + writel_relaxed(val, l2x0_base + L310_PREFETCH_CTRL); } iounmap(l2x0_base); diff --git a/include/soc/imx/imx_sip_smc.h b/include/soc/imx/imx_sip_smc.h new file mode 100644 index 000000000000..61a493278169 --- /dev/null +++ b/include/soc/imx/imx_sip_smc.h @@ -0,0 +1,23 @@ +/* + * Copyright 2017 NXP + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __IMX_SIP_SMC_H_ +#define __IMX_SIP_SMC_H_ + +#include + +#define IMX_SIP_SMC_VAL(func) ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + ARM_SMCCC_OWNER_SIP, \ + (func)) + +#define IMX_L2C310 0x1 + +#define IMX_SIP_SMC_L2C310 IMX_SIP_SMC_VAL(IMX_L2C310) + +#endif -- 2.14.1