From patchwork Fri May 24 08:56:43 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: 13672843 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 C3995C41513 for ; Fri, 24 May 2024 08:48: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=WJ2SqVHDEs39E/mJDq0bY2cuGJBE/2FBxZzHhMHxG8Y=; b=IxZ6TdCJTwVOArmkGLP47F6ZZC FxdxpJHJtWQcNsMJ4xhLlPdUcyO6xyIS5pE7vanNnYRRUUKFox2t8I6jViDxynfxSn5+vQpGU6lNG dplqAcJhFjuCf8Iyebzi3OB79BUslH2Hv6uDJh9s+Qz9lG7IL75tWuHOFy8VS1yqi7Ucbkok1xvuK 3+n9Oy8q0ML1BGwjipE7dL0HDe7RFqfbr++fRRpws1kiNbYB7nQgT/55kKR/GwIeMwOgIYX2eATIj +qUDhwDcZ810IaPGk3Sd4/+GX8lEFnH3EI8k4rN2LL3/Cur2ZH8zXgEdsAvvpx6p2M6goY1QQ8lLq MmXFVgIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQb8-00000008Q4W-2PmM; Fri, 24 May 2024 08:48:22 +0000 Received: from mail-db3eur04on061a.outbound.protection.outlook.com ([2a01:111:f400:fe0c::61a] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQb0-00000008Pwa-0uJ0 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 08:48:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZhCYoO5GbmglYIBBqcbGjK8VTfyLFmxfjbsLPBJllwaNnOosLe7FngGVMdjLwjJJNhF4C0Koo2528rxmAn8lvpwJmlEulYbAxfHo7fwfFBvDWJe7Pf6jQJLNIW2UvLtciCMnt2+Sv7cLMj08N+MAp+luBMb5v+d3nZHtVTr+q+7jhfFWkrRE2LCBE9VLjv8C7/Sbzk/ru4pM/qwkA3oGdgSqnCj8FOK/2c6Xvb3If1sXPA7v3U0Z1xdRkdJzACfrOsPWv7dBYHi7OqxA3mKLK/lweOsUaxKsLsB0k5kw0JyIPdNIfjVQJkDzynlS/Tjg1vzSFT3U7UVKn0sNvOwifA== 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=XTOGqsjUIROBv6+I1i2iMxboJyuAlrChAl9MTZdUzessDw3HLxaNe/+33jN4i0XIVFBkCR7jor7MZibnFeI5pWWV3UAfhNxLt/NHymTL0eHCyPdVVjVQlwl/h2dS0AMbzOFMWyTOuzEPH6fp1NN0O4TqVO//O/bdajOA9ZP4W1AbN6bg8mkXR+gbTU1YqzViytKTU+6GcvdMVmAv9AxudCZnH/vAgy4AqiBrcViytmF/6NfEwxjHJ6YYC1KILtgoPkRBcTtPXo+cNazIIMyKWZHMyIq64UmF3f/i3PrreertKbvUs6Sg/gNa3ui5L9Wrr9luC2Z6JW5G3P2EJONmqQ== 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=RmE0NcZo7GQkppAXwvZXXJPCV7aE/EdXwBEZTx17L5DNuT/Z73J7SnwuPfJycM1v85xDRjqi1dugpgTfK3Ntp0IRANu3hNwGZOsEm+Fb/WEwUDXiExW8kuzFTY59fNwHq0+hj3E83olzpKTHxixffLqCEPWxSvxWUo8bSJH0oc0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI1PR04MB9931.eurprd04.prod.outlook.com (2603:10a6:800:1d4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Fri, 24 May 2024 08:48:02 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c%7]) with mapi id 15.20.7611.016; Fri, 24 May 2024 08:48:02 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 May 2024 16:56:43 +0800 Subject: [PATCH v4 1/6] Documentation: firmware-guide: add NXP i.MX95 SCMI documentation Message-Id: <20240524-imx95-bbm-misc-v2-v4-1-dc456995d590@nxp.com> References: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> In-Reply-To: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peng Fan Cc: 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=1716541024; l=55803; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=fyjiPW7i3Esi/kVBE11tRQYjEUzJGakaE7Z+lYybjKY=; b=C8DEQaW9NtZMyOpCIaJeCieOu2aMJK9l333kusoGQ4OHfmkJWBQoD+aPO2WQ5Tbt+R8X8YjDo lcc6meUC1WSB2GDByIlU+ng0HOIqAxgfyxRZ+XK+yp33AfqwjILr8Jt X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0023.apcprd02.prod.outlook.com (2603:1096:4:1f4::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|VI1PR04MB9931:EE_ X-MS-Office365-Filtering-Correlation-Id: a969e505-e86b-4c4c-c4f4-08dc7bce3889 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|52116005|376005|7416005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?QYRW1NPU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XHpbdASw45nHkJWtee+5GuWqiC9QMLTL?= =?utf-8?q?QD+kv8puEewW3vUidMfytjBZvZFcT+s+LXNR7bSmxQ/seAUVhDwXjaUODP4OviRH9?= =?utf-8?q?d63EfPRj1FqE3qjInHwYcyyPygeB9O2DMfjV3I/17wTmOoC88uFqntAKMBxJdXuNL?= =?utf-8?q?jQcwsY8d9hceHFXTZFOo1F9IjahOSRB+UQXDq4dMiZ23tnTeq8uZ1Qtf5LfBeaqRu?= =?utf-8?q?5K0NDV3DyW3yzMnywB1aZiOvnIJ0MBlvdwmfGO+xbvy5vhYGs+OZnIiwzWigLV5uX?= =?utf-8?q?FxwXPdzSGAELaEbigJIbiswDFL1I9I6HLQ487oboNgm5GLsadWrbE12wI2oLVm2fQ?= =?utf-8?q?Che5ynbPYs5LTgsf+UKxnc7OONfD6lAZZoZ0Z0owfD2CKeYVscaKwF9NfH3Hvvmab?= =?utf-8?q?k9TheYVgbScqTp3tWmXS3qFshTisJ42Ef7KnOkZOOjyTgG/TI5Dw/+LI=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(376005)(7416005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?IhqTaaC/e/iCtLhFARiyq/AhmPat?= =?utf-8?q?UJDMeggqGnDEZ4BK6e8WjpO6emGbLzKUWyRElY5KG0osvDGxEA3qeOZL0sOJj3StU?= =?utf-8?q?JXzjbprSXX4RLBokc1Rm1BAaJlSM84uL3/FOXPX2UNXGVVRsLR7stYOpIs4GDbXg+?= =?utf-8?q?XDPu+Oi6MlfWVCMKBG0Dlw+ZwIHT5vjmRtkQZ8oMH3IqSkUPsQvHn4CRk/WgnstDa?= =?utf-8?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f-8?q?HJCa9lWAaVayesunTImfswTLVvTd2WiYomj+UKuSueKUWR9hiJfpCawY4e5dop0v8?= =?utf-8?q?Fn/OlQjHKU4fFeQOIHmpHzmd+WkylarPhRLnxcBIMaEwVdYL7E5PBG6J6bjIgS3sK?= =?utf-8?q?a/+9R68j4kijrYS9PCQl2Ig/+HuMSd5rERDD7m0M6CC0b4mvDR9MgBfFyGPMf44EE?= =?utf-8?q?D4RtJaPf5nAAhIS4Sh83GauhE0p1aY1cbgyXMl8vf/13yt9tRrOfLFvAAvF5oE5gr?= =?utf-8?q?DcWLg+fBnhIv4J7qqtR91CdZSP022Jy6L6kRyRCKaASdocTpMDh2LFheS2pZKOh68?= =?utf-8?q?2i7sgzk1YWC3Yc8EA661uzp4mfpAT0XEiu1/rdhYjbUaWWRaB2SUBHuyGq/8zdQ48?= =?utf-8?q?3ArWsN2yqxmf4xNiQwFePiDLwEVcKEAEj1woDh2BQDSqNjOdc8XzYv/ola809Fm4V?= =?utf-8?q?U8J+w3xjK7/X?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a969e505-e86b-4c4c-c4f4-08dc7bce3889 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 08:48:02.5001 (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: 2RF5vRBYTO6JKg+YMgEX/8CC3Ll4Nc6BbYBzZxtXecIJIus1EI9ZYo87XEA0MeQmMs4kjIWU41qyip3HX8O+Sg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9931 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_014814_788793_3E3F3074 X-CRM114-Status: GOOD ( 15.23 ) 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 May 24 08:56:44 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: 13672842 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 C09C3C25B74 for ; Fri, 24 May 2024 08:48: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=aiu9g6iNJWdMrDJCP1Ec4CgFmATEOaTyWzvJY7Nym1s=; b=05NW6ZbDr05dBRxgRFSqNaIU+a c75Jox2wGqm9wKRWabRuqaFCzPkqALaYIRNaCD7KAgevBb/Ozwo0hNYLDLDcZ3bS/QqSectFFKM1Y uDIs1JrBRLthz0OWV4Ydkc34yyu6xw6Iyq91mClstGp6H52LbqpYlXKZezXO7KP3CciVS+GYjCjOe acOzVNrHB7naLz/d+nsyJ5Q612/yOMm4dD4QAlcvEtFiJGbkdjR6tX5cwUyepln7zTokK0nySVbh/ xcbl1YHZ7eSzJNUiUo/82SpsJL7K5cKrPBJ/7vcW+Oy43/NVpNXVkM2OJyY0sEqwiSXtErHzsIUag mIR5MZlA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQbA-00000008Q5U-1WNT; Fri, 24 May 2024 08:48:24 +0000 Received: from mail-db3eur04on061a.outbound.protection.outlook.com ([2a01:111:f400:fe0c::61a] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQb5-00000008Pwa-3Ytl for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 08:48:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eQ/n3ttP9UsPBxyeUrY8NvEGcSYKdXnGiaMTftWCOyTbH8ljj/qP0Muq9a/okVkynBwLQKb1VFcYM4Bwkdf/62VUkUjlcIzYmQkwSmmNl3aaY7f130Ptz/JfZeNwwDUymjVuvVXEiXBTv5FMaQqJi73GP+mxy9/XIjwNOVlmKMWA9pbB1bI1DjqlwWMHvaNOpkep5ITNMmNJwWCL+cbKfmXM52vILMHda62/d8TA9wv2bCJwZL37uX3Rw+AapWmSEMCT5GhJ2CO6yToHr5NZzLC0AdbIVVUCSc/n8p/fzvzCIRBm/nrbuoodiotgCvkNvXbyvc2Fwy7FhaT14MF6gQ== 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=hvXC7aj8CdPSyHC5mKr9ZyjkOxagmn4DuQ76T39nl34=; b=HL/bzScUwfpsaCduIcDNFjqbOqwlEssCRTaHkROdOUBqa/rjbn+NWyj0YOLES4QSbtqMUygQI0J8pXfBww2CrS7x3tN03f2dgTI49BoYBkEe9pN0jojp0KsL2diwJOka2183MHKOtPpzD7y2JHEeR3Z4eMJSeCeQ0JfIp2HowpaOV4X9VfVSAPS4tFlTld+oz5uDWQ+mzWTgAkdJ9BUfbY4yoRTX+DGYEzWqA+8OXM1Y/r0CGVfg+dynGR0N4u7YBj56otm3y/L53oGcvhtYZvuE+Y4bB/zoz6GYPyzzPFHJKYCtTr9qUpFkWYQYwlYtm6373S2nU6x9frLRg9NjXw== 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=hvXC7aj8CdPSyHC5mKr9ZyjkOxagmn4DuQ76T39nl34=; b=lzEMJv5FDRO9Prg35Q4FeQp7grkOPzen1WhZ4kLwQdblK8hwSvAcFppIMue7qWWJkEFNXL3Ggq/Lff9A4to7ybk5WtfVL0eC/DRtWoRO03027XksC6iTDSxEUMkwoQftOBDAxqPjEif2O6bcji277/CXakXpQGD/9LuBIYjMDVo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI1PR04MB9931.eurprd04.prod.outlook.com (2603:10a6:800:1d4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Fri, 24 May 2024 08:48:08 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c%7]) with mapi id 15.20.7611.016; Fri, 24 May 2024 08:48:07 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 May 2024 16:56:44 +0800 Subject: [PATCH v4 2/6] dt-bindings: firmware: add i.MX95 SCMI Extension protocol Message-Id: <20240524-imx95-bbm-misc-v2-v4-2-dc456995d590@nxp.com> References: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> In-Reply-To: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peng Fan Cc: 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=1716541024; l=3068; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=jOGh34hNYtgrB3ysqbY5VPgRsqG8KK1fo2mx+9aW9nk=; b=UTrPVmTaF4kP1gw7YOYGKTSVmrdERvgmmY2Je3WUs3I9YBYACfLejAJtL0JN1YsD/pDwrhW8l L/Zf6K9+hvpB50apSubCYSsfymX8CLz/F4/5K6rTPwvQmnpdNFtgZNN X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0023.apcprd02.prod.outlook.com (2603:1096:4:1f4::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|VI1PR04MB9931:EE_ X-MS-Office365-Filtering-Correlation-Id: 1504684a-3470-486e-f7f0-08dc7bce3bdf X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|52116005|376005|7416005|366007|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?tbLhiUtk4LI/W2q9ndTwTncl9dUNtZ3?= =?utf-8?q?6wp+tVeJucwYcHdcOjej2mHt0XgLzYA6iVHCtqjmpe3P8GUvvapH7hlnARWdmnqCH?= =?utf-8?q?gj/k9KpT5JIZB9gi9Yfx4GFCST6glqj86l3oRh6gfbzE7Kxw5NlHuEcS4n0N6rM5r?= =?utf-8?q?sW2qlKrNWHZ7QkDOSVMtMLP/TlY73AqK1ez9/UlbIKpg/dr/vSZS0RGvOlwVbozj3?= =?utf-8?q?mk1OdWg/FQh8FGecaIJ2CAsLsxzm01iRBPwe2CKtbq+k+sMRSwa9d9mIVVuHWp7DM?= =?utf-8?q?8/Efaw/L17QwCya/L0m7p8r6oAcMBLQbq7RiSopVr9dF7BD98vKWYGVUPH0XzpgeR?= =?utf-8?q?fxnmimFPYT+nGkliwig7OiFN6V+cuXb80c1mlkOIJgpSwc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aBqQXlRm8xkgI3/qA03cBS//qgOU=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(52116005)(376005)(7416005)(366007)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?kr65vZTYqOxxxSRkysUp6IxyT22M?= =?utf-8?q?RTQulOXrRRr7b9rt7ToF1aw6Lm/P47bRUAdcYWWKF9HukUmN4EItKpUlsOjnD52s0?= =?utf-8?q?WW2zLjAVvyYCgV43gvqdxi3cXt/5Oac3o9oXhzllWOXiqWXCsZSjWF5mHg8oWAJo/?= =?utf-8?q?lbDpSm4duveKw2lLHtteeEFF9Bl+ndaHR9SL3U8SsoUOMIYt6UEvS9YhPP3hZG92w?= =?utf-8?q?Q5lRKEyP8nLhmrInxEfG64g7ZsOCQdsQzjUXlTv2ktVc21Nkgc2vE5RMh+TG0zI+y?= =?utf-8?q?kRxfrn8NeYemPYY4bkrvS4gB1LCYSczkgxELREMvAoXqlNXc2W38KoknmpGMKIoS4?= =?utf-8?q?p6fiM9qqTpFU33pO+DQoQXeQKmECpWsy2U+LLs7R0BjFFn8qH7xAdZPG9Jjlxe884?= =?utf-8?q?hwvOmcfgFRqkQ2BY3SGVES0zmrHcRh07iG3yImTz21db59m7sbpGXAyElb9Jl9Rha?= =?utf-8?q?wBXjr5sFojQ86LrGWWQWzSght0R5olpgKaCTCyfdGfIwiey2uKZjEjX0463Aprxbs?= =?utf-8?q?rnZWxTUEUrRIkmyUAsC6D1998sH2qqKxdUhEb2iDFa3h065lOxJiVTcL6Aqa9TU8j?= =?utf-8?q?ocxOsSp7XOkljVqOq6sbRVHmBy653gSpHK7F0AZDjeN1Nw749NgbiP4qZRTCsH5VS?= =?utf-8?q?CNM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-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1504684a-3470-486e-f7f0-08dc7bce3bdf X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 08:48:07.8678 (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: kwiK9Yoy3V0kl4QEVZHBq9g4j39NfAg+DkIpqeTbDIIgbuNRDxpdrmhTWvhGpCLhRkSVrT1HRPu3qLQirbrt/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9931 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_014820_080582_C4B860A9 X-CRM114-Status: GOOD ( 12.31 ) 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 Reviewed-by: Rob Herring (Arm) --- .../devicetree/bindings/firmware/arm,scmi.yaml | 5 ++- .../bindings/firmware/nxp,imx95-scmi.yaml | 43 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml index 7de2c29606e5..cead03fbe22a 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -22,6 +22,9 @@ description: | [0] https://developer.arm.com/documentation/den0056/latest +anyOf: + - $ref: /schemas/firmware/nxp,imx95-scmi.yaml + properties: $nodename: const: scmi @@ -278,7 +281,7 @@ properties: required: - reg -additionalProperties: false +unevaluatedProperties: false $defs: protocol-node: diff --git a/Documentation/devicetree/bindings/firmware/nxp,imx95-scmi.yaml b/Documentation/devicetree/bindings/firmware/nxp,imx95-scmi.yaml new file mode 100644 index 000000000000..1a95010a546b --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/nxp,imx95-scmi.yaml @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2024 NXP +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/nxp,imx95-scmi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: i.MX95 System Control and Management Interface(SCMI) Vendor Protocols Extension + +maintainers: + - Peng Fan + +properties: + protocol@81: + $ref: '/schemas/firmware/arm,scmi.yaml#/$defs/protocol-node' + unevaluatedProperties: false + + properties: + reg: + const: 0x81 + + protocol@84: + $ref: '/schemas/firmware/arm,scmi.yaml#/$defs/protocol-node' + unevaluatedProperties: false + + properties: + reg: + const: 0x84 + + nxp,ctrl-ids: + description: + Each entry consists of 2 integers, represents the ctrl id and the value + items: + items: + - description: the ctrl id index + enum: [0, 1, 2, 3, 4, 5, 6, 7, 0x8000, 0x8001, 0x8002, 0x8003, + 0x8004, 0x8005, 0x8006, 0x8007] + - description: the value assigned to the ctrl id + minItems: 1 + maxItems: 16 + $ref: /schemas/types.yaml#/definitions/uint32-matrix + +additionalProperties: true From patchwork Fri May 24 08:56:45 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: 13672845 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 A73A9C25B7D for ; Fri, 24 May 2024 08:49:00 +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=nfFpofBrM/bJnR4kBeYEO0wwMqwE6tHN1F/V+2YP+i8=; b=V27ysBrz9K43TbG/0q6dRdgQGx Yck0rBPa52mF+JplJe/dgKgjk3TuFNo2PQHk0khQxNvajg1BsXarlKi2KEMOb206WUV85CYTQ962p bP/c3jd2dcOpWNv+XJlmcWXd2dGvLh6C1AoG34nDxby4xrOtCItPiv86g7gYtmUtzfGmXeOK0Byyf khj0hjwR583YJ4JR689BbCJpZ+grvq8IrBpWoAVAHqFO7eH9qTQk1m9K577U6zvC8/k/YltnrMmaV Qtibv+5sF26VORjifGnM6eut8gO9HPk81MtUlCk9KeEPy2CjQy2ee9CXRIfkcW0Wx3itZd8FJRdo7 WCSRcbEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQbW-00000008QJf-2oqR; Fri, 24 May 2024 08:48:46 +0000 Received: from mail-vi1eur05on20600.outbound.protection.outlook.com ([2a01:111:f403:2613::600] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQb7-00000008Q1y-2Amu for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 08:48:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=atJYFbZtcj7Ip+OHbTgR9iSvSg1Fn2SCgD+ARMfPdLSK6JA3uEYo7aWPJOxPsRqSY6soiNQQQZW/dTWcmNiHQmhw4SEpLvmExJH2P3rAclS0/gJaSPgIoe4xpEuTZsdFf/+6PxGzsppV3U0Yv7wS5epYzaS9RM0dYx8UQ6O69emQggFpCrOlIO/eaMwk0xyjhPbVNGs29JsAg+CQvWNLznDga5iWjoShLvUV+NQLFFMtxHEJW/5k4W8TygSymcNzWD1GUrTgwMP9NNu2Ul4AKUOuyk3JWy90UwszP96M1XerU5NU9DOmK0Gi32BYS/l7Q6U92wbdOyzjTzefaIxfVw== 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=SDIiQ0WXldpS1c0zaz2zUEuRzwAAaQlxl5NUitHzIMk=; b=eL6E9puI65lFooGTxb4M/pJlkVeAcWGpm27vVGDdcYM+Xvwu5JjrGp+jiQgEJLvU0zf8d1+vTe0di/aD59aZWsKIuGy5WiVvxsX8/6tliEtRNFgkT5lbzal/Ua5oTroeXitb/Ao117N6DXsAqpxK2D8gCeqHCuvVPcuQ8z5b3RME39mZO32KoEwczgqdZnU8bOkx+e70CnfB+DoR9aMYDFNvFzXFNksxNmRgii90ns61oY5JQP6hWS35gsARwpKx9nLbAtEn6H39wUZGJgA27mgWwU1161OwsX4lTOy2zFedhJFSJHL2WzRSrF+CizSkf0ZwvU4aon9/eQTNuLavkg== 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=SDIiQ0WXldpS1c0zaz2zUEuRzwAAaQlxl5NUitHzIMk=; b=HEWofvCnWfEMLJyFvQZbHzsMvDS5g7m1xmCv79zSv1nar02QAw1wqpvEuwkSTLnIZTuHtMVXWFSMniF2HIXqVmVhBTkZJMcLmbx+IZpxRFQaDTF6pF/TVX2O7aCrSuQMJo5CNbxZKFLDONVlipJfQtJgkfbdJoKL2NuAIyxK8LA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI1PR04MB7149.eurprd04.prod.outlook.com (2603:10a6:800:12e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 08:48:13 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c%7]) with mapi id 15.20.7611.016; Fri, 24 May 2024 08:48:13 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 May 2024 16:56:45 +0800 Subject: [PATCH v4 3/6] firmware: arm_scmi: add initial support for i.MX BBM protocol Message-Id: <20240524-imx95-bbm-misc-v2-v4-3-dc456995d590@nxp.com> References: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> In-Reply-To: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peng Fan Cc: 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=1716541024; l=13836; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=LiEwtdf7o7H0ejhXmj7WnyGO4q5yLREiDmkzoa9AJTE=; b=ho5i5/6eHOq1JXzSaicvgEyzWSQvdVGwFnFMh8VIPGxFiwTrxqqY+HB+2lWSumhi+b6QoW81a YtOUyTRKpKNCS+qKNLV2iLuGxAIIJ8LGGB/P7IKhkooi2+/9NHFLiIf X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0023.apcprd02.prod.outlook.com (2603:1096:4:1f4::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|VI1PR04MB7149:EE_ X-MS-Office365-Filtering-Correlation-Id: 543a458b-45ed-469e-8c27-08dc7bce3f5a X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|7416005|52116005|1800799015|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?AkgFUuf8xrZHsowsbb2qUtDLhsaCS+N?= =?utf-8?q?+ae9A/8olbU8rpY5iuzeXAgJ3ZxoRKqm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LNnd2/madzF/uumUkngjSF7ku5OiW99+?= =?utf-8?q?nat6jNAOjm/CWbMx57sHJSPWZ+c6Eb/DDfQbdIafR2ubI8mL8RIuIjl6eLy/tQHg+?= =?utf-8?q?9+hcXBhgq03KmI3vFb2ijUWBmGoBE2AAL1lDraV33AqBKET5hpODCzenIGsBaWLZc?= =?utf-8?q?XbDQo4zozluMnXk+9Sor56bt5kxqWxNAFk8W/ZSJU+sp0XN2ldwkYI15pcUtdVMu6?= =?utf-8?q?gu4QVTkDxbg+coLRazI0yRvsyz9SIzMsQzN8eWY4b3nVwlPc1Vd+J/mRyUqSdtLoM?= =?utf-8?q?ymhmPMWQ7HTC48VjZUhY4Ee0i4I4iKL54wM4K+0TK+GtpCB4TWyXx0aem5Rkn1r2V?= =?utf-8?q?QMuMSgYY0o2FEkMzc62D9ae++f4Xg14whKr0ubwUiFZMdxrjMUDXT/TE=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(7416005)(52116005)(1800799015)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?QAsn1pckTPLs2vtMVUZQwxCZ21Zg?= =?utf-8?q?+F7SV24sUlYmmXDHOix3AsNzaDyY2x9l4/+q0gJbE1GnMhiwF97LrjhnXmNJSpUyM?= =?utf-8?q?UGtsR2FcqJ/HBTO/zFffem8JI9b5zRpI8Cn0sOQzyoIFPfr5cJXXil0TKA1yDIzDe?= =?utf-8?q?veVxyymBUuHfoXV+TUNsrdgCqAUI/YErBc9AMPiiIw6RIeccjFwu15DjzLSNY0Lwt?= =?utf-8?q?CbK31ZaoIypyLG4jIHKIa0Y1hA7ojnDJJNHyRkNFrc4e871gUfavB5jOXNaShf8dX?= =?utf-8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?utf-8?q?08FCdh0jIw1+/rZAkW5YbHuCEDdAziQyP0pz2I6vY+AOwz+9PixqXb8TxuvqMP9VD?= =?utf-8?q?+BL3qd6ysxhPGKDuqH3uRszZE7SQfklt+zTUuVrWAKJoqs9CpnVgdzeMsOj0QCahs?= =?utf-8?q?d1lOwwiZuiZm9lkaw2iMYDoOD1X+w4GCay/cREICmxq/1gmYS0SdS4J04RV2EorKf?= =?utf-8?q?lfJ3mI+9M4ccqtZ+xVm9qmODYDqw974VwRd539vbxjfx4GoCqbU8bUN6gfz0Vjlp9?= =?utf-8?q?UGTZDQcn5B2uRwcfIaT2ZMxsd5ALjtAgLLXOR39nLk+U21zI2u0Sw6BZE6WeRvnpF?= =?utf-8?q?7ZMCJQYE9m2Mebg+dGSAQ8uqNFl5Q02haDTKDOoptZQnPtCiStps/mZ0JUKSXMKSa?= =?utf-8?q?xUNpu0e6JCnC?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 543a458b-45ed-469e-8c27-08dc7bce3f5a X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 08:48:13.6867 (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: H2OdhUjYpDKCItjwLmbDozUeHVIfneLaxXTxUCZWVE1MQGEC91hq/t7Mj3AJyIfN7X8yUFB5btKBj0sMQa9RuQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7149 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_014822_011720_CCFF121C X-CRM114-Status: GOOD ( 15.64 ) 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 Reviewed-by: Cristian Marussi --- drivers/firmware/arm_scmi/Kconfig | 2 + drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/imx/Kconfig | 14 ++ drivers/firmware/arm_scmi/imx/Makefile | 2 + drivers/firmware/arm_scmi/imx/imx-sm-bbm.c | 380 +++++++++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 42 ++++ 6 files changed, 441 insertions(+) diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig index aa5842be19b2..79846cbaf71b 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -180,4 +180,6 @@ config ARM_SCMI_POWER_CONTROL called scmi_power_control. Note this may needed early in boot to catch early shutdown/reboot SCMI requests. +source "drivers/firmware/arm_scmi/imx/Kconfig" + endmenu diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index fd59f58ce8a2..fb9407fef60c 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -16,6 +16,7 @@ scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y) obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-module.o +obj-$(CONFIG_ARM_SCMI_PROTOCOL) += imx/ obj-$(CONFIG_ARM_SCMI_POWER_CONTROL) += scmi_power_control.o diff --git a/drivers/firmware/arm_scmi/imx/Kconfig b/drivers/firmware/arm_scmi/imx/Kconfig new file mode 100644 index 000000000000..4b6ac7febe8f --- /dev/null +++ b/drivers/firmware/arm_scmi/imx/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +menu "ARM SCMI NXP i.MX Vendor Protocols" + +config IMX_SCMI_BBM_EXT + tristate "i.MX SCMI BBM EXTENSION" + depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) + default y if ARCH_MXC + help + This enables i.MX System BBM control logic which supports RTC + and BUTTON. + + This driver can also be built as a module. + +endmenu diff --git a/drivers/firmware/arm_scmi/imx/Makefile b/drivers/firmware/arm_scmi/imx/Makefile new file mode 100644 index 000000000000..a7dbdd20dbb9 --- /dev/null +++ b/drivers/firmware/arm_scmi/imx/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_IMX_SCMI_BBM_EXT) += imx-sm-bbm.o diff --git a/drivers/firmware/arm_scmi/imx/imx-sm-bbm.c b/drivers/firmware/arm_scmi/imx/imx-sm-bbm.c new file mode 100644 index 000000000000..3f8321d247ae --- /dev/null +++ b/drivers/firmware/arm_scmi/imx/imx-sm-bbm.c @@ -0,0 +1,380 @@ +// 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, + .vendor_id = "NXP", + .sub_vendor_id = "i.MX95 EVK", +}; + +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..e59aedaa4aec --- /dev/null +++ b/include/linux/scmi_imx_protocol.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * SCMI Message Protocol driver NXP extension header + * + * Copyright 2024 NXP. + */ + +#ifndef _LINUX_SCMI_NXP_PROTOCOL_H +#define _LINUX_SCMI_NXP_PROTOCOL_H + +#include +#include +#include +#include + +enum scmi_nxp_protocol { + SCMI_PROTOCOL_IMX_BBM = 0x81, +}; + +struct scmi_imx_bbm_proto_ops { + int (*rtc_time_set)(const struct scmi_protocol_handle *ph, u32 id, + uint64_t sec); + int (*rtc_time_get)(const struct scmi_protocol_handle *ph, u32 id, + u64 *val); + int (*rtc_alarm_set)(const struct scmi_protocol_handle *ph, u32 id, + u64 sec); + int (*button_get)(const struct scmi_protocol_handle *ph, u32 *state); +}; + +enum scmi_nxp_notification_events { + SCMI_EVENT_IMX_BBM_RTC = 0x0, + SCMI_EVENT_IMX_BBM_BUTTON = 0x1, +}; + +struct scmi_imx_bbm_notif_report { + bool is_rtc; + bool is_button; + ktime_t timestamp; + unsigned int rtc_id; + unsigned int rtc_evt; +}; +#endif From patchwork Fri May 24 08:56:46 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: 13672846 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 B50FDC25B79 for ; Fri, 24 May 2024 08:49:02 +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=KzzwPKthF4HVJlH6L97WTpvcg2DuZpKVqHLCqpLaVkk=; b=fKQcnxi+CD/EtVrkVy/2jN9xlO C7aEkpMfMoiajiuMkfZn48LG1ZD60rFnHQtDlJ93jrCo5WzCr+fJJTNeW6ww/ys7W/aFLEHEFGfJX YOVqKFLV8Oy5IgptbS5UhJ/pwrj/dwML3Sdfmco5YCjtx6n3X5w1WwTrwh6jCPp9dJZfYl9Q1aJy5 fqluLARS7ApIRoXv9O+VAXzUsGK81HB+C2+stpEFD1zva60YvOSBw+9JzeEGsritkj2xjmoU08L53 pwQZ9ZVxXGe0byWSqDCh4EQDERgm0TyT2yI0+hJYAnnZAVED/TdwbZpEr3sflk8cvbrQe8Rkw32LY eJbFQT6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQbY-00000008QKi-1ENP; Fri, 24 May 2024 08:48:48 +0000 Received: from mail-vi1eur05on20600.outbound.protection.outlook.com ([2a01:111:f403:2613::600] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQbE-00000008Q1y-0Rc1 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 08:48:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NrHUW5zWNhIg/h0B4MKOeB9CNSF/qvyFkhoWOO6jJ7a0IkerP3KUUlkZmS/gymoB+3ut1Ti492wTfUihsrxxJ1K6Z9daL3KR/WnSPAVgHHkli20VH2TQgEl1KL26FON5BMMUlbsVzp0l6jpzVo2yljnjtPoCgKScocOlkPtf/ganzgG4FewU7Flp5VaRQJb2aMX/Tdg39jikJQ/aEb+aTPqcVlc3k7hNnJJ3rq6zpXm2b98UFsafDiWNwxuFns4jsWScOvYCSyJLfai9lXaSzLYw7QoOr9zUCmjxUAw3ei0G5kwQ9EsrUv/zr5Djp4im4yF1d7lKEcXf5a5FHwdtBQ== 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=rPfFM7ZrUtBRpsaZ8VSlqrA7EfNXSeEdu6+Tokdv9sE=; b=V89WwUfg3Xg7gTfAXGr8gpWBZXTqU1hRvHAjHs9DMrq6POmcT6TLgWG4lhA2++nZm/7nFZbT3tVWzqgRQe1YuERppAypG1dHJppdhpA4d43yJeMiOxIUlFl2asm2ZsGN6HPut8tSjJ9jaERs2s1z5WzOh9l3Q8tLVSPrZgiAtGPqQtUuQwsV4Rwx9okA2gtX9rjai5LnV4Lny3CRVEXlKTIk7wAXIILKQ7kVNwPUMybN55N8lb1F1CM3U6O9mB9F8hAND8Ist7xoMBovBHB1AVXCD5nOKXW7eemvELKxmGKIuDhUcBAOxajvNTsadQ4XmYMrYDbkHOmu5OZa7m77uw== 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=rPfFM7ZrUtBRpsaZ8VSlqrA7EfNXSeEdu6+Tokdv9sE=; b=KzdTG+pA+MYp/9IYZ7tR2rW917B9gMgSfXcACju5IIXlpTmNajMo5AJa5sjzkCBtZqwQHEfXn1Q1Nu7K5ScjlRSITqorrmZ1E6y+MpOHzLKkCQPp5j4AbcCXUvOawXbo1SLClfLuUpdXEVRVkdMwrsn8IZ5tqx8Y43CN+DEutvg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI1PR04MB7149.eurprd04.prod.outlook.com (2603:10a6:800:12e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 08:48:19 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c%7]) with mapi id 15.20.7611.016; Fri, 24 May 2024 08:48:19 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 May 2024 16:56:46 +0800 Subject: [PATCH v4 4/6] firmware: arm_scmi: add initial support for i.MX MISC protocol Message-Id: <20240524-imx95-bbm-misc-v2-v4-4-dc456995d590@nxp.com> References: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> In-Reply-To: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peng Fan Cc: 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=1716541024; l=11208; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=mW0EcuWJNi1Ev4S8xK4NKzhmyrrY3JZf9et/+B66yzk=; b=wJI9m9wiFMtXnsAD5ZHpVEDhFarIMTV/mwG4r0/YkRUnJnitjRdohxbotxrLX9OYEfuYRI3gw gbRsWlNHZNdAFArv9KPS8M+mjCKgP231nmcwNN256wYKlMvv134L+Kk X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0023.apcprd02.prod.outlook.com (2603:1096:4:1f4::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|VI1PR04MB7149:EE_ X-MS-Office365-Filtering-Correlation-Id: 831be702-e657-496a-3cd7-08dc7bce4285 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|7416005|52116005|1800799015|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?BNsDEOWxOdzFIUtafFsHnvwqtS46/2R?= =?utf-8?q?RGiv27WHitk5vGr4nU5fkkL+BxQw8kAlGCxnlaFPU1W7y9g0OCRgE9wag8XBrzSKg?= =?utf-8?q?R0tFKwSM68s/Td1dLWoS04srP8Br1FPPHa/Ri8Ui68bJrHX4YpbUHOrkTve4stg2B?= =?utf-8?q?YmagcTEXsEIEdlNedY424PjbVHUIG6K0twUM/uo+HQfKsAkdsJRcC/Vbjv3moT8Ud?= =?utf-8?q?0ELmcEo880YC/PcdBbKLZZ+0XIy16CukUcft9u1Aq8LY1Ise1Lgw8uiDNsXI5DOIY?= =?utf-8?q?4/mrN0/gJAorIvNKOz9fCkKbiQI2OHFjpm0Hr1PUQfTpq/7gkiULCAXYT2h4PMe5v?= =?utf-8?q?gOA2QtCAHHTAtPnVZsgUdJ9NRP0iRBGkfbolB5DtxlOaZSk46XuTIzQEGQTma9iPn?= =?utf-8?q?7bsQMjboavpQ1xAMcw64kqNp4P2iBnUEETpuawkGMivshQI5H0c+bjnuCpdFBYKE6?= =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IP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(7416005)(52116005)(1800799015)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?E+Z6JM7G83KU33j0BJQyRrEgdS1p?= =?utf-8?q?xuA8nqTUDIlxGHoEsijGiytcOkJYQX8rBMaee4EtkA0F7XnEoa84U7tb6pTQo1EpP?= =?utf-8?q?N+UOsIsv0ycyWjW6F0Ed3N8dukT1U63RltNLkWT28LMGo7Yr0Y8be29sxQEHNgrC9?= =?utf-8?q?3ED6jNYTOjSFjuAxlZ6FhZSakmvgW/fAR6MJJYiA0a7PPcFye0kICwKB1lEH2Zcof?= =?utf-8?q?ReWhM2FQ7bP/1Cm01YA+OJE9Zbq8O8AWUXnXGYiI31xlLyzrijzbEWQVGU/4XvL1p?= =?utf-8?q?VlmtrcKyOobd2UWS0BTH+RfKJWswxZCLcBlVKLBmmMaR8HyfeGGRjf0cdBy+lY1b6?= =?utf-8?q?rFjFk/AJIybSAEDYsm48gwcv6u3fOcgmI3ZWpgg6bUheflAogd3vtofl9Yr9+aHVp?= =?utf-8?q?ONfEHEgK3m8wGv0NAkojMFfGR2E5FHCJRu+Vvshhcvqz3u2dkhWaugchBjnIsOtSD?= =?utf-8?q?/QcDwI5ds7JvJeH57+HB5Dm0qXYVM9Q4qCv5t56nHJoo8HeFhVoCimMF97udNJbsX?= =?utf-8?q?xFCdhmC+dgwuF274TqhUveZdFy7WZtUNdX+l2Rv1wMRt5gzZIkDEfLpKjueVNzNoo?= =?utf-8?q?VhIlCxRtEEWWLtvHtOwlZygAytvRZGbrGd/gmd7nOilQhR341b4e1pS8j6QXJ+uxT?= =?utf-8?q?WA/Q1Je+8bwyQ/cawnLaDNTEQ5rh5+J4nImNJ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Exchange-CrossTenant-Network-Message-Id: 831be702-e657-496a-3cd7-08dc7bce4285 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 08:48:18.9958 (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: MuFi7CmE+p2/phoJpzPtat328gv+T0F4PJP3bt+ZdeVKEQkAwak8+7J9ulpqEC0E7Gl2Mf8k/SH0O0810nSSFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7149 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_014828_481105_85A63127 X-CRM114-Status: GOOD ( 15.92 ) 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/imx/Kconfig | 9 + drivers/firmware/arm_scmi/imx/Makefile | 1 + drivers/firmware/arm_scmi/imx/imx-sm-misc.c | 303 ++++++++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 22 ++ 4 files changed, 335 insertions(+) diff --git a/drivers/firmware/arm_scmi/imx/Kconfig b/drivers/firmware/arm_scmi/imx/Kconfig index 4b6ac7febe8f..e9d015859eaa 100644 --- a/drivers/firmware/arm_scmi/imx/Kconfig +++ b/drivers/firmware/arm_scmi/imx/Kconfig @@ -11,4 +11,13 @@ config IMX_SCMI_BBM_EXT This driver can also be built as a module. +config IMX_SCMI_MISC_EXT + tristate "i.MX SCMI MISC EXTENSION" + depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) + default y if ARCH_MXC + help + This enables i.MX System MISC control logic such as gpio expander + wakeup + + This driver can also be built as a module. endmenu diff --git a/drivers/firmware/arm_scmi/imx/Makefile b/drivers/firmware/arm_scmi/imx/Makefile index a7dbdd20dbb9..d3ee6d544924 100644 --- a/drivers/firmware/arm_scmi/imx/Makefile +++ b/drivers/firmware/arm_scmi/imx/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_IMX_SCMI_BBM_EXT) += imx-sm-bbm.o +obj-$(CONFIG_IMX_SCMI_MISC_EXT) += imx-sm-misc.o diff --git a/drivers/firmware/arm_scmi/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/imx/imx-sm-misc.c new file mode 100644 index 000000000000..9d0063299310 --- /dev/null +++ b/drivers/firmware/arm_scmi/imx/imx-sm-misc.c @@ -0,0 +1,303 @@ +// 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[MISC_MAX_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 evt_id, u32 flags) +{ + struct scmi_imx_misc_ctrl_notify_in *in; + struct scmi_xfer *t; + int ret; + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_NOTIFY, + sizeof(*in), 0, &t); + if (ret) + return ret; + + in = t->tx.buf; + in->ctrl_id = cpu_to_le32(ctrl_id); + in->flags = cpu_to_le32(flags); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int +scmi_imx_misc_ctrl_set_notify_enabled(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id, bool enable) +{ + int ret; + + /* misc_ctrl_req_notify is for enablement */ + if (enable) + return 0; + + ret = scmi_imx_misc_ctrl_notify(ph, src_id, evt_id, 0); + if (ret) + dev_err(ph->dev, "FAIL_ENABLED - evt[%X] src[%d] - ret:%d\n", + evt_id, src_id, ret); + + return ret; +} + +static 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; + if (src_id) + *src_id = r->ctrl_id; + dev_dbg(ph->dev, "%s: ctrl_id: %d flags: %d\n", __func__, + r->ctrl_id, r->flags); + + return r; +} + +static const struct scmi_event_ops scmi_imx_misc_event_ops = { + .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, + .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, + .misc_ctrl_req_notify = scmi_imx_misc_ctrl_notify, +}; + +static const struct scmi_protocol scmi_imx_misc = { + .id = SCMI_PROTOCOL_IMX_MISC, + .owner = THIS_MODULE, + .instance_init = &scmi_imx_misc_protocol_init, + .ops = &scmi_imx_misc_proto_ops, + .events = &scmi_imx_misc_protocol_events, + .supported_version = SCMI_PROTOCOL_SUPPORTED_VERSION, + .vendor_id = "NXP", + .sub_vendor_id = "i.MX95 EVK", +}; +module_scmi_protocol(scmi_imx_misc); diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h index e59aedaa4aec..e9285abfc191 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 { @@ -30,6 +36,7 @@ struct scmi_imx_bbm_proto_ops { enum scmi_nxp_notification_events { SCMI_EVENT_IMX_BBM_RTC = 0x0, SCMI_EVENT_IMX_BBM_BUTTON = 0x1, + SCMI_EVENT_IMX_MISC_CONTROL = 0x0, }; struct scmi_imx_bbm_notif_report { @@ -39,4 +46,19 @@ struct scmi_imx_bbm_notif_report { unsigned int rtc_id; unsigned int rtc_evt; }; + +struct scmi_imx_misc_ctrl_notify_report { + ktime_t timestamp; + unsigned int ctrl_id; + unsigned int flags; +}; + +struct scmi_imx_misc_proto_ops { + int (*misc_ctrl_set)(const struct scmi_protocol_handle *ph, u32 id, + u32 num, u32 *val); + int (*misc_ctrl_get)(const struct scmi_protocol_handle *ph, u32 id, + u32 *num, u32 *val); + int (*misc_ctrl_req_notify)(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 evt_id, u32 flags); +}; #endif From patchwork Fri May 24 08:56:47 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: 13672844 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 52827C25B74 for ; Fri, 24 May 2024 08:49:00 +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=ioVVw8yFlVpxvgP9UnDnq/crhXjR3jiD6gq048sB2T0=; b=PjVgdU/K8besCVB2j2b24cebtu rUEQbQt5Ut8O3H230or0P2Fp6LKUisGEvDPJHtT1S1q4dC63CYVGNqPHRrA3PhcbX02j5nXOQItQf +WW0ccbTTSbrhJzgtthBLIdesrl2XIPgaWQsVwVxeZVfSiaJbeVcGw1fxpPsmLTQHG25dHJTu2A8/ 43IKxRjxTxBlCw1ctETeO9Y4Cg4C52zQJYvaH86tHfUP+5GoI7uGJIVGWLA6vKdmo3uBxqedYpqt4 VcwjeSdyBGKQjQxfjJuy5KtdY3tiMhEyLTenQNXZy8U9dAZX92wj7oR5A4T/3uK0q/O0N5OfvD6aX IfNnmK9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQba-00000008QMA-0iMt; Fri, 24 May 2024 08:48:50 +0000 Received: from mail-vi1eur05on20600.outbound.protection.outlook.com ([2a01:111:f403:2613::600] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQbH-00000008Q1y-2ECq for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 08:48:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Od9Dug1wopLwMXwUL55VG8anG97DPn8ndU1FkEUUbobKP6WThlDCBhNd0WfLyF5tOj42GhZt+9MlaL0bFIoMUi7RuovcDEl+TV9NdbvO/ulvj83wgCqhQh1ZUu8RSPN9FQv6cEnt+bJmWuuOiQuXi5JofItSIvwAqFFVwJ75+LBJS2FH8Qqn5KcGE35sFK2dEDbpiTDbsZL8U1Kk8bJBuph+pCINHIXFqMYy5dfM/ml1TfX8b1udlWg/AL4g0tery4exmptmS2iUN8JqqJmFW49dRBBJKsFQPWU6Vwy6vYhi13HNQSxoj/DzJb/jKJcCmjK75EwKZOT+gVoRhQ3WQQ== 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=8NQY5udEZ6Omsl8pKuZ+IUofTK0jwbagvhq1E6uaoio=; b=RRv5CmxBCetvPEzHILcoovO13oC6u/lLkzNNorr40jGu0b7YSfEH+l+USPZEwb1z3201x3zsA3x8eP6fpZdcDBksNoI8QvT7KF6ovy723y1oR9T0wLnKY3qbgui46vquzvE81rQPa4EnroJ0nYF5XjGFVd30gTDsC703wfL3XcDLxhupQ3PUn+aHdKzpxoRfTEbPscFgqcSiKdWgaiXVaOMU1RNKVhvlcWWR4Sdr8wWBOsFy+WaUmCYEZ9TU8F05y4NNg+ARFevP7rBFtIJmzrgQL4dEB6gvpmK6QgiDoO8aNBVuiAFvzkPeTEtoT7/GSh2bO+3X5I8UEfA95ApYXA== 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=8NQY5udEZ6Omsl8pKuZ+IUofTK0jwbagvhq1E6uaoio=; b=SAJfiW5aouMleQ5Veb08DJDuibkTFZL8sfsj2IXX9ljqpWUaeYzz3H2uTKyopD0m6DoqVNjDhVmQ+QqqRxRUPoEbIVpflmRus6J0qiaJV+/NL9IIjCR1aeJhdFSEQ/tDUk7Th2lngcQw6YsDu6mTXbqNxnG201x0U+I/cMFc/lQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI1PR04MB7149.eurprd04.prod.outlook.com (2603:10a6:800:12e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 08:48:24 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c%7]) with mapi id 15.20.7611.016; Fri, 24 May 2024 08:48:24 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 May 2024 16:56:47 +0800 Subject: [PATCH v4 5/6] firmware: imx: support i.MX95 BBM module Message-Id: <20240524-imx95-bbm-misc-v2-v4-5-dc456995d590@nxp.com> References: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> In-Reply-To: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peng Fan Cc: 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=1716541024; l=9301; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=KYTXizoOVzSc57FIiRlksrodLSf5KroN9SCC/ukM9b0=; b=yQzW0dtrAJUl8NZNLs95d+aCLrCAYAH+il+T0WnEUyCaHfk+nhykqizedGrUSiGgfaYDwqKz6 f7gXNnWnILGBorWfVBmjCoFW+ONWzK7wLbfPvXQIigaoBN5HTQugmHb X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0023.apcprd02.prod.outlook.com (2603:1096:4:1f4::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|VI1PR04MB7149:EE_ X-MS-Office365-Filtering-Correlation-Id: 262250b7-d1cf-4bcc-a00e-08dc7bce45b1 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|7416005|52116005|1800799015|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?m1e75J7mqJeeA+3ynueyp3M+eyf73WJ?= =?utf-8?q?Vll7XHlbUEAoNuRm7AIz+f+GpYM4hplYNpoLo4i2STZQJoHUt52eN9IlSBPPwQadX?= =?utf-8?q?TccG/h4QR1yBqQiD1KMyRJyuUJ2vF3h7QN8tSCDEQGiUci9tJbZSrcSxWcDMv1oqr?= =?utf-8?q?6nNGAjTXe1b8AbLmyyIdVTy2JWFVubNUM1ceWCXsmP3rzGVRAqbEfHtOXlhFb7Xzz?= =?utf-8?q?Ptgp+otVJ8CjkU8kgYiTPWTtmeFEBE7g2KfexVRzrNTAhyMw07dPE3ZIvX6d/6l/X?= =?utf-8?q?sLGJlyJIQ43f2k2x6EyPfmbCpavCWhDfl2mx0x6a2CCcAX378G59vYg0yO0Ryt45S?= =?utf-8?q?ldAeJ/yJfoWMPsFhwkGzjoClsu88Ys9jMa04A+hepEITX2GaeSG7raIhVruJiyOJ/?= =?utf-8?q?ywrcdC8fn9IHUduAIzfKmK5vVHDsJuMyXkKttdASeKjTWF8M1xT2BMbtXYL3YpehB?= =?utf-8?q?IkmnTgZ64my3i/l6Cxy+WNH+SRy98/PJDESRJyFWlvA3muPZdafjUa5sN0mlQTn4+?= =?utf-8?q?2MJhCbmEe5kdfMCcezWUKRP5wP1lfsH8OwyY+WRJjzPmANpW8uh9FqwAufsYpdi+n?= =?utf-8?q?UvjLrk18CafByuxjI+4H1VxldlWZbtyOZq2IanfUqgu6uxr9RETaZK5kV63u2+Edq?= =?utf-8?q?mskK6WXLbThMOx7/a7fao89Zvu3/knLu1Fk1X9mIKt2vt9v/bFJtOBwF0t6TvXN8G?= =?utf-8?q?T3rv3QyXP20LnWd5cWN6QvddcYonCV/69QNkT8/AErebKZGRRCp2SCcNnwQsOo5Is?= =?utf-8?q?VmbdV5dhG6Aw7s3gfAwh94z2scC2PMoLaZFRhoUCgf/RO4ZlPyNPMmcQMmFTcaxuD?= =?utf-8?q?KpubCqiv/ysU8GcHPcS3iTWzCGJ6yMIt7eq+r8Taiw6hos/HkoLa6Pq9ICCDRY+Zf?= =?utf-8?q?9bUT+Aus6JuUUvFYwwHVffO3xbiNQyLQhGlzojwy2Ft7VE4vYHrLhcY+rKIUbWdzE?= =?utf-8?q?2vz9nrIAtox7mZv0BO+Ghuw73w9a3TsPpap6USdEOKaNRG3uj6gZdhPUb2sFHWLtQ?= =?utf-8?q?p1e3+fz8bopHRTPQjXFVvq9lbotHC5uym4Sb9saaZu74fYpfGizG6rAzr925l6n1x?= =?utf-8?q?sdVV3RTei4ka9s/4LX/j0IitxO8+Vzn6R6cPrTYjdydzygajrA5WFiDNObPrFkOje?= =?utf-8?q?7ToewsvT+59wFJ+e03GtuIAghy+VM5ZVUIRVXklxNy9q48UKxYoClcW+fAa/+OLay?= =?utf-8?q?KofCxwv7KAOnNJKwav9QJFgY63anJnOYSjQdfpYSBu2VcbqQjDabF3WkE2MVtPLio?= =?utf-8?q?ZByFlg9N9PIOUWZ6eI7FXjnlRdMLB98H9yL1iy9FcRsBT4e0ELi8XSfw=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(7416005)(52116005)(1800799015)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wQzYN61ZwtxgAb8jLXjnbwPXOSos?= =?utf-8?q?tTyU3hDNknyPJH76pkp8ULZy3lWIyul3oeg5W1uWhh8EK1EDGCtu8Vemglvgw1Ymd?= =?utf-8?q?vxqrNgrvtfKFbGOKN+SEc08bXpCHbSzP6HlW4ikpVfjLd+4S5rl0dCExJOltS8+ba?= =?utf-8?q?eys9NX2mWPBPnoh3tQrK1j2jFtpN6Y7BJDN7kMp8X1T4CD479FYuAYruOFH+wh6qv?= =?utf-8?q?HkpBCeUrU+pmbmH7ov9oAuZzTuzAuSmd6ZabuGcCrx3twuJaurRKFv7ksF5vR/CKh?= =?utf-8?q?F8fLfeyj159gN3wndZL8O8K9zF2wm3Rw8ewOes7GBkXzzCixx0GN3L7jEXeIs0ZxS?= =?utf-8?q?NMgdTFMGe5dja6I3Zrb9dmscE0TlXGyzIu8Ag3QerD3v5U6E50smF9R/i/bNuV7H+?= =?utf-8?q?mHg/d+zwzgEpjWunNskDXyytAW+8eBRJ+SZJgjhTVf86ABMgMdVW5o+MryWjZ1Zeq?= =?utf-8?q?OQnqWVVVxdVJWRyabOQsxHodihsxrLZaU4M+vzCJBtfmvj7850wSYDSKh+aRzY6ww?= =?utf-8?q?4J31MzBPxBmUH1UEtnlYdZdLjORHBSKcuHr67JMeuEbxnBSVLxq+M2Alk4/k4cDyF?= =?utf-8?q?BPk8oyMLSdJRXJlrNn6T5SP3jQ8Nuf2wJvqQBXZQNnhktQuLtgbswK7OulmTMGWyV?= =?utf-8?q?p5ClU/kUc9Y3+ZrQyj6XJShEuG/lF6qAKF48S3cux89c7rMKLtWc/QzNttUR+QV/e?= =?utf-8?q?Kk7LjhousEoqATa+PpQ7qY/D9BrDPq9IZjwuTwEpPwVok5Gnv2W1sTDLA+I1fN6aa?= =?utf-8?q?2Kv9wQxpKvZvmSQrOjaGFOlEqc8C5np+RWgjJcPkS4TcZC/R4YPfCbDfMDYo7rEdx?= =?utf-8?q?i95iGpSQtRhfh+TPkGaR6OqJ1c1ITzVmPgiiknEhQBgKBOFipCcbpe7qJl5al9I3i?= =?utf-8?q?AbHxceQQm4Hc1n7olj+P3TvxJvyJf7OtvVvv59f6qS7erwB8z1i27AlETQTueXDX/?= =?utf-8?q?LO4/8j/qvZtufRQB+mWvtnUeSeMsNZpZ+i4OWxYMccEwAbgxfrQTr8M6MfSVFUHP2?= =?utf-8?q?D27RJivBCZU+NrwnYxvbYyTXnkWU7OL7SDiW0YOVR4hjFNrA/DqNu4gZ/Lz5WPSK+?= =?utf-8?q?hRk8qiB/1rhB7Rpz0Wrqzvv9nTyalRoY2PsiS8fs/09sGkFJ3Ob4mdAJvP1JSS3Oh?= =?utf-8?q?f2caqQ63sUV5IAVPuswrpCCg8inMRgz/Pk7l1lrRkD5dz2ZwdjA1yLpXkepwCzbTi?= =?utf-8?q?8BvbzUd1mlJ/VPHhhWge5iVL2ikv6xXQrrKuY4kuZLM+Xi0xgsANnB96CkvRqMEtq?= =?utf-8?q?qM9HL77RNEsol4C9hHtG9ixfO/1Coe9UDpNzU66kn858MkFPhvO5OvNfatEf40/dz?= =?utf-8?q?i43+WXOem2OQfTqQRpZy3NSW92gHW2Em/UWYZFL53cl2h5aLaos910V9sF4M1qcyu?= =?utf-8?q?IuAA2NXXjCEYMc8W5jx8fPwNEbGUpejxTM1KVsn6pvLoYnyAdHKr1wUIp4Cx1rlhG?= =?utf-8?q?50hFJSVBp2oI7/g+YDJUZKEj9ctO5LZWkrHujvQ5AX3ShEdbLHZtBc7YtZ4SULCmx?= =?utf-8?q?6OH0IUvAObbW?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 262250b7-d1cf-4bcc-a00e-08dc7bce45b1 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 08:48:24.3637 (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: a2TFUp60S/dgfReowZnMSULWUWnHTpC+ysNpiLzhTDAphiEW7pqgzvs4YgJ0dopOuny93hTUC8Nf8pKOwy6P2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7149 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_014831_776285_72466994 X-CRM114-Status: GOOD ( 18.08 ) 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 | 314 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 315 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..5e7083bf8fd3 --- /dev/null +++ b/drivers/firmware/imx/sm-bbm.c @@ -0,0 +1,314 @@ +// 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); + bbnsm->suspended = false; + } + + 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) +{ + 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 May 24 08:56:48 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: 13672847 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 8C8C0C25B7D for ; Fri, 24 May 2024 08:49:04 +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=2NCVQn5W/vBwYHjz81Du6piSqYns32SwQkd+QKnI35I=; b=1Wz0M7Q0+PZ7rJArdROCbWZamz 6zRnwTUbG6CmEIZaMOnGIOCurcGLFe0ojZ78nh9rNb+n/E4A8db9y6xNP4Ckuy/9FVkHAW0n3FCW4 USwIVHZdlYlJspU3dhOVNwmwaRbcJ1JxhiDxK5/mfi6tIwIxgbedAjg1PCRhEa5xHgkyIzO30fnkf WztEyI8d33/Kd0AimPl7quIScR3WsuLbHQukOmYVYXCK3EXxfik7VJagPVIduT2CK91iWCTWq+UJl 4+bzkqPrwcv8yS2uDCB6za6yjpgUH+AwdF+YcQfL1lzC9m8W9TO9koV/Ke+rkIkaJCo13pztwO3yt dU0yQ/DA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQbb-00000008QNQ-2yUD; Fri, 24 May 2024 08:48:51 +0000 Received: from mail-vi1eur05on20600.outbound.protection.outlook.com ([2a01:111:f403:2613::600] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAQbK-00000008Q1y-3pII for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 08:48:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I9wns8TzJs58rdOaQITyoD0EtlEFi0ewDj+1S/7IvI9BOX/QjEvjB6z9XRd+1S/91MIA2+Y/uDT2pJXnmnQizVGnEb6XmUiJp2Ku3YpqpacMreLeXf80/HLd+pyRr/EDzPNx+kG7IecovIs9olo5Mk7CO0ZteVjaLo3J41UnlePvgfisV7TMgpnifcCc8vJjeZblDoGjlvFHlbbW7PGZ/eBz1D+7a3BDLbo7WuOnrrDHr6U1zAOT5emSZfNS4L69QismalnxX1ftIBiQFtB86VVH4Ziigdcpfo4VIZvDSl+RPgT4q2wQlp4aaOSNLw7x7n/ntUhRsuGkiad+jkaLbA== 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=OxAD0WISAG0EhoVXlvP6rzvlgsWO9vyOxx9AzUN1bCU=; b=SZ0cVxhek+iuW9EQOL6eIrwCNK9lQMHQYdcvIR5ADO9lGI09/oQB5kugmPAIjLRmLsrIsk3dF6oPMNeXxXiIvDGcmHDfxbgtxpXPio6jFOw3oACco8DfeawNY99e5ZgM9n0ISkKKtkZEiiewdwQ2DsIiav5MZW6D/8N5p/feakHO/lS8gb1y4Vdb02bvT7y7hy04rA+xfTspG1wFWKQ/w0sCwtFAPyc9GZ6m4HhbAcLx9vPffXlxIkW8JM6wqF+7SX3SvalMSN3zcbG6Nlo6yXhN3J26qC8KvI1Tcl5ySdrewX0Cu2t4r3OAez90Pu6sGP9Ggu/LeaVuozr9uXodIw== 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=OxAD0WISAG0EhoVXlvP6rzvlgsWO9vyOxx9AzUN1bCU=; b=GcR+a84qnTWWVALBjwNhRXHGvLB9T/lf7VSUqGkSi98gwj/Y/w8l/re2ZaITSq9pYVLUrOg/ZqfRLQ4sO4IpSjISYLqesBrH5Y/wZzvdstnZmjmC/9vn10D5r0SzYg+er34zKuHWU0fqVehKqVJv0pnf1fXmFnT0XnUs4e6Ad/I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI1PR04MB7149.eurprd04.prod.outlook.com (2603:10a6:800:12e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.22; Fri, 24 May 2024 08:48:29 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::557f:6fcf:a5a7:981c%7]) with mapi id 15.20.7611.016; Fri, 24 May 2024 08:48:29 +0000 From: "Peng Fan (OSS)" Date: Fri, 24 May 2024 16:56:48 +0800 Subject: [PATCH v4 6/6] firmware: imx: add i.MX95 MISC driver Message-Id: <20240524-imx95-bbm-misc-v2-v4-6-dc456995d590@nxp.com> References: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> In-Reply-To: <20240524-imx95-bbm-misc-v2-v4-0-dc456995d590@nxp.com> To: Jonathan Corbet , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Peng Fan Cc: 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=1716541024; l=5269; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=pFqUijGRbVOthzctHp+yS2z1grZ4Uyz1kZw2bfBgIOs=; b=r5S2v6roL2kbPs7O8mi0MQNHJfg1moHv8hZi8JFaX2cH4+7SqR13KWXsfZE8JFXEff1LTi8SK ixZsX/9WBzQB22Yitx4YCB2202Jlj+Jwad5ePQ/Md4g4vRBVAYGMSuL X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0023.apcprd02.prod.outlook.com (2603:1096:4:1f4::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|VI1PR04MB7149:EE_ X-MS-Office365-Filtering-Correlation-Id: d543bede-051e-41cb-9885-08dc7bce48e5 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|7416005|52116005|1800799015|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?chSRmsMXM+4G6vXgl09i4TUur26jexM?= =?utf-8?q?kfwlv2UQKcsFwd9KealSOROw+34h63y5qUAn/N2SWOFyrLIadiOcrfVM06kaH7l8i?= =?utf-8?q?Pd0LI6pNVu1eUzUfsvT+9RfyTdAQzngV2eCCk6eEzFCBEcCJgI1F9ayDPZsX0y9sU?= =?utf-8?q?nQRKTlVWKcktVBhcKZ9bDjLh8maDLa6Kei+CQCbW4VLfdlbqFYe5Z6HExAgZHMIMX?= =?utf-8?q?D/qpJLhiIx/S0E+PBSqsIVY2Se6FoBNmJusKYv4W60WNlTQbkeWLq83O3tEsQPzGm?= =?utf-8?q?az22qHQsNiRsTbZvOt+ZdYZQV0ong0x8X4bNurR3jn1sLMtLW5/125GWsv6mFoBus?= =?utf-8?q?EQ8tGgxIEGf3278D2Jumz+pZ6N5RUwr7E9UURQQxVJ1EcCotAp5d8wfp9G8aH8DUU?= =?utf-8?q?DCwrarb/QJxT3vKuxq/RN8bAxt0y/AwteuBQv1xeCbrPrNMlDSaXXcD0V4WCpC9fa?= =?utf-8?q?rjpMy05HTM/ksMFfgqERf9FxrmJfLzaF8kBkUMRDotEqAB+8BOOzjpM6tdPn4t3A3?= =?utf-8?q?NOJ+nn0X/gUI5qwHyIQGP2JXZBpZGBax2xsdURmbt6LZ1h7N4GpcV9rtGYgolN/OH?= =?utf-8?q?NcYCaqLPnE8vhx12uQL17bkJEskdxr2BESMW6JPhp8+AijCtwjqACqYu2UvT2Ihqh?= =?utf-8?q?ShJYdRbJXpHdrXJb/knAeSAAzvbwC7Ug7N6ycqDxeN0sPJMY4jMeZHq6tLXTRANJW?= =?utf-8?q?XwE2ljwaWI8eIASz0xx5QBV3Wmn3Aa9Vu7qOczfVR/QNvJT+nz+bqji54vpNkwFEl?= =?utf-8?q?Izc6loYwsap5HMY9fO6Jr3fL239PorBv7ulxWW+qT/+2S+qIENK45X+OCJnI1JgYK?= =?utf-8?q?A6SUNToEqVoa2utCqTvQjhGpyLyawhKuFBYH0fLMUriU/Jm6qoDLMqcQx7wXyVwdH?= =?utf-8?q?+j2kLP9oFRscP98e02sla5Dq3kDW387FL/wehzl6VMW7QLwNsr1LG7DVmx074GkWa?= =?utf-8?q?TDLtnAseCxAvcLpVzAMJ7qBVNYDK6yw3VWDQU0xsjZWYWk/9PavZsI/ceh+lSjO6a?= =?utf-8?q?4Db4uzGnr75Zjx/BtkBb9NLmx64TMZJr4r2nm2xJibdUqxcEPCwuI2BXJMd+QEiEO?= =?utf-8?q?NjWxHfKKhgkOKkVQCamSytp6H8tZTOGEh621CtoEKH9LowpsY3PnLK1yPbR++9ten?= =?utf-8?q?BRj8ONwmaZWHyQ6kjn7+YGDCUYSs8yA/vi0IqwfRCikATwxOcBpw5kycdK7TXKkJl?= =?utf-8?q?GVYWE2mGo1m8/hBfRgftG2SKl7G9US18szCYg7aFflQIs118hEwNAQ0pf8sfAGxvI?= =?utf-8?q?Vl2129RFnh3emvTI+coScq106TpgCTGipFyc+tnsWCeO1AibwtD/mwX8=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(7416005)(52116005)(1800799015)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Bg1zeTu5BO2FOFTApkgBt3aMoVj5?= =?utf-8?q?C0FcxaSH7Dc2H/oKE0Hx7hXz2NwlFMeFPqCvsZkHH8va1LMXUDo0oF19mRTobHSe4?=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utf-8?q?SLdWqqi2kzhwKEDScuVQd+sNMNXF1SO+U0TfUbTEdxNNcGznJJ1a/APilUoXQ0nHW?= =?utf-8?q?0lES7+5CYBrwXbJ/djd3x3LCwq6lp/bb44Q1kPo/6QKeUz2GqLaqc1Z7Z5KH9qwqi?= =?utf-8?q?cIJSlag7k/NoKxtBTiFjKrO2BNIe0amUWagUvJsR8YaOgs8o7R9Uc+HhYp5sgk0jY?= =?utf-8?q?5eA3RM8cORzSuPAL34+VH/uLhrc4VJrJirf5n5Dx8RXZsxouBG60Tiyy418klCyHt?= =?utf-8?q?wgtAOMafjT8WH7y6y5lmvj+aa1vbjaEU/hyfi1oW3IS9XQCh6IRU9VbQU1sWO3kJt?= =?utf-8?q?kGAJaoZ3VrHjAy1fDdtXYqJbCCU7A6fsz5ZB8SLgIzdUXiv2o6AZs9NVY4QhM3w6L?= =?utf-8?q?QwRGq9Pyehu/axCZsRl0eLO6GSrPt06No26PUp1PY+DN6eziERjed7NLA4umWZk9i?= =?utf-8?q?On7HG9MU2YUU16a4zcTNcxUfIP9Qss+6S7vdjJoqnINUlRdSkdns5Gv9KiHwqgpJQ?= =?utf-8?q?agIQlIGnxh+lIZpX8i6nBmtogXRDWdpwwuBGc4SX+mqg/gNg4ejsG1DMh3TM+oNzM?= =?utf-8?q?2QOEpVd+V/Ms?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d543bede-051e-41cb-9885-08dc7bce48e5 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2024 08:48:29.7156 (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: gL5+k130hyxT1fdH2B9iUPcacBRoSicVJCbP5maOj8e8S9R9p4tphjqBE1s2UzG1EyKFCCtBrcbTKDn6EL+YDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7149 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_014835_269899_A4FE6619 X-CRM114-Status: GOOD ( 16.51 ) 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 | 108 ++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 ++++++++++++ 3 files changed, 142 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..22c1a5819425 --- /dev/null +++ b/drivers/firmware/imx/sm-misc.c @@ -0,0 +1,108 @@ +// 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, flags; + int ret, i, num; + + 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; + num = of_property_count_u32_elems(np, "nxp,ctrl-ids"); + if (num % 2) { + dev_err(&sdev->dev, "Invalid wakeup-sources\n"); + return -EINVAL; + } + + for (i = 0; i < num; i += 2) { + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i, &src_id); + if (ret) { + dev_err(&sdev->dev, "Failed to read ctrl-id: %i\n", i); + continue; + } + + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i + 1, &flags); + if (ret) { + dev_err(&sdev->dev, "Failed to read ctrl-id value: %d\n", i + 1); + continue; + } + + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC, + SCMI_EVENT_IMX_MISC_CONTROL, + &src_id, + &scmi_imx_misc_ctrl_nb); + if (ret) + dev_err(&sdev->dev, "Failed to register scmi misc event: %d\n", src_id); + else { + ret = imx_misc_ctrl_ops->misc_ctrl_req_notify(ph, src_id, + SCMI_EVENT_IMX_MISC_CONTROL, + flags); + if (ret) + dev_err(&sdev->dev, "Failed to req notify: %d\n", src_id); + } + } + + return 0; +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_MISC, "imx-misc-ctrl" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_misc_ctrl_driver = { + .name = "scmi-imx-misc-ctrl", + .probe = scmi_imx_misc_ctrl_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_misc_ctrl_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM MISC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h new file mode 100644 index 000000000000..daad4bdf7d1c --- /dev/null +++ b/include/linux/firmware/imx/sm.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + +#ifndef _SCMI_IMX_H +#define _SCMI_IMX_H + +#include +#include + +#define SCMI_IMX_CTRL_PDM_CLK_SEL 0 /* AON PDM clock sel */ +#define SCMI_IMX_CTRL_MQS1_SETTINGS 1 /* AON MQS settings */ +#define SCMI_IMX_CTRL_SAI1_MCLK 2 /* AON SAI1 MCLK */ +#define SCMI_IMX_CTRL_SAI3_MCLK 3 /* WAKE SAI3 MCLK */ +#define SCMI_IMX_CTRL_SAI4_MCLK 4 /* WAKE SAI4 MCLK */ +#define SCMI_IMX_CTRL_SAI5_MCLK 5 /* WAKE SAI5 MCLK */ + +#if IS_ENABLED(CONFIG_IMX_SCMI_MISC_EXT) +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val); +int scmi_imx_misc_ctrl_set(u32 id, u32 val); +#else +static inline int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + return -EOPNOTSUPP; +} + +static inline int scmi_imx_misc_ctrl_set(u32 id, u32 val); +{ + return -EOPNOTSUPP; +} +#endif +#endif