From patchwork Fri Apr 5 12:39:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13619009 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2136.outbound.protection.outlook.com [40.107.20.136]) (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 38A1316D305 for ; Fri, 5 Apr 2024 12:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.136 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320305; cv=fail; b=FpzU9V3k0WO2fC+5CevCjwNNOKQXxeRp45pya/SUU9/ecdT8riXvy1AZ68EsTPneeDr+86VsrFh2J4HAL2Z5K+GCEtUKjCe4NIMs5dJbABVnUIVTZGd6faj+N1WcymPrFnI30PphjgRbEsdcf++gomzodkvXKcqPwMt2tvCSQt4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320305; c=relaxed/simple; bh=KOS1fMTnSlxPBGgDLiRCFGLt/HM0/qdbCuH8E69P9xE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Uc8CsF3JB+tENzy8+c3jkTusXsLnfJ7O9FA25cQ+RKsnOBsCBKn8zHz2/vs4iyvlamatkNtp/Sydtp0Ue9c52DlFP+rxXPmwzoxp6cBs5HPU1nBr4kc434qscgEoKz8dtUi0qp5u1HMKBHOr3mDxhlwxbjRrrkP8tyqz+czvs+M= 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=QX5v7o9w; arc=fail smtp.client-ip=40.107.20.136 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="QX5v7o9w" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YBWSKW4HwwJjL7Ep+rXjR84H/PurG43Ib7kDU+Vm8+HUTcqcAJytwPWIDaVGu8+teZSSauc/vBE57e16OUmBjVLrwNWiT2U4pZGfjqYBZpBjEhUjdQa0/VYhUPCvMcsXyKjQ8ZWVP+xx9u3Lqwgc4o1vK7E+rKJc29rGR+moYvXzGsa7wDMjXTioGBhfs3+le+EzwBo7GblM7I5fv3r7Z7WtZBuajhHgRvrMx0hkffD/fdr4DrOuirboKRUunaKUB/c4wotOhQ22wcctvLjnwVK8hFKX/6NEi115j1dTNK+gzQqIVY9+2urUPklyJ3vWMkVFkYlduLIqq7oU+a0nfw== 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=WIrAYHJD3ymVgy/ukproqrrzJHlE56llh+9tPgyKp0o=; b=k6/1gvNc19yBWCxhqgoyf1EQSs3pC8tLUPwaRuc4xrLEHvZNOcCOf6DWOIQjza3Av/WpD2xe869M+/ahvStTqBjg53EsePRlW/AoyCZfr7NuYRJFOf+KexaG3MitfrrH+KCEcsacmlyP9mp6WB41trFgCgiE8j1my4S0RGu5lHO7+6qhWxcYI1/3kqRUWZLneCLH7ggsn+4yipX1DCkVEwvMJKCtP9XpNiK5qGhVMm45joDoqpvs5G7XRLI+JwSmU8mDJxXXVpRrFe8IHjHa0BLZOeY/YCo/S2ybeK9aQAQOOHTv+1+3AnT/sogh3HjlLAkWfknL6bnaBvN0Ehg1GQ== 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=WIrAYHJD3ymVgy/ukproqrrzJHlE56llh+9tPgyKp0o=; b=QX5v7o9wORXl08s5uSSCpEjyxbPfBzbVhpyOlYua3hPirFDUhbIaMQ+vQy0h1W7dGsJGODdBqNI7BeMKU671koQiY3XjRumXMbi/6nftRa8mLy7yyU1OpTXhod+SQC6eSxr3nsATEGs43j+IjQGvQzWEDIcVYmhwb3P7xJK7Nkc= Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7744.eurprd04.prod.outlook.com (2603:10a6:102:c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 5 Apr 2024 12:31:42 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7386.037; Fri, 5 Apr 2024 12:31:42 +0000 From: "Peng Fan (OSS)" Date: Fri, 05 Apr 2024 20:39:23 +0800 Subject: [PATCH v2 1/6] dt-bindings: firmware: arm,scmi: set additionalProperties to true Message-Id: <20240405-imx95-bbm-misc-v2-v2-1-9fc9186856c2@nxp.com> References: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> In-Reply-To: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi Cc: Peng Fan , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712320792; l=884; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=lZELwg5Facpp/lW5lmbNGyPbb53VuKGtVUUGB3YN3gs=; b=L7LEle0TWxTrxLLMwUZaxlTtYH9Do5x3OeJrBK/7pG2abqLibcEKIwhH+WeCe1xoCfxxREHAb Miau3NjRnvgA6bfJSZ9rYQmhShxJM6zPDS/At4YxObjd9QfAfIz41+g X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:1f4::12) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) 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: DU0PR04MB9417:EE_|PA4PR04MB7744:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4oeRl5COufZZ3qieCCsCx7VFdSDe39bNOqYvRPo5wz+wwXETHeGFJhVFPsersK0cMqMKK6dEV/Us782aJJ/j0UayBYA9UeACX+eCIVLdd3xEUUKe8q5+cEY4wfANu+icm1Q7GURuT96dnWLbCBIhS6un2RQEt0vayIo0QJCAKLVvRNcrIXhNicJCTDYDDh1CGpbu4C7EBkGxM22t2ejOKqG5W0BjuiHsuO5a15eyuIF0l5/m2h9hL0Qz1lu3NTa+qZzwgyq9AvCQAXZbEMDWRvIC1+avfl8y860yHeNWW1E0OwNfQmpCdwJrpswEMIaQQHOPHQ4rntcKVCZ6P38vwLep/X2fpGbAPjdroWOEOsqLMEsBUluPv0sr5pktha36B8KubzpOA1Nl/bZ5v48DZIKBLenmWWjInVQQzsM9/F1N7xRtq8bofoiuELVXWULzwarH7Uk7VAyiKLqYhMksgfIV26Z/LYaq+7iX0DPhyiUky3gShxjIe06H0jMJzD263KDs922HewMCsHj4ZryjZH5wm59Z9ZqBQiR4/1ROh2WzvrUqmWPitZemznRnM19HI9ue+MbIvcIFMjSWQVJyx4KBxmVUc8wHK2ciEMp/aP8HDLW0L0Sye9sYyGD1xmdy8ZQtYclp8eVIT9aKeIXHz48aAiNzD9ykSuUJ7W0znJ3K2EnzYz1yYjWQ9cBfTaEVbfGjE/7BRf1j0m2dTcvTN1FQbF4EJX9wc0+kWe3oAHQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(1800799015)(52116005)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ZR+/BfPHkgP8p7TARDQvwzAOhRub?= =?utf-8?q?BfqL7sAYGplkJKzmmqSbUJaDOHeiTA5KZTicQxRdBhciAlodfW1T8pLNfpoQ5t+kE?= =?utf-8?q?6RkL9Mu3dR1Mxjp5blqgXQud5oKLZ6QmL9VJFvPKJ/cpGcBiomuLJDh1A0zonMpxw?= =?utf-8?q?dZmheCSUyuYAgHbALlIMZMJgaV2OSIpooa1VrSVQEkem54uYcWLy5m1Z3MiLMn4QD?= =?utf-8?q?KvmtXIiu/elMT83mhR6OFthKT2mBb9MKzpN7/dcombe76ZeraUpzSh24zzkkZf4Y5?= =?utf-8?q?x2Em52Igp6Mg2ZcaqZ+c/t0wQOaXUXChv0K9ZWJGIBX4/N4YosiDcvpIfmd67dhly?= =?utf-8?q?ByU+GsGBhvDKIvI19sQWVfU6cr9Q3RvrS5Zjt6FZI6qpDr5/eLR6H31b8nIuwAlgQ?= =?utf-8?q?W/IvE/R4pWY42LR01qc3N7vEcuf8C+dEbD7ol3vOwOW7SVfto3iDoejqQWULdrez1?= =?utf-8?q?EAQKD5zodoMUnR1T87KaP7jiBznK1NY9+k7v6wFKcitmjW9P9nW+Z9ybMQTUjOH10?= =?utf-8?q?ubVsap4/pqAgh7YoNdlAVWvbT/UxjqNRYMYOkLR8fQazq950vm5R8fi3nRziwmwjv?= =?utf-8?q?r76x2qYohzWhNIpeLcrjDXgk1NmI9VLHLNLuMUOKjp9SSGG5wvgiUf+ye4Bm1Z+CB?= =?utf-8?q?ZIUtJ185b2JQp/6zM8VOpazrGfmwDRPIJ3LluVhj50o6kL+Oa1S6CDb6Gur3i7Pls?= =?utf-8?q?dGox16OL1LMq386VMwOXVUQrcbT9QsMSA27dnYBEQDHHLIviuFMdD+p9gUPBQbcMx?= =?utf-8?q?1z0gtTkJXby+ZHO5p+NTcUvlgYIuVLHH6HF7I87wbxBKcXW0tsaJ3/xqHkNtOpK+X?= =?utf-8?q?k5i7voj7jlGIATT0SMM3nfCxcWkU9UM592yFqRHi3USMdEv9aPc3o/bOboTR/mZ/D?= =?utf-8?q?XLGLkoFb7jc8ZcGQuHnnYxRO1nkGXueogGK+O4wLXMRIqdRQPfN9wX8Svc5+AZ9Wg?= =?utf-8?q?IacU2ICMd2vvoffUh7xYUHiaDDm4/5d8xRhc88IlvV0cHinVvKfbC36Q/YEt2Dgqj?= =?utf-8?q?XKOv237RQ9ZDI6ojugJyWyZZoNSaMCzKsrIO1Cnj/v6LBNgDi8RBG7/ErRvfK2dJN?= =?utf-8?q?DleFeXbaqNs2LFA9moWatfdKFtBZhhtb2//+NIEuvmk+r/dfZk39Nn17K+Hg35YvC?= =?utf-8?q?j9Q/Ds+AZ6+aucUbkENKBcrSHfqeNKkz6q0lg0NQzghMefPi1SLq6Bk1ZrEuNhoIF?= =?utf-8?q?xqzcRLXYh5eycis8Ew/huC07Kkkjru393o13WrTqIAdPP2HxtEr7CP9VOZFcXHlsv?= =?utf-8?q?1yA2RCJv6k698ouIKp9G3BO37bB4pUvzdY/tU/4DmqXUlsa3Uj/GdrGuemyabG74T?= =?utf-8?q?Zg4PRGJNy4QLWvJthKI8tiX8u82HU8wYX8UQUkpGlIlZHUNXEAL++BPLDCbZXQqur?= =?utf-8?q?5yWOHAfc8pt+EnMCz8YLoWlZgz7pE/V3joAvl8+5OOWXLpoJ1iFL74P7RnqmvNbdN?= =?utf-8?q?udg+ao5ECC1s4ES7msRBwgYxFXA4uO9j6vwGSy03tKc7XTSiC+IqORKdBiwODP/Vh?= =?utf-8?q?u7cc80IalzYO?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96292b8e-dbda-4ff6-7fad-08dc556c5904 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2024 12:31:41.9587 (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: EB2khlVVl8J/zccl56AduvjQfsHXDlx2svT2om2Ki369wQpH0PTie4d5nE2yUg/TH6Gjsj/oOz2gkwjeS49ufg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7744 From: Peng Fan When adding vendor extension protocols, there is dt-schema warning: " imx,scmi.example.dtb: scmi: 'protocol@81', 'protocol@84' do not match any of the regexes: 'pinctrl-[0-9]+' " Set additionalProperties to true to address the issue. Signed-off-by: Peng Fan --- Documentation/devicetree/bindings/firmware/arm,scmi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml index 4591523b51a0..cfc613b65585 100644 --- a/Documentation/devicetree/bindings/firmware/arm,scmi.yaml +++ b/Documentation/devicetree/bindings/firmware/arm,scmi.yaml @@ -247,7 +247,7 @@ properties: reg: const: 0x18 -additionalProperties: false +additionalProperties: true $defs: protocol-node: From patchwork Fri Apr 5 12:39:24 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: 13619010 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2098.outbound.protection.outlook.com [40.107.20.98]) (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 423F92E40F for ; Fri, 5 Apr 2024 12:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.98 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320311; cv=fail; b=FGHsqAaHnQv8tJWJUqxsBRNcTqHeU1ZdKTOqJS2F5cw8AEFgyjS+sEQVmAICTl35aX3eIuBStgwAg2R6f6jFc0DVVEVVgsKJFhytZSQRxKIocNnvQHpHH+hlB3RLjabZStbslf8F/NGJClTc1QJ8A/5Q6tqBv7yMpSNavgynPxI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320311; c=relaxed/simple; bh=njXEMiMpEtIfaZaIhvK6loNWL5RDpfROj9sYckAJ0PI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=edYwax0AHnM4kvopwsKfuqtC6CgxMAQ6OnUgQ6cQTINHu4le1zH69wM9xO0vTg8mkc8s26Z2cTTcHbg+OdFNaM3yYkAbcaVUIOS3MsPJUSq2EOuZvQd8RCNE/ACciwFDJ0tnbhu/bCC614QoDZR6GV4os+Nkoti4Oitb4ZmxgM0= 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=V6054nZt; arc=fail smtp.client-ip=40.107.20.98 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="V6054nZt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDhVeKazmZnDfd8EG9twr2fJVhyBYLMaZ3XQNVHC88gQkyoLiTZbp+K3TeV+JRzifI/USQS5xxq6quJtXsxXf54ZYT+Nkn+jxB2hXBVNM5x6/sYz7e8ukrocTXTpqYZpSbPGJyAjD5Fh8X4MS3fDMDF3kQnsONI0g2gTkxEIqrmSVBYKzwTHVW2ITA3dk8t+xiQaP966w4bLVrTJVV2N2P6kVx/g2Bb5xIBrvAusUaJnxfg6LqgAEbkg4z6WPgWMHq7eEpv4JivWmftGff79hfz1RlU2IwlL97vutBQOPs2Tc55xJAzxDUORZFQySoxe1xnHgryW3U5zRZzFkzmh0g== 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=WLhlRCiWVsLIeV7NVQXArw+BAOVRkiuO/QlS5Qa4hLw=; b=UgiEJ3Qz+FTCE17Ok3YiVqj82y4KcjdrSSl2+7M5bQAtxTEegnqy4PjK8Is5XY+rZSjFEcINm/VSOkuJHaSo+uOfwGwfwe+NMbk3ozjlLBC4VOi7AZU/bxfrHSoA9rvBq1O5TLvRSgunitl88q1yJXvj/lDqh+hWlngGWSmChOBNLmQV9h7t4uvoVGNi2sBtnkCd52Ulq2xhXbpOnVy8QXjdIjhtjWudwxqCgf8ehYjKNZyvks+ZtkqYb1YIH3P3dm0YIqjDIklPbFatU5h8cUHTOhj8XzwNYzH7TUjD1HY0t7UbQHyQqiVC8N+jKsimv5cr5lmdjG6OBHdr8P6M4g== 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=WLhlRCiWVsLIeV7NVQXArw+BAOVRkiuO/QlS5Qa4hLw=; b=V6054nZt3ikgmb2xzQj0spH9G/gSR1uHoERObHSjUX565/nywiAMu75yvREONZJOa3UEeBijPH1wPhYC5J7JltmPbMqz4V5SnTlo0XdF/2EYuMOJ/DfWoK4KQuxGVENBEW6ajCH+u8tMdXhpeuuEYMIy09vU9+Lyqqcr6BiYkrk= Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7744.eurprd04.prod.outlook.com (2603:10a6:102:c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 5 Apr 2024 12:31:46 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7386.037; Fri, 5 Apr 2024 12:31:46 +0000 From: "Peng Fan (OSS)" Date: Fri, 05 Apr 2024 20:39:24 +0800 Subject: [PATCH v2 2/6] dt-bindings: firmware: add i.MX SCMI Extension protocol Message-Id: <20240405-imx95-bbm-misc-v2-v2-2-9fc9186856c2@nxp.com> References: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> In-Reply-To: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi Cc: Peng Fan , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712320792; l=2717; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=V2qEDgdGzTv/oSyf8SB67tGPyUyth0sA80L0w5qSmfA=; b=5QfGF7Twg0+Q1c/qsnnMpvQrEoNCxtcZcvFmHcbJTNudBBTyOC9jGDN4pLdmyvI7qil6RvinC W1eWz15oOzOB7ZoBQR4zIRQl6ZDc8JgIRIPGAuABUI1Oceo15ESS+IT X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:1f4::12) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) 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: DU0PR04MB9417:EE_|PA4PR04MB7744:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hVFlMhT1tmvR1DyaObPqn2D+EETYMbrT1B4s5shWl8Ute7f5JE58xDoLf2KgOJwPPGRD9vu3y4zrN1yMNswq0si31flg1NaRG1gsiVhpIH6gqusAJ412ZwThTh0eZ/pgJYiddlDtCXBQ0/xY4OX0gGFF/1QnI/UfB1TlwvaUi4Y1V3H4K8m8p9u/ltfOTyJ1E/ROvYrwPB3925cIy+5I4ub2fKwEjP6J0QaKSX1d75ZpxzYV6K41uCJ5F/9TAbQfj6JcIJcx0Wx1Mq+32Kromvs/qC1nBfVZKvegPLUTgphVh8DrayGqZY+1og/EvkqZaBmzySM+XX9wWPMTu4/ga8REkOMkQyPdlw1d2vL8AvRPPOkJS7FgfvADU4ysSI/m61bJ1DFBbw8G8g1hHJdbQ3xHXJArHjeEwUW8gstMtBa6e1Ga+mkDlHfRuyOPiihia2ilF9Wp2VL/52NFGjNdrK1e4hoDp22FHwBEo55C/cEeXAG2zMuQCuhxmJa9cKgNkfAAW+8aFd5kU66yecvdvonE39rRxA58P2sE9W/iS3yy8mgMvzF1X8CWX1ehzJJxvbHz39W3OSe//wLvR/tILzyf9sHr9BujyeSYiWFZmY93KdkOm4mXhfHZ9BGCYl5N5GNpnavtiewsvLbgTFhT7Fyc3wnpjJyIxhed9jaLk3o= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(1800799015)(52116005)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?eVl9/RiWeY7QBEbO0XxyVZY7vuCk?= =?utf-8?q?Xu2T4Miyan+jvSBfnXfwVKpeDplPjXrzM6Yv6aguHdA8MQzr5VfN5OvVlTqt5bGIF?= =?utf-8?q?vPJXVzUgqIa43sbt4JRIswH6Ke5tXa2TyxIFlcXLHk1ZVW3TF+OkY+PrOAq680ykG?= =?utf-8?q?OyZP59YHtHWTcF4wl+H59r142kS4tvPDexhdXj/tTLvTRXH7sv3EJVfva65AWeK1g?= =?utf-8?q?/CUl7NIVpqTMpdO6JX9A2p6F50RA2APlIBnMLq2l9OTMGx7j19Pi//IXxEbha3bDR?= =?utf-8?q?V8rzUD963guAU81sH/RnEDhAe/ZyLxvNV0tSiRdSVweLTIo3AZL6YWK1jhjHA4yrf?= =?utf-8?q?oC7rVcab7bb0Q291hh1mF8H+zN7iD5ftNNpCM0acB8dgzS02zg9kIZJxnS2V1mm8z?= =?utf-8?q?COjhi78mkvnp4aQ7LAs4W4OzYKH1Y8eQBEpwJ6TVTmIw1W34tfNVcB574rw2o1BO0?= =?utf-8?q?4Hhy57dgj69so+6DLvbsNGcPcU3fcW8kQQcU0pHjPEedCZ2bxrl/Pd+dA3fuwsT6N?= =?utf-8?q?RhZkxImGAGCudnU/uAOr0DnxzaDQqazHhENMc7Mo7f27yv5J6e20R81zqaVVHiCiA?= =?utf-8?q?u3FdgJQ4etxKm0jZF6ugfabpd91WiuynnrzNxmnFgTmpxQxuaJIWneeUkCMJmwADx?= =?utf-8?q?9AolYc5aPuc2L19aZisCov2ahQ5SQHmYL0CZOIVBhby5ZDhCnkH1NqBfJIyUScJJQ?= =?utf-8?q?r3jaDyBpjua/cAt0+ehxR4ZnBGIjpms35I2dPkw+dZiwEQXRzgLn2FDzAjWF2wI0u?= =?utf-8?q?o0Efb7b3oFQ3snOZqKsZlXdo/C4o1Cs5dh1Z10YkBFbTq0jS8Y/ci4+RYgapemdz/?= =?utf-8?q?cs2OvJjquZz4N9mHpbgfvdj+O8SfpIrHAZ9x140xFRpsKuCzxfIrp69r9xDx8XodV?= =?utf-8?q?ONJW0ghjnQLpbcdEKEQaP7LsGV924JcAb9tRAndX1VQmIkk6nq1yso+YpxrBD6u+Y?= =?utf-8?q?5VjJIKcbUy2olA9rrMLRXfNXRKHOqnVCtdZvOdaciwkwnbi8DfvHEzPFzTnHwjD2J?= =?utf-8?q?I+ZqROdPygQsj9/OwnTsHSaSDpFgm4VHjA4G5oH9MtbAaH9dx7/gsoqa+Exa3PH7V?= =?utf-8?q?o58bR3+RBbi9B4agmJec4o5fE+tAd4LWZZT5wgeop/9GBj+ky0g0clvMbthoEZbbT?= =?utf-8?q?fQEgXTscV9wUMagiDSSYMBfpgnekaJCx+Qb1WLIPLcCMpKH+gOJwn5mMyyk/H68qZ?= =?utf-8?q?MqeqbG9ZciGOVup0AGfw2tsqgBxkvj4/Epnkdnbiaw8wIfTA7qyoUzp7e04Zr7N6Z?= =?utf-8?q?bjVXRin0l/rrVPUFQTohnwBYpQ1FVSDnEnbr70StGSesqwZW/ZluCo5/JdUoTCbJY?= =?utf-8?q?C1tHbeYfqJBGXrBetgw70g2KyWtELb3w3elzarb9PPAGJXy07XQUvgd9I1WY270rL?= =?utf-8?q?9meqXl48vPQ02Ytw6ntiM8qFUY8+pO0ucRRQcP66Y34zyAgUejD0n1Z909AX6Q9fS?= =?utf-8?q?kik9LZ/BTJQuORYNHnHDh6lRVwTh8JdpTO6HTUa1bXx7s7bjb2GLJ133Mor2bAsX4?= =?utf-8?q?B/0bZVgrgcE2?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: efc710a7-cf80-4204-206b-08dc556c5b96 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2024 12:31:46.2833 (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: +VwKrp1SZfiJx2a22SI3Rj9uxZna7RA9jswX62V/GV0BVg9NqKdV+4hJ1ugJm6pw7tdcISxijel2IgS+zuvhtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7744 From: Peng Fan Add i.MX SCMI Extension protocols bindings for: - Battery Backed Secure Module(BBSM) - MISC settings such as General Purpose Registers settings. Signed-off-by: Peng Fan --- .../devicetree/bindings/firmware/imx,scmi.yaml | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/Documentation/devicetree/bindings/firmware/imx,scmi.yaml b/Documentation/devicetree/bindings/firmware/imx,scmi.yaml new file mode 100644 index 000000000000..7ee19a661d83 --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/imx,scmi.yaml @@ -0,0 +1,80 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2024 NXP +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/imx,scmi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: i.MX System Control and Management Interface(SCMI) Vendor Protocols Extension + +maintainers: + - Peng Fan + +allOf: + - $ref: arm,scmi.yaml# + +properties: + protocol@81: + $ref: 'arm,scmi.yaml#/$defs/protocol-node' + unevaluatedProperties: false + description: + The BBM Protocol is for managing Battery Backed Secure Module (BBSM) RTC + and the ON/OFF Key + + properties: + reg: + const: 0x81 + + required: + - reg + + protocol@84: + $ref: 'arm,scmi.yaml#/$defs/protocol-node' + unevaluatedProperties: false + description: + The MISC Protocol is for managing SoC Misc settings, such as GPR settings + + properties: + reg: + const: 0x84 + + wakeup-sources: + description: + Each entry consists of 2 integers, represents the source and electric signal edge + items: + items: + - description: the wakeup source + - description: the wakeup electric signal edge + $ref: /schemas/types.yaml#/definitions/uint32-matrix + + required: + - reg + +additionalProperties: false + +examples: + - | + firmware { + scmi { + compatible = "arm,scmi"; + mboxes = <&mu2 5 0>, <&mu2 3 0>, <&mu2 3 1>; + shmem = <&scmi_buf0>, <&scmi_buf1>; + + #address-cells = <1>; + #size-cells = <0>; + + protocol@81 { + reg = <0x81>; + }; + + protocol@84 { + reg = <0x84>; + wakeup-sources = <0x8000 1 + 0x8001 1 + 0x8002 1 + 0x8003 1 + 0x8004 1>; + }; + }; + }; +... From patchwork Fri Apr 5 12:39:25 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: 13619011 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2105.outbound.protection.outlook.com [40.107.14.105]) (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 4C2FA13BC36 for ; Fri, 5 Apr 2024 12:31:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.14.105 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320316; cv=fail; b=tSU7YyXEfk1vlnKpw0DoLh02xqryv1RfW8O7gTyXo4L9gr7hOIeptT0085ooofm5QvUVWx2QfMJB4D8ATLzCWCGJXSwg+Rwz1FNtn0I3QWQPt3wTTfQm676usCfT1boeQWLNg+FjDPatm5h91RnbLv2XC1uOdGl8cFau57uXF6I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320316; c=relaxed/simple; bh=Pb9SysegyYE0kNRoVfJpPtma28bQmPtlD+aoy+bIel4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=tl5NM2HD4i3LnXb7tcXF0tk8T0eqSGNxjPj7VVxxY4bYLdDn+SBAwrtc+zwzI+bi6Ssi0OEkG3vV2SsXGKyWZVDgKdhbG2bgLmOO6eAO80dPusXADNxWNQrErkHWL8JFbdKM6VUrRUL1BAWKNWfKy2thNJbZImYVxuMRKYSCtI8= 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=HqFbqaLQ; arc=fail smtp.client-ip=40.107.14.105 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="HqFbqaLQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TndyTur/Md4JNFQsM6AiE5/inr88+tsVSVpVxPzgXoFxOtMubo9RuB+EjJVctnlGy42j/LqgmVnIIOikHVa2sePmhAJalU8O4gPQYlon3vkvSY/tqvEEZ4ISMRsaz5XW3KKhHQBbSADMeTBRbAdWYtvznmTEpg65HzwYx8dgHFKbsnW0ayzOk3Dd8pxC+wPSlULgXyeZX2bdsgq28jCYLEL1ZYJegPBSRh3RCPyqMFcMO4aHBFkeekFBPba1CkN8qfh93lHkQxn+ecszATLjxK1Oq+8tFjCi4RMyDWfyS3gOS20U+Ze23DPbrNmQ5RL3eIv1QrMQAF1xCp1VzrP5Pw== 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=DneiBipWLSqto+cMFsG+2hNqPiVlCSkqIUslw3YnNwg=; b=RV1AItWOgwqr36iGHefJlyGpdKAjZuFLOO1X0Xt7vwfTQhKXfAb4paChDNCIrA53fVlup2pIc3kpJoFTcto75NxZn4J4eAVehVT1KoTG/DIWY2ulItfwBDLS5KJ3SwS/c5h2MMoDLI8nWoY+gPxYMf/MbbrM2CBFnn1EV1Zo2ZiCUZdUGTdmBH8zLUIFoF1nUqxci7uUg9+0Z0Iuwhf734aS90Om2SrZ/PGDugbD9v294ox6nju7kyMMi918/m9HWWfjYYyN7D5eISqpPOueIOthZ5hLbcms4FDjszIXg9dX0zgNKMEYvLXujmlaNuyAJd4wdNNwE3ozGm54R2McHA== 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=DneiBipWLSqto+cMFsG+2hNqPiVlCSkqIUslw3YnNwg=; b=HqFbqaLQaCjU6dKCz8kQ3tGYFQSu4FdMd9YaRPB5IwCFZsXUFJ4ZeAFkGnKy6leREWDwvjzP8alRmLdSPk0RLNrTeHf9gEjudbbMkPw/JGXZNqUiS/EZc/+UGabv2BdjKmpt/kQpAHQzlHTxT/XL7PRWs/nLF44aWcg2SQeLC1w= Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7744.eurprd04.prod.outlook.com (2603:10a6:102:c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 5 Apr 2024 12:31:50 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7386.037; Fri, 5 Apr 2024 12:31:50 +0000 From: "Peng Fan (OSS)" Date: Fri, 05 Apr 2024 20:39:25 +0800 Subject: [PATCH v2 3/6] firmware: arm_scmi: add initial support for i.MX BBM protocol Message-Id: <20240405-imx95-bbm-misc-v2-v2-3-9fc9186856c2@nxp.com> References: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> In-Reply-To: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi Cc: Peng Fan , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712320792; l=13006; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=f8vlPBXn372rggvzOyHbJ5Zxx2+A6HQ7e1t5EnI+uH8=; b=hrRd/zOB9wRTivSfoEAYrbEX1SEt231GmG75/CkvGJ9wItgxh2FqbadqghFhnY3u/fOaFbGUQ 3ubU1s8sv1gBXUFPcRvPhvz9Nqzgs6FxXPpYSknpVbxbjy7wjLeX9OJ X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:1f4::12) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) 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: DU0PR04MB9417:EE_|PA4PR04MB7744:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P8GnPa61LeF/+GL2I/OmH5YSRPD7XviWRGDCE8mV3EjSa33pPWm3EO+dWV32YPWz4/pROfAPoR37X2VeSIOspRac9dKzA9pYZy+MGuX7mIA7btMwS5rO07rY7RFyOeH/p0g9AlBPjvIYWN2oMc2Z5ZbHD8NiYwM2kdJ6heLwsy7b/3/PDklghYsrxugbDGssyWAJvGJPHjVGYX6VPIAfGbwwGjTcTM2UGcq4RUUILfqToHPtDPFVWkR4QKa+KXYH8MvruHbdGN3TODwUNwO61Y5bPKiy2fdvJ/HYfhXKMelT9Fzpv8aihH3dHTUS+86PcA5Uzn6OkZ2jeizshL4pVKlnWB391ZWuLme4QDPPh4RWyQyc9PYXdanpUzeC5wwCq2zuabgyfewWiQSt5etqCCW1ao5Dmb6x8K2QTVhJUNZZt25fPssg2zkrwkOT+5KpmCzRHSARaxqIHXc3o392A6Tpa29PQcpqIxcZJpKEAiVPzk1N4Q02c3RjAObXYAL3Bp3rJNzNpKJxSbFF6VyvSzPVTAMUBfw4LinhyEqQTbiUizHk5yDrArfS4NDWshydZK5UhAfi7eAHt7xMWMQuIg1dknDs66QCPmx/w647j4EI3Mj5Wo81HwsnY7QjEPDaxeZK7iH2/HsOdFHINbFM3R1PYLYT9q+vFjGgNrboGF5LxquKQeGuiI0WBPC5AHzbHZynblGCKj/frz5hW66gwduAdZcfb3N2f2SWsOQI0RE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(1800799015)(52116005)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?V2qzPrEJdrhiyoeJ9dTdCnOa3G4b?= =?utf-8?q?7kc/SgT1HYRBKraPHkbxyhdtiaNilvyB6t0OnIzVWh5wlJ7iZF7iQ+AiMuWWJ7aMX?= =?utf-8?q?EwVR4/URTzBiAPUXuIZm7DoPRVsNxwhA1wKKeAQ+YIRvA41W9IChC2mP5Jst8Bf4x?= =?utf-8?q?8kNlc7x8EBPpeo6ejUq2I+qua0nOypKjxqhZYmYxT3Nq/XS3aVvhrGDnN1F95y0+a?= =?utf-8?q?5GFuwUvzsVjJhZYRkAme6L6VzCCHGlu/JtwW00/mc2P17uPa7BlZyFjAYvWxJCv4/?= =?utf-8?q?a97G4z41eTDEkyHKMXrud4Kj5+MPRBQjyaG81KfVgKShdPHdh9/MlyWuTfz8I1vFo?= =?utf-8?q?kE8o8G0YMr36esRGzLFjNA0Rz0QmaUYy3gMoAT/chBSXWiT0bmmrtFM25TiEMJC13?= =?utf-8?q?cF+F2AkFGobewLn0MR+JwaJb8acubMwU0LjXdEdru1E42IDl9a0R75aRfspcchMbm?= =?utf-8?q?ZbD7LkQP05BSoLUZcczFt+1sq9voFXIjvSzV8WPr1gnnbGkYuXT9cgNQu+uHD1/4F?= =?utf-8?q?uCWjSZrzap1cFfFiUcyPQKvS5mtx/bwyYnkEbEvxVmaLwplmFHeWy6i98+zys1mvE?= =?utf-8?q?L667/Vo/QWzQpvh5MkSIjSZsqZDDvV4DPc1E+E/ToxfesVhsvMSPhd51U0gJ3ApJ3?= =?utf-8?q?es62hwS+JoiMbB0ZlF0ueVeU0C4otVixVp5XZLSUeO4FIjA4DOZ5BMvQdTTQqeaNM?= =?utf-8?q?9NjQNnDBdKsEw7pd6KFSPgm3vnDvcUPQSffGcK3MOnWAKi9orjCirhuiNUfSAbPn7?= =?utf-8?q?IN8LTRoNQgUXK2FN9JrN6zARudEjpmW6n8i9JVGYqLTiwHRXdXFGUeZRtvfEonzeU?= =?utf-8?q?KEz/FdUNn6D9HaQhNMeE74CArK1M6BBr6SBD1Ax/qlp6MENaDpQhFo8ZBDcdC6Ln8?= =?utf-8?q?4cBDiceYe79b4IvlT1Q4Ui3MXHki+PN5k/yYKP/BnqjuVsCgXsKeHwpoaTNrYiETQ?= =?utf-8?q?Av6qWH2EVrngN1cCIRBxWienZoq6fh47sW7Yqj8ZpC2H5UBb88RKC2lWZqd9N0QYP?= =?utf-8?q?LaUDptcTCSXUHHBynJYba3CcrtuMb5Gi+3PiFyfwgfrToiNWCCITuMBjiHz1XouL3?= =?utf-8?q?+0+7efvphknG3PvB+zqbOSxqGcI7GLl0Mf3elAEjBRpw9OnUBZ7jOV3HDtKEVTSmy?= =?utf-8?q?543gkL3otEuo33aV6t+m25QZX576KPCDuAY2VSEesH6YnpN9w7+qoa7ziwMckb1TG?= =?utf-8?q?Ac/1vzPE6ZDqx8AatjfxpMX15WnEXuCNihCZd/cZTCZDQXPyLg+KDEa+ZC/fAXbX/?= =?utf-8?q?lOZBo8N7aDE6T2WhHI4zayGc++sfz1VIkHX7BYW+GA1eqAlwSq2hGv3+stpQPSu4w?= =?utf-8?q?yq8DpvonYyIPkIQ2uf5DZNgp6asu9x5PyfG8vz5atJg72csvNyMgrPXwxcF17W23w?= =?utf-8?q?YUP9SNIgrrM4a2PxwfeYIhP9kePNOXMo/yTUcsMrSeVf9eafuC+4KxnLav38WWv0D?= =?utf-8?q?5KhQ//hDbs96U0DelwTUfyDbhgB8XaebG8ceYDQHYAqGBjpnyAKvW+YDhVfoUvtyz?= =?utf-8?q?nIN6m6XL84Om?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 89a700ed-04c3-47e2-34f9-08dc556c5e39 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2024 12:31:50.6935 (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: wEgqRkLBZ1kwvo31rdRBSqSrVHpNPiX0nKPMAaZluWMgLWKosOSIFgVSHGfmrIydU0xoLR1EB74b7CtE/aAbMQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7744 From: Peng Fan The i.MX BBM protocol is for managing i.MX BBM module which provides RTC and BUTTON feature. Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/Kconfig | 10 + drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/imx-sm-bbm.c | 378 +++++++++++++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 45 ++++ 4 files changed, 434 insertions(+) diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig index aa5842be19b2..56d11c9d9f47 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -181,3 +181,13 @@ config ARM_SCMI_POWER_CONTROL early shutdown/reboot SCMI requests. endmenu + +config IMX_SCMI_BBM_EXT + tristate "i.MX SCMI BBM EXTENSION" + depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) + default y if ARCH_MXC + help + This enables i.MX System BBM control logic which supports RTC + and BUTTON. + + This driver can also be built as a module. diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index a7bc4796519c..327687acf857 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -11,6 +11,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_HAVE_MSG) += msg.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += optee.o scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o powercap.o +scmi-protocols-$(CONFIG_IMX_SCMI_BBM_EXT) += imx-sm-bbm.o scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y) obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o diff --git a/drivers/firmware/arm_scmi/imx-sm-bbm.c b/drivers/firmware/arm_scmi/imx-sm-bbm.c new file mode 100644 index 000000000000..92c0aedf65cc --- /dev/null +++ b/drivers/firmware/arm_scmi/imx-sm-bbm.c @@ -0,0 +1,378 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System Control and Management Interface (SCMI) NXP BBM Protocol + * + * Copyright 2024 NXP + */ + +#define pr_fmt(fmt) "SCMI Notifications BBM - " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "protocols.h" +#include "notify.h" + +#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x10000 + +enum scmi_imx_bbm_protocol_cmd { + IMX_BBM_GPR_SET = 0x3, + IMX_BBM_GPR_GET = 0x4, + IMX_BBM_RTC_ATTRIBUTES = 0x5, + IMX_BBM_RTC_TIME_SET = 0x6, + IMX_BBM_RTC_TIME_GET = 0x7, + IMX_BBM_RTC_ALARM_SET = 0x8, + IMX_BBM_BUTTON_GET = 0x9, + IMX_BBM_RTC_NOTIFY = 0xA, + IMX_BBM_BUTTON_NOTIFY = 0xB, +}; + +#define GET_RTCS_NR(x) le32_get_bits((x), GENMASK(23, 16)) +#define GET_GPRS_NR(x) le32_get_bits((x), GENMASK(15, 0)) + +#define SCMI_IMX_BBM_NOTIFY_RTC_UPDATED BIT(2) +#define SCMI_IMX_BBM_NOTIFY_RTC_ROLLOVER BIT(1) +#define SCMI_IMX_BBM_NOTIFY_RTC_ALARM BIT(0) + +#define SCMI_IMX_BBM_RTC_ALARM_ENABLE_FLAG BIT(0) + +#define SCMI_IMX_BBM_NOTIFY_RTC_FLAG \ + (SCMI_IMX_BBM_NOTIFY_RTC_UPDATED | SCMI_IMX_BBM_NOTIFY_RTC_ROLLOVER | \ + SCMI_IMX_BBM_NOTIFY_RTC_ALARM) + +#define SCMI_IMX_BBM_EVENT_RTC_MASK GENMASK(31, 24) + +struct scmi_imx_bbm_info { + u32 version; + int nr_rtc; + int nr_gpr; +}; + +struct scmi_msg_imx_bbm_protocol_attributes { + __le32 attributes; +}; + +struct scmi_imx_bbm_set_time { + __le32 id; + __le32 flags; + __le32 value_low; + __le32 value_high; +}; + +struct scmi_imx_bbm_get_time { + __le32 id; + __le32 flags; +}; + +struct scmi_imx_bbm_alarm_time { + __le32 id; + __le32 flags; + __le32 value_low; + __le32 value_high; +}; + +struct scmi_msg_imx_bbm_rtc_notify { + __le32 rtc_id; + __le32 flags; +}; + +struct scmi_msg_imx_bbm_button_notify { + __le32 flags; +}; + +struct scmi_imx_bbm_notify_payld { + __le32 flags; +}; + +static int scmi_imx_bbm_attributes_get(const struct scmi_protocol_handle *ph, + struct scmi_imx_bbm_info *pi) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_imx_bbm_protocol_attributes *attr; + + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, sizeof(*attr), &t); + if (ret) + return ret; + + attr = t->rx.buf; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + pi->nr_rtc = GET_RTCS_NR(attr->attributes); + pi->nr_gpr = GET_GPRS_NR(attr->attributes); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_notify(const struct scmi_protocol_handle *ph, + u32 src_id, int message_id, bool enable) +{ + int ret; + struct scmi_xfer *t; + + if (message_id == IMX_BBM_RTC_NOTIFY) { + struct scmi_msg_imx_bbm_rtc_notify *rtc_notify; + + ret = ph->xops->xfer_get_init(ph, message_id, + sizeof(*rtc_notify), 0, &t); + if (ret) + return ret; + + rtc_notify = t->tx.buf; + rtc_notify->rtc_id = cpu_to_le32(0); + rtc_notify->flags = + cpu_to_le32(enable ? SCMI_IMX_BBM_NOTIFY_RTC_FLAG : 0); + } else if (message_id == IMX_BBM_BUTTON_NOTIFY) { + struct scmi_msg_imx_bbm_button_notify *button_notify; + + ret = ph->xops->xfer_get_init(ph, message_id, + sizeof(*button_notify), 0, &t); + if (ret) + return ret; + + button_notify = t->tx.buf; + button_notify->flags = cpu_to_le32(enable ? 1 : 0); + } else { + return -EINVAL; + } + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + return ret; +} + +static enum scmi_imx_bbm_protocol_cmd evt_2_cmd[] = { + IMX_BBM_RTC_NOTIFY, + IMX_BBM_BUTTON_NOTIFY +}; + +static int scmi_imx_bbm_set_notify_enabled(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id, bool enable) +{ + int ret, cmd_id; + + if (evt_id >= ARRAY_SIZE(evt_2_cmd)) + return -EINVAL; + + cmd_id = evt_2_cmd[evt_id]; + ret = scmi_imx_bbm_notify(ph, src_id, cmd_id, enable); + if (ret) + pr_debug("FAIL_ENABLED - evt[%X] dom[%d] - ret:%d\n", + evt_id, src_id, ret); + + return ret; +} + +static void *scmi_imx_bbm_fill_custom_report(const struct scmi_protocol_handle *ph, + u8 evt_id, ktime_t timestamp, + const void *payld, size_t payld_sz, + void *report, u32 *src_id) +{ + const struct scmi_imx_bbm_notify_payld *p = payld; + struct scmi_imx_bbm_notif_report *r = report; + + if (sizeof(*p) != payld_sz) + return NULL; + + if (evt_id == SCMI_EVENT_IMX_BBM_RTC) { + r->is_rtc = true; + r->is_button = false; + r->timestamp = timestamp; + r->rtc_id = le32_get_bits(p->flags, SCMI_IMX_BBM_EVENT_RTC_MASK); + r->rtc_evt = le32_get_bits(p->flags, SCMI_IMX_BBM_NOTIFY_RTC_FLAG); + dev_dbg(ph->dev, "RTC: %d evt: %x\n", r->rtc_id, r->rtc_evt); + *src_id = r->rtc_evt; + } else if (evt_id == SCMI_EVENT_IMX_BBM_BUTTON) { + r->is_rtc = false; + r->is_button = true; + r->timestamp = timestamp; + dev_dbg(ph->dev, "BBM Button\n"); + *src_id = 0; + } else { + WARN_ON_ONCE(1); + return NULL; + } + + return r; +} + +static const struct scmi_event scmi_imx_bbm_events[] = { + { + .id = SCMI_EVENT_IMX_BBM_RTC, + .max_payld_sz = sizeof(struct scmi_imx_bbm_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_bbm_notif_report), + }, + { + .id = SCMI_EVENT_IMX_BBM_BUTTON, + .max_payld_sz = sizeof(struct scmi_imx_bbm_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_bbm_notif_report), + }, +}; + +static const struct scmi_event_ops scmi_imx_bbm_event_ops = { + .set_notify_enabled = scmi_imx_bbm_set_notify_enabled, + .fill_custom_report = scmi_imx_bbm_fill_custom_report, +}; + +static const struct scmi_protocol_events scmi_imx_bbm_protocol_events = { + .queue_sz = SCMI_PROTO_QUEUE_SZ, + .ops = &scmi_imx_bbm_event_ops, + .evts = scmi_imx_bbm_events, + .num_events = ARRAY_SIZE(scmi_imx_bbm_events), + .num_sources = 1, +}; + +static int scmi_imx_bbm_protocol_init(const struct scmi_protocol_handle *ph) +{ + u32 version; + int ret; + struct scmi_imx_bbm_info *binfo; + + ret = ph->xops->version_get(ph, &version); + if (ret) + return ret; + + dev_info(ph->dev, "NXP SM BBM Version %d.%d\n", + PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); + + binfo = devm_kzalloc(ph->dev, sizeof(*binfo), GFP_KERNEL); + if (!binfo) + return -ENOMEM; + + ret = scmi_imx_bbm_attributes_get(ph, binfo); + if (ret) + return ret; + + return ph->set_priv(ph, binfo, version); +} + +static int scmi_imx_bbm_rtc_time_set(const struct scmi_protocol_handle *ph, + u32 rtc_id, u64 sec) +{ + struct scmi_imx_bbm_info *pi = ph->get_priv(ph); + struct scmi_imx_bbm_set_time *cfg; + struct scmi_xfer *t; + int ret; + + if (rtc_id >= pi->nr_rtc) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, IMX_BBM_RTC_TIME_SET, sizeof(*cfg), 0, &t); + if (ret) + return ret; + + cfg = t->tx.buf; + cfg->id = cpu_to_le32(rtc_id); + cfg->flags = 0; + cfg->value_low = lower_32_bits(sec); + cfg->value_high = 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 = lower_32_bits(sec); + cfg->value_high = upper_32_bits(sec); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_bbm_button_get(const struct scmi_protocol_handle *ph, u32 *state) +{ + struct scmi_xfer *t; + int ret; + + ret = ph->xops->xfer_get_init(ph, IMX_BBM_BUTTON_GET, 0, sizeof(u32), &t); + if (ret) + return ret; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) + *state = get_unaligned_le32(t->rx.buf); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static const struct scmi_imx_bbm_proto_ops scmi_imx_bbm_proto_ops = { + .rtc_time_get = scmi_imx_bbm_rtc_time_get, + .rtc_time_set = scmi_imx_bbm_rtc_time_set, + .rtc_alarm_set = scmi_imx_bbm_rtc_alarm_set, + .button_get = scmi_imx_bbm_button_get, +}; + +static const struct scmi_protocol scmi_imx_bbm = { + .id = SCMI_PROTOCOL_IMX_BBM, + .owner = THIS_MODULE, + .instance_init = &scmi_imx_bbm_protocol_init, + .ops = &scmi_imx_bbm_proto_ops, + .events = &scmi_imx_bbm_protocol_events, + .supported_version = SCMI_PROTOCOL_SUPPORTED_VERSION, +}; + +module_scmi_protocol(scmi_imx_bbm); diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h new file mode 100644 index 000000000000..90ce011a4429 --- /dev/null +++ b/include/linux/scmi_imx_protocol.h @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * SCMI Message Protocol driver NXP extension header + * + * Copyright 2024 NXP. + */ + +#ifndef _LINUX_SCMI_NXP_PROTOCOL_H +#define _LINUX_SCMI_NXP_PROTOCOL_H + +#include +#include +#include +#include + +enum scmi_nxp_protocol { + SCMI_PROTOCOL_IMX_BBM = 0x81, +}; + +struct scmi_imx_bbm_proto_ops { + int (*rtc_time_set)(const struct scmi_protocol_handle *ph, u32 id, + uint64_t sec); + int (*rtc_time_get)(const struct scmi_protocol_handle *ph, u32 id, + u64 *val); + int (*rtc_alarm_set)(const struct scmi_protocol_handle *ph, u32 id, + u64 sec); + int (*button_get)(const struct scmi_protocol_handle *ph, u32 *state); +}; + +enum scmi_nxp_notification_events { + SCMI_EVENT_IMX_BBM_RTC = 0x0, + SCMI_EVENT_IMX_BBM_BUTTON = 0x1, + SCMI_EVENT_IMX_MISC_CONTROL_DISABLED = 0x0, + SCMI_EVENT_IMX_MISC_CONTROL_FALLING_EDGE = 0x1, + SCMI_EVENT_IMX_MISC_CONTROL_RISING_EDGE = 0x2, +}; + +struct scmi_imx_bbm_notif_report { + bool is_rtc; + bool is_button; + ktime_t timestamp; + unsigned int rtc_id; + unsigned int rtc_evt; +}; +#endif From patchwork Fri Apr 5 12:39:26 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: 13619012 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2105.outbound.protection.outlook.com [40.107.14.105]) (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 EB00B1649DB for ; Fri, 5 Apr 2024 12:31:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.14.105 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320320; cv=fail; b=fdsLXBlHesFPiGb1V7NLzvlY7RlIPrHf18waFaR0RAFRtXSLfofg7OC88Xm7qH1cukcmLNP0H+TGbuvikpLlUAxng2xdT9zoOjOK97TLkK5KoTe8IBKVdLd0mygBtrVYCGGJWVEm/u6LgrMDNM6s3pph7X2XEbcx5jVhIywR+zg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320320; c=relaxed/simple; bh=gXR57Xut5a8ONa6Atrdt+b0uy3ceNM/RhwV1jyV72ds=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=FFExXWNZ0hzFr7yR8FuCG111Ai/jQ6nwJ/gupdxO4EbKcR7SdAwOat5D5zHxbjwj48kd9gDl1wmduae5V6TMIFQq7mDfCbZM9/FtT0vr2Z5plgi1tGPeR+o+WdU4LNqMs5qnm3YJpurInHqA84J+ENxBrlZOhB1zcM5LH/hQXwU= 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=Ht0GXMeb; arc=fail smtp.client-ip=40.107.14.105 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="Ht0GXMeb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ONdWn7swiRA54sUpikZXF+QZuoMC8g8zn3a600GRlZC30svFvW7yjnA5cLPXlXC4eOrOi7Hidgm10ieiFOXAQDrmVvCrbu76f8M3MPZgXMaEAToXVqLkoDwb0FaMVAxyHXAoaIqiFHbq4cWpp+4iuuBbsGj8DX47efJLnvIY5Kf+KCMbLCQfb6Gy5YVHziYEeADpaQh7HsozUEhpqpC9ZnAltZwPgFqy85ackFk4Kr7yD0JZYU3Pna3pwTT38el0yO2i0LcQMghEBFrmnQvvwUpuRNGqHgDP5hQQOBfrYht8ne9x4na7/27nq1BlGrlT7J1lwPAP4o6V6QA8H+prRA== 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=s5Rvxu6VWR+sA8gXWI+TbHy2yE4Vhh5l648QXsDxvRM=; b=f/3AP0l++fKSKcGT/K7DaOTm+yu+tv0YL0W2VzwCOYJg4tuCpP7nJ8WVK9ynnDksADl7FK6YGK4cwUBEW9yHBj6tSyrkSDzPHI1kjwlhvp+4fCH3lWjmy3XKjQIB5UDXmpgAimLFuXZK1aEzLSaai4cVSPaw8B+tE6niXyBOqkRSKtADcdI0w181Ovjaog2Ph3xIhO/MOla2L/Z4Yxa23YLGhG0wE6+LqFHGbkUudy24zWoJhIFPHt1C0eA4xty1f4Ta7HgTueju5dT6ixtictN5tGMAFUg4QHdJEbElfyBElVH5Bpnj6CTdDjVJlNRd7N8/bKlW6rq+cKUlHUyfBQ== 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=s5Rvxu6VWR+sA8gXWI+TbHy2yE4Vhh5l648QXsDxvRM=; b=Ht0GXMebaAD4/zu+354zodaoN9rLM0QNeFt2LdDMUdy3F5yAy7Y+L8aPFE5v3yOxXaFVqN2TW9EZT00iJgNuUWyXSB1S69BJIfQVfjFAnqB60tiHbWQJ3N9qYUhq6l1oFNSf5nJkWlLRtm7Ub1W2suXskzaOpEbmW+vgENlGJJg= Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7744.eurprd04.prod.outlook.com (2603:10a6:102:c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 5 Apr 2024 12:31:55 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7386.037; Fri, 5 Apr 2024 12:31:55 +0000 From: "Peng Fan (OSS)" Date: Fri, 05 Apr 2024 20:39:26 +0800 Subject: [PATCH v2 4/6] firmware: arm_scmi: add initial support for i.MX MISC protocol Message-Id: <20240405-imx95-bbm-misc-v2-v2-4-9fc9186856c2@nxp.com> References: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> In-Reply-To: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi Cc: Peng Fan , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712320792; l=10991; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=rrwtI122rbdiOSHcoQ2WEjSVLO8kCScFoHvALXkpUaY=; b=8pE4c7enfC7R06e7yxYJe18mFkJKnIckLHzsu/npK1ghcbL16r7XRNgm0VfWGirDF/GDxSYZt qj15SWy99yoD/jUAbG4hkkD+rXUmjGW86u6EN48pE4Ncky0sTZ1cTxX X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:1f4::12) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) 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: DU0PR04MB9417:EE_|PA4PR04MB7744:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +IUiZ3/W8x4xBj4VBQEsKXHWwgDuj++PGXyKd2KdLANZ11QVBcPGbxLf7jSc0nTRarUDp/ohB6enWjSrSDdFqlM3djQjMHYtncQjx7JjUrpumLH5UIBkqkEl/S+v39+Ex0Yae1pzDcmsRx4QwKt5fEkjVu/RrmopkKdTvvlEsPtN24124EhscMZM07kiGzRezyPEFamPmkgDWo4PoNiBeHtkdZdRolwdkgn/bpvesNFhRsg0R10Gj2QeYXSC44lzhYYiNZQFBVX3DuqXaycmFxsfN4k68A13941U0cS4rOeGFpIJ0yDE+yQM4EZ24PLdXhGnHIuDZDcjUAE1WaeuF+TjI7U36lxabONv/Pio9Kt009l7CX35G/OykFk6Gcvx8iBGfmHJgqyKrpM4AJbLlDmv9zj0MtDHeyBcP1+ZU+KTWs0M35+56YuP1TRgBcTwnKmjJV70UXNG9FOa9QYjkQNa78FSWdzyzpnM17MyuD03d1lcdrKY1WUVybWS+63GVNYkfO16l+6feXIWvzxM7suknsFexdlkIbXAhnaXcEIB7y05zezu0a8nZyaJFOU/G1HH0e9jcz6Y3eFvyEEhsi3zv8ArZbOF4zHsglhAtKzEbfurt+rrbn0byixU3rZ7d2tOERny13FDcppwwetB6Q/AghGJM7B3acRB8+OI8gQ7C5a+QyuuDOyCyYZ85tcGFMoPbI1uKNE5AXsS6kdvNwp2+U5N/KKqck8VqgUNDrg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(1800799015)(52116005)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PQ1au58sVtS/KBDYaoD8bt+L+An8?= =?utf-8?q?+3qhsDt436V/jbYccdCDr+kaPh2+1Mj0FZtaRzoJ2IrOQRsd13JKsCiiAEZ9/iIeH?= =?utf-8?q?AxJ9yA5vvipzw2dsWrRk0fwOrHfw1mJd1LvSKRqWaFJKvb3dxDaxZD8oIZV7qDmO7?= =?utf-8?q?17Mm7odSRR5uUU7l4dNWxaS81FDoRspIDOQX9zap2nXooQpNEaYr7z0qjSqWLmYQB?= =?utf-8?q?3Iy1f/MbsTyedxs3PKdXLmsiEGnYKG0jyNZCSHpFDmu3YFGfd/Cjx16NbvWMLA2w3?= =?utf-8?q?jGgDJE8jEQSSEpDJ+fXnUM1Bm7Fpl/LOjCL4QrjNF0SuJ4CiQDs6R8be35V64zwHc?= =?utf-8?q?AHUTlL2FG9HoxnDtG5htxaweRs3dG4qTJfFk05C2DrATCwLb7xAXRGH49+ZA/bOMe?= =?utf-8?q?WZbKbS/NFEFDH4gBBxeXpUo+eUHphDUDFX9wgp/kUX2s12Ez0omTEigf8BcyoDJsV?= =?utf-8?q?x+yOkHKAMsI0M4VZ7uxHfyOCx9yW9pyqWl6XjpUunAX2UnPIdt5+mxy3Z8bRJyLH9?= =?utf-8?q?vZMz6gOPU6M/FR2L47jjFBBDCf0Ni97qlp6Lpx8OC7y3ymkZgCb4K3on3K87ikRrI?= =?utf-8?q?ESnX0FO151TGZgrkPf3PIN25tH5jFIbNcablustC5r0AmusdP2JuVW/ZsvCFgPTjZ?= =?utf-8?q?8gYs0gjsJRyw9cQ9l09Q2/UQES6pjlLJ7tkuLL3r/X1nFQcjidAXEfiRuPZpOlgpj?= =?utf-8?q?rTbhM2APmwp2uJMYLIJVWBHTDe+PY09sOlCxivyIuQN/xYcAHwsgWc2mxWa1RDqwm?= =?utf-8?q?VNAUQvx5AcNnWg1fgiGSUPL0eC4jGMDWdZ4hvdbEuaW3ybLVeWE41oavqi3j2iqoy?= =?utf-8?q?uTLPwAxvuvqwcoN4NOlEzVFjN8Q2l8WLBXBtGK1P39oZoHCpa95wOQ3GuApD87z3Y?= =?utf-8?q?oK7EHGb3wl/UxWHrPHQUkdT/aV+ZY01eeD5XTqAZJlWeArbwgkz3QWnS3n94NP6YX?= =?utf-8?q?ZVOHAXDyRTSQCtXo1MDvSfBSxOXtqdYLeoq5vbEQaXdQd2pQvbFPAsoZ5ahUHdqka?= =?utf-8?q?1tAJSYM62eFl8N9zhd1ITTGJum2zFO0+FtwdpyDHoMohF9Rh2WD2CUOH7nbP5/vSu?= =?utf-8?q?t2J3rz1oVv5iALlyu0ymY1kp2wRiHr5QMDhDnh80x4+NTMHtFJ/NevS3yVwK67DMl?= =?utf-8?q?B26T64nqefTN0pnauuWERKZfBa47PS3DMPxWSC8nN8f8U8tBwVXgL3HMsBgjo+3WO?= =?utf-8?q?wdnf9jGmPaUFcKRN5vi6xo+fbXyh7/t7ZVOGxCyKf5U2vE5nWZOvCWiUQBnAO82un?= =?utf-8?q?p0qu5uNTBLGEPoXlFiipoEyR5b2FPz0LPvRAaEjoxXWCiFNdwb3XygwusClhD/296?= =?utf-8?q?j4LrIWqCtc+B2r6OrJeMATECxfXHlGBaigXSiNDRsdZWs3N5uyOvhT5pipv27kjhe?= =?utf-8?q?DOclEm0fAsCM7U4xmlmJhs7dX179BuqIwypDHnVUX7I0MEh7+3BF7gUhligqByVo1?= =?utf-8?q?w0Y3stmBqfTpM5AJGNOv0qnIS6mO84Wrc9fBDZgwmNLHRZB5nw0nyGD0M76LbIbqX?= =?utf-8?q?LoUAzwoxr7uF?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08614db7-91af-4a15-612c-08dc556c60ce X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2024 12:31:54.9649 (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: 23lQLKN4fKH5d2gUeFncJTW0mEY2PBmThuvYvc4aFW8WQGEkT6AH+LI+6cfZHvEX3L1BXhF+6xxetoWhALwYhw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7744 From: Peng Fan The i.MX MISC protocol is for misc settings, such as gpio expander wakeup. Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/Kconfig | 10 ++ drivers/firmware/arm_scmi/Makefile | 1 + drivers/firmware/arm_scmi/imx-sm-misc.c | 305 ++++++++++++++++++++++++++++++++ include/linux/scmi_imx_protocol.h | 17 ++ 4 files changed, 333 insertions(+) diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig index 56d11c9d9f47..bfeae92f6420 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -191,3 +191,13 @@ config IMX_SCMI_BBM_EXT and BUTTON. This driver can also be built as a module. + +config IMX_SCMI_MISC_EXT + tristate "i.MX SCMI MISC EXTENSION" + depends on ARM_SCMI_PROTOCOL || (COMPILE_TEST && OF) + default y if ARCH_MXC + help + This enables i.MX System MISC control logic such as gpio expander + wakeup + + This driver can also be built as a module. diff --git a/drivers/firmware/arm_scmi/Makefile b/drivers/firmware/arm_scmi/Makefile index 327687acf857..a23fde721222 100644 --- a/drivers/firmware/arm_scmi/Makefile +++ b/drivers/firmware/arm_scmi/Makefile @@ -12,6 +12,7 @@ scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_VIRTIO) += virtio.o scmi-transport-$(CONFIG_ARM_SCMI_TRANSPORT_OPTEE) += optee.o scmi-protocols-y = base.o clock.o perf.o power.o reset.o sensors.o system.o voltage.o powercap.o scmi-protocols-$(CONFIG_IMX_SCMI_BBM_EXT) += imx-sm-bbm.o +scmi-protocols-$(CONFIG_IMX_SCMI_MISC_EXT) += imx-sm-misc.o scmi-module-objs := $(scmi-driver-y) $(scmi-protocols-y) $(scmi-transport-y) obj-$(CONFIG_ARM_SCMI_PROTOCOL) += scmi-core.o diff --git a/drivers/firmware/arm_scmi/imx-sm-misc.c b/drivers/firmware/arm_scmi/imx-sm-misc.c new file mode 100644 index 000000000000..1b0ec2281518 --- /dev/null +++ b/drivers/firmware/arm_scmi/imx-sm-misc.c @@ -0,0 +1,305 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * System control and Management Interface (SCMI) NXP MISC Protocol + * + * Copyright 2024 NXP + */ + +#define pr_fmt(fmt) "SCMI Notifications MISC - " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include "protocols.h" +#include "notify.h" + +#define SCMI_PROTOCOL_SUPPORTED_VERSION 0x10000 + +enum scmi_imx_misc_protocol_cmd { + SCMI_IMX_MISC_CTRL_SET = 0x3, + SCMI_IMX_MISC_CTRL_GET = 0x4, + SCMI_IMX_MISC_CTRL_NOTIFY = 0x8, +}; + +struct scmi_imx_misc_info { + u32 version; + u32 nr_dev_ctrl; + u32 nr_brd_ctrl; + u32 nr_reason; +}; + +struct scmi_msg_imx_misc_protocol_attributes { + __le32 attributes; +}; + +#define GET_BRD_CTRLS_NR(x) le32_get_bits((x), GENMASK(31, 24)) +#define GET_REASONS_NR(x) le32_get_bits((x), GENMASK(23, 16)) +#define GET_DEV_CTRLS_NR(x) le32_get_bits((x), GENMASK(15, 0)) +#define BRD_CTRL_START_ID BIT(15) + +struct scmi_imx_misc_ctrl_set_in { + __le32 id; + __le32 num; + __le32 value[MISC_MAX_VAL]; +}; + +struct scmi_imx_misc_ctrl_notify_in { + __le32 ctrl_id; + __le32 flags; +}; + +struct scmi_imx_misc_ctrl_notify_payld { + __le32 ctrl_id; + __le32 flags; +}; + +struct scmi_imx_misc_ctrl_get_out { + __le32 num; + __le32 *val; +}; + +static int scmi_imx_misc_attributes_get(const struct scmi_protocol_handle *ph, + struct scmi_imx_misc_info *mi) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_imx_misc_protocol_attributes *attr; + + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, + sizeof(*attr), &t); + if (ret) + return ret; + + attr = t->rx.buf; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + mi->nr_dev_ctrl = GET_DEV_CTRLS_NR(attr->attributes); + mi->nr_brd_ctrl = GET_BRD_CTRLS_NR(attr->attributes); + mi->nr_reason = GET_REASONS_NR(attr->attributes); + dev_info(ph->dev, "i.MX MISC NUM DEV CTRL: %d, NUM BRD CTRL: %d,NUM Reason: %d\n", + mi->nr_dev_ctrl, mi->nr_brd_ctrl, mi->nr_reason); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_misc_ctrl_validate_id(const struct scmi_protocol_handle *ph, + u32 ctrl_id) +{ + struct scmi_imx_misc_info *mi = ph->get_priv(ph); + + if ((ctrl_id < BRD_CTRL_START_ID) && (ctrl_id > mi->nr_dev_ctrl)) + return -EINVAL; + if (ctrl_id >= BRD_CTRL_START_ID + mi->nr_brd_ctrl) + return -EINVAL; + + return 0; +} + +static int scmi_imx_misc_ctrl_notify(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 flags) +{ + struct scmi_imx_misc_ctrl_notify_in *in; + struct scmi_xfer *t; + int ret; + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_NOTIFY, + sizeof(*in), 0, &t); + if (ret) + return ret; + + in = t->tx.buf; + in->ctrl_id = cpu_to_le32(ctrl_id); + in->flags = cpu_to_le32(flags); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int +scmi_imx_misc_ctrl_set_notify_enabled(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id, bool enable) +{ + int ret; + + ret = scmi_imx_misc_ctrl_notify(ph, src_id, enable ? evt_id : 0); + if (ret) + dev_err(ph->dev, "FAIL_ENABLED - evt[%X] src[%d] - ret:%d\n", + evt_id, src_id, ret); + + return ret; +} + +static int scmi_imx_misc_ctrl_get_num_sources(const struct scmi_protocol_handle *ph) +{ + return GENMASK(15, 0); +} + +static void * +scmi_imx_misc_ctrl_fill_custom_report(const struct scmi_protocol_handle *ph, + u8 evt_id, ktime_t timestamp, + const void *payld, size_t payld_sz, + void *report, u32 *src_id) +{ + const struct scmi_imx_misc_ctrl_notify_payld *p = payld; + struct scmi_imx_misc_ctrl_notify_report *r = report; + + if (sizeof(*p) != payld_sz) + return NULL; + + r->timestamp = timestamp; + r->ctrl_id = p->ctrl_id; + r->flags = p->flags; + *src_id = r->ctrl_id; + dev_dbg(ph->dev, "%s: ctrl_id: %d flags: %d\n", __func__, + r->ctrl_id, r->flags); + + return r; +} + +static const struct scmi_event_ops scmi_imx_misc_event_ops = { + .get_num_sources = scmi_imx_misc_ctrl_get_num_sources, + .set_notify_enabled = scmi_imx_misc_ctrl_set_notify_enabled, + .fill_custom_report = scmi_imx_misc_ctrl_fill_custom_report, +}; + +static const struct scmi_event scmi_imx_misc_events[] = { + { + .id = SCMI_EVENT_IMX_MISC_CONTROL_DISABLED, + .max_payld_sz = sizeof(struct scmi_imx_misc_ctrl_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_misc_ctrl_notify_report), + }, + { + .id = SCMI_EVENT_IMX_MISC_CONTROL_FALLING_EDGE, + .max_payld_sz = sizeof(struct scmi_imx_misc_ctrl_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_misc_ctrl_notify_report), + }, + { + .id = SCMI_EVENT_IMX_MISC_CONTROL_RISING_EDGE, + .max_payld_sz = sizeof(struct scmi_imx_misc_ctrl_notify_payld), + .max_report_sz = sizeof(struct scmi_imx_misc_ctrl_notify_report), + } +}; + +static struct scmi_protocol_events scmi_imx_misc_protocol_events = { + .queue_sz = SCMI_PROTO_QUEUE_SZ, + .ops = &scmi_imx_misc_event_ops, + .evts = scmi_imx_misc_events, + .num_events = ARRAY_SIZE(scmi_imx_misc_events), +}; + +static int scmi_imx_misc_protocol_init(const struct scmi_protocol_handle *ph) +{ + struct scmi_imx_misc_info *minfo; + u32 version; + int ret; + + ret = ph->xops->version_get(ph, &version); + if (ret) + return ret; + + dev_info(ph->dev, "NXP SM MISC Version %d.%d\n", + PROTOCOL_REV_MAJOR(version), PROTOCOL_REV_MINOR(version)); + + minfo = devm_kzalloc(ph->dev, sizeof(*minfo), GFP_KERNEL); + if (!minfo) + return -ENOMEM; + + ret = scmi_imx_misc_attributes_get(ph, minfo); + if (ret) + return ret; + + return ph->set_priv(ph, minfo, version); +} + +static int scmi_imx_misc_ctrl_get(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 *num, u32 *val) +{ + struct scmi_imx_misc_ctrl_get_out *out; + struct scmi_xfer *t; + int ret, i; + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_GET, sizeof(u32), + 0, &t); + if (ret) + return ret; + + put_unaligned_le32(ctrl_id, t->tx.buf); + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + out = t->rx.buf; + *num = le32_to_cpu(out->num); + for (i = 0; i < *num && i < MISC_MAX_VAL; i++) + val[i] = le32_to_cpu(out->val[i]); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_misc_ctrl_set(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 num, u32 *val) +{ + struct scmi_imx_misc_ctrl_set_in *in; + struct scmi_xfer *t; + int ret, i; + + ret = scmi_imx_misc_ctrl_validate_id(ph, ctrl_id); + if (ret) + return ret; + + if (num > MISC_MAX_VAL) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_SET, sizeof(*in), + 0, &t); + if (ret) + return ret; + + in = t->tx.buf; + in->id = cpu_to_le32(ctrl_id); + in->num = cpu_to_le32(num); + for (i = 0; i < num; i++) + in->value[i] = cpu_to_le32(val[i]); + + ret = ph->xops->do_xfer(ph, t); + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static const struct scmi_imx_misc_proto_ops scmi_imx_misc_proto_ops = { + .misc_ctrl_set = scmi_imx_misc_ctrl_set, + .misc_ctrl_get = scmi_imx_misc_ctrl_get, +}; + +static const struct scmi_protocol scmi_imx_misc = { + .id = SCMI_PROTOCOL_IMX_MISC, + .owner = THIS_MODULE, + .instance_init = &scmi_imx_misc_protocol_init, + .ops = &scmi_imx_misc_proto_ops, + .events = &scmi_imx_misc_protocol_events, + .supported_version = SCMI_PROTOCOL_SUPPORTED_VERSION, +}; +module_scmi_protocol(scmi_imx_misc); diff --git a/include/linux/scmi_imx_protocol.h b/include/linux/scmi_imx_protocol.h index 90ce011a4429..a69bd4a20f0f 100644 --- a/include/linux/scmi_imx_protocol.h +++ b/include/linux/scmi_imx_protocol.h @@ -13,8 +13,14 @@ #include #include +#define SCMI_PAYLOAD_LEN 100 + +#define SCMI_ARRAY(X, Y) ((SCMI_PAYLOAD_LEN - (X)) / sizeof(Y)) +#define MISC_MAX_VAL SCMI_ARRAY(8, uint32_t) + enum scmi_nxp_protocol { SCMI_PROTOCOL_IMX_BBM = 0x81, + SCMI_PROTOCOL_IMX_MISC = 0x84, }; struct scmi_imx_bbm_proto_ops { @@ -42,4 +48,15 @@ struct scmi_imx_bbm_notif_report { unsigned int rtc_id; unsigned int rtc_evt; }; + +struct scmi_imx_misc_ctrl_notify_report { + ktime_t timestamp; + unsigned int ctrl_id; + unsigned int flags; +}; + +struct scmi_imx_misc_proto_ops { + int (*misc_ctrl_set)(const struct scmi_protocol_handle *ph, u32 id, u32 num, u32 *val); + int (*misc_ctrl_get)(const struct scmi_protocol_handle *ph, u32 id, u32 *num, u32 *val); +}; #endif From patchwork Fri Apr 5 12:39:27 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: 13619013 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2098.outbound.protection.outlook.com [40.107.20.98]) (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 4D1DA16D9B1 for ; Fri, 5 Apr 2024 12:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.98 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320324; cv=fail; b=VM6yKVhu/GWU1Bjvz/yrD0iPi8LI/bG8a7R8L7IqImzD+zpK9cJEL8a6yNCRQO7bK11vijtFyeHMKNn+QWZRgLAX5oXFYmSn90TvE1MM2q+rUN0Ln0p9vssGtsZueWE1faziqggTsngb+DR/nfRwGL4/599VrOh/MojDul8PzsA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320324; c=relaxed/simple; bh=7eShSB1HQebkY20sqLbYKFiD+32vvCrnjG0Yj35mBes=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=s2HM6znNZFQsvKKOpFNjabqwLrbI/zcOMkRETTOZaz+vnaqZlfBVogFIIQBLCYXyeuVlcLp4sDEGdWfU0ytCxV0OQX5/G1m0s17z2IgdUJ7K9ItI0Kjw1O1oRePFZdoNj0GKfRNCAwJ105U/HVn7qRCdi66ppW1aCZUDYviiAII= 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=eGAlBXxa; arc=fail smtp.client-ip=40.107.20.98 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="eGAlBXxa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m0Rsh2sFCNn+kGYoD/xQOdfVfvRi+hzYGQhonil0K/tfXMIL6cWpWyxv793NbMd1ZRxMP+wKah901cIyJgIF95wGZ7II2RuMWSe3uCqA9YWIaEt8tmg73bnN/CbxUFkrTIvC+u8gezrH7uynzZ2HtIcOtfZCo0gcUdFKwu+9pmSdUgT2n0ABGIVszVXVmrHRzAPzRHHNOQWsB39b0sHWCJdp5I6TgDZLy5EHanjE8jw5eH9XZ3I/1s2wFd8JJSmsAhVQYd1tx7okA1ZDPZ+08ZmDS3OCciLfNS9ryR2uG6hTxq3hJIbHwSINYR8AhUHpevSTXpNnGq7FdqyVysshqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i4bWUdJk5TwFdQWhDrGyBda9rTGBzN47VQeiZ7m4qmY=; b=Oe5KzaaqCTWyJW7ALbziGbVX9UbPWulSTEfR7eNEwdFseMvoPMsmVZu/UuO9sz1RSFrP/dsEMcP7bvkgjNQHVrMODJCpqRD8YHokg/vWewIe3EE0DWUCe/9NBjmQlto9v53lpLdRPrLUSl+YSnHQKS5bpQ/axLh5OsYP/6iaoxshfVsOApATA7/K4C++nXQF/Nk1sSXhe8XB56tbvG0tS/91ob+SDo2ZTeBtXuZj0tujfnWL4gKlZXM8WyMB+pUbg1Y9Gn3hJkUGYUUpNxdCH8KZJt4k8q7LH4u+qEKqg6uVB4ilWOfMezUKdXVRqmIk5ohVJT2VO8yy/l7A81SFgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i4bWUdJk5TwFdQWhDrGyBda9rTGBzN47VQeiZ7m4qmY=; b=eGAlBXxakJTTEAseIInWgaE1Cti1zVKWg8OeaDzxCk5bxGupaPZpY1oHECFQgSm4e2FgiFnK7EUAGDh1FUJkoVMNBPnxEFfPpKyZmZERw3YAHNdPSkGAKIBevBrFIEvR8d+OfRSLFMCtx8hpaR8OvulUHnILa4D6LvZmplON97k= Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7744.eurprd04.prod.outlook.com (2603:10a6:102:c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 5 Apr 2024 12:31:59 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7386.037; Fri, 5 Apr 2024 12:31:59 +0000 From: "Peng Fan (OSS)" Date: Fri, 05 Apr 2024 20:39:27 +0800 Subject: [PATCH v2 5/6] firmware: imx: support BBM module Message-Id: <20240405-imx95-bbm-misc-v2-v2-5-9fc9186856c2@nxp.com> References: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> In-Reply-To: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi Cc: Peng Fan , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712320792; l=9360; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=Qe4YMjymxAKRop7ehNWBHg5FvDm2cdcwGYpisnkYZ7c=; b=vSs53BV829LpJWQKScfmmL9pJgwsMqB1/M3m8ulRx6xnuB5VcnoEk+DInb/iW612o1OfN7pg3 M46V5VlNxyFBXjSGNXE9eW6Ai9u56TtraQ/JwlTVBs9rcG42Q3zliqZ X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:1f4::12) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) 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: DU0PR04MB9417:EE_|PA4PR04MB7744:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fh2cytYS+ppVx9mEe9IGbA95p7V9lQ2mzOzOc7//C8vJPK02XrTne3z3eEWeKUi7SEHElTmIPt2L1/oheKv+OK637xjvjxGZ1JJw94ScSCjyzYiXKjj90gfUtV5ooe42bBcda8JT6B6jM2etFYq0pGydy31y0fI+aenDZ0Tq8bgvlpVurLJQSRMWuqRpsyMDkFdZJpsFKjgSUURwcm8TEB44ANgNZ6p/lvxqktNbKk++DmdFhcO0pJVdCyQCEm72vdz3ihIxjfnvD8JkhQ/YGksPF8+U1CtVftV7MdQvoOfNtvBeIrRU/xmuqjBa9piF/uo3+PQWt2zBJ0xsOTYa//flx8olQqd9iNzx+Rx3ALgFlQGpP/9UPtABCQ9lrMg/F3XSCVXvVvh7PDv4WkYz62K+x/bTsSdW8nEbu6IPNpdzaRrzSlPRhpnAiYISkzgjEhGDR4YFzeMK4mBijo942/oyUN6NvNKEJ10c+jEW7ciRNhAiEt7+9807uSwYaH6Kl4rCzaeAuflDtrV2tXSwTUMF9iaVHG67cbFpI4bY1kA8KOdjuJWoNxqSHp15hP4Me1DXvF8mOxNUTZ4n6SxLIg0ETYcUyXcVbqrJWAeaHiKoHFS+SyfDe933sqvQU6W1XAWhF+C/F1wdSjbeDImNrNu/GRWHHC+ckYICghRxUJmWkvfFaVBLxsYpD883HZOzFz2TnY1lgPzmDMjDSXukFMMyBnI2+4qcn7qweBY/lNg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(1800799015)(52116005)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ll7zT1PEixOoJQJYPUmQdekSdJZm?= =?utf-8?q?mrzBwGNChxfB2/0tyRUHHppxdIA1uzxtRrusIddx68pQfgBYV7+y7BaqpfplEQatu?= =?utf-8?q?bblOAzHZRmAam/rnmK6a9OSupMdJZcN5sCRVjnvtaUh6jiXXMXwyf+GT1yniHyZ0b?= =?utf-8?q?SpITvUqnaqhOIi5QsDMw9iYZ08TRuGjkBwq3atVBuKntu5z6G+7t22gul+uHxIhnf?= =?utf-8?q?CxIS7FBpdfc1y4NJvzeFmodgQUSAeomgWzVM8AUw3a9caImYxmqUGS9fw7W7S5Ezu?= =?utf-8?q?75RN480Z4qp8atcAvI/8DgjSNZcnsVOAk0yectozBfigqDpz6bskD6Ah9ioTDu0p6?= =?utf-8?q?VFBX1joluFd9jHzSseOi9ft+w96qsXwPxziGYVjMRR53A06ChZD1TW0B4kPj0RmgP?= =?utf-8?q?RlJvSBXwNt3tEC4cjuMNR10hQrPemjeyVIcRep5qZOCSFuiTd4Viha2eHeZy0bXiH?= =?utf-8?q?f1qYv2cD2XG/JkiGba10Gnlv0PkrLamg6F0NJUFJ44gLpkcsTUCT2dv5i1l79md4C?= =?utf-8?q?ebGzWXg7lOIaehK+ILNLLXdNxHtyew3mEdOHIVks2O8KP2CYlInb3/ksauFRJbB42?= =?utf-8?q?sAokhXljPTUBiIgfd/g6+DLv2usQoRY6ps0IWX8p69XVKBtQCHyP/pKq7N6CuyE97?= =?utf-8?q?drOII6P5Jp0mNArqgDc8B/FVkdqWTB+i3xbUh2kAKWd3KZsgCzVl7hAdivn1vSTJJ?= =?utf-8?q?jz2jx5mUOP3/g+Gb7ue4YqvCfGitA7yI56daLP+gpCgK3fk3zw81SFOA/G3oQFSmP?= =?utf-8?q?/JIEESfFWeXn51KuwPMSA3729gA0osLsuq9Yf2x7zPvrprFD5PZPcKI40Jofib/Nn?= =?utf-8?q?9VC0QtLNk3p1b3imgB/vZNSGXKmxQDqShYdsD1S5ZQE4fo1TndaM+KHcMuowxrv+u?= =?utf-8?q?HGSiOmpJZEDAE2NoPAO/lglGIcmnVKv77tKI72bgtNkibZPAwPzwyQvWZa3N3gJSw?= =?utf-8?q?hd9DDQa0XISIKcucg9Lyt+NhBGQwHesABVyfSkEferaoNEr12vdkx6uDZHLyqYomd?= =?utf-8?q?TN6tiQ3J1B5IEvXrAmQpOpAyU4MvN0hXKlcQ8KIAbtk9DPX2dvvWqPfla3OUWS/o2?= =?utf-8?q?jwRrJjcn5f1EuEoy9JYerIn3LwSiL92ecb4FZ3gW6RLFaSl7m02W1ZlX+gXXebxAe?= =?utf-8?q?yU9LEz/Jw0TQjnIGI52ogy9+CaxCpJFcWB3XyIfmQ7oT6n8R0AAqHSvAXTi3wv244?= =?utf-8?q?N3N4OOU3uHQVtztBY2ug+ihwFuzh1pWTAqYsPRGbjSrN1ZvSanusGHdouLieD+PXY?= =?utf-8?q?aIIvoIjvHq+oJJfN0r/H6hCCrNIJx8rILacljUWX5svqbQxtnFG/RLw9dsup2QWJV?= =?utf-8?q?hK+tTfo5quWpRBxCMiOKySd47nfa6PMh/qe+PIfBnNfXLm7ZOVcy7J2E8XC7AOrMC?= =?utf-8?q?+Tf/Y70EZGwLSP6yCHnwce3ylb2bkT8T+0Y2sMeEyb58wfMPtNcDa0RBgGgn/jQam?= =?utf-8?q?h6Fc34PVuPKfmGByLJXpSqUIJjQtigi1jwRjUkxoAZz0Nep3sc9sb1YLOZROfiyjy?= =?utf-8?q?4XSUcp+5zSKz?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34935b08-19d5-4a83-120e-08dc556c6355 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2024 12:31:59.2355 (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: DR7qSJaMR9xCEU6EcZzAVokSCuKNncV6p1VPDGL+BPVIwsPqi5J25oomgGdAW12V0meFFC8YGXBlwneLvS1w9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7744 From: Peng Fan The BBM module provides RTC and BUTTON feature. To i.MX95, this module is managed by System Manager. Linux could use i.MX SCMI BBM Extension protocol to use RTC and BUTTON feature. This driver is to use SCMI interface to get/set RTC, enable pwrkey. Signed-off-by: Peng Fan --- drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-bbm.c | 317 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 318 insertions(+) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8f9f04a513a8..fb20e22074e1 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o +obj-${CONFIG_IMX_SCMI_BBM_EXT} += sm-bbm.o diff --git a/drivers/firmware/imx/sm-bbm.c b/drivers/firmware/imx/sm-bbm.c new file mode 100644 index 000000000000..fcb2ae8490c8 --- /dev/null +++ b/drivers/firmware/imx/sm-bbm.c @@ -0,0 +1,317 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DEBOUNCE_TIME 30 +#define REPEAT_INTERVAL 60 + +struct scmi_imx_bbm { + struct rtc_device *rtc_dev; + struct scmi_protocol_handle *ph; + const struct scmi_imx_bbm_proto_ops *ops; + struct notifier_block nb; + int keycode; + int keystate; /* 1:pressed */ + bool suspended; + struct delayed_work check_work; + struct input_dev *input; +}; + +static int scmi_imx_bbm_read_time(struct device *dev, struct rtc_time *tm) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + u64 val; + int ret; + + ret = bbnsm->ops->rtc_time_get(ph, 0, &val); + if (ret) + dev_err(dev, "%s: %d\n", __func__, ret); + + rtc_time64_to_tm(val, tm); + + return 0; +} + +static int scmi_imx_bbm_set_time(struct device *dev, struct rtc_time *tm) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + u64 val; + int ret; + + val = rtc_tm_to_time64(tm); + + ret = bbnsm->ops->rtc_time_set(ph, 0, val); + if (ret) + dev_err(dev, "%s: %d\n", __func__, ret); + + return 0; +} + +static int scmi_imx_bbm_alarm_irq_enable(struct device *dev, unsigned int enable) +{ + return 0; +} + +static int scmi_imx_bbm_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct scmi_protocol_handle *ph = bbnsm->ph; + struct rtc_time *alrm_tm = &alrm->time; + u64 val; + int ret; + + val = rtc_tm_to_time64(alrm_tm); + + ret = bbnsm->ops->rtc_alarm_set(ph, 0, val); + if (ret) + dev_err(dev, "%s: %d\n", __func__, ret); + + return 0; +} + +static const struct rtc_class_ops smci_imx_bbm_rtc_ops = { + .read_time = scmi_imx_bbm_read_time, + .set_time = scmi_imx_bbm_set_time, + .set_alarm = scmi_imx_bbm_set_alarm, + .alarm_irq_enable = scmi_imx_bbm_alarm_irq_enable, +}; + +static void scmi_imx_bbm_pwrkey_check_for_events(struct work_struct *work) +{ + struct scmi_imx_bbm *bbnsm = container_of(work, struct scmi_imx_bbm, check_work.work); + struct scmi_protocol_handle *ph = bbnsm->ph; + struct input_dev *input = bbnsm->input; + u32 state = 0; + int ret; + + ret = bbnsm->ops->button_get(ph, &state); + if (ret) { + pr_err("%s: %d\n", __func__, ret); + return; + } + + pr_debug("%s: state: %d, keystate %d\n", __func__, state, bbnsm->keystate); + + /* only report new event if status changed */ + if (state ^ bbnsm->keystate) { + bbnsm->keystate = state; + input_event(input, EV_KEY, bbnsm->keycode, state); + input_sync(input); + pm_relax(bbnsm->input->dev.parent); + pr_debug("EV_KEY: %x\n", bbnsm->keycode); + } + + /* repeat check if pressed long */ + if (state) + schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(REPEAT_INTERVAL)); +} + +static int scmi_imx_bbm_pwrkey_event(struct scmi_imx_bbm *bbnsm) +{ + struct input_dev *input = bbnsm->input; + + schedule_delayed_work(&bbnsm->check_work, msecs_to_jiffies(DEBOUNCE_TIME)); + + /* + * Directly report key event after resume to make no key press + * event is missed. + */ + if (bbnsm->suspended) { + bbnsm->keystate = 1; + input_event(input, EV_KEY, bbnsm->keycode, 1); + input_sync(input); + } + + return 0; +} + +static void scmi_imx_bbm_pwrkey_act(void *pdata) +{ + struct scmi_imx_bbm *bbnsm = pdata; + + cancel_delayed_work_sync(&bbnsm->check_work); +} + +static int scmi_imx_bbm_notifier(struct notifier_block *nb, unsigned long event, void *data) +{ + struct scmi_imx_bbm *bbnsm = container_of(nb, struct scmi_imx_bbm, nb); + struct scmi_imx_bbm_notif_report *r = data; + + if (r->is_rtc) + rtc_update_irq(bbnsm->rtc_dev, 1, RTC_AF | RTC_IRQF); + if (r->is_button) { + pr_debug("BBM Button Power key pressed\n"); + scmi_imx_bbm_pwrkey_event(bbnsm); + } + + return 0; +} + +static int scmi_imx_bbm_pwrkey_init(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + struct input_dev *input; + int ret; + + if (device_property_read_u32(dev, "linux,code", &bbnsm->keycode)) { + bbnsm->keycode = KEY_POWER; + dev_warn(dev, "key code is not specified, using default KEY_POWER\n"); + } + + INIT_DELAYED_WORK(&bbnsm->check_work, scmi_imx_bbm_pwrkey_check_for_events); + + input = devm_input_allocate_device(dev); + if (!input) { + dev_err(dev, "failed to allocate the input device for SCMI IMX BBM\n"); + return -ENOMEM; + } + + input->name = dev_name(dev); + input->phys = "bbnsm-pwrkey/input0"; + input->id.bustype = BUS_HOST; + + input_set_capability(input, EV_KEY, bbnsm->keycode); + + ret = devm_add_action_or_reset(dev, scmi_imx_bbm_pwrkey_act, bbnsm); + if (ret) { + dev_err(dev, "failed to register remove action\n"); + return ret; + } + + bbnsm->input = input; + + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM, + SCMI_EVENT_IMX_BBM_BUTTON, + NULL, &bbnsm->nb); + + if (ret) + dev_err(dev, "Failed to register BBM Button Events %d:", ret); + + ret = input_register_device(input); + if (ret) { + dev_err(dev, "failed to register input device\n"); + return ret; + } + + return 0; +} + +static int scmi_imx_bbm_rtc_init(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + int ret; + + bbnsm->rtc_dev = devm_rtc_allocate_device(dev); + if (IS_ERR(bbnsm->rtc_dev)) + return PTR_ERR(bbnsm->rtc_dev); + + bbnsm->rtc_dev->ops = &smci_imx_bbm_rtc_ops; + bbnsm->rtc_dev->range_min = 0; + bbnsm->rtc_dev->range_max = U32_MAX; + + ret = devm_rtc_register_device(bbnsm->rtc_dev); + if (ret) + return ret; + + bbnsm->nb.notifier_call = &scmi_imx_bbm_notifier; + return handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_BBM, + SCMI_EVENT_IMX_BBM_RTC, + NULL, &bbnsm->nb); +} + +static int scmi_imx_bbm_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device *dev = &sdev->dev; + struct scmi_protocol_handle *ph; + struct scmi_imx_bbm *bbnsm; + int ret; + + if (!handle) + return -ENODEV; + + bbnsm = devm_kzalloc(dev, sizeof(struct scmi_imx_bbm), GFP_KERNEL); + if (!bbnsm) + return -ENOMEM; + + bbnsm->ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_BBM, &ph); + if (IS_ERR(bbnsm->ops)) + return PTR_ERR(bbnsm->ops); + + bbnsm->ph = ph; + + device_init_wakeup(dev, true); + + dev_set_drvdata(dev, bbnsm); + + ret = scmi_imx_bbm_rtc_init(sdev); + if (ret) { + dev_err(dev, "rtc init failed: %d\n", ret); + return ret; + } + + ret = scmi_imx_bbm_pwrkey_init(sdev); + if (ret) { + dev_err(dev, "pwr init failed: %d\n", ret); + return ret; + } + + return 0; +} + +static int __maybe_unused scmi_imx_bbm_suspend(struct device *dev) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + + bbnsm->suspended = true; + + return 0; +} + +static int __maybe_unused scmi_imx_bbm_resume(struct device *dev) +{ + struct scmi_imx_bbm *bbnsm = dev_get_drvdata(dev); + + bbnsm->suspended = false; + + return 0; +} + +static SIMPLE_DEV_PM_OPS(scmi_imx_bbm_pm_ops, scmi_imx_bbm_suspend, scmi_imx_bbm_resume); + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_BBM, "imx-bbm" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_bbm_driver = { + .driver = { + .pm = &scmi_imx_bbm_pm_ops, + }, + .name = "scmi-imx-bbm", + .probe = scmi_imx_bbm_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_bbm_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM BBM driver"); +MODULE_LICENSE("GPL"); From patchwork Fri Apr 5 12:39:28 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: 13619014 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2095.outbound.protection.outlook.com [40.107.20.95]) (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 AA79B16D9BE for ; Fri, 5 Apr 2024 12:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.95 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320328; cv=fail; b=iV9eRV7r45dICECmU/zGhcKP5QSANTFGZ40vNdrRajjVyx3JPP5Saqn9XgQZ0QZZcOf0jOqJDen1OChO8CTiiNbX5AuIoVYxiVOyW/a0G5c6mwvx2WkGgZFcJeYLzJUe8rP66CGpUq3ylMC7EbaQMnoxWLMNUCWCHkWSRDhzlSY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712320328; c=relaxed/simple; bh=F14h2hIZxy/WaPTp6QzvyniwhgTu1G7E/XZjU3o7xuE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=Vg1i6lyhh571HbgpXAjnXYDMFKt1/isOTAdBN0miUHyLqgjT6E4sFff3cS+Zv8WXx+d1EVL8pD5TZVOFK4VnvFBZgCfAMJpBvfy/BTFvrFDTkkX8zGj4idOAaWs+EeLxR6KKMu3SZYu2JMcwG1K+2njiORiPmArFzFcwY86jZtw= 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=NUVhu3pa; arc=fail smtp.client-ip=40.107.20.95 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="NUVhu3pa" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YbOR2Bk3jOsCSs07kfbVXjxapqIve1OUfrIwTqf9LpkAocu+NwCldVvikMkLuzZUK7ng9ie8bW9GjnxUaSzYFNoQVp27/RC6KgkbFTR10gjNcg46OVkCWH6ALHhe2Eu7YiBMWJcWyZLjaApZEzgzsWdXyZo71Kkig5Xa1PMuGcyubbI1Y+s+f6zbo2UwW1vHHo5C0+KWJ5Vh51b4atDEMgAPLQ80r5cwUKMjauIfADnF4VQ8TKu6icKDMEOSO7xM2bLJLdOslPaq1Pd2k1xPm+nE64P9tS9glnhJujbugIjnt7LMW4WwIR17jwfwreYR7JdZ/zhMM2CexUveK/vuew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qmLEKLDgTbuTKcvdN45vKFWC6Ra3feV6bbsCVFoin+Q=; b=Uu70MlunmDkq2ZwIrtzOtHLFpF5E6jJhSzJa3/rv6r8wiXXsSzIsyqcSEZP60/fzqppRuOc0Pw8YjAspdFMa5ksOQYwVFgyx+I7lWijMTfTh+lZZKwSeT9IyuyOXvjMJ5jFEsfY3tdrt/YW1cwxfGx24ucrRMJ5o6bLyE6SUorp4ZditBeI5FAqu9Iu80WzepuZRdH3Gz9B3qFkRV8TNDMupMmpTcq1EFdTWVcnXgFw7Iw0R+R90/+/McGiiqL2q7QvIQLsDcBJwFU4rRrwhmuMAzRJnwu3dxv24+BNKzU7ko0vWpqnQ1WwdD3GO7rF7t1dxd2PR0hCLU9G1XqJJIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qmLEKLDgTbuTKcvdN45vKFWC6Ra3feV6bbsCVFoin+Q=; b=NUVhu3pakuKSiULZ/H7pA7EXuIc/FJYUzu6cNYAqlPOcxo28ELyxPDw4DFqQiFKkllOQ+vMfq5b91B92JNmU2GY4/rljf7dcQE/tVcJHIujiUqZqhKKUS0JAGHLuDiaJRqmtmmwW94VJnsZ4zfX3IRFZYXV5ZVG+Q83SoTKhJhE= Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PA4PR04MB7744.eurprd04.prod.outlook.com (2603:10a6:102:c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 5 Apr 2024 12:32:03 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7386.037; Fri, 5 Apr 2024 12:32:03 +0000 From: "Peng Fan (OSS)" Date: Fri, 05 Apr 2024 20:39:28 +0800 Subject: [PATCH v2 6/6] firmware: imx: add i.MX95 MISC driver Message-Id: <20240405-imx95-bbm-misc-v2-v2-6-9fc9186856c2@nxp.com> References: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> In-Reply-To: <20240405-imx95-bbm-misc-v2-v2-0-9fc9186856c2@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Sudeep Holla , Cristian Marussi Cc: Peng Fan , devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712320792; l=4839; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=CxsTem4c2UkSyoEAgF9+D0rRRjQcCv/6gmp4AinHGy8=; b=t0H+mFmPeAYegC19iPxmWW1dcghnCrQMgG53u8dAzgygUK8ThK/tgn0DK6SYsIVPEdT1JQ5WU LDHzUHS2Ay5B/VlUQgXvwP3H+R18Mlzd0pXo8rDxksC895BaVAKj18D X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:1f4::12) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) 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: DU0PR04MB9417:EE_|PA4PR04MB7744:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yq8+E9rnCZW6I0Eb6CsIV7q/C1ENaM8Xjw4q4nYv/7uxLJDC7qbkFMOZh81Lfo4F1L8gmjUMT6eBLSzKymj2/vxQ1v1ZdiqGAvi2AJtkMbgjbHNEMjwdtzzFjd++1QZ2NCK1MHywAc177jCYCnDc0gBLan5Xlt8AT29sBUCzy5jePWyyuGufaR2RneDCP0WZB7LSiWGc7fcow19zCFubrfuUpHQydwqMtfTdjoTlZlwNg5pSMMP+byOcibSYRSLvK9cfngTZdPZeGu691lT/OIeXi1N3RJizyERmtOjneiXRnPsgQ98SJ/dah04+N2K5gNWla89LiTdhYF8ktID2pHAYoCyF+ZvjTgiCdvNIkcS7V9zA5EtoqSjVZDKDwXnaHycKufKlniokCED6jiQMcG0Otk5vmAj4/KGRCazS7HjwGUusMSlGEigK9I0zHbheZ2qpkkDIcSIfCe6iw2hVPiE6nJIQCJcdxCR0DisK25Kwy96x1klYUuPcQ6/DVcgIFRXW5Uoj7BAK+QMbZbkgvy8RDgEodUYJJpRVzRaX3bUpWuBERUEFCewIyGkJ48YRMiW4UQXSmhB5mOhsOWt2sfpkr0RWvzUbLNiTW4l2F388L0lppNE76B/32QdtAdKyF8a1y385j9YJ9bcjsuphRfMWAW8MFAnSAmeYQVPe2k81DKmj5FT/XICiBgASrqCKlwjQW1a1lRETYTE4SayryalEk2a6v1PHSjPyZJ5ItZg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(7416005)(1800799015)(52116005)(366007)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?w2NkDXPiGCwAgCRlbmIrADm3szih?= =?utf-8?q?uQOMH1jAv7/MyEaQsCXdb0dlbC3qLHA/Ii22DTXuFtybASnLUPMpo8hRgezEKH3tk?= =?utf-8?q?wN7uelnJLx0TniW5lu+7q00C9e9j/alA3sRpigELehXwtX50NIGJdNZoa/SQEI/J4?= =?utf-8?q?Y8EVmQaSecuBYBmEFPrkv/hASWGj2ab1sckEwUifiyMbai67163xHT+KhKH7RONd5?= =?utf-8?q?6Da6ZZjdcz9ElYEaFc0tOZp39CCNB6HY3pRfTpwxlHNe+DvKUhjxSdN5fTosNHZ25?= =?utf-8?q?2Y6XigLPsLar0jDphjfTi7o7NxtEzgEDvGDJgIxmjwdEudpAIlMkgKOaHyUwLQOFZ?= =?utf-8?q?C+aj2hHw/6AE7w4LNRBygGEYlDR7jv55jJDc5mtWSgCchpAVBMeNHZAXB8luYROD8?= =?utf-8?q?xqnxVX/mpXez86qPNGVkY7ywvJu4rOdbsBa2lNjeIT36txu8COQhM6XRS5zu+TBay?= =?utf-8?q?lS7UeIQgXoNYo+9J/vV7RutOuYFNkwF68O+5Jk7UMkGVYmVsuEhtw3C4zvgPlep08?= =?utf-8?q?flodJnpiEuT4Kz4SgHZHesNG4OidGYWVOQCKSVxtAVTh3ehsza/3DY9Mb8ce6ieXS?= =?utf-8?q?E42kIH04itj6KxhWVFg3k/wdYqfWnZp/COD21uowzoIJaxJ19zrYxBagqfSDEHi/m?= =?utf-8?q?QkligtZrjGu1hMXvmqCgPvHkKVFY5BdVZrTc2deBLY4fFbUC6fTUz6V7Kb9a+LEmq?= =?utf-8?q?AFfFD8V+x2Y/R1v8OazvMNHCX2zP38fbTz+siXD3oGa4u14/ZcwKSMSg+Dh97Drzf?= =?utf-8?q?2hhYRHU8PICgGJVs1flj1I3c9uJQdj4oTyhJ8XbZR75OounDrO1o5beUWdPlYeMRK?= =?utf-8?q?+BXFq2DCgqQg0PGDyl35q5pNeWxHTqpyIhMMG9P9w3hz/OcyZJd5ZUyPlc0Ja6Nnm?= =?utf-8?q?dCGQbkxyT8rNZnLvcccdjm6Djq5nVhHFD8FtzBfLp+JteSjQk1eF8MsP3u6Q+oBYo?= =?utf-8?q?AyX5TUVvvBtmJEwSsr95edp9b4SV6eaxyF/opPuZe1KaMJJbIm6Oj6su/gQE2j+6w?= =?utf-8?q?7wJolv3xwHHCOO/2hs7BcqPfc5ee/NcPwJYcq3EpNX0OF5KkcDal2FM2iCjZ8hGPG?= =?utf-8?q?Pj6oexlooMoeNOitC3h2oWgi4VeeLl0iYgHq49PRYZi+x+hJfWhJHPXQOK3oVPDm2?= =?utf-8?q?r6yDmXqGAb5iCh4uSAru57iU8MQyHVd1u+VEkvk3UbBG9dme6h5yoUEIXoCqxjlO8?= =?utf-8?q?qjYegNxRSEfZcZM5rt+wdayBzisO1cIF6hj5v4G3cshExeGv2xdSFE4xY6iBXll8L?= =?utf-8?q?zZmdXPtufwiyR3L/u4VwH8ghH2AxfWxC64WjxKD50YtHwPENGzUGYojnvLLzMXIJ2?= =?utf-8?q?o1iywnytbTz6tqbpyb3ukaiXZolrbERVyZu5Zua0AFyrQXpOFGNkCMWCEH2V40YOy?= =?utf-8?q?CyxAepsE2Zb1zBVkmr5wg2nzf9YQbeJCPTv+4K+GLeJqZNIQPG+h5ygSljyld7gW9?= =?utf-8?q?A1mSpjIKFXnpHJLvOcLA7iZKe0taUSwnpGhQiQZZmQ4a+rQIyMsdc2RBE4KFyV6FA?= =?utf-8?q?hWYtIpyc+24w?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ef5d688-57ac-400a-cbc3-08dc556c65e4 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2024 12:32:03.5516 (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: QzxWKbIZAyDqDQR6R3aT6uPb9ry7HzpakoxeNvj4CqWRSYwDcmQLK8UGN8bbmWtF7bJ3ivo3U6SKhueiA2b5JA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7744 From: Peng Fan The i.MX95 System manager exports SCMI MISC protocol for linux to do various settings, such as set board gpio expander as wakeup source. The driver is to add the support. Signed-off-by: Peng Fan --- drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-misc.c | 92 +++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 +++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index fb20e22074e1..cb9c361d9b81 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o obj-${CONFIG_IMX_SCMI_BBM_EXT} += sm-bbm.o +obj-${CONFIG_IMX_SCMI_MISC_EXT} += sm-misc.o diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c new file mode 100644 index 000000000000..a5609de426f6 --- /dev/null +++ b/drivers/firmware/imx/sm-misc.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2024 NXP. + */ + +#include +#include +#include +#include +#include +#include + +static const struct scmi_imx_misc_proto_ops *imx_misc_ctrl_ops; +static struct scmi_protocol_handle *ph; +struct notifier_block scmi_imx_misc_ctrl_nb; + +int scmi_imx_misc_ctrl_set(u32 id, u32 val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_set(ph, id, 1, &val); +}; +EXPORT_SYMBOL(scmi_imx_misc_ctrl_set); + +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + if (!ph) + return -EPROBE_DEFER; + + return imx_misc_ctrl_ops->misc_ctrl_get(ph, id, num, val); +} +EXPORT_SYMBOL(scmi_imx_misc_ctrl_get); + +static int scmi_imx_misc_ctrl_notifier(struct notifier_block *nb, + unsigned long event, void *data) +{ + return 0; +} + +static int scmi_imx_misc_ctrl_probe(struct scmi_device *sdev) +{ + const struct scmi_handle *handle = sdev->handle; + struct device_node *np = sdev->dev.of_node; + u32 src_id, evt_id, wu_num; + int ret, i; + + if (!handle) + return -ENODEV; + + imx_misc_ctrl_ops = handle->devm_protocol_get(sdev, SCMI_PROTOCOL_IMX_MISC, &ph); + if (IS_ERR(imx_misc_ctrl_ops)) + return PTR_ERR(imx_misc_ctrl_ops); + + scmi_imx_misc_ctrl_nb.notifier_call = &scmi_imx_misc_ctrl_notifier; + wu_num = of_property_count_u32_elems(np, "wakeup-sources"); + if (wu_num % 2) { + dev_err(&sdev->dev, "Invalid wakeup-sources\n"); + return -EINVAL; + } + + for (i = 0; i < wu_num; i += 2) { + WARN_ON(of_property_read_u32_index(np, "wakeup-sources", i, &src_id)); + WARN_ON(of_property_read_u32_index(np, "wakeup-sources", i + 1, &evt_id)); + ret = handle->notify_ops->devm_event_notifier_register(sdev, SCMI_PROTOCOL_IMX_MISC, + evt_id, + &src_id, + &scmi_imx_misc_ctrl_nb); + if (ret) + dev_err(&sdev->dev, "Failed to register scmi misc event: %d\n", src_id); + } + + return 0; + +} + +static const struct scmi_device_id scmi_id_table[] = { + { SCMI_PROTOCOL_IMX_MISC, "imx-misc-ctrl" }, + { }, +}; +MODULE_DEVICE_TABLE(scmi, scmi_id_table); + +static struct scmi_driver scmi_imx_misc_ctrl_driver = { + .name = "scmi-imx-misc-ctrl", + .probe = scmi_imx_misc_ctrl_probe, + .id_table = scmi_id_table, +}; +module_scmi_driver(scmi_imx_misc_ctrl_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("IMX SM MISC driver"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/firmware/imx/sm.h b/include/linux/firmware/imx/sm.h new file mode 100644 index 000000000000..daad4bdf7d1c --- /dev/null +++ b/include/linux/firmware/imx/sm.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright 2024 NXP + */ + +#ifndef _SCMI_IMX_H +#define _SCMI_IMX_H + +#include +#include + +#define SCMI_IMX_CTRL_PDM_CLK_SEL 0 /* AON PDM clock sel */ +#define SCMI_IMX_CTRL_MQS1_SETTINGS 1 /* AON MQS settings */ +#define SCMI_IMX_CTRL_SAI1_MCLK 2 /* AON SAI1 MCLK */ +#define SCMI_IMX_CTRL_SAI3_MCLK 3 /* WAKE SAI3 MCLK */ +#define SCMI_IMX_CTRL_SAI4_MCLK 4 /* WAKE SAI4 MCLK */ +#define SCMI_IMX_CTRL_SAI5_MCLK 5 /* WAKE SAI5 MCLK */ + +#if IS_ENABLED(CONFIG_IMX_SCMI_MISC_EXT) +int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val); +int scmi_imx_misc_ctrl_set(u32 id, u32 val); +#else +static inline int scmi_imx_misc_ctrl_get(u32 id, u32 *num, u32 *val) +{ + return -EOPNOTSUPP; +} + +static inline int scmi_imx_misc_ctrl_set(u32 id, u32 val); +{ + return -EOPNOTSUPP; +} +#endif +#endif