From patchwork Fri Aug 23 09:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13774774 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2080.outbound.protection.outlook.com [40.107.105.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4784C14A4C9; Fri, 23 Aug 2024 08:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403415; cv=fail; b=A4D8wUKsh+yW51d+1ubSOLp7fKzQw7VJWF6ZoXyowF+IojcFByfJ0A0nGuWvzIhtlgJXSYoLXUvSqEtcZNnH/tXpXj0Ze+ajNlrcbbrY2ILNE5rLEAEfvySPvPAuj6Uec8HWfgqwFufB8fmxtpWT5t4CsPgSjacxsIsEVKOtCo0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403415; c=relaxed/simple; bh=sHQpXEC+RqscEGcLpCkLkqyKaQ0yyOcczWbB6WcuzCs=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=i7NUAb9HgtmPWuOhRo9bfu2sYbYIB7BNBycQOcaxWFyiDFN0bzOcn5AtT3TjgyHKwWWwX/kin5qxFVKtTQ0k6gZcUN7J1g0c6fPCHqLDMCHEpGZHNPDvu9GGRfoH4brQrmrcq3Lnqya6J8r9OerB1ACCWPjDgfKTkxYhbjpGzrY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=QbPyaluo; arc=fail smtp.client-ip=40.107.105.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="QbPyaluo" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uHgxRtyYJcAErnGORUGzgFqOf6Vv8gp9NC8BX432exKQJvxD7TXBQJoBc0i3G1ycnIS5WtcZdLTNFyq93UsWiIFuZZ5HDWFbL/ZhnNgIFeCWPMvcqbnCXikgmtuG4rarVT2M9hVnEDVkHA5k/sFGwqQDRG+SWv6IHW5NV1cm6KolYE2TU6cGf37kg1YbrUj9GrUDSJVaGORXQ7MvEMkpIOxYS9VQUJh9euT1ZlvfBLZrbzGeFHJC3ZRbvS/8GW+XVw/RuSvzKzRfS05z1O12OSoOEydQbeCMdhLow7t8Of0ORwEUzPJkX5SZKlBk7Ki32EsKGd6yWWViK0gJ+M18VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kfP3fyHgZ67LxyuKCIpPfKfchfag5OlWpJDtUSQOpoY=; b=bfdx0/am60u6N+1ukuiZocfeqcwn1GNBeeetmoF/i4N97RS93nVcfkW8wVG+URVUF7262/+bQccfs4NhZEj+cF5sIgtmQL9NJPk/xjiMaV1UV4XmqwwJkNS5cgYWD8kEM9LBlovBWdRywrwTkP0lbkDTcEGWUXVk6kuRI9VpkSiy81r+2ZddfMo2jf7PDEBZX4ZkMWyIawNLpMG97gP2fDCUdrzQ5LLapVwZy6R0vSnlMuIQV0WgNd9U14B1V+drLtnNcHUUcgqT0wgBbFYHFuAULfii4T0j4I8q7cJgoQCGGqmlBp/7KMeVc/HSuVZ0RBXsiJEoMBNy1S2TmXEJ6A== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kfP3fyHgZ67LxyuKCIpPfKfchfag5OlWpJDtUSQOpoY=; b=QbPyaluo/E1iEEGbERzsrxd78n2eJiTpt6sJR/CtkkkCKEUh1y0iexbrqMmMYyPILGDb3T2mh18xHOJi9h786aUOKnDXzLcuZY1wrZ0q+yyDqe3JjiSL5IOekMNTJAxSLkiUfalGgtVL0DtiRJ0gJl8kz4FPFMwDmWhL4dwj3aHPsmOmKxXoO56d/eYFiBR1tQ7DkzfBs7eKUIKNBAYMGGeh6NJryWqBMzYksSpNHpvRoJjlNswUWiyAyC3UeHqDPflKMTYn6Z3W2Z56FcHiniQZT6cL6in8t+ROyDYpvorfN+IEJ01HJoEsSF7DV7n5D1MvmvOOS670qbniIK6oYA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by PA1PR04MB10892.eurprd04.prod.outlook.com (2603:10a6:102:488::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 08:56:50 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:56:50 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Aug 2024 17:05:17 +0800 Subject: [PATCH v8 1/7] dt-bindings: firmware: add i.MX95 SCMI Extension protocol Message-Id: <20240823-imx95-bbm-misc-v2-v8-1-e600ed9e9271@nxp.com> References: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> In-Reply-To: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724403944; l=3176; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=1UJH5hjLqh4YN/4gw/b+EmkX5IO48u961dXp/hGkojY=; b=M/iZih/4IO5TrsyNqqsq+Nowydss4EhYcCxJbyZs8v/5TAyXw0xtHmppqT7ICwZGq7flX19Dq cx8sNs6NcV8ASzprMEvjusOWVRhPI0RZEUQw3pbH82aILNpxFCxViAS X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0173.apcprd01.prod.exchangelabs.com (2603:1096:4:28::29) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PA1PR04MB10892:EE_ X-MS-Office365-Filtering-Correlation-Id: c7a7253e-7cef-4807-213b-08dcc3518708 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|1800799024|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ZyTTiFrOVlucJ3ICRkji971CikXQ7LA?= =?utf-8?q?uRnfeb4QZmUFwBNUWnSqxCa7ZIUgSFN2ItH9ep0Jl3ojLckx12jtimmZwICH7xdNN?= =?utf-8?q?FGjRD0Bz/257Iz1lRpUUxlH1BZUTk9V5SaJPQK16LNgnQtIZxNErPRjuiqr4OJk13?= =?utf-8?q?s9ljaLquAe0o9Gr9yswd9LdUFx8A78Fhv3aBWhTgTGtg9lq+rKkgp57NScCnfvy9P?= =?utf-8?q?CXsDXTNl0TjAYM6lTQ+Fwbav0+aQy0nrdQPVlf0MBdNqFwaECVbhy0IMXJVRg7Yq6?= =?utf-8?q?uGUPSpPiHYByIAhwQt9CCvhi/i0q2NNhNT1exidHkPLN8Hl7puT44m5LYucnIu5/Y?= =?utf-8?q?g5Eo+MkztYajRyebv2SiBAVmVkX7AWWjJ0jfTXqHBl1yQ3e8e1VI55zMctBhw4Pfq?= =?utf-8?q?YktpY9t0XrL6ph4zYd1bF2mfDgWj7oITFUc3wPqPAFpmoFrIAMX78DZkIbaJ9uzh9?= =?utf-8?q?XvAEpJwauhNfmHg8+ECymw2aKshQSVnLzJyuDQiQR0oDz/Rpgelu8RNptcAymiTxc?= =?utf-8?q?UsYaIgftp1T0941IUxm7JxxjP+mELS3cemMvVwkpp1KjZnizl0r3RCebFBoTEicKd?= =?utf-8?q?tTX90PWBjWOMpKLQQ82TdrPCZZhPp1G/Wp54mLg5YR+VUbMFx+UJZdqDYjehEsD9w?= =?utf-8?q?olLPQ3PxRQRkwNncHpTIm1PT5zmgyW4EG6GCMaieqv1e/OLahzCx86u2HKfe0A3N4?= =?utf-8?q?YiOdl9RG42Ooddu8OlweQ1dNbYpZTY+E3J7PRDi2v+y0pcXk+tlnwYWwKQFRbPwga?= =?utf-8?q?Ja4ksWay91GohTsKkyPY8KDAJF/7Tgs50TC6LVZOgTjVvqooCggYptJKYTrxIr7Qd?= =?utf-8?q?pRoPC/R3H/m2wL8ml1FEw7lGjX9hPKgQcMKRhZSbPogxB9AC+lxE5mkybS7DhYcTd?= =?utf-8?q?3xFaUFtOzeAcSpEdTsMnNJP/fh6Ah6tsoPUWYibTHTS4xtDZII5hKQQJw2j87r30K?= =?utf-8?q?5VUUYQ/3iK7qh9IPdEB6ga1+ipiyZw8G4md0G0PtI5X5zid0rBcs6oE2aHbiWfby+?= =?utf-8?q?BM0m5vCJGJEoljVzglsw8h76AME6PsAKlgVDfUyCXnO40wrbOx+OvZoxn2yZX11tJ?= =?utf-8?q?f6KS48EsHWtXwM/XgV8IU3GPBRXdDg8Qksh5ixewNqqg9jc70MF+sd9z7TZuq0Qur?= =?utf-8?q?8wO7csPjlV0o4x9v/oWQOWQ0htY+to+3iYRSeR/O/btzlrEFxCcX3IsikdT8js5Ap?= =?utf-8?q?MusHCxhZuoLPnNzUoeaPFFHUrtCF496/DcLCYvyNPgsFRDZ3c14l8kQgfCpSD21/e?= =?utf-8?q?MYfQmNPxul2pGMbqkPwJrcxEPxWcSYVf14iU6RrapU4YUkqnOOEB/GRTRQ7AmjHQW?= =?utf-8?q?g9ZfNkmEhLwf?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(376014)(1800799024)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?ut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eUZS89HBhDEdFfjwQrp4wrMYlG+GHFDEnOk?= =?utf-8?q?wVMV6VSrNhH1dr7yBbzf+DwfxsykuCxAMbSdglifGsOfhkSW0FAUD+ddPZx9H8OwR?= =?utf-8?q?Q/IcjQUDh+8PedCsKgzG0Nd2alxnx/f1cdGwNVJRInZNdW8BW0JdCBp3gkE77f3ND?= =?utf-8?q?fJLOz9lceV2sYn9OPDQCzb35CS7wUhWT2Q2hoOoytXdVmLx5rGSH2rJEFVcYCdzUh?= =?utf-8?q?YZjZOdpdhTjfsdevlGPA2vSKuAilbWhBzm0ub+2zwMbkAbfp0rWSvyVdDD697u/Tu?= =?utf-8?q?lrHG4yP8+j2/5FS4uR3aRlNDG/qKa36Ya122wi2Auqx/W/soRUTkKthICrg6r7/wt?= =?utf-8?q?mQwRsb0YASW3nJUt8kqOQszi5yQSGDM+XUy96N3qdxvDYjWZglRLLpFCbeIaOBcYX?= =?utf-8?q?UOmxIa5SR72z4BXBeADQpvb5ngGkn/AF42AL4TNZBtNeBUDzugRiA3tZeU47nzwNO?= =?utf-8?q?oTROSvAMYOIMpgTkeICMryrMFBmAXJAOP64ggZ6qHRvUEX3MsgfQ41TrnA+CX2r55?= =?utf-8?q?IgR5ZyEWuiBG9dS2UhBY7pnpN8E4lT22xlAYZjYaPfx+88ZfiIMaN5oWSl6bEolEA?= =?utf-8?q?VM7CyNy6Z+mAMRLXv2bNcylaVDC4Qm2y9kmmM7b30fPGM9wKi9G7W8KddwqNYeaYU?= =?utf-8?q?IvzzNPh7qqAa?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c7a7253e-7cef-4807-213b-08dcc3518708 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:56:50.6027 (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: DhjlgTBe2y3ASzjlW+gkYHD6vKbHdAE3+LTpLmZTHy/fqvuS9ZPu3aY5/rMto3+N3z21YQMDsXZfN6CMdZ5Qag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10892 From: Peng Fan Add i.MX SCMI Extension protocols bindings for: - Battery Backed Module(BBM) Protocol This contains persistent storage (GPR), an RTC, and the ON/OFF button. The protocol can also provide access to similar functions implemented via external board components. - MISC Protocol. This includes controls that are misc settings/actions that must be exposed from the SM to agents. They are device specific and are usually define to access bit fields in various mix block control modules, IOMUX_GPR, and other GPR/CSR owned by the SM. Reviewed-by: Rob Herring (Arm) Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan --- .../devicetree/bindings/firmware/arm,scmi.yaml | 5 ++- .../bindings/firmware/nxp,imx95-scmi.yaml | 43 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml index 211f5254adf2..54d7d11bfed4 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -22,6 +22,9 @@ description: | [0] https://developer.arm.com/documentation/den0056/latest +anyOf: + - $ref: /schemas/firmware/nxp,imx95-scmi.yaml + properties: $nodename: const: scmi @@ -299,7 +302,7 @@ properties: required: - reg -additionalProperties: false +unevaluatedProperties: false $defs: protocol-node: diff --git a/Documentation/devicetree/bindings/firmware/nxp,imx95-scmi.yaml b/Documentation/devicetree/bindings/firmware/nxp,imx95-scmi.yaml new file mode 100644 index 000000000000..1a95010a546b --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/nxp,imx95-scmi.yaml @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2024 NXP +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/nxp,imx95-scmi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: i.MX95 System Control and Management Interface(SCMI) Vendor Protocols Extension + +maintainers: + - Peng Fan + +properties: + protocol@81: + $ref: '/schemas/firmware/arm,scmi.yaml#/$defs/protocol-node' + unevaluatedProperties: false + + properties: + reg: + const: 0x81 + + protocol@84: + $ref: '/schemas/firmware/arm,scmi.yaml#/$defs/protocol-node' + unevaluatedProperties: false + + properties: + reg: + const: 0x84 + + nxp,ctrl-ids: + description: + Each entry consists of 2 integers, represents the ctrl id and the value + items: + items: + - description: the ctrl id index + enum: [0, 1, 2, 3, 4, 5, 6, 7, 0x8000, 0x8001, 0x8002, 0x8003, + 0x8004, 0x8005, 0x8006, 0x8007] + - description: the value assigned to the ctrl id + minItems: 1 + maxItems: 16 + $ref: /schemas/types.yaml#/definitions/uint32-matrix + +additionalProperties: true From patchwork Fri Aug 23 09:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13774775 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2054.outbound.protection.outlook.com [40.107.22.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A797B142E9D; Fri, 23 Aug 2024 08:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403421; cv=fail; b=AReysXnSewGY6HTAF0vrP7zDd00GDuZgl5qRbi+wye5PoE9zlI2VmHwp4GTTsDNi4X8urRaru4npPhIa4xVa7A76nhscRxVdaa+5cvdmIagddkt1xukVlp7WoBfhDgaVJaCCzWJBYNE70s0wEpKkBvjY/H4l/r0VCguYrZpL/1w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403421; c=relaxed/simple; bh=PrXuLIvp7rHtCjfR6rRXiZGY3IUbYgeIe0OMWEGe+qA=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=qdK3IhTJhL3o33mMCza76LLLaCUEtqIYOKwkNC5YXl7W9p9yWLctqBD6brtsfppCDYdBgIiK3fFUqoUEhYZQ2gkFei8A3q7Pi3PsV+nhBeV2MWSURosNCqr8Mhx2t3rcoDhfdaap2ONVjq0iMopaZT4W5TGkzKObVHf4Sg8Sv/0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=VOJJL+R/; arc=fail smtp.client-ip=40.107.22.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="VOJJL+R/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wbzp9TTCh9xWnntKVjVyapHA7hUuU2AN5SDtY7Px/RBVo/BPgfrNCiqZtnEJzG7U2Sfv+6cek7sw5IoSiAFK3L4ttRrhMWXv/m+s1T6tnnrxw9/OiVLIzKfIQTZZgU1X9mxxrBKY3OH4gGmr0YVv1Gv+daYWVgp3kvoEq8OTndMqD5BBOENkJz8sTsKLuIG3ylbDcxkAJOFAvDBx0xsEQJDOGw6sVhsMV60BLQaXwf6wQrQm3mJjOEPGbr38LpF1kHGnoskvuKhz3WE2mrnlnOBGuZQQPZiXWJaYwjBDN4S35EdcPEdJBDbKsmLBvUmE+ZB3+UvayzOzGap96oFM6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=93Iby0bRJgZa3j0s4ibGUUk5t3AtRn05uBADIkTFaqs=; b=l6QV0yFN2LXTNueL+tC6KnDoX4j5dHs4hmn0vRhxqEBnsAvocmetqDoieJjfN1di8wFt4QS8bCWgDlq5xQRpOSam/A9768kDtQTSHDp4rnLTP4hQQUsorw8wEtw9iNtPgxBeWhHLDa8oPmulANFfQfzud2XB8C0yjHvG6e1y7Q7LXY0OabQW1HgmMEB4n7tvoT34FxOPKtdA0s9JmNDHe9rW8u/OFCk9PY9283QIacMTI3uyRi8b7UCxrcAFUS5KL8o7ijic4hZAwDQvNzLvw5FmAbM2oHR+edkErETP4eyLSgiqEd8zPhJm2EJuDvjEDKONqcw5r6SnQpEtOgWcXw== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=93Iby0bRJgZa3j0s4ibGUUk5t3AtRn05uBADIkTFaqs=; b=VOJJL+R/kdJR2HWMX9NHlnnzIujaa5TqSzbfWg65UF0W/hehksIybopig5oPeR9wn57dpSuFBCy53l0knfD695W4Tw/++kVrNWX7kMu+1FMRXwUP3MXTN8I6UNuD5MRqbIW8c9d6N8vAlnBHIhjeabD1aCGqhXPbMgQOKRuBfK867oMZadYQ9YtezhcJT3s1xx59dW5lk7PzDWrp01SwbmiRmyZvHI5yT8fcB4+EG2Slu4qCi7ca+x7u1OtES2faNtlyABwTJnFHhMuf6voZ1WZos09F/UL2OwWiLd+IDP1w43/q3rJXuCq1e+Uu8fKOS0fvzADXnDFJ3rl/rxPk7A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by PA1PR04MB10892.eurprd04.prod.outlook.com (2603:10a6:102:488::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 08:56:55 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:56:55 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Aug 2024 17:05:18 +0800 Subject: [PATCH v8 2/7] firmware: arm_scmi: add initial support for i.MX BBM protocol Message-Id: <20240823-imx95-bbm-misc-v2-v8-2-e600ed9e9271@nxp.com> References: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> In-Reply-To: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724403944; l=14046; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=v2Js2Zvagh5LoyvFSfyUnRSKey1cPVTbHPUtPegBylM=; b=GDtKbupGOhA/l8V8VJE/scsLcpMYSBr1ttxHADCupPRjxeKX/vhkhZzV1Cs0PKUZkp6StAMhZ qvDiWmUmUZQDo/vSSgQIwSBTxMeT8EzXmZKVJTnXvqYToYhG2xv6UVz X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0173.apcprd01.prod.exchangelabs.com (2603:1096:4:28::29) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PA1PR04MB10892:EE_ X-MS-Office365-Filtering-Correlation-Id: b68227a4-b177-436b-3079-08dcc3518a11 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|1800799024|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4OXTOuDjYXKJABDlAtJOjFy1lDiZrp3?= =?utf-8?q?4+FX6vKZim5/yaFHY/QchZzxbQjUWJYAlKljY3KNg+oGcflWMAuJHZjc7el8gU2Xh?= =?utf-8?q?ZQiacjOdMTdviEUFOjcd6xDN6hCyJOt4l7pBdit/Ep8f2ukgAQt6c2BMtrbmdhCnl?= =?utf-8?q?xQu+TPmqyB7GxLXmDVYT87aMbXHyZLmP3eRabXBreLgTX7wgOXiRz6gmqiJofLijQ?= =?utf-8?q?/ib9N7rZgPhI9GuYg6rqlhx4+URn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I0/xw+X2thLODdj4GRuB?= =?utf-8?q?Vd3Km5JPS+fd82IecLlFAPfyWe7fdDAMUGMaPn26nGrOd+ObijmPWoInXMyWgFAaP?= =?utf-8?q?ywEaWuf+SQV1ts4EQUfqlv1nppuqQoLenv0EEzVteswRNn/fVS34mt0PXvAvibv6O?= =?utf-8?q?fpVssTwbX1Etuq10+xv97JYH7Pe4D7yEUGcEATAfoMtBjm2iAktuBe62XGM4Cz2/q?= =?utf-8?q?/AeszFGG7aixFR1o7hEy+LORAfEJH3qnHCbEPmPuokqAofJ2nfsP7pM=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(376014)(1800799024)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?7JGOKqgTAEUlx+VDgNXTy0lIaVN1?= =?utf-8?q?VOA8n95dlzll4RLnxxlD55ujHkFDLozI1q3SuvMw6A9d/BoBbtpckKiKMbUSOw9LL?= =?utf-8?q?6+IDDIS6uKHvuPadXgA+w2hkRR3/tlrshFjSlaRY/zeV5eYK75eaKvA/1C2b2cMm6?= =?utf-8?q?20I/xfMhKt33cbb+ut+C9rOwLBMMvwLxsAVHcxHTZNXHjAbOA0JOQ+vWg/dyEL9aZ?= =?utf-8?q?lRhwXl3ujcS/3S7r48SOb9q7oharE3ol9VkpCK6QzCPnc6N04POZ388Dx3GYMEbTq?= =?utf-8?q?k1COQx8jgnWTqd4kRdhk1vwS+0TPTkKzRJ/02UCMt6RtOqzH+IPWFP7ZMSpQXBzwm?= =?utf-8?q?v+b5hd69Fe2aBXVm9z1N0GsA/OPDIbEWUdiMaaHgJj/4dlKniNHke8gUZCemw3fMa?= =?utf-8?q?ERaOEMwF9mKu6Bt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4tZqIeJtgDVq8JNtt5Ayq/E05Mqa3KrNNQ+9pglrTCESwfB503s?= =?utf-8?q?sAaYdgGhPpFEGk37Chy109L4oKVtS6rXn27Dpy8zQiNudfiBdh9cbkHIGcUF9Z20x?= =?utf-8?q?lSJmxC5ORGzcbGKA9Mkf6+a9772nXTZBRKjZ6kBsmpWoTpTwIw7owtiayAi3etf2v?= =?utf-8?q?iEU55FZmuJQc2QC8O3Sya5fToUD+wm3kTjjeiUhgRfwztFXqD/qTRzVjM4TZy/OBx?= =?utf-8?q?dSKNjhpM1/j3?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b68227a4-b177-436b-3079-08dcc3518a11 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:56:55.6907 (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: YraZ4w4yIlRjN2NpRxDWrP1NJazEOLJjN52OMD9FuVz0flIYYAoHAciejfist5WgsZormxG9/kFldSjxuSSUxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10892 From: Peng Fan i.MX95 has a battery-backed module(BBM), which has persistent storage (GPR), an RTC, and the ON/OFF button. The System Manager(SM) firmware use SCMI vendor protocol(SCMI BBM) to let agent be able to use GPR, RTC and ON/OFF button. Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/Kconfig | 1 + drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/vendors/imx/Kconfig | 13 + drivers/firmware/arm_scmi/vendors/imx/Makefile | 2 + drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c | 379 +++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 42 +++ 6 files changed, 438 insertions(+) diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig index 67053c1862d1..dabd874641d0 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -70,6 +70,7 @@ config ARM_SCMI_DEBUG_COUNTERS SCMI monitoring. source "drivers/firmware/arm_scmi/transports/Kconfig" +source "drivers/firmware/arm_scmi/vendors/imx/Kconfig" endif #ARM_SCMI_PROTOCOL diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index 9659b7d1b963..9ac81adff567 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -11,6 +11,7 @@ scmi-protocols-y += pinctrl.o scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y) obj-$(CONFIG_ARM_SCMI_PROTOCOL) += transports/ +obj-$(CONFIG_ARM_SCMI_PROTOCOL) += vendors/imx/ obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-module.o diff --git a/drivers/firmware/arm_scmi/vendors/imx/Kconfig b/drivers/firmware/arm_scmi/vendors/imx/Kconfig new file mode 100644 index 000000000000..51ccbd038627 --- /dev/null +++ b/drivers/firmware/arm_scmi/vendors/imx/Kconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0-only +menu "ARM SCMI NXP i.MX Vendor Protocols" + +config IMX_SCMI_BBM_EXT + tristate "i.MX SCMI BBM EXTENSION" + depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) + default y if ARCH_MXC + help + This enables i.MX System BBM control logic which supports RTC + and BUTTON. + + This driver can also be built as a module. +endmenu diff --git a/drivers/firmware/arm_scmi/vendors/imx/Makefile b/drivers/firmware/arm_scmi/vendors/imx/Makefile new file mode 100644 index 000000000000..a7dbdd20dbb9 --- /dev/null +++ b/drivers/firmware/arm_scmi/vendors/imx/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_IMX_SCMI_BBM_EXT) += imx-sm-bbm.o diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c new file mode 100644 index 000000000000..0df7ca135c34 --- /dev/null +++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-bbm.c @@ -0,0 +1,379 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System Control and Management Interface (SCMI) NXP BBM Protocol + * + * Copyright 2024 NXP + */ + +#define pr_fmt(fmt) "SCMI Notifications BBM - " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "../../protocols.h" +#include "../../notify.h" + +#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x10000 + +enum scmi_imx_bbm_protocol_cmd { + IMX_BBM_GPR_SET = 0x3, + IMX_BBM_GPR_GET = 0x4, + IMX_BBM_RTC_ATTRIBUTES = 0x5, + IMX_BBM_RTC_TIME_SET = 0x6, + IMX_BBM_RTC_TIME_GET = 0x7, + IMX_BBM_RTC_ALARM_SET = 0x8, + IMX_BBM_BUTTON_GET = 0x9, + IMX_BBM_RTC_NOTIFY = 0xA, + IMX_BBM_BUTTON_NOTIFY = 0xB, +}; + +#define GET_RTCS_NR(x) le32_get_bits((x), GENMASK(23, 16)) +#define GET_GPRS_NR(x) le32_get_bits((x), GENMASK(15, 0)) + +#define SCMI_IMX_BBM_NOTIFY_RTC_UPDATED BIT(2) +#define SCMI_IMX_BBM_NOTIFY_RTC_ROLLOVER BIT(1) +#define SCMI_IMX_BBM_NOTIFY_RTC_ALARM BIT(0) + +#define SCMI_IMX_BBM_RTC_ALARM_ENABLE_FLAG BIT(0) + +#define SCMI_IMX_BBM_NOTIFY_RTC_FLAG \ + (SCMI_IMX_BBM_NOTIFY_RTC_UPDATED | SCMI_IMX_BBM_NOTIFY_RTC_ROLLOVER | \ + SCMI_IMX_BBM_NOTIFY_RTC_ALARM) + +#define SCMI_IMX_BBM_EVENT_RTC_MASK GENMASK(31, 24) + +struct scmi_imx_bbm_info { + u32 version; + int nr_rtc; + int nr_gpr; +}; + +struct scmi_msg_imx_bbm_protocol_attributes { + __le32 attributes; +}; + +struct scmi_imx_bbm_set_time { + __le32 id; + __le32 flags; + __le32 value_low; + __le32 value_high; +}; + +struct scmi_imx_bbm_get_time { + __le32 id; + __le32 flags; +}; + +struct scmi_imx_bbm_alarm_time { + __le32 id; + __le32 flags; + __le32 value_low; + __le32 value_high; +}; + +struct scmi_msg_imx_bbm_rtc_notify { + __le32 rtc_id; + __le32 flags; +}; + +struct scmi_msg_imx_bbm_button_notify { + __le32 flags; +}; + +struct scmi_imx_bbm_notify_payld { + __le32 flags; +}; + +static int scmi_imx_bbm_attributes_get(const struct scmi_protocol_handle *ph, + struct scmi_imx_bbm_info *pi) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_imx_bbm_protocol_attributes *attr; + + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, sizeof(*attr), &t); + if (ret) + return ret; + + attr = t->rx.buf; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + pi->nr_rtc = GET_RTCS_NR(attr->attributes); + pi->nr_gpr = GET_GPRS_NR(attr->attributes); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_notify(const struct scmi_protocol_handle *ph, + u32 src_id, int message_id, bool enable) +{ + int ret; + struct scmi_xfer *t; + + if (message_id == IMX_BBM_RTC_NOTIFY) { + struct scmi_msg_imx_bbm_rtc_notify *rtc_notify; + + ret = ph->xops->xfer_get_init(ph, message_id, + sizeof(*rtc_notify), 0, &t); + if (ret) + return ret; + + rtc_notify = t->tx.buf; + rtc_notify->rtc_id = cpu_to_le32(0); + rtc_notify->flags = + cpu_to_le32(enable ? SCMI_IMX_BBM_NOTIFY_RTC_FLAG : 0); + } else if (message_id == IMX_BBM_BUTTON_NOTIFY) { + struct scmi_msg_imx_bbm_button_notify *button_notify; + + ret = ph->xops->xfer_get_init(ph, message_id, + sizeof(*button_notify), 0, &t); + if (ret) + return ret; + + button_notify = t->tx.buf; + button_notify->flags = cpu_to_le32(enable ? 1 : 0); + } else { + return -EINVAL; + } + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + return ret; +} + +static enum scmi_imx_bbm_protocol_cmd evt_2_cmd[] = { + IMX_BBM_RTC_NOTIFY, + IMX_BBM_BUTTON_NOTIFY +}; + +static int scmi_imx_bbm_set_notify_enabled(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id, bool enable) +{ + int ret, cmd_id; + + if (evt_id >= ARRAY_SIZE(evt_2_cmd)) + return -EINVAL; + + cmd_id = evt_2_cmd[evt_id]; + ret = scmi_imx_bbm_notify(ph, src_id, cmd_id, enable); + if (ret) + pr_debug("FAIL_ENABLED - evt[%X] dom[%d] - ret:%d\n", + evt_id, src_id, ret); + + return ret; +} + +static void *scmi_imx_bbm_fill_custom_report(const struct scmi_protocol_handle *ph, + u8 evt_id, ktime_t timestamp, + const void *payld, size_t payld_sz, + void *report, u32 *src_id) +{ + const struct scmi_imx_bbm_notify_payld *p = payld; + struct scmi_imx_bbm_notif_report *r = report; + + if (sizeof(*p) != payld_sz) + return NULL; + + if (evt_id == SCMI_EVENT_IMX_BBM_RTC) { + r->is_rtc = true; + r->is_button = false; + r->timestamp = timestamp; + r->rtc_id = le32_get_bits(p->flags, SCMI_IMX_BBM_EVENT_RTC_MASK); + r->rtc_evt = le32_get_bits(p->flags, SCMI_IMX_BBM_NOTIFY_RTC_FLAG); + dev_dbg(ph->dev, "RTC: %d evt: %x\n", r->rtc_id, r->rtc_evt); + *src_id = r->rtc_evt; + } else if (evt_id == SCMI_EVENT_IMX_BBM_BUTTON) { + r->is_rtc = false; + r->is_button = true; + r->timestamp = timestamp; + dev_dbg(ph->dev, "BBM Button\n"); + *src_id = 0; + } else { + WARN_ON_ONCE(1); + return NULL; + } + + return r; +} + +static const struct scmi_event scmi_imx_bbm_events[] = { + { + .id = SCMI_EVENT_IMX_BBM_RTC, + .max_payld_sz = sizeof(struct scmi_imx_bbm_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_bbm_notif_report), + }, + { + .id = SCMI_EVENT_IMX_BBM_BUTTON, + .max_payld_sz = sizeof(struct scmi_imx_bbm_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_bbm_notif_report), + }, +}; + +static const struct scmi_event_ops scmi_imx_bbm_event_ops = { + .set_notify_enabled = scmi_imx_bbm_set_notify_enabled, + .fill_custom_report = scmi_imx_bbm_fill_custom_report, +}; + +static const struct scmi_protocol_events scmi_imx_bbm_protocol_events = { + .queue_sz = SCMI_PROTO_QUEUE_SZ, + .ops = &scmi_imx_bbm_event_ops, + .evts = scmi_imx_bbm_events, + .num_events = ARRAY_SIZE(scmi_imx_bbm_events), + .num_sources = 1, +}; + +static int scmi_imx_bbm_rtc_time_set(const struct scmi_protocol_handle *ph, + u32 rtc_id, u64 sec) +{ + struct scmi_imx_bbm_info *pi = ph->get_priv(ph); + struct scmi_imx_bbm_set_time *cfg; + struct scmi_xfer *t; + int ret; + + if (rtc_id >= pi->nr_rtc) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, IMX_BBM_RTC_TIME_SET, sizeof(*cfg), 0, &t); + if (ret) + return ret; + + cfg = t->tx.buf; + cfg->id = cpu_to_le32(rtc_id); + cfg->flags = 0; + cfg->value_low = cpu_to_le32(lower_32_bits(sec)); + cfg->value_high = cpu_to_le32(upper_32_bits(sec)); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_rtc_time_get(const struct scmi_protocol_handle *ph, + u32 rtc_id, u64 *value) +{ + struct scmi_imx_bbm_info *pi = ph->get_priv(ph); + struct scmi_imx_bbm_get_time *cfg; + struct scmi_xfer *t; + int ret; + + if (rtc_id >= pi->nr_rtc) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, IMX_BBM_RTC_TIME_GET, sizeof(*cfg), + sizeof(u64), &t); + if (ret) + return ret; + + cfg = t->tx.buf; + cfg->id = cpu_to_le32(rtc_id); + cfg->flags = 0; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) + *value = get_unaligned_le64(t->rx.buf); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_rtc_alarm_set(const struct scmi_protocol_handle *ph, + u32 rtc_id, bool enable, u64 sec) +{ + struct scmi_imx_bbm_info *pi = ph->get_priv(ph); + struct scmi_imx_bbm_alarm_time *cfg; + struct scmi_xfer *t; + int ret; + + if (rtc_id >= pi->nr_rtc) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, IMX_BBM_RTC_ALARM_SET, sizeof(*cfg), 0, &t); + if (ret) + return ret; + + cfg = t->tx.buf; + cfg->id = cpu_to_le32(rtc_id); + cfg->flags = enable ? SCMI_IMX_BBM_RTC_ALARM_ENABLE_FLAG : 0; + cfg->value_low = cpu_to_le32(lower_32_bits(sec)); + cfg->value_high = cpu_to_le32(upper_32_bits(sec)); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_button_get(const struct scmi_protocol_handle *ph, u32 *state) +{ + struct scmi_xfer *t; + int ret; + + ret = ph->xops->xfer_get_init(ph, IMX_BBM_BUTTON_GET, 0, sizeof(u32), &t); + if (ret) + return ret; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) + *state = get_unaligned_le32(t->rx.buf); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static const struct scmi_imx_bbm_proto_ops scmi_imx_bbm_proto_ops = { + .rtc_time_get = scmi_imx_bbm_rtc_time_get, + .rtc_time_set = scmi_imx_bbm_rtc_time_set, + .rtc_alarm_set = scmi_imx_bbm_rtc_alarm_set, + .button_get = scmi_imx_bbm_button_get, +}; + +static int scmi_imx_bbm_protocol_init(const struct scmi_protocol_handle *ph) +{ + u32 version; + int ret; + struct scmi_imx_bbm_info *binfo; + + ret = ph->xops->version_get(ph, &version); + if (ret) + return ret; + + dev_info(ph->dev, "NXP SM BBM Version %d.%d\n", + PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); + + binfo = devm_kzalloc(ph->dev, sizeof(*binfo), GFP_KERNEL); + if (!binfo) + return -ENOMEM; + + ret = scmi_imx_bbm_attributes_get(ph, binfo); + if (ret) + return ret; + + return ph->set_priv(ph, binfo, version); +} + +static const struct scmi_protocol scmi_imx_bbm = { + .id = SCMI_PROTOCOL_IMX_BBM, + .owner = THIS_MODULE, + .instance_init = &scmi_imx_bbm_protocol_init, + .ops = &scmi_imx_bbm_proto_ops, + .events = &scmi_imx_bbm_protocol_events, + .supported_version = SCMI_PROTOCOL_SUPPORTED_VERSION, + .vendor_id = "NXP", + .sub_vendor_id = "IMX", +}; +module_scmi_protocol(scmi_imx_bbm); diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h new file mode 100644 index 000000000000..2df2ea0f1809 --- /dev/null +++ b/include/linux/scmi_imx_protocol.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * SCMI Message Protocol driver NXP extension header + * + * Copyright 2024 NXP. + */ + +#ifndef _LINUX_SCMI_NXP_PROTOCOL_H +#define _LINUX_SCMI_NXP_PROTOCOL_H + +#include +#include +#include +#include + +enum scmi_nxp_protocol { + SCMI_PROTOCOL_IMX_BBM = 0x81, +}; + +struct scmi_imx_bbm_proto_ops { + int (*rtc_time_set)(const struct scmi_protocol_handle *ph, u32 id, + uint64_t sec); + int (*rtc_time_get)(const struct scmi_protocol_handle *ph, u32 id, + u64 *val); + int (*rtc_alarm_set)(const struct scmi_protocol_handle *ph, u32 id, + bool enable, u64 sec); + int (*button_get)(const struct scmi_protocol_handle *ph, u32 *state); +}; + +enum scmi_nxp_notification_events { + SCMI_EVENT_IMX_BBM_RTC = 0x0, + SCMI_EVENT_IMX_BBM_BUTTON = 0x1, +}; + +struct scmi_imx_bbm_notif_report { + bool is_rtc; + bool is_button; + ktime_t timestamp; + unsigned int rtc_id; + unsigned int rtc_evt; +}; +#endif From patchwork Fri Aug 23 09:05:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13774776 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2044.outbound.protection.outlook.com [40.107.105.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D81DC14A08F; Fri, 23 Aug 2024 08:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.44 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403426; cv=fail; b=dyai5vluUCInFpQYZutaKJI6x6gVxcJCDZ5UkMGBfLNwHn0DCWpY9wZTP4c9dDFGCM9Gf5tnpYIxqywfy/6HwedyjR2Wv1OWxO7tg4HOlqEqMj+V3OOS0dvRv6hmjLW+O2bX0MWjaalmzgWpws5D/hjtYSlvmrDumlLUJcu94p4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403426; c=relaxed/simple; bh=YzX+egaADaOvLdccNeRElzHXSKX3T40Ex3hk4ikMEtI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=QfM5QXuqa3MASayWeG7/O4Bdp2zGMnBAbxti9dpSC4i2XUbw1hBLCHpecvEguHESvf7Kc9ruCf02iG3TzknS5edOrUBfqqH7zLxM38IvzF/APYtSPTJ4Ahzog7/lODvXgkj4F4Ic9Prcr+ntTpRuswRLLtv0M1wOWdM9JMQlHuw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=OBs3h10f; arc=fail smtp.client-ip=40.107.105.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="OBs3h10f" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B2ODFO3Dz7gEtNdfi4cccNtwf2eCqIV5rbnMKj1DB1eDyyBzPC4F/eZSgHUmYkhtMrMHR0vqBt1d8oGFpJjuqVSqcEZOukhEqko5IAYdUS7HDf6F9A1xYSut/jRBNDasyy7OUdyA/h+OLQ2P/u+6+cg87VXrfnCMZKahAaiQPo2ArF6CmxMSjWUKxKJiMcKZ1+fUraNt5uZMgF6PA8V9Q3MHGvMl7Jyv5hDVL75eHRdjXapTnX7S2tRhbZrosTU2jv1POfHaGQXtyVWVYN6SedaiywQVJGmgFDlqN+l5fJfCGGu09O4pcOhSlGyQyAcmd5oWLXA9QsiF/e9fMKDK0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lKPhPaPubDMB7T0nU+qx5zkB3qjRgawlZplzI8gYwOE=; b=sytRDX4zcztZ1uyqQoouRM+pVOn8+cnrn6i8j6XeZWjSmBtgdxYWjldSvWObnVbZoamUM85zhuIHY6iLOz0Ts9NEZaxOcpisivrYkAkfiocY8sHnouT5XKma0q2QMmwwLbrd/09ZHkDUelVUGB3GD+iEJQqcyzKsxpFkqoU0otLX4Yk+6E9XX5rCOp00+7wzDKvhP0cX9TTFfOM4lvhSNAzunoQym+/Y60SNIeXZ/gKTRaqu0yHer1+/TkgbBEKFageIhNLVBKdHAk08eo1pYH2EVkA3Cca2HiaOYYovADwa/1wMrYVUX71CtDoLqPwLcCZ5KvVHhX5YapWAyl8p2g== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lKPhPaPubDMB7T0nU+qx5zkB3qjRgawlZplzI8gYwOE=; b=OBs3h10f4Bm2pmFM3H9Fvmsp7tRhYj6mReJe8fNGNKebdTgcHr5P3GXJMUc+iPq7BJO1Ch0D7z9AjCthz7rDysTREFn4SBVz1XQv1dVbPa7lu+6Fh3+wQ0RyE4GPLpp75Ey0VELXRMTLucZ9Y0D/s6o+DX+OL5T0p42HjmgqK0EDpZGysVptFLNghXTx3y7vE/xCn/ym3OmP4nDSGjANp1/bf4C1pSR9RQXkauCWfl5CFdRduNTjF0A6zTCx2Q6F1PqPriK6eT7HPXRUQliH2gYe8gkY3QiU4XAG+qVTalUQPtAIryPn16YrVCa5dlOY6LaJ5iTste3UaLv4rUk5gA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by PA1PR04MB10892.eurprd04.prod.outlook.com (2603:10a6:102:488::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 08:57:00 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:57:00 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Aug 2024 17:05:19 +0800 Subject: [PATCH v8 3/7] firmware: arm_scmi: add initial support for i.MX MISC protocol Message-Id: <20240823-imx95-bbm-misc-v2-v8-3-e600ed9e9271@nxp.com> References: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> In-Reply-To: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724403944; l=11659; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=N3sn+AcOHmdt2ArwuyQeJTgG5UtWBpIYOiQIExKZQWY=; b=+bQv8asYhO7Fm7whDpt8aPxtyaIvZsRhrCgVf2JMVI4yIEd1YJxYMc3r2MOfRGtDbJeGGtiR2 qMkfi2CA//eDXwMSmUxZpHuLP8Ylo3QPI/Ax2XG6PuJK09i2HCpSYgs X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0173.apcprd01.prod.exchangelabs.com (2603:1096:4:28::29) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PA1PR04MB10892:EE_ X-MS-Office365-Filtering-Correlation-Id: 53ae84dc-a6af-462e-0e50-08dcc3518d16 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|1800799024|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?jQ3RLRkraqwIFNHtN//1/T8VjAV6JDG?= =?utf-8?q?WG8Im1eb2pS1OaKqLkmBqCznbd3eG0Vb4DfMNHtw9tIFQqsAL4FV6puoLLLC47l8A?= =?utf-8?q?+iWJLo1ATOVtQ+DyDNApmON2hyqzK6eekr438jKK2CQscowvG3GGBuWkiB/PyIh7B?= =?utf-8?q?6tXqjHal09Oh4MFuKOMGViSA7fbpTMmwhN2tiCoR5eBFi8Da8dyCdNbhim1RPXUg3?= =?utf-8?q?oNm5JLhp06Z5lAWvw7845eMYeIGRd0IxvyterkxwB+mhUaORdi6UZXOEbHlzAz+6N?= =?utf-8?q?75q01w5RkFygngZ5fSoHm9Ab4Ir0lxvms6NRSa0a6ZMlNnf15+u2L8pFti5PiMTPb?= =?utf-8?q?nyKxYAhOuFQDq/gcsmGN92vxZWv0FyuY6lIBdrmyGbhnxQ7R6F9pQgbWq1EGgvtao?= =?utf-8?q?MQjmdppkyw63Nr7zssc3u4/8IYaJ+gBpxvO03z0queTiAsooFiCb+iOc2vuLpzXNQ?= =?utf-8?q?y9DpTe9bL6F47I7DziXW0tDNmzjGWc+LVQzmQeFmbxqfsettiugOQgf5OjvHyKLil?= =?utf-8?q?qVK7xhjF3Mf+b7dO81S7bQh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CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(376014)(1800799024)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?JY920e159EuOzIBiMAn1qIxc2qo/?= =?utf-8?q?1s9qHqQ154K3cxaKmUm61GiBVQ3hz0NpAmreSwfYymmDqkHEO0TATx2TLhJuIQY9f?= =?utf-8?q?Nofow2wwslRgO2ebA/Gfv3mw6rQ9NfgcwujwFhrDA3dfINIU13htbvgqkLzkmPu8Y?= =?utf-8?q?Yu1ot8M0ghxIt+qyBLev6aiaffVSYg4ADYcFKaiLESJXp13aj2tJpkNJRGbJgbpnb?= =?utf-8?q?FmRqO5FjE4DlDjSmQuvx3Y7Ze2UH69XRVcueHSJzizTh/Os6Pc7TncsUzNIjwAYvU?= =?utf-8?q?u3HoR8yjt0EZby72LFCVXTY7Ac9ifeevTeqPIGNdUjhvP723boH7qUT97ITW+acZm?= =?utf-8?q?4YhoB20djQzdHpxBYKLJdfCtRUOn8n6ACUIHV5pV2AtXbhDQaawFJRXsIL46HKTcr?= =?utf-8?q?BKZXGinN6bNRHyU91gDa4cpuVvCqhYIGnb/8RY9zaVL3aA9/KoWvvlIjNFVAezHYX?= =?utf-8?q?t/N7+d6MOUmmvt9OGzg6JKVHubqyjCFSpS2QB5HP+oL0ZHHktR56tzFC+QFG66gzY?= =?utf-8?q?eowSO2hIZoFX0nCQsQe0D9kJnoUw/I4uyTB6L+zwSNLtUj4+qfGPSTsRihniHIPC8?= =?utf-8?q?qa2JfUSVPjV+Qtq90GCLmXxD8xmo6Z474mUrB1Y00GzbC8YvNG96/sRULmHAPm7xP?= =?utf-8?q?TtVHEceiDznVTkCGzOQnO/ncW2ZjaiZtaVvP8eLuZ09IRU3dKB0V0amSrzFH9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53ae84dc-a6af-462e-0e50-08dcc3518d16 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:57:00.7468 (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: fCkoyp6Ku8xu+vmUQ8I02vWTJfB+CJfMafTnGF/88fJKBF+a4GAr6XXdewe43rfwxujCYUbxUDPFTUPit9ZF8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10892 From: Peng Fan i.MX95 System Manager(SM) firmware includes a SCMI vendor protocol, SCMI MISC protocol which includes controls that are misc settings/actions that must be exposed from the SM to agents. They are device specific and are usually define to access bit fields in various mix block control modules, IOMUX_GPR, and other General Purpose registers, Control Status Registers owned by the SM. Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/vendors/imx/Kconfig | 10 + drivers/firmware/arm_scmi/vendors/imx/Makefile | 1 + .../firmware/arm_scmi/vendors/imx/imx-sm-misc.c | 315 +++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 17 ++ 4 files changed, 343 insertions(+) diff --git a/drivers/firmware/arm_scmi/vendors/imx/Kconfig b/drivers/firmware/arm_scmi/vendors/imx/Kconfig index 51ccbd038627..e9d015859eaa 100644 --- a/drivers/firmware/arm_scmi/vendors/imx/Kconfig +++ b/drivers/firmware/arm_scmi/vendors/imx/Kconfig @@ -9,5 +9,15 @@ config IMX_SCMI_BBM_EXT This enables i.MX System BBM control logic which supports RTC and BUTTON. + This driver can also be built as a module. + +config IMX_SCMI_MISC_EXT + tristate "i.MX SCMI MISC EXTENSION" + depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) + default y if ARCH_MXC + help + This enables i.MX System MISC control logic such as gpio expander + wakeup + This driver can also be built as a module. endmenu diff --git a/drivers/firmware/arm_scmi/vendors/imx/Makefile b/drivers/firmware/arm_scmi/vendors/imx/Makefile index a7dbdd20dbb9..d3ee6d544924 100644 --- a/drivers/firmware/arm_scmi/vendors/imx/Makefile +++ b/drivers/firmware/arm_scmi/vendors/imx/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_IMX_SCMI_BBM_EXT) += imx-sm-bbm.o +obj-$(CONFIG_IMX_SCMI_MISC_EXT) += imx-sm-misc.o diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c new file mode 100644 index 000000000000..0e93a81e579a --- /dev/null +++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c @@ -0,0 +1,315 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System control and Management Interface (SCMI) NXP MISC Protocol + * + * Copyright 2024 NXP + */ + +#define pr_fmt(fmt) "SCMI Notifications MISC - " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "../../protocols.h" +#include "../../notify.h" + +#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x10000 + +#define MAX_MISC_CTRL_SOURCES GENMASK(15, 0) + +enum scmi_imx_misc_protocol_cmd { + SCMI_IMX_MISC_CTRL_SET = 0x3, + SCMI_IMX_MISC_CTRL_GET = 0x4, + SCMI_IMX_MISC_CTRL_NOTIFY = 0x8, +}; + +struct scmi_imx_misc_info { + u32 version; + u32 nr_dev_ctrl; + u32 nr_brd_ctrl; + u32 nr_reason; +}; + +struct scmi_msg_imx_misc_protocol_attributes { + __le32 attributes; +}; + +#define GET_BRD_CTRLS_NR(x) le32_get_bits((x), GENMASK(31, 24)) +#define GET_REASONS_NR(x) le32_get_bits((x), GENMASK(23, 16)) +#define GET_DEV_CTRLS_NR(x) le32_get_bits((x), GENMASK(15, 0)) +#define BRD_CTRL_START_ID BIT(15) + +struct scmi_imx_misc_ctrl_set_in { + __le32 id; + __le32 num; + __le32 value[]; +}; + +struct scmi_imx_misc_ctrl_notify_in { + __le32 ctrl_id; + __le32 flags; +}; + +struct scmi_imx_misc_ctrl_notify_payld { + __le32 ctrl_id; + __le32 flags; +}; + +struct scmi_imx_misc_ctrl_get_out { + __le32 num; + __le32 val[]; +}; + +static int scmi_imx_misc_attributes_get(const struct scmi_protocol_handle *ph, + struct scmi_imx_misc_info *mi) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_imx_misc_protocol_attributes *attr; + + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, + sizeof(*attr), &t); + if (ret) + return ret; + + attr = t->rx.buf; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + mi->nr_dev_ctrl = GET_DEV_CTRLS_NR(attr->attributes); + mi->nr_brd_ctrl = GET_BRD_CTRLS_NR(attr->attributes); + mi->nr_reason = GET_REASONS_NR(attr->attributes); + dev_info(ph->dev, "i.MX MISC NUM DEV CTRL: %d, NUM BRD CTRL: %d,NUM Reason: %d\n", + mi->nr_dev_ctrl, mi->nr_brd_ctrl, mi->nr_reason); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_misc_ctrl_validate_id(const struct scmi_protocol_handle *ph, + u32 ctrl_id) +{ + struct scmi_imx_misc_info *mi = ph->get_priv(ph); + + /* + * [0, BRD_CTRL_START_ID) is for Dev Ctrl which is SOC related + * [BRD_CTRL_START_ID, 0xffff) is for Board Ctrl which is board related + */ + if ((ctrl_id < BRD_CTRL_START_ID) && (ctrl_id > mi->nr_dev_ctrl)) + return -EINVAL; + if (ctrl_id >= BRD_CTRL_START_ID + mi->nr_brd_ctrl) + return -EINVAL; + + return 0; +} + +static int scmi_imx_misc_ctrl_notify(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 evt_id, u32 flags) +{ + struct scmi_imx_misc_ctrl_notify_in *in; + struct scmi_xfer *t; + int ret; + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_NOTIFY, + sizeof(*in), 0, &t); + if (ret) + return ret; + + in = t->tx.buf; + in->ctrl_id = cpu_to_le32(ctrl_id); + in->flags = cpu_to_le32(flags); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int +scmi_imx_misc_ctrl_set_notify_enabled(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id, bool enable) +{ + int ret; + + /* misc_ctrl_req_notify is for enablement */ + if (enable) + return 0; + + ret = scmi_imx_misc_ctrl_notify(ph, src_id, evt_id, 0); + if (ret) + dev_err(ph->dev, "FAIL_ENABLED - evt[%X] src[%d] - ret:%d\n", + evt_id, src_id, ret); + + return ret; +} + +static void * +scmi_imx_misc_ctrl_fill_custom_report(const struct scmi_protocol_handle *ph, + u8 evt_id, ktime_t timestamp, + const void *payld, size_t payld_sz, + void *report, u32 *src_id) +{ + const struct scmi_imx_misc_ctrl_notify_payld *p = payld; + struct scmi_imx_misc_ctrl_notify_report *r = report; + + if (sizeof(*p) != payld_sz) + return NULL; + + r->timestamp = timestamp; + r->ctrl_id = p->ctrl_id; + r->flags = p->flags; + if (src_id) + *src_id = r->ctrl_id; + dev_dbg(ph->dev, "%s: ctrl_id: %d flags: %d\n", __func__, + r->ctrl_id, r->flags); + + return r; +} + +static const struct scmi_event_ops scmi_imx_misc_event_ops = { + .set_notify_enabled = scmi_imx_misc_ctrl_set_notify_enabled, + .fill_custom_report = scmi_imx_misc_ctrl_fill_custom_report, +}; + +static const struct scmi_event scmi_imx_misc_events[] = { + { + .id = SCMI_EVENT_IMX_MISC_CONTROL, + .max_payld_sz = sizeof(struct scmi_imx_misc_ctrl_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_misc_ctrl_notify_report), + }, +}; + +static struct scmi_protocol_events scmi_imx_misc_protocol_events = { + .queue_sz = SCMI_PROTO_QUEUE_SZ, + .ops = &scmi_imx_misc_event_ops, + .evts = scmi_imx_misc_events, + .num_events = ARRAY_SIZE(scmi_imx_misc_events), + .num_sources = MAX_MISC_CTRL_SOURCES, +}; + +static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 *num, u32 *val) +{ + struct scmi_imx_misc_ctrl_get_out *out; + struct scmi_xfer *t; + int ret, i; + int max_msg_size = ph->hops->get_max_msg_size(ph); + int max_num = (max_msg_size - sizeof(*out)) / sizeof(__le32); + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_GET, sizeof(u32), + 0, &t); + if (ret) + return ret; + + put_unaligned_le32(ctrl_id, t->tx.buf); + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + out = t->rx.buf; + *num = le32_to_cpu(out->num); + + if (*num >= max_num || + *num * sizeof(__le32) > t->rx.len - sizeof(__le32)) { + ph->xops->xfer_put(ph, t); + return -EINVAL; + } + + for (i = 0; i < *num; i++) + val[i] = le32_to_cpu(out->val[i]); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_misc_ctrl_set(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 num, u32 *val) +{ + struct scmi_imx_misc_ctrl_set_in *in; + struct scmi_xfer *t; + int ret, i; + int max_msg_size = ph->hops->get_max_msg_size(ph); + int max_num = (max_msg_size - sizeof(*in)) / sizeof(__le32); + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + if (num > max_num) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_SET, sizeof(*in), + 0, &t); + if (ret) + return ret; + + in = t->tx.buf; + in->id = cpu_to_le32(ctrl_id); + in->num = cpu_to_le32(num); + for (i = 0; i < num; i++) + in->value[i] = cpu_to_le32(val[i]); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static const struct scmi_imx_misc_proto_ops scmi_imx_misc_proto_ops = { + .misc_ctrl_set = scmi_imx_misc_ctrl_set, + .misc_ctrl_get = scmi_imx_misc_ctrl_get, + .misc_ctrl_req_notify = scmi_imx_misc_ctrl_notify, +}; + +static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph) +{ + struct scmi_imx_misc_info *minfo; + u32 version; + int ret; + + ret = ph->xops->version_get(ph, &version); + if (ret) + return ret; + + dev_info(ph->dev, "NXP SM MISC Version %d.%d\n", + PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); + + minfo = devm_kzalloc(ph->dev, sizeof(*minfo), GFP_KERNEL); + if (!minfo) + return -ENOMEM; + + ret = scmi_imx_misc_attributes_get(ph, minfo); + if (ret) + return ret; + + return ph->set_priv(ph, minfo, version); +} + +static const struct scmi_protocol scmi_imx_misc = { + .id = SCMI_PROTOCOL_IMX_MISC, + .owner = THIS_MODULE, + .instance_init = &scmi_imx_misc_protocol_init, + .ops = &scmi_imx_misc_proto_ops, + .events = &scmi_imx_misc_protocol_events, + .supported_version = SCMI_PROTOCOL_SUPPORTED_VERSION, + .vendor_id = "NXP", + .sub_vendor_id = "IMX", +}; +module_scmi_protocol(scmi_imx_misc); diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h index 2df2ea0f1809..066216f1357a 100644 --- a/include/linux/scmi_imx_protocol.h +++ b/include/linux/scmi_imx_protocol.h @@ -15,6 +15,7 @@ enum scmi_nxp_protocol { SCMI_PROTOCOL_IMX_BBM = 0x81, + SCMI_PROTOCOL_IMX_MISC = 0x84, }; struct scmi_imx_bbm_proto_ops { @@ -30,6 +31,7 @@ struct scmi_imx_bbm_proto_ops { enum scmi_nxp_notification_events { SCMI_EVENT_IMX_BBM_RTC = 0x0, SCMI_EVENT_IMX_BBM_BUTTON = 0x1, + SCMI_EVENT_IMX_MISC_CONTROL = 0x0, }; struct scmi_imx_bbm_notif_report { @@ -39,4 +41,19 @@ struct scmi_imx_bbm_notif_report { unsigned int rtc_id; unsigned int rtc_evt; }; + +struct scmi_imx_misc_ctrl_notify_report { + ktime_t timestamp; + unsigned int ctrl_id; + unsigned int flags; +}; + +struct scmi_imx_misc_proto_ops { + int (*misc_ctrl_set)(const struct scmi_protocol_handle *ph, u32 id, + u32 num, u32 *val); + int (*misc_ctrl_get)(const struct scmi_protocol_handle *ph, u32 id, + u32 *num, u32 *val); + int (*misc_ctrl_req_notify)(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 evt_id, u32 flags); +}; #endif From patchwork Fri Aug 23 09:05:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13774777 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2075.outbound.protection.outlook.com [40.107.105.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B190142E9D; Fri, 23 Aug 2024 08:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.105.75 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403432; cv=fail; b=NdhfoTqa7Do3a5Cb9F6mHU5uGjPqH/HMsLX4uPelM+EGuJ4B1wczWPwcEHKDOuz2aT9zcmjvmVkXdqvYSLZfy7+aN1rQdsw5J+Vi/ISnYnjkXZhg41y7+sXlhjaBA0szHYLNEvFXsImeYl8CROpQfEMzc7Arj7UazaoqdcNx61I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403432; c=relaxed/simple; bh=Mxtx727GKtDC5qb+9YKPTWtjdLgYtIaycaq2wKxGAeM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=d6LJBgKDRuour3zOMYaFpnKXFFnWian/j0BNETpNCHFFCagGffwyCFZg1n9/E396BkBHx0Grea1j1yySmWtrKuhWz+q7B9oSBFPM5GL27G3zcu1qYdjiJXLicWCfE89Ekg97uNJ1fwmPhV7SGCyz+K1UTlq8lx9NlO7V54CiVB8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=qnZ0SecC; arc=fail smtp.client-ip=40.107.105.75 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="qnZ0SecC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PYrFD05xuGYCcvgmLYQBU8vLNt6wfD1ywRugyTv7lMjUW636KAGohXQfWRluldMXPxy7nmQ7aSgiEO3bIqA80wsq2l0YRNB9r+n211ur47LoQ3QqK20Kaijh61bQHfddxjxMVylZEcl/GFLDofUOp/WOmTkmXwy5oj38iXcq3rjTGMXksX2mAQESxcw0oKYQiE3nOPuOfnUEu0RPfIis1kkvLIDxMimr34OSZNb9rdP1BmzslhbWckfqVrUvXpqMYX6W2IQYNrhTIyT6gz0qGMDOCvZR2kQKk65S5bUfh8WznGc7hF3IMwwHAayJBS9UxkgjJaDwmbQKMGOptfyinQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AF/4FrWG/WUGQlZcVFSjAzcI1cZT51tO78QpKTkfC6M=; b=KsnUCoyTbhG9TzQ6oC1aL8kN/7FZzWJYJoWxw5XSAmwkyQSQ+jmZhm1TRqYt6C++8jEA0UI/ce34NxKzl8a5Tj0CFP1f/+KxrhnuHNoE4PYNLnlCAT19UxQxVgmP0D37NSFtxqB8zKJJJ3ZVeYI/Gw8UwWkBNidHg11iUylj6zjqmggygVjxWqA4qOx5CgUb8k2XeZIV21NGPqJlxivHQ2olcSd/tqiNMUba1+0V1SxcDVeU+l+pc4ErgQLd+gZme59SVxsWrhjaa0TJcHx+iTGLLK4wUuzHwiw0bLIpaE6h0emPhfS+2CgaqKe5afQv3u7yeO9rlVwlUn/7WqMM8g== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AF/4FrWG/WUGQlZcVFSjAzcI1cZT51tO78QpKTkfC6M=; b=qnZ0SecCjcrW2lRbnnymtUD7Z79xWVkgWl8c+zuJY8dfrtJF/tUdL13AZOTu4rBPuZI9cTZC7xkLXF/PDiUMORJSPWUeWWfgx82FmpYEtgZusonVJr+Y4pa2XkJ3VMgHMlbXgFR0IjyCBbxfqc/6T04Q57OlWnv/vEJFJZ0pk5Y/Be6jTAR0aZdgB5waFrcwHVeDCb8056LdMHt6qd0REvPFxRix8ETgw1oucYzdPe8toJ7zePpV9XPShLhpLQwqjMxqu4//GfQoao9JEyALO5DZilvqEHXDpIq4EYriTYU71MVWmLKiuY5jojRlDIljIJg8CB+YaiGMkK9cAcQUzQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by PA1PR04MB10892.eurprd04.prod.outlook.com (2603:10a6:102:488::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Fri, 23 Aug 2024 08:57:06 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:57:05 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Aug 2024 17:05:20 +0800 Subject: [PATCH v8 4/7] firmware: arm_scmi: add NXP i.MX95 SCMI documentation Message-Id: <20240823-imx95-bbm-misc-v2-v8-4-e600ed9e9271@nxp.com> References: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> In-Reply-To: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724403944; l=55322; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=VyVgCny3AZ1ua8GlLQg3N6wgSuj0JGI0PHtl0IL+rkc=; b=0tMyMeDsdO4IQ07HcEAOzlWIIVlCm/fK8IiUnOL5J9zV9enNP7i4/nCGKcP+JzEzDwyAwKVoK V0Vg5XzZIq0DCwvfIp/sAGqS8mXK24rPE6fckloPhPWYCuPAEs4eOy8 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0173.apcprd01.prod.exchangelabs.com (2603:1096:4:28::29) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|PA1PR04MB10892:EE_ X-MS-Office365-Filtering-Correlation-Id: ad8d4069-e529-44a3-af25-08dcc351901a X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|1800799024|7416014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?QByouZqQvJPL7m12HscgUM/XnFCu93f?= =?utf-8?q?pgJTOjbzlabGmMZhTysANgdJwiRlgovxkVuDL+itVSQaoF3YX48etaOVmL8LNsLzh?= =?utf-8?q?iBXn4hNPlAaaU9Eir7KGneDPtQ/4ck9vDg4zIFqc7J3bp1HBeuOj89rKgmtvuG9En?= =?utf-8?q?gSw2DTldv5Fz6TrW/NzhCFsOEQJgqZhFoZi74mBg8Zguz7/mwgaQ5/vJihSYxd2q7?= =?utf-8?q?cODxMFb+al3IzG++sFWKoMTqtHMaLH5cKiiQxSBNlKmSdT4U2bmysQ3jwWvYbkhSA?= =?utf-8?q?aqXacBCj/6f0JEYjvLBZMRa40905sy/W1S6PO0CRWzlQGVfR9OLcbslB6vIt749QF?= =?utf-8?q?lDbDUMQYMSGYofeu6yOgZMgO2kTlh2rEaTyaEfr+wPXvaq2nmxS22o7p9v6UR/SJU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q?L+56EQSU+2v3IXz6g7yl1WoUPfU5ExAqNITNZFZccFWKYJJFQVlzdfRmsSePDBAoR?= =?utf-8?q?zoJVmVkXpAtiM5EmeRqk+u+/nuyvuVvkPOhzLqbJ2FKHFwYRq3V1XMg=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(52116014)(376014)(1800799024)(7416014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?CAj4avnWgPKhvOmPwGk6MG0v9z8T?= =?utf-8?q?P6Y7TurSXNv9jMN3Vc+89xIIvuVrdzUluRYFolpLzdaEPhwuhSnwT/Y3ZPfRGrnIz?= =?utf-8?q?MOg85+Nzyp1sbDLKlFK3leJfT4zdgVNFpWQ3fBgUYiBdTCfdo2oHwaCY6Pkj0FAex?= =?utf-8?q?DiSrDJjMeb7+lBGw98QCGF0Gft23kuIBdPJb1D3NjYEAuGi7WdaJQ8DAgjteLKyul?= =?utf-8?q?YIUPzMvKPnB8l9lG27aS1na2LUKaTNU4KDU5LMHM7lA/vrWdFrwf/qH6s9Di1yMuA?= =?utf-8?q?7ONrNKkDu3d+ZwraY94g5FUm9Cyjc6wjDslUvXy8GxFjZPyOgLU4qs947Y0+u/eJX?= =?utf-8?q?VRXt6XQJi9DAjJjcLvV4sbTXRcd1ABR9et6MQTordrcRYueAjsc30oPSVqMlLLorX?= =?utf-8?q?iTYflB01gnTtfC5ULIdHrBAUg1x6uSmB2Yhz4GdN8MhqLDb9/Z5TR2L+5MmcH9+HB?= =?utf-8?q?NBrg8XPpczp/8IWz85HRivoz2vxtAFkksLDvE62cLVHx5OE0YE9+1+xHBBlyr8fEC?= =?utf-8?q?v+W9SmMzefdUzdKjTlimLpYHesojoSqII0x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GHNXBIML8ZzbtMu1MDwsjCZBzG?= =?utf-8?q?sWXa0JFSAG2o1LMdfsRpBfrhXFyQj3C77LcUMUdnc9CUbId1xEOdpsbztQIB/dt80?= =?utf-8?q?cOCdZ10CyXAn?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad8d4069-e529-44a3-af25-08dcc351901a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:57:05.8992 (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: t9q3O0h/cC9iEoHxNgEJjTqIAnY88Lyqttw+CWce8W7KTNshEbGxzZD6aeIKlEMw4NZbraP0b1JBYyCMN5KClQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10892 From: Peng Fan Add NXP i.MX95 System Control Management Interface(SCMI) vendor extensions protocol documentation. Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/vendors/imx/imx95.rst | 886 ++++++++++++++++++++++++ 1 file changed, 886 insertions(+) diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx95.rst b/drivers/firmware/arm_scmi/vendors/imx/imx95.rst new file mode 100644 index 000000000000..6a9e53c17df1 --- /dev/null +++ b/drivers/firmware/arm_scmi/vendors/imx/imx95.rst @@ -0,0 +1,886 @@ +.. SPDX-License-Identifier: GPL-2.0 +.. include:: + +=============================================================================== +i.MX95 System Control and Management Interface(SCMI) Vendor Protocols Extension +=============================================================================== + +:Copyright: |copy| 2024 NXP + +:Author: Peng Fan + +The System Manager (SM) is a low-level system function which runs on a System +Control Processor (SCP) to support isolation and management of power domains, +clocks, resets, sensors, pins, etc. on complex application processors. It often +runs on a Cortex-M processor and provides an abstraction to many of the +underlying features of the hardware. The primary purpose of the SM is to allow +isolation between software running on different cores in the SoC. It does this +by having exclusive access to critical resources such as those controlling +power, clocks, reset, PMIC, etc. and then providing an RPC interface to those +clients. This allows the SM to provide access control, arbitration, and +aggregation policies for those shared critical resources. + +SM introduces a concept Logic Machine(LM) which is analogous to VM and each has +its own instance of SCMI. All normal SCMI calls only apply to that LM. That +includes boot, shutdown, reset, suspend, wake, etc. Each LM (e.g. A55 and M7) +are completely isolated from the others and each LM has its own communication +channels talking to the same SCMI server. + +This document covers all the information necessary to understand, maintain, +port, and deploy the SM on supported processors. + +The SM implements an interface compliant with the Arm SCMI Specification +with additional vendor specific extensions. + +SCMI_BBM: System Control and Management BBM Vendor Protocol +============================================================== + +This protocol is intended provide access to the battery-backed module. This +contains persistent storage (GPR), an RTC, and the ON/OFF button. The protocol +can also provide access to similar functions implemented via external board +components. The BBM protocol provides functions to: + +- Describe the protocol version. +- Discover implementation attributes. +- Read/write GPR +- Discover the RTCs available in the system. +- Read/write the RTC time in seconds and ticks +- Set an alarm (per LM) in seconds +- Get notifications on RTC update, alarm, or rollover. +- Get notification on ON/OFF button activity. + +For most SoC, there is one on-chip RTC (e.g. in BBNSM) and this is RTC ID 0. +Board code can add additional GPR and RTC. + +GPR are not aggregated. The RTC time is also not aggregated. Setting these +sets for all so normally exclusive access would be granted to one agent for +each. However, RTC alarms are maintained for each LM and the hardware is +programmed with the next nearest alarm time. So only one agent in an LM should +be given access rights to set an RTC alarm. + +Commands: +_________ + +PROTOCOL_VERSION +~~~~~~~~~~~~~~~~ + +message_id: 0x0 +protocol_id: 0x81 + ++---------------+--------------------------------------------------------------+ +|Return values | ++---------------+--------------------------------------------------------------+ +|Name |Description | ++---------------+--------------------------------------------------------------+ +|int32 status | See ARM SCMI Specification for status code definitions. | ++---------------+--------------------------------------------------------------+ +|uint32 version | For this revision of the specification, this value must be | +| | 0x10000. | ++---------------+--------------------------------------------------------------+ + +PROTOCOL_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~ + +message_id: 0x1 +protocol_id: 0x81 + ++---------------+--------------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status | See ARM SCMI Specification for status code definitions. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes | Bits[31:8] Number of RTCs. | +| | Bits[15:0] Number of persistent storage (GPR) words. | ++------------------+-----------------------------------------------------------+ + +PROTOCOL_MESSAGE_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x2 +protocol_id: 0x81 + ++---------------+--------------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: in case the message is implemented and available | +| |to use. | +| |NOT_FOUND: if the message identified by message_id is | +| |invalid or not implemented | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Flags that are associated with a specific function in the | +| |protocol. For all functions in this protocol, this | +| |parameter has a value of 0 | ++------------------+-----------------------------------------------------------+ + +BBM_GPR_SET +~~~~~~~~~~~ + +message_id: 0x3 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of GPR to write | ++------------------+-----------------------------------------------------------+ +|uint32 value |32-bit value to write to the GPR | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the GPR was successfully written. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to write | +| |the specified GPR | ++------------------+-----------------------------------------------------------+ + +BBM_GPR_GET +~~~~~~~~~~~ + +message_id: 0x4 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of GPR to read | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the GPR was successfully read. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to read | +| |the specified GPR. | ++------------------+-----------------------------------------------------------+ +|uint32 value |32-bit value read from the GPR | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_ATTRIBUTES +~~~~~~~~~~~~~~~~~~ + +message_id: 0x5 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: returned the attributes. | +| |NOT_FOUND: Index is invalid. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Bit[31:24] Bit width of RTC seconds. | +| |Bit[23:16] Bit width of RTC ticks. | +| |Bits[15:0] RTC ticks per second | ++------------------+-----------------------------------------------------------+ +|uint8 name[16] |Null-terminated ASCII string of up to 16 bytes in length | +| |describing the RTC name | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_TIME_SET +~~~~~~~~~~~~~~~~ + +message_id: 0x6 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Bits[31:1] Reserved, must be zero. | +| |Bit[0] RTC time format: | +| |Set to 1 if the time is in ticks. | +| |Set to 0 if the time is in seconds | ++------------------+-----------------------------------------------------------+ +|uint32 time[2] |Lower word: Lower 32 bits of the time in seconds/ticks. | +| |Upper word: Upper 32 bits of the time in seconds/ticks. | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: RTC time was successfully set. | +| |NOT_FOUND: rtcId pertains to a non-existent RTC. | +| |INVALID_PARAMETERS: time is not valid | +| |(beyond the range of the RTC). | +| |DENIED: the agent does not have permission to set the RTC. | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_TIME_GET +~~~~~~~~~~~~~~~~ + +message_id: 0x7 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Bits[31:1] Reserved, must be zero. | +| |Bit[0] RTC time format: | +| |Set to 1 if the time is in ticks. | +| |Set to 0 if the time is in seconds | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: RTC time was successfully get. | +| |NOT_FOUND: rtcId pertains to a non-existent RTC. | ++------------------+-----------------------------------------------------------+ +|uint32 time[2] |Lower word: Lower 32 bits of the time in seconds/ticks. | +| |Upper word: Upper 32 bits of the time in seconds/ticks. | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_ALARM_SET +~~~~~~~~~~~~~~~~~ + +message_id: 0x8 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Bits[31:1] Reserved, must be zero. | +| |Bit[0] RTC enable flag: | +| |Set to 1 if the RTC alarm should be enabled. | +| |Set to 0 if the RTC alarm should be disabled | ++------------------+-----------------------------------------------------------+ +|uint32 time[2] |Lower word: Lower 32 bits of the time in seconds. | +| |Upper word: Upper 32 bits of the time in seconds. | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: RTC time was successfully set. | +| |NOT_FOUND: rtcId pertains to a non-existent RTC. | +| |INVALID_PARAMETERS: time is not valid | +| |(beyond the range of the RTC). | +| |DENIED: the agent does not have permission to set the RTC | +| |alarm | ++------------------+-----------------------------------------------------------+ + +BBM_BUTTON_GET +~~~~~~~~~~~~~~ + +message_id: 0x9 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the button status was read. | +| |Other value: ARM SCMI Specification status code definitions| ++------------------+-----------------------------------------------------------+ +|uint32 state |State of the ON/OFF button. 1: ON, 0: OFF | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_NOTIFY +~~~~~~~~~~~~~~ + +message_id: 0xA +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Notification flags | +| |Bits[31:3] Reserved, must be zero. | +| |Bit[2] Update enable: | +| |Set to 1 to send notification. | +| |Set to 0 if no notification. | +| |Bit[1] Rollover enable: | +| |Set to 1 to send notification. | +| |Set to 0 if no notification. | +| |Bit[0] Alarm enable: | +| |Set to 1 to send notification. | +| |Set to 0 if no notification | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: notification configuration was successfully | +| |updated. | +| |NOT_FOUND: rtcId pertains to a non-existent RTC. | +| |DENIED: the agent does not have permission to request RTC | +| |notifications. | ++------------------+-----------------------------------------------------------+ + +BBM_BUTTON_NOTIFY +~~~~~~~~~~~~~~~~~ + +message_id: 0xB +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Notification flags | +| |Bits[31:1] Reserved, must be zero. | +| |Bit[0] Enable button: | +| |Set to 1 to send notification. | +| |Set to 0 if no notification | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: notification configuration was successfully | +| |updated. | +| |DENIED: the agent does not have permission to request | +| |button notifications. | ++------------------+-----------------------------------------------------------+ + +NEGOTIATE_PROTOCOL_VERSION +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x10 +protocol_id: 0x81 + ++--------------------+---------------------------------------------------------+ +|Parameters | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|uint32 version |The negotiated protocol version the agent intends to use | ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: if the negotiated protocol version is supported | +| |by the platform. All commands, responses, and | +| |notifications post successful return of this command must| +| |comply with the negotiated version. | +| |NOT_SUPPORTED: if the protocol version is not supported. | ++--------------------+---------------------------------------------------------+ + +Notifications +_____________ + +BBM_RTC_EVENT +~~~~~~~~~~~~~ + +message_id: 0x0 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 flags |RTC events: | +| |Bits[31:2] Reserved, must be zero. | +| |Bit[1] RTC rollover notification: | +| |1 RTC rollover detected. | +| |0 no RTC rollover detected. | +| |Bit[0] RTC alarm notification: | +| |1 RTC alarm generated. | +| |0 no RTC alarm generated. | ++------------------+-----------------------------------------------------------+ + +BBM_BUTTON_EVENT +~~~~~~~~~~~~~~~~ + +message_id: 0x1 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 flags |RTC events: | ++------------------+-----------------------------------------------------------+ +| |Button events: | +| |Bits[31:1] Reserved, must be zero. | +| |Bit[0] Button notification: | +| |1 button change detected. | +| |0 no button change detected. | ++------------------+-----------------------------------------------------------+ + +SCMI_MISC: System Control and Management MISC Vendor Protocol +================================================================ + +Provides miscellaneous functions. This includes controls that are miscellaneous +settings/actions that must be exposed from the SM to agents. They are device +specific and are usually define to access bit fields in various mix block +control modules, IOMUX_GPR, and other GPR/CSR owned by the SM. This protocol +supports the following functions: + +- Describe the protocol version. +- Discover implementation attributes. +- Set/Get a control. +- Initiate an action on a control. +- Obtain platform (i.e. SM) build information. +- Obtain ROM passover data. +- Read boot/shutdown/reset information for the LM or the system. + +Commands: +_________ + +PROTOCOL_VERSION +~~~~~~~~~~~~~~~~ + +message_id: 0x0 +protocol_id: 0x84 + ++---------------+--------------------------------------------------------------+ +|Return values | ++---------------+--------------------------------------------------------------+ +|Name |Description | ++---------------+--------------------------------------------------------------+ +|int32 status | See ARM SCMI Specification for status code definitions. | ++---------------+--------------------------------------------------------------+ +|uint32 version | For this revision of the specification, this value must be | +| | 0x10000. | ++---------------+--------------------------------------------------------------+ + +PROTOCOL_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~ + +message_id: 0x1 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status | See ARM SCMI Specification for status code definitions. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Protocol attributes: | +| |Bits[31:24] Reserved, must be zero. | +| |Bits[23:16] Number of reset reasons. | +| |Bits[15:0] Number of controls | ++------------------+-----------------------------------------------------------+ + +PROTOCOL_MESSAGE_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x2 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: in case the message is implemented and available | +| |to use. | +| |NOT_FOUND: if the message identified by message_id is | +| |invalid or not implemented | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Flags that are associated with a specific function in the | +| |protocol. For all functions in this protocol, this | +| |parameter has a value of 0 | ++------------------+-----------------------------------------------------------+ + +MISC_CONTROL_SET +~~~~~~~~~~~~~~~~ + +message_id: 0x3 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of the control | ++------------------+-----------------------------------------------------------+ +|uint32 num |Size of the value data in words | ++------------------+-----------------------------------------------------------+ +|uint32 val[8] |value data array | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the control was set successfully. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to set the | +| |control | ++------------------+-----------------------------------------------------------+ + +MISC_CONTROL_GET +~~~~~~~~~~~~~~~~ + +message_id: 0x4 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of the control | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the control was get successfully. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to get the | +| |control | ++------------------+-----------------------------------------------------------+ +|uint32 num |Size of the return data in words, max 8 | ++------------------+-----------------------------------------------------------+ +|uint32 | | +|val[0, num - 1] |value data array | ++------------------+-----------------------------------------------------------+ + +MISC_CONTROL_ACTION +~~~~~~~~~~~~~~~~~~~ + +message_id: 0x5 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of the control | ++------------------+-----------------------------------------------------------+ +|uint32 action |Action for the control | ++------------------+-----------------------------------------------------------+ +|uint32 numarg |Size of the argument data, max 8 | ++------------------+-----------------------------------------------------------+ +|uint32 | | +|arg[0, numarg -1] |Argument data array | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the action was set successfully. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to get the | +| |control | ++------------------+-----------------------------------------------------------+ +|uint32 num |Size of the return data in words, max 8 | ++------------------+-----------------------------------------------------------+ +|uint32 | | +|val[0, num - 1] |value data array | ++------------------+-----------------------------------------------------------+ + +MISC_DISCOVER_BUILD_INFO +~~~~~~~~~~~~~~~~~~~~~~~~ + +This function is used to obtain the build commit, data, time, number. + +message_id: 0x6 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the build info was got successfully. | +| |NOT_SUPPORTED: if the data is not available. | ++------------------+-----------------------------------------------------------+ +|uint32 buildnum |Build number | ++------------------+-----------------------------------------------------------+ +|uint32 buildcommit|Most significant 32 bits of the git commit hash | ++------------------+-----------------------------------------------------------+ +|uint8 date[16] |Date of build. Null terminated ASCII string of up to 16 | +| |bytes in length | ++------------------+-----------------------------------------------------------+ +|uint8 time[16] |Time of build. Null terminated ASCII string of up to 16 | +| |bytes in length | ++------------------+-----------------------------------------------------------+ + +MISC_ROM_PASSOVER_GET +~~~~~~~~~~~~~~~~~~~~~ + +ROM passover data is information exported by ROM and could be used by others. +It includes boot device, instance, type, mode and etc. This function is used +to obtain the ROM passover data. The returned block of words is structured as +defined in the ROM passover section in the SoC RM. + +message_id: 0x7 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the data was got successfully. | +| |NOT_SUPPORTED: if the data is not available. | ++------------------+-----------------------------------------------------------+ +|uint32 num |Size of the passover data in words, max 13 | ++------------------+-----------------------------------------------------------+ +|uint32_t | | +|data[0, num - 1] |Passover data array | ++------------------+-----------------------------------------------------------+ + +MISC_CONTROL_NOTIFY +~~~~~~~~~~~~~~~~~~~ + +message_id: 0x8 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of control | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Notification flags, varies by control | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: notification configuration was successfully | +| |updated. | +| |NOT_FOUND: control id not exists. | +| |INVALID_PARAMETERS: if the input attributes flag specifies | +| |unsupported or invalid configurations.. | +| |DENIED: if the calling agent is not permitted to request | +| |the notification. | ++------------------+-----------------------------------------------------------+ + +MISC_RESET_REASON_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x9 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 reasonid |Identifier for the reason | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if valid reason attributes are returned | +| |NOT_FOUND: if reasonId pertains to a non-existent reason. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Reason attributes. This parameter has the following | +| |format: Bits[31:0] Reserved, must be zero | +| |Bits[15:0] Number of persistent storage (GPR) words. | ++------------------+-----------------------------------------------------------+ +|uint8 name[16] |Null-terminated ASCII string of up to 16 bytes in length | +| |describing the reason | ++------------------+-----------------------------------------------------------+ + +MISC_RESET_REASON_GET +~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0xA +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Parameters | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|uint32 flags |Reason flags. This parameter has the following format: | +| |Bits[31:1] Reserved, must be zero. | +| |Bit[0] System: | +| |Set to 1 to return the system reason. | +| |Set to 0 to return the LM reason | ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: reset reason return | ++--------------------+---------------------------------------------------------+ +|uint32 bootflags |Boot reason flags. This parameter has the format: | +| |Bits[31] Valid. | +| |Set to 1 if the entire reason is valid. | +| |Set to 0 if the entire reason is not valid. | +| |Bits[30:29] Reserved, must be zero. | +| |Bit[28] Valid origin: | +| |Set to 1 if the origin field is valid. | +| |Set to 0 if the origin field is not valid. | +| |Bits[27:24] Origin. | +| |Bit[23] Valid err ID: | +| |Set to 1 if the error ID field is valid. | +| |Set to 0 if the error ID field is not valid. | +| |Bits[22:8] Error ID. | +| |Bit[7:0] Reason | ++--------------------+---------------------------------------------------------+ +|uint32 shutdownflags|Shutdown reason flags. This parameter has the format: | +| |Bits[31] Valid. | +| |Set to 1 if the entire reason is valid. | +| |Set to 0 if the entire reason is not valid. | +| |Bits[30:29] Number of valid extended info words. | +| |Bit[28] Valid origin: | +| |Set to 1 if the origin field is valid. | +| |Set to 0 if the origin field is not valid. | +| |Bits[27:24] Origin. | +| |Bit[23] Valid err ID: | +| |Set to 1 if the error ID field is valid. | +| |Set to 0 if the error ID field is not valid. | +| |Bits[22:8] Error ID. | +| |Bit[7:0] Reason | ++--------------------+---------------------------------------------------------+ +|uint32 extinfo[8] |Array of extended info words | ++--------------------+---------------------------------------------------------+ + +MISC_SI_INFO_GET +~~~~~~~~~~~~~~~~ + +message_id: 0xB +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: silicon info return | ++--------------------+---------------------------------------------------------+ +|uint32 deviceid |Silicon specific device ID | ++--------------------+---------------------------------------------------------+ +|uint32 sirev |Silicon specific revision | ++--------------------+---------------------------------------------------------+ +|uint32 partnum |Silicon specific part number | ++--------------------+---------------------------------------------------------+ +|uint8 siname[16] |Silicon name/revision. Null terminated ASCII string of up| +| |to 16 bytes in length | ++--------------------+---------------------------------------------------------+ + +MISC_CFG_INFO_GET +~~~~~~~~~~~~~~~~~ + +message_id: 0xC +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: config name return | +| |NOT_SUPPORTED: name not available | ++--------------------+---------------------------------------------------------+ +|uint32 msel |Mode selector value | ++--------------------+---------------------------------------------------------+ +|uint8 cfgname[16] |config file basename. Null terminated ASCII string of up | +| |to 16 bytes in length | ++--------------------+---------------------------------------------------------+ + +MISC_SYSLOG_GET +~~~~~~~~~~~~~~~ + +message_id: 0xD +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Parameters | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|uint32 flags |Device specific flags that might impact the data returned| +| |or clearing of the data | ++--------------------+---------------------------------------------------------+ +|uint32 logindex |Index to the first log word. Will be the first element in| +| |the return array | ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: system log return | ++--------------------+---------------------------------------------------------+ +|uint32 numLogflags |Descriptor for the log data returned by this call. | +| |Bits[31:20] Number of remaining log words. | +| |Bits[15:12] Reserved, must be zero. | +| |Bits[11:0] Number of log words that are returned by this | +| |call | ++--------------------+---------------------------------------------------------+ +|uint32 syslog[N] |Log data array, N is defined in bits[11:0] of numLogflags| ++--------------------+---------------------------------------------------------+ + +NEGOTIATE_PROTOCOL_VERSION +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x10 +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Parameters | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|uint32 version |The negotiated protocol version the agent intends to use | ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: if the negotiated protocol version is supported | +| |by the platform. All commands, responses, and | +| |notifications post successful return of this command must| +| |comply with the negotiated version. | +| |NOT_SUPPORTED: if the protocol version is not supported. | ++--------------------+---------------------------------------------------------+ + +Notifications +_____________ + +MISC_CONTROL_EVENT +~~~~~~~~~~~~~~~~~~ + +message_id: 0x0 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 ctrlid |Identifier for the control that caused the event. | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Event flags, varies by control. | ++------------------+-----------------------------------------------------------+ From patchwork Fri Aug 23 09:05:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13774778 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013025.outbound.protection.outlook.com [52.101.67.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C93E14A08F; Fri, 23 Aug 2024 08:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.25 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403436; cv=fail; b=kIZFe8p4PL5QluIgtvsPK9X87VBezd2cUgdgMAn2gbGkGRC87Ov7TK3nBNcsGlXS/ZU33W/qSmAB5Nk7nptnV/10gqcTVH/X0q0R5A/39IEe5OT16f1x1rBaHvNJonxPAv3T6W8jz0/E57MJH42eMKT7UFoJS4YLCpGp3fj+YC0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403436; c=relaxed/simple; bh=LQvxg4wjhO9FWV8ybDeg50raOjfc2rJ4N3Rx1dkcBxg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=hM2u7ZUX2KMK+Rp4FC3pBJM/IpglJbrUmt/po8pRNgWyDPIzJhPjciW09dgRhdaRK+r1CNBDQzCS2GG8WieStBmWCcR5yx8Lt7HO90Rh/ZUZxXfRAOuZJ+4O+HCsA8Gd9NwSMqNUgucgGsJQinpkj+RqpVfe6KCG3z33cwu1DeI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=rgn8nF0X; arc=fail smtp.client-ip=52.101.67.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="rgn8nF0X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MxDUnTMMhuQ6TJDo52aw5Znk4LAvsWLaiNnYYRPOH/X3J8SOy9GzfS0y5XT0mkHyJpY28k6sYi+Oi5T5QdxwepYn0UfIfzXSp3k+n7veotmfcBHmrUGvLiDyl9dpMuuYQaoZPJxrrqcWikOEsBN5W0NIaaGEf9KJwHIQV9aHvrM9Bu01/FBP8D+XPhpVN6PzbB9QTLxhTjvKKHMkORWOiSvgVUNkprP/aVIDUFb7vRXvObqH5R4GTI2WQ3wuxNe2KkQQaXpyH/Wi6xcX6TZZ095Avoys+sLm1iiFYvjo9+cDkjBODN6mPJdSkQQjD+CpDVk6K7J86XCjxv+2F5MiRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tJ9BbhLwFgdLZiK9h91g5ImtM5fDYlp3ZRSCHB3HgOI=; b=qJsRfSZDtJ9Lx5PSdmV0+ijop3SJ3YvrXrNpKd/tEo3A8eoOXzY0Ep7oRpe95QFjPFMhQK84tOBlYQ3tiaIzVkl01mV7sWhRt3e3AuS3ZaZhizx76BIWGXUjs1EaJzqvSostCh0ppEjqkZJXVDlpkWt+oOC0Gpb8rePB9M94HXwwAdEmHRWX+8E66AI4RvAmL0yjkOTLneW1/SIaoKLzUvUxhjCZPjRqLLgp7ApIO6zODXUZGyzqGxZgrN54l51GOVsStwpMNL/bz139vXNiUS9djm5E/QatHfMqYLF3Mnb4KRO33lIxkngYiadGnY/Whk2vC3pLFzzQzb14S/mUEQ== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tJ9BbhLwFgdLZiK9h91g5ImtM5fDYlp3ZRSCHB3HgOI=; b=rgn8nF0Xyo7gromGBl00/pGQTktfHKHPsCMowwbNflJBxL8DoOFn287PqdhvJ/cVeVCaeQMSWavIUxDK1V5bhPMJ6JlbJnvLbVfrp9uFBR7pOEfpv3elnmpZ+Dxu5BJ4nfyX7jhz1f2aJQii1A/3gSl/Gu1Cg2ZB79iGCdwxk2I6Z/F5kFC8V3ib7ngue9yzYt/28alWk4RwHnv1xjoFAc3CazS5LKUBGgJlk58NVJDkPxeVVVtFzV9ffpw8AL24zhL2ijDE+QZIu+I/hPa7MqRfesnr9HRbtA5mMSYoTzdNbhuY6Bg1gwv/LWJ8FQFC4Zy2aMkZOgCjr66BHpAF7w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by DBAPR04MB7271.eurprd04.prod.outlook.com (2603:10a6:10:1a6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 08:57:11 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:57:10 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Aug 2024 17:05:21 +0800 Subject: [PATCH v8 5/7] firmware: imx: add i.MX95 MISC driver Message-Id: <20240823-imx95-bbm-misc-v2-v8-5-e600ed9e9271@nxp.com> References: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> In-Reply-To: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724403944; l=6495; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=D48dI8TueQeMQCWqqGsKwb9eBu8K4dfQ0em7IUIjo5A=; b=RaROcmSbo0BoZ2se9ht7oYUj31+I7UHCjbskbV7cgDWJXtzEhHxQOHG/7vVB/0iMOLFcLWTwn cbdy+sz3X2RBdp0FaMvfShXIMF8L5rXAr4hd4MmF7ioIjFcKkgIPjmZ X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0173.apcprd01.prod.exchangelabs.com (2603:1096:4:28::29) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DBAPR04MB7271:EE_ X-MS-Office365-Filtering-Correlation-Id: eb5c36d6-f949-47c4-930f-08dcc3519323 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Tg6InPquUgOrL5f8I0rfPnl1aeD2Vtk?= =?utf-8?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GTMO9KIkVk9Ee0VPxRi4+7utDFYmOsE1LfO0uToHiMzE+dlvAfZXDbH/xBtx8zcp?= =?utf-8?q?WiSOoYarHyg44nHMWQCtg6+ToB41YlTANWQmTEvNK92kZO0Q7omD9JHTOU9cycv2z?= =?utf-8?q?tH04JaU76XWFs7jHp950RJRvq97vyNHHlN5i+r1HL3nRrCfSCWJE7orQkYmgcMcC8?= =?utf-8?q?h6tg1NXie+mKDGJrlKdTzb/O8omk/WVakdSBiFqDMaHX9m4cBEDKqnTzqmfifvQsh?= =?utf-8?q?yc/o4M9a813QQcbduEmJRRETpmJ4jxQ//i38uvmUJy5n3N7QcEjb2p0BhUHOXOTjv?= =?utf-8?q?RvfxeS7nWaQr19nP/cF3jn4jTzXrsaG461dCC6qpGpmgxg073yJmVaxz6tR6q+svk?= =?utf-8?q?gyX51ian1jEFxtAa29bN0Z/cKG3wV333BApnqmzpcFmJjxMXcvJknsecnsWfJcML8?= =?utf-8?q?jG5LdnkycYKnfk50FTGLL7hk508FL0yE+hxIvQK56caR1dKjQbGQSkw=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Nw2iCnZHBdpJ+q1ilHWksCgfDN2h?= =?utf-8?q?+osXr1mNsUi+ATr1Hp3aStRuRd1uSczepo/AluJ0QDCk1ejQmgAtLX/0GXkV46UyE?= =?utf-8?q?w1oyCcbJpBFLrmr6y+P8FqW8WvIbPDQwViKmEMBQ9Zj2YnUjRb+7R38d0I5KK2ASZ?= =?utf-8?q?M5PGMy3Wxfd8uEhEUNJ4ofDzDU4f80I89nHqz6J3MjoyRx6//Lr37xE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/8PUDC1eks?= =?utf-8?q?Kyao919L0CVKV+pISicBTbuzNqRIL40Qn0OuQ3iOWDlq1L3yfiOq1snY5ZU7PlDLy?= =?utf-8?q?DioihtFV1g0HnlfFpx23RpA1GdGEJjEbMrDdje1nwScLfwfn2qKpUVu5CoKJlPner?= =?utf-8?q?mK+rmdZBhyt0CeBKGNELwMfrbC8VuLlTnMQ6FS8+z7ohXUy1JNRShjx28fZzekHB1?= =?utf-8?q?8w0xA4n2pm+BfVCz+3rjfhoXcsPZCXwz63V27xe6wk1sGj5u9gZjxupWWLxGs446k?= =?utf-8?q?l8u16WoKgiWfXwUgM7/N/9RfLhMxRLLmQ9+SJ2+tCOJ7TL5hcwNwMqLGcNC8vECJ/?= =?utf-8?q?LWrvw2UvMlfjlwlhvvN/dqC65ikvaSOQXU0tkGaUkP7w5Z7fvJrf92dObzl/BpZM4?= =?utf-8?q?C2VCpewQp5hpwOzXUgLUzfDWeJs13MSyMv43OHHOtFZsoJAQA/qNhYKgrb3w2egnA?= =?utf-8?q?zEIdhM3GJ6vm?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb5c36d6-f949-47c4-930f-08dcc3519323 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:57:10.8943 (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: M62CmeufP7/d7BVpv6s1EpfgE6+arUlkFC+hbFWpop8QhlLZZ9CemTfpdgrIL10G6WVqvyOBYdJlTzpVMSm2kg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7271 From: Peng Fan The i.MX95 System manager exports SCMI MISC protocol for linux to do various settings, such as set board gpio expander as wakeup source. The driver is to add the support. Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan --- drivers/firmware/imx/Kconfig | 11 ++++ drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-misc.c | 119 ++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 +++++++++++ 4 files changed, 164 insertions(+) diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index 183613f82a11..477d3f32d99a 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -22,3 +22,14 @@ config IMX_SCU This driver manages the IPC interface between host CPU and the SCU firmware running on M4. + +config IMX_SCMI_MISC_DRV + tristate "IMX SCMI MISC Protocol driver" + depends on IMX_SCMI_MISC_EXT || COMPILE_TEST + default y if ARCH_MXC + help + The System Controller Management Interface firmware (SCMI FW) is + a low-level system function which runs on a dedicated Cortex-M + core that could provide misc functions such as board control. + + This driver can also be built as a module. diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8f9f04a513a8..8d046c341be8 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,3 +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_SCMI_MISC_DRV} += sm-misc.o diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c new file mode 100644 index 000000000000..fc3ee12c2be8 --- /dev/null +++ b/drivers/firmware/imx/sm-misc.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include +#include + +static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops; +static struct scmi_protocol_handle *ph; +struct notifier_block scmi_imx_misc_ctrl_nb; + +int scmi_imx_misc_ctrl_set(u32 id, u32 val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_set(ph, id, 1, &val); +}; +EXPORT_SYMBOL(scmi_imx_misc_ctrl_set); + +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_get(ph, id, num, val); +} +EXPORT_SYMBOL(scmi_imx_misc_ctrl_get); + +static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb, + unsigned long event, void *data) +{ + /* + * notifier_chain_register requires a valid notifier_block and + * valid notifier_call. SCMI_EVENT_IMX_MISC_CONTROL is needed + * to let SCMI firmware enable control events, but the hook here + * is just a dummy function to avoid kernel panic as of now. + */ + return 0; +} + +static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device_node *np = sdev->dev.of_node; + u32 src_id, flags; + int ret, i, num; + + if (!handle) + return -ENODEV; + + if (imx_misc_ctrl_ops) { + dev_err(&sdev->dev, "misc ctrl already initialized\n"); + return -EEXIST; + } + + imx_misc_ctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_MISC, &ph); + if (IS_ERR(imx_misc_ctrl_ops)) + return PTR_ERR(imx_misc_ctrl_ops); + + num = of_property_count_u32_elems(np, "nxp,ctrl-ids"); + if (num % 2) { + dev_err(&sdev->dev, "Invalid wakeup-sources\n"); + return -EINVAL; + } + + scmi_imx_misc_ctrl_nb.notifier_call = &scmi_imx_misc_ctrl_notifier; + for (i = 0; i < num; i += 2) { + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i, &src_id); + if (ret) { + dev_err(&sdev->dev, "Failed to read ctrl-id: %i\n", i); + continue; + } + + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i + 1, &flags); + if (ret) { + dev_err(&sdev->dev, "Failed to read ctrl-id value: %d\n", i + 1); + continue; + } + + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC, + SCMI_EVENT_IMX_MISC_CONTROL, + &src_id, + &scmi_imx_misc_ctrl_nb); + if (ret) { + dev_err(&sdev->dev, "Failed to register scmi misc event: %d\n", src_id); + } else { + ret = imx_misc_ctrl_ops->misc_ctrl_req_notify(ph, src_id, + SCMI_EVENT_IMX_MISC_CONTROL, + flags); + if (ret) + dev_err(&sdev->dev, "Failed to req notify: %d\n", src_id); + } + } + + return 0; +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_MISC, "imx-misc-ctrl" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_misc_ctrl_driver = { + .name = "scmi-imx-misc-ctrl", + .probe = scmi_imx_misc_ctrl_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_misc_ctrl_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM MISC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h new file mode 100644 index 000000000000..daad4bdf7d1c --- /dev/null +++ b/include/linux/firmware/imx/sm.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + +#ifndef _SCMI_IMX_H +#define _SCMI_IMX_H + +#include +#include + +#define SCMI_IMX_CTRL_PDM_CLK_SEL 0 /* AON PDM clock sel */ +#define SCMI_IMX_CTRL_MQS1_SETTINGS 1 /* AON MQS settings */ +#define SCMI_IMX_CTRL_SAI1_MCLK 2 /* AON SAI1 MCLK */ +#define SCMI_IMX_CTRL_SAI3_MCLK 3 /* WAKE SAI3 MCLK */ +#define SCMI_IMX_CTRL_SAI4_MCLK 4 /* WAKE SAI4 MCLK */ +#define SCMI_IMX_CTRL_SAI5_MCLK 5 /* WAKE SAI5 MCLK */ + +#if IS_ENABLED(CONFIG_IMX_SCMI_MISC_EXT) +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val); +int scmi_imx_misc_ctrl_set(u32 id, u32 val); +#else +static inline int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + return -EOPNOTSUPP; +} + +static inline int scmi_imx_misc_ctrl_set(u32 id, u32 val); +{ + return -EOPNOTSUPP; +} +#endif +#endif From patchwork Fri Aug 23 09:05:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13774779 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011023.outbound.protection.outlook.com [52.101.65.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2010E1802AB; Fri, 23 Aug 2024 08:57:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.23 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403441; cv=fail; b=e/ST4zERl6bSGlqyNoR6BzE6up6BtrcCA9J6s+1F11I+yY/rhEvT89loXNcFQFLpWvLorNtKAIAm7b4cYvuZcKEs1NVh4JLTW5Hg0bog3vtvH5zGTIES7DvqHzI9qfbMFpuJDJE9eZgr7RHrLGUwJwXoXklRoq247ptTz1DYqNE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403441; c=relaxed/simple; bh=NUOF7J33SNo0WE5FvoAYCztsP3E+EVDnUROpA/hQ67c=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=naRAPITpTjvwbLqOfjqaLNfZgvIWmBg5hEyD2LgvDwHL8F4YUIQey0YsbWyy3JOXsE0HBk3h7YJy2pF2NbouHbqhiMhb5cauBtLyNpn+HBD6nAF7EMRh4bjLhJxB++AowFmzxa1Z4Ace7tkdUfa78Eqy5N6VUAsxVw1kj5JSVi4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=v2bDBJom; arc=fail smtp.client-ip=52.101.65.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="v2bDBJom" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IUUhXaSptVKNDre5NUJUjzb8Gn10VdFlVrx1HDZWMBnYzAaFSXfZE4gaPDeKy7dKEnGBzfe1JsYGqikXZPjeRp1jalMm4T3r07vipfXnGPzyed7LAW/Zk+T2RhQwnaU5VkCbrJLN9Hl2I6Uom7tph2ASpQ1JDCW1DJmxfx6MopyJ7ZVudSurxOZGqXUpPirlf4wY7b+F6pM1yvPCcmS+lb/B97AzIZ/s2/ndDhG0pEQMQJnnHSThCUFmOA2w9esSURz030cpXYqMOpmUrEYdacYooXyQ+PorcN59zy81sYvp6MiVSoDVxgPcPeURPL66DEtB89HBmmKNTAuPIT2IUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MApvW3b6HF5krhWAKtG9pIQgpnnDtvNLy3JI/M1wEEg=; b=N8tGnU1ZxRGIvrdS7IA62y3RewvomTSAztjwyXIduZ/q1XiSDBnOiOxBoG5Z8QXyV2WTRi0hMhMnrRlhFWtTSd3ESW87/KfUJcYO3dt+krRMiDLaxClJkFz2yjxpYIMLOOVTg43nIlomBAxUX2cRsh0tcHBkHHqnACG4EGt+XRk0mKdMEbfA4zrSncqsEdeNxUenTExB1LzqY4FyKcQeA38lbbMJD/oLBX20UUPQbo5tzlr9pmY5qG3SkYoZizQkRSMs03lqXIpnU9a398hI2ISlaocAPYw8t6J5TRFPJbrkPr7Ge/ddXkNqJUqX60yI3g5j7BF84ZyD+3shN4W2gw== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MApvW3b6HF5krhWAKtG9pIQgpnnDtvNLy3JI/M1wEEg=; b=v2bDBJom0jzQb+ds1WE048L0l5EKlu0uwywTy8L87CcgzoCzo4b3Oc8yplLVcdGKMWiadYxdEh97Q6OdNW+xIK5qsGH74wtJAO8HtUltCEr2Sf8BBwHeM2re4bZdc3Kkmw8DhEAYpRGUNSjmwNNE+mo8O2wXSz3puoBnr49D9tm+wXrv3Hyh8tyJwOgCOt02ECPwGWHbedaSOjDXD1lAgOG/HEyGbHvbe4+qBjt89oy8E+tg3ZYQMAqJIAV2n02yghWK9jTqYq5NKoFON0vkhGpgNzO4ipQ9XnQcZWIJnLYggY8jUbqq82g3mhODK4ZWPQnL3s3MnCosrM5rnm+jTw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by DBAPR04MB7271.eurprd04.prod.outlook.com (2603:10a6:10:1a6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 08:57:16 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:57:16 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Aug 2024 17:05:22 +0800 Subject: [PATCH v8 6/7] rtc: support i.MX95 BBM RTC Message-Id: <20240823-imx95-bbm-misc-v2-v8-6-e600ed9e9271@nxp.com> References: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> In-Reply-To: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724403944; l=6360; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=ipvnuf27dki3nO9pw5HIbOzHnHeM3TfS1+lCPTW3Gr4=; b=L+uoU8QWjKkQ5+bYjVE7wTz6p1zamPRg84KpvfOqpxuEH6yA25EHKLSpsMjwANrtlCgmUJo9H uv9zYQeyD8KCQPUFx6qLDUL5e+kklm2M6GCYuBIkKLGK/XF8CbOXml1 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0173.apcprd01.prod.exchangelabs.com (2603:1096:4:28::29) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DBAPR04MB7271:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cd11d93-247c-4006-6ca8-08dcc351962e X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?FipZWp3LZia10Epz2JP9ipreFjpblFS?= =?utf-8?q?ZNKMzoQvL/m9FQyIIU2csplJmSj1L/nZ4DV8emSQ3LQ58Di1LaQZIM8BZ80X5LLfv?= =?utf-8?q?idOqUSIDixUn/uEej3fxa0+YwWvY2DFVPe36St7h0DDmh7PWUo90AsCOG2RgKkN2v?= =?utf-8?q?w4j8I+OHZSh4KU8Wy4QsV+KA/RQ+KWO6ZPdjh8AZSIhoQ9k387Yzdpjr7D9EdPg6d?= =?utf-8?q?SiwJ4MVfWPWklhUdrYdj+ip7Ag0mm3I5H9b4SVCOIXVDElaSIm8ctNHFnAzdGylVe?= =?utf-8?q?1iTB9TE6cUozUbkqziReVEJ0pZJ2hnmhDUAgv4xIbW6QVbbGun5U35QOMFAUYM4UB?= =?utf-8?q?zHdYA9hWqg3H6msfZPE6EX9Ti6EOT6rTO/pXw9cJZmRMhzElKP2sw0SkCO7uIcheH?= =?utf-8?q?gmK3Fp8k2H+3ghcnzy2GDPXgnuxiH0kKFXYPu326TsS8TFtTrfjWMUt+Nss0YQlAe?= =?utf-8?q?DqYg6HXpExtsDivTXPfovtCT75ZwvfIPfNdTgxykPNDIrV9nuQ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i5qxo=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Rr+/vbSOp0BljZ7PjYPujzfDUiB4?= =?utf-8?q?cG4fQMg71q8XPYOHNwh/5Nur5MyYUozGHUct5LfZaV7sEs4gQ8KjXGu0C6GhpWF+t?= =?utf-8?q?V7zKDXArmPeeIRV9T5wiynsZ1Jnhi3VNgRGsOejbcQgeYO+OaXkO1++tCzvi4OHw+?= =?utf-8?q?6hTZ4m0GCF0twjn8XccDkUvqIb4/bwdprMvXwuCMNX/QNCpcOmf0WH/HmxOq7HYRV?= =?utf-8?q?kJyazVGnG61AlAL91vBY75mTstkSha0LlgE5hpO9s7JkjJ4tL6oi+xCkoo30RoIdJ?= =?utf-8?q?s7wlhAGj4Vd+HJKEov5mq0hpe3sF24jrlOPDB5eHBna9wjsG+uE2B2W0XNuDhT2y1?= =?utf-8?q?UF22Oe1D5Q1qoqvM1DO8cfiaqbePJoDyRjX5nwMzZwMw+yFOrFbbl9y+9PvlqSrnR?= =?utf-8?q?8OLG6zpngKLYjUwlojiStkYcUujmOYAE6h0bgX48mtRkLwt0s7UqG9sAXaWw9mNBV?= =?utf-8?q?+FSaInkefqjGOli1udi+QnL2rZoryBBF8dnjtoWmNUBQN3Foj3K895VvLJGM/veK3?= =?utf-8?q?jP2qNz/51YW+4DKzfnJUn0xO4bAvWFTUd7TIg+BzR5xDRZay60D860NP6hnpYlW7f?= =?utf-8?q?K0LzsJEsb6wWrAJczQOwkdQAs3H0UiQDyBXWnANX9E9gDx0Bupj7BN5KZ1M/9FLgN?= =?utf-8?q?cc4+su94n/O5TUtesELS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.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cd11d93-247c-4006-6ca8-08dcc351962e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:57:16.0454 (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: c1u2bVMBau0Mfi01SO0rc50Zc6gWdm5JIZiS0hfcYxLRlY610mifPjw+1+iUHjz7PQ1YEJjrdFY1iPxlzXr7Vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7271 From: Peng Fan The BBM module provides RTC feature. To i.MX95, this module is managed by System Manager and exported System Control Management Interface(SCMI). Linux could use i.MX SCMI BBM Extension protocol to use RTC feature. This driver is to use SCMI interface to get/set RTC. Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan Acked-by: Alexandre Belloni --- drivers/rtc/Kconfig | 8 +++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-imx-sm-bbm.c | 162 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index b3469f6986e9..ea416938ad24 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1827,6 +1827,14 @@ config RTC_DRV_BBNSM This driver can also be built as a module, if so, the module will be called "rtc-bbnsm". +config RTC_DRV_IMX_BBM_SCMI + depends on IMX_SCMI_BBM_EXT || COMPILE_TEST + default y if ARCH_MXC + tristate "NXP i.MX BBM SCMI RTC support" + help + If you say yes here you get support for the NXP i.MX BBSM SCMI + RTC module. + config RTC_DRV_IMX_SC depends on IMX_SCU depends on HAVE_ARM_SMCCC diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 3004e372f25f..8ee79cb18322 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -74,6 +74,7 @@ obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o obj-$(CONFIG_RTC_DRV_HYM8563) += rtc-hym8563.o obj-$(CONFIG_RTC_DRV_IMXDI) += rtc-imxdi.o obj-$(CONFIG_RTC_DRV_IMX_SC) += rtc-imx-sc.o +obj-$(CONFIG_RTC_DRV_IMX_BBM_SCMI) += rtc-imx-sm-bbm.o obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o diff --git a/drivers/rtc/rtc-imx-sm-bbm.c b/drivers/rtc/rtc-imx-sm-bbm.c new file mode 100644 index 000000000000..daa472be7c80 --- /dev/null +++ b/drivers/rtc/rtc-imx-sm-bbm.c @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP. + */ + +#include +#include +#include +#include +#include +#include + +struct scmi_imx_bbm { + const struct scmi_imx_bbm_proto_ops *ops; + struct rtc_device *rtc_dev; + struct scmi_protocol_handle *ph; + struct notifier_block nb; +}; + +static int scmi_imx_bbm_read_time(struct device *dev, struct rtc_time *tm) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + u64 val; + int ret; + + ret = bbnsm->ops->rtc_time_get(ph, 0, &val); + if (ret) + return ret; + + rtc_time64_to_tm(val, tm); + + return 0; +} + +static int scmi_imx_bbm_set_time(struct device *dev, struct rtc_time *tm) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + u64 val; + + val = rtc_tm_to_time64(tm); + + return bbnsm->ops->rtc_time_set(ph, 0, val); +} + +static int scmi_imx_bbm_alarm_irq_enable(struct device *dev, unsigned int enable) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + + /* scmi_imx_bbm_set_alarm enables the irq, just handle disable here */ + if (!enable) + return bbnsm->ops->rtc_alarm_set(ph, 0, false, 0); + + return 0; +} + +static int scmi_imx_bbm_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + struct rtc_time *alrm_tm = &alrm->time; + u64 val; + + val = rtc_tm_to_time64(alrm_tm); + + return bbnsm->ops->rtc_alarm_set(ph, 0, true, val); +} + +static const struct rtc_class_ops smci_imx_bbm_rtc_ops = { + .read_time = scmi_imx_bbm_read_time, + .set_time = scmi_imx_bbm_set_time, + .set_alarm = scmi_imx_bbm_set_alarm, + .alarm_irq_enable = scmi_imx_bbm_alarm_irq_enable, +}; + +static int scmi_imx_bbm_rtc_notifier(struct notifier_block *nb, unsigned long event, void *data) +{ + struct scmi_imx_bbm *bbnsm = container_of(nb, struct scmi_imx_bbm, nb); + struct scmi_imx_bbm_notif_report *r = data; + + if (r->is_rtc) + rtc_update_irq(bbnsm->rtc_dev, 1, RTC_AF | RTC_IRQF); + else + pr_err("Unexpected bbm event: %s\n", __func__); + + return 0; +} + +static int scmi_imx_bbm_rtc_init(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + int ret; + + bbnsm->rtc_dev = devm_rtc_allocate_device(dev); + if (IS_ERR(bbnsm->rtc_dev)) + return PTR_ERR(bbnsm->rtc_dev); + + bbnsm->rtc_dev->ops = &smci_imx_bbm_rtc_ops; + bbnsm->rtc_dev->range_max = U32_MAX; + + bbnsm->nb.notifier_call = &scmi_imx_bbm_rtc_notifier; + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM, + SCMI_EVENT_IMX_BBM_RTC, + NULL, &bbnsm->nb); + if (ret) + return ret; + + return devm_rtc_register_device(bbnsm->rtc_dev); +} + +static int scmi_imx_bbm_rtc_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_protocol_handle *ph; + struct scmi_imx_bbm *bbnsm; + int ret; + + if (!handle) + return -ENODEV; + + bbnsm = devm_kzalloc(dev, sizeof(*bbnsm), GFP_KERNEL); + if (!bbnsm) + return -ENOMEM; + + bbnsm->ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_BBM, &ph); + if (IS_ERR(bbnsm->ops)) + return PTR_ERR(bbnsm->ops); + + bbnsm->ph = ph; + + device_init_wakeup(dev, true); + + dev_set_drvdata(dev, bbnsm); + + ret = scmi_imx_bbm_rtc_init(sdev); + if (ret) + device_init_wakeup(dev, false); + + return ret; +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_BBM, "imx-bbm-rtc" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_bbm_rtc_driver = { + .name = "scmi-imx-bbm-rtc", + .probe = scmi_imx_bbm_rtc_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_bbm_rtc_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM BBM RTC driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Aug 23 09:05:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13774780 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013006.outbound.protection.outlook.com [52.101.67.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 628D3185E7A; Fri, 23 Aug 2024 08:57:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.6 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403447; cv=fail; b=KnmFdCRXqk5sERcFYjOB8SuG2MMypa+5h2uaf6/65c156Dl6qN/pFEAIKneCdZ97+fEnFQflj+ORk8J5cXHh9mfnn2MNYQHwmtBPIucWQ3JZ8aDCjh6B9D64bT7TKHr6B0/L+D3euiPfX3ihSVPzZrpmOe+79BMjCepncOwhlfQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724403447; c=relaxed/simple; bh=kxc2eMKo0SVpN4AB/VCrof0om0KnqGLBnf+CDyaUvMI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=QebUt3CUvkHryxWD1F5tlx3iDUYvkr0YRxXUFnHDb/Y/Blk+u8iwtJULMgp1IbN8LPnn9GvNLWDQ+2dhH97KNLW0o9DgIkIZYm5yfuCduiKeEzA80xFaoeDGj4DH/zsKa1Ha8DwOWl56khtAuOpfu6psf2v75nOVi/lZ527XvEA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=FsEEpEbR; arc=fail smtp.client-ip=52.101.67.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="FsEEpEbR" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kpij4SS1cQ54AW18dYMCid13TI+bny1rpx9XE/yAQD/tl8nj9gbufppNN3DLQya8xPbaTAckFI6/rZs9Vzp9+FcmnZXhCyPYiFuF+cIcuAj71i+/yINeiq3lVDRqudfw61BDLcB39038dQZbcZCGbCLS7RO1gLfid1bkNNBK9Ov6QXHh8wkphhFrk5DAtIlwNu6hUAOZym1lG/Jq+nHwfvLu/1oQu2NtjAuYvRXRFTjwA0csp2jPOJONeBHzUZ9z7qeEteoMzphDEi6v++0dpEiei0ApJ1zoRQaS673JW+RaQzbu33uPf+VKg0tNm/ud1/W3zf/Ce59kcdVGhj1lIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VwVO40Kbuaig/BZztDwJec5em76QDLNVCraOKEbMZg0=; b=qALvMGGBoIc0rmpTqOxIxw37JH6YiTdyCTrWv0I40f6ZvzVn+cRE+fZMzr2gOZzYhXbjKbXlZxFi5B30+HK+Zw7eArccmQK5AsGpqqPEd7Moxu2UCnnfD0cC+7F2cT5SjtHne5VPBHQwp8jeDZTyA9YJTRLZoHgOcqjj0J/H0I2LJHcplUgkKiyRmZccpGL9bDrJ9okVov8YEXhWMZ8UpuCPfgL1JuxAIy6CUUNErec7re1OgsDVjeheOJZNsXk7ztTWVryxu4hc8pNCfx+kTdhJGsPlJ0yJYDFDGWxOGGxBSyRDhtzxTTTWBb/InH5PLtRl0LWEt9NnTsPxwdaRCQ== 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=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VwVO40Kbuaig/BZztDwJec5em76QDLNVCraOKEbMZg0=; b=FsEEpEbRCaUcGGbeP9PGJ63XpVeUmMWAY8pw5Oj8fsjBZE/1CQrZzexol6YTZylmxF/yp7c58zV+Ohg54s7yvmI67aWZ8mbsMp32mPlVGPcmwsNPicyGJ7/7s8kkroRWTKvECGLWlJWuNCea9pWq5d3ItP3qMzVFdbxogkQBQsqAHIFXKWFC3RxEenRn+P3fhwA2QfWxUQuV6dY0etdFA+m34rddzIaaOmOaB1KYXd5x/84BWPhfeQY8/GdljT9j1wDSMISzGHigwefzBu7XlKSK10DoqRsv40zTtxdzMb9fzW18H7SBzYOmm15wHWVdaAj8K4/VvbedkvMEWhS7LA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by DBAPR04MB7271.eurprd04.prod.outlook.com (2603:10a6:10:1a6::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 08:57:22 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%6]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 08:57:22 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Aug 2024 17:05:23 +0800 Subject: [PATCH v8 7/7] input: keyboard: support i.MX95 BBM module Message-Id: <20240823-imx95-bbm-misc-v2-v8-7-e600ed9e9271@nxp.com> References: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> In-Reply-To: <20240823-imx95-bbm-misc-v2-v8-0-e600ed9e9271@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Alexandre Belloni , Dmitry Torokhov Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1724403944; l=8234; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=sBgFKxgc7cdv86yg3Whp2f3mLa6n9LiELZb9Y0Qgs7w=; b=3W6TfSHzhGlTGIFXb/Sq/VuSvXyypK5QU2RUIMyP1lXLuhiXl3qxqa1iQzJO4cLJpppoy7wvL NmlVg2jAf1rBN+IVFIxDgoefBntCoOw8z4sWnCFI5MCaASTwp5Okj7P X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0173.apcprd01.prod.exchangelabs.com (2603:1096:4:28::29) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|DBAPR04MB7271:EE_ X-MS-Office365-Filtering-Correlation-Id: bbbebbe4-0d6c-4260-a3cd-08dcc35199f5 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|7416014|1800799024|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?ltpHiDlf8qRaxkleVuTdWmoZq3zbN6U?= =?utf-8?q?LQ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bH5bKmOq/1Xi8u98QZsoUGSov06ryZSEn3TTuEVn9bKU/XlO+gXgFvn+3x1Im?= =?utf-8?q?9zbD2VN1XsW2ufCxrhk/8eTIr5Jgi6m5HbF8zgcLvpxv+u2RuLSZP3m4ii5ngA8WD?= =?utf-8?q?vneovtFlKJYttu4Nt/J78oGBZgO+q5PX1ccalBItZQ8wVUpVjUIMK/PZMc+PKOLO7?= =?utf-8?q?kbCp2z1VR/rXieoGx8GiXTqWSWrcgUysrwz+xMVQ2bPxFAf6CZsMRf3SlfxCHmIi/?= =?utf-8?q?zheqgitMJr9pHW7mdHK7ShuX/y+vny8dsI/ETeuhmqpncM+usYKifIzBxUjzauZB1?= =?utf-8?q?QH7z1MCcyHtVkO9ErUR1E+bsIr7DU0HrbmDhsf+bZ+CZQDPo/TEqzq6bINciQoW0o?= =?utf-8?q?Gols0uCbxiNU5nfACQ+w5qDdk8fxSyBZF2Gy5U++17zk8cjENvxJN76xUQJffJsmP?= =?utf-8?q?TZ15x+LspEuXjchpFBv1z7PbeDRYoPWIkZ1xhrS3sJ5BMKYbL/lnXso=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(7416014)(1800799024)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?R31BB3swEwVIqeWfAjIWdOnPprwx?= =?utf-8?q?2RQ7BfRFJGdgw7ppOYGFkSKmYEZ0uwpBEuoVOR5vnf7NqVTJl37fLyzL0sejw3FAC?= =?utf-8?q?fwk8W9HpXucHAgTeE9dAZljZH/ON1qFV7Mqr71WkE2gxkz6GzeY3/x9fZAd1//PXd?= =?utf-8?q?SXR7BCCgL4nh839+0OCtw5tpIkRER0c4qz8w4w4X9B+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s58UXoIJQoTDt6OPf?= =?utf-8?q?mkbiyz16r9/fkqudx6tCjL9A5z3Ayw60OKNQwGpdqnjY3Z804u45b5HvJZux86cRX?= =?utf-8?q?NnAhTjcKajP6ZUjtcjKMXptp16Vvke4NjPV6xbAkmOmpbmbWjuDzuzOOuQLEOQE3m?= =?utf-8?q?5rMuhYzxeGAirdg15Gz62Mv9IS7/qHjKoVJVld9QyJe67EoCaiH0XyCsS+ywvpWhE?= =?utf-8?q?Uw2RCJVDXQh0sTuM99tenmTg7U8AdGCAElWJ5YK3MQg0ael4nG+HO8An9nPONGt6O?= =?utf-8?q?S/ZfCtgXwZDrSWV5M07vh9iveSW1QNurYnejFiHZkzgUPARsIiLnUby09jLysRdE8?= =?utf-8?q?27euusDBV2jZj86wMHnUn2WrQDMP637dT/ZS3/TEzBTorcensmfIcy/WMrPKCX0QI?= =?utf-8?q?RZ83bNpV5R5Mi9tIP8u/AJ9rN0SRLgafVmadOMJNQ/gVmFWPuWG5GBLOvLisuxhlo?= =?utf-8?q?GQyBNXSVyLRL?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bbbebbe4-0d6c-4260-a3cd-08dcc35199f5 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 08:57:22.3720 (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: NX6BawmhwsvRj7fCFTggvMsyyjGYapeA0GnX72h39q4sPcZbPXW4m7OgLHERFHYVpZfitbI6iNZfpmGkAultfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7271 From: Peng Fan The BBM module provides BUTTON feature. To i.MX95, this module is managed by System Manager and exported using System Management Control Interface(SCMI). Linux could use i.MX SCMI BBM Extension protocol to use BUTTON feature. This driver is to use SCMI interface to enable pwrkey. Acked-by: Dmitry Torokhov Signed-off-by: Peng Fan --- drivers/input/keyboard/Kconfig | 11 ++ drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/imx-sm-bbm-key.c | 225 ++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 72f9552cb571..a3301239b9a6 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -454,6 +454,17 @@ config KEYBOARD_IMX To compile this driver as a module, choose M here: the module will be called imx_keypad. +config KEYBOARD_IMX_BBM_SCMI + tristate "IMX BBM SCMI Key Driver" + depends on IMX_SCMI_BBM_EXT || COMPILE_TEST + default y if ARCH_MXC + help + This is the BBM key driver for NXP i.MX SoCs managed through + SCMI protocol. + + To compile this driver as a module, choose M here: the + module will be called scmi-imx-bbm-key. + config KEYBOARD_IMX_SC_KEY tristate "IMX SCU Key Driver" depends on IMX_SCU diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index b8d12a0524e0..5915e52eac28 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_KEYBOARD_IPAQ_MICRO) += ipaq-micro-keys.o obj-$(CONFIG_KEYBOARD_IQS62X) += iqs62x-keys.o obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o obj-$(CONFIG_KEYBOARD_IMX_SC_KEY) += imx_sc_key.o +obj-$(CONFIG_KEYBOARD_IMX_BBM_SCMI) += imx-sm-bbm-key.o obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o diff --git a/drivers/input/keyboard/imx-sm-bbm-key.c b/drivers/input/keyboard/imx-sm-bbm-key.c new file mode 100644 index 000000000000..96486bd23d60 --- /dev/null +++ b/drivers/input/keyboard/imx-sm-bbm-key.c @@ -0,0 +1,225 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEBOUNCE_TIME 30 +#define REPEAT_INTERVAL 60 + +struct scmi_imx_bbm { + struct scmi_protocol_handle *ph; + const struct scmi_imx_bbm_proto_ops *ops; + struct notifier_block nb; + int keycode; + int keystate; /* 1:pressed */ + bool suspended; + struct delayed_work check_work; + struct input_dev *input; +}; + +static void scmi_imx_bbm_pwrkey_check_for_events(struct work_struct *work) +{ + struct scmi_imx_bbm *bbnsm = container_of(to_delayed_work(work), + struct scmi_imx_bbm, check_work); + struct scmi_protocol_handle *ph = bbnsm->ph; + struct input_dev *input = bbnsm->input; + u32 state = 0; + int ret; + + ret = bbnsm->ops->button_get(ph, &state); + if (ret) { + pr_err("%s: %d\n", __func__, ret); + return; + } + + pr_debug("%s: state: %d, keystate %d\n", __func__, state, bbnsm->keystate); + + /* only report new event if status changed */ + if (state ^ bbnsm->keystate) { + bbnsm->keystate = state; + input_event(input, EV_KEY, bbnsm->keycode, state); + input_sync(input); + pm_relax(bbnsm->input->dev.parent); + pr_debug("EV_KEY: %x\n", bbnsm->keycode); + } + + /* repeat check if pressed long */ + if (state) + schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(REPEAT_INTERVAL)); +} + +static int scmi_imx_bbm_pwrkey_event(struct scmi_imx_bbm *bbnsm) +{ + struct input_dev *input = bbnsm->input; + + pm_wakeup_event(input->dev.parent, 0); + + /* + * Directly report key event after resume to make no key press + * event is missed. + */ + if (READ_ONCE(bbnsm->suspended)) { + bbnsm->keystate = 1; + input_event(input, EV_KEY, bbnsm->keycode, 1); + input_sync(input); + WRITE_ONCE(bbnsm->suspended, false); + } + + schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(DEBOUNCE_TIME)); + + return 0; +} + +static void scmi_imx_bbm_pwrkey_act(void *pdata) +{ + struct scmi_imx_bbm *bbnsm = pdata; + + cancel_delayed_work_sync(&bbnsm->check_work); +} + +static int scmi_imx_bbm_key_notifier(struct notifier_block *nb, unsigned long event, void *data) +{ + struct scmi_imx_bbm *bbnsm = container_of(nb, struct scmi_imx_bbm, nb); + struct scmi_imx_bbm_notif_report *r = data; + + if (r->is_button) { + pr_debug("BBM Button Power key pressed\n"); + scmi_imx_bbm_pwrkey_event(bbnsm); + } else { + /* Should never reach here */ + pr_err("Unexpected BBM event: %s\n", __func__); + } + + return 0; +} + +static int scmi_imx_bbm_pwrkey_init(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct input_dev *input; + int ret; + + if (device_property_read_u32(dev, "linux,code", &bbnsm->keycode)) { + bbnsm->keycode = KEY_POWER; + dev_warn(dev, "key code is not specified, using default KEY_POWER\n"); + } + + INIT_DELAYED_WORK(&bbnsm->check_work, scmi_imx_bbm_pwrkey_check_for_events); + + input = devm_input_allocate_device(dev); + if (!input) { + dev_err(dev, "failed to allocate the input device for SCMI IMX BBM\n"); + return -ENOMEM; + } + + input->name = dev_name(dev); + input->phys = "bbnsm-pwrkey/input0"; + input->id.bustype = BUS_HOST; + + input_set_capability(input, EV_KEY, bbnsm->keycode); + + ret = devm_add_action_or_reset(dev, scmi_imx_bbm_pwrkey_act, bbnsm); + if (ret) { + dev_err(dev, "failed to register remove action\n"); + return ret; + } + + bbnsm->input = input; + + bbnsm->nb.notifier_call = &scmi_imx_bbm_key_notifier; + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM, + SCMI_EVENT_IMX_BBM_BUTTON, + NULL, &bbnsm->nb); + + if (ret) + dev_err(dev, "Failed to register BBM Button Events %d:", ret); + + ret = input_register_device(input); + if (ret) { + dev_err(dev, "failed to register input device\n"); + return ret; + } + + return 0; +} + +static int scmi_imx_bbm_key_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_protocol_handle *ph; + struct scmi_imx_bbm *bbnsm; + int ret; + + if (!handle) + return -ENODEV; + + bbnsm = devm_kzalloc(dev, sizeof(*bbnsm), GFP_KERNEL); + if (!bbnsm) + return -ENOMEM; + + bbnsm->ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_BBM, &ph); + if (IS_ERR(bbnsm->ops)) + return PTR_ERR(bbnsm->ops); + + bbnsm->ph = ph; + + device_init_wakeup(dev, true); + + dev_set_drvdata(dev, bbnsm); + + ret = scmi_imx_bbm_pwrkey_init(sdev); + if (ret) + device_init_wakeup(dev, false); + + return ret; +} + +static int __maybe_unused scmi_imx_bbm_key_suspend(struct device *dev) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + + WRITE_ONCE(bbnsm->suspended, true); + + return 0; +} + +static int __maybe_unused scmi_imx_bbm_key_resume(struct device *dev) +{ + return 0; +} + +static SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_key_ops, scmi_imx_bbm_key_suspend, + scmi_imx_bbm_key_resume); + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_BBM, "imx-bbm-key" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_bbm_key_driver = { + .driver = { + .pm = &scmi_imx_bbm_pm_key_ops, + }, + .name = "scmi-imx-bbm-key", + .probe = scmi_imx_bbm_key_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_bbm_key_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM BBM Key driver"); +MODULE_LICENSE("GPL");