From patchwork Fri Apr 12 10:47:07 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: 13627611 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7BBA9C04FF6 for ; Fri, 12 Apr 2024 10:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=WJ2SqVHDEs39E/mJDq0bY2cuGJBE/2FBxZzHhMHxG8Y=; b=mvq0ysD8TiY+WOqdfROhoZEkAK s1v8rvddbd8LqN626HaDG3qXNDppXl5EhWcxp3HDBksYdqY2tUg1NjFOPoDx57l8i1XFpC4JQIKJD NXQtAnYnz+jgVG2nM4XZHceKqi5FYHKIxmUOv5r8csV2vyci5Tx86KvSrSWEKUKwV0WeCfrffIhpd j2zJh0K3ZLazofeke0xg5BFpWjVVqMR2lN/jLR70Qf/7zNtvRqjFm679tTwabVwzatTrj2rKS0GUC LfhCSfpmlhxpj9gdlbO4y85rMDI8CZ+R0JGwj6Mal9oxf7Mz7/j8pXFyrYTV8GhBdqwJU9pPZULQM 1ODU/R3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvELM-0000000GkRr-3XKO; Fri, 12 Apr 2024 10:41:16 +0000 Received: from mail-vi1eur02on20601.outbound.protection.outlook.com ([2a01:111:f403:2607::601] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvEJl-0000000GjXF-1AO1 for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 10:39:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TNNgR1ZBb9LEShufrMuz4kwbdF5TEbwP7TF/gZaHvuyOg/RU21Ogd5Z7K2VGaVl1I7WVUBu2fCX2HTSw5x5W8KxWFvTbsKSlWqeqsYyMAyKPcCSBndiX64xzae34pab/gGgzut/i0WnMohHdgXjT4FRGOZd9e2WBXUbV/z37iIgG5hmPgUiRtGLrVkr5wFN4XEH2oPQKKOV8/0h5qF2izBvxvdsdP1RDPKk+BNW8r2MtVd9rq5jywBJd38HzV0QU373uhJv4EF0UyyTD0SM6lbCLvx8gCXU3Gxkys+6tQLnbP0z6DjofIZIxl32/xj6HjWCpNBo5jQzABAtwqKY4dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a2gl1Sp6ayVBbajmw1IMfR+FqAfWlcMNAdiZatq5fI8=; b=Hy+vNE1TpYyLSk0TZ5TBjK6CJsbQTRU4FJZ6jUHmGGd8Iuc+mXj9i1rLu+FjBY4Ym72mjQ+mzEySGuGRk6T+5dVfPzdp6HZRCwhCbhi6gEDGhPNBvWjpN1BAF2q06p5l0pIdDg3AAs0xE/EPZmD3AxsbUG1dRyCmztZwkxsa1X0Iq0BCoggZwRRgJL0LIZNJGx35kC2PaAJLUDf06LE3NVAJz81jBChzORWcDctQi8txH5p9cSalapNXGTLLAimCO0qnQNcWp7ugV7hR/rXQN8vcY1tyNTT0UY3fhsXiIW2stMNbOo+n6HVyPvgncGa8/Ys8Rd5qhqUTzebXw4Q0wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a2gl1Sp6ayVBbajmw1IMfR+FqAfWlcMNAdiZatq5fI8=; b=Mbw/2gVHzu0u6zDv9km+qxJfI+7L8Tf9YS2cgJ3GqHMHKSvWm6cYE9EPueJMRdyTYs6VxUbEFkmwDx6L7FLHHS/qEyGMD1OX6ZftJGEP7BxR7UQEfOSaFp5LPO62hJUfFKBCTi1hThkROY7dXGvkYhxRuOvo+SoW7oxZQMPqXy8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) by VI2PR04MB10147.eurprd04.prod.outlook.com (2603:10a6:800:21e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.56; Fri, 12 Apr 2024 10:39:20 +0000 Received: from PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54]) by PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54%3]) with mapi id 15.20.7409.039; Fri, 12 Apr 2024 10:39:20 +0000 From: "Peng Fan (OSS)" Date: Fri, 12 Apr 2024 18:47:07 +0800 Subject: [PATCH v3 1/6] Documentation: firmware-guide: add NXP i.MX95 SCMI documentation Message-Id: <20240412-imx95-bbm-misc-v2-v3-1-4380a4070980@nxp.com> References: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> In-Reply-To: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi Cc: Peng Fan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712918849; l=55803; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=fyjiPW7i3Esi/kVBE11tRQYjEUzJGakaE7Z+lYybjKY=; b=mOOVFcgtk5dQwc0kC/sJvbdZYvb/jWhoOSHsT6rCUetTehe+EvbLkqXDGXrlCEjcdj/ZRq6W0 yfmA10uaBv1B60EMqRF82hUrJF8lUL29ZAjcOCTtsqZmBbk3vg40/3b X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0243.apcprd06.prod.outlook.com (2603:1096:4:ac::27) To PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9416:EE_|VI2PR04MB10147:EE_ X-MS-Office365-Filtering-Correlation-Id: 33f30bd9-6d5a-4ab0-416d-08dc5adccfbf X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pz5kTqeyyy1uU+LmpRXQbw6rDpkV9uTIU3W+SpAi5gCcPTj6vazZnI7jbqD4/U0xajtx8HzXd2hcfxQb1H9zKLnlWO8MOCy4wATrj1urj6+RakQ+W44VFR/dLytQjTG9fS+bpOM/P4wqJCUeaQB8MyPBZmXam5uPOxyyHl30TjSvLzt3+APcAS9ptwzcGgeKq35lZK3CmHqULvvh1KZnlSckZE0OTggdhJI5NpCvWbRnZauTF26EBgu5Y53h8Rqla/24I6/CWiWg07aCAHcm0RF4/KPG4jpUyqFGpmLB/KjwJ86OLXbSI+wAMwEO8LAI68RO7T9qQLJmY8C0lgWtbNETaUXcYtDItvcHbnNbi5llgQ8quGhBPDFcKipjVbv3535tjIcFDg7Lx+YWet4n1UXBwSefwLsLjmRfaSKlhtMNUk0eWmoBEGjTN6/ymFi8whBP+09JJSprMcJsl+TMAGG84u9NAGRw529FZ0IaxGfwyBOZuAHKNtr/TdoL3/6DLhSq15jGbE5sshWb4gqkqIvX4C2fE+eZ9NF6fKJ5QxYndZ+Jnh1SEsg90OcHBftdVKX6qCMEpRXmDV1xgEu+So8RwHXFc0PX4hTyFo4gwca0adw9AbSSBMgv2RkJINlOGvyqtaVqK3n5stK3MANS26she5yqVwi+AKMGlMLO5xiP9R1U9TuCf9V08Y5hz0L8rg1NqXWjMyRYhu2q+dhwQgwHgyhtg6qzRXtJl8gM+Tc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB9416.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(52116005)(1800799015)(366007)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?eYlnRD4QrZs0HoF1p9YelLigvOf5?= =?utf-8?q?Zu5dk0orxlPu0p/7DKPUqe9DiYB/m0FeKU543phNLpkvh+YM7YiaNfVUaMsce/1dZ?= =?utf-8?q?4EwlU8KDMwFpySi/hsz9yYMBSYsHbVmXeHjzVSF8O2qMk3BpVXDoOfXeaIpuDuIW+?= =?utf-8?q?JYl7kO8tys9yxiZP4LcQ67clrDpw17tnKaxWeLE4GMQRlMHtDm263/uqgHkWlThgU?= =?utf-8?q?racjMdJ0deaCgKrXvTDN9NJCIgUF13zSjl89sgTdb0OFm906OotIG4Ry1fqM9idnN?= =?utf-8?q?UaM6J7g5HQZqTS9wdUCcl6n7tJDdjfgvBxHOKD09lKmtmeeWJz56sQH4w4eUEC9zl?= =?utf-8?q?oyq0Zq7hjje+1Mjs2F5Yo7dl0nc3XG/8wDvEWRco0MSwtvv41Sv4HD5eRtDXSaCDS?= =?utf-8?q?MRY/b/OSguOQf7ljm6U3zuNGJsjr01EWaiUsUCPGJ7RAnVxmZtLxxneIqkU7ZtKE4?= =?utf-8?q?nGRd/cw16SxHdPfu5KeTaWvv0b1wGk0hjfTPgAaOffI5Yo8rbfll+r92LdrYWYesC?= =?utf-8?q?k2555r/mPZxPhWrWKXQAvWfBWQKWCFvevzlAj7UJectqf7bTwPUUJqy9Xo8ephRzQ?= =?utf-8?q?AS4SzH/o0fpkZkxJGqSRA/HQ5YeGh5zBcLOiD8PPzMn5tH6hGh0MC7IY2/z8C+tf3?= =?utf-8?q?IXv9NyoiZEPdikfHWICY8W9j+BJorHchmtluCy/QUreZAO14Cxz4Z7Nuy6slN5C46?= =?utf-8?q?qclm036EZlC7EuJzxecujoq1MrJ2g8ehMPLvq7/JjSDmC00shHjQ4Zw9VXfrEcNZ/?= =?utf-8?q?SDOXtBo6YwlkpbxbuDATvm8GFXamYUr9upJIQEbAw/SWzee/itKQzqWCNlOs90TpG?= =?utf-8?q?3lZsJ8DBx+InMeDdn4VmbcspI4UAr+RN54EjR5A1txCiYTB5wG8C+uUt1koNBdkDC?= =?utf-8?q?H+Z4rQsRB+mzpHCL7S1xEkUzAb0N9bXDBuWaRXFHmUTTtNGFl/ZZ6dVMcQBVeQPVv?= =?utf-8?q?I9N7a4wqgzAoShWVFVn3bZBuQbI68aMrXLk/Cy6ZMxcgUamrhrmtOIqpzbAFQMHu4?= =?utf-8?q?Sbcf0/I7Z297KCJ1d7agn00gWJq+bJKWImmRZuC1ZV4XKpvvRjfL8o21fKTcdPRWg?= =?utf-8?q?3/h8jHYdSg7W+3jfchqZDRVdQJoCtZGy5Y+l1j3KFDb3XSM4UL3XPBEw+XFGx/43A?= =?utf-8?q?skO82VRgsDQI897asdqGG4Fay5z3AOwt7cZdEEZqRmFiSJ4pKVAMeinLOEkAaxAo6?= =?utf-8?q?M9L62D17opSmh0wWvVBDKn+Etltr3KPkJZP9UyQIWRNoqgQu5cgxecf2rNaVvwnf0?= =?utf-8?q?5g2/IqjcQjBRDOamUFoL22VMyKv0Q8u+s8IuZeqqp+YucQRZmZi8ShLN7ZVw2o1QN?= =?utf-8?q?qggbHydrjY27j9qWs37pzhDNg9MRQegQ7Wl7ntweMz0nV1nx88j6FUe6YSChyo9Ra?= =?utf-8?q?28AEHXrv9S3B9U64v+3eNrKp5LunPV6Iq5l5/oJYtzlIKtVXWvFx/mvmF1yqUmuM8?= =?utf-8?q?YVBfczl6uCHEXzYTB9KJL0ncDQCZsNaw35atrhU89ZdGS0D16rm4IL2VLNbWpv447?= =?utf-8?q?nbi+c3HpAStf?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33f30bd9-6d5a-4ab0-416d-08dc5adccfbf X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9416.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 10:39:20.7747 (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: F0ezFm/Q3Jj0zOG4/JygGn/EA6Q0oUIlCTsstoIOLPRDOF1fmsK58zPTPl1GEUnbyKi9/MeiyNChfag0wXs5lw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10147 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_033939_167090_35100FC0 X-CRM114-Status: GOOD ( 16.17 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan Add NXP i.MX95 System Control Management Interface(SCMI) vendor extensions protocol documentation. Signed-off-by: Peng Fan --- Documentation/firmware-guide/index.rst | 10 + Documentation/firmware-guide/nxp/imx95-scmi.rst | 877 ++++++++++++++++++++++++ Documentation/firmware-guide/nxp/index.rst | 10 + 3 files changed, 897 insertions(+) diff --git a/Documentation/firmware-guide/index.rst b/Documentation/firmware-guide/index.rst index 5355784ca0a2..8f66ae31337e 100644 --- a/Documentation/firmware-guide/index.rst +++ b/Documentation/firmware-guide/index.rst @@ -4,6 +4,9 @@ The Linux kernel firmware guide =============================== +ACPI subsystem +============== + This section describes the ACPI subsystem in Linux from firmware perspective. .. toctree:: @@ -11,3 +14,10 @@ This section describes the ACPI subsystem in Linux from firmware perspective. acpi/index +NXP firmware +============ + +.. toctree:: + :maxdepth: 1 + + nxp/index diff --git a/Documentation/firmware-guide/nxp/imx95-scmi.rst b/Documentation/firmware-guide/nxp/imx95-scmi.rst new file mode 100644 index 000000000000..bd87a961e4a5 --- /dev/null +++ b/Documentation/firmware-guide/nxp/imx95-scmi.rst @@ -0,0 +1,877 @@ +.. 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. + +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 3.2 Specification +with vendor specific extensions. + +SCMI_BBM: System Control and Management Interface Driver (BBM) +============================================================== + +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 v3.2 section 4.1.4 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 v3.2 section 4.1.4 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 written. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to write | +| |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 set. | +| |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 v3.2 section 4.1.4. | ++------------------+-----------------------------------------------------------+ +|uint32 state |State of the ON/OFF button | ++------------------+-----------------------------------------------------------+ + +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 Interface Driver (MISC) +================================================================ + +Provides misc. functions. 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. 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 v3.2 section 4.1.4 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 v3.2 section 4.1.4 for status | +| |code definitions. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Protocol attributes: | +| |Bits[31:24] Reserved, must be zero. | +| |Bits[23:16] Number of 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 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 | ++------------------+-----------------------------------------------------------+ +|uint32 val[8] |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 | ++------------------+-----------------------------------------------------------+ +|uint32 arg[8] |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 | ++------------------+-----------------------------------------------------------+ +|uint32 val[8] |value data array | ++------------------+-----------------------------------------------------------+ + +MISC_DISCOVER_BUILD_INFO +~~~~~~~~~~~~~~~~~~~~~~~~ + +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 +~~~~~~~~~~~~~~~~~~~~~ + +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 | ++------------------+-----------------------------------------------------------+ +|uint32_t data[8] |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_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 +~~~~~~~~~~~~~~~~~ + +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 +~~~~~~~~~~~~ + +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 +~~~~~~~~~~~~~ + +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 +~~~~~~~~~~~ + +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: reset reason 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[16] |Log data array | ++--------------------+---------------------------------------------------------+ + +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. | ++------------------+-----------------------------------------------------------+ + diff --git a/Documentation/firmware-guide/nxp/index.rst b/Documentation/firmware-guide/nxp/index.rst new file mode 100644 index 000000000000..b38c980a50c6 --- /dev/null +++ b/Documentation/firmware-guide/nxp/index.rst @@ -0,0 +1,10 @@ +.. SPDX-License-Identifier: GPL-2.0 + +==================== +NXP Firmware Support +==================== + +.. toctree:: + :maxdepth: 1 + + imx95-scmi From patchwork Fri Apr 12 10:47:08 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: 13627608 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C681C4345F for ; Fri, 12 Apr 2024 10:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rE/c0UQSNMAuRFmh3+wZXc2pkdirxmhgfwUVeeLpcyE=; b=oVeOEb/rE7IeRmCMlJBNi/kS3/ j7fUwUU5jI6pTiCNAhtmSN5WXtkyOoFFfdRfUKlQQu2CwDWAwXC8qfrkDWfTe7WHPxBD5oea774av 9Re36G6u2JeaKK7Rt5DhkaN8FTST4uDsIyoCbrOmKRrBrSKX5y2TMkfm/4ppuqouvXVujrbCulZda ch1uRSFQNnv6F/mXqxzO5YSZWj8wiI/FiC3BzHm1c/zXWigtfy/qNeWLNJFknBLmC3UE2vPONFKxa BYdjvwYzirl0veVxmPiWd7wEltsCKwMZewDo8GxSWVvRUT3iNDu5nzUdBJo7a1lQ3JWDL2CRtN2sJ dXhXNrEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvELL-0000000GkQf-1Egf; Fri, 12 Apr 2024 10:41:15 +0000 Received: from mail-db8eur05on20608.outbound.protection.outlook.com ([2a01:111:f400:7e1a::608] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvEJe-0000000Gjcf-46k3 for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 10:39:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gqWA7F5uo3P8h65XynFaitdDp5nPOO7UNqR/9q6Oc2k0w3LsiJLti+VuJZoqZAqa5b6uGd/fkpxbyOwGp2wiHAs0vWVCTIMtsEbHfjKKZCe4q0rC42aYekeIlmu2sDuL6Q7e7p9tsWDoFVvrkcZriNWFdXDrQz+Hon8TgFF9DRTNQ1A9JpPpcVdUuOTyNGzSOqa4pFg8qpk5Z4SeN6flshZcGs2j7L00fS3gZGaCUCK3NDA/5+urwyv4c0iTpH8nEClrKzWA1W2SmIMbzPU9HwFvEb9HS9nsae8XJ4PVUvNbiKcJKpkMALwu6W7MUfB6DJ3qD+ydI1QGjrY43YqCzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=w7F6ZhX6iuZZeC8ehCng386DvE6AU7+VQse2eQzKgOA=; b=B+jT22uWH+VtK1/t4em1oE7zSUBX8evx4AwO3uCnMuh61buGMAi6VAOMAYhsyJPIPwoPTtVXNyRBvQWN7kwpvdyqAo1IcfrrFBNwQjGJZJTkJGn7mw1cqBPszNk4zR0NHs07m/4l17uqbTKCmUYdpRXq9FPE67hjH9AetHhn/e89UjRx7qnJXm40FzueFWdIwqQyrzSz+eNsdEcg8uIBoJHgyYP0p/6WQwF2Ta0Sch70bC91gUmxrIcoo1J05ETG2d8ZK1LaKRLavmrVXxkhX/Zs1CCBcafbvR50qATGrAVmB9tuoz07abj7V5UXil5/S0+TKz5nQ51K+lfgVHAoMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w7F6ZhX6iuZZeC8ehCng386DvE6AU7+VQse2eQzKgOA=; b=QG9E4IAIEbZGN98oXGuGRePPgAYrNfZNo7P8q10nYxjZr3CIpcgRbGap/wjWAeEEudsKRsbhMub4Ih5m8e5LJNKxV4v5j7uCQtPJZ/MKhbwwwaEbJMGGz0SsIEai5ZWlbxncGIT/yX5IsdP7ICaalSTm4s/jSu6eBUfRSw4B3qQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) by PA4PR04MB7839.eurprd04.prod.outlook.com (2603:10a6:102:c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 10:39:25 +0000 Received: from PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54]) by PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54%3]) with mapi id 15.20.7409.039; Fri, 12 Apr 2024 10:39:25 +0000 From: "Peng Fan (OSS)" Date: Fri, 12 Apr 2024 18:47:08 +0800 Subject: [PATCH v3 2/6] dt-bindings: firmware: add i.MX95 SCMI Extension protocol Message-Id: <20240412-imx95-bbm-misc-v2-v3-2-4380a4070980@nxp.com> References: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> In-Reply-To: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi Cc: Peng Fan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712918849; l=2879; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=kBV4FDeFdLHNHdghSed8ocvNmBpb7al6GBdfi5DzB/A=; b=jNtAV/HgbMyj5+0To/cwcARNwVW3jtr1DH+hFL0+4jZb7yjeQsuYqH3p3w2bC37FL20K+dVZZ ZWB0FbWloefC0Mp7QKCHxCjPfZ17vaefK+H7nAwabgnT1BmyHBolzb8 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0243.apcprd06.prod.outlook.com (2603:1096:4:ac::27) To PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9416:EE_|PA4PR04MB7839:EE_ X-MS-Office365-Filtering-Correlation-Id: c0c97a4e-750c-43e4-34c3-08dc5adcd2bd X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jXW8BL/f1qa37K3fjd+IMzU8BbG4GSFYfzYx6sLj7oMZo0QqqB1lG4BkX+wto7nfEoC++oGEhErEZF5T9eVi6ADmn8aW2OoXSYJtvh/OuxWvRziMIlS94CToi8V2pRFZro7rxAvF+dcKM9c0KOdcbVGKZKIuI4HZZPwyr9p6DV1pjTFmiDE0W8rqiQl/2WU9zaKNAA4tf9CcUU9+rPUUADqiLjBnI/+BtSmLOtf66IR+kRs45NyKQjKfBoS/EYIJxRRbaK6mKuV5Wg8yTxXUlEcwBwVoZ/v3nDc7BaYlZVKHgW3yrfdrGcAJ8oqmJUq7WDoTd4eHLUC8OZPMN+Wy/MmbstS2cuvDVRvGRDjoGaFQl+AJ2zdWiBuNJ6wHCkPbdICPaDXm8wDZZvp3JUsgo7tiXGU6buP+C43uGBiBaPHDhZVerf/a7oFsmZpmHbKacSjKzehxGE5OFPo7uK5I57kaXGhR/E6HgB0J6D1BPjAGdiaQhnmn8x+DlcPWPwx0rbSYI6AHTMdvzTolMLR2z/fVnWbCRBDLK8W+ge4zILAE5o8rPvyx+2OfZ4sovURqzz4ELQA+nG1BS3b8JPTi3FlKEPTX9/6YBx0Rhb71JCV+r1X1Ly/3+cjVWLzImOIQiaKbqE/1bl5H+kgG8W5LzIUsamwclSSCGwP9ysQkMq6QMNwdJqAG0kpdALyFROLv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB9416.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(52116005)(1800799015)(376005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yVGQdxL4cK6aJHFHrDK6pzhhR2RB?= =?utf-8?q?zOeM2i0lzRdKZvgwOODyUJYfmqu+VGNDwqxUi2nb+n/BbrfH6XKx4mmBEcWuSMSDQ?= =?utf-8?q?hldjMuSJLtbJvQvaGk4CxLRgHtkGmRJUgjlw0mDB3DBxU03797eksKFVFXl3zZM/b?= =?utf-8?q?RKO+G7YTbc1OgqaGXUpo8U2MZzf2blW7kNokSa1o1JMWBz2hvrqfJxE7bE4UYrT83?= =?utf-8?q?mF31dNxhqV0WVvQfiPvp2jcfvD2FMDNOwEIAvZIL5SqFX/mzXHETWZ9v/V3dnMhDA?= =?utf-8?q?CKjY1s3XvdQZVBl7eMYpueU8S47rpXU0WN81BNEPITbAt04Kpyi8gCguaZsGIpaLA?= =?utf-8?q?zWJtp4MI4TqiZbryKLUTHN9DS2qOBHm1d/T7dREwKFc6Pf9jzFZIydVA34fFLHddA?= =?utf-8?q?RVcA6gEDrFmvBlw9je5gfApnaUDId48U/alHQK+EBmvDlNzVVgzbHmhlsNs/Rl69w?= =?utf-8?q?qYRrADCW1z2vyEH4AyRMm5fOiPF/kJFd16JoQ1SpZ0H6n0GkuXeqZ+AO3/jlVZpCp?= =?utf-8?q?ophXxyXmo8QNqBpG5W8duSKi5iSBwLA6PiB+NdT29krhL7WgsI1acP/6Dp74TTLW5?= =?utf-8?q?UR0SX0y1txmYLTdzP5aJ+rDLBanM/El7uC8+RCoAlVYBf0PDlZLInx0rjugJs1/6N?= =?utf-8?q?+HeS4k9dwi9UOq3tTGa4BmzOohzovOU5wuXBWVR+YUcD1hdqHOQVEJhmLZG9zR3eV?= =?utf-8?q?B1rDJEDKudZgOXSfYy5VAvKD+Y4vw9ZBMfjjpVwks4lmgFPwiI1WvIVbL9y58ExW1?= =?utf-8?q?bK+VNh5oqtHtj4i/uB7dmVdFnAvg2MOPs8xKjmm7jIaCPEvVL5u4u2HaKPZ46SpE8?= =?utf-8?q?0XlaVyaSy8ekrY+t6SF3TKPmcGV/O9/OZ9FKKkUYiCGG4U5stb38jf1VLfNA0S2hz?= =?utf-8?q?LudozlmM4hadyUd3m3q8vi7BACJPyLu2Zn4Rom4ifrtyXomCFCDTo091eQdr4gIJh?= =?utf-8?q?x28LwCwjYWLeyPHLXqpit2cYEUMW8TzNe88DnIxQlLkTbAN034iPSJHNIfQ8LNKWf?= =?utf-8?q?JzbPlxm3t1mIki9QQeNDhajWgSCNsZRUcTHaM+Ns1futZ+Qsix+mCdX8LvGYt4n1e?= =?utf-8?q?d5nixDYVwy1MSOUff1Vi270HsH5vzKgu7i2ZnFEYJVsG7FcjYLsSKBB5QUwzj5bbU?= =?utf-8?q?JqcmHWKvk4eQs22j0OzOcY9zFokxcRk49Vu3XUiEVlnftwbu491nW/boRG7Db4d6D?= =?utf-8?q?VdCuqQWorQyB0sPQbMpNajj1e1wL2y5q0l+v8L3QKzjCxRf1JGk8JvpC36isGEEEe?= =?utf-8?q?H36ILIuGIMjT5oC8LkivAiU1XuhPqU+zZPUCoFQA3OLgxLmcjYREqcxjRzb/GQXnW?= =?utf-8?q?ym0dv9VElrqZfD8DnDkL8BCqbdCa0pSkNwGR/RP71ulccsqzOj3S7/KW4WU/WW6fs?= =?utf-8?q?JykjOVUPg1vzgtzphpJt/izHTIzj+Ot6HkR8sV3861gHMgtFiHsPEZyHxMP3WwL2K?= =?utf-8?q?t6vCQ7Vl66+ashUlKcfIVqYqowoM2DHRdE/PGk/EIwFvjIDaWRpqQNU4ECUKKWyq/?= =?utf-8?q?pYmipa700Wds?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c0c97a4e-750c-43e4-34c3-08dc5adcd2bd X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9416.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 10:39:25.5792 (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: KZiPdFBOPWwg+8RyPjHNQFcW7ELRAny4Pgi1yXAbYJ2Tqsi+nY1y/XM/3/0H3En0EZuZPSR7TOrf4X0phXDgbA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7839 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_033931_520722_070D5E13 X-CRM114-Status: GOOD ( 11.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Signed-off-by: Peng Fan --- .../devicetree/bindings/firmware/arm,scmi.yaml | 21 +++++++++++++ .../bindings/firmware/nxp,imx95-scmi.yaml | 36 ++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml index 93fb7d05f849..fa2cc910c485 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -247,6 +247,27 @@ properties: reg: const: 0x18 + protocol@81: + $ref: '#/$defs/protocol-node' + unevaluatedProperties: false + + properties: + reg: + const: 0x81 + + protocol@84: + type: object + anyOf: + - allOf: + - $ref: /schemas/firmware/nxp,imx95-scmi.yaml + - $ref: '#/$defs/protocol-node' + + unevaluatedProperties: false + + properties: + reg: + const: 0x84 + additionalProperties: false $defs: 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..b84c4a53b78a --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/nxp,imx95-scmi.yaml @@ -0,0 +1,36 @@ +# 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: + nxp,wakeup-sources: + description: + Each entry consists of 2 integers, represents the source and electric signal edge + items: + items: + - description: the wakeup source + - description: the wakeup electric signal edge + minItems: 1 + maxItems: 32 + $ref: /schemas/types.yaml#/definitions/uint32-matrix + +if: + properties: + reg: + const: 0x84 +then: + properties: + nxp,wakeup-sources: true +else: + properties: + nxp,wakeup-sources: false + +additionalProperties: true From patchwork Fri Apr 12 10:47:09 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: 13627610 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5ED0EC4345F for ; Fri, 12 Apr 2024 10:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vFyquM9ch0vN4oS8X0ePF/kuWGeb/rVBYPU0SdnP0CM=; b=R7JoXHtLj1MtxdthFyivYVAce7 F/if/yJYuYWzQFEBRAWMYtbki61d6CGHGpiyvdKzsWFVX04wyxR/450YAS6Xh+b2LOVDR5D0IRNUc gfCcYl30rUDD+j7FBZW80yigTvFLi6LWAkNVMn8RPw1XjzlAAO3SoTY5tdAuRHZ+tYhXLijVZZ1Pu nEfxiaU3/w56gJ6MNsJ5XrtohPe3FJCsm1lH4pQndl8xzklbKncyOiiuyp0A3pDlIqc+tP56NMta1 O/4ygFGKBlGUtS0JLYX/NvyMYAxUb5QVnSssuD0Cuw7XwEzmts9olyuCQAOKldOJLiZHO4yuS6s92 vngItpGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvELO-0000000GkSG-0OSa; Fri, 12 Apr 2024 10:41:18 +0000 Received: from mail-db8eur05on20608.outbound.protection.outlook.com ([2a01:111:f400:7e1a::608] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvEJt-0000000Gjcf-1i80 for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 10:40:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gkzjcNSyOuXV9ia1YXS3sQN/Fm2dMpEfwyQYXXta4YpK/PofdEYteotov4Cwwh53sv5WPehQN1x1nfUVpNLkRe9QrrsOJEeXSvF79o5iOHgcI1RueV9XaZ46TUCLi/nsQPG1xs6qVo6B8HR+bf5SejG7WsE3qcwgF7doalQrlwMEclAyIG1k0khdAX8D/z6fY/CQanL53O8vdef3X8IUgJMJvzTzSWR0iBGfJTYMx21yg3jdSOGQxnBqrie8gf3/xMNhLwUNevPVDAUIuDRNkX1IyFbGzhxRYkKKYrS3PireKUExjHPVxDMQWj/lR6ZW414Z++RRdsgd+KKM0ec8JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pMGmxAgESxq8nmoUSBxt1fXYHI5yhImMshqNAZOxHFo=; b=mexdeqNXsQ4WZ12H6ZUW5A6c3i4iM+K6kwHFRTrwitZ54PUOubz/kXaWqcAfaRWzpEAWgSWJSLl1/VJ8dbRI1EJ4rDQvmQ3u0wumBpYdTIawbv8AreNGRkgQO9zR/zzm53wlEE3YgnC0PiqG8J5PwBE2Fs5wpyh6fhlKJNqsM/q8jP9l+X11mnBo+4gL/BeSIErE4pRQs5xf5nA0S1GBvX6x65XYxNYP73GQz/yUpRfYJTmyzCLjkx5zuFnKpwt1bkQWB0MwuSEHyFaHCKz1xrdK43fBhnTU8VUtNKw/OW7val5avqVSNn1wE1QAMiDkWGWMSWC1keQ1AorOt9Hy9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pMGmxAgESxq8nmoUSBxt1fXYHI5yhImMshqNAZOxHFo=; b=DFqkmnV2iI4gmSdmUE8j+UVBIDCLurBYsxYKzCQaq1YdD7x3u7d/vAtGxc3ten1aTvvkMZRSz3yJpQi1O+MBEl+EUTQrzGNr6QAXsMoe5ECQlgvirgUVRurBvDizz7+FIm1Op/WZOsINaWhZmr8veVDnE+U2bNshrSA90K8k8Ys= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) by PA4PR04MB7839.eurprd04.prod.outlook.com (2603:10a6:102:c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 10:39:30 +0000 Received: from PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54]) by PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54%3]) with mapi id 15.20.7409.039; Fri, 12 Apr 2024 10:39:30 +0000 From: "Peng Fan (OSS)" Date: Fri, 12 Apr 2024 18:47:09 +0800 Subject: [PATCH v3 3/6] firmware: arm_scmi: add initial support for i.MX BBM protocol Message-Id: <20240412-imx95-bbm-misc-v2-v3-3-4380a4070980@nxp.com> References: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> In-Reply-To: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi Cc: Peng Fan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712918849; l=13198; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=WZBtUso1mE3eWFNA1twMIBVrsuhSBdnlpopJT1V6HAk=; b=VWqF9riEFNtd1okundJkNlY+t6exXm3cQcu50mD+QqpVu42kCG+bzZ7nezqvcyUi4OgvGG6cH uSrfJHILgj4D7KJIUUGGQyvZXzSNht78OpMXmMpxnj6lshNnu9MYEPW X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0243.apcprd06.prod.outlook.com (2603:1096:4:ac::27) To PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9416:EE_|PA4PR04MB7839:EE_ X-MS-Office365-Filtering-Correlation-Id: 3bd98dc1-2ecc-40d3-08af-08dc5adcd57b X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1woqoi0HYVBszaXYxbISV5nPMtyASzeDokGUNvP+3YgxzoHanSQrmjpW0s9s3DjFYNkZ6YB2lFypVRQ9PshUUkvL+XmXZ1YfkeEG+CFVcB88OptfiBdxIbBSPVU3XVP9AXbKFf52AKMwNwAN2RYKLRyNYcbQDKugoRmOLksU9Ij5Lz7aC/Qf6CbY/Hp4sHcHIowVsEhtfxxDU1jV24fyYcLu65SB26Yq1m7Y1SvGnJnb1QuqARktli8Jgk/BFvf/taSSkXfRwJGil9A+Vk6FoWb4GZlKnla8m5XGyt06QZbQDYO0Mmvpt/G+GNLz8ZJf8k3Ag3jsPQpQouwxTMIQGI9DUGFKIniNNJ7bA063epDW68iExd9ZZ5pKSlq/Vhd68gYq1VegpZ5y/rDVdMsf4NIZ6V0TcLnMl9pEIUylN2RcgItsjo9P0ObLgZbxJlXcih2uCMRYqp348y2EJrUJx4zFKLdx8XGNCbB2ZIUoKSw1xSLzAgzZXgUOWOLSp7Ju+r3V7iKYj9jqw8MRFKzZ1DA+tHD7RTgvnLxq/GRMzE5bRm8xUkztVrFlFJFVrKTe/yQ/RfYqDHCXiGBwtnK4mpRyup/QQJ+oXi/hCuBmgdo1/ln7WZZEcqgU4AAnizAa+m+ZYR+B5KHjNQ7ROv6ZwaazAbHBvEkJJeStYAUQSD2+sOph1koiAsNK3DsXIuPb8wODOkGjBKzrUdd2/rWXn9qAQJDaoUtth2a8pqrPa6w= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB9416.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(52116005)(1800799015)(376005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Dy+9T6L+j4jzmhDaxij9boPriIAB?= =?utf-8?q?GK87v2nC9VKIETfSySj3R/33YHh0zKMyUTty7a5feokOlWYLvlXj5uORm4/3IEB4H?= =?utf-8?q?/ruFUF8ELPTk1qKCV5ipXvYpDO2L2Pa2No3stIr77cihmZ7JedS520CdSqvarljSP?= =?utf-8?q?Ro/uA4fMubDK7tMKCJEL3FXuYl2r/W8KPUdO/n4zIvYs7oHDAuSENfkMgXONw8vM4?= =?utf-8?q?btKoe8cotyTYZ0ughblEepMLkg7/DvlK/qP3JPjslFGtAOpbB5n/wwoss/fIeMphu?= =?utf-8?q?H6W2Cs9Tw2+rhXXH7e59zh5Li0KSIpLiclaNmbJTM57NbWjLvpx/zw4cbYS/aLYIA?= =?utf-8?q?SBf1cDH5qPrXh+NMWNHYeG6/cvmzsesVpouihNYFx2aa0fAfACezi10qEGXsYVyWk?= =?utf-8?q?NbLlgWtrp8Bif5jGcq/bad63DL0aDTDpsrTIzdo1nCKroAfgry4yLE23lqsberpWa?= =?utf-8?q?rrldXjREeTY/DnFtEwChEU22IiIF484vWVli6pO3lrOxDDE0utPOTG90XnDpWsY6C?= =?utf-8?q?7t9K/rJmK3vdw0NNcM7jI7ob35ynP9MAgSKSfMEI2WGGNhtXUI6xrZ5czPLfWHunA?= =?utf-8?q?20IO/c6RsPI7qv4lXcC5Yix1WR6Y0NL9kUfRt+IXO06S1Ksr8iXgEspfBgHQhJUnG?= =?utf-8?q?JlkcbgeaLS3EyFfGHK42GKLfAqSh8nQisgj2yGG1rPv7zyxBy5g6gYz8KEsu4ywEq?= =?utf-8?q?8sXAA/Bx3mrbnmbWcjdEjUpj2eIiNmVX3SX3uCRoRaPWfdkrUfezrCIdqiV3sNiN/?= =?utf-8?q?FMJLSdqAoG65lcE+0EyGrMKXt+HNNBtHKncxXDiEU+FPUxk9lE2ppOk7ZJIiOWBwC?= =?utf-8?q?4A4ZwfRP8P3zABW3vuLV6hL3kB6udaT6nNlr1Y8gpW1IM8DBohvr8QSCfK24oA6d1?= =?utf-8?q?EIYdICuTqVGNQH4LI28WgmEIsKzsXcUU/PCr0OX34PZSagZCar1mCRLNPP8oxRZpG?= =?utf-8?q?Ia7y4Rnuzy6NmrYwTLcuzumsn1i1X1ftO6u2omuLSaGQTJVRbQnHzu3P+hAmeWbJc?= =?utf-8?q?DSd4PMx0HV5QX45D8vEXSvHnzSg7SwlT+XIL0Hn8BOQNZsabY6zKGW61nsf1SAlUo?= =?utf-8?q?/Agil7zfROswho8x5BAd9tl/gzd8/LNo5w58J0SRRLQ6znOv6ZxES2hs+DOPBGOsn?= =?utf-8?q?g5qEhB6G3gSGiKNhi638RfQPL5eAKFOrE0UTMKQVz2Dvdy1VJSfWo/cyjn/KRVGDg?= =?utf-8?q?mZLqu4rPozfLtkcPnkM+tNKnV/1QSwNepm1InyzXvc0X1t/RCqkQ+nIbqe/SqK14G?= =?utf-8?q?2sOmYLKfDItEYjUs+neFFR28w84J8Uo1IN1Hh1mioFF2ErYgVw5aRetJTFkRlXr8E?= =?utf-8?q?K41hxBrNRgPXfnNYFbXwzTHOsstHRWw1rJQRuDSuoWtn2aFW6cbpEMnjnyn80RzTM?= =?utf-8?q?st4nO4F93GTFrkzWnwJRS1euJjF1y9jaBg533r/DUrU4r0HiQquPHeeurD51uD3I5?= =?utf-8?q?EmbJdwwkNPzI5S3zv6L2LyuNVBSXM1ptlikr7vomyyFJ7NHX7Vgl0PRuli7PIhkj1?= =?utf-8?q?ln0RmD5MIE2r?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bd98dc1-2ecc-40d3-08af-08dc5adcd57b X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9416.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 10:39:30.1978 (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: Cp5jBgEEyAKqQsK/Ep+8ElMB2VGeI5OcygoqZ863FYd617EcYVpvgWksyJDD9uTgP3/iBHRNPYAF4IOl7SP5eQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7839 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_033945_969451_0DF06C13 X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/Kconfig | 10 + drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/imx-sm-bbm.c | 378 +++++++++++++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 45 ++++ 4 files changed, 434 insertions(+) diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig index aa5842be19b2..56d11c9d9f47 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -181,3 +181,13 @@ config ARM_SCMI_POWER_CONTROL early shutdown/reboot SCMI requests. endmenu + +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. diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index a7bc4796519c..327687acf857 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -11,6 +11,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += optee.o scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o powercap.o +scmi-protocols-$(CONFIG_IMX_SCMI_BBM_EXT) += imx-sm-bbm.o scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y) obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o diff --git a/drivers/firmware/arm_scmi/imx-sm-bbm.c b/drivers/firmware/arm_scmi/imx-sm-bbm.c new file mode 100644 index 000000000000..7ee699cc4215 --- /dev/null +++ b/drivers/firmware/arm_scmi/imx-sm-bbm.c @@ -0,0 +1,378 @@ +// 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_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 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, 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 = SCMI_IMX_BBM_RTC_ALARM_ENABLE_FLAG; + 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 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, +}; + +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..90ce011a4429 --- /dev/null +++ b/include/linux/scmi_imx_protocol.h @@ -0,0 +1,45 @@ +/* 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, + 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, + SCMI_EVENT_IMX_MISC_CONTROL_DISABLED = 0x0, + SCMI_EVENT_IMX_MISC_CONTROL_FALLING_EDGE = 0x1, + SCMI_EVENT_IMX_MISC_CONTROL_RISING_EDGE = 0x2, +}; + +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 Apr 12 10:47:10 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: 13627614 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1DB5C04FFE for ; Fri, 12 Apr 2024 10:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gtm/D848hkXF4zHUuvYNntyFOXu4tGr1sZSUsaUL0gU=; b=Owwc5AEibJVexRNJN7C5JsXR6F VpwWjnKK2byvjIfIgF6aj31w0HnE92rPwIG79dy0OWe9ttQIiofeHrUIh9S91YCQOTsMpNXg0C2GK cWEQlv3ylwxtE6YmKjFSnB/vnxVK9in0amKR9+3+sfQSJiAE/w0d/bs4kke+3kUdyo/raOH75+Rxz df2NrV/w52uPaLiXHDbYjk+b1O3zAdWuiJFvCeVRP0Gk8KDQGxU6itZm+cdpn4gROCuQspg9NYej+ 7MVbsUS1KJXeniCavxlCDe/gsB/KTx2wySPGlipPRWt+hs9GzE44E6cQWAAehUvv5xivqnkOLS1gO J2F1d/OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvELS-0000000GkVQ-2L0v; Fri, 12 Apr 2024 10:41:22 +0000 Received: from mail-db8eur05on20608.outbound.protection.outlook.com ([2a01:111:f400:7e1a::608] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvEKE-0000000Gjcf-1N76 for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 10:40:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CIAGSMSkAslz5UmqUyzLR+edIgEvwlsxQMJ1dxen4FUt/3a9YcFY6eHQnHEg7ibbFhVRumh+KLX8YB44NI0uAWeHrPS+ivSfFJ5z0QuqwoilZI/4P6Cj6kcdrvGsBWud4fUks+29E691bVnxGD6K4bxMA4zNROnF93fiPqhzz2+Yn1bxwzfdNuKmjFuYHAPowqcZ50WgJUxcN2kdpmVBYIyyoveD3rtBgdmsr2UErxgxKOoxtDm7s1lkiV1GgAXVeoJQ9FfJvn3mcu9KUr+ZF/2XuuGxN/04Ryot78Qb2ipx87SdEtRJIKIL2DWV6E+6Kh6E2Sp6D3ivoviXHk3TYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G6TFiOzYXzLz97ME1+nCCA5wS2Nvj09TuZS0aNywfIo=; b=DmIm/OeZ0fur6t3FPLMKrbBYBY95yU2CTRLBE+Im2rxyMRZtxy55eC/dw6y2nRKuN9oQnpnXGHzV5MfcExtRi3HGA8mZFFCRGAd0uVVjVhM23WUmuzoRJwxw7r/mRH0ppZAFTQRu7TQOkPoRWxy8JP7PUaCaJI4HRJPMhOjaauRzqzgBoMWGulJWaELEckB8rh7MlkzeaerQZJZx51a6H/90727jMdJyD+RTzctRUoY+CLpa6z0BcynDmrxypacjXIRyO7IW35bocM52/h2ur/DOr6z+H5QSw6Cv/oRr3TAo0YYxRYu7u4VaBxZE1clYgEneGW7s7uhq/dUAsrpRlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G6TFiOzYXzLz97ME1+nCCA5wS2Nvj09TuZS0aNywfIo=; b=fgSVhAZJojgA6BsxHtLcpAsvcwlrvF/UXl1kFvDi7ajfzWKO+/52LxxtV8HhOy+pSqY3Q4D6Zv0Xyuii7Cf4OlZJ5UgS75qOu0aXaBgwqGGZRPqI7DmI2kohkfj6MyRp/Scpv8dePNc/d1UN3h3PClXCgwBPOK2bSqWAFDOZNTU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) by PA4PR04MB7839.eurprd04.prod.outlook.com (2603:10a6:102:c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 10:39:34 +0000 Received: from PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54]) by PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54%3]) with mapi id 15.20.7409.039; Fri, 12 Apr 2024 10:39:34 +0000 From: "Peng Fan (OSS)" Date: Fri, 12 Apr 2024 18:47:10 +0800 Subject: [PATCH v3 4/6] firmware: arm_scmi: add initial support for i.MX MISC protocol Message-Id: <20240412-imx95-bbm-misc-v2-v3-4-4380a4070980@nxp.com> References: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> In-Reply-To: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi Cc: Peng Fan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712918849; l=11303; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=CgPGaPP+YJI903GGXjqbanZ6FzgOXN8sDyrSQkwxsuo=; b=nO2OqQETwxI/cFUeaQfBal7d7p+xBU5KcKwUO8yYPYkyHd/FqWY3vjbgQUn7I11/bMM5+eWwJ XhqnEPuZQ1DC060KgpZyICGd6x79BCjPmj4Zl12FiYPO0YYnG0DcyXY X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0243.apcprd06.prod.outlook.com (2603:1096:4:ac::27) To PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9416:EE_|PA4PR04MB7839:EE_ X-MS-Office365-Filtering-Correlation-Id: 0db023f7-b29d-495b-ceb3-08dc5adcd828 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hze5dTG15AT4/CTZnfMD74BUT8DQcHSak7LHtdI77KJ3xJrABIY+8JollP1F/ELAvy7aQspIGFQiAnGF+rE5+Y6xpmqOQPew7fhZdXTTltdZs9wY/116KB3guelcYE6SR38fxBHHFS2lxdzWhuBjFNnjQAd/UXPoRImcgrk2+mv9reFobUV88G0/Z0mhVOsj273zB2cT8OYzlnCG29Vs+tXhvrRlP++pspGijO9k4wllNC8gZzkq6lmGX7MJb6pmQL4L6FRUnW5RgMrVlkgbJGTCcf3DwzYTQ57S8V9kWBseWQg30VzmmV/NNcrfCyylhjkMLBFskucDLsTx+fbA9LTyS7Q6Vb6IKbWF9vbMG6gbbRi5A+U8c7FUfhTNQPUlQ99Th6fRiLuXZYg3gZ1xuHazrEli/1t8L4qHGffCibfqs3pRVGY7PhNheNVA9ZlagCoTibMgQwM9jEWb0I7b0RqoGMYbPPjA9mcfDaP7hdZi+UF/jyY5GQs6tM6EZMQPUR2t6NfSW+w6ko3Of0NzEa4K9awU1LSRcipgY4bRFA464hJPysKzjevniRFKSlmm6qkLn7+Xmt38RUsUbDyz50pJmvMxfYrt8W/b0PZkk+h7UAcYrc4soINQC4+eFqlvy8FhNzZndEu4M5hMDAuef8uDEMdGKbcNpcFln1sxtVmg0K9gKHB3KisCrc7EimFo2HVlfWNRLpfSVgFjnme3wJRefpsXHVpcqImRmeNJokU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB9416.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(52116005)(1800799015)(376005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PNQr4KrfSFuObXVlfJxNW9zaR7bq?= =?utf-8?q?dHgTO7/S6Bn5NyAlN/VEENv9h6+g6opHcGiF2e4aPRMdvbxZ3MiUjxwMEaHpMZSfO?= =?utf-8?q?rxfuPyY/Wg0zwAyxx6HiKKnStSJWKgyRBx2obrmopi3/xGLeUxyujfDYg8atKjDZv?= =?utf-8?q?ATTR7lE7/5Iw2NfKUfpVYyaojFZFWdDnNGr87JIGgFY1MSqFRhsoMTYCT9tXdgzIs?= =?utf-8?q?C/SKa2oeagqSP4lyJmdM8Z3R0CYScEuHSD+3p22qIbvlkEb8vofBop8hdO1kERCJJ?= =?utf-8?q?94tQloM+0gkVnx9CknT1PcPF6Crt8s+U0tt0EcTU8tNV9VglbLVgnWHRfONMveShV?= =?utf-8?q?3BXu6yIfJkHXoRAi3LYLl2tixTA5d7T/xNUV0xoE0nTr6Ve40SF/W6KW/LNUFH6g4?= =?utf-8?q?STvjDoSTtyuT3SlRAi4qLUiEgzO96pHx78aOJa/CsgYeMaewRsiaJlXEJemrGr6vu?= =?utf-8?q?AuLybl9nwHgH74xF4HF1BkX885Xx0vkMRSXDpgojFHZ9fi2kw4MM6wS3kjT1fwJUh?= =?utf-8?q?KlKCMI2sr4YMEbPPkln0CHYbm04JQJeoWyjQ9W16OWiWTkNU7gx+716XD4jvV6hET?= =?utf-8?q?ur1bPBnWtZUrtG7dIQVcx0fU1X1515/ypqtPMFUIc7H5xgtmog7/Fj8Q1cwPdeei9?= =?utf-8?q?tGShoKpFQRlK+U7BaZYd4+PiHY/UwfxUYvFyb2huyOfwmNxyAH+9S+O4ZWBSGJb/h?= =?utf-8?q?XWnWEf9/vrsZM40exNdYzaJCCVZYOkFJaavigiA1XLqDA6dsNicawKXu29vwLdf7B?= =?utf-8?q?ud77k2AMAqUrpZeTsPE+43MezWPmV8lLmtYoi8PLt7OvyjHMBMy1uUDjDpatKB+3u?= =?utf-8?q?RfkJsLmQ39dEAHjoyW44ItOoxsgk4vx3/isdTIVFrWedwpyJ3YPAYA/LmvyRG+sf2?= =?utf-8?q?3UifJA77jdsxd6Sf5XKJBE6x3Q9qc0qTT3T8Ig0egu7N35IXsoqTyHHgiez7F001S?= =?utf-8?q?dxGhk9u7Wqt+ycpG6e5kyeoZwNqVlnnBmEbB9hbX7pL1+JCJS37JIXGA9r8sfJmxL?= =?utf-8?q?s2ne62LBaT1hDItxlqCqsr7PvFeDsWaDX9AM/TZb37Zx+RrtjRdfD/9lqRYmIbNH+?= =?utf-8?q?8XF9WVX/2ad52fzE3kZ9/Lj3e8ZRfaMjhudmYSWdZ6b6oiSK1IJwJi225K8f7sVXR?= =?utf-8?q?3jy6Jv6SxnqaBFMQOyvILDRrqsVgffixfQ0eB16bCUmSRxO67lM33174Zgpyv7Kug?= =?utf-8?q?n7crkZJYF+20Xh4INYrfh0C3Kd2RXsnwoIrFfPkrLBjHN8OGSox1RIl/JI2gYvcW8?= =?utf-8?q?3o4FLFZKZo277vFUKx4yOr7YrOWEJUtJywG2fbNM9oVhkHnYeYfZnvl+aStt7IIFb?= =?utf-8?q?pc61AQXH67Kudqbl3TXnXca/dliUIsS27rZMP80T6IOgZ6ptpZdIab7MlHZUzMRhY?= =?utf-8?q?XL88qqBYu1V9lOTQZjJp0wiyNUKdUbyOybYy6FTbEtnZav4xnHXsXl9A1tnFa46X8?= =?utf-8?q?H+SoNn/hpFvx2YOXgfOUaAzMdK3NqKHCeLppJFNyozODp9uhDaXyhVZPNX5k6v9nF?= =?utf-8?q?XtfEprRVHAru?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0db023f7-b29d-495b-ceb3-08dc5adcd828 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9416.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 10:39:34.6575 (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: 9/YX4gJWSvKUhKxBT3zn5cUsfo8KVMipiEsGlsptBcy4fMPeS3V32Y1ggamwxaRJrP639x5cunOqU8x65rhsEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7839 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_034006_738092_92CDC11E X-CRM114-Status: GOOD ( 17.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/Kconfig | 10 ++ drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/imx-sm-misc.c | 305 ++++++++++++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 17 ++ 4 files changed, 333 insertions(+) diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig index 56d11c9d9f47..bfeae92f6420 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -191,3 +191,13 @@ config IMX_SCMI_BBM_EXT 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. diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index 327687acf857..a23fde721222 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -12,6 +12,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += optee.o scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o powercap.o scmi-protocols-$(CONFIG_IMX_SCMI_BBM_EXT) += imx-sm-bbm.o +scmi-protocols-$(CONFIG_IMX_SCMI_MISC_EXT) += imx-sm-misc.o scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y) obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o diff --git a/drivers/firmware/arm_scmi/imx-sm-misc.c b/drivers/firmware/arm_scmi/imx-sm-misc.c new file mode 100644 index 000000000000..1b0ec2281518 --- /dev/null +++ b/drivers/firmware/arm_scmi/imx-sm-misc.c @@ -0,0 +1,305 @@ +// 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 + +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[MISC_MAX_VAL]; +}; + +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); + + 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 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; + + ret = scmi_imx_misc_ctrl_notify(ph, src_id, enable ? 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 int scmi_imx_misc_ctrl_get_num_sources(const struct scmi_protocol_handle *ph) +{ + return GENMASK(15, 0); +} + +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; + *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 = { + .get_num_sources = scmi_imx_misc_ctrl_get_num_sources, + .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_DISABLED, + .max_payld_sz = sizeof(struct scmi_imx_misc_ctrl_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_misc_ctrl_notify_report), + }, + { + .id = SCMI_EVENT_IMX_MISC_CONTROL_FALLING_EDGE, + .max_payld_sz = sizeof(struct scmi_imx_misc_ctrl_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_misc_ctrl_notify_report), + }, + { + .id = SCMI_EVENT_IMX_MISC_CONTROL_RISING_EDGE, + .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), +}; + +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 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; + + 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); + for (i = 0; i < *num && i < MISC_MAX_VAL; 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; + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + if (num > MISC_MAX_VAL) + 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, +}; + +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, +}; +module_scmi_protocol(scmi_imx_misc); diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h index 90ce011a4429..a69bd4a20f0f 100644 --- a/include/linux/scmi_imx_protocol.h +++ b/include/linux/scmi_imx_protocol.h @@ -13,8 +13,14 @@ #include #include +#define SCMI_PAYLOAD_LEN 100 + +#define SCMI_ARRAY(X, Y) ((SCMI_PAYLOAD_LEN - (X)) / sizeof(Y)) +#define MISC_MAX_VAL SCMI_ARRAY(8, uint32_t) + enum scmi_nxp_protocol { SCMI_PROTOCOL_IMX_BBM = 0x81, + SCMI_PROTOCOL_IMX_MISC = 0x84, }; struct scmi_imx_bbm_proto_ops { @@ -42,4 +48,15 @@ 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); +}; #endif From patchwork Fri Apr 12 10:47:11 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: 13627612 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74D2FC4345F for ; Fri, 12 Apr 2024 10:41:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=dgcsirBynwiog0ti3HVRve4epUWUcGVopW0OXZsKfBE=; b=eLEq1Pq1AEmSbLGxY91OHzf9qg 8Ve30hsSfD21rm8Q2wvDU6GoBxi3EHUwzYc0pLVD4b+9vfGBdzE+ubsG2I2Cea3QUQUNVHqtJIvfO BaVYcvBrMCG0zEJ/q7VaWNFkv8EZadE6dMffyKVGqlCLm19wzTN3J+r4gmeN1J3WwCYu5Sk31DSab lSTjGXBYtLgZmFeGCI20a9LFfhJ36lBkTGwZWjtYbW/FLzytsl9nFrBXgrarCQSZOlFPUMicInnnf B8L3lSlPGqX8/Oykt0ihxOEgW4ri/yPemh5mWtfH0bVwukb7WYmK+L3ojBxp/lddujGE01aOVBsQt TJ9L00eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvELU-0000000GkWC-1ahj; Fri, 12 Apr 2024 10:41:24 +0000 Received: from mail-db8eur05on20608.outbound.protection.outlook.com ([2a01:111:f400:7e1a::608] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvEKO-0000000Gjcf-0FOB for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 10:40:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PwroFxFj2+oBA9OPqUUWYPEeI47/FkICWg8ROzsAE2sewcQ1U8T58H9YY9KM7hNTo3TT+xKmrm3o1ZIH3/4lVwYlygO4CMP84iJ2lnrzcun5NQ67ptVwPEdh/CvN8Cj5crhXngfQGyHGpCOPnU9oTTh5kK+Ao1jI0FmvI18pxsjMeX4s4sqj1UM4N0Kdd6rjotPiuzD+RVbzwZTYw3ehayeIlsICJBhy3MotGXemBGFZrV1roTdTFmLkl41To6w+OugxuD1TBS3TKQeAW03g+BfgoKTU9EQUWP6CzVDtr5HHR8140N4dRLmvaUAzsVrPz7HcOKX6jdd/hnWU8JZvOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i4bWUdJk5TwFdQWhDrGyBda9rTGBzN47VQeiZ7m4qmY=; b=LlQyO91DqR4X7hDU8IS1PonDeFgkIzetGcctB7SB0UZEUtfwgqFgY1X4OaovF57tqBin/mBKO10xfyi1ZtpbZP1h5BRb1hu+LlA/prRe2O8KDROiNarHrLLpXT8fdY+nWacC0BQP+nULgGtLpmo+dYReWAssBDo/0VG4qCYL5Yy7/4bxjYikWdbp7zxBPxgjOde16wLB5By56haCXjvZzLCXc8QsocT/wmfzpMEqrzVzoiCmSKnT9VM99YCUgYDViizIurUTEJ5EIYWLcMjquDv2Bks/ayGlacyGMfg78oRqVJpCR2A8hEhGDFwAnDEW/hvfC9K4lrvR+cro8hX/0A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i4bWUdJk5TwFdQWhDrGyBda9rTGBzN47VQeiZ7m4qmY=; b=Ay8/6nXKh1te4HqiIvSdxPMVl6ODJzzKQaL8OxmStlZQRiBb1y2GXFa9/dhgIF52WSIUfYUG73paH4W8OpXhZah9QJ34NUDB08xOXW2CphX861lYrfvoJf5GTR5phjJfW/3oDdSWyh6rqJLpRYS3A3ujgjlXpUKzKx9jZ76FZsQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) by PA4PR04MB7839.eurprd04.prod.outlook.com (2603:10a6:102:c9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 12 Apr 2024 10:39:39 +0000 Received: from PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54]) by PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54%3]) with mapi id 15.20.7409.039; Fri, 12 Apr 2024 10:39:39 +0000 From: "Peng Fan (OSS)" Date: Fri, 12 Apr 2024 18:47:11 +0800 Subject: [PATCH v3 5/6] firmware: imx: support BBM module Message-Id: <20240412-imx95-bbm-misc-v2-v3-5-4380a4070980@nxp.com> References: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> In-Reply-To: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi Cc: Peng Fan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712918849; l=9360; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=Qe4YMjymxAKRop7ehNWBHg5FvDm2cdcwGYpisnkYZ7c=; b=MmI3BFTfpRBV4xJtmD1YrQQuGQ8NajI77EbVfe8+Q5rz64l9sfl1gbg4LcSv+vOKXOpS8xWmD ODVs60GbX7dDaSTIBIIeIxvKJq4dcWRJsg0e5sYbzPrzZjP14ElyGjW X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0243.apcprd06.prod.outlook.com (2603:1096:4:ac::27) To PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9416:EE_|PA4PR04MB7839:EE_ X-MS-Office365-Filtering-Correlation-Id: 27e2ae47-6d30-4a16-51e8-08dc5adcdad7 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gyANO/EsKz1+25k4goLlA32r/otUhP20A8WNHL4Rp++FMhXGyo7Ct2s3loWzWU/XT5p9KL1KZJwIgPD7u/XJmLzx8/VYMR4kcrNPM1RbFoeGg1CeA3L1NDKkv0iUDy930E9RCi9qauvBZBhrdDoRKb5gVas3IorrW/59YEyzVTKUVkWq2CNns1XBg2gEv5e+rFCeUW4QEaO4swhdzXSldoUJtdwqUR/1EFVoiRqrka4c6gT0eAuIhYen4DldmMIACXt2heJtnG7B/E54vRWgAh07gtTtbUVvfxjRtd4U2TmRGWNFVl3GZ0CqHM4aZvN1TYbPOILhVcEKvGW10+xA+eANuKLk1BQ6dyTJEKkH2+p3eC9TOpdL7668CB9TUzRU3/7YzypCXP78oNP2WxZRo8kPlyIzdtrdgDBJjZkRBs4WETkuwzdwGUyTnZHUyskE9RDI6/3nqlZv3amy7NVohdpkQvD3JPi3L493+2ZwZrrzdLgc4BfODr8tvBsPljr8+1FOT89VZV+76ZGbJsjMSFxZyswT9IFHSJYZ1s06gzotqq67dhsusxLhtHK820hOUkq3Pzlu4jjQYu5KiWMXthkvOPsXrp9fWOaM/UaAJLoQUOJwJQFN+iUsmqdLuoXnsadXuB1LtyrYBs6Y38d+srJbsEzctHE1auFLFVrNNRm8tkCO4APoh7Zzca9qCb/5qhWNn97dsZEmYhCOacc2gQ+SkZK1aMcVS1GRhTmzQwE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB9416.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7416005)(52116005)(1800799015)(376005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?55/mJTeD95cFutOSEFAJ0KdTj/tV?= =?utf-8?q?lbCmJCmYaVUlE+p/kFYpNdWka5YsmdQx5KDkKIPZrBbFKVFoCIDoafDRTNJ3npFWu?= =?utf-8?q?JjdIk3MheWfPgXtiWNVMJzjhRMiEc81JXyqCstp2bGu132OLumZhGgacnowu1dxjx?= =?utf-8?q?T5eu8ytaWi3DcjQrsZZc+NlQJCWE6mDtKEEMhQTefViQJ9xyREBNFblIn/tkT6wbT?= =?utf-8?q?B9gervROHYSc0prFH3jOzaiZnXrTqciRZ7sR4WMWqemKDHF4O2fDq4dhjDIg9+Acn?= =?utf-8?q?nkD47H+V0Rby8JASMaiijfZUuHOZTwRx+0ZiYGvuIkD6ZEeLSlGgCqt77036NoQDd?= =?utf-8?q?zVDhC5JEvjF7UxiXSYiA06FThijeRNl+jcW0bYfzlV+Q07XJ/EO0NhKoWB2Ri9Ewc?= =?utf-8?q?NT9Yvc+YBSbrhj7ItthgijFJMGSUrcR1e6pVowj/294IOsRkjE4ygtj3FjMTfmV7B?= =?utf-8?q?a8ux2gKONmHiB0CE0q8Cr0csdtTWHwd+YTzSb4grdaGbz4ZXgXt/J43wSFZUarbW3?= =?utf-8?q?Bpwr4GVM9iss0wqtAFtVJklmlhObTKQWzZl/8Df3YxDzmIB+Hlmp/F5EdMH7nVrwO?= =?utf-8?q?nIewefO7wMzu1sbth2PI0IruXOVXCSZvi9Nn/ldSccd+LrB+z+iaXsuvBqmoOMsrz?= =?utf-8?q?v//t9NSHMOSlYD7WEIJu79yS9l5b/PyLjYl31nIR4LaPnd3TPjfGayLXImFt+2KQu?= =?utf-8?q?3ktt66MZ+EHLr98Sz6URoGfNLWQ/WbHCHyg/vt6ov8JZn8Nd/6o/XZLTaL8nItyAl?= =?utf-8?q?QK8eTCp2JThnn4+jPCMxppF1ivIt3xE4aEg2vNACU0DwyqFSBzmc8xhJ6BPAfmj8M?= =?utf-8?q?ofM3kTM5dBBdXcTTe9pUhmbdMnoEwVXQ5J/ijJ2RuYY3Qs47JZz0HCbveER69pboJ?= =?utf-8?q?y5htUBMCtIayOHA9Jh+IJZqmITZIHFLW6H2SplTflS0H28Hi8xUaj1Vdw4DVzx/NI?= =?utf-8?q?mlTqwmR5392QFlYvkDhi7N0lr6HqUiXXrR2Ki68pNAGXDuBP6ApmsDExyFvrmvcL8?= =?utf-8?q?oc4lntZuhP7lH0OGOUGpWI/RsxUhIuNM5LWnfLoHk5T9ndfLAxdbo0gO9envCbJQy?= =?utf-8?q?dVUfqbu29K31ezGnA8hzbnFUqINOveQyNYDTlx905NAQUcmJTyfzOy46epYD7airn?= =?utf-8?q?QPNgjfBVqsUZqZQk53xkkpg9qVoxcHpRpgVzPf/OQXXfRa4FuZwBTgeO0dU4N2e8m?= =?utf-8?q?xjujogYsfUyBIdpbSKqNQuOKWE1Gio3UpE/aK5HfJ2Ks5DWCklcNudP2kPqAEmf8k?= =?utf-8?q?CJtqccmrgoXvKY0ivAuSUP0C7bNVvq99PTl4SH1/whK+RVqUABvQ7MRFz7cyrTE2B?= =?utf-8?q?9qlXJgSua4LmUnR5h5+zko+vbAZT558ORo2retXVk1zXSD6EUvydGA/QgvV0GUkwN?= =?utf-8?q?NhbyD2jTboDYHaOn4Bk5/SODgxJomNfKrkRnPDcSQAelaDHQXhHdE/XBBApG7CMPg?= =?utf-8?q?0Z/wE0bLZELK0qGk5JGULJJP88cT2QR3JUqLzdY9sgCdwMZBLo0tPm7lzlwk5ou0b?= =?utf-8?q?cNkb2nZLzftb?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27e2ae47-6d30-4a16-51e8-08dc5adcdad7 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9416.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 10:39:39.2503 (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: vk53YmvSaiag58yHOR/r8/RnDM7tWOC7M1FwmEw/uQvmrP3eP1gnY4N0ypp7H1mRpGqBQOMnASkAkomyoXIa4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7839 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_034016_355363_BBB8B774 X-CRM114-Status: GOOD ( 19.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan The BBM module provides RTC and BUTTON feature. To i.MX95, this module is managed by System Manager. Linux could use i.MX SCMI BBM Extension protocol to use RTC and BUTTON feature. This driver is to use SCMI interface to get/set RTC, enable pwrkey. Signed-off-by: Peng Fan --- drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-bbm.c | 317 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 318 insertions(+) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8f9f04a513a8..fb20e22074e1 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_BBM_EXT} += sm-bbm.o diff --git a/drivers/firmware/imx/sm-bbm.c b/drivers/firmware/imx/sm-bbm.c new file mode 100644 index 000000000000..fcb2ae8490c8 --- /dev/null +++ b/drivers/firmware/imx/sm-bbm.c @@ -0,0 +1,317 @@ +// 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 rtc_device *rtc_dev; + 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 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) + dev_err(dev, "%s: %d\n", __func__, 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; + int ret; + + val = rtc_tm_to_time64(tm); + + ret = bbnsm->ops->rtc_time_set(ph, 0, val); + if (ret) + dev_err(dev, "%s: %d\n", __func__, ret); + + return 0; +} + +static int scmi_imx_bbm_alarm_irq_enable(struct device *dev, unsigned int enable) +{ + 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; + int ret; + + val = rtc_tm_to_time64(alrm_tm); + + ret = bbnsm->ops->rtc_alarm_set(ph, 0, val); + if (ret) + dev_err(dev, "%s: %d\n", __func__, ret); + + return 0; +} + +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 void scmi_imx_bbm_pwrkey_check_for_events(struct work_struct *work) +{ + struct scmi_imx_bbm *bbnsm = container_of(work, struct scmi_imx_bbm, check_work.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; + + schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(DEBOUNCE_TIME)); + + /* + * Directly report key event after resume to make no key press + * event is missed. + */ + if (bbnsm->suspended) { + bbnsm->keystate = 1; + input_event(input, EV_KEY, bbnsm->keycode, 1); + input_sync(input); + } + + 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_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); + if (r->is_button) { + pr_debug("BBM Button Power key pressed\n"); + scmi_imx_bbm_pwrkey_event(bbnsm); + } + + 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; + + 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_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_min = 0; + bbnsm->rtc_dev->range_max = U32_MAX; + + ret = devm_rtc_register_device(bbnsm->rtc_dev); + if (ret) + return ret; + + bbnsm->nb.notifier_call = &scmi_imx_bbm_notifier; + return handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM, + SCMI_EVENT_IMX_BBM_RTC, + NULL, &bbnsm->nb); +} + +static int scmi_imx_bbm_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(struct scmi_imx_bbm), 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) { + dev_err(dev, "rtc init failed: %d\n", ret); + return ret; + } + + ret = scmi_imx_bbm_pwrkey_init(sdev); + if (ret) { + dev_err(dev, "pwr init failed: %d\n", ret); + return ret; + } + + return 0; +} + +static int __maybe_unused scmi_imx_bbm_suspend(struct device *dev) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + + bbnsm->suspended = true; + + return 0; +} + +static int __maybe_unused scmi_imx_bbm_resume(struct device *dev) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + + bbnsm->suspended = false; + + return 0; +} + +static SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_ops, scmi_imx_bbm_suspend, scmi_imx_bbm_resume); + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_BBM, "imx-bbm" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_bbm_driver = { + .driver = { + .pm = &scmi_imx_bbm_pm_ops, + }, + .name = "scmi-imx-bbm", + .probe = scmi_imx_bbm_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_bbm_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM BBM driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Apr 12 10:47:12 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: 13627609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6200CC00A94 for ; Fri, 12 Apr 2024 10:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=1nSskgTDf6Y7FLTjJEAAQp4UdijMfcjRStDmFGh80kg=; b=XSfqMNzbuo0DhgyUSBTGdrFKvt Nck7UzUJFawUgDPqFMXCxBmZ3iBQWuRNPmk8L+R0aLt3USWhStOos56Ar+FeHTlOyBUIum2g4z0Ak FSdA2rhFlVlmi7XW0b9kk/zUwyMDNFbuwrEND1BetbbCbdNfQXA3GkAgq2rJsEH/qxcfj+JncBy7U 8mug6tcHMu3cBMSq5ZoM6n+/aSKu4ciqOY56e5bfuB7FqPoIbshE5MrhGq9GjJZMp1U9jNAR2ENoc n/krkhOhsC6RZ71pUTivQLsK3i6XWBeoKsSfSWJsWcM6Sl6nW2ORXu0211HxOqA5wtQMt97p80Kdu 1+FBAIrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvELP-0000000GkSg-0177; Fri, 12 Apr 2024 10:41:19 +0000 Received: from mail-vi1eur02on20601.outbound.protection.outlook.com ([2a01:111:f403:2607::601] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rvEK1-0000000GjXF-2eCc for linux-arm-kernel@lists.infradead.org; Fri, 12 Apr 2024 10:40:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i3DLJkWdDJKtOaHEmJJT6R6E52rHTBR6ZKSK6oTINbNo+4YZ+NRsCUZvPmoHhmKArSYH+G9MUdzzELzCpImyt6fBTG9WxbTW5cBOMdcfZnE7kU7S8Dv2StqTF6sd4EGrWnM1bO98rbGgS2kct6Tp/+y3Uxl9jIeyca4NIxG3L2SMWPTP0jtSAIQQo6W3mQG3Sz6f/rKD5wqRE9qIUKl0FvtaKN2t85fQ4cuPkovLkURjEsSyC9Ulb0Rt5y4ADnm0k6xSMh0ILNZMkFm6b0rXgCdamkVEF0bQ+7RyP6nR3cyOTFBaLlLl4k5xzFpvVR9ojTAt48c4ISXu/kefgzK2cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qmLEKLDgTbuTKcvdN45vKFWC6Ra3feV6bbsCVFoin+Q=; b=MmK7po28Dogdg0Jv09RoI4o+tXEDf1DBq1C9JVzaki33xXLuLdPyou4vBSxHznXDUxFeLAe797XDYY3vK8w+0bcuwpjKRFI3pFlQGLbKpA6tCCfk7YPg2uBtxsgSQRArY6H7giPIOXWlT3HsJeS2y80M3z9saqrTkt7iqB+sTXUFjopqul+/aoLVeQCLlIqYueFHsMKIuvcUloOINWl0uWzmQL+UDjexL3k+0M6xU41tG6RkOQ3PtF49RneeSmhii6KZTgb/UrHx3CEWLMVn/oPF1G1Pz1HHkzQTm+ks5/CTZ+HIcmVEZjnj3zQAYD06y2LI/eB+i/u/asmCZF5cIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qmLEKLDgTbuTKcvdN45vKFWC6Ra3feV6bbsCVFoin+Q=; b=WXdU3DTRyLIAFaYxgCdVKccq9he7yS7ud6UlW4fqRhVPx8fiKulrBO2TjLcTv0TMcOSbwvEmNhEJOyM2Oig5ylNdoNL7gnpptJRKhUX944+ag0WvWcfBkI+vhaNSsmxafQwtAPJzeMxRN2U16F2PBLmSW8dhdf5jLEi/bDRwk7k= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) by VI2PR04MB10147.eurprd04.prod.outlook.com (2603:10a6:800:21e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.56; Fri, 12 Apr 2024 10:39:43 +0000 Received: from PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54]) by PA4PR04MB9416.eurprd04.prod.outlook.com ([fe80::9d65:d883:afbd:7f54%3]) with mapi id 15.20.7409.039; Fri, 12 Apr 2024 10:39:43 +0000 From: "Peng Fan (OSS)" Date: Fri, 12 Apr 2024 18:47:12 +0800 Subject: [PATCH v3 6/6] firmware: imx: add i.MX95 MISC driver Message-Id: <20240412-imx95-bbm-misc-v2-v3-6-4380a4070980@nxp.com> References: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> In-Reply-To: <20240412-imx95-bbm-misc-v2-v3-0-4380a4070980@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi Cc: Peng Fan , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712918849; l=4839; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=CxsTem4c2UkSyoEAgF9+D0rRRjQcCv/6gmp4AinHGy8=; b=MnmQFLlmxWxbr8VNJYoOn/Y4xHMlU3QSDhC1NmWmqVK4Jm557rYiLnofdQ9a8erkKvED215J6 6yVwHiJ47/CD0ys4iX56S80O+oVTBS1yzZr7xWdUx8rsJsEEBbnk/2b X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0243.apcprd06.prod.outlook.com (2603:1096:4:ac::27) To PA4PR04MB9416.eurprd04.prod.outlook.com (2603:10a6:102:2ab::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PA4PR04MB9416:EE_|VI2PR04MB10147:EE_ X-MS-Office365-Filtering-Correlation-Id: f2570369-9839-4ef9-7fde-08dc5adcdd93 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LXypHQ49sSI6HyaSVGk0ohKV78M13swP0AqN6U3jMzTnt5yQqdoI3+tgB8g3KzsbnhiDKNK6/loQ+7sswCNZ6OBcstfrDjFTaOXfjRxG5PDrZn0io8L98coh8TIwEUQ94V5hgHggoD/qf2Pp6csmA50mkO8M3FQg/XF6WdZpL3n6UmjkdW8BE6bYaIpgaMOhm1DzSs/2rUSJ8q6FHCQTdNR0z/TQIe+FfVnByxL06dhUfUeJMRDP22HziWqvB7oGXiqFI7sc8PqjbYqlHUySrPQ0z9hgPQV+kS7oRB0KcJoilod9fLnE7Z0nvSGOiMPDWuHuMW8qsaAVNzkeyvzMrkcRo0856xKiwCvtdO8pyuUL1bGkPvTT8KlIFIjDHkov6nFvEACXiTaGFVxI8DdyHFlSuA3V7Y1T+UF2zCBU8buaI7kLL43HrG6WUZTj5ZeTCVUvB0ww1dsADaCxFhksiiNssd97ma1NhrkNx2Bkv2MhNSUcMCPvZltolraTfOKy+QOBxxVkBYc27RZgYbEyixfRNKKYCnI0DBAR+hN3b1rjFQ2weTS4Qe6UWcg6HJJUglWDNtnYBow7JEIclwYVxMqJ25J+oqeXbPSrcXO0vxdCNwfcQhT/ayy48phOrBq7GFz8BMwWEnTdqaEaSwaSJ1jvOPvI0s6qyRdeLrEKqcDxodOkyw9ripNlK1G/8vKtr4u+j6Qzahxoqf8Wuj9HjmpRJCoYTdeS51aRDYuxRiY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PA4PR04MB9416.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(52116005)(1800799015)(366007)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?OKww1eExOHLRYGtfceWp0enryNdG?= =?utf-8?q?n+/IJRlpI4orxnLBn8upYhvsnIl0K6qQxA7g7UnWn9D7GNLQjNQKu4GHvETIcITaw?= =?utf-8?q?HG/iUasxlVCkrDuJxCaS5nqmRKu7KKXTcT69CKJMybAWCeoMvrjNfw5O/AhRfAZ8Q?= =?utf-8?q?qvX6bHGT2+pJcfepxppQZ95fZ7UJBLwFtxcGpFckrKnzWLEP407ZfSzg8gVT6PISz?= =?utf-8?q?dXPViYm5KnehvF8ZbgsT2rlrMxTrbhpDlf+r9BFQf3QD9AYW/nrRvNIGgQWaYXdB5?= =?utf-8?q?iOk996vTWTOa91m036OsGSlbphgxW6cBJMohvfR+HeuQULOtEIHp88URcm0zAUCeP?= =?utf-8?q?u48aVbZ0Pg0iTIu87OggNMn5caZljiS6Joq5k3pzLECOuJIZ6/ats7n4XJB9g/TKe?= =?utf-8?q?K+sM0w77lXnCO89ldqSpCYnE6hpI7Sz0+REsVf7KzgTiWsuNVX4YFiYtMKXgFm8st?= =?utf-8?q?MFDzpqZMuWNGiTTkaI+CX1hsFHg1NUC8E7EY1lfutEix9bJpk7221bjG1v+oTiaCv?= =?utf-8?q?gd6WDYG1pHyEfCo6igxM/9jHfCwPCIf18viB/MUnrG3HWH+HBlpdc+jTaNFA6m4di?= =?utf-8?q?Z92yDfpXPS4J8EasqRTxrkhylY4j6zIuuWgXza+TwkxfkKtgBqv9pRJYwP1Guy9VV?= =?utf-8?q?aqqZVxBuTmO1HRAFIf0vcDE58cy0T1pEnaqQkGgLAgZm7Wgz7HOERzAD8XPSnh3Ba?= =?utf-8?q?KfiqgCy2yEWrv91TA+O7TTTbQMInyP5wKdbNluRpniqjSXpWvoJJCNEl9fjO5rEwW?= =?utf-8?q?wMt4XSt0jvT25IeD/XUa4DXqXyNjkq5JmzTnKOQdr1lT7vOf0euiko44OqDjsKBpd?= =?utf-8?q?USC/eI7zPUt8nYSN4Y6mLtV1gCkb0/Ox+8BMbjnEH6DMkcDzioGiR0gp2z2x3scCH?= =?utf-8?q?MlJRXkttTYx1eKq0IuH8UCerq64XcXF3M59fv6BfDBrAaoo2lSIdrugxgHMH18PcK?= =?utf-8?q?W1qDVediK7sFlTHDl0wjnH1D8c1ZTdaOQBt3C1lH9ljTosNq/DMapCu67HgkzrGRz?= =?utf-8?q?EF+a1CpFw5rmitOoGuQ7ku9TLS5PT5jxJDw1wY6xC4nZho135dIW0sZfXO9i2yNTA?= =?utf-8?q?vR4O1ipEYkGiISeKk04WIR3/Bcs1Rm6Dgt+LWQSdPjalgDxfvZclbMQo8oJNLdcB9?= =?utf-8?q?d0TKOrjDBLkNXk3CmyJ6DfYpcp8ih4vSFfcYX9BScqLVz0NtloF+6eEMQp2gIfs8l?= =?utf-8?q?JWYvT8qsATGjFbVsBpVk2KLHoicpvqneLCc/6DKM1carc/sXjnU85xWyIcHhf+gkv?= =?utf-8?q?xtqQ2o11cHAF0ux0CNYXawJNOVSzKXYeOMSmznKokI/7H50fiPwpzWm0WKEcRXq1R?= =?utf-8?q?j3+4phLR35amb7h4HAhOBKnacG+FGkbrue1pifl+G2yvLmNIbwassDxy0S+TVCWoN?= =?utf-8?q?dC20hemYq5z6NS9SsB0nMJgfWqhEu0j2Sxx9mk8BnZMX36oy0NttQPolAT8oQSgQF?= =?utf-8?q?bcvGHuC3RIWs2joqkU4l1wcjgKJGvJ923mah8DbmoP7r+Ep78YJJG0TmsGl6AA3sf?= =?utf-8?q?WCNbfEXDRmwi?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2570369-9839-4ef9-7fde-08dc5adcdd93 X-MS-Exchange-CrossTenant-AuthSource: PA4PR04MB9416.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 10:39:43.7931 (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: FKnb3gXw1zjSaltvFe8AoSpQqHzFPS8+UGmYdaB3hvfJI7YGHDSyrYTThmHi3PN7Zn+2RI9bbt8M8q2qLN8kHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI2PR04MB10147 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240412_033954_334147_D9DAB7B8 X-CRM114-Status: GOOD ( 15.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Signed-off-by: Peng Fan --- drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-misc.c | 92 +++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 +++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index fb20e22074e1..cb9c361d9b81 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -2,3 +2,4 @@ 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_BBM_EXT} += sm-bbm.o +obj-${CONFIG_IMX_SCMI_MISC_EXT} += 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..a5609de426f6 --- /dev/null +++ b/drivers/firmware/imx/sm-misc.c @@ -0,0 +1,92 @@ +// 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) +{ + 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, evt_id, wu_num; + int ret, i; + + if (!handle) + return -ENODEV; + + 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); + + scmi_imx_misc_ctrl_nb.notifier_call = &scmi_imx_misc_ctrl_notifier; + wu_num = of_property_count_u32_elems(np, "wakeup-sources"); + if (wu_num % 2) { + dev_err(&sdev->dev, "Invalid wakeup-sources\n"); + return -EINVAL; + } + + for (i = 0; i < wu_num; i += 2) { + WARN_ON(of_property_read_u32_index(np, "wakeup-sources", i, &src_id)); + WARN_ON(of_property_read_u32_index(np, "wakeup-sources", i + 1, &evt_id)); + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC, + evt_id, + &src_id, + &scmi_imx_misc_ctrl_nb); + if (ret) + dev_err(&sdev->dev, "Failed to register scmi misc event: %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