From patchwork Tue Nov 10 14:12:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Franck Lenormand (OSS)" X-Patchwork-Id: 11894393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41261C55ABD for ; Tue, 10 Nov 2020 14:13:03 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF489207D3 for ; Tue, 10 Nov 2020 14:13:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zn2A5AxH"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="emBVrNrM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF489207D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=SL3GdhmUI9kDj3H/qTCeH1q7COeX4OE3D+seZBsXPaw=; b=zn2A5AxHczeKCrh/MAWzcUeCD EjbpDMu310Iy9xJZhgOJx+ARJB0RqZKO5ivheUEVWNv6nPw0Hu7Qhh7e35k7u4RqUhxUGZqDPgheE p3+Tz88qwGl6et5Qe+iUKW2BADvv90OOWHRrD4bCJkwIMKLa0RM8vbw4Z/wrykRUW06ewpOSEX+m7 yxKcQ4DJyZ0uN98tTbXgTEdh1hkZNpEyCRWH/cByhLRSsY0MKJFLUnvQcdYWWMXQeIeA1vZgrrgrt 8cbWfL3iETzi3VST2bwFFwK6UVXXRtpI37uHQxjRlgfw/HtLN42htB7uezj9GPrF8PXMjmFM9YOsj KjpqESqFA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUNt-0007Ch-8T; Tue, 10 Nov 2020 14:12:33 +0000 Received: from mail-am6eur05on2057.outbound.protection.outlook.com ([40.107.22.57] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUNo-0007Ae-55 for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 14:12:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dm5Ff5FT4Cs6XUuckf+gUwY1pPpY5MXht3l/LHLEA4S2jw7TI5d6rDffyDXmi2k9qbps+tVSC6yy/K180JAiS6CewTKl2DXelCxDO3/a9hjBfcImH77tze8KD2K+oF7dzwUZcWHlFQp9cnB9DmxaUvqSXoB5IFd9jjPQfDYNk/f5tTOoNccN2jq8rbEz88svdGmObi2iaDVXr1hhW05tioSRVjyKCqiHTxWo3512PI1K9vUs6qHElgLSES3J2F/j0GrnCcVz0qXrP+elA8n7PRp1/WF2XGdTigGAeG85NXguOh73kG9ahY6Xri8dQvgV1pGI+UsIiR/4GO2+NsaL2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1HDvPh7V5Nw5tvT43AEsMu4TE4sDdvPg89a7EFM6B5U=; b=PS+UT9Y/Rf6ZReuF080b16sx0qO6UAUcJT6bxXO1XCZkIJO0il7EiLndfFmXe0yxgoJv93J9EIVXoGk43rgO4ooYSbh9zxVmGxw6CDyGr8uZ3DrFEuN3GhB9wJgNSRoDhnbVKe1TDOE8Ytx7tMqCrdKUkV7hanvlXJcjkhvORe7pFC25Nsz9xmB4HTf9vTsSpy1rSuzdtHjz1AWWJsXRGISYzni3gt9INBEMgZpx5l/y/o6J2/NAflqtPKT5+l0T95OPB9Yng32gb02Flhlp5jn9YMho2yD5ntsc7f2rgN8yu/q3dua8X1lEbzYYHa7UIRQugz0gBH2qPvXkOh87fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1HDvPh7V5Nw5tvT43AEsMu4TE4sDdvPg89a7EFM6B5U=; b=emBVrNrMa+PhYfPnpN4TaJArVIR+YPG4FWf6K4DGJsE4oze4HJJLR/vmIP3EfnZTqGYORexrZht1lTDpNBuJi+f52YJdikzj6DPjqymqarz0iyMmitagu8T0mmMIMS3UHTCeVPp95PaCSt4MFNBBNp395BMalrnNAL00h3R4cQc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) by AM0PR04MB4931.eurprd04.prod.outlook.com (2603:10a6:208:c1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Tue, 10 Nov 2020 14:12:20 +0000 Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5]) by AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5%8]) with mapi id 15.20.3541.025; Tue, 10 Nov 2020 14:12:20 +0000 From: franck.lenormand@oss.nxp.com To: shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Subject: [PATCH V3 1/5] firmware: imx: scu-seco: Add Secure Controller APIS Date: Tue, 10 Nov 2020 15:12:10 +0100 Message-Id: <1605017534-87305-2-git-send-email-franck.lenormand@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> References: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) To AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from SOPDPUATS05.ea.freescale.net (81.1.10.98) by AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3541.21 via Frontend Transport; Tue, 10 Nov 2020 14:12:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f25e1aa5-e912-4630-14c8-08d88582a32b X-MS-TrafficTypeDiagnostic: AM0PR04MB4931: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:176; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YbYsaL1jgIckmUKTbmuzwzd6nu8ylycgAzhlvE424tSNgC8MnSpKgc5QMQRptRUwfhb+1jAjSjCOLVB4t2pD8whFYfcQbUOTvv0HGammeCFD0hS39uK2lpvTubfRf5id6VpsJcYmpHhgalS/AUjycwEWfgdDymkWnP/Xj3XQhUdyV7BvO2PiopbrIBmDL7KwfQqJUXxHBbG6v48FEnJ7+PIeFR8q+vlExhaRqmiZa1mg3qxa9GlgHpwJ0P9MbkUSWY+i0awRm0YVf+hcu2XdUt/xT/0A4H1W/MxArfOT6Ub1VCxuisp4NWVXHGgt1veHjg5k50a0zeaJA4uDAwjcTA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR0401MB2401.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(498600001)(2906002)(2616005)(16526019)(8676002)(9686003)(186003)(66556008)(66946007)(5660300002)(6486002)(30864003)(6506007)(52116002)(26005)(956004)(6666004)(83380400001)(6512007)(86362001)(66476007)(4326008)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: s8NTP6djR7DNvRT16Y+2KrW3YQbZ5cu6oxdrkNdVzPoDphxj3NAzdbquom3PNg2zEbTdE3oP9wGIDvVXQRSG4yMr+6qo619HjIDl0N1b8HHPY7KjqSgwnRCuC4gmzMSexKvbAqmH1EQB0tl57GJpTIIHfDinNFWfHjLqKPK/nfcaEp0C0ZdzpC0kvCYMiAbTNevrZ+1ZTL15Si5g3rgnfCiuhKiRB+IB+tN2xqL8z0zY0V04BMTil90EqtM2Ncf+tp1BR3UqHYSrsg4h9D3ubCEJf9OKDCNE4oetQCPPDFeet9j8+mcFZqw4lli0zk9mx7iiK5HIwhW45fm3IxfHX2HEb5fcechGC4v2lZgdR4bujJcMPSJjdWHgVWF9vfrafGdA4BQ7LtmcLu7iPoKa8NPzE7aln9KKKW52RUVshxwf7CSVSP8jgwg+0a27TomljznP5eIiLEB4kMFzJ/iPwZHzGQtwkHkOOgroOUmwZLUYuTAyaMLo3vVC28d57ZqJBKb7FJ9d9XxingHTkwm1KMUsHJ6mFtST0cPe0JpBmOhkyVLv/3TH14ZQB78/YzT2WR+FIeL9IQz3H1eiCZtlqG3/zAGPM1JSsW/CdtmKRmO5UxmA5l0vEdQg9Pb0tXXTtk0/8Mfgg0ee73uRvkTbgg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f25e1aa5-e912-4630-14c8-08d88582a32b X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2401.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2020 14:12:20.6616 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5wsN6gnKomA27mKzsXzYB6WzA1/g9Z1pTsNvxDHFabNJUrptTtqOE0GjZytQ0N4wR0jcBJAXihXVNrBrCAJL+KMsK7yL8FMmd9S7fPL+j60= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4931 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_091228_318601_26D5E7E6 X-CRM114-Status: GOOD ( 26.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aisheng.dong@nxp.com, peng.fan@nxp.com, leonard.crestez@nxp.com, abel.vesa@nxp.com, Anson.Huang@nxp.com, linux-kernel@vger.kernel.org, linux@rempel-privat.de, linux-imx@nxp.com, kernel@pengutronix.de, qiangqing.zhang@nxp.com, franck.lenormand@oss.nxp.com, daniel.baluta@nxp.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Franck LENORMAND This patch adds the APIs: - imx_sc_seco_build_info: get commit and sha of SECO - imx_sc_seco_secvio_enable: enable SNVS IRQ handling - imx_sc_seco_secvio_config: configure SNVS register - imx_sc_seco_secvio_dgo_config: configure SNVS DGO register Signed-off-by: Franck LENORMAND Reviewed-by: Daniel Baluta --- drivers/firmware/imx/Makefile | 2 +- drivers/firmware/imx/imx-scu.c | 8 +- drivers/firmware/imx/seco.c | 253 ++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/ipc.h | 1 + include/linux/firmware/imx/sci.h | 1 + include/linux/firmware/imx/svc/seco.h | 73 ++++++++++ 6 files changed, 334 insertions(+), 4 deletions(-) create mode 100644 drivers/firmware/imx/seco.c create mode 100644 include/linux/firmware/imx/svc/seco.h diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index b76acba..f23e2b0 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_IMX_DSP) += imx-dsp.o -obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o +obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o seco.o obj-$(CONFIG_IMX_SCU_PD) += scu-pd.o diff --git a/drivers/firmware/imx/imx-scu.c b/drivers/firmware/imx/imx-scu.c index dca79ca..bf768d2 100644 --- a/drivers/firmware/imx/imx-scu.c +++ b/drivers/firmware/imx/imx-scu.c @@ -241,9 +241,11 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, bool have_resp) * APIs are defined as void function in SCU firmware, so they * should be treated as return success always. */ - if ((saved_svc == IMX_SC_RPC_SVC_MISC) && - (saved_func == IMX_SC_MISC_FUNC_UNIQUE_ID || - saved_func == IMX_SC_MISC_FUNC_GET_BUTTON_STATUS)) + if ((saved_svc == IMX_SC_RPC_SVC_MISC && + (saved_func == IMX_SC_MISC_FUNC_UNIQUE_ID || + saved_func == IMX_SC_MISC_FUNC_GET_BUTTON_STATUS)) || + (saved_svc == IMX_SC_RPC_SVC_SECO && + (saved_func == IMX_SC_SECO_FUNC_BUILD_INFO))) ret = 0; } diff --git a/drivers/firmware/imx/seco.c b/drivers/firmware/imx/seco.c new file mode 100644 index 0000000..fd11bd4 --- /dev/null +++ b/drivers/firmware/imx/seco.c @@ -0,0 +1,253 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2020 NXP + * + * File containing client-side RPC functions for the SECO service. These + * functions are ported to clients that communicate to the SC. + */ + +#include + +struct imx_sc_msg_seco_get_build_id { + struct imx_sc_rpc_msg hdr; + u32 version; + u32 commit; +}; + +/** + * imx_sc_seco_build_info() - Get version and commit ID of the SECO + * + * @ipc: IPC handle + * @version: Version of the SECO + * @commit: Commit ID of the SECO + * + * @return Returns 0 for success and < 0 for errors + */ +int imx_sc_seco_build_info(struct imx_sc_ipc *ipc, uint32_t *version, + uint32_t *commit) +{ + int ret; + struct imx_sc_msg_seco_get_build_id msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_SECO; + hdr->func = IMX_SC_SECO_FUNC_BUILD_INFO; + hdr->size = 1; + + ret = imx_scu_call_rpc(ipc, &msg, true); + if (ret) + return ret; + + if (version) + *version = msg.version; + if (commit) + *commit = msg.commit; + + return 0; +} +EXPORT_SYMBOL(imx_sc_seco_build_info); + +/** + * imx_sc_seco_secvio_enable() - Enable the processing of secvio IRQ from the + * SNVS by the SECO + * + * @ipc: IPC handle + * + * @return Returns 0 for success and < 0 for errors + */ +int imx_sc_seco_secvio_enable(struct imx_sc_ipc *ipc) +{ + struct imx_sc_rpc_msg msg; + int ret; + + msg.ver = IMX_SC_RPC_VERSION; + msg.svc = IMX_SC_RPC_SVC_SECO; + msg.func = IMX_SC_SECO_FUNC_SECVIO_ENABLE; + msg.size = 1; + + ret = imx_scu_call_rpc(ipc, &msg, true); + if (ret) + return ret; + + return 0; +} +EXPORT_SYMBOL(imx_sc_seco_secvio_enable); + +struct imx_sc_msg_seco_config { + struct imx_sc_rpc_msg hdr; + union { + struct req_seco_config { + u32 data0; + u32 data1; + u32 data2; + u32 data3; + u32 data4; + u8 id; + u8 access; + u8 size; + } __packed __aligned(4) req; + struct resp_seco_config { + u32 data0; + u32 data1; + u32 data2; + u32 data3; + u32 data4; + } rsp; + } u; + +}; + +/** + * imx_sc_seco_secvio_config() - Configure a set of SNVS registers for secure + * violation + * + * Some registers are extended by others registers, they configure the same + * kind of behavior, it constitutes a set + * + * @ipc: IPC handle + * @id: ID of the register, ie the offset of the first register of the set + * @access: Write (1) or Read (0) the registers + * @data0: Data for the first register + * @data1: Data for the second register + * @data2: Data for the third register + * @data3: Data for the fourth register + * @data4: Data for the fifth register + * @size: Number of register to configure + * + * @return Returns 0 for success and < 0 for errors + */ +int imx_sc_seco_secvio_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data0, u32 *data1, u32 *data2, u32 *data3, + u32 *data4, u8 size) +{ + struct imx_sc_msg_seco_config msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + int ret; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_SECO; + hdr->func = IMX_SC_SECO_FUNC_SECVIO_CONFIG; + hdr->size = 7; + + /* Check the pointers on data are valid and set it if doing a write */ + switch (size) { + case 5: + if (!data4) + return -EINVAL; + if (access) + msg.u.req.data4 = *data4; + fallthrough; + case 4: + if (!data3) + return -EINVAL; + if (access) + msg.u.req.data3 = *data3; + fallthrough; + case 3: + if (!data2) + return -EINVAL; + if (access) + msg.u.req.data2 = *data2; + fallthrough; + case 2: + if (!data1) + return -EINVAL; + if (access) + msg.u.req.data1 = *data1; + fallthrough; + case 1: + if (!data0) + return -EINVAL; + if (access) + msg.u.req.data0 = *data0; + break; + default: + return -EINVAL; + } + + msg.u.req.id = id; + msg.u.req.access = access; + msg.u.req.size = size; + + ret = imx_scu_call_rpc(ipc, &msg, true); + if (ret) + return ret; + + /* Pointers already checked so we just copy the data if reading */ + if (!access) + switch (size) { + case 5: + *data4 = msg.u.rsp.data4; + fallthrough; + case 4: + *data3 = msg.u.rsp.data3; + fallthrough; + case 3: + *data2 = msg.u.rsp.data2; + fallthrough; + case 2: + *data1 = msg.u.rsp.data1; + fallthrough; + case 1: + *data0 = msg.u.rsp.data0; + } + + return 0; +} +EXPORT_SYMBOL(imx_sc_seco_secvio_config); + +struct imx_sc_msg_seco_dgo_config { + struct imx_sc_rpc_msg hdr; + union { + struct req_seco_dgo_config { + u32 data; + u8 id; + u8 access; + } __packed __aligned(4) req; + struct resp_seco_dgo_config { + u32 data; + } rsp; + } u; +}; + +/** + * imx_sc_seco_secvio_dgo_config() - Configure the DGO module + * + * @ipc: IPC handle + * @id: ID of the register, ie the offset of the register + * @access: Write (1) or Read (0) the registers + * @data: Data for the register + * + * @return Returns 0 for success and < 0 for errors + */ +int imx_sc_seco_secvio_dgo_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data) +{ + struct imx_sc_msg_seco_dgo_config msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + int ret; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_SECO; + hdr->func = IMX_SC_SECO_FUNC_SECVIO_DGO_CONFIG; + hdr->size = 3; + + if (!data) + return -EINVAL; + if (access) + msg.u.req.data = *data; + + msg.u.req.access = access; + msg.u.req.id = id; + + ret = imx_scu_call_rpc(ipc, &msg, true); + if (ret) + return ret; + + if (!access && data) + *data = msg.u.rsp.data; + + return 0; +} +EXPORT_SYMBOL(imx_sc_seco_secvio_dgo_config); diff --git a/include/linux/firmware/imx/ipc.h b/include/linux/firmware/imx/ipc.h index 89105743..6924359 100644 --- a/include/linux/firmware/imx/ipc.h +++ b/include/linux/firmware/imx/ipc.h @@ -25,6 +25,7 @@ enum imx_sc_rpc_svc { IMX_SC_RPC_SVC_PAD = 6, IMX_SC_RPC_SVC_MISC = 7, IMX_SC_RPC_SVC_IRQ = 8, + IMX_SC_RPC_SVC_SECO = 9, }; struct imx_sc_rpc_msg { diff --git a/include/linux/firmware/imx/sci.h b/include/linux/firmware/imx/sci.h index 22c7657..914dce1 100644 --- a/include/linux/firmware/imx/sci.h +++ b/include/linux/firmware/imx/sci.h @@ -15,6 +15,7 @@ #include #include #include +#include int imx_scu_enable_general_irq_channel(struct device *dev); int imx_scu_irq_register_notifier(struct notifier_block *nb); diff --git a/include/linux/firmware/imx/svc/seco.h b/include/linux/firmware/imx/svc/seco.h new file mode 100644 index 0000000..3bd5e74 --- /dev/null +++ b/include/linux/firmware/imx/svc/seco.h @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2020 NXP + * + * Header file containing the public API for the System Controller (SC) + * Security Controller (SECO) function. + * + * SECO_SVC (SVC) Security Controller Service + * + * Module for the Security Controller (SECO) service. + */ + +#ifndef _SC_SECO_API_H +#define _SC_SECO_API_H + +#include +#include + +/* + * This type is used to indicate RPC SECO function calls. + */ +enum imx_sc_seco_func { + IMX_SC_SECO_FUNC_UNKNOWN = 0, + IMX_SC_SECO_FUNC_BUILD_INFO = 16, + IMX_SC_SECO_FUNC_SECVIO_ENABLE = 25, + IMX_SC_SECO_FUNC_SECVIO_CONFIG = 26, + IMX_SC_SECO_FUNC_SECVIO_DGO_CONFIG = 27, +}; + +#if IS_ENABLED(CONFIG_IMX_SCU) +int imx_sc_seco_build_info(struct imx_sc_ipc *ipc, uint32_t *version, + uint32_t *commit); + +int imx_sc_seco_secvio_enable(struct imx_sc_ipc *ipc); + +int imx_sc_seco_secvio_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data0, u32 *data1, u32 *data2, u32 *data3, + u32 *data4, u8 size); + +int imx_sc_seco_secvio_dgo_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data); + +#else /* IS_ENABLED(CONFIG_IMX_SCU) */ +static inline +int imx_sc_seco_build_info(struct imx_sc_ipc *ipc, uint32_t *version, + uint32_t *commit) +{ + return -EOPNOTSUPP; +} + +static inline +int imx_sc_seco_secvio_enable(struct imx_sc_ipc *ipc) +{ + return -EOPNOTSUPP; +} + +static inline +int imx_sc_seco_secvio_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data0, u32 *data1, u32 *data2, u32 *data3, + u32 *data4, u8 size) +{ + return -EOPNOTSUPP; +} + +static inline +int imx_sc_seco_secvio_dgo_config(struct imx_sc_ipc *ipc, u8 id, u8 access, + u32 *data) +{ + return -EOPNOTSUPP; +} +#endif /* IS_ENABLED(CONFIG_IMX_SCU) */ + +#endif /* _SC_SECO_API_H */ From patchwork Tue Nov 10 14:12:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Franck Lenormand (OSS)" X-Patchwork-Id: 11894391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9FD8C4742C for ; Tue, 10 Nov 2020 14:13:09 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4255F20797 for ; Tue, 10 Nov 2020 14:13:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cazra69m"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="gU6TBrXK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4255F20797 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=iOIakEvB3dW8igZOvFe5r955E7R09Z7oSfOVeZnQvRE=; b=cazra69m2Qr1cbrSiQIhbneym mv1b46JedRmvE3rup0aXDgRqWISj+/hjQ7ml3oNdkLS9g0PENsrxJj/NhE5s3lV/qb79+IlsoDwku oamdzlGDui3t/c2SpuOOiOviuqvPob3hTOwiVg1AqF7raRz5ZcldDvc81A+gx3/8ensfEGYjtp1Us x3aYB+fpnhxcag9dhn3Z1NfX7GyW+3HdJj9/LzRWBuMbogsM7EURmXbzf9J57JonnwMEbiTUfEIvk rz2H5Ff0hB13Yg/PLHuCFnD6QX+WKquvcorWvxR/uix9hPDX1ZVhbwCNKQDX7ebvAREKWC5bp3cpy mG74XiTMQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUO0-0007FQ-En; Tue, 10 Nov 2020 14:12:40 +0000 Received: from mail-eopbgr30075.outbound.protection.outlook.com ([40.107.3.75] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUNw-0007Cf-EY for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 14:12:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HDcUjUw5QpXhTo2biMN5j+5mVo4Ktu68F9CMdE4jcS+Sw4LriXr9tgUeRinKKhiDq/96ZuGZC9APPPUQ4JZum9nro+bkQ9maj0dOYkEle9UnKH9mpt5kyNJtWA5x1IAdj8dTsVr68VWxoboXeLdoNP/DrYtCNwjdGq5O2KeN57klK8J4NOJQzlb0xAxskRCmrAfn1tBZeCsinfyi9YzvVsswufqjxKbH8yommkpiDrdhF8Czc0mmvWaQm8TKFLqVp9R40+B6d0W8Sg/jqrcY2wR8sQB5JQbXy2Y1ZPBdmRzP0Q0H82x/tDHpOWTScGOAz/lJwIv61KxCdi96bnoQdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N4/dNxtFNG6pRfgwBcw7Dz/2s6SFql0A6aFbOeAzMXY=; b=CoEIL/qQSKf72QFu+b7xd3Zw9sUowBvMs95UfEeedhuhFgoF0dUquC7ckgvUuEiXpD86B8PvB+xTMVGt6kBmd7n6cJlYl/UwJDhmig9+vKcPhM8jCnj46ugV12kUlOeW1kAnrcjzYGjOltdl/4/n9NcTTOXixu1dUTQpr/dwK4zoR+l4yNw0Z3EAP5PMY2FCvwGz06AqLsz2Nbvh0Qy6C1qt5qRrS0BB4u2Tk3PVdaGXkKmexdHA4249i6BkaE8DvFnbVe2TeV3CERDVQuTWTN9F9vAh7wMIn2vCX9X3p5Umup43/lCrUv74Va/KPM/oSW4XzotwpFgWHsSYucrI8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N4/dNxtFNG6pRfgwBcw7Dz/2s6SFql0A6aFbOeAzMXY=; b=gU6TBrXKzE7TuQBwrG5vIJoZ76vqR8i1pWYG0lsf0ZKmXYddeb6ElVO7KbDKctI26aweB/6UaJ5OMfWcDc+7Qncgf5t1hONUm6mlyqB3G5oq6+kpjLt3iVodDBUk/ZgM1dcUV93LpGv9Y22scWo17E5/kh62/M5u8rrLoR0drfY= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) by AM0PR04MB4931.eurprd04.prod.outlook.com (2603:10a6:208:c1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Tue, 10 Nov 2020 14:12:22 +0000 Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5]) by AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5%8]) with mapi id 15.20.3541.025; Tue, 10 Nov 2020 14:12:22 +0000 From: franck.lenormand@oss.nxp.com To: shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Subject: [PATCH V3 2/5] firmware: imx: scu-irq: Add API to retrieve status of IRQ Date: Tue, 10 Nov 2020 15:12:11 +0100 Message-Id: <1605017534-87305-3-git-send-email-franck.lenormand@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> References: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) To AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from SOPDPUATS05.ea.freescale.net (81.1.10.98) by AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3541.21 via Frontend Transport; Tue, 10 Nov 2020 14:12:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d0ff6c0d-cf6f-454b-8bae-08d88582a3f6 X-MS-TrafficTypeDiagnostic: AM0PR04MB4931: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:765; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IAqFx06I/Yn9GzH+LySYbelzXLDyEhZfFTXgP5pJYf2HtwcNAXAZXCK+yLYonWKx7f5D79Gw+IrE3wnsuBHirfbzn9xoCoF6ZWhtyCcYtc4q+RtneR0GRPnE7EZlM15rbvqm/M0nkHm1x15524Xf6sVN3nooqhn9VrjAp0DVcw2hE4xgw9JfDybIhXQReUd+yxgxRDoovEbtPWn8RzGLcq32T+R0e+WtOZNNjK0DAGaVWcGZKIrwJ34X5hXDyX7KOvLzy6zrUsI6QJ4Wz6MQdxqLmTsuDIu1sZHGf/l+It8/VfpXyB9yXkIf3a0/O7ln/YjTzvUctVVgqjYjv9uBcQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR0401MB2401.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(498600001)(2906002)(2616005)(16526019)(8676002)(9686003)(186003)(66556008)(66946007)(5660300002)(6486002)(6506007)(52116002)(26005)(956004)(6666004)(83380400001)(6512007)(86362001)(66476007)(4326008)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: A5d5skD6sP4yC5e3NXGnKgl216X74VnMDW3ulJU2MhD2RuTOENMKZeqs4jft4MFOCtrLyjaeArYGlSiV+tY7TPdw//Cs/KXGu5aSdh07KORNDYlK/bwPhM7M7DNoWNHg9Ewh+HTS/k52e/galS4D6OxNweC4PnoGv36BLuzTmKWcI0u6UT10cvYnyEAkmo88ZKONCNRy53LmbKlVAWawO8PmY2ABYZTmHVBVrrsz6hIPPcoQ1218K/tjfUDHRyQciletxBmzqRkiQu3MnVArcUL8MoP5bR0IvwmEcXnjD6iorJDg3IH6ZMmkijuvKFi7WQJDHV1bI6pBr91TNEJk8ivnHf+taxRmIoMDj2X1nGkHytG2+ISETDn+Ze3hbGesWWHebpQiJ6M73UXD9ND/zAWIOhDWx6FOUV7JhTPAEX4KlI2oSzLASvzNzI5rOeDn3pv+/mEi4EMnR6w6nXDxNhV0G8foAkF1kkfYJQI1X4wz7rBXOLVDK7iCR7VdeMjiYFza2Nr0baHRMVjK/dUD87ivViVPX/5zRJt4vS5pkdNT60siDQEFVwZC6LpPd1DDEr3BbdopX2nZmNSqMsBqaT4Tv6yKpRV5Y3bQAHJO4K/bpnUsemQlp66uzWBySLqkRZ+D0BrQW7iGQwJ0S05p1A== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d0ff6c0d-cf6f-454b-8bae-08d88582a3f6 X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2401.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2020 14:12:21.8490 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3z7uUrCYPrBiqd2ZWVAUJU1uKKPSmYzs9wWberTBakgzxcTAQ0VUPPmquLh+iiTO8/C9yyPG56qcjJ4/oC1r3o+7LkHJ/9Lop50RVRwv28w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4931 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_091236_531919_926648F1 X-CRM114-Status: GOOD ( 19.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aisheng.dong@nxp.com, peng.fan@nxp.com, leonard.crestez@nxp.com, abel.vesa@nxp.com, Anson.Huang@nxp.com, linux-kernel@vger.kernel.org, linux@rempel-privat.de, linux-imx@nxp.com, kernel@pengutronix.de, qiangqing.zhang@nxp.com, franck.lenormand@oss.nxp.com, daniel.baluta@nxp.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Franck LENORMAND This patch adds the API to retrieve the status of an IRQ. It also adds values used to process SECVIO IRQ from the SCU. Signed-off-by: Franck LENORMAND --- drivers/firmware/imx/imx-scu-irq.c | 48 +++++++++++++++++++++++++++----------- include/linux/firmware/imx/sci.h | 4 ++++ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/imx/imx-scu-irq.c b/drivers/firmware/imx/imx-scu-irq.c index d9dcc20..bb0b5aa 100644 --- a/drivers/firmware/imx/imx-scu-irq.c +++ b/drivers/firmware/imx/imx-scu-irq.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright 2019 NXP + * Copyright 2019-2020 NXP * * Implementation of the SCU IRQ functions using MU. * @@ -66,29 +66,18 @@ static int imx_scu_irq_notifier_call_chain(unsigned long status, u8 *group) static void imx_scu_irq_work_handler(struct work_struct *work) { - struct imx_sc_msg_irq_get_status msg; - struct imx_sc_rpc_msg *hdr = &msg.hdr; u32 irq_status; int ret; u8 i; for (i = 0; i < IMX_SC_IRQ_NUM_GROUP; i++) { - hdr->ver = IMX_SC_RPC_VERSION; - hdr->svc = IMX_SC_RPC_SVC_IRQ; - hdr->func = IMX_SC_IRQ_FUNC_STATUS; - hdr->size = 2; - - msg.data.req.resource = mu_resource_id; - msg.data.req.group = i; - - ret = imx_scu_call_rpc(imx_sc_irq_ipc_handle, &msg, true); + ret = imx_scu_irq_get_status(i, &irq_status); if (ret) { pr_err("get irq group %d status failed, ret %d\n", i, ret); return; } - irq_status = msg.data.resp.status; if (!irq_status) continue; @@ -97,6 +86,39 @@ static void imx_scu_irq_work_handler(struct work_struct *work) } } +/** + * imx_scu_irq_get_status() - Get the status of the IRQs of a group + * + * @group: The group of IRQ to retrieve status + * @irq_status: Status of the IRQs retrieved + * + * @return Returns 0 for success and < 0 for errors + */ +int imx_scu_irq_get_status(u8 group, u32 *irq_status) +{ + struct imx_sc_msg_irq_get_status msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + int ret; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_IRQ; + hdr->func = IMX_SC_IRQ_FUNC_STATUS; + hdr->size = 2; + + msg.data.req.resource = mu_resource_id; + msg.data.req.group = group; + + ret = imx_scu_call_rpc(imx_sc_irq_ipc_handle, &msg, true); + if (ret) + return ret; + + if (irq_status) + *irq_status = msg.data.resp.status; + + return 0; +} +EXPORT_SYMBOL(imx_scu_irq_get_status); + int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable) { struct imx_sc_msg_irq_enable msg; diff --git a/include/linux/firmware/imx/sci.h b/include/linux/firmware/imx/sci.h index 914dce1..20a16a7 100644 --- a/include/linux/firmware/imx/sci.h +++ b/include/linux/firmware/imx/sci.h @@ -17,9 +17,13 @@ #include #include +#define IMX_SC_IRQ_GROUP_WAKE 3U /* Wakeup interrupts */ +#define IMX_SC_IRQ_SECVIO BIT(6) /* Security violation */ + int imx_scu_enable_general_irq_channel(struct device *dev); int imx_scu_irq_register_notifier(struct notifier_block *nb); int imx_scu_irq_unregister_notifier(struct notifier_block *nb); int imx_scu_irq_group_enable(u8 group, u32 mask, u8 enable); int imx_scu_soc_init(struct device *dev); +int imx_scu_irq_get_status(u8 group, u32 *irq_status); #endif /* _SC_SCI_H */ From patchwork Tue Nov 10 14:12:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Franck Lenormand (OSS)" X-Patchwork-Id: 11894403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F04DFC388F7 for ; Tue, 10 Nov 2020 14:14:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B3F020797 for ; Tue, 10 Nov 2020 14:14:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="3CuUgKIo"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="YZ5OXZvJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B3F020797 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=ksEtRemRn67lTiG8GMS9/2epuOiZqZ5W+0OAgy39Wek=; b=3CuUgKIofYlRMijwtCtm2EdrH asrxOAa9J1+tvo+gI1cXpxr5/nKNCEstaJxnTaDSmndAAOTTVjPzRHfeO59ac2LuRjZS9zPtHall0 XhgC+c1pTBX6sz43Bqkc+W1MrkDnechb1v1D7qBvIA936Y7tpKoTqqML2Vh7jzRmmECvDckqba3yj lEi2wwN5Op7tYO+XQWZ4tvbMadDZfU3d4XhFmEMt6Pzx/aqF6AWWhmq8WNgO+eLNy0Z9gb4PE6F4F OxE1gpvcNYehFzTkn9pdfWhM3FJswhyktw9YCqef2w57lVPusqSph4Ctra8jd7gHH9GDv4YrUVaeo KvgZ/W7gw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUO5-0007Gg-Nl; Tue, 10 Nov 2020 14:12:45 +0000 Received: from mail-eopbgr30075.outbound.protection.outlook.com ([40.107.3.75] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUNx-0007Cf-Il for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 14:12:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZVw718i/kzRXWheQAyluIbL9LA/Dk0QxMIt5muvdP5x9kQrFu7MjdluCKpOxAfQkL+fVrPp8Cq7xLIqfqQb4mCONz3g37GwcHtQL3hM+1aT7pg3vaOsxhRZe2hGLxYzPNL/0zdFyBJ0dkcM1v9k1aZfRKANf+XtAxr0gmZua3mL1O4pqyHEkDqlg7s+CUnr4wNq9738+oreUqjw1yW5pldDLpx9jR8ELWZmVInQiphB2z35hLO7bzkb3J9bFpQIG6YqRk3n9gOFvuLCyHE5sZEMyymSm9iqgMHZ/LKQIGhlmNoLNI7o2AlaurHEtINy8TpDGYsnWzQ2iiRIMFOJt+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZlCjeFFIoQ5+ViSEam7mGZZbb79CVzNu4mUPe+u8z54=; b=giofUpd9zjyFavGte5YjXhLTQqE2UoKcYN53zh8iCORuHOhZXIGEXPGOtCgDxMR46+MEzKkZAkfp4yxc3+0fZkK1FwKLZW2UXT7fOtd/kxFyNCpf0h2eDXRK4A+N9ACoBXruJEwz8PVP7UwKJ9+OrKPpJgMqtdOQ57I8KyHZkwnYnjrykdi2UrgD6NB5YouYnYkak1BMRK5jk+C8qPo10aN4hyCaoPWk7SzTAKOekG7dGQf/vQSfpsZgxJJM/SzF1lJqEKD/CQtkv+kVCX6pIWkdflu4eldf/o4g/NbnFGBgwRmpA+KevOEm+P8t2pXT7Ihw8HbXyORC+fOX4AaQ9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZlCjeFFIoQ5+ViSEam7mGZZbb79CVzNu4mUPe+u8z54=; b=YZ5OXZvJrgYG5DnrEFnQGGkJfmk7wj+AHCP5MywJp1qleFsZthhRznmqR5CbGHcuOdWVffqn0aJCB/R2Mr8GSB3PQypF6mSGnM/ryWlfiIu95o+sEGIVOuORc4zX0/UroH//q8gZScp2Ig88TOayKUc18pszxQpq9Q04Su0uy5o= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) by AM0PR04MB4931.eurprd04.prod.outlook.com (2603:10a6:208:c1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Tue, 10 Nov 2020 14:12:28 +0000 Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5]) by AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5%8]) with mapi id 15.20.3541.025; Tue, 10 Nov 2020 14:12:28 +0000 From: franck.lenormand@oss.nxp.com To: shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Subject: [PATCH V3 3/5] dt-bindings: firmware: imx-scu: Add SECVIO resource Date: Tue, 10 Nov 2020 15:12:12 +0100 Message-Id: <1605017534-87305-4-git-send-email-franck.lenormand@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> References: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) To AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from SOPDPUATS05.ea.freescale.net (81.1.10.98) by AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3541.21 via Frontend Transport; Tue, 10 Nov 2020 14:12:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5b831691-c2cb-4454-0798-08d88582a4ae X-MS-TrafficTypeDiagnostic: AM0PR04MB4931: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jHrk91hftUtS0SInk8THU4kZphMuKF4FPeEzOvXx052C2+yfJmQAdhNNPch/zfKiBgydNaPCZ0+FjTVb2RH5S9E7laBgXMAYyD6dwlVpNtZ4nEY9BM5BT8p40SNmt9jiZJmfCXeNw8DwLYJlOkcEaW0gDvV2tfd07pMZW6uBSeGRgzUYAgH4evrg5pmr3LuW1lH60S3EE+cvcRzg8uRGve8LfFavixL4Mnr3QdQ8j812GRLc2tGMZT/pYM3xsQ0CUKnD/SA0FHsHRYrrI/ngX0/JGSPhpKhtT1I8OYO0MHFH88A9ddBrRxZdQaPb9IZMyucXPMJdRVk0rNkIpQE8Bg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR0401MB2401.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(4744005)(498600001)(2906002)(2616005)(16526019)(8676002)(9686003)(186003)(66556008)(66946007)(5660300002)(6486002)(6506007)(52116002)(26005)(956004)(6666004)(83380400001)(6512007)(86362001)(66476007)(4326008)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YK9ZNH49RAfAVY7agMTek1gpJy3E+AZKX8C0AU4W/p8XJcaL7M7gWkfmQkMb5QFjLr1y/kMZAi5nXD4OH0KIvFN3CxhCIx6NO3UovtMh6+DrAsep4V5KVxrf7azw6va9uaLpkrT/SbGNl1dpRwHDh8eVZikyu/iGgRthkbz8qDyZ9Am0O/EufETI10xuyiIN02ZIJT+AqlZgsQa0fyMkM8fayyJahlrW/PiFJciFQm0GNzZxVYnn6d10lKdVs3IiOpYepuV95u8cFSNxIWIYDi+e40pjIQgiu4ORxpSCtYof8OF4G56HZ3CJ2PxIwyBJDt8Je67086gS5EsjPGPGQAKnWlQFu/shsl2qa6S5z4uNbUzs9ITs3KwnJI8AV3niBrJ8+RQhhfR8lJTxRFQW8GciGkg4jXddIPuZH+uVGpL2j1z5lqyXm7gR1UTdyBomWK8UStJ5rLWyet0ImWBY/uBb8cDGQrjThjKAa9S8jhnOJu4sDs5O9gWv/1B+3Yi461T4+8KvqqAYiww85QIboNNyN3+m4jBnB+AVG4Yq4JqK9T5XTx0YMLYUzMo7AkXs/yae+2DfTNdcJk7b1kUJt+jbUzOUuZaaoEob1Q0u/bccmO3xC9Ahnxt6vUcjysDn X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b831691-c2cb-4454-0798-08d88582a4ae X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2401.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2020 14:12:23.1604 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PVpQvlynYaAC9aP8iSLgJ8f2c+Khb8bODQGZTAtaDa4Urq0i8mq/TM8M0ZmZrtgNyTyvzP2/PZIybSo1AGoNfhhjslpRbe//sUro9rT+o4s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4931 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_091237_650115_792C3874 X-CRM114-Status: GOOD ( 13.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aisheng.dong@nxp.com, peng.fan@nxp.com, leonard.crestez@nxp.com, abel.vesa@nxp.com, Anson.Huang@nxp.com, linux-kernel@vger.kernel.org, linux@rempel-privat.de, linux-imx@nxp.com, kernel@pengutronix.de, qiangqing.zhang@nxp.com, franck.lenormand@oss.nxp.com, daniel.baluta@nxp.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Franck LENORMAND The SNVS can trigger interruption when detecting a security violation. This patch adds the definition of the resource. Signed-off-by: Franck LENORMAND --- include/dt-bindings/firmware/imx/rsrc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/dt-bindings/firmware/imx/rsrc.h b/include/dt-bindings/firmware/imx/rsrc.h index 54278d5..fe5f25f 100644 --- a/include/dt-bindings/firmware/imx/rsrc.h +++ b/include/dt-bindings/firmware/imx/rsrc.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2016 Freescale Semiconductor, Inc. - * Copyright 2017-2018 NXP + * Copyright 2017-2018, 2020 NXP */ #ifndef __DT_BINDINGS_RSCRC_IMX_H @@ -50,6 +50,7 @@ #define IMX_SC_R_DC_1_BLIT2 38 #define IMX_SC_R_DC_1_BLIT_OUT 39 #define IMX_SC_R_DC_1_WARP 42 +#define IMX_SC_R_SECVIO 44 #define IMX_SC_R_DC_1_VIDEO0 45 #define IMX_SC_R_DC_1_VIDEO1 46 #define IMX_SC_R_DC_1_FRAC0 47 From patchwork Tue Nov 10 14:12:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Franck Lenormand (OSS)" X-Patchwork-Id: 11894397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3030C4742C for ; Tue, 10 Nov 2020 14:13:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 23EE520797 for ; Tue, 10 Nov 2020 14:13:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fubzfW2H"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="EMSSmfxA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23EE520797 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=A7tPMjIw8e/SbS7NrJWXMkNnbxvGpJKkeZUqcterGi0=; b=fubzfW2HWso6/DjTKA708Z2rP bfeZzwvzvFRBwmZDkxssCYA4qhjeEtvnb+YMELA0060hsk6lZ5KgEMaVBS9xmonc1/guyJVLhAauO RBP16S0tuCPd6xkMS4BeELETlBynovgTSyekgU2OlCVf61c/Cdm1/SmB1LNilhQg9u7yw3GymQXt/ nsWW8jg/QpJxugC11lxNAKNGEXfrsheYYE0Aoy3dBqO8yuf7ZtJ9No9f94Nm1JXFI7xS6H/eXo6VV BcTBq7QlGv3vbjyDRDsk0OCJ3GQ5hRvR6qW3E2rsJmlmUox4LYRaa3kkmzF/RbqJVjSmRkJiR8+Lq +CiwNH7Vg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUOF-0007Jf-3n; Tue, 10 Nov 2020 14:12:55 +0000 Received: from mail-eopbgr30075.outbound.protection.outlook.com ([40.107.3.75] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUNz-0007Cf-3H for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 14:12:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NJ0Y5990guV6OT4e9eY+5sCS9SyayzajRE6n/Jh3F/MVPJSjiIs+IjMW4XWjC2k+XGri/5nWgxVifv2vniG1kziBIUpk5tYcv9M0kHFaa/7kfrdWqcSZ6zbV9mobkZuVRpMyBWzHhvW5ZXfkoYSwN3f1qqExlpRjn4eo+QwkU4/wdyoTPgPIVIjL4aBkxEQp8Sitxe1fgWTDOeov0nuIpAHHgVw3/Ib1NmeQJeQ+bPKs8kiCNGozZ7jyMPvQijaLV1bi0KkTQ7rkZvksXRO0MhJU/uvEwDdli6pEzBb49EIWNL7MNDEeAYxx/4DwthkhYcjSeeu/SNDGPnamNUF3Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nKh9XZkW9Bg/RRnRMswGzrN/E4oIRi4kmVGjHlBc89c=; b=Q4srz9j2WG0SWzlJfsJRgjEcGl3/0cOZ5xTo9xlLDL1fqZEpfmI5F6GUMOvlbwkR7fqkrIQWl9C1TSN5nZ/GMuXLBnzpcvMusnexACmH1tAqpfv8PPC8H5Lg3V0S3dcb6CqoQAgkXk+5NtBmlbfCC+MYwDNrzrut5pWf+jKaPISN1RVRZn3B9+da5yE+7G+IU7V/i5wtiEnNcKz7yJNkVRwY2zMjlk1H6ELhnbQ3lUZr/OCj39QQoVVIsLP7ozhin8s0EAiKSihCp5zMOtoJEDPHZYRoU4rDbtezVEu3m+k+fd4qpejnLQM8OtIi5su6N3EvkfqVDluJOSJLmkWnXw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nKh9XZkW9Bg/RRnRMswGzrN/E4oIRi4kmVGjHlBc89c=; b=EMSSmfxAicP1eHuMYg53M2ChtgGfetMcead5+AqBnQdLeiAbUyyH+5pxyojzFJrSg0+RaUBUMxCIzSPUnh0Kfues+5aazmm+vg6pXBAJyf1vRSjTJAqJw9HtJrGxzCPCAIJj9Vk3bSOjvWTr6rHSGqrkH4vY8DkZsp8n6lYkYaI= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) by AM0PR04MB4931.eurprd04.prod.outlook.com (2603:10a6:208:c1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Tue, 10 Nov 2020 14:12:35 +0000 Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5]) by AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5%8]) with mapi id 15.20.3541.025; Tue, 10 Nov 2020 14:12:35 +0000 From: franck.lenormand@oss.nxp.com To: shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Subject: [PATCH V3 4/5] dt-bindings: arm: imx: Documentation of the SC secvio driver Date: Tue, 10 Nov 2020 15:12:13 +0100 Message-Id: <1605017534-87305-5-git-send-email-franck.lenormand@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> References: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) To AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from SOPDPUATS05.ea.freescale.net (81.1.10.98) by AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3541.21 via Frontend Transport; Tue, 10 Nov 2020 14:12:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 9950bac7-ce4c-4bc8-690c-08d88582a571 X-MS-TrafficTypeDiagnostic: AM0PR04MB4931: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +NhjLC1JrEUxvdHzZ83KJCANFfCZPdynLKvaknmZivaEp/9fcMgl1vd6HEK+X/JnTESZ4Ny/gQuCj/Nl0qKZ1vUB1w7t3zK1yeGhUi0GrhSGA50uRlbZu5S5vTqPN27YaCLrlEQ4H48E8ng0u9s61cbwDYVxKNtzUz9seEzYnainHhAj+1PrlCDFr/FEmkiuVlZe5IPKljJwOBvECIQ4don0OX10s0zqi8a4T3UeRfs8Cc7T9qummQT/Nx015EUoOANPCcjphdTaX/BEuv/+HtkNsgyLkZsYTb8YSCe/VvaiLWme351Sox+Cd2/wv4XQG+SeW6aPyUZjW1YINeheclnDnNiUTqmGRb/zAsmWXEPvsd3FkbGrHTqWVTYYRhAtUbDSpeFlG2zSUk7hoBRpzg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR0401MB2401.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(498600001)(2906002)(2616005)(16526019)(8676002)(9686003)(186003)(66556008)(66946007)(5660300002)(966005)(6486002)(6506007)(52116002)(26005)(956004)(6666004)(83380400001)(6512007)(86362001)(66476007)(4326008)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: YiL98jjy8oQ5DUV0qZoVwU3oniE2+cznVsVvMuclf2gXbiiKR8OzqlqBZRpyUsOUDHMoG30KBfZDo4Xcb3opk88Rvp40qytPt76q1lceCDaL36Y4GxqLAraf+/lR2sJqqkZbZcavCjqs6KFLPini+q3AWu23GpBK/csJzdfvijzpJ2PZoUbCsLnPrThs9HPUbNaM0+BfhkV97p1fINWARg/ERmX5/32R8D85KHt40BvIACxKHZwL2xEimvc5vUfZm4gN2Sp9gHGwc8/IBcHtI1iTig6NXkxX7LLXU8cLrAW9gs8cERCumKmhpzNFpwA3h1OX+X2/aAipnbKGPNCxOjOKYIbkfRDfNTF9cpOOfNQr8eSU6UL148ZafwzMh45RnAn5wwkic0naMOL+MMNy+OXgM/rkdB1S4XVoH8u46FzRCCHYMD9h8M4ot6+tyNPYLuI+4oaK9emDkytqob00ZLv/fjlfE0j2e/JoIiT3TlkIhHE5l1A2WD7kPsbKpBBCdRhLfO5sPlGrGi4u3evjxnOnleDYA4gDMvGQvsGzQnyzPm2o/QD/28Mfk48aDXSfoJcdP8LbuzUUMbyqWxFLYPW9QIjSiq6ZlQslQ3zTz9kjwrOMZerMVtBIgrQr0+s7 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9950bac7-ce4c-4bc8-690c-08d88582a571 X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2401.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2020 14:12:24.3999 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: SpCrQu40L0yG8Ub+GtQWCR8NuNd6UE9GrexVCC+w1CeIVawD8zms9UIcO7CYxtMn/7A5D5Xt4DjHAdZMtnVeBeo0geExaZO79alKu8ACsn4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4931 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_091239_240020_6BFE4A48 X-CRM114-Status: GOOD ( 15.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aisheng.dong@nxp.com, peng.fan@nxp.com, leonard.crestez@nxp.com, abel.vesa@nxp.com, Anson.Huang@nxp.com, linux-kernel@vger.kernel.org, linux@rempel-privat.de, linux-imx@nxp.com, kernel@pengutronix.de, qiangqing.zhang@nxp.com, franck.lenormand@oss.nxp.com, daniel.baluta@nxp.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Franck LENORMAND This patch adds the documentation for the security violation driver using the SCU on imx8x and imx8q. Signed-off-by: Franck LENORMAND --- .../bindings/arm/freescale/fsl,imx-sc-secvio.yaml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/freescale/fsl,imx-sc-secvio.yaml diff --git a/Documentation/devicetree/bindings/arm/freescale/fsl,imx-sc-secvio.yaml b/Documentation/devicetree/bindings/arm/freescale/fsl,imx-sc-secvio.yaml new file mode 100644 index 0000000..8037395 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/freescale/fsl,imx-sc-secvio.yaml @@ -0,0 +1,34 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/arm/freescale/fsl,imx-sc-secvio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP i.MX Security Violation driver + +maintainers: + - Franck LENORMAND + +description: | + Receive security violation from the SNVS via the SCU firmware. Allow to + register notifier for additional processing + +properties: + compatible: + enum: + - fsl,imx-sc-secvio + nvmem: + $ref: http://devicetree.org/schemas/nvmem/nvmem-consumer.yaml + description: + Phandle to the nvmem provider. + +required: + - compatible + - nvmem + +examples: + - | + sc_secvio: sc-secvio + compatible = "fsl,imx-sc-secvio"; + nvmem = <&ocotp> + }; From patchwork Tue Nov 10 14:12:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Franck Lenormand (OSS)" X-Patchwork-Id: 11894401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0A6DC388F7 for ; Tue, 10 Nov 2020 14:13:40 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F58720797 for ; Tue, 10 Nov 2020 14:13:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CCsIMO7N"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="lLFQwV3D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F58720797 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=PiZqJ2hMBonGT2Sk7rYeJo+0HpPGVm3mJH54njrBPa4=; b=CCsIMO7NNWmGdQiOHAeSR4POb fu+Y6ApSL50Rzg2WtmskdItRjqcQZu6bR0J6pLrVNAB4uijIEDmCU004E2ETK8Z1RlXTqJqgbbtUZ TcnNzoNTbPyuCDDF/Xh0+63M787ovk+rmhDVoowH26X9XWZ6AlIE3UXigewb++ULgUdSgXyjERAnn eaxOm+6Vw2RB+daUgAjBB5R2Y73QZwLYn1WgDPiMOKkiztxFk+R+qv1kAvq6RCx2pnQGDyND1TFgn nY6ULyj6Vt+bZ3YUki/9gDcEvwFYRdaAoqFiHo+LoFNn5+5gBvQfQfD4N4p0Q9O3y5sqgEoBCmMm4 rPSaenlsw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUOP-0007OK-MH; Tue, 10 Nov 2020 14:13:05 +0000 Received: from mail-eopbgr30072.outbound.protection.outlook.com ([40.107.3.72] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcUO3-0007GC-Nh for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 14:12:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gw8xRmzoeyN35uA9flT3l7Lg6l3xc5XHTuPxHMr1ljEiDcmrz/7Fn2N1IAd3xn4abk2o9f6CdXCuLXrhsUWmC+2ucwQahNn/bJ8+HZ8REWaqsMkbLFAUpofbTExl4NHG3wLYvZVlByIDiApx88e5apLytLSREKk4VyViMLUhIezwfYG21cIuhDohj3Pka9+09dx0krZJ74UkrjhibgtloaUiZGPMeoobd2Uv2TUtbGaUvQnndPLIUBQ/5UzAU6cPK/ux6Juf+xK431LGHMg5SwSqbc9yB47cp6yrS9Sf4ODCSrlmK6wzY4py3XSFYxDPwg6wn7lZZitrWoWvd5uOEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=81ois8JkR6huE2zmTGy3Q2OM7DEcR8vy4z8TwyXlPwY=; b=laQsYUBkMTgntuHllpx12FAnkY8ZwvVf2HOVYBWqPLTejbjhs/hxijWeSWh7m4wO/IwOdTOIfRFdTEO+nvKd3jLx0grb/ESU4Q2osBoXD/oecG1tBkyLCBfOVoSgnUAkN4Py1u2G+nDM5mfx/3YW5sqEs5PnRPvSQ82tgEhKen2eRbrITw2E9UUkTdwBEVoQNsi9Mfv1gJ/fgYSvEjVapSKFe2C52cT6k+v6Uyj04DcgDIdONMYuZ4nZifi5A0hq5nzR1HP9obApip1MhGyQoldaN8IEaLgo9zkFxuJgBOr+HbBwqlVkH8ZFoNnRH/S2EiI06Pittc8BToc2jiqU6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=81ois8JkR6huE2zmTGy3Q2OM7DEcR8vy4z8TwyXlPwY=; b=lLFQwV3DroTnhEX7ZhViZcfZdQWNz5yCdb04X72v814RPF0Z0qhHFlRcmTxnBHKFV2XJo77RmQWygjGgfzVnt13kWnUdPR5ChLQRcBhyahNW0/EvmQu8GExRU6W6aeSB5V3x2p4effYDUV2p7/gy41HrEcMNUj94B2mrt2T5V3o= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) by AM0PR04MB4931.eurprd04.prod.outlook.com (2603:10a6:208:c1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.27; Tue, 10 Nov 2020 14:12:38 +0000 Received: from AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5]) by AM4PR0401MB2401.eurprd04.prod.outlook.com ([fe80::fd3f:1280:bcea:2ab5%8]) with mapi id 15.20.3541.025; Tue, 10 Nov 2020 14:12:38 +0000 From: franck.lenormand@oss.nxp.com To: shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Subject: [PATCH V3 5/5] soc: imx8: Add the SC SECVIO driver Date: Tue, 10 Nov 2020 15:12:14 +0100 Message-Id: <1605017534-87305-6-git-send-email-franck.lenormand@oss.nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> References: <1605017534-87305-1-git-send-email-franck.lenormand@oss.nxp.com> X-Originating-IP: [81.1.10.98] X-ClientProxiedBy: AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) To AM4PR0401MB2401.eurprd04.prod.outlook.com (2603:10a6:200:47::26) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from SOPDPUATS05.ea.freescale.net (81.1.10.98) by AM4PR0101CA0083.eurprd01.prod.exchangelabs.com (2603:10a6:200:41::51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.3541.21 via Frontend Transport; Tue, 10 Nov 2020 14:12:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: cff2b9fa-cacd-42a2-32b9-08d88582a632 X-MS-TrafficTypeDiagnostic: AM0PR04MB4931: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:12; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M6jRsSlfxfEEtEna3kH4130WYFfHvk9pXuNfZWGgeDdLd/OL45oPn5IR0Du4mUngqBR5rvx5sjacQ4nI+6Hd/7SlOq2lwal8R63ugeMdIi90OMzDCIYsZiV1tRWAAyrCP9mNwLmX2lqLqhoupn0SOk5Rk1Exq4UoIJ5LHiynbp1Kt3idXiduZFh4YZSUvTcq4NWJ0a6rUv29xDMdD2UiUidUfeu7D+RiqoZDuiqUZQJezwPmhrxpmSSfEas81g1VSp0zrUj6i/E7f8hA//3q1KPo8d3aO5DRnlO1uPiG3ZPHELPmkm7H9XAz9+lQeddqs6iSd0H2en8bszxvDX+Hyg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM4PR0401MB2401.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(498600001)(2906002)(2616005)(16526019)(8676002)(9686003)(186003)(66556008)(66946007)(5660300002)(6486002)(30864003)(6506007)(52116002)(26005)(956004)(6666004)(83380400001)(6512007)(86362001)(66476007)(4326008)(8936002)(579004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: iBuWv12Cysl6Kk/SfTHEdrXqialjPq6YBjOn1dlpBhBsnxDnS0rG5YkaxywQpAKv6a/gbEwQBxUdcn4HgZLtb/X92Cx8C9R5gHSsTeas5tzGDvpWPB+od8S4eevxMF15JkEVs0P595T5AyXcGAkLNE9kZ5DHjvoIVYna8Hq0ROZdf77ReHcSD5DMj9+XgkdR24r3BfvdPCvpaFAmHt8kzqkYfe0Ps8Ly7tlzHKToeK/waY6+q1IrCBZ9Ae6w/BzYGUABysK+0ZiLomJ5IKmMMzgWVOvb8pToIx2rqCEM1DsroqXDQDE8DtUHZfQIF/KzJyYRujdWbYKgaAP4h5RRqa1HJxXQ9kp2a/XcG4YjW947pfewESA6pAArmGmjIl6hkP/nNSxWQvLg/MwuFeijHV57HMZsybe/N98513k4kgXcPoWyXKO1E7yB6EXWOK4AmZGO7frGvl1CUKs0kao1qrY6ymN923SN6A5Rjkb8CXFRt5LJgmz5Xez9CDOzNgoZZ+CuloKD++5k7HRLUxydKDuEmW0dyZ5E9EV/vWMo8AssW+LY3J9d5rsc+BI8uvT9NeifqEuV9Sb3thbKgUO+EcXk25JdlACgT39Ow4LG8MNcp0s7FYO2WTDZjgnSIZV1 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: cff2b9fa-cacd-42a2-32b9-08d88582a632 X-MS-Exchange-CrossTenant-AuthSource: AM4PR0401MB2401.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2020 14:12:25.8383 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GZTE/aJ2uTAY4oYJcxkf6PFIBVycyAhsSzPurFv1K1OEbSw3Ilti78WSpc91UcOvkXn1wcOM93YdQdbCAUrQ/feWS9s7egV3o/bH6PSU1cY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4931 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_091244_159373_B4AC31A8 X-CRM114-Status: GOOD ( 26.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aisheng.dong@nxp.com, peng.fan@nxp.com, leonard.crestez@nxp.com, abel.vesa@nxp.com, Anson.Huang@nxp.com, linux-kernel@vger.kernel.org, linux@rempel-privat.de, linux-imx@nxp.com, kernel@pengutronix.de, qiangqing.zhang@nxp.com, franck.lenormand@oss.nxp.com, daniel.baluta@nxp.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Franck LENORMAND The SNVS is a hardware component in the imx8 SoC. One of its function is to detect hardware attacks, in which case it creates a SECurity VIOlation. This patch adds the support for the reception of these secvio and report it to the audit framework. It also gives the possibility to perform custom processing when a secvio is detected. Signed-off-by: Franck LENORMAND Reported-by: kernel test robot --- drivers/soc/imx/Kconfig | 10 + drivers/soc/imx/Makefile | 1 + drivers/soc/imx/secvio/Kconfig | 10 + drivers/soc/imx/secvio/Makefile | 3 + drivers/soc/imx/secvio/imx-secvio-audit.c | 39 ++ drivers/soc/imx/secvio/imx-secvio-debugfs.c | 379 ++++++++++++ drivers/soc/imx/secvio/imx-secvio-sc-int.h | 84 +++ drivers/soc/imx/secvio/imx-secvio-sc.c | 858 ++++++++++++++++++++++++++++ include/soc/imx/imx-secvio-sc.h | 177 ++++++ 9 files changed, 1561 insertions(+) create mode 100644 drivers/soc/imx/secvio/Kconfig create mode 100644 drivers/soc/imx/secvio/Makefile create mode 100644 drivers/soc/imx/secvio/imx-secvio-audit.c create mode 100644 drivers/soc/imx/secvio/imx-secvio-debugfs.c create mode 100644 drivers/soc/imx/secvio/imx-secvio-sc-int.h create mode 100644 drivers/soc/imx/secvio/imx-secvio-sc.c create mode 100644 include/soc/imx/imx-secvio-sc.h diff --git a/drivers/soc/imx/Kconfig b/drivers/soc/imx/Kconfig index a9370f4..6c1bc78 100644 --- a/drivers/soc/imx/Kconfig +++ b/drivers/soc/imx/Kconfig @@ -19,4 +19,14 @@ config SOC_IMX8M support, it will provide the SoC info like SoC family, ID and revision etc. +config SECVIO_SC + tristate "NXP SC secvio support" + depends on IMX_SCU + help + If you say yes here you get support for the NXP SNVS security + violation module. It includes the possibility to read information + related to security violations and tampers. It also gives the + possibility to register user callbacks when a security violation + occurs. + endmenu diff --git a/drivers/soc/imx/Makefile b/drivers/soc/imx/Makefile index 078dc91..c91a499 100644 --- a/drivers/soc/imx/Makefile +++ b/drivers/soc/imx/Makefile @@ -5,3 +5,4 @@ endif obj-$(CONFIG_HAVE_IMX_GPC) += gpc.o obj-$(CONFIG_IMX_GPCV2_PM_DOMAINS) += gpcv2.o obj-$(CONFIG_SOC_IMX8M) += soc-imx8m.o +obj-${CONFIG_SECVIO_SC} += secvio/ diff --git a/drivers/soc/imx/secvio/Kconfig b/drivers/soc/imx/secvio/Kconfig new file mode 100644 index 0000000..dcfaea5 --- /dev/null +++ b/drivers/soc/imx/secvio/Kconfig @@ -0,0 +1,10 @@ +config SECVIO_SC + tristate "NXP SC secvio support" + depends on IMX_SCU + help + If you say yes here you get support for the NXP SNVS security + violation module. It includes the possibility to read information + related to security violations and tampers. It also gives the + possibility to register user callbacks when a security violation + occurs. + diff --git a/drivers/soc/imx/secvio/Makefile b/drivers/soc/imx/secvio/Makefile new file mode 100644 index 0000000..d5a89ba --- /dev/null +++ b/drivers/soc/imx/secvio/Makefile @@ -0,0 +1,3 @@ +obj-y += imx-secvio-sc.o +obj-$(CONFIG_DEBUG_FS) += imx-secvio-debugfs.o +obj-$(CONFIG_AUDIT) += imx-secvio-audit.o diff --git a/drivers/soc/imx/secvio/imx-secvio-audit.c b/drivers/soc/imx/secvio/imx-secvio-audit.c new file mode 100644 index 0000000..dc96e16 --- /dev/null +++ b/drivers/soc/imx/secvio/imx-secvio-audit.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019-2020 NXP + */ + +#include + +#include + +/** + * report_to_audit_notify() - Report secvio and tamper status to audit FW + * + * This function can be chained in a notifier list + * + * @nb: notifier block + * @status: error code + * @notif_info: Pointer on secvio_sc_notifier_info structure + * + * Return: + * 0 - OK + * < 0 - error. + */ +int report_to_audit_notify(struct notifier_block *nb, unsigned long status, + void *notif_info) +{ + struct audit_buffer *ab; + struct secvio_sc_notifier_info *info = notif_info; + + ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_INTEGRITY_RULE); + if (!ab) + return -ENOMEM; + + audit_log_format(ab, " hpsvs=0x%.08x lps=0x%.08x lptds=0x%.08x", + info->hpsvs, info->lps, info->lptds); + audit_log_task_info(ab); + audit_log_end(ab); + + return 0; +} diff --git a/drivers/soc/imx/secvio/imx-secvio-debugfs.c b/drivers/soc/imx/secvio/imx-secvio-debugfs.c new file mode 100644 index 0000000..bcbd77a --- /dev/null +++ b/drivers/soc/imx/secvio/imx-secvio-debugfs.c @@ -0,0 +1,379 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019-2020 NXP + */ + +/* + * The module exposes 3 files in debugfs: + * - secvio/info: + * * Read: It returns the value of the fuses and SNVS registers which are + * readable and related to secvio and tampers + * * Write: A write of the format " [ + * ]()" + * will write the SNVS register having the provided id with the + * values provided (cf SECO documentation) + * - secvio/enable: State of the IRQ + * - secvio/check: Check the state of the security violation and tampers + * and calls notifier + * - secvio/clear: Clear the state of all secvio and tampers + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include "imx-secvio-sc-int.h" + +/** + * fuse_reader() - Read a set of fuse + * + * @dev: secvio device + * @id: offset of the fuse + * @value: array of values read + * @mul: number of fuse to read + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int fuse_reader(struct device *dev, u32 id, u32 *value, u8 mul) +{ + struct imx_secvio_sc_data *data = dev_get_drvdata(dev); + u32 size_to_read = mul * sizeof(u32); + int ret; + + ret = nvmem_device_read(data->nvmem, id, size_to_read, value); + if (ret < 0) { + dev_err(data->dev, "Failed to read fuse %d: %d\n", id, ret); + return ret; + } + + if (ret != size_to_read) { + dev_err(data->dev, "Read only %d instead of %d\n", ret, + size_to_read); + return -ENOMEM; + } + + return 0; +} + +/** + * snvs_reader() - Read a set of SNVS register + * + * @dev: secvio device + * @id: offset of the register + * @value: array of values read + * @mul: number of registers to read + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int snvs_reader(struct device *dev, u32 id, u32 *value, u8 mul) +{ + int ret; + u32 *v1, *v2, *v3, *v4, *v5; + + v1 = NULL; + v2 = NULL; + v3 = NULL; + v4 = NULL; + v5 = NULL; + + switch (mul) { + case 5: + v5 = &value[4]; + fallthrough; + case 4: + v4 = &value[3]; + fallthrough; + case 3: + v3 = &value[2]; + fallthrough; + case 2: + v2 = &value[1]; + fallthrough; + case 1: + v1 = &value[0]; + break; + default: + return -EINVAL; + } + + ret = call_secvio_config(dev, id, SECVIO_CONFIG_READ, v1, v2, v3, v4, + v5, mul); + if (ret < 0) + dev_err(dev, "Failed to read snvs reg %d: %d\n", id, ret); + + return ret; +} + +/** + * snvs_dgo_reader() - Read a set of DGO register + * + * @dev: secvio device + * @id: offset of the register + * @value: array of values read + * @mul: number of registers to read + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int snvs_dgo_reader(struct device *dev, u32 id, u32 *value, u8 mul) +{ + struct imx_secvio_sc_data *data = dev_get_drvdata(dev); + int ret; + + /* We check that we only have 1 register to read */ + if (mul != 1) + return -EINVAL; + + ret = imx_sc_seco_secvio_dgo_config(data->ipc_handle, id, + SECVIO_CONFIG_READ, value); + if (ret) + dev_err(dev, "Failed to read snvs dgo reg %d: %d\n", id, ret); + + return ret; +} + +static const struct imx_secvio_info_entry { + int (*reader)(struct device *dev, u32 id, u32 *value, u8 mul); + const char *type; + const char *name; + u32 id; + u8 mul; +} gs_imx_secvio_info_list[] = { + {fuse_reader, "fuse", "trim", 30, 1}, + {fuse_reader, "fuse", "trim2", 31, 1}, + {fuse_reader, "fuse", "ctrim1", 260, 1}, + {fuse_reader, "fuse", "ctrim2", 261, 1}, + {fuse_reader, "fuse", "ctrim3", 262, 1}, + {fuse_reader, "fuse", "ctrim4", 263, 1}, + {fuse_reader, "fuse", "OSC_CAP", 768, 1}, + + {snvs_reader, "snvs", "HPLR", 0x0, 1}, + {snvs_reader, "snvs", "LPLR", 0x34, 1}, + {snvs_reader, "snvs", "HPSICR", 0xc, 1}, + {snvs_reader, "snvs", "HPSVCR", 0x10, 1}, + {snvs_reader, "snvs", "HPSVS", 0x18, 1}, + {snvs_reader, "snvs", "LPSVC", 0x40, 1}, + {snvs_reader, "snvs", "LPTDC", 0x48, 2}, + {snvs_reader, "snvs", "LPSR", 0x4c, 1}, + {snvs_reader, "snvs", "LPTDS", 0xa4, 1}, + {snvs_reader, "snvs", "LPTGFC", 0x44, 3}, + {snvs_reader, "snvs", "LPATCTL", 0xe0, 1}, + {snvs_reader, "snvs", "LPATCLK", 0xe4, 1}, + {snvs_reader, "snvs", "LPATRC1", 0xe8, 2}, + {snvs_reader, "snvs", "LPMKC", 0x3c, 1}, + {snvs_reader, "snvs", "LPSMC", 0x5c, 2}, + {snvs_reader, "snvs", "LPPGD", 0x64, 1}, + {snvs_reader, "snvs", "HPVID", 0xf8, 2}, + + {snvs_dgo_reader, "dgo", "Offset", 0x0, 1}, + {snvs_dgo_reader, "dgo", "PUP/PD", 0x10, 1}, + {snvs_dgo_reader, "dgo", "Anatest", 0x20, 1}, + {snvs_dgo_reader, "dgo", "T trim", 0x30, 1}, + {snvs_dgo_reader, "dgo", "Misc", 0x40, 1}, + {snvs_dgo_reader, "dgo", "Vmon", 0x50, 1}, +}; + +struct imx_secvio_sc_info_seq_data { + struct device *dev; + const struct imx_secvio_info_entry *list; + int size; +}; + +/** + * imx_secvio_sc_info_seq_start() - Start sequence + * + * @m: seq file + * @pos: position in the sequence + * + * Return pointer on position + */ +static void *imx_secvio_sc_info_seq_start(struct seq_file *m, loff_t *pos) +{ + struct imx_secvio_sc_info_seq_data *data = m->private; + + /* Check we are not out of bound */ + if (*pos >= data->size) + return NULL; + + return (void *)pos; +} + +/** + * imx_secvio_sc_info_seq_next() - Iterate sequence + * + * @m: seq file + * @v: pointer + * @pos: position in the sequence + * + * Return pointer on position + */ +static void *imx_secvio_sc_info_seq_next(struct seq_file *m, void *v, loff_t *pos) +{ + /* Increment the counter */ + ++*pos; + + /* call the start function which will check the index */ + return imx_secvio_sc_info_seq_start(m, pos); +} + +/** + * imx_secvio_sc_info_seq_stop() - Stop sequence + * + * @m: seq file + * @v: pointer + */ +static void imx_secvio_sc_info_seq_stop(struct seq_file *m, void *v) +{ +} + +/** + * imx_secvio_sc_info_seq_show() - Show the item in the sequence + * + * @m: seq file + * @v: pointer + * @pos: position in the sequence + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int imx_secvio_sc_info_seq_show(struct seq_file *m, void *v) +{ + struct imx_secvio_sc_info_seq_data *data = m->private; + const struct imx_secvio_info_entry *e; + int ret; + u32 vals[5]; + int idx; + + idx = *(loff_t *)v; + e = &data->list[idx]; + + /* Read the values */ + ret = e->reader(data->dev, e->id, (u32 *)&vals, e->mul); + if (ret) { + dev_err(data->dev, "Fail to read %s %s (idx %d)\n", e->type, + e->name, e->id); + return 0; + } + + seq_printf(m, "%5s/%-10s(%.3d):", e->type, e->name, e->id); + + /* Loop over the values */ + for (idx = 0; idx < e->mul; idx++) + seq_printf(m, " %.8x", vals[idx]); + + seq_puts(m, "\n"); + + return 0; +} + +static const struct seq_operations imx_secvio_sc_info_seq_ops = { + .start = imx_secvio_sc_info_seq_start, + .next = imx_secvio_sc_info_seq_next, + .stop = imx_secvio_sc_info_seq_stop, + .show = imx_secvio_sc_info_seq_show, +}; + +/** + * imx_secvio_sc_info_open() - Store node info for ioctl + * + * @inode: inode + * @file: file used to perform the ioctl + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int imx_secvio_sc_info_open(struct inode *inode, struct file *file) +{ + struct imx_secvio_sc_info_seq_data *data; + + data = __seq_open_private(file, &imx_secvio_sc_info_seq_ops, sizeof(*data)); + if (!data) + return -ENOMEM; + + data->dev = inode->i_private; + data->list = gs_imx_secvio_info_list; + data->size = ARRAY_SIZE(gs_imx_secvio_info_list); + + return 0; +} + +static const struct file_operations imx_secvio_sc_info_ops = { + .owner = THIS_MODULE, + .open = imx_secvio_sc_info_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release_private, +}; + +/** + * if_debugfs_remove_recursive() - Wrapper for debugfs_remove_recursive + * + * Can be used with devm + * + * @dentry: directory entry + */ +static void if_debugfs_remove_recursive(void *dentry) +{ + debugfs_remove_recursive(dentry); +} + +/** + * imx_secvio_sc_debugfs() - Create the debugfs + * + * @dev: secvio device + * + * Return: + * 0 - OK + * < 0 - error. + */ +int imx_secvio_sc_debugfs(struct device *dev) +{ + struct imx_secvio_sc_data *data = dev_get_drvdata(dev); + struct dentry *dir; + int ret = 0; + + /* Create a folder */ + dir = debugfs_create_dir(dev_name(dev), NULL); + if (IS_ERR(dir)) { + dev_err(dev, "Failed to create dfs dir\n"); + ret = PTR_ERR(dir); + goto exit; + } + data->dfs = dir; + + ret = devm_add_action(dev, if_debugfs_remove_recursive, data->dfs); + if (ret) { + dev_err(dev, "Failed to add managed action to disable IRQ\n"); + goto remove_fs; + } + + /* Create the file to read info and write to reg */ + dir = debugfs_create_file("info", 0x666, data->dfs, dev, + &imx_secvio_sc_info_ops); + if (IS_ERR(dir)) { + dev_err(dev, "Failed to add info to debugfs\n"); + ret = PTR_ERR(dir); + goto exit; + } + + goto exit; + +remove_fs: + debugfs_remove_recursive(data->dfs); + +exit: + return ret; +} diff --git a/drivers/soc/imx/secvio/imx-secvio-sc-int.h b/drivers/soc/imx/secvio/imx-secvio-sc-int.h new file mode 100644 index 0000000..54de7fa --- /dev/null +++ b/drivers/soc/imx/secvio/imx-secvio-sc-int.h @@ -0,0 +1,84 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019-2020 NXP + */ + +#ifndef SECVIO_SC_H +#define SECVIO_SC_H + +/* Includes */ +#include +#include +#include +#include +#include + +/* Access for sc_seco_secvio_config API */ +#define SECVIO_CONFIG_READ 0 +#define SECVIO_CONFIG_WRITE 1 + +/* Internal Structure */ +struct imx_secvio_sc_data { + struct device *dev; + + struct imx_sc_ipc *ipc_handle; + + struct notifier_block irq_nb; + struct notifier_block report_nb; + struct notifier_block audit_nb; + + struct nvmem_device *nvmem; + + struct miscdevice miscdev; + +#ifdef CONFIG_DEBUG_FS + struct dentry *dfs; +#endif + + u32 version; +}; + +/** + * call_secvio_config() - Wrapper for imx_sc_seco_secvio_config() + * + * @dev: secvio device + * @id: ID of the register, ie the offset of the first register of the set + * @access: Write (1) or Read (0) the registers + * @data0: Data for the first register + * @data1: Data for the second register + * @data2: Data for the third register + * @data3: Data for the fourth register + * @data4: Data for the fifth register + * @size: Number of register to configure + * + * Return: + * 0 - OK + * < 0 - error. + */ +int call_secvio_config(struct device *dev, u8 id, u8 access, u32 *data0, + u32 *data1, u32 *data2, u32 *data3, u32 *data4, u8 size); + +#ifdef CONFIG_DEBUG_FS +extern +int imx_secvio_sc_debugfs(struct device *dev); +#else +static inline +int imx_secvio_sc_debugfs(struct device *dev) +{ + return 0; +} +#endif /* CONFIG_DEBUG_FS */ + +#ifdef CONFIG_AUDIT +int report_to_audit_notify(struct notifier_block *nb, unsigned long status, + void *notif_info); +#else /* CONFIG_AUDIT */ +static inline +int report_to_audit_notify(struct notifier_block *nb, unsigned long status, + void *notif_info) +{ + return 0; +} +#endif /* CONFIG_AUDIT */ + +#endif /* SECVIO_SC_H */ diff --git a/drivers/soc/imx/secvio/imx-secvio-sc.c b/drivers/soc/imx/secvio/imx-secvio-sc.c new file mode 100644 index 0000000..1e0d6aa --- /dev/null +++ b/drivers/soc/imx/secvio/imx-secvio-sc.c @@ -0,0 +1,858 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019-2020 NXP + */ + +/* + * The SoC of the i.MX8 family contains a hardware block called SNVS + * (Secure Non-Volatile Storage). + * + * The i.MX8 (QM/QXP/DXL) SoC contains the (SNVS) block. This + * block can detect specific hardware attacks. Due to the presence of the SECO, + * this block can only be accessible using the SCFW API. + * + * This module interacts with the SCU which relays request to/from the SNVS block + * to detect if security violation occurred. + * + * The module exports an API to add processing when a SV is detected: + * - register_imx_secvio_sc_notifier + * - unregister_imx_secvio_sc_notifier + * - imx_secvio_sc_check_state + * - int_imx_secvio_sc_clear_state + * - imx_secvio_sc_enable_irq + * - imx_secvio_sc_disable_irq + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include "imx-secvio-sc-int.h" + +/* Definitions */ +static int int_imx_secvio_sc_enable_irq(struct device *dev); +static int int_imx_secvio_sc_disable_irq(struct device *dev); + +/* Reference on the driver_device */ +static struct device *gs_imx_secvio_sc_dev; + +/* Register IDs for sc_seco_secvio_config API */ +#define HPSVS_ID 0x18 +#define LPS_ID 0x4c +#define LPTDS_ID 0xa4 +#define HPVIDR_ID 0xf8 + +#define SECO_MINOR_VERSION_SUPPORT_SECVIO_TAMPER 0x53 +#define SECO_VERSION_MINOR_MASK GENMASK(15, 0) + +/* Notifier list for new CB */ +static BLOCKING_NOTIFIER_HEAD(imx_secvio_sc_notifier_chain); + +/** + * register_imx_secvio_sc_notifier() - Add function to secvio call chain + * + * @nb: notifier block of the function to add + * + * Return: + * 0 - OK + * < 0 - error. + */ +int register_imx_secvio_sc_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register(&imx_secvio_sc_notifier_chain, + nb); +} +EXPORT_SYMBOL(register_imx_secvio_sc_notifier); + +/** + * unregister_imx_secvio_sc_notifier() - Remove function to secvio call chain + * + * @nb: notifier block of the function to add + * + * Return: + * 0 - OK + * < 0 - error. + */ +int unregister_imx_secvio_sc_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister(&imx_secvio_sc_notifier_chain, + nb); +} +EXPORT_SYMBOL(unregister_imx_secvio_sc_notifier); + +/** + * if_imx_scu_irq_register_notifier() - Wrapper for imx_scu_irq_register_notifier + * + * Can be used for devm actions + * + * @nb: notifier block of the function to add + */ +static void if_unregister_imx_secvio_sc_notifier(void *nb) +{ + unregister_imx_secvio_sc_notifier(nb); +} + +/** + * imx_secvio_sc_notifier_call_chain() - Call secvio notifier chain + * + * @info: The structure containing the info to pass to notified functions + * + * Return: + * 0 - OK + * < 0 - error. + */ +static +int imx_secvio_sc_notifier_call_chain(struct secvio_sc_notifier_info *info) +{ + return blocking_notifier_call_chain(&imx_secvio_sc_notifier_chain, 0, + (void *)info); +} + +int call_secvio_config(struct device *dev, u8 id, u8 access, u32 *data0, + u32 *data1, u32 *data2, u32 *data3, u32 *data4, u8 size) +{ + int ret = 0; + struct imx_secvio_sc_data *data; + + data = dev_get_drvdata(dev); + + ret = imx_sc_seco_secvio_config(data->ipc_handle, id, access, data0, + data1, data2, data3, data4, size); + if (ret) + dev_err(dev, "Fail %s secvio config %d", + ((access) ? "write" : "read"), ret); + + return ret; +} + +/** + * int_imx_secvio_sc_get_state() - Get the state of secvio and tamper + * + * @dev: secvio device + * @info: The structure to use to store the status + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int int_imx_secvio_sc_get_state(struct device *dev, + struct secvio_sc_notifier_info *info) +{ + struct secvio_sc_notifier_info _info = {0}; + struct secvio_sc_notifier_info *p_info; + int ret = 0, ret2 = 0; + + p_info = info ? info : &_info; + + /* Read secvio status */ + ret = call_secvio_config(dev, HPSVS_ID, SECVIO_CONFIG_READ, + &p_info->hpsvs, NULL, NULL, NULL, NULL, 1); + if (ret) { + ret2 = ret; + dev_warn(dev, "Cannot read secvio status: %d\n", ret); + } + p_info->hpsvs &= HPSVS__ALL_SV__MASK; + + /* Read tampers status */ + ret = call_secvio_config(dev, LPS_ID, SECVIO_CONFIG_READ, + &p_info->lps, NULL, NULL, NULL, NULL, 1); + if (ret) { + ret2 = ret; + dev_warn(dev, "Cannot read tamper 1 status: %d\n", ret); + } + p_info->lps &= LPS__ALL_TP__MASK; + + ret = call_secvio_config(dev, LPTDS_ID, SECVIO_CONFIG_READ, + &p_info->lptds, NULL, NULL, NULL, NULL, 1); + if (ret) { + ret2 = ret; + dev_warn(dev, "Cannot read tamper 2 status: %d\n", ret); + } + p_info->lptds &= LPTDS__ALL_TP__MASK; + + dev_dbg(dev, "Status: %.8x, %.8x, %.8x\n", p_info->hpsvs, + p_info->lps, p_info->lptds); + + return ret2; +} + +/** + * imx_secvio_sc_get_state() - Wrapper for int_imx_secvio_sc_get_state + * + * Return: + * 0 - OK + * < 0 - error. + */ +inline int imx_secvio_sc_get_state(struct secvio_sc_notifier_info *info) +{ + if (!gs_imx_secvio_sc_dev) + return -EOPNOTSUPP; + + return int_imx_secvio_sc_get_state(gs_imx_secvio_sc_dev, info); +} +EXPORT_SYMBOL(imx_secvio_sc_get_state); + +/** + * int_imx_secvio_sc_check_state() - Get the state and call chain of notifier + * if there is a status + * + * @dev: secvio device + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int int_imx_secvio_sc_check_state(struct device *dev) +{ + struct secvio_sc_notifier_info info = {0}; + int ret = 0; + + ret = int_imx_secvio_sc_get_state(dev, &info); + if (ret) { + dev_err(dev, "Failed to get secvio state\n"); + goto exit; + } + + /* Call chain of CB registered to this module if status detected */ + if (info.hpsvs || info.lps || info.lptds) + if (imx_secvio_sc_notifier_call_chain(&info)) + dev_warn(dev, + "Issues when calling the notifier chain\n"); + +exit: + return ret; +} + +/** + * imx_secvio_sc_check_state() - Wrapper for int_imx_secvio_sc_check_state + * + * Return: + * 0 - OK + * < 0 - error. + */ +inline int imx_secvio_sc_check_state(void) +{ + if (!gs_imx_secvio_sc_dev) + return -EOPNOTSUPP; + + return int_imx_secvio_sc_check_state(gs_imx_secvio_sc_dev); +} +EXPORT_SYMBOL(imx_secvio_sc_check_state); + +/** + * imx_secvio_sc_notify() - Process event from SCU + * + * If the event is secvio we check the state, then + * re-enable the IRQ which has been disabled by SCU + * + * @nb: secvio device + * @event: The id of the IRQ received in a group + * @group: The group of the IRQ + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int imx_secvio_sc_notify(struct notifier_block *nb, + unsigned long event, void *group) +{ + struct imx_secvio_sc_data *data = + container_of(nb, struct imx_secvio_sc_data, + irq_nb); + struct device *dev = data->dev; + int ret = 0; + + /* Filter event for us */ + if (!((event & IMX_SC_IRQ_SECVIO) && + (*(u8 *)group == IMX_SC_IRQ_GROUP_WAKE))) + goto exit; + + dev_warn(dev, "secvio security violation detected\n"); + + ret = int_imx_secvio_sc_check_state(dev); + + /* Re-enable interrupt */ + ret = int_imx_secvio_sc_enable_irq(dev); + if (ret) + dev_err(dev, "Failed to enable IRQ\n"); + +exit: + return ret; +} + +/** + * int_imx_secvio_sc_clear_state() - Clear secvio and tamper state + * + * @dev: secvio device + * @hpsvs: high power security violation status to clear + * @lps: low power status to clear + * @lptds: low power tamper detector status to clear + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int int_imx_secvio_sc_clear_state(struct device *dev, u32 hpsvs, u32 lps, + u32 lptds) +{ + int ret = 0; + + ret = call_secvio_config(dev, HPSVS_ID, SECVIO_CONFIG_WRITE, &hpsvs, + NULL, NULL, NULL, NULL, 1); + if (ret) { + dev_err(dev, "Cannot clear secvio status: %d\n", ret); + goto exit; + } + + ret = call_secvio_config(dev, LPS_ID, SECVIO_CONFIG_WRITE, &lps, NULL, + NULL, NULL, NULL, 1); + if (ret) { + dev_err(dev, "Cannot clear tamper 1 status: %d\n", ret); + goto exit; + } + + ret = call_secvio_config(dev, LPTDS_ID, SECVIO_CONFIG_WRITE, &lptds, + NULL, NULL, NULL, NULL, 1); + if (ret) { + dev_err(dev, "Cannot clear tamper 2 status: %d\n", ret); + goto exit; + } + +exit: + return ret; +} + +/** + * imx_secvio_sc_clear_state() - Wrapper for imx_secvio_sc_clear_state + * + * @hpsvs: high power security violation status to clear + * @lps: low power status to clear + * @lptds: low power tamper detector status to clear + * + * Return: + * 0 - OK + * < 0 - error. + */ +inline int imx_secvio_sc_clear_state(u32 hpsvs, u32 lps, u32 lptds) +{ + if (!gs_imx_secvio_sc_dev) + return -EOPNOTSUPP; + + return int_imx_secvio_sc_clear_state(gs_imx_secvio_sc_dev, hpsvs, lps, + lptds); +} +EXPORT_SYMBOL(imx_secvio_sc_clear_state); + +/** + * report_to_user_notify() - Print to console the status + * + * @nb: notifier block + * @status: error code + * @notif_info: Pointer on structure containing the status of the secvio and + * tampers + * + * Return: + * 0 - OK + */ +static int report_to_user_notify(struct notifier_block *nb, + unsigned long status, void *notif_info) +{ + struct secvio_sc_notifier_info *info = notif_info; + struct imx_secvio_sc_data *data = + container_of(nb, struct imx_secvio_sc_data, + report_nb); + struct device *dev = data->dev; + + /* Information about the security violation */ + if (info->hpsvs & HPSVS__LP_SEC_VIO__MASK) + dev_info(dev, "SNVS secvio: LPSV\n"); + if (info->hpsvs & HPSVS__SW_LPSV__MASK) + dev_info(dev, "SNVS secvio: SW LPSV\n"); + if (info->hpsvs & HPSVS__SW_FSV__MASK) + dev_info(dev, "SNVS secvio: SW FSV\n"); + if (info->hpsvs & HPSVS__SW_SV__MASK) + dev_info(dev, "SNVS secvio: SW SV\n"); + if (info->hpsvs & HPSVS__SV5__MASK) + dev_info(dev, "SNVS secvio: SV 5\n"); + if (info->hpsvs & HPSVS__SV4__MASK) + dev_info(dev, "SNVS secvio: SV 4\n"); + if (info->hpsvs & HPSVS__SV3__MASK) + dev_info(dev, "SNVS secvio: SV 3\n"); + if (info->hpsvs & HPSVS__SV2__MASK) + dev_info(dev, "SNVS secvio: SV 2\n"); + if (info->hpsvs & HPSVS__SV1__MASK) + dev_info(dev, "SNVS secvio: SV 1\n"); + if (info->hpsvs & HPSVS__SV0__MASK) + dev_info(dev, "SNVS secvio: SV 0\n"); + + /* Information about the tampers */ + if (info->lps & LPS__ESVD__MASK) + dev_info(dev, "SNVS tamper: External SV\n"); + if (info->lps & LPS__ET2D__MASK) + dev_info(dev, "SNVS tamper: Tamper 2\n"); + if (info->lps & LPS__ET1D__MASK) + dev_info(dev, "SNVS tamper: Tamper 1\n"); + if (info->lps & LPS__WMT2D__MASK) + dev_info(dev, "SNVS tamper: Wire Mesh 2\n"); + if (info->lps & LPS__WMT1D__MASK) + dev_info(dev, "SNVS tamper: Wire Mesh 1\n"); + if (info->lps & LPS__VTD__MASK) + dev_info(dev, "SNVS tamper: Voltage\n"); + if (info->lps & LPS__TTD__MASK) + dev_info(dev, "SNVS tamper: Temperature\n"); + if (info->lps & LPS__CTD__MASK) + dev_info(dev, "SNVS tamper: Clock\n"); + if (info->lps & LPS__PGD__MASK) + dev_info(dev, "SNVS tamper: Power Glitch\n"); + if (info->lps & LPS__MCR__MASK) + dev_info(dev, "SNVS tamper: Monotonic Counter rollover\n"); + if (info->lps & LPS__SRTCR__MASK) + dev_info(dev, "SNVS tamper: Secure RTC rollover\n"); + if (info->lps & LPS__LPTA__MASK) + dev_info(dev, "SNVS tamper: Time alarm\n"); + + if (info->lptds & LPTDS__ET10D__MASK) + dev_info(dev, "SNVS tamper: Tamper 10\n"); + if (info->lptds & LPTDS__ET9D__MASK) + dev_info(dev, "SNVS tamper: Tamper 9\n"); + if (info->lptds & LPTDS__ET8D__MASK) + dev_info(dev, "SNVS tamper: Tamper 8\n"); + if (info->lptds & LPTDS__ET7D__MASK) + dev_info(dev, "SNVS tamper: Tamper 7\n"); + if (info->lptds & LPTDS__ET6D__MASK) + dev_info(dev, "SNVS tamper: Tamper 6\n"); + if (info->lptds & LPTDS__ET5D__MASK) + dev_info(dev, "SNVS tamper: Tamper 5\n"); + if (info->lptds & LPTDS__ET4D__MASK) + dev_info(dev, "SNVS tamper: Tamper 4\n"); + if (info->lptds & LPTDS__ET3D__MASK) + dev_info(dev, "SNVS tamper: Tamper 3\n"); + + return 0; +} + +/** + * int_imx_secvio_sc_enable_irq() - Enable the secvio IRQ in SCU + * + * @dev: secvio device + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int int_imx_secvio_sc_enable_irq(struct device *dev) +{ + int ret = 0, ret2; + u32 irq_status; + struct imx_secvio_sc_data *data; + + data = dev_get_drvdata(dev); + + /* Enable the IRQ */ + ret = imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_WAKE, IMX_SC_IRQ_SECVIO, + true); + if (ret) { + dev_err(dev, "Cannot enable SCU IRQ: %d\n", ret); + goto exit; + } + + /* Enable interrupt */ + ret = imx_sc_seco_secvio_enable(data->ipc_handle); + if (ret) { + dev_err(dev, "Cannot enable SNVS irq: %d\n", ret); + goto exit; + }; + + /* Unmask interrupt */ + ret = imx_scu_irq_get_status(IMX_SC_IRQ_GROUP_WAKE, &irq_status); + if (ret) { + dev_err(dev, "Cannot unmask irq: %d\n", ret); + goto exit; + }; + +exit: + if (ret) { + ret2 = int_imx_secvio_sc_disable_irq(dev); + if (ret2) + dev_warn(dev, "Failed to disable the IRQ\n"); + } + + return ret; +} + +/** + * int_imx_secvio_sc_disable_irq() - Disable secvio IRQ + * + * @dev: secvio device + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int int_imx_secvio_sc_disable_irq(struct device *dev) +{ + int ret = 0; + struct imx_secvio_sc_data *data; + + data = dev_get_drvdata(dev); + + /* Disable the IRQ */ + ret = imx_scu_irq_group_enable(IMX_SC_IRQ_GROUP_WAKE, IMX_SC_IRQ_SECVIO, + false); + if (ret) { + dev_err(dev, "Cannot disable SCU IRQ: %d\n", ret); + return ret; + } + + return 0; +} + +/** + * if_imx_secvio_sc_disable_irq() - Wrapper for int_imx_secvio_sc_disable_irq + * + * Can be used with devm + * + * @dev: secvio device + */ +static void if_imx_secvio_sc_disable_irq(void *dev) +{ + int_imx_secvio_sc_disable_irq(dev); +} + +/** + * imx_secvio_sc_open() - Store node info for ioctl + * + * @node: inode + * @file: file used to perform the ioctl + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int imx_secvio_sc_open(struct inode *node, struct file *filp) +{ + filp->private_data = node->i_private; + + return 0; +} + +/** + * imx_secvio_sc_ioctl() - IOCTL handler for the driver + * + * @file: file used to perform the ioctl + * @cmd: command to perform + * @arg: Pointer on structure with info for the command + * + * Return: + * 0 - OK + * < 0 - error. + */ +static long imx_secvio_sc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct device *dev = file->private_data; + struct secvio_sc_notifier_info info; + int ret; + + switch (cmd) { + case IMX_SECVIO_SC_GET_STATE: + ret = int_imx_secvio_sc_get_state(dev, &info); + if (ret) { + dev_err(dev, "Fail to get state\n"); + goto exit; + } + + ret = copy_to_user((void *)arg, &info, sizeof(info)); + if (ret) { + dev_err(dev, "Fail to copy info to user\n"); + ret = -EFAULT; + goto exit; + } + break; + case IMX_SECVIO_SC_CHECK_STATE: + ret = int_imx_secvio_sc_check_state(dev); + if (ret) { + dev_err(dev, "Fail to check state\n"); + goto exit; + } + break; + case IMX_SECVIO_SC_CLEAR_STATE: + ret = copy_from_user(&info, (void *)arg, sizeof(info)); + if (ret) { + dev_err(dev, "Fail to copy info from user\n"); + ret = -EFAULT; + goto exit; + } + + ret = int_imx_secvio_sc_clear_state(dev, info.hpsvs, info.lps, + info.lptds); + if (ret) { + dev_err(dev, "Fail to clear state\n"); + goto exit; + } + break; + default: + ret = -ENOIOCTLCMD; + } + +exit: + return ret; +} + +const static struct file_operations imx_secvio_sc_fops = { + .owner = THIS_MODULE, + .open = imx_secvio_sc_open, + .unlocked_ioctl = imx_secvio_sc_ioctl, +}; + +static void if_misc_deregister(void *miscdevice) +{ + misc_deregister(miscdevice); +} + +static void reset_global_dev(void *dev) +{ + gs_imx_secvio_sc_dev = NULL; +} + +/** + * imx_secvio_sc_setup() - Configure the driver + * + * @dev: secvio device + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int imx_secvio_sc_setup(struct device *dev) +{ + struct imx_secvio_sc_data *data; + u32 seco_version = 0; + bool own_secvio; + u32 irq_status; + int ret = 0; + + if (!devres_open_group(dev, NULL, GFP_KERNEL)) { + ret = -ENOMEM; + goto exit; + } + + /* Allocate private data */ + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + dev_err(dev, "Failed to allocate mem for data\n"); + goto clean; + } + + data->dev = dev; + + dev_set_drvdata(dev, data); + + data->nvmem = devm_nvmem_device_get(dev, NULL); + if (IS_ERR(data->nvmem)) { + ret = PTR_ERR(data->nvmem); + if (ret != -EPROBE_DEFER) + dev_err(dev, "Failed to retrieve nvmem\n"); + + goto clean; + } + + /* Get a handle */ + ret = imx_scu_get_handle(&data->ipc_handle); + if (ret) { + dev_err(dev, "cannot get handle to scu: %d\n", ret); + goto clean; + }; + + /* Check the version of the SECO */ + ret = imx_sc_seco_build_info(data->ipc_handle, &seco_version, NULL); + if (ret) { + dev_err(dev, "Failed to get seco version\n"); + goto clean; + } + + if ((seco_version & SECO_VERSION_MINOR_MASK) < + SECO_MINOR_VERSION_SUPPORT_SECVIO_TAMPER) { + dev_err(dev, "SECO version %.8x doesn't support all secvio\n", + seco_version); + ret = -EOPNOTSUPP; + goto clean; + } + + /* Init debug FS */ + ret = imx_secvio_sc_debugfs(dev); + if (ret) { + dev_err(dev, "Failed to set debugfs\n"); + goto clean; + } + + /* Check we own the SECVIO */ + ret = imx_sc_rm_is_resource_owned(data->ipc_handle, IMX_SC_R_SECVIO); + if (ret < 0) { + dev_err(dev, "Failed to retrieve secvio ownership\n"); + goto clean; + } + + own_secvio = ret > 0; + if (!own_secvio) { + dev_err(dev, "Secvio resource is not owned\n"); + ret = -EPERM; + goto clean; + } + + /* Check IRQ exists and enable it */ + ret = imx_scu_irq_get_status(IMX_SC_IRQ_GROUP_WAKE, &irq_status); + if (ret) { + dev_err(dev, "Cannot get IRQ state: %d\n", ret); + goto clean; + } + + ret = int_imx_secvio_sc_enable_irq(dev); + if (ret) { + dev_err(dev, "Failed to enable IRQ\n"); + goto clean; + } + + ret = devm_add_action_or_reset(dev, if_imx_secvio_sc_disable_irq, dev); + if (ret) { + dev_err(dev, "Failed to add managed action to disable IRQ\n"); + goto clean; + } + + /* Register the notifier for IRQ from SNVS */ + data->irq_nb.notifier_call = imx_secvio_sc_notify; + ret = imx_scu_irq_register_notifier(&data->irq_nb); + if (ret) { + dev_err(dev, "Failed to register IRQ notification handler\n"); + goto clean; + } + + ret = devm_add_action_or_reset(dev, if_unregister_imx_secvio_sc_notifier, + &data->irq_nb); + if (ret) { + dev_err(dev, "Failed to add action to remove irq notify\n"); + goto clean; + } + + /* Register the notification for reporting to user */ + data->report_nb.notifier_call = report_to_user_notify; + ret = register_imx_secvio_sc_notifier(&data->report_nb); + if (ret) { + dev_err(dev, "Failed to register report notify handler\n"); + goto clean; + } + + ret = devm_add_action_or_reset(dev, if_unregister_imx_secvio_sc_notifier, + &data->report_nb); + if (ret) { + dev_err(dev, "Failed to add action to remove report notify\n"); + goto clean; + } + + /* Register the notification to report to audit FW */ + data->audit_nb.notifier_call = report_to_audit_notify; + ret = register_imx_secvio_sc_notifier(&data->audit_nb); + if (ret) { + dev_err(dev, "Failed to register report audit handler\n"); + goto clean; + } + + ret = devm_add_action(dev, if_unregister_imx_secvio_sc_notifier, + &data->audit_nb); + if (ret) { + dev_err(dev, "Failed to add action to remove audit notif\n"); + goto clean; + } + + /* Register misc device for IOCTL */ + data->miscdev.name = devm_kstrdup(dev, "secvio-sc", GFP_KERNEL); + data->miscdev.minor = MISC_DYNAMIC_MINOR; + data->miscdev.fops = &imx_secvio_sc_fops; + data->miscdev.parent = dev; + ret = misc_register(&data->miscdev); + if (ret) { + dev_err(dev, "failed to register misc device\n"); + goto exit; + } + + ret = devm_add_action_or_reset(dev, if_misc_deregister, &data->miscdev); + if (ret) { + dev_err(dev, "Failed to add action to unregister miscdev\n"); + goto clean; + } + + gs_imx_secvio_sc_dev = dev; + ret = devm_add_action_or_reset(dev, reset_global_dev, dev); + if (ret) { + dev_err(dev, "Failed to add action to disable global dev\n"); + goto clean; + } + + /* Process current state of the secvio and tampers */ + int_imx_secvio_sc_check_state(dev); + + devres_remove_group(dev, NULL); + + goto exit; + +clean: + devres_release_group(dev, NULL); + +exit: + return ret; +} + +/** + * imx_secvio_sc_probe() - Probe the driver + * + * @pdev: platform device + * + * Return: + * 0 - OK + * < 0 - error. + */ +static int imx_secvio_sc_probe(struct platform_device *pdev) +{ + int ret; + struct device *dev = &pdev->dev; + + ret = imx_secvio_sc_setup(dev); + if (ret && ret != -EPROBE_DEFER) + dev_err(dev, "Failed to setup\n"); + + return ret; +} + +static const struct of_device_id imx_secvio_sc_dt_ids[] = { + { .compatible = "fsl,imx-sc-secvio", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, imx_secvio_sc_dt_ids); + +static struct platform_driver imx_secvio_sc_driver = { + .driver = { + .owner = THIS_MODULE, + .name = "imx-secvio-sc", + .of_match_table = imx_secvio_sc_dt_ids, + }, + .probe = imx_secvio_sc_probe, +}; +module_platform_driver(imx_secvio_sc_driver); + +MODULE_AUTHOR("Franck LENORMAND "); +MODULE_DESCRIPTION("NXP i.MX driver to handle SNVS secvio irq sent by SCFW"); +MODULE_LICENSE("GPL"); diff --git a/include/soc/imx/imx-secvio-sc.h b/include/soc/imx/imx-secvio-sc.h new file mode 100644 index 0000000..a26e2ff --- /dev/null +++ b/include/soc/imx/imx-secvio-sc.h @@ -0,0 +1,177 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2019-2020 NXP + */ + +#ifndef _MISC_IMX_SECVIO_SC_H_ +#define _MISC_IMX_SECVIO_SC_H_ + +#include +#include + +/* Bitmask of the security violation status bit in the HPSVS register */ +#define HPSVS__LP_SEC_VIO__MASK BIT(31) +#define HPSVS__SW_LPSV__MASK BIT(15) +#define HPSVS__SW_FSV__MASK BIT(14) +#define HPSVS__SW_SV__MASK BIT(13) +#define HPSVS__SV5__MASK BIT(5) +#define HPSVS__SV4__MASK BIT(4) +#define HPSVS__SV3__MASK BIT(3) +#define HPSVS__SV2__MASK BIT(2) +#define HPSVS__SV1__MASK BIT(1) +#define HPSVS__SV0__MASK BIT(0) + +/* Bitmask of all security violation status bit in the HPSVS register */ +#define HPSVS__ALL_SV__MASK (HPSVS__LP_SEC_VIO__MASK | \ + HPSVS__SW_LPSV__MASK | \ + HPSVS__SW_FSV__MASK | \ + HPSVS__SW_SV__MASK | \ + HPSVS__SV5__MASK | \ + HPSVS__SV4__MASK | \ + HPSVS__SV3__MASK | \ + HPSVS__SV2__MASK | \ + HPSVS__SV1__MASK | \ + HPSVS__SV0__MASK) + +/* + * Bitmask of the security violation and tampers status bit in the LPS register + */ +#define LPS__ESVD__MASK BIT(16) +#define LPS__ET2D__MASK BIT(10) +#define LPS__ET1D__MASK BIT(9) +#define LPS__WMT2D__MASK BIT(8) +#define LPS__WMT1D__MASK BIT(7) +#define LPS__VTD__MASK BIT(6) +#define LPS__TTD__MASK BIT(5) +#define LPS__CTD__MASK BIT(4) +#define LPS__PGD__MASK BIT(3) +#define LPS__MCR__MASK BIT(2) +#define LPS__SRTCR__MASK BIT(1) +#define LPS__LPTA__MASK BIT(0) + +/* + * Bitmask of all security violation and tampers status bit in the LPS register + */ +#define LPS__ALL_TP__MASK (LPS__ESVD__MASK | \ + LPS__ET2D__MASK | \ + LPS__ET1D__MASK | \ + LPS__WMT2D__MASK | \ + LPS__WMT1D__MASK | \ + LPS__VTD__MASK | \ + LPS__TTD__MASK | \ + LPS__CTD__MASK | \ + LPS__PGD__MASK | \ + LPS__MCR__MASK | \ + LPS__SRTCR__MASK | \ + LPS__LPTA__MASK) + +/* + * Bitmask of the security violation and tampers status bit in the LPTDS + * register + */ +#define LPTDS__ET10D__MASK BIT(7) +#define LPTDS__ET9D__MASK BIT(6) +#define LPTDS__ET8D__MASK BIT(5) +#define LPTDS__ET7D__MASK BIT(4) +#define LPTDS__ET6D__MASK BIT(3) +#define LPTDS__ET5D__MASK BIT(2) +#define LPTDS__ET4D__MASK BIT(1) +#define LPTDS__ET3D__MASK BIT(0) + +/* + * Bitmask of all security violation and tampers status bit in the LPTDS + * register + */ +#define LPTDS__ALL_TP__MASK (LPTDS__ET10D__MASK | \ + LPTDS__ET9D__MASK | \ + LPTDS__ET8D__MASK | \ + LPTDS__ET7D__MASK | \ + LPTDS__ET6D__MASK | \ + LPTDS__ET5D__MASK | \ + LPTDS__ET4D__MASK | \ + LPTDS__ET3D__MASK) + +/** + * struct secvio_sc_notifier_info - Information about the status of the SNVS + * @hpsvs: status from register HPSVS + * @lps: status from register LPS + * @lptds: status from register LPTDS + */ +struct secvio_sc_notifier_info { + u32 hpsvs; + u32 lps; + u32 lptds; +}; + +/** + * register_imx_secvio_sc_notifier() - Register a notifier + * + * @nb: The notifier block structure + * + * Register a function to notify to the imx-secvio-sc module. The function + * will be notified when a check of the state of the SNVS happens: called by + * a user or triggered by an interruption form the SNVS. + * + * The struct secvio_sc_notifier_info is passed as data to the notifier. + * + * Return: 0 in case of success + */ +int register_imx_secvio_sc_notifier(struct notifier_block *nb); + +/** + * unregister_imx_secvio_sc_notifier() - Unregister a notifier + * + * @nb: The notifier block structure + * + * Return: 0 in case of success + */ +int unregister_imx_secvio_sc_notifier(struct notifier_block *nb); + +/** + * imx_secvio_sc_get_state() - Get the state of the SNVS + * + * @info: The structure containing the state of the SNVS + * + * Return: 0 in case of success + */ +int imx_secvio_sc_get_state(struct secvio_sc_notifier_info *info); + +/** + * imx_secvio_sc_check_state() - Check the state of the SNVS + * + * If a security violation or a tamper is detected, the list of notifier + * (registered using register_imx_secvio_sc_notifier() ) will be called + * + * Return: 0 in case of success + */ +int imx_secvio_sc_check_state(void); + +/** + * imx_secvio_sc_clear_state() - Clear the state of the SNVS + * + * @hpsvs: Value to write to HPSVS register + * @lps: Value to write to LPS register + * @lptds: Value to write to LPTDSregister + * + * The function will write the value provided to the corresponding register + * which will clear the status of the bits set. + * + * Return: 0 in case of success + */ +int imx_secvio_sc_clear_state(u32 hpsvs, u32 lps, u32 lptds); + +/* Commands of the ioctl interface */ +enum ioctl_cmd_t { + GET_STATE, + CHECK_STATE, + CLEAR_STATE, +}; + +/* Definition for the ioctl interface */ +#define IMX_SECVIO_SC_GET_STATE _IOR('S', GET_STATE, \ + struct secvio_sc_notifier_info) +#define IMX_SECVIO_SC_CHECK_STATE _IO('S', CHECK_STATE) +#define IMX_SECVIO_SC_CLEAR_STATE _IOW('S', CLEAR_STATE, \ + struct secvio_sc_notifier_info) + +#endif /* _MISC_IMX_SECVIO_SC_H_ */