From patchwork Sat Dec 30 12:34:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 10137717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F5A06037D for ; Sat, 30 Dec 2017 12:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86CD828C9F for ; Sat, 30 Dec 2017 12:51:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7916828CA3; Sat, 30 Dec 2017 12:51:44 +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=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 8F5BA28C9F for ; Sat, 30 Dec 2017 12:51:43 +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: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:In-Reply-To:References: List-Owner; bh=qgT7X9IJRrNYmEP4bfNSs9n3ML7Apb5SK4G2bev2Ui4=; b=fjHi+mjGsthV6w aQpNNtPULNBCcvQiCD/gQdbHy7oe56knuPf7GEM2W5Jp9Y+FPP4noJ9uCClDoDxEvZaFFA+TE5O2M vsbd8Y7hXla++Zy4aX/W+ifdWhUUNSuMg5EWv5x6jWqTLmfU4mCbHSwyGNTmg5yfVxQdksDCiFaVZ HIrrvzHc1bJDgL1AJ0kBJcagZN/bnXZu1Sw0z+1+jT8PLiCEgv61qWS/bkLmh1EZ/8rZD8kQs8Llv N+BPpb4Z2Rn5KYwVihuQ4VcqxZc3uxZI0EDtbFaSvei8cOHEpxcm+tu6QCirXWEVETOv9tPJYeyCP lqB0v1B+nyApWEajQF8w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eVGby-0005ro-OI; Sat, 30 Dec 2017 12:51:38 +0000 Received: from mail-eopbgr60050.outbound.protection.outlook.com ([40.107.6.50] helo=EUR01-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eVGbt-0005q1-8z for linux-arm-kernel@lists.infradead.org; Sat, 30 Dec 2017 12:51:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Ewm1IhPLgvYKMAym6bOLSkRsWhuUOhc11Yv1KDe4ZmU=; b=H6beKhIhnVxgJYy8G0193uuCbKi8T668DtBD0qW28C0FlwEpbP5axVbTqsZSZXfuSP783ITHMdmNMY0T589IpKl+3tNCUBrUj3ANt0P5mH4UH/yHuCN9vLmxLwIFyk0cl8mDdG8WUOIMI0Zo3wdDpXgTCDgMo8GLIUlHZE88LsM= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; Received: from shlinux2.ap.freescale.net (123.151.195.1) by HE1PR04MB3227.eurprd04.prod.outlook.com (2603:10a6:7:1b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Sat, 30 Dec 2017 12:51:11 +0000 From: Peng Fan To: shawnguo@kernel.org Subject: [PATCH V2] ARM: imx: introduce imx_l2c310_write_sec Date: Sat, 30 Dec 2017 20:34:03 +0800 Message-Id: <1514637243-20111-1-git-send-email-peng.fan@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [123.151.195.1] X-ClientProxiedBy: HK2PR0302CA0011.apcprd03.prod.outlook.com (2603:1096:202::21) To HE1PR04MB3227.eurprd04.prod.outlook.com (2603:10a6:7:1b::27) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e9bb6d3-83d9-491f-f657-08d54f840307 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:HE1PR04MB3227; X-Microsoft-Exchange-Diagnostics: 1; HE1PR04MB3227; 3:/3Ntzj3KNHkLjY+993rpiIszGPZ30GcHLTkwWpVP7Cf39WGl8dLZK9eDOjIhjjGYpSWQC6QTNfpjxNGgkn/mAUlYm+JRi7TSlvOJ8gBTUj1HI240nEBuBEM2f3lRn/6DyaTr8O1hfK7Cv3IewGPFGIQBCzgzNggcQGxGUhqBKbbyzCsCgvoQMqnlYDpKvyqsP4LQWZaxMWDetcuGWq3yNyooMQAN4WtvgH0LIvNYkzcZ1Fbx6v3Es+CL/P2SSQYK; 25:qmsTuiFwGEJ5qJ3RRysc1OP2awC+hHwy97mCeqksczqCl3EcIWHqWD54KXJCZ7sWlOu335QgeAHd1NE5XxDvtdv1o0v42m4ODY4sq8Mk4Iywkx54TMqVOeuSiN2NjXIqa9q9gDg1joODYkAE6YtFHrAU3yW5PAgE3YIeSxGULjbc9KjyYsK+Faz3eFtZRSZ3/j2RZum2zkxAUsb1BXdUHFyuzUmGq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sRTtuDttlEjuC7HMT1VdQ/9Ribg2b6TAnxuzcm8eE040A8ivAGfzQrseQSiX0wlIjx5cdV5YcwJG8i6Ho2ceo3iyXtj1A7RDIagfnZDj7c3Uc5l5w4y3ZGv47UaElHpz7DO3+EgjOLCPlLs80zOuWvJJrT992d9F3RwV2QDZfntkya33zsg3MUjngmOJ/ytTJu262Hb X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3231023)(944501075)(3002001)(10201501046)(93006095)(93001095)(6055026)(6041268)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:HE1PR04MB3227; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR04MB3227; X-Forefront-PRVS: 05373A0663 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39380400002)(376002)(39860400002)(346002)(366004)(396003)(189003)(199004)(25786009)(66066001)(6666003)(316002)(478600001)(5660300001)(2906002)(47776003)(4326008)(6116002)(50466002)(16526018)(3846002)(48376002)(15760500003)(97736004)(36756003)(51416003)(59450400001)(2361001)(7736002)(386003)(81156014)(106356001)(52116002)(81166006)(8676002)(54906003)(305945005)(6916009)(105586002)(39060400002)(575784001)(68736007)(8936002)(6486002)(2351001)(6506007)(50226002)(86362001)(16586007)(53936002)(6512007); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR04MB3227; H:shlinux2.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR04MB3227; 23:CdKXmtmBcIQJK28x50DDLZAXDekEVUnocMelg++a3?= =?us-ascii?Q?AW4TZhs1D8wPx6NmAO1uv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PM/oPE+CG6JUz3XqrS8LqokW1doxVL0CXCXu0fFazlE4LG7UGsXPHMAvm53zGbLcCA89YypVQbYEbbN5byJS3Xw/9EQNve2XclvCLZt7X2Gn06ml60aqQ3u+7NScRY1QvPIbv2mrBIj9FDwxtQb/daB16687ZLsEasKVjdt7vT0WGjaTjkOs/u0cwkWAAY0S/smErqbfegEVqWBG/QCs9rR5 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Dec 2017 12:51:11.4173 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3e9bb6d3-83d9-491f-f657-08d54f840307 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR04MB3227 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171230_045133_872119_D19B3C8E X-CRM114-Status: GOOD ( 13.71 ) 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: Dong Aisheng , Peng Fan , linux-kernel@vger.kernel.org, Fabio Estevam , Sascha Hauer , van.freenix@gmail.com, 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 Some PL310 registers could only be wrote in secure world, so introduce imx_l2c310_write_sec to support Linux running in non-secure world configure PL310. Signed-off-by: Peng Fan Cc: Shawn Guo Cc: Sascha Hauer Cc: Fabio Estevam Cc: Dong Aisheng --- V2: Use SPDX Tag Use CONFIG_HAVE_ARM_SMCCC to fix build error for armv5. Add IS_ENABLED(CONFIG_OPTEE) check when assigning write_sec arch/arm/mach-imx/system.c | 27 ++++++++++++++++++++++++++- include/soc/imx/imx_sip_smc.h | 21 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) 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..2c27e52d8c7d 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" @@ -92,6 +94,22 @@ void __init imx1_reset_init(void __iomem *base) #endif #ifdef CONFIG_CACHE_L2X0 +#ifdef CONFIG_HAVE_ARM_SMCCC +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); + + if (res.a0 != 0) + pr_err("Failed to write l2c310 0x%x: 0x%lx\n", reg, res.a0); +} +#else +void imx_l2c310_write_sec(unsigned long val, unsigned int reg) +{ +} +#endif + void __init imx_init_l2cache(void) { void __iomem *l2x0_base; @@ -102,6 +120,10 @@ void __init imx_init_l2cache(void) if (!np) return; + if (IS_ENABLED(CONFIG_OPTEE) && + 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 +139,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..c35ae69e0d2f --- /dev/null +++ b/include/soc/imx/imx_sip_smc.h @@ -0,0 +1,21 @@ +/* + * Copyright 2017 NXP + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#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