From patchwork Fri Jun 21 07:04:36 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: 13706915 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2073.outbound.protection.outlook.com [40.107.22.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB76816B396 for ; Fri, 21 Jun 2024 06:55:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952951; cv=fail; b=h459+Jv460K4s9kRaRnfUIAJ8fFQO98C4LHXIDiW8iUAzNLjTuwcKf0+z8EWOk+aJllD9E90R9+oUnknofZ5wE3fD8MXN48TLwp6NBtJ4FaAQt1v1Pc/ZeJNK7UBylExyJnZcNKLv03GWygeIrqGgErH7jhg8ONK40B/ZuJJuss= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952951; c=relaxed/simple; bh=3bB969yPOcno3ecKlf2KwrutqmA9MAaa51lLGASMl1U=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=om82GdiKUTa5UP5CmH/vSviD6GLqEZVl+dxl091w47EYZjFLPpRbu2nhhiFoyYbEeLSOrSP6jvpDZ81M69T/VcXPwS2vil7+Ya+RdmDaLgMgO3TNfumU7HFGwy26DiJdKnMd3/Am1IlTRGHi7tEudUYTJACxJjrsi2fSQ3yQJ8s= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=bhLJt3dc; arc=fail smtp.client-ip=40.107.22.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="bhLJt3dc" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cY4q9Tme2fIgmoCFQ0DjD4BJVYXjp62TpQH/wTic8P5HDF4GEH4hosBZa/f0g3k1Q78ISFVX0uldC6e/yf+9/j+dRvOcdT1DNZXLdSIHjJK8drqlA1jhwhCCVHlSUwD02aylBq3uf1VWjykz1cM6UJiQhS1avVGa24qs6ziG0NJYPB0Uk9t3SibdgJ9qcySCkDSY13dxmeaoS3DtJvHW/QSIbBfdv2DKt4F50LezkIXlvj3Ehgf9lTeNZ08P1Vi6nTvIfLbCDh/sEMY/i8wXwJxQT801UitL+isPYS4vZutgtImK69T0QD5uaXZF/hIROkAeKBx4nvbw//gjEGErjQ== 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=jQGLNs4HQnxqPz7/aC1qwqXOzlFqEa+bgEWPkV6CXvA=; b=YmJn26EhmN1c7TQkvYPcUXPhsH/X8nDs+tLeuriftzrPXz6poOPMvXjWIBMp1T9J6y+mtv4rb5qxdwHZQfAN29vQHIkEI+xDA32KsZIEOGu5FZlAzC3ouNH6YHk6NPWZzUca/82PoYWbw5D/cJnkEALkeoG9+DVp6NyRtks6ccMqgMMrShALIjDmFx7fszQc2mF9ZeknVYr84sR95iwYJX8z+aSo+gskIOKrY6AgDssOUhRvgWUgjxpt1hn7XLOmCST+8bRPInw5C2VJ8PCZ7O5UwditMoEmIrEtsF7OISy7gdbLSS2xlOmmLwM8y3zzWmthKms/sOOv3FrYHBRY5w== 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=jQGLNs4HQnxqPz7/aC1qwqXOzlFqEa+bgEWPkV6CXvA=; b=bhLJt3dc4JhdZsulSRK3K9oquZDSp/OTROUYnDn0A+IIJgzrjVOFo11pec82qmuzUgoN8QA0N0RCzfhHmzNYuk5OHhuH1CNsQfBPZWBoUoFn9WwQFruGpXFp+fUmS7RlqRNxakzCN8EUGX81+CQ/WHwYN7g4h28WMNYJXj4vQZI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by GV1PR04MB10426.eurprd04.prod.outlook.com (2603:10a6:150:1cc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Fri, 21 Jun 2024 06:55:43 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.017; Fri, 21 Jun 2024 06:55:43 +0000 From: "Peng Fan (OSS)" Date: Fri, 21 Jun 2024 15:04:36 +0800 Subject: [PATCH v5 1/7] Documentation: firmware-guide: add NXP i.MX95 SCMI documentation Message-Id: <20240621-imx95-bbm-misc-v2-v5-1-b85a6bf778cb@nxp.com> References: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@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 , Alexandre Belloni , Dmitry Torokhov 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, arm-scmi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718953487; l=56444; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=ilYt43w3dYjk0YVi2cKAhfSqVWMt8gQT2yqQJN+Lc+8=; b=n+EtoWnQ3X9P9yGTEqGHEPCgzd+McAVU7MRmYaJojZxYQeNbCc+XnW7R87NoQfFIr+88poPdX q1mb0NofSSKAZkV4148v+VJ9sJXH2dd38X//+NHbtoMqSujAGb7ME2H X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|GV1PR04MB10426:EE_ X-MS-Office365-Filtering-Correlation-Id: 8d2ec44b-1632-4eee-f5f0-08dc91bf2b67 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|52116011|7416011|376011|921017|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?3KNPamTFn0njbE22bIg3Job9SO9w9I9?= =?utf-8?q?fQlLjKt7H9oJe5HbDGv25bVtcRQeOAt2JBOWWE624ZHayyvWaCFGG6r9H/Wu+5Xpo?= =?utf-8?q?Bp74yLp7gHlAYJxcJ2QZEs8g4XIWkP4mI4l2bHfnsC5nDhgjolEV/yoMjZEnGSExk?= =?utf-8?q?LMJ/nwpY9l6DeRuED6u3Ii1D+vH3BocV69+Ksh5sRfTLvAXWjo0/yxpdzF5zwy4Qj?= =?utf-8?q?VJR9NqtqzkCXAGrh4nJbojluL4Gne701pqAatGvkX+xm9rZgQ7Ej4zK7KvFOrf6+J?= =?utf-8?q?CyMlH3svecXrCSXTnJvzuMh/JonKBAGYR6f759bb8Ck0fz/wb41TxTdsYEvsBhODj?= =?utf-8?q?z27TdxKZw5+9yfF73XTpnzI0y2sxbuKDI6h/uvDzXpeJfcclUdC71IMX74K62zSPo?= =?utf-8?q?WYu95aCIZedfsEoyoXyGYTGEG7SZ3aYQkpFXwYBVD/OQsYfyWLrHs46r4FFXd06gA?= =?utf-8?q?9fyJWzk45xNGTIpjZjgXCnD1E/Tn4URM47GXECK5j7b2jfsNVCKmt5GLGYALGJCJx?= =?utf-8?q?XK9U+R5+USTV9aqCGzGyJcq8c9FjUCTr1cO2yCEIKlHTKIL7ZCVXETH33Xk78/8pR?= =?utf-8?q?UoSAUTCvME+seKNdSC2h5LsmfbE86Dwii7hJa4Xj5iugWJKIdE6VX1gKCxarj10SR?= =?utf-8?q?C+0pZfZsZ/Vok69VrSUPXhzoOap1oHP6DrPeqiX7ICWkRbMqeIHeyNsV3UO1HFWYh?= =?utf-8?q?dNsfMzIRPAv1gl+Sc5RvUFiD9BEOxYRAr6EB/jsTAJOA57FeZK0rc7BvVKUf9vqjj?= =?utf-8?q?TZgL7y/sAtJnEVt2vVetCJFHJ6O1TJkYwXBRl5eZiz7p8IeKJYrA3Un0v/ltyRpBv?= =?utf-8?q?z7qg1WRh0D6mzL0LfFmGIGmHqRo2x3nCStn3bWd9aL1z5p8jimClaFEa3sX/TCz7E?= =?utf-8?q?xbEpK6qa0YoBIMx/oqZtDOCmsyMk9cMqfsjFQFjzBq/bhoWU+OKPpTl9Kjrj9RPBb?= =?utf-8?q?J0ptNypOHQZlSiwBXoX8QNyQNuVbT70qT4/bbn37S6CzUYRav3P+nxFwaNJUph59a?= =?utf-8?q?6wTC5wu1eNPPXqZ4SiGoppj8mbqGJ/x/J6nNZRpoTgQnjGvO9T4leg3OnsH10C88O?= =?utf-8?q?fbvqN+p2WG7xx4mR033ByWIOaSLzkJjyXZLLI6nAKS1y2/Nm9Rspm1pSBO9VYV5cf?= =?utf-8?q?sJUDh+6a0WbIDvLWaxlIZ+0LbHCSlLHFvGho7YI9PovQrtWSIsBz/v8p7tgBVA6EX?= =?utf-8?q?XaD0RIAEZS2JCk3+W2MkOdc+YgPsnGIY/NivWQ7n053TN+s9p1JPd6+XfkBcnoRKW?= =?utf-8?q?fH3M9K4WtPdL0Gf9FXXUzbPPTxvvafzwPbsTSqiXlnusrUnCthe5fnkWw/qj8EaKd?= =?utf-8?q?2n0iP71sLDAF?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5941.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(366013)(52116011)(7416011)(376011)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?9qNfPW45CPo+iIp0ql1O2gnN5+SS?= =?utf-8?q?Ibw6mmNfROSXFLjLF9tH7Z+/bPcdyzYCeEK4HTbhVV05M50juW9q51Z/5t+ImCLYj?= =?utf-8?q?kRc7tlft/k+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o38FFRCCftAhDR5rBv0OXYq81th8pvP2V4x5FfNBGzVjx0R1?= =?utf-8?q?q/VRh7zbV8mDnrke5KT8tLvrxtKmsb4iWejKsEtWh5dWDNkoAULCJMFWmu/iZTrX1?= =?utf-8?q?mcAYN8pVwxxJ6tTFsOeLj034J8+3jHSKhhPfvNjoqSs8PT8do9S+X3wRL3HO3cKhy?= =?utf-8?q?gNEDMqVC63mDQbf/wAMnc+0LHY4Ol+QRr2xFepdxTYVsB+khI6QdHxr29RsVl01i+?= =?utf-8?q?CGE3fEt1tpaCT/g9lwDpWoNa30xkCtwEUzwE5u3BdCBj+T/OyvVaSIeRHL3P0tkg0?= =?utf-8?q?aF70ddFp6REjWPMZUSKtPSMTl7Eu75ViqDSN7sZgPdhH3sjh3wCdumeRqO0vJAAa3?= =?utf-8?q?l9WQIAwWFR9YjT0csLBShxbktm8wgdTZQGkuhT0+zzD9ONXwFoJTnSmrXeYDtWCpW?= =?utf-8?q?xdMQpAPKJcHanbslu5DZphj77WmsowhdTfDCJ6SFW9EH3N//pqn/iM7L53ziCCKwV?= =?utf-8?q?S8sVtnZ9xZgLwKIXycxY+n4MI2gyXXaMk4q0OToW5GB4IfIthOUlT79xn/giG2LBO?= =?utf-8?q?akk86i2srKS3?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d2ec44b-1632-4eee-f5f0-08dc91bf2b67 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 06:55:43.8379 (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: UNkic7TaWjIGcwYkaip2z9r28NnZNMY6XzdqWpeiesFtLhqGTpQ5IP4XwgnX9kWDPiPQ+NoOs1QP7L6E83hFow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10426 From: Peng Fan Add NXP i.MX95 System Control Management Interface(SCMI) vendor extensions protocol documentation. Signed-off-by: Peng Fan Reviewed-by: Cristian Marussi --- Documentation/firmware-guide/index.rst | 10 + Documentation/firmware-guide/nxp/imx95-scmi.rst | 887 ++++++++++++++++++++++++ Documentation/firmware-guide/nxp/index.rst | 10 + 3 files changed, 907 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..03ee81978f65 --- /dev/null +++ b/Documentation/firmware-guide/nxp/imx95-scmi.rst @@ -0,0 +1,887 @@ +.. SPDX-License-Identifier: GPL-2.0 +.. include:: + +=============================================================================== +i.MX95 System Control and Management Interface(SCMI) Vendor Protocols Extension +=============================================================================== + +:Copyright: |copy| 2024 NXP + +:Author: Peng Fan + +The System Manager (SM) is a low-level system function which runs on a System +Control Processor (SCP) to support isolation and management of power domains, +clocks, resets, sensors, pins, etc. on complex application processors. It often +runs on a Cortex-M processor and provides an abstraction to many of the +underlying features of the hardware. The primary purpose of the SM is to allow +isolation between software running on different cores in the SoC. It does this +by having exclusive access to critical resources such as those controlling +power, clocks, reset, PMIC, etc. and then providing an RPC interface to those +clients. This allows the SM to provide access control, arbitration, and +aggregation policies for those shared critical resources. + +SM introduces a concept Logic Machine(LM) which is analogous to VM and each has +its own instance of SCMI. All normal SCMI calls only apply to that LM. That +includes boot, shutdown, reset, suspend, wake, etc. Each LM (e.g. A55 and M7) +are completely isolated from the others and each LM has its own communication +channels talking to the same SCMI server. + +This document covers all the information necessary to understand, maintain, +port, and deploy the SM on supported processors. + +The SM implements an interface compliant with the Arm SCMI Specification +with additional vendor specific extensions. + +SCMI_BBM: System Control and Management BBM Vendor Protocol +============================================================== + +This protocol is intended provide access to the battery-backed module. This +contains persistent storage (GPR), an RTC, and the ON/OFF button. The protocol +can also provide access to similar functions implemented via external board +components. The BBM protocol provides functions to: + +- Describe the protocol version. +- Discover implementation attributes. +- Read/write GPR +- Discover the RTCs available in the system. +- Read/write the RTC time in seconds and ticks +- Set an alarm (per LM) in seconds +- Get notifications on RTC update, alarm, or rollover. +- Get notification on ON/OFF button activity. + +For most SoC, there is one on-chip RTC (e.g. in BBNSM) and this is RTC ID 0. +Board code can add additional GPR and RTC. + +GPR are not aggregated. The RTC time is also not aggregated. Setting these +sets for all so normally exclusive access would be granted to one agent for +each. However, RTC alarms are maintained for each LM and the hardware is +programmed with the next nearest alarm time. So only one agent in an LM should +be given access rights to set an RTC alarm. + +Commands: +_________ + +PROTOCOL_VERSION +~~~~~~~~~~~~~~~~ + +message_id: 0x0 +protocol_id: 0x81 + ++---------------+--------------------------------------------------------------+ +|Return values | ++---------------+--------------------------------------------------------------+ +|Name |Description | ++---------------+--------------------------------------------------------------+ +|int32 status | See ARM SCMI Specification for status code definitions. | ++---------------+--------------------------------------------------------------+ +|uint32 version | For this revision of the specification, this value must be | +| | 0x10000. | ++---------------+--------------------------------------------------------------+ + +PROTOCOL_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~ + +message_id: 0x1 +protocol_id: 0x81 + ++---------------+--------------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status | See ARM SCMI Specification for status code definitions. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes | Bits[31:8] Number of RTCs. | +| | Bits[15:0] Number of persistent storage (GPR) words. | ++------------------+-----------------------------------------------------------+ + +PROTOCOL_MESSAGE_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x2 +protocol_id: 0x81 + ++---------------+--------------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: in case the message is implemented and available | +| |to use. | +| |NOT_FOUND: if the message identified by message_id is | +| |invalid or not implemented | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Flags that are associated with a specific function in the | +| |protocol. For all functions in this protocol, this | +| |parameter has a value of 0 | ++------------------+-----------------------------------------------------------+ + +BBM_GPR_SET +~~~~~~~~~~~ + +message_id: 0x3 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of GPR to write | ++------------------+-----------------------------------------------------------+ +|uint32 value |32-bit value to write to the GPR | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the GPR was successfully written. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to write | +| |the specified GPR | ++------------------+-----------------------------------------------------------+ + +BBM_GPR_GET +~~~~~~~~~~~ + +message_id: 0x4 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of GPR to read | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the GPR was successfully read. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to read | +| |the specified GPR. | ++------------------+-----------------------------------------------------------+ +|uint32 value |32-bit value read from the GPR | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_ATTRIBUTES +~~~~~~~~~~~~~~~~~~ + +message_id: 0x5 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: returned the attributes. | +| |NOT_FOUND: Index is invalid. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Bit[31:24] Bit width of RTC seconds. | +| |Bit[23:16] Bit width of RTC ticks. | +| |Bits[15:0] RTC ticks per second | ++------------------+-----------------------------------------------------------+ +|uint8 name[16] |Null-terminated ASCII string of up to 16 bytes in length | +| |describing the RTC name | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_TIME_SET +~~~~~~~~~~~~~~~~ + +message_id: 0x6 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Bits[31:1] Reserved, must be zero. | +| |Bit[0] RTC time format: | +| |Set to 1 if the time is in ticks. | +| |Set to 0 if the time is in seconds | ++------------------+-----------------------------------------------------------+ +|uint32 time[2] |Lower word: Lower 32 bits of the time in seconds/ticks. | +| |Upper word: Upper 32 bits of the time in seconds/ticks. | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: RTC time was successfully set. | +| |NOT_FOUND: rtcId pertains to a non-existent RTC. | +| |INVALID_PARAMETERS: time is not valid | +| |(beyond the range of the RTC). | +| |DENIED: the agent does not have permission to set the RTC. | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_TIME_GET +~~~~~~~~~~~~~~~~ + +message_id: 0x7 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Bits[31:1] Reserved, must be zero. | +| |Bit[0] RTC time format: | +| |Set to 1 if the time is in ticks. | +| |Set to 0 if the time is in seconds | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: RTC time was successfully get. | +| |NOT_FOUND: rtcId pertains to a non-existent RTC. | ++------------------+-----------------------------------------------------------+ +|uint32 time[2] |Lower word: Lower 32 bits of the time in seconds/ticks. | +| |Upper word: Upper 32 bits of the time in seconds/ticks. | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_ALARM_SET +~~~~~~~~~~~~~~~~~ + +message_id: 0x8 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Bits[31:1] Reserved, must be zero. | +| |Bit[0] RTC enable flag: | +| |Set to 1 if the RTC alarm should be enabled. | +| |Set to 0 if the RTC alarm should be disabled | ++------------------+-----------------------------------------------------------+ +|uint32 time[2] |Lower word: Lower 32 bits of the time in seconds. | +| |Upper word: Upper 32 bits of the time in seconds. | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: RTC time was successfully set. | +| |NOT_FOUND: rtcId pertains to a non-existent RTC. | +| |INVALID_PARAMETERS: time is not valid | +| |(beyond the range of the RTC). | +| |DENIED: the agent does not have permission to set the RTC | +| |alarm | ++------------------+-----------------------------------------------------------+ + +BBM_BUTTON_GET +~~~~~~~~~~~~~~ + +message_id: 0x9 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the button status was read. | +| |Other value: ARM SCMI Specification status code definitions| ++------------------+-----------------------------------------------------------+ +|uint32 state |State of the ON/OFF button. 1: ON, 0: OFF | ++------------------+-----------------------------------------------------------+ + +BBM_RTC_NOTIFY +~~~~~~~~~~~~~~ + +message_id: 0xA +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of RTC | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Notification flags | +| |Bits[31:3] Reserved, must be zero. | +| |Bit[2] Update enable: | +| |Set to 1 to send notification. | +| |Set to 0 if no notification. | +| |Bit[1] Rollover enable: | +| |Set to 1 to send notification. | +| |Set to 0 if no notification. | +| |Bit[0] Alarm enable: | +| |Set to 1 to send notification. | +| |Set to 0 if no notification | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: notification configuration was successfully | +| |updated. | +| |NOT_FOUND: rtcId pertains to a non-existent RTC. | +| |DENIED: the agent does not have permission to request RTC | +| |notifications. | ++------------------+-----------------------------------------------------------+ + +BBM_BUTTON_NOTIFY +~~~~~~~~~~~~~~~~~ + +message_id: 0xB +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Notification flags | +| |Bits[31:1] Reserved, must be zero. | +| |Bit[0] Enable button: | +| |Set to 1 to send notification. | +| |Set to 0 if no notification | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: notification configuration was successfully | +| |updated. | +| |DENIED: the agent does not have permission to request | +| |button notifications. | ++------------------+-----------------------------------------------------------+ + +NEGOTIATE_PROTOCOL_VERSION +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x10 +protocol_id: 0x81 + ++--------------------+---------------------------------------------------------+ +|Parameters | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|uint32 version |The negotiated protocol version the agent intends to use | ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: if the negotiated protocol version is supported | +| |by the platform. All commands, responses, and | +| |notifications post successful return of this command must| +| |comply with the negotiated version. | +| |NOT_SUPPORTED: if the protocol version is not supported. | ++--------------------+---------------------------------------------------------+ + +Notifications +_____________ + +BBM_RTC_EVENT +~~~~~~~~~~~~~ + +message_id: 0x0 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 flags |RTC events: | +| |Bits[31:2] Reserved, must be zero. | +| |Bit[1] RTC rollover notification: | +| |1 RTC rollover detected. | +| |0 no RTC rollover detected. | +| |Bit[0] RTC alarm notification: | +| |1 RTC alarm generated. | +| |0 no RTC alarm generated. | ++------------------+-----------------------------------------------------------+ + +BBM_BUTTON_EVENT +~~~~~~~~~~~~~~~~ + +message_id: 0x1 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 flags |RTC events: | ++------------------+-----------------------------------------------------------+ +| |Button events: | +| |Bits[31:1] Reserved, must be zero. | +| |Bit[0] Button notification: | +| |1 button change detected. | +| |0 no button change detected. | ++------------------+-----------------------------------------------------------+ + +SCMI_MISC: System Control and Management MISC Vendor Protocol +================================================================ + +Provides miscellaneous functions. This includes controls that are miscellaneous +settings/actions that must be exposed from the SM to agents. They are device +specific and are usually define to access bit fields in various mix block +control modules, IOMUX_GPR, and other GPR/CSR owned by the SM. This protocol +supports the following functions: + +- Describe the protocol version. +- Discover implementation attributes. +- Set/Get a control. +- Initiate an action on a control. +- Obtain platform (i.e. SM) build information. +- Obtain ROM passover data. +- Read boot/shutdown/reset information for the LM or the system. + +Commands: +_________ + +PROTOCOL_VERSION +~~~~~~~~~~~~~~~~ + +message_id: 0x0 +protocol_id: 0x84 + ++---------------+--------------------------------------------------------------+ +|Return values | ++---------------+--------------------------------------------------------------+ +|Name |Description | ++---------------+--------------------------------------------------------------+ +|int32 status | See ARM SCMI Specification for status code definitions. | ++---------------+--------------------------------------------------------------+ +|uint32 version | For this revision of the specification, this value must be | +| | 0x10000. | ++---------------+--------------------------------------------------------------+ + +PROTOCOL_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~ + +message_id: 0x1 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status | See ARM SCMI Specification for status code definitions. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Protocol attributes: | +| |Bits[31:24] Reserved, must be zero. | +| |Bits[23:16] Number of reset reasons. | +| |Bits[15:0] Number of controls | ++------------------+-----------------------------------------------------------+ + +PROTOCOL_MESSAGE_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x2 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: in case the message is implemented and available | +| |to use. | +| |NOT_FOUND: if the message identified by message_id is | +| |invalid or not implemented | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Flags that are associated with a specific function in the | +| |protocol. For all functions in this protocol, this | +| |parameter has a value of 0 | ++------------------+-----------------------------------------------------------+ + +MISC_CONTROL_SET +~~~~~~~~~~~~~~~~ + +message_id: 0x3 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of the control | ++------------------+-----------------------------------------------------------+ +|uint32 num |Size of the value data in words | ++------------------+-----------------------------------------------------------+ +|uint32 val[8] |value data array | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the control was set successfully. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to set the | +| |control | ++------------------+-----------------------------------------------------------+ + +MISC_CONTROL_GET +~~~~~~~~~~~~~~~~ + +message_id: 0x4 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of the control | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the control was get successfully. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to get the | +| |control | ++------------------+-----------------------------------------------------------+ +|uint32 num |Size of the return data in words, max 8 | ++------------------+-----------------------------------------------------------+ +|uint32 | | +|val[0, num - 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, max 8 | ++------------------+-----------------------------------------------------------+ +|uint32 | | +|arg[0, numarg -1] |Argument data array | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the action was set successfully. | +| |NOT_FOUND: if the index is not valid. | +| |DENIED: if the agent does not have permission to get the | +| |control | ++------------------+-----------------------------------------------------------+ +|uint32 num |Size of the return data in words, max 8 | ++------------------+-----------------------------------------------------------+ +|uint32 | | +|val[0:num-1] |value data array | ++------------------+-----------------------------------------------------------+ + +MISC_DISCOVER_BUILD_INFO +~~~~~~~~~~~~~~~~~~~~~~~~ + +This function is used to obtain the build commit, data, time, number. + +message_id: 0x6 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the build info was got successfully. | +| |NOT_SUPPORTED: if the data is not available. | ++------------------+-----------------------------------------------------------+ +|uint32 buildnum |Build number | ++------------------+-----------------------------------------------------------+ +|uint32 buildcommit|Most significant 32 bits of the git commit hash | ++------------------+-----------------------------------------------------------+ +|uint8 date[16] |Date of build. Null terminated ASCII string of up to 16 | +| |bytes in length | ++------------------+-----------------------------------------------------------+ +|uint8 time[16] |Time of build. Null terminated ASCII string of up to 16 | +| |bytes in length | ++------------------+-----------------------------------------------------------+ + +MISC_ROM_PASSOVER_GET +~~~~~~~~~~~~~~~~~~~~~ + +ROM passover data is information exported by ROM and could be used by others. +It includes boot device, instance, type, mode and etc. This function is used +to obtain the ROM passover data. The returned block of words is structured as +defined in the ROM passover section in the SoC RM. + +message_id: 0x7 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if the data was got successfully. | +| |NOT_SUPPORTED: if the data is not available. | ++------------------+-----------------------------------------------------------+ +|uint32 num |Size of the passover data in words, max 13 | ++------------------+-----------------------------------------------------------+ +|uint32_t | | +|data[0:num-1] |Passover data array | ++------------------+-----------------------------------------------------------+ + +MISC_CONTROL_NOTIFY +~~~~~~~~~~~~~~~~~~~ + +message_id: 0x8 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 index |Index of control | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Notification flags, varies by control | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: notification configuration was successfully | +| |updated. | +| |NOT_FOUND: control id not exists. | +| |INVALID_PARAMETERS: if the input attributes flag specifies | +| |unsupported or invalid configurations.. | +| |DENIED: if the calling agent is not permitted to request | +| |the notification. | ++------------------+-----------------------------------------------------------+ + +MISC_RESET_REASON_ATTRIBUTES +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x9 +protocol_id: 0x84 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 reasonid |Identifier for the reason | ++------------------+-----------------------------------------------------------+ +|Return values | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|int32 status |SUCCESS: if valid reason attributes are returned | +| |NOT_FOUND: if reasonId pertains to a non-existent reason. | ++------------------+-----------------------------------------------------------+ +|uint32 attributes |Reason attributes. This parameter has the following | +| |format: Bits[31:0] Reserved, must be zero | +| |Bits[15:0] Number of persistent storage (GPR) words. | ++------------------+-----------------------------------------------------------+ +|uint8 name[16] |Null-terminated ASCII string of up to 16 bytes in length | +| |describing the reason | ++------------------+-----------------------------------------------------------+ + +MISC_RESET_REASON_GET +~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0xA +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Parameters | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|uint32 flags |Reason flags. This parameter has the following format: | +| |Bits[31:1] Reserved, must be zero. | +| |Bit[0] System: | +| |Set to 1 to return the system reason. | +| |Set to 0 to return the LM reason | ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: reset reason return | ++--------------------+---------------------------------------------------------+ +|uint32 bootflags |Boot reason flags. This parameter has the format: | +| |Bits[31] Valid. | +| |Set to 1 if the entire reason is valid. | +| |Set to 0 if the entire reason is not valid. | +| |Bits[30:29] Reserved, must be zero. | +| |Bit[28] Valid origin: | +| |Set to 1 if the origin field is valid. | +| |Set to 0 if the origin field is not valid. | +| |Bits[27:24] Origin. | +| |Bit[23] Valid err ID: | +| |Set to 1 if the error ID field is valid. | +| |Set to 0 if the error ID field is not valid. | +| |Bits[22:8] Error ID. | +| |Bit[7:0] Reason | ++--------------------+---------------------------------------------------------+ +|uint32 shutdownflags|Shutdown reason flags. This parameter has the format: | +| |Bits[31] Valid. | +| |Set to 1 if the entire reason is valid. | +| |Set to 0 if the entire reason is not valid. | +| |Bits[30:29] Number of valid extended info words. | +| |Bit[28] Valid origin: | +| |Set to 1 if the origin field is valid. | +| |Set to 0 if the origin field is not valid. | +| |Bits[27:24] Origin. | +| |Bit[23] Valid err ID: | +| |Set to 1 if the error ID field is valid. | +| |Set to 0 if the error ID field is not valid. | +| |Bits[22:8] Error ID. | +| |Bit[7:0] Reason | ++--------------------+---------------------------------------------------------+ +|uint32 extinfo[8] |Array of extended info words | ++--------------------+---------------------------------------------------------+ + +MISC_SI_INFO_GET +~~~~~~~~~~~~~~~~ + +message_id: 0xB +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: silicon info return | ++--------------------+---------------------------------------------------------+ +|uint32 deviceid |Silicon specific device ID | ++--------------------+---------------------------------------------------------+ +|uint32 sirev |Silicon specific revision | ++--------------------+---------------------------------------------------------+ +|uint32 partnum |Silicon specific part number | ++--------------------+---------------------------------------------------------+ +|uint8 siname[16] |Silicon name/revision. Null terminated ASCII string of up| +| |to 16 bytes in length | ++--------------------+---------------------------------------------------------+ + +MISC_CFG_INFO_GET +~~~~~~~~~~~~~~~~~ + +message_id: 0xC +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: config name return | +| |NOT_SUPPORTED: name not available | ++--------------------+---------------------------------------------------------+ +|uint32 msel |Mode selector value | ++--------------------+---------------------------------------------------------+ +|uint8 cfgname[16] |config file basename. Null terminated ASCII string of up | +| |to 16 bytes in length | ++--------------------+---------------------------------------------------------+ + +MISC_SYSLOG_GET +~~~~~~~~~~~~~~~ + +message_id: 0xD +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Parameters | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|uint32 flags |Device specific flags that might impact the data returned| +| |or clearing of the data | ++--------------------+---------------------------------------------------------+ +|uint32 logindex |Index to the first log word. Will be the first element in| +| |the return array | ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: system log return | ++--------------------+---------------------------------------------------------+ +|uint32 numLogflags |Descriptor for the log data returned by this call. | +| |Bits[31:20] Number of remaining log words. | +| |Bits[15:12] Reserved, must be zero. | +| |Bits[11:0] Number of log words that are returned by this | +| |call | ++--------------------+---------------------------------------------------------+ +|uint32 syslog[N] |Log data array, N is defined in bits[11:0] of numLogflags| ++--------------------+---------------------------------------------------------+ + +NEGOTIATE_PROTOCOL_VERSION +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +message_id: 0x10 +protocol_id: 0x84 + ++--------------------+---------------------------------------------------------+ +|Parameters | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|uint32 version |The negotiated protocol version the agent intends to use | ++--------------------+---------------------------------------------------------+ +|Return values | ++--------------------+---------------------------------------------------------+ +|Name |Description | ++--------------------+---------------------------------------------------------+ +|int32 status |SUCCESS: if the negotiated protocol version is supported | +| |by the platform. All commands, responses, and | +| |notifications post successful return of this command must| +| |comply with the negotiated version. | +| |NOT_SUPPORTED: if the protocol version is not supported. | ++--------------------+---------------------------------------------------------+ + +Notifications +_____________ + +MISC_CONTROL_EVENT +~~~~~~~~~~~~~~~~~~ + +message_id: 0x0 +protocol_id: 0x81 + ++------------------+-----------------------------------------------------------+ +|Parameters | ++------------------+-----------------------------------------------------------+ +|Name |Description | ++------------------+-----------------------------------------------------------+ +|uint32 ctrlid |Identifier for the control that caused the event. | ++------------------+-----------------------------------------------------------+ +|uint32 flags |Event flags, varies by control. | ++------------------+-----------------------------------------------------------+ + 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 Jun 21 07:04:37 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: 13706916 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2046.outbound.protection.outlook.com [40.107.22.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 182B9168C1D for ; Fri, 21 Jun 2024 06:55:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952956; cv=fail; b=WnbQLHUN46MJhAlbb0gsBknl6kcveEqpsPFKJ4wqqkXqsjJhurnJvGf+s8TK2s5hj+YHgVcT4r2e+Fs7wGyhkYcH/YgkjiSm0zLKVFOTUjl5XVEBNlk44JiWj5/WZK4ilRowIYMndmQUCA+Ef7UyPDkKHS4JncVQ7GWyLY7fVCM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952956; c=relaxed/simple; bh=G4nGSdnZXL5YrqPNc+JpT348+bi1RjrP7YsaFpTG4aY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=cYKDVDYbuP3fLSSy57sWxwtGmywcLrXetAI2KJ6QQf9DiXA2bg9hRJCBmMijAbucpZSqavsz2sTpDArxLHwbTeg1JbwRFgYIXHCjKv3/H/rfbvpH2TIo8dZdkNKVbSkMaTjEUeYelKgaaP+J40HwioqPnhy2buGczf2g5EMXiRg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=flODI7lk; arc=fail smtp.client-ip=40.107.22.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="flODI7lk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xa+/fpXcm3iFaj6/e0BIzmblGFK6UVbAguJraf5JrOfSxaW+r2qGvbGRXI4kSNAWUyaMv51Z4QwMu7X8PHejKxekIMBSgSTx/3UJ+gZzhLTylB/rpHh1hsRn7F8Wj+4A8KL9ORJ0YBYa7964NDeM0cP9uRJE5BqQN6W2XazRaRTdOa4/iN4MSGYR32Q/Qc2N+4KtAs7yAk3+tArLf7PDtOwyKBNjkhWrSNwbnkqGyhkXm+UknZg5xWIkuBewC/THN5+C+J+rugC04OaGXuix2c59iL+x3CytmcgU8vpGUMgmDeBehqzCB8NezPVffHM8wgb2T0FHnlUf1qQYVzcLXw== 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=3QoauDQxxFBenh0iSUn2b3RJUCaW1ML4tL550SXdj6g=; b=Je64J+fsuq38ire+7vx0AnW67M+zW5DT5Fp0ti/0vkElSValnccnsd/Oz1/TWGfifZufwF48JVTSX7lsd85zFtL0WA7r5Ql2/0+Ck3zo6/vcKnohWQVs089acw2GgjlV8a1ipkeV8G84GLRU8wlhLH9oOEkCCpO2zcLSFo2nJ/muKHeY22yH6gwf2jciWMyT6xDZ4HqSe/53L1p2xnnsn83F5eeWCczfv1Lupk3Ujfml/4Yy9LWslb4goihhCfi7lwTReWNGhMdLe7LUIZYvgcc4T0z2Ybx+TNB5Q7wbgtI/xCYKC5KBSG+2Hrewo5w3kLfQY6gEj3V9DCObPRQN1A== 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=3QoauDQxxFBenh0iSUn2b3RJUCaW1ML4tL550SXdj6g=; b=flODI7lkJaa+W4NWrIt5V1ong9RG0pl/mQRVmp72ARG/09B2sUcd6qteJlCY1i1qZlMmsV8K31DbTFzdgS2a39zUKWy8pr7+Fcz393v7V74pOZhyds6+yQpJZh2JKnYV7InnAFFiMgwiWyXc2RCDisw4ORAWb/4jqtlT0vHYU0Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by GV1PR04MB10426.eurprd04.prod.outlook.com (2603:10a6:150:1cc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Fri, 21 Jun 2024 06:55:50 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.017; Fri, 21 Jun 2024 06:55:50 +0000 From: "Peng Fan (OSS)" Date: Fri, 21 Jun 2024 15:04:37 +0800 Subject: [PATCH v5 2/7] dt-bindings: firmware: add i.MX95 SCMI Extension protocol Message-Id: <20240621-imx95-bbm-misc-v2-v5-2-b85a6bf778cb@nxp.com> References: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@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 , Alexandre Belloni , Dmitry Torokhov 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, arm-scmi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718953487; l=3120; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=XkeqFAGjNHOKfoWCkbUZAUkgOf7T6GEG5kbFMiWO5cE=; b=evh5Cwt3Yx42Ap7J/WIZLUu1fj85CvDAkAWvSR/udDvf/zZ20Lm3CYBLvW5qtnW3kJWC1Ujqk jLfnFUjXAJeDIblXyt+hVj1uHR2uILB2IVOVhTePO9r713BHG3vqsjd X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|GV1PR04MB10426:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e28bfc7-114a-4c27-ae9d-08dc91bf2fb3 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|52116011|7416011|376011|921017|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Rx+mpZwhNp28s8a39+mjYsT2laM7m51?= =?utf-8?q?WutMdWA/1bGFFlhgpvnUXByCE+sj0HYwWQXXac8PapeVeRAyEApsk5T1DZ8nnQvaR?= =?utf-8?q?GeF2jH6KOGnv2SFpd3GnKkOjUrN3CWzlMkijhrBez+SZV7ZVJ5GWBX4ZX4+AtcZMd?= =?utf-8?q?wu/FyFTkY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n0NrfGaV7kHIDJxpmSiegHDhwd6zNSc6xBVkTha?= =?utf-8?q?RcPXIc2Td8QmneO1UHFuwQi2RQd4UAK9ca8SsHQiNNEBLxfdqz4uxHIQZ1goPQuw7?= =?utf-8?q?f2xeHZDeBYn/qZ+93v8bNiVuIPEnCk7Xf1S2u29xNPcxY6JZVqq/7+GCuXjIeoZnz?= =?utf-8?q?iOQ9eo47flKJ4iD4dNjeNEjMvauGVEJgHu9c96brk5C4+m4jJKyF+eFRT5r2ZNjD9?= =?utf-8?q?TRSmNKHI41swchAjNF46RcAJjRjBp+TyIUw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5941.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(366013)(52116011)(7416011)(376011)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?hZz5/oIbX4Y6wlgXBVzp55wu1NDD?= =?utf-8?q?SDELHwOwemcoNk5c5peJhp88UJclnHJtf6ILMSJq2co2gDQJTh6MkU7TRKD4KvFsD?= =?utf-8?q?laU9v9LlxM+NIDpjpjiC3UMZTK0Xt+kXGOrcuB/iTrk2Q/CkZHprm+2pqPgXM85Zl?= =?utf-8?q?YiQEb9tkXS54RBaXsaEmyRoZlpJFw+2KINswWn5AiyJ5pcYZdd0H1oFH0CE/4ze5c?= =?utf-8?q?YXIIjPra0prTIgw3ShsiXO3JYSorg/z4cizZyvqa4Mw5s1izQzqjVeb2MvVt9WSGy?= =?utf-8?q?agX1+mojAC9oYwl9WvO8XDwqAX7NyQEttzx54kMDsSad9mUqZSAHeG8rTLNlvmFoR?= =?utf-8?q?kzFX20ePFrqTXEJ6T31TvAZQzfe/4tZOYVQ38j+RToomL8s5D34Uvg7D9nm2pzzK5?= =?utf-8?q?zfKVybx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Q2jgvU3Vff4sEFvA3y4mO0kegtydmiqsjnzL5pzgp1lK+EKBmiA1GHkoI+?= =?utf-8?q?iPTp90cy4CxtNehmhrgRB8R75ForVmrVAI+Hh8sbThIQFq8bBJvUIPa+sOQ35RHLs?= =?utf-8?q?i/dYZodjeuV3Oqeie664XcVcsjmyctAy4ePEmiZqH6h8fw3jKF2NHzCa/56ztxQgb?= =?utf-8?q?ejsMv1i9eWWNxRtmpmKzhuIHfT/dl36TGPChR7izyWfYxyZ75c1i/dnTyYyp6J1fX?= =?utf-8?q?NRICKnVkNjfZ?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e28bfc7-114a-4c27-ae9d-08dc91bf2fb3 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 06:55:50.6673 (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: Ij2s4Uq1Sj7fND8rw/rhQWlrNsZMGUKM5NEYKohiLuqFRo9nR+P6jwMNgllcdi11EYR2BmNC3VGOoR63gyTggw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10426 From: Peng Fan Add i.MX SCMI Extension protocols bindings for: - Battery Backed Module(BBM) Protocol This contains persistent storage (GPR), an RTC, and the ON/OFF button. The protocol can also provide access to similar functions implemented via external board components. - MISC Protocol. This includes controls that are misc settings/actions that must be exposed from the SM to agents. They are device specific and are usually define to access bit fields in various mix block control modules, IOMUX_GPR, and other GPR/CSR owned by the SM. Reviewed-by: "Rob Herring (Arm)" Signed-off-by: Peng Fan Reviewed-by: Cristian Marussi --- .../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 4d823f3b1f0e..47f0487e35de 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 @@ -284,7 +287,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 Jun 21 07:04:38 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: 13706917 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2088.outbound.protection.outlook.com [40.107.22.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71ACD16C688 for ; Fri, 21 Jun 2024 06:56:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.88 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952963; cv=fail; b=JTQ7EQbkasw4mbeYKaS7fkioKRtDrdp2cjwhkTpmlvoSHjcuBriYA0lwTkaHTko4V+/agTyLkGI4F+2kb0O7ZLV8V+VMEFp3YWfLWP/yeZCsMHYzsVH9jtOQ3WB9aKvXDGK0L9IVl6atbBxV/M8p+ySPzntWh/sTxNwfqVUOBw8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952963; c=relaxed/simple; bh=xR9UW4Jdz0yuYEI1aBoF4HryZ/pqGfpyfS/4R150Ms0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=jyxh00bQ2VU9uXlWKjgpV2Z0FdoED/BZf0kar3NB/LSD7uWdfAxWusx/9YKlC1y19m8E2wV+FfziyqImcZ0Li/51jwjk1oZUqYSAuDP6iNcFg+jeITE1aoH/XAHJFd6NsYDvij/02Dwv9YrnO/aKY0X6zEa6K/QdFBxQde6wgTs= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=UniJaokW; arc=fail smtp.client-ip=40.107.22.88 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="UniJaokW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dTVE9j7jQCTeuWuTkUx31QNKXDr+geqw6ldGCHszBZGIzJxRiKRtiSoic1YQv2zFJfeym+D+DZlq70e3pWComRUurGj3ByAHXPeJweAB5kFh25qeRpPx0itEmUvsaNV1Tgk8CIo9mnWZZ3hegDdzEFUGU2pLz19O+SyoXRDNcyT6uV9autFRjT+ece646aoUKCnb0S6iLF4r9wB3/ahpNjKTheCXIz2abZQqIZZoOI4Nt4Hs4uKuy7GHSmESkG9Wy+2IOuOzsd35+9nPIvfs0jmxiI+p4aGcaqXqgK7kmUJVAu/n8KfQ4naiqMakErguf7cy2NAWDNkqGnKsFW5oBA== 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=QAZe/XpfLU5x78InrIRx8wxQbwTt+69hCuXdxwFNfvE=; b=L1wL5Xe0L7vV5h80SZoiSuHHkjIu0UYP+FDynKEbJpqTXRkUXEqMvrmiaq+rvWYhIJ6xYeYOBSzlas0bLQq3r04MylU+egs6Ql0Ehgtl+2FXKaUWD74Xm9ayiDZWfWcpzpvNKAw55Bac2o8QjRvZnj4Jt6FZLUESJD7KoA3QWx2HLFx3Xh8IKpct4YkgtM6dGMclYaNPA8pOq6SGEFP7O5CIlXhjMHSySnjR5zGAxB2oPDcnTvQnRBZO8yecmhF9hFh3bZrREYKHCeN3B824vfzynCKk12CAAXqR6c+0gyXuDIVVh8dTMWIv9b3QEudtiEJ0j+5+4b1tq008U7uDqw== 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=QAZe/XpfLU5x78InrIRx8wxQbwTt+69hCuXdxwFNfvE=; b=UniJaokWFDKFbSYo4N5FU2wvKZUtMOq8Q96++NZluMoEP49CP5DAykaTvQxeHIiTL0NXv9y9GW6gNoVyT4/nQqRKEF2aR7jRRx9iFYnw4BK1KLESHDy7/+w++BJ+5hE+PH7asOoSiYkJNNroTHodJjoCznOXpvwfSqpOyIcjlgQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by GV1PR04MB10426.eurprd04.prod.outlook.com (2603:10a6:150:1cc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Fri, 21 Jun 2024 06:55:58 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.017; Fri, 21 Jun 2024 06:55:58 +0000 From: "Peng Fan (OSS)" Date: Fri, 21 Jun 2024 15:04:38 +0800 Subject: [PATCH v5 3/7] firmware: arm_scmi: add initial support for i.MX BBM protocol Message-Id: <20240621-imx95-bbm-misc-v2-v5-3-b85a6bf778cb@nxp.com> References: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@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 , Alexandre Belloni , Dmitry Torokhov 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, arm-scmi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718953487; l=13884; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=qf3BvGVUQfUDNPRd2U+n/wlDtywN4BIpyG9Mq65nrws=; b=apGCZPhiN53JTpgT+P0ea8VkUib3ZGs1/MDFvxRPwZFzc56zuBGpGfc3uEOJc26H+ook2OBsC BSe8I8sDFLqBtwVTzX2ytop69Tt7rmr5W5DeIlhW1wvfTDJvFMie9+3 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|GV1PR04MB10426:EE_ X-MS-Office365-Filtering-Correlation-Id: ec9fdc89-9fd5-41d1-06b9-08dc91bf33c6 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|52116011|7416011|376011|921017|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?dP8Z8hA8McA/6T0Etc0XxpdGGdOsLnH?= =?utf-8?q?j7whPfrvI2xn4cGPG7hfTQYCnbIhDdp5fJvfh6CcUCsVvu3K8kqFZ2EK4JBlvVB1D?= =?utf-8?q?nw5UA/yL/G3gE3B0Yof4S3VwAC4J9fAKVDRTSAH5ZOCnw7waJ/lO+B3tvz9/v8a5L?= =?utf-8?q?lfudwHHa+QqAX3uKtdcg/6KVZ7ibVWcBcnNSVPGS87HU73lD/GHiThFCBtgGdP//g?= =?utf-8?q?uDHgr9PYZu/nMc3xl2Biniom9O3ELHMtsEa6rkqMfFXoGJVjKqdt6T208nQVTRBY3?= =?utf-8?q?+rQYKPth9vYCQInOe14MbGmTMblpXj0If5zqOUPdpL6o5NWmTGdbsdel/GEYMISaD?= =?utf-8?q?SN5cSV6XKusChjF8dAhh/rD3DOcqdsEBoYWwlmALWc4qwOHrs/jigR468NVP4Rlku?= =?utf-8?q?8fDiRaIxl0xj6JXNhPn8GVdGhumFhjW4KMiK7ahcikKbwQBc0Lvx7eF9feNxCMc+v?= =?utf-8?q?zLsBI4/4GL/u5YQ0y6NSB3th5sjy0TwQj8Q2j7URfpnG0f4g+JK/s7XPXr21W5LUn?= =?utf-8?q?TK/lrTfTN9oCbcE45VBObXqijFtGlUgHnFHzY7L0ViVrc6MGD/TLH9yd7gq9eT9P6?= =?utf-8?q?jRsVGB3zLy4EK3kIQpIe0YZj48vUyKs7rHAZTbFVTqnAnCpZ7wJADroc42IjEkb5M?= =?utf-8?q?ghEJ2hKswvINKvQhnXGoSgMIDybiQm40bxzUIUhjkTMfpaaBP/9yb+gHt9ttdAz4c?= =?utf-8?q?+t/c3fkOwvFmHJkk/RDAxNG/lfzoM9DpXDKNsEtH0XcErbKFWgw/8Ayeyu3f1P0fW?= =?utf-8?q?HQDE+OPrtXAZY5UDbu5vAQrPSJ8SDA9J3ne3Ymslzeef3LfLpswwqCisKx/OsByYW?= =?utf-8?q?jG2WZA/f6h6d4k06T861q8a1illOuHRAZJbZa0HrJLqU7Y0YgecgORguIMiilitWn?= =?utf-8?q?9zV2tkafc2GA0LdGHh6YPh2duguQy+HTG+t/VaM1zaz2Z++sOB+q/uOs742VNuzbk?= =?utf-8?q?msobDfDQ1th5+zosEb/nVX1UUZ3qnICKGUulIy+Brvt29F5Iv3JKaO/LyZ9QBUv85?= =?utf-8?q?U1bG5igAHOkF5fDIopj2I+05EPlV+Go6QbUY9YnolBaTG1uWi7g6PfEsf1xLeeLWj?= =?utf-8?q?FQTWDqLLxcSMtuOd5Le4J7ahMkdQaIfehsq8iPOSrCrSTlhMTL/KhxF8sBHPXi2Je?= =?utf-8?q?Rx0PvnW2qW8cOeN/Kopf4GwaYgO0SUvVQeZTsR8xUqzMhHQAkQfBlciI6xr0ZWtja?= =?utf-8?q?SjwdjSKl8K9MXDJ7cjdN7gCpL6PBtzbjqr0mHxh64p9+AmYDDlPuFqjkBOabTNkzH?= =?utf-8?q?8ElCuKacvzaOT/oXtj0JbsTxkWINhy6U06ccKK1iir6fi8Zqi6I3g98etH2R7vZXC?= =?utf-8?q?Gm9lQ9PJXNUF?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5941.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(366013)(52116011)(7416011)(376011)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Ce2CBxwbE8W7t+IYUpvwSbEE2HBu?= =?utf-8?q?kpLwOO6N+Tf1aY++MzqoIKDU7tTKMv5QIU3eYuaFhS7W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/IN?= =?utf-8?q?ZfE/sFm2v33hTosHUbX0pHqwZOsnQWv/p6L1gBTiJ+w8zWvIPuRX6MTju4vOcgvHM?= =?utf-8?q?gLJDuDZdJxPCW8bdtpBqF6lG3dkFkB32mzHnvUa5aWQQnGX9HNEjGC4jc1GvizmUP?= =?utf-8?q?ofSKGu20M05PD3kuOYdEUji9SfeEKMCawVLbBar0VKWAgP9Ue3ScI9KoKs/KqDxaJ?= =?utf-8?q?Xt0WVifhwlKs/sBhuybXw5Oun/d9EiX0w2ZQY0lSpcXN/cR7tLVOS5Xx+4E7njrxi?= =?utf-8?q?vJQ7m8DUK4KUPAeoUOD7NCTZ6GOZDAOqMX6kb6OFB5rLHU24+zo/CBbzmS3J5+DX/?= =?utf-8?q?t2TImBcecitcZJZ+2es/pUeKeRH1JchBXqfP0J/e2U8VlhDrBzZuTj4IaCIccmvsY?= =?utf-8?q?jjucL8dEX2kS7WvitW9RQ9NWxRNYGnnCtaeU6XFv+dJ1f0zhsC492NA3sbAW+Q7N1?= =?utf-8?q?vtvRKOR+vKmTH1KgCa9JPrd1jBYAo4vc6Y9O6/Jg2GJGGSzY0lVEINSgjKqlC6Lyw?= =?utf-8?q?C+4h/WmLIH1MombsZNdNf1R52KZnal1KEgfsnO6UUqOZi1y9063lui4H+J/CYkvTC?= =?utf-8?q?5s0evQku2PaJ?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec9fdc89-9fd5-41d1-06b9-08dc91bf33c6 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 06:55:58.0997 (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: J4uqN5bj6nKMiormAF8k73VDuclKo1wu7XiINyI3v4LmK4at7QSo2cCW3Hs3UXH7uRYMzGqvyt6+KyoJzD90tg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10426 From: Peng Fan i.MX95 has a battery-backed module(BBM), which has persistent storage (GPR), an RTC, and the ON/OFF button. The System Manager(SM) firmware use SCMI vendor protocol(SCMI BBM) to let agent be able to use GPR, RTC and ON/OFF button. Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/Kconfig | 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 | 379 +++++++++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 42 ++++ 6 files changed, 440 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..559ad9f7088c --- /dev/null +++ b/drivers/firmware/arm_scmi/imx/imx-sm-bbm.c @@ -0,0 +1,379 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System Control and Management Interface (SCMI) NXP BBM Protocol + * + * Copyright 2024 NXP + */ + +#define pr_fmt(fmt) "SCMI Notifications BBM - " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "../protocols.h" +#include "../notify.h" + +#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x10000 + +enum scmi_imx_bbm_protocol_cmd { + IMX_BBM_GPR_SET = 0x3, + IMX_BBM_GPR_GET = 0x4, + IMX_BBM_RTC_ATTRIBUTES = 0x5, + IMX_BBM_RTC_TIME_SET = 0x6, + IMX_BBM_RTC_TIME_GET = 0x7, + IMX_BBM_RTC_ALARM_SET = 0x8, + IMX_BBM_BUTTON_GET = 0x9, + IMX_BBM_RTC_NOTIFY = 0xA, + IMX_BBM_BUTTON_NOTIFY = 0xB, +}; + +#define GET_RTCS_NR(x) le32_get_bits((x), GENMASK(23, 16)) +#define GET_GPRS_NR(x) le32_get_bits((x), GENMASK(15, 0)) + +#define SCMI_IMX_BBM_NOTIFY_RTC_UPDATED BIT(2) +#define SCMI_IMX_BBM_NOTIFY_RTC_ROLLOVER BIT(1) +#define SCMI_IMX_BBM_NOTIFY_RTC_ALARM BIT(0) + +#define SCMI_IMX_BBM_RTC_ALARM_ENABLE_FLAG BIT(0) + +#define SCMI_IMX_BBM_NOTIFY_RTC_FLAG \ + (SCMI_IMX_BBM_NOTIFY_RTC_UPDATED | SCMI_IMX_BBM_NOTIFY_RTC_ROLLOVER | \ + SCMI_IMX_BBM_NOTIFY_RTC_ALARM) + +#define SCMI_IMX_BBM_EVENT_RTC_MASK GENMASK(31, 24) + +struct scmi_imx_bbm_info { + u32 version; + int nr_rtc; + int nr_gpr; +}; + +struct scmi_msg_imx_bbm_protocol_attributes { + __le32 attributes; +}; + +struct scmi_imx_bbm_set_time { + __le32 id; + __le32 flags; + __le32 value_low; + __le32 value_high; +}; + +struct scmi_imx_bbm_get_time { + __le32 id; + __le32 flags; +}; + +struct scmi_imx_bbm_alarm_time { + __le32 id; + __le32 flags; + __le32 value_low; + __le32 value_high; +}; + +struct scmi_msg_imx_bbm_rtc_notify { + __le32 rtc_id; + __le32 flags; +}; + +struct scmi_msg_imx_bbm_button_notify { + __le32 flags; +}; + +struct scmi_imx_bbm_notify_payld { + __le32 flags; +}; + +static int scmi_imx_bbm_attributes_get(const struct scmi_protocol_handle *ph, + struct scmi_imx_bbm_info *pi) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_imx_bbm_protocol_attributes *attr; + + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, sizeof(*attr), &t); + if (ret) + return ret; + + attr = t->rx.buf; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + pi->nr_rtc = GET_RTCS_NR(attr->attributes); + pi->nr_gpr = GET_GPRS_NR(attr->attributes); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_notify(const struct scmi_protocol_handle *ph, + u32 src_id, int message_id, bool enable) +{ + int ret; + struct scmi_xfer *t; + + if (message_id == IMX_BBM_RTC_NOTIFY) { + struct scmi_msg_imx_bbm_rtc_notify *rtc_notify; + + ret = ph->xops->xfer_get_init(ph, message_id, + sizeof(*rtc_notify), 0, &t); + if (ret) + return ret; + + rtc_notify = t->tx.buf; + rtc_notify->rtc_id = cpu_to_le32(0); + rtc_notify->flags = + cpu_to_le32(enable ? SCMI_IMX_BBM_NOTIFY_RTC_FLAG : 0); + } else if (message_id == IMX_BBM_BUTTON_NOTIFY) { + struct scmi_msg_imx_bbm_button_notify *button_notify; + + ret = ph->xops->xfer_get_init(ph, message_id, + sizeof(*button_notify), 0, &t); + if (ret) + return ret; + + button_notify = t->tx.buf; + button_notify->flags = cpu_to_le32(enable ? 1 : 0); + } else { + return -EINVAL; + } + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + return ret; +} + +static enum scmi_imx_bbm_protocol_cmd evt_2_cmd[] = { + IMX_BBM_RTC_NOTIFY, + IMX_BBM_BUTTON_NOTIFY +}; + +static int scmi_imx_bbm_set_notify_enabled(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id, bool enable) +{ + int ret, cmd_id; + + if (evt_id >= ARRAY_SIZE(evt_2_cmd)) + return -EINVAL; + + cmd_id = evt_2_cmd[evt_id]; + ret = scmi_imx_bbm_notify(ph, src_id, cmd_id, enable); + if (ret) + pr_debug("FAIL_ENABLED - evt[%X] dom[%d] - ret:%d\n", + evt_id, src_id, ret); + + return ret; +} + +static void *scmi_imx_bbm_fill_custom_report(const struct scmi_protocol_handle *ph, + u8 evt_id, ktime_t timestamp, + const void *payld, size_t payld_sz, + void *report, u32 *src_id) +{ + const struct scmi_imx_bbm_notify_payld *p = payld; + struct scmi_imx_bbm_notif_report *r = report; + + if (sizeof(*p) != payld_sz) + return NULL; + + if (evt_id == SCMI_EVENT_IMX_BBM_RTC) { + r->is_rtc = true; + r->is_button = false; + r->timestamp = timestamp; + r->rtc_id = le32_get_bits(p->flags, SCMI_IMX_BBM_EVENT_RTC_MASK); + r->rtc_evt = le32_get_bits(p->flags, SCMI_IMX_BBM_NOTIFY_RTC_FLAG); + dev_dbg(ph->dev, "RTC: %d evt: %x\n", r->rtc_id, r->rtc_evt); + *src_id = r->rtc_evt; + } else if (evt_id == SCMI_EVENT_IMX_BBM_BUTTON) { + r->is_rtc = false; + r->is_button = true; + r->timestamp = timestamp; + dev_dbg(ph->dev, "BBM Button\n"); + *src_id = 0; + } else { + WARN_ON_ONCE(1); + return NULL; + } + + return r; +} + +static const struct scmi_event scmi_imx_bbm_events[] = { + { + .id = SCMI_EVENT_IMX_BBM_RTC, + .max_payld_sz = sizeof(struct scmi_imx_bbm_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_bbm_notif_report), + }, + { + .id = SCMI_EVENT_IMX_BBM_BUTTON, + .max_payld_sz = sizeof(struct scmi_imx_bbm_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_bbm_notif_report), + }, +}; + +static const struct scmi_event_ops scmi_imx_bbm_event_ops = { + .set_notify_enabled = scmi_imx_bbm_set_notify_enabled, + .fill_custom_report = scmi_imx_bbm_fill_custom_report, +}; + +static const struct scmi_protocol_events scmi_imx_bbm_protocol_events = { + .queue_sz = SCMI_PROTO_QUEUE_SZ, + .ops = &scmi_imx_bbm_event_ops, + .evts = scmi_imx_bbm_events, + .num_events = ARRAY_SIZE(scmi_imx_bbm_events), + .num_sources = 1, +}; + +static int scmi_imx_bbm_rtc_time_set(const struct scmi_protocol_handle *ph, + u32 rtc_id, u64 sec) +{ + struct scmi_imx_bbm_info *pi = ph->get_priv(ph); + struct scmi_imx_bbm_set_time *cfg; + struct scmi_xfer *t; + int ret; + + if (rtc_id >= pi->nr_rtc) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, IMX_BBM_RTC_TIME_SET, sizeof(*cfg), 0, &t); + if (ret) + return ret; + + cfg = t->tx.buf; + cfg->id = cpu_to_le32(rtc_id); + cfg->flags = 0; + cfg->value_low = cpu_to_le32(lower_32_bits(sec)); + cfg->value_high = cpu_to_le32(upper_32_bits(sec)); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_rtc_time_get(const struct scmi_protocol_handle *ph, + u32 rtc_id, u64 *value) +{ + struct scmi_imx_bbm_info *pi = ph->get_priv(ph); + struct scmi_imx_bbm_get_time *cfg; + struct scmi_xfer *t; + int ret; + + if (rtc_id >= pi->nr_rtc) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, IMX_BBM_RTC_TIME_GET, sizeof(*cfg), + sizeof(u64), &t); + if (ret) + return ret; + + cfg = t->tx.buf; + cfg->id = cpu_to_le32(rtc_id); + cfg->flags = 0; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) + *value = get_unaligned_le64(t->rx.buf); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_rtc_alarm_set(const struct scmi_protocol_handle *ph, + u32 rtc_id, 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 int scmi_imx_bbm_protocol_init(const struct scmi_protocol_handle *ph) +{ + u32 version; + int ret; + struct scmi_imx_bbm_info *binfo; + + ret = ph->xops->version_get(ph, &version); + if (ret) + return ret; + + dev_info(ph->dev, "NXP SM BBM Version %d.%d\n", + PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); + + binfo = devm_kzalloc(ph->dev, sizeof(*binfo), GFP_KERNEL); + if (!binfo) + return -ENOMEM; + + ret = scmi_imx_bbm_attributes_get(ph, binfo); + if (ret) + return ret; + + return ph->set_priv(ph, binfo, version); +} + +static const struct scmi_protocol scmi_imx_bbm = { + .id = SCMI_PROTOCOL_IMX_BBM, + .owner = THIS_MODULE, + .instance_init = &scmi_imx_bbm_protocol_init, + .ops = &scmi_imx_bbm_proto_ops, + .events = &scmi_imx_bbm_protocol_events, + .supported_version = SCMI_PROTOCOL_SUPPORTED_VERSION, + .vendor_id = "NXP", + .sub_vendor_id = "IMX", +}; +module_scmi_protocol(scmi_imx_bbm); diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h new file mode 100644 index 000000000000..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 Jun 21 07:04:39 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: 13706918 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2072.outbound.protection.outlook.com [40.107.22.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08DD816C6B2 for ; Fri, 21 Jun 2024 06:56:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952970; cv=fail; b=T5JCk/Mo5dOLBtRalF6Jm6RfHKZU9cD4OPe7+E/n0CHWak1bA/sIBf/76zMNoct5p628ROxoqxkrs8u3vtjapSAnfI5zhUCLf11+p1/oMuru4ObzLYCAFlJT6/wF1pm2nofj76C8dZZ++iOo2iLUU45DQnvxMTI5QrWerkDhcM4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952970; c=relaxed/simple; bh=6va5vkFBCgl5PL/a5ZQoCqeFFLZsb6k2yDH9hHDBRyY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=CiBWO5Y94uXqLriOSxlezfZAV5r7s8/ZfywF8uL+1YI65ivFgseaTBZuXm2b1isQ2Tq1pCjv6kWDgCRQKqTxSehcmCXQ0a4KtTwrKdhOFNM+bcIOSSz3y9Snz4UmTGuN+a7R72B9Q8+C9wS1DyDytiFEA/uQiv5KN01v0PSoIVQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=cG6m1w3+; arc=fail smtp.client-ip=40.107.22.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="cG6m1w3+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nb8Pwb7pjb/swvRNiMSCMoKVSBqKXqcmq7Xt6f5dfKAs/Ujn5a9DktmDLR9WlgIsAZm6PfjJ6CWp5ajYuUDeo3bzGMWYcJAM1NJy3H3duvhnxLRhI2bwgquNiRorp+cY2CjDbyPXHXxh9zP5/5kuHXVTyvawNajCbLg2vlielkxKXlDI3Evu8hRbkRPjGQayXRjb8FBhwcVw3FgSEEZPxtKYzqQwM+W5N3KzDXRLA2hXBh96Q14ami75/V88P+zVuWk81p02eWQzVEziJx1dldC23t+9qQxHwOC/vD57E35lFkc32bb4V48IceVKOCevz4TvGz/pW0H8QCfACgR7/Q== 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=b6D2tsyHnxa1BpBzxQCLu8hcG+zpSWBn6jX61FKApko=; b=RD0m5OvJfro4sTzQDs/gYRZwQ/6mVzwmWeBhJFFipwh4y9TFKCee29lrPBY8T+IZWmMbxuhB3GqNNljtsvleaMDoNw8WdQ3TYE7eqm8qSmrNhC2se5eq0ML/VBL2Ko8EFTo7iVY45oTjMsF0ddXTYrLsmbjjf4aALnN0fP6j6AfgiK51wcJ89GkHs1zHg+AgEYvSSZio7b0pvQOIeTrA+mgn2+wiudwIT/73qkKgr4+fWst6fBjOA5NYuWyF5Q0zCLqXttKGiMEWliEjrBtHHP5iH8FsclxmTbJ9LTmn0bmcCZYIiAcVDWU0FwnpCRLzWD6U6Zn+taI4GojRoXjWnA== 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=b6D2tsyHnxa1BpBzxQCLu8hcG+zpSWBn6jX61FKApko=; b=cG6m1w3+8NOZ1y01enwYEamSqA3d9LL62RLIwGHxKFfJlMX4PRVlx4EQpGmjv2O+2nYuzk45vOfcDRCTT31EmHniJonLG9HWqg20Ftes3SGT+KOXL77SMkCUvbphF8QnrUsflRhKe6ODmDysfmWFUP5Ka+3pN21DKjapAze1D4c= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by GV1PR04MB10426.eurprd04.prod.outlook.com (2603:10a6:150:1cc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Fri, 21 Jun 2024 06:56:05 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.017; Fri, 21 Jun 2024 06:56:05 +0000 From: "Peng Fan (OSS)" Date: Fri, 21 Jun 2024 15:04:39 +0800 Subject: [PATCH v5 4/7] firmware: arm_scmi: add initial support for i.MX MISC protocol Message-Id: <20240621-imx95-bbm-misc-v2-v5-4-b85a6bf778cb@nxp.com> References: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@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 , Alexandre Belloni , Dmitry Torokhov 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, arm-scmi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718953487; l=11404; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=TUMkdIZMCjh7xQDIbhQnprsPSDQiIPMHfHmaWUsZEbE=; b=55Whg98PqDfS9bPemuxyJXZ+gJ0B4aCE3IDPPuQY5MxfAnNNA8jrmniQ0u6vZi9iuVlgrDPWg 4y7zzwN2lZ1BdlsekonmpjTkE6bb+sc/LPMBlP0+YVTP6/7domIZXL8 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|GV1PR04MB10426:EE_ X-MS-Office365-Filtering-Correlation-Id: 56570eb3-d838-4b48-0dac-08dc91bf3824 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|52116011|7416011|376011|921017|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?JK/mg2NoUjaeBeRzgT8gFbriR4tliO4?= =?utf-8?q?hHEDMtezz/Uafj2WhFqH/HYZ/UPDhOZfmy0tIAvDE6ouq/gPjG4WOCHNt+6vnaBb9?= =?utf-8?q?iqqq9D4hKlwCTYDCpxZGeeTrXVBOicP/GOw7dRuf9xcnNbdusRNMcHoz05wFN8YN3?= =?utf-8?q?Hl4+xGKYjYF8QChDJD0AcpjijKkIpxp3AxvrZqbfOLHLPBydwqxb2sm/81d3xF8D9?= =?utf-8?q?jVQVzw2EFAG7hX9tBlSdvJUMitLht59Meue7G8udFCxOLCJ4Vde6W4PvkEHD0amF5?= =?utf-8?q?iVYNhnlrpbQ8Po3AIuqSAgOcww8kHA4hqHboIbZygyw5wAeUbA8Z8h23sdL+pMCgi?= =?utf-8?q?59ee9TczjL6Mspabno9KPDbgoCRxGtyoCAZpJEQr5qYiT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LZ?= =?utf-8?q?zwoefHXtYQdNfoM+P/v/yFqO9TDM+R2TrGThg7AqnK85LkLeQybVeYmStV40PheSy?= =?utf-8?q?m5n19uR+FW6t?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5941.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(366013)(52116011)(7416011)(376011)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?IidMC8j47CWrQtMC5VfQSpS7vWqN?= =?utf-8?q?Hbl/+R2audZ9eIoM/DoRTf56ASHMxV1z3vkQ9hHKPIo8c5KtovGEvkhy9ShMidJzG?= =?utf-8?q?1Vtw/7w1MhSM+GVAv1UNdugOHlaFe/Hqxg7In6vMso98hgvH6ow++UCliVCZ06z8q?= =?utf-8?q?CwNhDrHexw4mT6nfeUFKY7rd+wjV9/017x3OcA7lgwoS29tChMelz9QjU5m7uOCy6?= =?utf-8?q?uakakAOvnobyo1LXaaI29/aegl7faDJHM+Q7ZTmJOSnq/SIGD7lUMLeVOFNrRRDbn?= =?utf-8?q?8dEtZ1mlGJ1lVQ93ML2KYIfxR7F3m+diRDaX3HjtSsalL/8Y0Wt0zeupWVIYN7k9g?= =?utf-8?q?wKpzHTW3YtbqkzrlOhOi4BqSiLo7TMd8tETmdtISbb/FzIh2PFXYKSE9aj8xU9ETP?= =?utf-8?q?HEOu23LBNoCxjATr305088Fkbjo3RkLvzpR7Hj2XunmJhE8f32ioMr/yLpkBZyQXl?= =?utf-8?q?NiAjpLSLWquo1dtVM6VHOUtKOUMDLawCJYvKJvtW5dnzlJlNn6BKEg0ZR2G87RKMT?= =?utf-8?q?7n+65ofiI4IYX6GoIUp5XxL3JGI9/U72lPuU87t7CdiBzB6bdEvE3M5U2AMq6ouqN?= =?utf-8?q?v20LC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jYkSLTZyEYfWsx5dJJ3eLFBOv7G2D9h+yf2PNP+6qtEJxZn6JMcji?= =?utf-8?q?IXeAevRN4DEB?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56570eb3-d838-4b48-0dac-08dc91bf3824 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 06:56:04.9892 (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: 2MsZ0g1jhd2EwuHTZtzScdfSD8ZcPBZTmlvP6/I4kKsjE7sLrpXa0SG0T7FpXSgUrV6ppvxoccCnivmW/0sEQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10426 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 Reviewed-by: Cristian Marussi --- drivers/firmware/arm_scmi/imx/Kconfig | 9 + drivers/firmware/arm_scmi/imx/Makefile | 1 + drivers/firmware/arm_scmi/imx/imx-sm-misc.c | 315 ++++++++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 17 ++ 4 files changed, 342 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..ca79d86d542c --- /dev/null +++ b/drivers/firmware/arm_scmi/imx/imx-sm-misc.c @@ -0,0 +1,315 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System control and Management Interface (SCMI) NXP MISC Protocol + * + * Copyright 2024 NXP + */ + +#define pr_fmt(fmt) "SCMI Notifications MISC - " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "../protocols.h" +#include "../notify.h" + +#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x10000 + +#define MAX_MISC_CTRL_SOURCES GENMASK(15, 0) + +enum scmi_imx_misc_protocol_cmd { + SCMI_IMX_MISC_CTRL_SET = 0x3, + SCMI_IMX_MISC_CTRL_GET = 0x4, + SCMI_IMX_MISC_CTRL_NOTIFY = 0x8, +}; + +struct scmi_imx_misc_info { + u32 version; + u32 nr_dev_ctrl; + u32 nr_brd_ctrl; + u32 nr_reason; +}; + +struct scmi_msg_imx_misc_protocol_attributes { + __le32 attributes; +}; + +#define GET_BRD_CTRLS_NR(x) le32_get_bits((x), GENMASK(31, 24)) +#define GET_REASONS_NR(x) le32_get_bits((x), GENMASK(23, 16)) +#define GET_DEV_CTRLS_NR(x) le32_get_bits((x), GENMASK(15, 0)) +#define BRD_CTRL_START_ID BIT(15) + +struct scmi_imx_misc_ctrl_set_in { + __le32 id; + __le32 num; + __le32 value[]; +}; + +struct scmi_imx_misc_ctrl_notify_in { + __le32 ctrl_id; + __le32 flags; +}; + +struct scmi_imx_misc_ctrl_notify_payld { + __le32 ctrl_id; + __le32 flags; +}; + +struct scmi_imx_misc_ctrl_get_out { + __le32 num; + __le32 val[]; +}; + +static int scmi_imx_misc_attributes_get(const struct scmi_protocol_handle *ph, + struct scmi_imx_misc_info *mi) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_imx_misc_protocol_attributes *attr; + + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, + sizeof(*attr), &t); + if (ret) + return ret; + + attr = t->rx.buf; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + mi->nr_dev_ctrl = GET_DEV_CTRLS_NR(attr->attributes); + mi->nr_brd_ctrl = GET_BRD_CTRLS_NR(attr->attributes); + mi->nr_reason = GET_REASONS_NR(attr->attributes); + dev_info(ph->dev, "i.MX MISC NUM DEV CTRL: %d, NUM BRD CTRL: %d,NUM Reason: %d\n", + mi->nr_dev_ctrl, mi->nr_brd_ctrl, mi->nr_reason); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_misc_ctrl_validate_id(const struct scmi_protocol_handle *ph, + u32 ctrl_id) +{ + struct scmi_imx_misc_info *mi = ph->get_priv(ph); + + /* + * [0, BRD_CTRL_START_ID) is for Dev Ctrl which is SOC related + * [BRD_CTRL_START_ID, 0xffff) is for Board Ctrl which is board related + */ + if ((ctrl_id < BRD_CTRL_START_ID) && (ctrl_id > mi->nr_dev_ctrl)) + return -EINVAL; + if (ctrl_id >= BRD_CTRL_START_ID + mi->nr_brd_ctrl) + return -EINVAL; + + return 0; +} + +static int scmi_imx_misc_ctrl_notify(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 evt_id, u32 flags) +{ + struct scmi_imx_misc_ctrl_notify_in *in; + struct scmi_xfer *t; + int ret; + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_NOTIFY, + sizeof(*in), 0, &t); + if (ret) + return ret; + + in = t->tx.buf; + in->ctrl_id = cpu_to_le32(ctrl_id); + in->flags = cpu_to_le32(flags); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int +scmi_imx_misc_ctrl_set_notify_enabled(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id, bool enable) +{ + int ret; + + /* misc_ctrl_req_notify is for enablement */ + if (enable) + return 0; + + ret = scmi_imx_misc_ctrl_notify(ph, src_id, evt_id, 0); + if (ret) + dev_err(ph->dev, "FAIL_ENABLED - evt[%X] src[%d] - ret:%d\n", + evt_id, src_id, ret); + + return ret; +} + +static void * +scmi_imx_misc_ctrl_fill_custom_report(const struct scmi_protocol_handle *ph, + u8 evt_id, ktime_t timestamp, + const void *payld, size_t payld_sz, + void *report, u32 *src_id) +{ + const struct scmi_imx_misc_ctrl_notify_payld *p = payld; + struct scmi_imx_misc_ctrl_notify_report *r = report; + + if (sizeof(*p) != payld_sz) + return NULL; + + r->timestamp = timestamp; + r->ctrl_id = p->ctrl_id; + r->flags = p->flags; + if (src_id) + *src_id = r->ctrl_id; + dev_dbg(ph->dev, "%s: ctrl_id: %d flags: %d\n", __func__, + r->ctrl_id, r->flags); + + return r; +} + +static const struct scmi_event_ops scmi_imx_misc_event_ops = { + .set_notify_enabled = scmi_imx_misc_ctrl_set_notify_enabled, + .fill_custom_report = scmi_imx_misc_ctrl_fill_custom_report, +}; + +static const struct scmi_event scmi_imx_misc_events[] = { + { + .id = SCMI_EVENT_IMX_MISC_CONTROL, + .max_payld_sz = sizeof(struct scmi_imx_misc_ctrl_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_misc_ctrl_notify_report), + }, +}; + +static struct scmi_protocol_events scmi_imx_misc_protocol_events = { + .queue_sz = SCMI_PROTO_QUEUE_SZ, + .ops = &scmi_imx_misc_event_ops, + .evts = scmi_imx_misc_events, + .num_events = ARRAY_SIZE(scmi_imx_misc_events), + .num_sources = MAX_MISC_CTRL_SOURCES, +}; + +static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 *num, u32 *val) +{ + struct scmi_imx_misc_ctrl_get_out *out; + struct scmi_xfer *t; + int ret, i; + int max_msg_size = ph->hops->get_max_msg_size(ph); + int max_num = (max_msg_size - sizeof(*out)) / sizeof(__le32); + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_GET, sizeof(u32), + 0, &t); + if (ret) + return ret; + + put_unaligned_le32(ctrl_id, t->tx.buf); + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + out = t->rx.buf; + *num = le32_to_cpu(out->num); + + if (*num >= max_num || + *num * sizeof(__le32) > t->rx.len - sizeof(__le32)) { + ph->xops->xfer_put(ph, t); + return -EINVAL; + } + + for (i = 0; i < *num; i++) + val[i] = le32_to_cpu(out->val[i]); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_misc_ctrl_set(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 num, u32 *val) +{ + struct scmi_imx_misc_ctrl_set_in *in; + struct scmi_xfer *t; + int ret, i; + int max_msg_size = ph->hops->get_max_msg_size(ph); + int max_num = (max_msg_size - sizeof(*in)) / sizeof(__le32); + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + if (num > max_num) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_SET, sizeof(*in), + 0, &t); + if (ret) + return ret; + + in = t->tx.buf; + in->id = cpu_to_le32(ctrl_id); + in->num = cpu_to_le32(num); + for (i = 0; i < num; i++) + in->value[i] = cpu_to_le32(val[i]); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static const struct scmi_imx_misc_proto_ops scmi_imx_misc_proto_ops = { + .misc_ctrl_set = scmi_imx_misc_ctrl_set, + .misc_ctrl_get = scmi_imx_misc_ctrl_get, + .misc_ctrl_req_notify = scmi_imx_misc_ctrl_notify, +}; + +static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph) +{ + struct scmi_imx_misc_info *minfo; + u32 version; + int ret; + + ret = ph->xops->version_get(ph, &version); + if (ret) + return ret; + + dev_info(ph->dev, "NXP SM MISC Version %d.%d\n", + PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); + + minfo = devm_kzalloc(ph->dev, sizeof(*minfo), GFP_KERNEL); + if (!minfo) + return -ENOMEM; + + ret = scmi_imx_misc_attributes_get(ph, minfo); + if (ret) + return ret; + + return ph->set_priv(ph, minfo, version); +} + +static const struct scmi_protocol scmi_imx_misc = { + .id = SCMI_PROTOCOL_IMX_MISC, + .owner = THIS_MODULE, + .instance_init = &scmi_imx_misc_protocol_init, + .ops = &scmi_imx_misc_proto_ops, + .events = &scmi_imx_misc_protocol_events, + .supported_version = SCMI_PROTOCOL_SUPPORTED_VERSION, + .vendor_id = "NXP", + .sub_vendor_id = "IMX", +}; +module_scmi_protocol(scmi_imx_misc); diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h index e59aedaa4aec..321064514778 100644 --- a/include/linux/scmi_imx_protocol.h +++ b/include/linux/scmi_imx_protocol.h @@ -15,6 +15,7 @@ enum scmi_nxp_protocol { SCMI_PROTOCOL_IMX_BBM = 0x81, + SCMI_PROTOCOL_IMX_MISC = 0x84, }; struct scmi_imx_bbm_proto_ops { @@ -30,6 +31,7 @@ struct scmi_imx_bbm_proto_ops { enum scmi_nxp_notification_events { SCMI_EVENT_IMX_BBM_RTC = 0x0, SCMI_EVENT_IMX_BBM_BUTTON = 0x1, + SCMI_EVENT_IMX_MISC_CONTROL = 0x0, }; struct scmi_imx_bbm_notif_report { @@ -39,4 +41,19 @@ struct scmi_imx_bbm_notif_report { unsigned int rtc_id; unsigned int rtc_evt; }; + +struct scmi_imx_misc_ctrl_notify_report { + ktime_t timestamp; + unsigned int ctrl_id; + unsigned int flags; +}; + +struct scmi_imx_misc_proto_ops { + int (*misc_ctrl_set)(const struct scmi_protocol_handle *ph, u32 id, + u32 num, u32 *val); + int (*misc_ctrl_get)(const struct scmi_protocol_handle *ph, u32 id, + u32 *num, u32 *val); + int (*misc_ctrl_req_notify)(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 evt_id, u32 flags); +}; #endif From patchwork Fri Jun 21 07:04:40 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: 13706919 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2051.outbound.protection.outlook.com [40.107.22.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66BB316B72E for ; Fri, 21 Jun 2024 06:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952977; cv=fail; b=WaCH3ni0LtceXxy33hZfrWPH0nQ3xcmjKPOsyZc7FZ2Yu9Hwpn/4krkngqiZZzCVYrr6QgInBtqiBmGdwJjsUe+ln0Q7Mn/XAEEchnnSJeKfrfHmf2YsA6zf9ifllfA0xq3Z+nuF3kqrb0c3Ou7pITbuUWvq6x4S48aTDSjRYSQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952977; c=relaxed/simple; bh=znwwOZYcZ/cOQiRbIjSJ/wWzMCcmPndge6mLJ8jCWiQ=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=CZ7VJf5wFi5zeXztirQ/h5RbJtoCGvIHwXCHXKoUjTW0gEzY0ZWOZC3HqTspeX2nsxp07jvc0MybRK0fE0QFxtzqVv0pciEUf1o+4VNZEyiCkPHBfbWL+M1xGL78D+whs5//9BVRFN+nHiqjAgLUj5oArFUAal0HrtIsLNUMmKk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=R9t8s0Uu; arc=fail smtp.client-ip=40.107.22.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="R9t8s0Uu" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P/vPhHHiC7Xi6JRXjisKdhkhg1WAcjV8kq5CfirTgRg9aE8GLE/P6J2lunzsrF+6EvsPtfCpmELp9jFWkNubcdCRELZGeGHTU2ZvLEV8wbM6bxi16xoiYm53N9oXadaF8yylvTbHk6KwxFR4e9cvjCKyJHGX+LY76qlfbnOUrxTzbROzulzqv4IHvuAaVwSTENa0Qx/xWFdnHbD2XMS8iKlp9At7Rz6C8Aimt4oa86hTj86vCReRaQr9w0zf+vm7gkSky2S+p6LvisgqM/yeSDdFjPCclTcH53kyghY3l9bwgUEoGHsD6eo5ceDrqr9FicufGXARUrqgawGh74SOqQ== 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=7LVaQmxewtWgDieWlVI4F6SboEGpS/btxQN0knD2YWM=; b=Jo8sq/SnrBBw2qd5j1b7ZUNobA9ae0HrRd9pEjPO/X10HBZH1C4mayZktNf0RjDJQgIvfbeciMC7YYPKW7hgIB0b7kc7ZTAGO/nChmHZrdwC7wYdHAaBNSvbMR40wWl4Pg0rOMMzKP3pLm6/QtkrQC/sE8OzFMRJvvPI4NViaFUXhko1Le3qWS9s4LtxV1kCu/QGvbw2Eh3Zz0OuIBjwhO+jzr3ILJpA1t5fRiqST4T8DNIln1x8WMUOG46h5lhcTjWMFXDHa3jlR28eIiyqrjnEmzPKM/JH/+Q1te/B1VSyo2RjuFrbtDGVE1YLpAIASWsoGgFjzUTbTk+W9BARuw== 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=7LVaQmxewtWgDieWlVI4F6SboEGpS/btxQN0knD2YWM=; b=R9t8s0Uu/QrFyhQmeWs05Pnf7WYkvgZxC5jlOmzv2gx0hZiBGiKuxEpXX+UaVjCCZeQlltNbu89JMiW6YYqdK1XYRIxw/Bpvrv8xgxY8jvWpqJ8HJg+QVWMkZBrATVpLoN6o4SJAGeD9dfUXBk0q8iN2mmd1LuDrGi5DDl5QPBg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by GV1PR04MB10426.eurprd04.prod.outlook.com (2603:10a6:150:1cc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Fri, 21 Jun 2024 06:56:12 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.017; Fri, 21 Jun 2024 06:56:12 +0000 From: "Peng Fan (OSS)" Date: Fri, 21 Jun 2024 15:04:40 +0800 Subject: [PATCH v5 5/7] firmware: imx: add i.MX95 MISC driver Message-Id: <20240621-imx95-bbm-misc-v2-v5-5-b85a6bf778cb@nxp.com> References: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@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 , Alexandre Belloni , Dmitry Torokhov 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, arm-scmi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718953487; l=6433; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=6mJryA2gjuHsLRyd9bfAMdNInUOb690lV8nR15s/uP4=; b=HVOZ0M8O0QK/VT0rwIgpBNRRnE0B9sW7iPNmUNYOQTEdL4mZm93qBOKNC9gs+nnxVOxTYJqPJ tDYyzIuTPblBuZi/ZkizIxInPuhc5Ug0dojz8M4dy3pPhpOaSdp3Ad4 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|GV1PR04MB10426:EE_ X-MS-Office365-Filtering-Correlation-Id: f217f2de-d50a-46e6-06b5-08dc91bf3c75 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|52116011|7416011|376011|921017|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?k7b/YlhTgXVJfbd2LRyDyvylgb+gfd8?= =?utf-8?q?TlCvZgsuRk+obxMOpWXGnZ3+cge12mHxXhU6MWFSoN9PWoJiPsA/0JOIZCXgNSwrz?= =?utf-8?q?8K/zd3FVUp3854Lyh3T/VmO6nQLh+8VtD3XIkb9EUFuT8YUVp9zc8GA2T+r96fCAk?= =?utf-8?q?MShE0JTTrO2ZuXwVfgnXm1KODoZ316LDo1QRQJTk5EabsqTnf6jRF7+Ti6UuF1OIB?= =?utf-8?q?Q6I7tAOqoK332JZMN/1HSsYyQuHoz15b9LkvJx+qBvSoKKb+xXKZIHYSrdAO9TwUz?= =?utf-8?q?+k1PpWZ2OCFiGULUW6i1p77aBsf40nDkr76TBwAuLbi5hQtkwpSxD1yyDkeHR1I4s?= =?utf-8?q?o6dzCmUeLHg12dynXwPus8qZsgivsHWN0Ptpqo+emFeRfcQ2t5ukpLiHFvnr4a+L5?= =?utf-8?q?G2rSq6FHjS14CBd5gGt3MA0sadRQgOrjDT508sDMu5F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fO1r?= =?utf-8?q?sa3hJl0nsKza?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5941.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(366013)(52116011)(7416011)(376011)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?zry7EPgENIAyUHDBnzoHYS8JH03s?= =?utf-8?q?LtQG9pFCJrRzUjnujt4rtSQjSgBHPHCdelvfeyPT5rPWUJAl8Iv/SN9vFmKggPTWa?= =?utf-8?q?klCqyt1Dcjc9UXPRyyxqjq0mGXH3E5OnVej5XGIfpHwXvGwSIpinsmDbnhBOIKKcG?= =?utf-8?q?p48iP82FXZLWBLLJDgSEjoG5EEoc8akVm+eOfQcaXF94srxG4g3UE2h9N2/IEq8TA?= =?utf-8?q?++8A/FDpoSfT4lNrVX/5HvYuTmTqprxwdUpzkeCvzNjV+Pq5cVSpY0aZ8gPMqWfP6?= =?utf-8?q?hf76qMNGk3TG+sVW92XGuwH/0PHYzad3XuRcSKsLLAQELNjyJVda5/I1BTPMQtqpl?= =?utf-8?q?UzUMmEvo8VSmEMQSS6VrumRUw2WZu9S8ApMGW9g13DtdZSLsJa1UTVl2IQvOje/cE?= =?utf-8?q?aJuBhHKCMkNPeonbfKom39DGMfgHQatGnkc8FAAYvcg2IE6sI2IycSwlO0LCWMCPs?= =?utf-8?q?LAtrRiNsoz58OibKV6joOj0IGdO9x11eXjr+muwU51ECjre/TREAa22iowo7TIMGU?= =?utf-8?q?ikkpiH5HLlpc6GnzJahM+tHCngDsCGEvrPkqHzcNmakSfhWp8bet6FnIy2TJZo7Mb?= =?utf-8?q?xjMtovNtaEU/XkdLl9Wa4/ba6zEY8jDfW05brHt8xtf5Q39DWydzFGHRJnj+La81M?= =?utf-8?q?QfICCMyr2w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-8?q?GacZfKcUxgbX?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f217f2de-d50a-46e6-06b5-08dc91bf3c75 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 06:56:12.1161 (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: Ppkx2QiVEH+EDgOBCe8Pu3ZnnvUnJptFzTPsmbMoIrOvb2Oz8k7ecZMdnk+ikCu72fZq0TBEiDP8Nim7s4DA9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10426 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 Reviewed-by: Cristian Marussi --- drivers/firmware/imx/Kconfig | 11 ++++ drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-misc.c | 119 ++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 +++++++++++ 4 files changed, 164 insertions(+) diff --git a/drivers/firmware/imx/Kconfig b/drivers/firmware/imx/Kconfig index 183613f82a11..477d3f32d99a 100644 --- a/drivers/firmware/imx/Kconfig +++ b/drivers/firmware/imx/Kconfig @@ -22,3 +22,14 @@ config IMX_SCU This driver manages the IPC interface between host CPU and the SCU firmware running on M4. + +config IMX_SCMI_MISC_DRV + tristate "IMX SCMI MISC Protocol driver" + depends on IMX_SCMI_MISC_EXT || COMPILE_TEST + default y if ARCH_MXC + help + The System Controller Management Interface firmware (SCMI FW) is + a low-level system function which runs on a dedicated Cortex-M + core that could provide misc functions such as board control. + + This driver can also be built as a module. diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8f9f04a513a8..8d046c341be8 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o +obj-${CONFIG_IMX_SCMI_MISC_DRV} += sm-misc.o diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c new file mode 100644 index 000000000000..342e1254a356 --- /dev/null +++ b/drivers/firmware/imx/sm-misc.c @@ -0,0 +1,119 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include +#include + +static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops; +static struct scmi_protocol_handle *ph; +struct notifier_block scmi_imx_misc_ctrl_nb; + +int scmi_imx_misc_ctrl_set(u32 id, u32 val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_set(ph, id, 1, &val); +}; +EXPORT_SYMBOL(scmi_imx_misc_ctrl_set); + +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_get(ph, id, num, val); +} +EXPORT_SYMBOL(scmi_imx_misc_ctrl_get); + +static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb, + unsigned long event, void *data) +{ + /* + * notifier_chain_register requires a valid notifier_block and + * valid notifier_call. SCMI_EVENT_IMX_MISC_CONTROL is needed + * to let SCMI firmware enable control events, but the hook here + * is just a dummy function to avoid kernel panic as of now. + */ + return 0; +} + +static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device_node *np = sdev->dev.of_node; + u32 src_id, flags; + int ret, i, num; + + if (!handle) + return -ENODEV; + + if (imx_misc_ctrl_ops) { + dev_err(&sdev->dev, "misc ctrl already initialized\n"); + return -EEXIST; + } + + imx_misc_ctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_MISC, &ph); + if (IS_ERR(imx_misc_ctrl_ops)) + return PTR_ERR(imx_misc_ctrl_ops); + + num = of_property_count_u32_elems(np, "nxp,ctrl-ids"); + if (num % 2) { + dev_err(&sdev->dev, "Invalid wakeup-sources\n"); + return -EINVAL; + } + + scmi_imx_misc_ctrl_nb.notifier_call = &scmi_imx_misc_ctrl_notifier; + for (i = 0; i < num; i += 2) { + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i, &src_id); + if (ret) { + dev_err(&sdev->dev, "Failed to read ctrl-id: %i\n", i); + continue; + } + + ret = of_property_read_u32_index(np, "nxp,ctrl-ids", i + 1, &flags); + if (ret) { + dev_err(&sdev->dev, "Failed to read ctrl-id value: %d\n", i + 1); + continue; + } + + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC, + SCMI_EVENT_IMX_MISC_CONTROL, + &src_id, + &scmi_imx_misc_ctrl_nb); + if (ret) + dev_err(&sdev->dev, "Failed to register scmi misc event: %d\n", src_id); + else { + ret = imx_misc_ctrl_ops->misc_ctrl_req_notify(ph, src_id, + SCMI_EVENT_IMX_MISC_CONTROL, + flags); + if (ret) + dev_err(&sdev->dev, "Failed to req notify: %d\n", src_id); + } + } + + return 0; +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_MISC, "imx-misc-ctrl" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_misc_ctrl_driver = { + .name = "scmi-imx-misc-ctrl", + .probe = scmi_imx_misc_ctrl_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_misc_ctrl_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM MISC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h new file mode 100644 index 000000000000..daad4bdf7d1c --- /dev/null +++ b/include/linux/firmware/imx/sm.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + +#ifndef _SCMI_IMX_H +#define _SCMI_IMX_H + +#include +#include + +#define SCMI_IMX_CTRL_PDM_CLK_SEL 0 /* AON PDM clock sel */ +#define SCMI_IMX_CTRL_MQS1_SETTINGS 1 /* AON MQS settings */ +#define SCMI_IMX_CTRL_SAI1_MCLK 2 /* AON SAI1 MCLK */ +#define SCMI_IMX_CTRL_SAI3_MCLK 3 /* WAKE SAI3 MCLK */ +#define SCMI_IMX_CTRL_SAI4_MCLK 4 /* WAKE SAI4 MCLK */ +#define SCMI_IMX_CTRL_SAI5_MCLK 5 /* WAKE SAI5 MCLK */ + +#if IS_ENABLED(CONFIG_IMX_SCMI_MISC_EXT) +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val); +int scmi_imx_misc_ctrl_set(u32 id, u32 val); +#else +static inline int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + return -EOPNOTSUPP; +} + +static inline int scmi_imx_misc_ctrl_set(u32 id, u32 val); +{ + return -EOPNOTSUPP; +} +#endif +#endif From patchwork Fri Jun 21 07:04:41 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: 13706920 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2073.outbound.protection.outlook.com [40.107.22.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8EBFC16D333 for ; Fri, 21 Jun 2024 06:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952983; cv=fail; b=dRtTwMT+JAXP/+Yo8z2u/YS7yEo22cnngM3WAlzprUF7wj55BvS3YL74xLMUHzJewpm2JX3CRFadbJzJn0K048B1vw1iZLYRWWY9SfqjjQDLQiVcJBBvgkgKG09eRwHAXr/bEaLl3EFZvGYzmfoBhCoL90KTuFCVGeZzzyS+Rc4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952983; c=relaxed/simple; bh=CqMGW21wLzQwHCQSMNma+Vvw2YS/kHx8/LptB3z0aIg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=b8e08OQuoXqDAwWTwbiEx3kQNA4dZGPDQEN9xF76JyljVDueNhDn2Jw7WrzWRsQUf34f8lCut9xozDZLQt30EDeDhbtXpfIcD7nQqHH7YbQUzzq4Zvu9gIPCpUMq04vHzw7772bqj0uwgZdhHwQLu6WWUWWqmyK7Xxwt4zEfo5g= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=UI/3inGG; arc=fail smtp.client-ip=40.107.22.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="UI/3inGG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eFg9s5Dp1r8m7WtLpXbg9/Rim8aWoLZbOEzJ2uhPhMjlSBD/QA1F86i+OZzmhduAsKI8EPVtEP/I72N2/s1g5lMeccdSNUDVQlrkkENw4jtiC2ACAFgRiuYicM5Qq6ROUor5zwOD6wi2NmPuKsorGlwpq2NgMShV+OZN518lccVa1NqJYRk06lOwhb6vXn7oJIuHauL8yN8MScggP8ueddQJMjdiwREPjodrcAaq2ni31UIxlIH1kP1t5g/lsbcTnr7oRJ8sglFB97zb+kDU/MGVzmEBDZ/OB8bzzMsVMa0Gn1q9qnxwIVIkqdPUVjyKnnzkTvoloQyvpLVqt1W1DQ== 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=fWJNKk3jgwCNHoMe46PPOkniwkqxONFBhlGDDTjK5QU=; b=BHMCPHjApc9HKIE4tM9BJcdo5wiTBDH3hr1uaHXJmIE4jxRyPNscBltfFgsBzctvatE7Y7tGFTa/2bR3JRtidK7s00Yjs4vvuMBiUiwk0xgMmwSai5MW4nCrDXDAv5sK3j9T1Pk4EckYDtoPE0QjoWUZmkA3/3XcLkDuGIEZNlkAswPs8JLliG75EW3tPZGDqXw85OiNWhC5OSmOIrvG/bImm9mI4aaL4aSTdfcc9kjqGA8MW9U6tXPRZn2VMq0m7wJ6FzhiIkHf9VlqW997ZpxoVlj9q8Nd5v5miTFpBTL7OVH7SXEvWl/GSIKLaT2JipchUuM3Thwu0sb9s09cFw== 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=fWJNKk3jgwCNHoMe46PPOkniwkqxONFBhlGDDTjK5QU=; b=UI/3inGGSJJVA5PAgngl0YDhFRixMCY1Nxm3d56QQoKSxAA8vP3EpRmliYeQaW4rV59uKieBjtNT6jV9plXC+HQn6kJuw5/frvliVLXZs8PSnXOCRk+e+TTQMORwQPpzLxsSPax5Ss84LByqgfqQi9UpzoJJAeY+Xkw1yshD/4M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by GV1PR04MB10426.eurprd04.prod.outlook.com (2603:10a6:150:1cc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Fri, 21 Jun 2024 06:56:18 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.017; Fri, 21 Jun 2024 06:56:18 +0000 From: "Peng Fan (OSS)" Date: Fri, 21 Jun 2024 15:04:41 +0800 Subject: [PATCH v5 6/7] rtc: support i.MX95 BBM RTC Message-Id: <20240621-imx95-bbm-misc-v2-v5-6-b85a6bf778cb@nxp.com> References: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@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 , Alexandre Belloni , Dmitry Torokhov 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, arm-scmi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718953487; l=6289; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=3stfAX6GDrY2yBI8qtkGNlp9Yy53JQgBChIeJkCcYsU=; b=lpdaEaKWf70vtixuRA2/MHtFiMqlaDNTv4mxP597gAdLj+D7yFjG77tszgA3/F0QA6nT8PB4L RVmgTlu91HDCIpJ6UHizg/MMCKLbUR/YE+VmrIpFO0sknoivOiK2t2S X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|GV1PR04MB10426:EE_ X-MS-Office365-Filtering-Correlation-Id: d5e00da9-c5ad-49c4-f526-08dc91bf4082 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|52116011|7416011|376011|921017|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?Fv1ceZHCxzp3xo8tHBeCxNZIP0lZaQN?= =?utf-8?q?4UhXxlYMiFV69TxbgPSnmb8tidxgeewsLyfzZ+xqCc/npYm3CG9zVxMJVFrZ3LKXR?= =?utf-8?q?UUU17SKaeps7YGDrI+JyLLUDkX2B87BFIji90mwFC/clMEPORTvcVPoz3EKYGIGmG?= =?utf-8?q?KfkLtOLenf3yd4F98tVaQ4pNXmAKk3inIaGKCAofJGz6JkBeC4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3V1F?= =?utf-8?q?27PSu8tznA07UOpy74fl0A3Sn35U4iSntIGvm8Yj8rysaU7f7Tl4Z+1FkEmoQMcKX?= =?utf-8?q?RfEvLNT2OWgIIqLldf3A6S8H0ZhXueZx12hPMMjnPbs8yLJhPkQRZvSeDjdurh8Qa?= =?utf-8?q?hRESlrclydhKsy+pGuhFFrQ3iEEw9YR4q95fdqRgH0y0gM4Nxr7URaphz4hEESUi/?= =?utf-8?q?sgSCR3CzMqmfNuiir862xK1MoxohUWAgawLh1rF2WtPylSvPNhHmVObTn9OHGLTpB?= =?utf-8?q?SdPvjGWecvX+?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5941.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(366013)(52116011)(7416011)(376011)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?hAWdWoFl6Q41ldo8bZuo6fvmDKEp?= =?utf-8?q?SFH9qLJcBrFAd/ccqEGxrRg+OoW+kGz0PaIhotlVy31zC9gQlKNftsvqBR5eb2Yxd?= =?utf-8?q?Llxloe1yfzsfzaUpOJE26OTjy52P2usn7L0oAvtQ47GG3sBAqVfrDiOSYvX4YXxUn?= =?utf-8?q?OzIyr1lFc/a0v+GRYVseBnsUIka5+J+YxeX4uoNgSxU4pqqPPegbXv5GVJ2QAGm+k?= =?utf-8?q?f0Fr3yskIvDGeqriOXdJpk0g53fh90SbOoTposjW3IWOoipuhVzk9Wli+JTmsdsSz?= =?utf-8?q?3RsYy+Vle9bfomOBSGFtU7W7y2qjA8hnSs7SqbVV0ZbhHQFS6wHXxVJ3D2YoVCupF?= =?utf-8?q?9QYpuw+r8oebCRnsRli/xQdnbQJxMHoAHHPTUuNC9S8GnZ+cK1uljYwUoG0j9ewpU?= =?utf-8?q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OpNyISWNRexPLRDC/Urq5ZUc6jko79DLyZ2n4C1mddddQREgGuC5Aa9v?= =?utf-8?q?m7hWPBbo5fA0KVxDSy539R7yOuQzj9qk4WbQyEZUY+a7uJdf2ctP9xW9eRavPAEQd?= =?utf-8?q?NEHGTbgtjxiMSoOErxCcjfzt1rXVEv0Oqq4iOM2SZHgtux6xKRTbDiFRYiJmDiLKH?= =?utf-8?q?hmbpZuOm+MJCO2qpyu8LT8sOpo49lOhJjsjFbDRTzXmxcm6DffJ5VAzwUUmDUqI5/?= =?utf-8?q?pOY509uTPJV4?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5e00da9-c5ad-49c4-f526-08dc91bf4082 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 06:56:18.8318 (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: 3+2tW1uSKcaq430a3oHeOaKlc/rrJ2Rcc1D7+ZmCt8X26sCMVAHg+V4MVJHU80mlftxHa7LrCUKA5HwRIKihZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10426 From: Peng Fan The BBM module provides RTC feature. To i.MX95, this module is managed by System Manager and exported System Control Management Interface(SCMI). Linux could use i.MX SCMI BBM Extension protocol to use RTC feature. This driver is to use SCMI interface to get/set RTC. Signed-off-by: Peng Fan Reviewed-by: Cristian Marussi --- drivers/rtc/Kconfig | 8 +++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-imx-sm-bbm.c | 168 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 2a95b05982ad..8122bfeba8c0 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -1827,6 +1827,14 @@ config RTC_DRV_BBNSM This driver can also be built as a module, if so, the module will be called "rtc-bbnsm". +config RTC_DRV_IMX_BBM_SCMI + depends on IMX_SCMI_BBM_EXT || COMPILE_TEST + default y if ARCH_MXC + tristate "NXP i.MX BBM SCMI RTC support" + help + If you say yes here you get support for the NXP i.MX BBSM SCMI + RTC module. + config RTC_DRV_IMX_SC depends on IMX_SCU depends on HAVE_ARM_SMCCC diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 3004e372f25f..8ee79cb18322 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -74,6 +74,7 @@ obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o obj-$(CONFIG_RTC_DRV_HYM8563) += rtc-hym8563.o obj-$(CONFIG_RTC_DRV_IMXDI) += rtc-imxdi.o obj-$(CONFIG_RTC_DRV_IMX_SC) += rtc-imx-sc.o +obj-$(CONFIG_RTC_DRV_IMX_BBM_SCMI) += rtc-imx-sm-bbm.o obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o diff --git a/drivers/rtc/rtc-imx-sm-bbm.c b/drivers/rtc/rtc-imx-sm-bbm.c new file mode 100644 index 000000000000..a634e5915d2b --- /dev/null +++ b/drivers/rtc/rtc-imx-sm-bbm.c @@ -0,0 +1,168 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP. + */ + +#include +#include +#include +#include +#include +#include + +struct scmi_imx_bbm { + const struct scmi_imx_bbm_proto_ops *ops; + struct rtc_device *rtc_dev; + struct scmi_protocol_handle *ph; + struct notifier_block nb; +}; + +static int scmi_imx_bbm_read_time(struct device *dev, struct rtc_time *tm) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + u64 val; + int ret; + + ret = bbnsm->ops->rtc_time_get(ph, 0, &val); + if (ret) { + dev_err(dev, "%s: %d\n", __func__, ret); + return ret; + } + + rtc_time64_to_tm(val, tm); + + return 0; +} + +static int scmi_imx_bbm_set_time(struct device *dev, struct rtc_time *tm) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + u64 val; + 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 ret; +} + +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 ret; +} + +static const struct rtc_class_ops smci_imx_bbm_rtc_ops = { + .read_time = scmi_imx_bbm_read_time, + .set_time = scmi_imx_bbm_set_time, + .set_alarm = scmi_imx_bbm_set_alarm, + .alarm_irq_enable = scmi_imx_bbm_alarm_irq_enable, +}; + +static int scmi_imx_bbm_rtc_notifier(struct notifier_block *nb, unsigned long event, void *data) +{ + struct scmi_imx_bbm *bbnsm = container_of(nb, struct scmi_imx_bbm, nb); + struct scmi_imx_bbm_notif_report *r = data; + + if (r->is_rtc) + rtc_update_irq(bbnsm->rtc_dev, 1, RTC_AF | RTC_IRQF); + else + pr_err("Unexpected bbm event: %s\n", __func__); + + return 0; +} + +static int scmi_imx_bbm_rtc_init(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + int ret; + + bbnsm->rtc_dev = devm_rtc_allocate_device(dev); + if (IS_ERR(bbnsm->rtc_dev)) + return PTR_ERR(bbnsm->rtc_dev); + + bbnsm->rtc_dev->ops = &smci_imx_bbm_rtc_ops; + bbnsm->rtc_dev->range_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_rtc_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_rtc_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_protocol_handle *ph; + struct scmi_imx_bbm *bbnsm; + int ret; + + if (!handle) + return -ENODEV; + + bbnsm = devm_kzalloc(dev, sizeof(*bbnsm), GFP_KERNEL); + if (!bbnsm) + return -ENOMEM; + + bbnsm->ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_BBM, &ph); + if (IS_ERR(bbnsm->ops)) + return PTR_ERR(bbnsm->ops); + + bbnsm->ph = ph; + + device_init_wakeup(dev, true); + + dev_set_drvdata(dev, bbnsm); + + ret = scmi_imx_bbm_rtc_init(sdev); + if (ret) + device_init_wakeup(dev, false); + + return ret; +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_BBM, "imx-bbm-rtc" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_bbm_rtc_driver = { + .name = "scmi-imx-bbm-rtc", + .probe = scmi_imx_bbm_rtc_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_bbm_rtc_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM BBM RTC driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Jun 21 07:04:42 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: 13706921 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2077.outbound.protection.outlook.com [40.107.22.77]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B993916D4E6 for ; Fri, 21 Jun 2024 06:56:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952991; cv=fail; b=NGFUpUvpG5weFHZFkLIB/c/d+f2WztfvjlpPi0D4RgaHQLGrQsSaiP/3rjaC3v/t2tZLE83faEBqdOOD+v4KROx4tsxvALDuTqK0X0BupQvIStju+xDPtCtLR0p4wBrCB3WvHZVEHMsJ2Ds8YPjVrgjy3rHh/K969mB5Hrcgtbk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718952991; c=relaxed/simple; bh=BQjEWFs3tn1kJ3gHqry+33Y19uPuh+IDbf4sSa4/dBE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=lwI5/nOhBG3BRjc8nPmaWRAuw383KV8IOBiT0/MhRfAGsYxR3ZJ+6V05nwx8tq9Ehs7r5e9QUMgRmLMrK7UTPuNAcjxdHFdCC4QFlESgNCKHE7k5UEa+BKCzlTUVP3RJzglNXVt02Lc2gKhMS6qVSj3PiTpVlpEqFZhK7+/mWus= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=e1C1w/sA; arc=fail smtp.client-ip=40.107.22.77 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="e1C1w/sA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UU0/0mE/X+O4K5UjG1TcSkT5OUab5vVdoPOn3BlVWk9g/kPhXLx8dl5LsOqnRM2mG2OjsDWKvXWLethoWjc19u5igx32QDMculzwlfuGc8oArswDLdN9IcIM6TILFt2VDTWWIHOI4VaXdEnoN1p1Yy48slVb7qOuuiuYtE3PE7nYDqbMJdWALGnDXvd5qdSATBP3QNTFhECc4upGSsfF9v5pbgsIbgT9AXdDu5Ky/MateZQR0TyYlKQAqm+tfDjwhFJHP8TSFBBANzYvQ2vIJIuvFJHJVZAOGfbg6ZYzI6tYo2kKMuTZ5zpmFgN0UWBWhbmjvKSc/kW/1+vahp7wxA== 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=C0ggd5wKMv4U80GyDOSu2OoINrWdvdDCP012GJn8Wwo=; b=Y4F7JYzIlkNCS547gfRhNWOuWH5j9fnaIj7nNMFvGpshPO6+l/i/xT1ZQlMugO1DogCg7AJ2vy0ANvE9ev2wkc0WB26mn/CwRRI4GBwq9qD5ymkG8v+fPP/NyMHDSJEhkKl70bU3S5kyrDgrCZ25X3GX3EIFnhjML8HVa5ck2XAkay9ObNbflKt/HPfh7IR+oWng6rsZNuv1aE4TV1uJmcm7lbuZN0VIvGMhD008Wq6vvPXUp4c73Gi/udi8mVoawIb+H4/xQ98KOuWpA8Ai9r4MAV6Vb+zkreW+DoUknNDqFEwGigTbTzwSO8dtBsmBke0VMW+FzBMLX5yhcW1yWQ== 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=C0ggd5wKMv4U80GyDOSu2OoINrWdvdDCP012GJn8Wwo=; b=e1C1w/sAWUm7Ru2rMJ3VfPnkm/TC+thyHFIOqCYlHdbM/oPyjLdXxL6t8zxMQtAtLhM9aqHG0bhi0aakk0wdWMajxAQ9E+POMXKJNjyizW7YaQfPpWwzIR1idPpv+H+XZkWvQ4MUaQ004EoNT0riHQLxSiGHklkbcfZPchz0Vv0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) by GV1PR04MB10426.eurprd04.prod.outlook.com (2603:10a6:150:1cc::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7698.19; Fri, 21 Jun 2024 06:56:26 +0000 Received: from AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256]) by AM6PR04MB5941.eurprd04.prod.outlook.com ([fe80::9f4e:b695:f5f0:5256%4]) with mapi id 15.20.7698.017; Fri, 21 Jun 2024 06:56:25 +0000 From: "Peng Fan (OSS)" Date: Fri, 21 Jun 2024 15:04:42 +0800 Subject: [PATCH v5 7/7] input: keyboard: support i.MX95 BBM module Message-Id: <20240621-imx95-bbm-misc-v2-v5-7-b85a6bf778cb@nxp.com> References: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@nxp.com> In-Reply-To: <20240621-imx95-bbm-misc-v2-v5-0-b85a6bf778cb@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 , Alexandre Belloni , Dmitry Torokhov 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, arm-scmi@vger.kernel.org, linux-rtc@vger.kernel.org, linux-input@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1718953487; l=8179; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=ChfkEJX/72hXEL9g1a8O55kYUMOihK4KW1T6yM6QP7s=; b=478Kz2I4jFt9FPxkAK98lmXfjQPwSEDRoU4ChGwdkT9MAJDo+jB1gg6nuORaR7bm8I4KVBzUT JqOZH3l/a+MBl6n63yUIcLj2DjBKNKzwAa0dT3pjhv+bJ+NRxUa3F+5 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0122.apcprd01.prod.exchangelabs.com (2603:1096:4:40::26) To AM6PR04MB5941.eurprd04.prod.outlook.com (2603:10a6:20b:9e::16) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5941:EE_|GV1PR04MB10426:EE_ X-MS-Office365-Filtering-Correlation-Id: d4a72654-60e5-466f-3f9f-08dc91bf448f X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|1800799021|366013|52116011|7416011|376011|921017|38350700011; X-Microsoft-Antispam-Message-Info: =?utf-8?q?AFuYzA8dFOGnmoNS4NIRR9+KFs/Cp4H?= =?utf-8?q?aqZyhuq3XNKaG8KVUYedjqaz1vwbd1wVDeZacyojGv0DHas75GcOfSpmEzfo0Sbi9?= =?utf-8?q?7QJuHh65HMi3+hpwPbRi3cdWKE3XNYfcTqmiidE9fdmLAXDO5ttVHnxvMlPUUikbg?= =?utf-8?q?b6Nb11HonfskJd+nZCihc6rq90+akkNnSSI1qYnLGOPsGqDYY5kbVaQTs2ErxioUR?= =?utf-8?q?VqmUqIEV4qFIPJG9xfI6iy6y4dgtkT5F5kYqSdy+ppq93q/D3JfitwGh0mMUGzurj?= =?utf-8?q?4QPotCrxP+YY18SiOSrkpc9Zkt+ElePN9HH8NOr2JeCUpZmarDVua9fBYF8A1DE28?= =?utf-8?q?4hMdrYtd4VBB8/CoipyAYvmlOwx23IDO+NDKfp6ES3YmcRULTjrquJS3T8IrrO76G?= =?utf-8?q?CJWfkdT22qNqKkl6+3H+wtsb1L9CIxq7hMnYPqprq8zVen1zLcdenz2F05YoT6dQg?= =?utf-8?q?PcRs/Vj5zBPrHjnLhzmrilBGcyi3ZHL6OHr2HfZgF4yDcB7UsLbLjQ2jPOC5poz12?= =?utf-8?q?4GNUCBXrIWsjRxglqNe/tGE6Ots7cFHGcsWbVw7Vootz9HwEtFiGEJThXyxXWYS4d?= =?utf-8?q?0x83ubygUnZdXJ3kVrA5BplRzkh9QmTb6+D2X5EAPi+0l8I0SuBEixUcrRU8Cgj/h?= =?utf-8?q?FQIsM5GI3XxVm27f/nPVviAcH9F3Kpemd8P+EkJjEapyPVdoTGWiJHXjINHu0ynaQ?= =?utf-8?q?OT4NhjDmonho4sr5GZNbHPXI3LA7ZF3nBEv1s2WBX8jsP/Sn2YtZpSvvXFZqt2R/U?= =?utf-8?q?Ao1dSzzr09VXKv3OZkKgDy2x4DU/oOP+AZirY14NIMHELaCHzwVsVAnokso9R/Cx7?= =?utf-8?q?2/cuquSl54h3kuXJhGcWnvMnYY7+t0q/baeyfphrgFjCd4TwNbL5AwhC91Rq4lVhZ?= =?utf-8?q?8kBAfD0kq1rtpWzZ0EMZEpcuswkuz27M99FGhdxlsxNfvciFXA8XUwWmj7vFTTeMi?= =?utf-8?q?xBgJVSX2SsBe66MezEvcI+UvfNCiL+6NfgJpiUzZE4v+Y2/DdzRuwblBuHKhHjlgo?= =?utf-8?q?ugrhv27QPF01cNvXDqigWWe02fuS0CS/3JKm8LJASfHQBcQD/gIXQNuraD6YzsCNM?= =?utf-8?q?BKmo2k/Z8VkAkcf1EyaJW1nHeL7udHDP0E5VXinmizrCh9YwjRah2HU6QppBPjuz5?= =?utf-8?q?4gkgzqMQ6L6USAy2S7yGs6u1nCPa+gohJDn+l9xA3OA0vKNfs+J1d+gn91o+fNUih?= =?utf-8?q?qQ4PiG4ZFkVJ5lzSgfY+lipspgG33Y2az/mr4uoR8ghue/u5UqbYlK+Z0SuRznsY9?= =?utf-8?q?Td51u6IhNDVmB3CaCUpsU71h5LCHaqQomtpM9YBLIYnyiEmT1ewQnUv9wdJJfm3RS?= =?utf-8?q?XC9Ucfurwpn1?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5941.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230037)(1800799021)(366013)(52116011)(7416011)(376011)(921017)(38350700011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?SC2arv7oPPDRuk5Q+IBSP904f4aR?= =?utf-8?q?LrMg1M0YPPDKTWcdxQ4lIzVlxdtkC1fYXmp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VwVb15nqEXjfQZJeFUV?= =?utf-8?q?drhvfSNs4Yg+j9wn5apXt7wnJU3kSMk6Eu2/IlW6QOZzqYHaAWFULdTlW0Ydllbaa?= =?utf-8?q?fvzn2rYUYbs7HdrbBGJqUZ0iCGNPDG/FRyUKRSN0rXb+YNQ8p+iWDh/IRaFMtLSNP?= =?utf-8?q?67PsFCstAEdzNP5upWJUxU1SZzJQM7F5wWo5aqeuZk/r6k4N7OTn2x1Glad8r4hIM?= =?utf-8?q?R9tD4lLNK2EL9+e84abul7xvUCxNx6OVn97fsktPO/JEO8cdiqhPbpKEsVMQQ1wo2?= =?utf-8?q?BsKM0OveBrQDS6NSIExJYanvTPLCOe6c9GQDK1UNrn0fv2IQ+mntQyIXU+rKOUOpi?= =?utf-8?q?mf9Xv7fI5RUt3zklolu9AYGam1CcbQT/0Xk0pTypAg7ZzbDlAglvm+ccYf8K/yT5Z?= =?utf-8?q?td6aIKBUj2dPW5/fcmhVlgUtFSIcgvXhOZfBOEpdPs6KTzYO1UB3Hl64fRDZ1vcu+?= =?utf-8?q?c2hraocC/naBu5h+XjXGdb/OzwCsXzkJotuIcYge35nK1AyUA6NzyhuYMNWAN2vY0?= =?utf-8?q?LBxo7WbsujukDEG//AIut6GjMoIQbY0FrJVn+jqwV+SPKgUbw0S2Ztox0FzBeEDD4?= =?utf-8?q?8CEhJMEkk7PY?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4a72654-60e5-466f-3f9f-08dc91bf448f X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5941.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2024 06:56:25.5987 (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: SmTeL7EWNsEbLfOuXKP+NFRvyoE5Stss07R2Nnwa9hzyawP3qzhdO7EGgjkCNJd6jsKUxVnvuNg7LInI1tyxcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10426 From: Peng Fan The BBM module provides BUTTON feature. To i.MX95, this module is managed by System Manager and exported using System Management Control Interface(SCMI). Linux could use i.MX SCMI BBM Extension protocol to use BUTTON feature. This driver is to use SCMI interface to enable pwrkey. Signed-off-by: Peng Fan --- drivers/input/keyboard/Kconfig | 11 ++ drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/imx-sm-bbm-key.c | 225 ++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 1d0c5f4c0f99..1c3fef7d34af 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -466,6 +466,17 @@ config KEYBOARD_IMX To compile this driver as a module, choose M here: the module will be called imx_keypad. +config KEYBOARD_IMX_BBM_SCMI + tristate "IMX BBM SCMI Key Driver" + depends on IMX_SCMI_BBM_EXT || COMPILE_TEST + default y if ARCH_MXC + help + This is the BBM key driver for NXP i.MX SoCs managed through + SCMI protocol. + + To compile this driver as a module, choose M here: the + module will be called scmi-imx-bbm-key. + config KEYBOARD_IMX_SC_KEY tristate "IMX SCU Key Driver" depends on IMX_SCU diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index aecef00c5d09..624c90adde89 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_KEYBOARD_IPAQ_MICRO) += ipaq-micro-keys.o obj-$(CONFIG_KEYBOARD_IQS62X) += iqs62x-keys.o obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o obj-$(CONFIG_KEYBOARD_IMX_SC_KEY) += imx_sc_key.o +obj-$(CONFIG_KEYBOARD_IMX_BBM_SCMI) += imx-sm-bbm-key.o obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o diff --git a/drivers/input/keyboard/imx-sm-bbm-key.c b/drivers/input/keyboard/imx-sm-bbm-key.c new file mode 100644 index 000000000000..907dad383b8f --- /dev/null +++ b/drivers/input/keyboard/imx-sm-bbm-key.c @@ -0,0 +1,225 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEBOUNCE_TIME 30 +#define REPEAT_INTERVAL 60 + +struct scmi_imx_bbm { + struct scmi_protocol_handle *ph; + const struct scmi_imx_bbm_proto_ops *ops; + struct notifier_block nb; + int keycode; + int keystate; /* 1:pressed */ + bool suspended; + struct delayed_work check_work; + struct input_dev *input; +}; + +static void scmi_imx_bbm_pwrkey_check_for_events(struct work_struct *work) +{ + struct scmi_imx_bbm *bbnsm = container_of(to_delayed_work(work), + struct scmi_imx_bbm, check_work); + struct scmi_protocol_handle *ph = bbnsm->ph; + struct input_dev *input = bbnsm->input; + u32 state = 0; + int ret; + + ret = bbnsm->ops->button_get(ph, &state); + if (ret) { + pr_err("%s: %d\n", __func__, ret); + return; + } + + pr_debug("%s: state: %d, keystate %d\n", __func__, state, bbnsm->keystate); + + /* only report new event if status changed */ + if (state ^ bbnsm->keystate) { + bbnsm->keystate = state; + input_event(input, EV_KEY, bbnsm->keycode, state); + input_sync(input); + pm_relax(bbnsm->input->dev.parent); + pr_debug("EV_KEY: %x\n", bbnsm->keycode); + } + + /* repeat check if pressed long */ + if (state) + schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(REPEAT_INTERVAL)); +} + +static int scmi_imx_bbm_pwrkey_event(struct scmi_imx_bbm *bbnsm) +{ + struct input_dev *input = bbnsm->input; + + pm_wakeup_event(input->dev.parent, 0); + + 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 (READ_ONCE(bbnsm->suspended)) { + bbnsm->keystate = 1; + input_event(input, EV_KEY, bbnsm->keycode, 1); + input_sync(input); + WRITE_ONCE(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_key_notifier(struct notifier_block *nb, unsigned long event, void *data) +{ + struct scmi_imx_bbm *bbnsm = container_of(nb, struct scmi_imx_bbm, nb); + struct scmi_imx_bbm_notif_report *r = data; + + if (r->is_button) { + pr_debug("BBM Button Power key pressed\n"); + scmi_imx_bbm_pwrkey_event(bbnsm); + } else { + /* Should never reach here */ + pr_err("Unexpected BBM event: %s\n", __func__); + } + + return 0; +} + +static int scmi_imx_bbm_pwrkey_init(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct input_dev *input; + int ret; + + if (device_property_read_u32(dev, "linux,code", &bbnsm->keycode)) { + bbnsm->keycode = KEY_POWER; + dev_warn(dev, "key code is not specified, using default KEY_POWER\n"); + } + + INIT_DELAYED_WORK(&bbnsm->check_work, scmi_imx_bbm_pwrkey_check_for_events); + + input = devm_input_allocate_device(dev); + if (!input) { + dev_err(dev, "failed to allocate the input device for SCMI IMX BBM\n"); + return -ENOMEM; + } + + input->name = dev_name(dev); + input->phys = "bbnsm-pwrkey/input0"; + input->id.bustype = BUS_HOST; + + input_set_capability(input, EV_KEY, bbnsm->keycode); + + ret = devm_add_action_or_reset(dev, scmi_imx_bbm_pwrkey_act, bbnsm); + if (ret) { + dev_err(dev, "failed to register remove action\n"); + return ret; + } + + bbnsm->input = input; + + bbnsm->nb.notifier_call = &scmi_imx_bbm_key_notifier; + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM, + SCMI_EVENT_IMX_BBM_BUTTON, + NULL, &bbnsm->nb); + + if (ret) + dev_err(dev, "Failed to register BBM Button Events %d:", ret); + + ret = input_register_device(input); + if (ret) { + dev_err(dev, "failed to register input device\n"); + return ret; + } + + return 0; +} + +static int scmi_imx_bbm_key_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_protocol_handle *ph; + struct scmi_imx_bbm *bbnsm; + int ret; + + if (!handle) + return -ENODEV; + + bbnsm = devm_kzalloc(dev, sizeof(*bbnsm), GFP_KERNEL); + if (!bbnsm) + return -ENOMEM; + + bbnsm->ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_BBM, &ph); + if (IS_ERR(bbnsm->ops)) + return PTR_ERR(bbnsm->ops); + + bbnsm->ph = ph; + + device_init_wakeup(dev, true); + + dev_set_drvdata(dev, bbnsm); + + ret = scmi_imx_bbm_pwrkey_init(sdev); + if (ret) + device_init_wakeup(dev, false); + + return ret; +} + +static int __maybe_unused scmi_imx_bbm_key_suspend(struct device *dev) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + + WRITE_ONCE(bbnsm->suspended, true); + + return 0; +} + +static int __maybe_unused scmi_imx_bbm_key_resume(struct device *dev) +{ + return 0; +} + +static SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_key_ops, scmi_imx_bbm_key_suspend, + scmi_imx_bbm_key_resume); + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_BBM, "imx-bbm-key" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_bbm_key_driver = { + .driver = { + .pm = &scmi_imx_bbm_pm_key_ops, + }, + .name = "scmi-imx-bbm-key", + .probe = scmi_imx_bbm_key_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_bbm_key_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM BBM Key driver"); +MODULE_LICENSE("GPL");