From patchwork Fri Feb 2 06:34:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13542139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40F3BC48292 for ; Fri, 2 Feb 2024 06:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=5iX4jcJ9WnsXk/NES3phKyGOQKHbqa/tec+oAGIxYsw=; b=etv1VAs/Ddg85RVVnnp9tqP6L1 eJtT/clWNhMp/oJGwf8DOcyTace6ydNo026eiaoU+lYKz3yQjA9nK03NuscJ0Pnl8OjdWwQEI5O02 YiBspGzFxFOSToa93WwB2NQdMUKULDP5F2+I74lsl++djqOAYsEpOa4yPcarVETWXHJfudUT4N+qs FMLxRD+/aANov3Gm3FD6kZ2GMKcQCFs5uecViFj9/QnSdms+HcbrpkC68G31Jhi8wVxuR0OA+tgwW zBMl9T3VHqeCkNlEehNiq/BAtqs+j4rFmboV6AkRRcySpXQBvIQFXAy6uVkWCY+VBXkYLU/K8Y6FF c9ttkkiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4Q-0000000AQQH-150u; Fri, 02 Feb 2024 06:30:38 +0000 Received: from mail-he1eur04on20601.outbound.protection.outlook.com ([2a01:111:f403:260f::601] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4M-0000000AQNl-3oPW for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2024 06:30:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MoKuk/PwMyYH02Puuz7uSX03CTkOpB21n3gcWCEyLCtOYcKtKS0JpY03PdYIKrbsYgXBBkyh0fMBIkbjxPzm5yLcFxBUEWafQ08Fy0aGITnKi4+Bw8nwbEaDOU7CHfjMJr8Ar72aez7qyQVxjw7rWzggTrKjS7IDNAN1sLRbCjc2jUhJiKQcR7+5z+D61MfAA0xGquhHYhT0O+Fm7UXEWEC7GiZfu4ypoMnR/jHOy34f2t3tLVJHPZVNCBJjPiYIzVsMc0HuOzu0VG/pzf+gzQcap22bA0wu6y9fOq1t6WS4Xi0sRh2UYDl+flGhZpk2lBHwcacKrVzPIGbrQ3MeyQ== 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=1w5Ox2XDe/kTQATWRcn4dqOKnSOQnf8cJTAmHRLgw7o=; b=RQfj8GfMzRJUixS0XK+GajlxYSYO7IoJm0K4hHce5+4npqiHjdZLB0N+9uIhROFraPowytVQ7U8Nau8ZEYmdsvUebw8G2wdkdPV+G6P+6swEO8E2RSvfatfXcHEKIZQOCeaCHFKoMGTI1IHPaQ/C7KAskYur/qciaCC3XDB53jtyDjfhhx/zTR7GAXyj11wbVcBmuMU3nfvVFdM7IDPPUURMbngTe/ahhrA0c7rfA/OtX2mZumM/eAoMW1kumS2y1bj81lLGoD0EujVu+7F0lDFFabzcqOLKVhPaCXmm/HBIRg5VmS1HtgZmabp07gmoJahZ1fPgSSSuE6T0wxcHkQ== 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=1w5Ox2XDe/kTQATWRcn4dqOKnSOQnf8cJTAmHRLgw7o=; b=HbzUJWTUrfJUYH03607g5FZkeGNagGyhnRL67AzFrWT44K/rdAUnZv9oqIQkD9xfaR7warxNGlfwxEQ6LpDUQrp9M/h7zOJTSSjzXN7Hr9H2sBHWAk4QIrX9h+4KOt/qvluXo6E7SheVbf3nC4KibWtJXPvh5QXGYKWOQweNAt4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 06:30:28 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6%3]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 06:30:28 +0000 From: "Peng Fan (OSS)" Date: Fri, 02 Feb 2024 14:34:39 +0800 Subject: [PATCH 1/5] dt-bindings: firmware: add i.MX SCMI Extension protocol Message-Id: <20240202-imx95-bbm-misc-v1-1-3cb743020933@nxp.com> References: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> In-Reply-To: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706855688; l=2092; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=O5WGPt6z08564VNPrITnGf4yj18gsknkJha38j3OpeQ=; b=wTvF3tfCl6P78HdhfSEmpO963ft47ptm8+VQufd4jDlpRfzSbzAwy6ZOnnr+gcb8oB/O2fTUz hqlODCAmJ7tAk8UL6Jt92/wo6GkNUHW/J7Sa15YUSeLIgJ/ttcK2pyO X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:1f5::11) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM9PR04MB8604:EE_ X-MS-Office365-Filtering-Correlation-Id: d67690cb-29ae-4274-0855-08dc23b87279 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: 4DOL0EKFHt3tms/3QbxxRmLUqsVmVymMuut74ajYoNtMLyedKR5mGMDz5xPm55fKBfeGZaPH0WafFjEk3upeSRBEvd3wq487It3XNVWPC2MSa+H16/rs62zPBo1VY2ne0cIMMledDFKKOKgb4Ufpc0I+OBQ16YEDseJ7hz7vdfAxbOJ0ZAH9voB/dlvyYEgPoApPYk3uM1hS/ztsq9bEWo032pCFuGLixJg/LJTYmrgmzI1+8r0q+/5fl/mIkvQntwfjT0U96LLSrJCm7TtpkXM8hxxNnK2swhSwxtUWz1pSKi2TKsbFLzQlfx2ygDdw/FRPKo9x75goTs5l0VSiTiYBTwbKxdGBOkTWSeUwstjrX6p5++rM7KU+px7Wmmz7idZEuVwrXEDR9UIw86Q93blxebbSTPvBFaXR10PzvhNRIw9ia9Z92ERnnfz+4uc6JxRzabAegm+3ERKV9n3xcE1m55KOnA2tPx9eF8gZK/q/ls4qYGV4ehjHbb0IxCKHf+KCk3FOgQDTrg/v6m+Wr0SDKVYrvpVJXuL9Up/EE6DB70au+sDc99vO28gSfVkuns2dp+Y/u5fsgoisMib/vgoLXi9rN5pz4CANkCwQ4nIxZt768DWTw4xnny905y9Z 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)(376002)(39860400002)(346002)(136003)(366004)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(9686003)(6512007)(6666004)(6506007)(52116002)(8936002)(921011)(4326008)(7416002)(2906002)(5660300002)(316002)(8676002)(66476007)(86362001)(66556008)(66946007)(38350700005)(26005)(36756003)(110136005)(41300700001)(6486002)(966005)(478600001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?tY0fU2aUfH99hSADGrEpbZSMJ+6A?= =?utf-8?q?o2diYdENgL2w1fDO+Ed+vrvAwi+XgB+iN3P3RLSZfFMDYkvBipYPruWlmm3EM0jIW?= =?utf-8?q?ZSLxjsP6KV9QtPjRgsNbvASAiWoxWOADGLIVcNpJe1V54iL/EWrD4fiO4erE6OZ38?= =?utf-8?q?Y8TqPCSq3kAWsV4qq/DBnx2amc01Vqj5Poqq1CkH13X78vsy+35tZ0/8Gj459HQ76?= =?utf-8?q?RJWKmULvH56Z38j2m5ZXsHShhGsaDwEwuFe0lWGQ+13kH4glZRWVWJZJ8A7eQaRBR?= =?utf-8?q?CBgzJeP/pUnguFfeA80hZhVvZVphAAQtyhDfzyJBPbqCiO39WDw+zMKQ+8E2VkP0P?= =?utf-8?q?AlURF2gg7fGjsijrjuxcf+Uc/2cyVp2XI6QU9jpqJHtwoxwDgDD8PiB28RAXuiCkK?= =?utf-8?q?uGIV5kpeVqekEIe1tM0H07w3zFfcfk4y69faiacT54zP0RUfeIbHfV917mwSEup+E?= =?utf-8?q?8L+XHVVwV/fm2HbofhmpaxhFUAnkqeRDElRFYiy6OcrUZ+mn5xAOwVjTP77Y1zx+N?= =?utf-8?q?GwLkWR8U9/ZjLeriZXUcFxGPKl95dsb65gIEOtift/9lDxLq9tVlrwJd1YBEqEPJE?= =?utf-8?q?eVH0UbnH04xuWC6TxDo3c7IY5SukM93zTMO1OtyALK4B/piI8tw/xp5siKKuspMyW?= =?utf-8?q?Z7xMaE4c1Xo6kCsGSyBkqRfUosyCHq5cEYZv30XGMiHx1vQTiCttpWReacp75ifoe?= =?utf-8?q?sIxFswUHhan48hrYz31y9WXEn94n42OF3qbGeCvC2zEhMxvTUD6C/n5kr25543q7N?= =?utf-8?q?63ooEpzMxf6mmK6I9XhQ+lgdQvWDWtrIgbV2a8zojdCO0Q6xXbesyZLJ8o+d04ij7?= =?utf-8?q?ylDvwt+yEUl1P+6nKaE1h5TWIzXyzGvKJgJ2BScd0Sdt6bvrCYZamivcZM7IjWIjB?= =?utf-8?q?h9IFncKqqBb/VhJYCCDDZmQTtpUj4eHCOwzUS1RWw3dSQUU6Q2WDrDy3ew3taSeyL?= =?utf-8?q?FPf5u6zRIuYljL7CuvLOsnlpDfr/bjEBBDwmrezJLIvApE9ukB1j6wY1+s5weE3RA?= =?utf-8?q?awmdwQpsK7TCVz0BdZgtBFtksTgf9GjigR8/ONFgE+U5vn0ut1nK68ToAEz0TCn77?= =?utf-8?q?XFjQb8FBPUp9J+rkKd1wtfs9CfOdGx1NcV//RGdKTkbK9ReZzwOqeGKg6qUjI+NpM?= =?utf-8?q?8b3QgVF+8oquUtpWLxuwLbOBu7xOq2F1yfsvitI/hXXljBhw0jH1hoHR4/FrVSpjG?= =?utf-8?q?XL4Lu7SC1yj++9IHbYYA0ioZcHvPqWvcAqd2i8lSptdZnjQ7SubC6ybGeEfoOZ5z9?= =?utf-8?q?mND/lKYglGm0AvgDLAroIIvoYX9XuI55LHjNkiibkeNgRsy23X1HXsQ2EgQDeFyVF?= =?utf-8?q?BbFO/jz2IO2gI6E9BLUy1OnROjgO1ioyRFXab2+xDvoRMmJbid9m9I9H1pWwEoFMS?= =?utf-8?q?zxqS38NRDGNHinQfOL5GPploojxp1k1VnC9b7vYsTwCoHxxc42FW6waZuV9HGbVdl?= =?utf-8?q?EZHZSIz4H4Ddm+5SqPwOKix+m/d6fFqXRvEY01PsHodLLG3/gFMrqgAWsTOdDkhTU?= =?utf-8?q?VHbf1C/6tKlq?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d67690cb-29ae-4274-0855-08dc23b87279 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 06:30:28.2496 (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: OT72g6pxTPORrQcz2xNMsgqPXPiulq/HYxikjFM/uGCrrzF+SQQ2npPHEHXaXi2VKFuZFZKxcd2Ow+2pRUTpBA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8604 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240201_223034_997833_350FE146 X-CRM114-Status: GOOD ( 12.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan Add i.MX SCMI Extension protocol BBM and MISC binding. Signed-off-by: Peng Fan --- .../devicetree/bindings/firmware/nxp,scmi.yaml | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/Documentation/devicetree/bindings/firmware/nxp,scmi.yaml b/Documentation/devicetree/bindings/firmware/nxp,scmi.yaml new file mode 100644 index 000000000000..00d6361bbbea --- /dev/null +++ b/Documentation/devicetree/bindings/firmware/nxp,scmi.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2024 NXP +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/firmware/nxp,scmi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: i.MX System Control and Management Interface (SCMI) Protocol Extension + +maintainers: + - Peng Fan + +allOf: + - $ref: arm,scmi.yaml# + +properties: + protocol@11: + $ref: 'arm,scmi.yaml#/$defs/protocol-node' + unevaluatedProperties: false + + properties: + reg: + const: 0x81 + + protocol@13: + $ref: 'arm,scmi.yaml#/$defs/protocol-node' + unevaluatedProperties: false + + properties: + reg: + const: 0x84 + + wakeup-sources: + description: each entry consists of 2 integers and represents the source and edge + items: + items: + - description: the wakeup source + - description: the wakeup edge + $ref: /schemas/types.yaml#/definitions/uint32-matrix + +additionalProperties: false + +examples: + - | + firmware { + scmi { + #address-cells = <1>; + #size-cells = <0>; + + protocol@81 { + reg = <0x81>; + }; + + protocol@84 { + reg = <0x84>; + wakeup-sources = <6 1 + 7 1 + 8 1 + 9 1 + 10 1>; + }; + }; + }; +... From patchwork Fri Feb 2 06:34:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13542138 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 357ECC48291 for ; Fri, 2 Feb 2024 06:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=qM+xOFR4resu6dcSc9P6rC0nShAiVed4cou4yRci7wk=; b=yA9IqVbU7g0Y8w8m3dlknAsoip iuxnRLCphp6mv5+V1tbzSQBkb/h+ylouCDmhLASomadNcFjfOjhjwDFbnWft4K/6XvoJix6du7UM8 lQ92VVrJo7VEEhv3+jrzIvDRu/qCxfyZ6UfGFXDpPjfeM/sfJOXlHIkQJXN29S9+DRuK1M6ufe4d1 KNfzoSaClQ5ksJd5l7fj2zHlm98r7XBbPNZlaZPuh89vwrskkdPJxQr/nCD3P2tfHvoRa1P0iLSGk 6UMqjry4r9Z13jTultvfrZW2SORSCqTNN31P1x7kHtk5rt9C+JceBktTqE3/oWHv8nQsRRCLPUoBB kiQi7+Vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4U-0000000AQSD-0E9G; Fri, 02 Feb 2024 06:30:42 +0000 Received: from mail-he1eur04on20601.outbound.protection.outlook.com ([2a01:111:f403:260f::601] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4P-0000000AQNl-2bGo for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2024 06:30:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VuvFTd5NcbxVbex+DdnK3oEfAXu1PUG3EpX4AtwJiAIZ0xZGlQDdRhpLOaimwIvQ8Lh0m62IPssNNfUV6chA7gdtIHdE2gVvz+VneEvGkzq/5tfJy7dmrjV/WveZmaiXydvPPnZ4UjQ3nOLYWPWgcZInmrnRB0MVkO0OC6TjvOJaZizE6VdFeqUVBIWjla5Aq1THNBUqLEAqCg+Snk8+ZJQjtrpXR4D/A50kBKgsLqX9YDvoa9tQxDRMkPD+EiQvu1tqBMt0vf0faP+58LZlaQKUl0Na6QGcXEigl1DjwmRxYOmKaVt7Z8SEUWIwSPauK/sR7CJ8bVB5DV5J3xPV7g== 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=BDdJ05RhwufQkaXVU6j+MQLL2DZqoQcZuNvMQa4WyyE=; b=cuVa97ea1uj79zAEtOiHZfkOni084Ss6RiJV/gRz/SIXu+dahBDqEO0FS4rYV2lzXrArJlqh+h6CKkTezkCTBK3QnUYojkcAfOqHXyfM5fCW6lP/ZJvQffmnGamy4b1uT5nRpsjzvMgruRfdDROQzb/f73mHCDIipjUf4TPa5p3fcpfI04rNhWGi8yl5STd6OovtUFi2ShwPgb/L6M4kVdQF/l3fdZo/qG9eDcumodF0L/IXHnZbROXexXou4DQ7WgUTBEasELxmlyMXIBb9IzIPYTyoKPNJK/PeKr/Fk0NyAJaxXirf0Y0Kvpb/QD7ZpQ1esln8617CzvglN+cWqw== 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=BDdJ05RhwufQkaXVU6j+MQLL2DZqoQcZuNvMQa4WyyE=; b=e0KUlduKhoKq6aeoJfpFu8N/PSzVw/QEid0aiySOSG8hMO9XUQPKCSXuz0Tdo98mCvTTWwcMaWzvSMKxss3Tu5vg6TDO/BwSwjGP1UOKeUyDVx/aXxnhAD1S0pSi4hm/6Sfsv90JBWqtNPIkzGZe/FGWRlDwlCcxFHxImgITRgc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 06:30:32 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6%3]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 06:30:32 +0000 From: "Peng Fan (OSS)" Date: Fri, 02 Feb 2024 14:34:40 +0800 Subject: [PATCH 2/5] firmware: arm_scmi: add initial support for i.MX BBM protocol Message-Id: <20240202-imx95-bbm-misc-v1-2-3cb743020933@nxp.com> References: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> In-Reply-To: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706855688; l=13433; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=oRArFReJUPXPh7xJfujn3ilyJwTRG/9bXnkyCVvqurw=; b=fOG8CrzLnU0ZaBJqY9LNB65g3odJOEl/9MbQmiTr/jN923qoTM6eMu9Hw1CZ/zi7+Iqt24OId 7NFnFjSfUosAW/Yn4BQgW0coJf2Eg7A2zaUa/DUXwW1pIJuSSyJ30oA X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:1f5::11) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM9PR04MB8604:EE_ X-MS-Office365-Filtering-Correlation-Id: 29299557-7343-4a96-c67e-08dc23b8750a 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: SoOJjFp+Xtf9bxzu7GoRnJ8CEJ28+eDQRZdonD7Fm0sEjjKqsqliT+18JG6ErY/wH8GOSgEArFuT2B5iMpgXX1X4WRcX/JODDEJ17m9loTsVASMME5HHbQgm/QhEzrE92/fAN9jn0iyL76Lb081cUr8VOfJiebalWtwHFkTfErU4xF4oINQRhOF+zDrU7MjUDDM2x5tup0aG26qiQsn5c//qRV0zA5+GASMGf/y3NxMeIxXW5422/6bKjPCqgY0GtlI0ZGcWeyEndix7HtXc5ejLoJD7S0qEGlYm0xxrRjpp4P6D4EkWf7cE8X6jYylHy2FiplNeTe5eazFmFMvvavziESdLEK0DTEV1OqdEN4QiEr8EUNuyDFCbFGNEu93CsnQicrpkYtzy/CnRQqahM2kslH/lHhevFigZaPQKHNjM2aFiDKxVwAUAccOYmB3RIGk6IPCl9Icn/YDnm2K16vfEMWQBHvP2Z4nUg0bXzBFmJkzXO/VB6YkRxtFuCfx1g84BLVuZryTHBov/+AlRXjNY1pYJHdvPfMa/L9CWqGYwIOmKTDbPoLanxCoHNnwEYe6dEXeIU2IElc3nsVwWr2/dmmT42CzZ+7o32RTrUersFzUsvpZaamkrqXgNgmSt89QIDXSQZyPrFvmrsHOoDw== 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)(376002)(39860400002)(346002)(136003)(366004)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(9686003)(6512007)(6666004)(6506007)(30864003)(52116002)(8936002)(921011)(4326008)(7416002)(2906002)(5660300002)(316002)(8676002)(66476007)(86362001)(66556008)(66946007)(38350700005)(26005)(36756003)(110136005)(41300700001)(6486002)(478600001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PSpHkVh3xas4E1iBll+gaoq/lswl?= =?utf-8?q?/J2BtDCpjVPfz/jMz27u5PpxPD2UJTJ11xU8wO1LXeF6zqiTFmz2P6YbJ+IGLAUXP?= =?utf-8?q?icOxo4oZN8PuULJcObRVBTyUpZ9lHxCJk7sVX7bPKQ51iiyGJVmWjUt0eFT7br4JF?= =?utf-8?q?NkJ2jA1tZ5jEi5JSiz4WbvNIMOEjTTAunE3fpAq0Ef+FftoALLf9nyJTv/IPw7Sg1?= =?utf-8?q?xs57RoD+TvEAOxJM7tskM/jw7gRqkYifiXflvLI/3hTkljzWBchxwxujrs0ar+1Z8?= =?utf-8?q?Eats4YzvtOKkw141QT9/OExCJGGcsYpjjp3dQfM1guE2qMVQOlBE8jjtLOUJMfA5d?= =?utf-8?q?fi+gBkwizQx7713pZyc5As/UCNrwLgyMhw81mwyxRO4fIcLQv/LX3FQc3z1fL+K6P?= =?utf-8?q?Lbf8B7vb/xImE6oNPwl7tFDrg8nPYGWq4OlXuzpfZDIw9MT3Woe7DOpuox/pRzkCO?= =?utf-8?q?e8vWv8lRxOo5dUtYaXixmYxeoJKW5OojjAcU/dMb76JekgUAIufupeAgo5ywMWQ8R?= =?utf-8?q?nfPCxfyx24PhI5fOCSkWod4C+GNOelHvNwwukzejrzg/9YrI8TBpkqr+etxUSi8P/?= =?utf-8?q?1H1ZmqfiNAgrhe2IGl96XuIaC2njlVrhw9mpQO4J8MWMXuoHMij66OHiWCeqg8/xj?= =?utf-8?q?T24iep8937iPyGVYury/MzlvX9Bgfv01kVsDEknz2pb46HK5fJWpkcHa5T/t1QoP2?= =?utf-8?q?iLh87WSsYh852OVD2gCAzCDBv+nm8QcOE+zHoN4uztZgl6tGK8aGS0ZqCtM7FCh2H?= =?utf-8?q?zhkdDfuUTtvdD5hmQ7arlXoD17/UTqY5HUarA1bUgrJYI4u1hVUTw/krBayKElXeZ?= =?utf-8?q?KHO9c8kn/LfHVrEy79BCIEXkIcYWn1xSFIFGspfneVq8Kz1sTgq4q7MRT0RLRdWTV?= =?utf-8?q?FxW8f3d6BqXnoUJ/m7GHgUr4RbhyXg/OArJ676cQylWX6VizXp1L6I4OmhCFQ7eTv?= =?utf-8?q?0cAn/eJ5kCorEj9HzY9V5QDm2t8VH2zrGYFz+402bduIcjgGfQx7vXWe+BvY7Svub?= =?utf-8?q?cYwnTma5lPvS0rJCTr/BLzvCCUFUsK/9ecdwB1SkmfVbNEjqvLlYL0yeTFpKCVoT4?= =?utf-8?q?0TPIOe1oyAoSsNkLif9xuStY/5RD0GwBLzCBGL5D8rhu/srZqynpWLF6pBUcesD6w?= =?utf-8?q?axa7UQvvQ+NYQiB+0Bi0iJG52D0OUMFN+q5C6MncESuLzOLG/rJUdbhIbvUz3Y0+B?= =?utf-8?q?ehoPw1Oi3jcJ0i3NNVSBUBKAZutbezJEgZLmnjyC0QeD9xuLqFeZZ2rGdD4xQAUrj?= =?utf-8?q?6vgiaxR5p1Ix+um487/ytr2Xko6SkEVC1gTtgz8QeI/7P/akijnGU81nWI4KmsaBi?= =?utf-8?q?zl19du+7m4xce7pYf2U22QtoF30pXJSig52tjlcqxte2DWN0gqczPyqPnuyQbB1iM?= =?utf-8?q?NXvEwQTQoJq3xW5ylkivpk97KbWa/3qdeUYqYm56bpa4pUilvp4+/s6NPSJEgHGcf?= =?utf-8?q?3p7UguVeSvbTcvLbFDAbkDVhVTPj9kna0sjfqTvHysN8UrQWKjaICoxlZ6fnNyuMw?= =?utf-8?q?pFLgtMWDdVlZ?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29299557-7343-4a96-c67e-08dc23b8750a X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 06:30:32.7740 (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: mnm7l1UNd9ZduhFn4Nqe9ygwVkLgckA/1+TnmGdHxRdHEWkdcC5H4MDLIQHDHcWJKYwD1OgPW111HqzmGENF4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8604 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240201_223037_850755_E0D638F7 X-CRM114-Status: GOOD ( 17.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan 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 | 381 +++++++++++++++++++++++++++++++++ include/linux/scmi_nxp_protocol.h | 50 +++++ 4 files changed, 442 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..0e12aaeabc42 --- /dev/null +++ b/drivers/firmware/arm_scmi/imx-sm-bbm.c @@ -0,0 +1,381 @@ +// 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 0x0 + +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 BBM_PROTO_ATTR_NUM_RTC(x) (((x) & 0xFFU) << 16U) +#define BBM_PROTO_ATTR_NUM_GPR(x) (((x) & 0xFFFFU) << 0U) + +#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_ID(x) (((x) >> 24) & 0xFF) + +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; + struct scmi_msg_imx_bbm_rtc_notify *rtc_notify; + struct scmi_msg_imx_bbm_button_notify *button_notify; + + if (message_id == IMX_BBM_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) { + 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 = SCMI_IMX_BBM_EVENT_RTC_ID(le32_to_cpu(p->flags)); + r->rtc_evt = le32_to_cpu(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(1); + return NULL; + } + + return r; +} + +static int scmi_imx_bbm_get_num_sources(const struct scmi_protocol_handle *ph) +{ + return 1; +} + +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 = { + .get_num_sources = scmi_imx_bbm_get_num_sources, + .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), +}; + +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, SCMI_IMX_BBM_RTC_TIME_SET, sizeof(*cfg), 0, &t); + if (ret) + return ret; + + cfg = t->tx.buf; + cfg->id = cpu_to_le32(rtc_id); + cfg->flags = 0; + cfg->value_low = cpu_to_le32(sec & 0xffffffff); + cfg->value_high = cpu_to_le32(sec >> 32); + + 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, SCMI_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, SCMI_IMX_BBM_RTC_ALARM_SET, sizeof(*cfg), 0, &t); + if (ret) + return ret; + + cfg = t->tx.buf; + cfg->id = cpu_to_le32(rtc_id); + cfg->flags = SCMI_IMX_BBM_RTC_ALARM_ENABLE_FLAG; + cfg->value_low = cpu_to_le32(sec & 0xffffffff); + cfg->value_high = cpu_to_le32(sec >> 32); + + 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, SCMI_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_nxp_protocol.h b/include/linux/scmi_nxp_protocol.h new file mode 100644 index 000000000000..a2077e1ef5d8 --- /dev/null +++ b/include/linux/scmi_nxp_protocol.h @@ -0,0 +1,50 @@ +/* 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, +}; + +#define SCMI_IMX_BBM_RTC_TIME_SET 0x6 +#define SCMI_IMX_BBM_RTC_TIME_GET 0x7 +#define SCMI_IMX_BBM_RTC_ALARM_SET 0x8 +#define SCMI_IMX_BBM_BUTTON_GET 0x9 + +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 Feb 2 06:34:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13542136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECE2DC47258 for ; Fri, 2 Feb 2024 06:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=uSYImCELMHUvcmZRG51zMQ8+fKsdU4PRspZnkUAGr+A=; b=01d+IRmdE46Br6rQYkndIYsEea iVBZKJnNR5boZ/ynke22fmoH6Y8UodBWINYn4yUUnXo4yhHIJWzwgDkemsPamoo4lJNxdZiPyWTxZ Q7ine06uGoumUb5MJgRLDhpfPP1m4qlWuoPs6wk/+3ISGyFBzbiZASbS7LNkE9XC9rQyhWBZDZqWL RL3X34pKBp74sgLJRWar1CYm8bkGCEcCzCQznktfrh6CMkQKcjdHnpq0Jde9XeB8yJU+LhhCfQlxA bWNeyW0CI5uapjfIMazoS+pC36tFfNfT7yRQYSz6eURutDfrBSiG/KAFEkfBc6gJFkbTiDmouev6s mKD1wyMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4V-0000000AQTM-2DdB; Fri, 02 Feb 2024 06:30:43 +0000 Received: from mail-he1eur04on20601.outbound.protection.outlook.com ([2a01:111:f403:260f::601] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4S-0000000AQNl-2UCW for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2024 06:30:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SI3sctGxh9rDZ1lxC6vCzagAT0x7mgfjWtSKq2fr1DfiNSvyEs4Dqslgkp/56BGeRJ4jwIUa0SG9DIeF3ztBGVOxHGh11ll42UcZ67KJS8S0uelFtEibFCFPI+DUvS3YrJNbQeSktKrEeEvCn5gKMBTQP3hjbfuJPkh1k/JNQ12p2/dIZrXUQqCM9IyKp7xABtKvybCQhbe9udWE+FqtBZgNlzWK1L3eXqoaioctZxPSvkaEi8iHyiQGS2XuscFRuRvd6w6WvJMzQKjTWh1nR3o+6tOm8zHw19ho2/q+rpYyCqZ9b0sQVeFgzLZKPNGIhup0pkKAQJL+LcUls3PdgA== 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=FIPmRhGYBZcC9nmdc3gAJL3q6sFDELDgVfbdQXGNaGM=; b=S6wms+knJHgr4mXFdQNIcI84KfAnT+IIb7eOFYZstt0h/BMmG+ibShgXUu0klaS49XRWZvhcnpzB+OTOGjmJgDdf1qslAqWBcwYEWFloRFRDaPI589SIM//VpI7Y9h0xpq8jKvJI5aItBDpZDUi/TNifKZ3sQGtTir7QwKgmIDi64axgv6B++f4gokLgPY3NpHsbsqdPl7t+GreieQHtHpd2My71Ui7kTsgKCvUT7iQgACBrdU/vS7GuuBBmM0mwmIMJPqvpMhcG6pkTDU/dI5c9+P1MGPqkc2Ii4KCpW8VxX6rnYxoD0+jJTmj3+Z9+IA2kwS7hSdicorIMH9WWFA== 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=FIPmRhGYBZcC9nmdc3gAJL3q6sFDELDgVfbdQXGNaGM=; b=XW0nbITOUrGWvLXHMZzWyv7L7nCCQ+1XTOAlftg/KGq6tWRYcNGytJSR0m9XKV2CgHVERgyivPleNbWTgWscOMAEQCvsm/12YjzPBl5ET84CIPox6wfx3OIk9amid8iGlth2ebjOrjVwjhSG9T5q98oL+NwW+QBBR5l97XdFlrE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 06:30:37 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6%3]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 06:30:37 +0000 From: "Peng Fan (OSS)" Date: Fri, 02 Feb 2024 14:34:41 +0800 Subject: [PATCH 3/5] firmware: arm_scmi: add initial support for i.MX MISC protocol Message-Id: <20240202-imx95-bbm-misc-v1-3-3cb743020933@nxp.com> References: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> In-Reply-To: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706855688; l=10438; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=tZxW+mINZL8afIXv/OhfnOalP2oB6/24XR+jpplh/t8=; b=xFDp/C3pFXPgK+VoEN28yQfJ34LalKuNZCQTiO5cSvfEEMKug30ZKgjXULxmcUK53cqULm0ny vOhlbc24tWUAEHfmTMTr4ZUSzSUFaCRFQqD+AON066jNIpAGdg0zXVM X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:1f5::11) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM9PR04MB8604:EE_ X-MS-Office365-Filtering-Correlation-Id: 24d53390-c4d5-42ec-c135-08dc23b877d3 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: JT8KgEXkPxIP1l6ylx2BraRpU6KPmqfr4ixZZ0TFLmCkG27x2p3ZMVv27cA2IEHmmYuASjXFF4BYGDKWsymIZTOlIe3CoAP4a76/V7CdQ1uElfwdALaNYpfmBdC+7XE/LWQr6I4noJXuGgM9AYqLhwMThFyyGl5u1nkb5tJEYhAjtZV+4yNKudkvub8qcLMggNmzXhxI9vyPCD7R66v1f4D43gWM9wnCRaOLsFvH3pXInx/PMNTww5DI4r4ZOaq5vDh2NmBu+Cpt4lFS8WgYrgQ6cndBMgSdMF1cEfr2z9v9UmxprnoEjB4wwy2Tuv0WmEaOY/2K+p+vV8vQx9CMnCgoaZ9VnzZanY1D1xyNXgZxhkFEwwF+cBOCIlUVBdgONgQinoegGv6ASugeH7i3j2qRXJfcS1ZaV1bQrEtzu9U8ssbRToMozkflB1fDAk5DvdMWwXJehK7Cw1Sr/7KS0v7cA3u+JufUZAnaxxDQG0eKVPgzvxn3JpEQBvj4Sv7s5DJIH4UY/HuyGN5Vf8N+IEh+g4dMFqOkUYDnXdRvV5SxGbyEgxo1ttTjCe1OM6xN6k8Dcdc1xtElNVW3rCCty3mRIgSUqU8GxClOD9Ehgw5+MpLTHcYXGAybu2UmMf+RoqQXdcZFA+DXyxKyoLE36A== 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)(376002)(39860400002)(346002)(136003)(366004)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(9686003)(6512007)(6666004)(6506007)(52116002)(8936002)(921011)(4326008)(7416002)(2906002)(5660300002)(316002)(8676002)(66476007)(86362001)(66556008)(66946007)(38350700005)(26005)(36756003)(110136005)(41300700001)(6486002)(478600001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?x6gzWSmVdVnISWGeq0NEajAY1Bfs?= =?utf-8?q?8JaTwScz1kCMTLMtgaA7xaKlR3jErOsIhHZXfs6u5I9a/cTlgLhOYk/8v+jI3Psxu?= =?utf-8?q?9xJduOmm8vtjYmGuPPzjjDXIdAJ2zVSA3MYCGIImqDY5FaNMTfmW/pAqC8xsZmPnl?= =?utf-8?q?+rERhycqxm520fdQjuD5otjgJGb/1o7cAmTm/Ci/tFgFmUL02f8MHSpHQlz/7Zw7x?= =?utf-8?q?4rfCyTo4fzjf0aUOy57sN1qrclM16U7LKCHG5WNMKXT4rmWvavS3KKLCo0HsmIBnU?= =?utf-8?q?ZVvsawoELAlYeQcULD/hBOmmeMcm64esjOTij2kgDPmd84h4YbCIz1ASGarYdVOFE?= =?utf-8?q?SDz755YYE+r8+4FssBmnVxmljBgMOcz9hHD7vxV5azb3sgnbONou4OjaOHxXLm8u/?= =?utf-8?q?E2dk61mHZkSMoBMXtUNcyaL0tRRx8z97Tf9qYJaa7n+o/4w9O81hX6BVByvDHAdtS?= =?utf-8?q?hnD8T/yQJ8GZR2cZcbpOvAPsKAEbF0M0UKA16dLdWUDzg7Jc1EKESLl+/uVKhlxDk?= =?utf-8?q?h8GRTjYLgLeUqVF5W0df79V4SjdA/TPVH75B2W9Udnlezngc4K6f176sAqFvhVSzj?= =?utf-8?q?BY6guwC0d+97d6Vea46wO/cTRg4+OIaP1frWCJrD9Lh1kCuPBM8X3RMKI1gOQ2Wxw?= =?utf-8?q?H5FJPfR2XNn4dmD+3LGZUwTzNeWx0RJy+XOCQaP7M0NP6fyj0oZAuLoxqTxrwhcO2?= =?utf-8?q?zIEXfZb8Qry4rEU04jO++ex6UiEj242TqUbMYYWlMvHA6vjFfp6WaBd9zXHOXkevN?= =?utf-8?q?q6O+1twmNyjdSKhfCphqUwHglhrsUwHHxH7zYcznIhbExnW4auwdntNhtvMp7d+rS?= =?utf-8?q?BIXU6HDni3sYaQfKXAkj5q39Tm2flDXmWotJgKQ1BOPMoO4uh5h/zmtoEdv6U4YKC?= =?utf-8?q?qP0DWsnMYX7y3YwIE/KcuAH8TYutmQ3qpATPPReIeFtl221xSBwSH7zszTjjq2E6q?= =?utf-8?q?npg23xbSkAYR03EOsSXmxJ6mXvyi/SblqmfkYXzoeCgJM3dWHcZWk8yqG5lOgwEGB?= =?utf-8?q?RoKDfIBr2uilQLlW0u+jC/4/gKQwjoOizOXoqxoXXucCQhtv4MuVVXj04NcReJbUw?= =?utf-8?q?FELKDTMvXfQJATMOlXrZN6ZfKjL0iM9/o75HZh61nyC9o+jCTat+fakAPB3GEpqbb?= =?utf-8?q?hlBAcZ74FaYZvQoFq+uf18iua0bMKt171uYSo4Z3ad+4Uinlc4pHsYC4WxhQAaOTc?= =?utf-8?q?YXH/rsbuTbzvMsRftSmHZY/3fPwagbnBfidrIpyIxWHzy+iDZYmuMPMjNu2qS9Gq+?= =?utf-8?q?29+7XFMBNkuov9hlFg2dQrvEyWXZin/Zgf/XY4KAxU07SjgRY6HGS9Xrsu7S+hzqw?= =?utf-8?q?9dreqpJDJ4mcRCarX+jv8u4Hi3i0QAfqd4ji3g30HHh6fPzaRbTD3TL5vM66+g0nu?= =?utf-8?q?y5U1VcBg/F/paBXdoloo+ljw07a5QvSDOfsGWlMELwHoX3OvkwnFK1be0lFDD0bWo?= =?utf-8?q?eccsTFfFR9oR+me/IEzs+P6YZIbbZB0j1KLO0kBb3Nas/7dc/BVfs0ZwsZJSRkKeB?= =?utf-8?q?tneAZAHi/es9?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24d53390-c4d5-42ec-c135-08dc23b877d3 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 06:30:37.2111 (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: pM8Ua20QLUpgZbfYKvI+futhA7/qAusPTTqIDy359ri9Fu5xy8hhxIyCxEjoKG9lHVhvWHlz6jWDbRbrNUg/bA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8604 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240201_223040_692646_61994D1E X-CRM114-Status: GOOD ( 17.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan The i.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 | 289 ++++++++++++++++++++++++++++++++ include/linux/scmi_nxp_protocol.h | 17 ++ 4 files changed, 317 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..7805d41cca4d --- /dev/null +++ b/drivers/firmware/arm_scmi/imx-sm-misc.c @@ -0,0 +1,289 @@ +// 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 0x0 + +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_ctrl; + u32 nr_reason; +}; + +struct scmi_msg_imx_misc_protocol_attributes { + __le32 attributes; +}; + +#define GET_REASONS_NR(x) le32_get_bits((x), GENMASK(23, 16)) +#define GET_CTRLS_NR(x) le32_get_bits((x), GENMASK(15, 0)) + +struct scmi_imx_misc_ctrl_set_in { + __le32 id; + __le32 num; + __le32 value[MISC_MAX_VAL]; +}; + +struct scmi_imx_misc_ctrl_notify_in { + __le32 ctrl_id; + __le32 flags; +}; + +struct scmi_imx_misc_ctrl_notify_payld { + __le32 ctrl_id; + __le32 flags; +}; + +struct scmi_imx_misc_ctrl_get_out { + __le32 num; + __le32 val[MISC_MAX_VAL]; +}; + +static int scmi_imx_misc_attributes_get(const struct scmi_protocol_handle *ph, + struct scmi_imx_misc_info *mi) +{ + int ret; + struct scmi_xfer *t; + struct scmi_msg_imx_misc_protocol_attributes *attr; + + ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0, + sizeof(*attr), &t); + if (ret) + return ret; + + attr = t->rx.buf; + + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + mi->nr_ctrl = GET_CTRLS_NR(attr->attributes); + mi->nr_reason = GET_REASONS_NR(attr->attributes); + dev_info(ph->dev, "i.MX MISC NUM CTRL: %d, NUM Reason: %d\n", + mi->nr_ctrl, mi->nr_reason); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + +static int scmi_imx_misc_ctrl_notify(const struct scmi_protocol_handle *ph, + u32 ctrl_id, u32 flags) +{ + struct scmi_imx_misc_info *mi = ph->get_priv(ph); + struct scmi_imx_misc_ctrl_notify_in *in; + struct scmi_xfer *t; + int ret; + + if (ctrl_id >= mi->nr_ctrl) + return -EINVAL; + + 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) +{ + struct scmi_imx_misc_info *mi = ph->get_priv(ph); + + return mi->nr_ctrl; +} + +static void * +scmi_imx_misc_ctrl_fill_custom_report(const struct scmi_protocol_handle *ph, + u8 evt_id, ktime_t timestamp, + const void *payld, size_t payld_sz, + void *report, u32 *src_id) +{ + const struct scmi_imx_misc_ctrl_notify_payld *p = payld; + struct scmi_imx_misc_ctrl_notify_report *r = report; + + if (sizeof(*p) != payld_sz) + return NULL; + + r->timestamp = timestamp; + r->ctrl_id = p->ctrl_id; + r->flags = p->flags; + if (src_id) + *src_id = r->ctrl_id; + dev_dbg(ph->dev, "%s: ctrl_id: %d flags: %d\n", __func__, r->ctrl_id, r->flags); + + return r; +} + +static const struct scmi_event_ops scmi_imx_misc_event_ops = { + .get_num_sources = scmi_imx_misc_ctrl_get_num_sources, + .set_notify_enabled = scmi_imx_misc_ctrl_set_notify_enabled, + .fill_custom_report = scmi_imx_misc_ctrl_fill_custom_report, +}; + +static const struct scmi_event scmi_imx_misc_events[] = { + { + .id = SCMI_EVENT_IMX_MISC_CONTROL_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_info *mi = ph->get_priv(ph); + struct scmi_imx_misc_ctrl_get_out *out; + struct scmi_xfer *t; + int ret, i; + + if (ctrl_id >= mi->nr_ctrl) + return -EINVAL; + + ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_GET, sizeof(u32), + sizeof(*out), &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++) + 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_info *mi = ph->get_priv(ph); + struct scmi_imx_misc_ctrl_set_in *in; + struct scmi_xfer *t; + int ret, i; + + if (ctrl_id >= mi->nr_ctrl) + 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, +}; + +module_scmi_protocol(scmi_imx_misc); diff --git a/include/linux/scmi_nxp_protocol.h b/include/linux/scmi_nxp_protocol.h index a2077e1ef5d8..45415a6ff845 100644 --- a/include/linux/scmi_nxp_protocol.h +++ b/include/linux/scmi_nxp_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 { @@ -47,4 +53,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 Feb 2 06:34:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13542141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84395C47258 for ; Fri, 2 Feb 2024 06:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=aiUtyr+/thBAZs911/wz+ZthNk5Zhhk6p21qrVW9RMs=; b=kgYNxMUDXcXNDNzLkNzIhFGHrv Sq65+aLLEwzTcMpFDpV0Al/5Bhazp1JJKO2NixAVVtRjS0d0bLBVSt0BIfU9z7ljbq7nUsJczQcNP XgtUFKfcG06JG7gMysmK2pgNnjVzIA+ylRekHAFiRIQP0vfxm3SFMApc6WeVhNtaWzMiiBrv3diSv a1mJMV6+GkdE4SoZDMPwm77GEJGc+c05tW2l9VVEPAWHinueoi0R943tPGagp0H00TMUvI7w1zVnG eugnCcojDXVAHK4aR5dmYKHvblUwHUZlewx2uUTjYrbO4Fb1ABUhE4wLT+IXPE2OSxoiDp5fe0bGx wbDoB3Ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4e-0000000AQXl-3N4G; Fri, 02 Feb 2024 06:30:52 +0000 Received: from mail-he1eur04on20600.outbound.protection.outlook.com ([2a01:111:f403:260f::600] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4a-0000000AQTa-3WRe for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2024 06:30:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkD5JFORGK175VtD63EQiLJ8HHZgCmQMLcyE7v+BcpcwOxGkOSSaIMY30iqIaBK/tTrgKpgwuQ1HI7bd5RzD1kG7lb7qZCj1Fkp6tTznWcZmNg2YxqtYTh6CM5vKUwa1ZjPBicnPTld9RpE644qVNOJIW0y3lFX8QKNt/17hPgYhIIBiW0GXKDR7ACcUMtARrOW01Jv+mC4ejIiUMsLwU2Iz3qBDWTYrBWS3EoqI5oEM3fKaUZdU3bWJp89hlW82yccoyO0gp6QIeETehUpAv2TvYq6wmhMDjhvfqs14zJt1juALl2zAWEnV33yBkaMgdY9WCMR/qSJTFq8pSeU8+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tY/IS7Vtj2DJ3guZOJa0tmbF3oF6souaDnCA+Gb6Uc8=; b=QgHZydzdJvDxExZkyknxnZmkXsN0cvHaj1x+JO/BFgSS1tOWtGKXDikbeW2Da3ooyf0rk/UtYf3eLiJWc0GalRAgP8L7p1a9JDUAWFetnaTXtz/okmm69mNtSViH3N8WOnDp+4levhoAczpz7W9laH0pgU0CYgkm/q0BSKOGzHKwP6xtgXdHaPpteYdkuclE4l6XpraAotCLNg870M+4TsYw/he0p2AxmUHJEQKYU9/wgOzGVeEbzpQt09uAlvoSWk9SIcLS2J3Vk5M57I4+mF5akBNH1+niOd9V+ehXCy6A37X6sSMCntiTxYJFlL9hBm4GgGUR16zF9HepKrPW7A== 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=tY/IS7Vtj2DJ3guZOJa0tmbF3oF6souaDnCA+Gb6Uc8=; b=X4zml0pn4WzD3V3Bshgg/5gRq7yuiesKNIb//3dnz5/wN1ETpIbUA2Ag0OTELxFs3Yd7LELeErrTkiUs63cWDjaya7pxiXxGNj6eAYHB3qCZgIuTpTUsl7lKpexWPHV4pxG5BF/u794wvtwkRqqmsZwZp/XeeyV5JSGrqtPJKL0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 06:30:41 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6%3]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 06:30:41 +0000 From: "Peng Fan (OSS)" Date: Fri, 02 Feb 2024 14:34:42 +0800 Subject: [PATCH 4/5] firmware: imx: support BBM module Message-Id: <20240202-imx95-bbm-misc-v1-4-3cb743020933@nxp.com> References: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> In-Reply-To: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706855688; l=9360; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=bGPXYa2wA+R5Utwn/Cjyzw9Bhmxb9hyReBWGN67cbcg=; b=f7+QbG52VmdPpSl6W6bDgIfiwUzCoVU94MpctJjevbPhXzp5IIiM+MEI1ukZ2GZR83D59tIqy NGh15XB/XSjA7364wg8HoWHUBjd8m3zJ40NYsmBHSlCwG0Xs+cRprY6 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:1f5::11) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM9PR04MB8604:EE_ X-MS-Office365-Filtering-Correlation-Id: 35bcc5c5-0019-419f-82fc-08dc23b87a5a 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: WUN5N2v1sXdDUwVh3XMWHFRrCZTpg4SMl0jcG9ok7GuUQtOuv/6Q+tj0xgr6lBINiJzx4zCrZ71yXWZSe6+fZbgrZYEPc8CQTnr5SWGN6DRQuujZqw3QkdC5MKzsCrrMI3JPwMuQyPEWvdNCDLF5dkft0VfXAsx53lellHG6JYY+J+9THzMk8lvSZjIN89xKZDixLfPAFgbsNyN9anCSNj+u/HmFE4PxVIJwFe7Rawlo35FWUBLGIAcW6co/7u/bo0Z9GKtmpDaxkELh3hcbg7xgSd/XuBxxLsT3Ap41mr7aJALLb7hL+TBRnQYQm+bJuZlnqt4TuD/RWvqTjMrBne/ua5ZMuBUrocWObVk2eEnACkwIUuIcABKKJWd7KR5sQuWmM8M808345f6UbMEB7D5wcpKqW/vyXIvl7GT7QCiVH73O50JEmttXZMFnAFobKSeDTyCdCOL2dyWkfkC6zP5RBmS7m7V2D4Ohw5Dh3GaxwIaHm7UkzLr/7E35S9F7d6MXJSqRfrRu1Sbkb1LZqYaDyKAa5umKgSU6Qbb2skMJ3R6RFKeqAY03irwoPOMKio+c1wM3hdtYNaCfeGnM5ic66ABrUpPwaNrfKjH1u/hzlZ1jIyWe1eproRkoMLgwoeXFj1AMXmmhplf3TaFosg== 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)(376002)(39860400002)(346002)(136003)(366004)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(9686003)(6512007)(6506007)(52116002)(8936002)(921011)(4326008)(7416002)(2906002)(5660300002)(316002)(8676002)(66476007)(86362001)(66556008)(66946007)(38350700005)(26005)(36756003)(110136005)(41300700001)(6486002)(478600001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?b54nxUcRaa/ea3XVIAFCAXDs6QoA?= =?utf-8?q?kpERzvUI2HQhul0Eoo1piVJ0LZgzar801ADZXLT0uVKwP/FQBVafxMMFh4JY9gzN1?= =?utf-8?q?KcekFiM5QXflawFroCijwqSIiQZ020oVPV/rfx2c+rtpyhapqZotNknaC3PbcfgIt?= =?utf-8?q?8Ab1e+tOba7y6GURruDOZAVQZ07gpOL6Hi/25VZfOtYGT4Nm8lJzNfnkeDMSnMnEj?= =?utf-8?q?akGeZ62rgGyzB0qrY23CvwmGoFi+tlYklFt5xO/4tGyp2BI+TUSNczg1ItH+3l117?= =?utf-8?q?0SBrrEKlcTvRGLb9ka8vtLShix4tTox5eXyYpO5G5DmM/1ofuxE2UfrUlbWZwNNBB?= =?utf-8?q?6QT4sqENqikm2d2aFU2BojEZn8H/eQ4X16qerg+SsEuk0Ft2Ee/1HBGuet57KTFyf?= =?utf-8?q?PsviRcBP2DHFzVfGKQnMta0l/X98pzSdhUhkOE482btuVSRQ/S9WQj7QYqc1fkEAM?= =?utf-8?q?FBmNHXiibcA7t0w+o33aUqAuy+IY3VFdDHQZO1nHj0bIfaFE5G+L0x/4B+YEbc9K8?= =?utf-8?q?6v/yUeKoXO011F1ZRjTG8eTsX5Y6eiWjxix7H55R3oARgNbx2zMwWW+YMJ+0KeN7x?= =?utf-8?q?jPeYwEARvTFQBJ/sRdquccNDWWCcLwzCHoB6/ErvcR//mL7/zw6UI1JKSJ/Ek5t4z?= =?utf-8?q?oDZ4+YhlgQcyWl6HXb2jhdWUN7y7fS7sYh4zS23RfYqJ4/CEctpQA7xW7vqZl238U?= =?utf-8?q?YqGXmrm6YGaXgKdIM3wKEmjnNJMyN4HCiouVUlU6umBzJU8rrlKZ54WSicLunNF8q?= =?utf-8?q?I/FSr4aqD3OGjrGxK0Qb/YLoVivvkfov6NC5C6tb/awRXkhgPK/blt0IIBi7YOTbO?= =?utf-8?q?eEUmpv+yV5FmiuQdmv4cq9QFvONvtxnGgOc/GhlFfCCseJR5PehmebfJeCgYI2CvK?= =?utf-8?q?PycbIR8wBpIhVLg3gd076LWODZDRS7RjL82az0Or/kusx34nSxr3ch0ehB3X/7jOF?= =?utf-8?q?kXSgBzBHYhGTodBBga1/8YsQragNpAw+DLIS5wY81acJMkXYbxbU5HwcHdo2VAE95?= =?utf-8?q?Kb7d3bvngqyTpbaP+emnjgDvuMiSL7Y0kpCKkTZRJoeRrzNsuOUomDMDPNynlaecx?= =?utf-8?q?vNiU66/wEPBMb5mdFQLX03KdcXpNaWfm3STM3UTauqhpx6ac0ewWj2lSDofJ0vMV0?= =?utf-8?q?YLmk034wnnN90UWpOptYWxOEDkAOxef9xGNf5zi7daBcGWLX1izVKkI/BHzYdvmah?= =?utf-8?q?Dh8OLeRn/92EmhwuNhbg/yE4kc0havqTmeEqeYtZXTJdPqOYzInqdzaJig/vAC6fG?= =?utf-8?q?szIVvWTm2+DWIxGFnKpY7kB8O22VCFQ4dZTMfmjJXOIBCbqgNOE038EsTsEkeltAj?= =?utf-8?q?zuUmi5Pi/wiAOoPMSUHlGGIIydPMosIoxnK14s7WqOsXLtcEg1Op6oKvmWNxaIYoU?= =?utf-8?q?YUe2hxttpIdKINtjfDTYFAv+GnWR4bsQG3+mc0L4AdJv9+C+AW6uk3IuoNIgoNF5c?= =?utf-8?q?jCSDym7yr59sMz2DLSLkjoVT0IDU8b2t5xnG394oxc7eP6eUSeUP+1ObJ47NY2RK7?= =?utf-8?q?iWsPGNU32dlW?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35bcc5c5-0019-419f-82fc-08dc23b87a5a X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 06:30:41.5131 (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: IRqMbqmgn+fMpAD1bPy4G6Q1jl9dLfQHpAr4+A8GyRGLJN47rcDZ8swdmcw/XNfK9GU8yXNBcBxRBeB/fBinfQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8604 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240201_223049_106341_7F4C3FD8 X-CRM114-Status: GOOD ( 20.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan The BBM module provides RTC and BUTTON feature. To i.MX95, this module is managed by System Manager. Linux could use i.MX SCMI BBM Extension protocol to use RTC and BUTTON feature. This driver is to use SCMI interface to get/set RTC, enable pwrkey. Signed-off-by: Peng Fan --- drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-bbm.c | 317 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 318 insertions(+) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 8f9f04a513a8..fb20e22074e1 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o +obj-${CONFIG_IMX_SCMI_BBM_EXT} += sm-bbm.o diff --git a/drivers/firmware/imx/sm-bbm.c b/drivers/firmware/imx/sm-bbm.c new file mode 100644 index 000000000000..c5bc571881c7 --- /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 Feb 2 06:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13542140 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E60C0C48291 for ; Fri, 2 Feb 2024 06:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HoKdN5KyzvoIYx3CLrqAap0RNYyIUa0JXRhU8W2BfP4=; b=TmKpdd+pMxcEPopiiY22yr98WF QTylETvj5qGRjyrB7cYytov0r85Iqm/k4FEKhYSzIzv0wELE736fJbx8c18h4/UZjOOaVZTD/m6en QwdzlQPPURaXsYFxUVEcD78kKv7Szb6B09z3Mw0RCWMTE00Eu298g726+Z+689oLa6137nHuTQsDo B2PvH5fS4a90eZY+bdNO8FQYRSY0UHuH856bLq1oOT8sYI78Mr4Le++eVEx0PRVnj+caGFSnzfutf 8nQbxhe2TMFxhZKEqyC8u5/9ALplMHAHV/ONmKHidvG9f0mMf4aIdYCe4kvAokXgMp8gbib1EMloh hCNeuKHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4f-0000000AQYj-43uz; Fri, 02 Feb 2024 06:30:53 +0000 Received: from mail-he1eur04on20600.outbound.protection.outlook.com ([2a01:111:f403:260f::600] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rVn4c-0000000AQTa-3A1k for linux-arm-kernel@lists.infradead.org; Fri, 02 Feb 2024 06:30:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bhjtLWwiSogMkL9GiHQyFbHghBGBC6oFMLGeR2vWPYhYVT7Kbqes1YnPP2YoXo0DQSkdYZ0lFs7+M8YTThz4fkpLWGFp3sco1Cib3DLWe0PnX6DajWaZMPlIV93K/A3DREgScF+GLUiuy1HTtwcrpSx0tI5juugQLDAiwLgnGoZyyGNahrPVf76b2Frfr4EATKPAetXM34+9+WVdQyMJsQS7Ok49UHcilvIiUd/Uv5GvA3U8TRuwqovyaTtofyKKZJfqFiWLttPK/FYzMlvmznMawsyxCKVDT/5ZhzzXQxtoB/OZAmp30FDJ9Tq5G/kqgo/1zWKEtnbM6s4Dv7X5RA== 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=F/+8+PBCrKXHGNNHEE/QQiIcvFqinI1PO5Zudu9T9Xg=; b=MMlzPbV9x1deQrMSBWiUBDOA/8gyUAjOT0onzWpAfum4hLISC0Gli/MCxzhzTkMRwGmSwSDlPABibhLrbDHQ8PDzuDDEJ6Rqw3FKmeE6AcSyUzzd44TUnkmhl0C/QhD7sLqTSa3DztXMvb/mmTU1Vgx5kfIChZQcuySbt7t1Uz/cxDLL1PNHgoB54qXFJJLn9KEAwUZ+KxKi2wDeOekzSKX6hCpJps0Y/LhXu/NxCe1vsJpFyC8CpRdgKPBPUunopYJTD3zVZZKyIPCmZlgVO0QHgmRsvnhaA7NYLxOyqYMhDm4kbdeteF2SUH1NLzfemiMDgDO9ulP1SlmHykJKOQ== 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=F/+8+PBCrKXHGNNHEE/QQiIcvFqinI1PO5Zudu9T9Xg=; b=XdIdISDKB64YAeb2fpDWnaABB/QkaMVf8K109tmeoFcfAz+UIxr8s7MqqAEwkzXKptTICeQIl5K8VIxvJ2E+wPKetJLarvFcCcETf2o6uLgMUDKIu8XfQ7puVBe/LKcOJOzLlmqVZtYP/2W5l6gvU7IhdYHCWLhJMZqDKqVSMYg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AM9PR04MB8604.eurprd04.prod.outlook.com (2603:10a6:20b:43b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.26; Fri, 2 Feb 2024 06:30:45 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::c499:8cef:9bb1:ced6%3]) with mapi id 15.20.7249.027; Fri, 2 Feb 2024 06:30:45 +0000 From: "Peng Fan (OSS)" Date: Fri, 02 Feb 2024 14:34:43 +0800 Subject: [PATCH 5/5] firmware: imx: add i.MX95 MISC driver Message-Id: <20240202-imx95-bbm-misc-v1-5-3cb743020933@nxp.com> References: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> In-Reply-To: <20240202-imx95-bbm-misc-v1-0-3cb743020933@nxp.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Sudeep Holla , Cristian Marussi , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1706855688; l=4839; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=l1+u1wEujwpxZp3cg566GNVi0f6jUiKSXBYb9aNl0nE=; b=7kFiu0G+0ErsohkFa7SxRb4C2Xj7w1sgzEswV4UpIHy1ERHGa8HUp8YemYmW76B2mC5FsnGtT 2jGGZfASWb5C40TIEQz1T8gpNvOTQz4A0RghbBIqWcHBh2KPlEaT//K X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0048.apcprd02.prod.outlook.com (2603:1096:4:1f5::11) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AM9PR04MB8604:EE_ X-MS-Office365-Filtering-Correlation-Id: 330b7724-358c-4e29-32e9-08dc23b87cf8 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: AF+K50A9/GmAlwMXN9rOfmBjoiMPZ0ubmaXpMS/cQ8S5KlaOhpbs8MN9RjU7UOSt5cs4CAKPNzjY2s0t4y+gxkf6LUba6+2e2aRgiQv55EhrWWVdHMGmlLrp+nEm+z9C2fS9WHWDdi+NIfNBveIQ2rgTYl/r2c97z/llasIAk1lp+ROugKnScLYQz4S+NcG1DGNegW+4G7AMPA4V7AXMdcWnCxS6AEy4117kfp7DSYUgx/08JrCwGNPAj6Hia4qwYWnCO9dsv/fV/qnSG+YlQ8hks6Z6woBcRUCmZaZSMZqduGIPYQ/67GZk0B8PCbyMAJ9ZD+ULNzI/1Q7HFYCds9qH7ARSYEnH0LJE8mGznWuK4CURLyj8HFIElvK0yrro866wg5fyrXTXXO51LYfgEdbUphWdXxIehd32I5IC7t9h+AJgCs0d+L724SuW2LMRSEAUst88orjG0pXMBvYump0qxjXTHsoi/Hv4BwmUq8zb5hRrw1wvTQG2/XkE0D4/igJea2rucll7R+S1xWrLsKKu5Xm8hBy9kF4UFAxXF56llxSkFHZLpERwezbyIM2WAmSxiZfrJQ3u+kUHcg87Gpx4JpHxI6lptq3ouUfHoecNgQoFp+he5SOfcUrn8sJapulBSU8eu0u93skheXw+rA== 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)(376002)(39860400002)(346002)(136003)(366004)(396003)(230922051799003)(1800799012)(64100799003)(451199024)(186009)(9686003)(6512007)(6506007)(52116002)(8936002)(921011)(4326008)(7416002)(2906002)(5660300002)(316002)(8676002)(66476007)(86362001)(66556008)(66946007)(38350700005)(26005)(36756003)(110136005)(41300700001)(6486002)(478600001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xHJ6a5gNL5/jK4y5mvEmSKzOwDmU?= =?utf-8?q?LX13xBxobB56iIPWhXU7dRkEBSdKt0grwMFYl9tUSqLdv/i9vafXvFqloqX28kg27?= =?utf-8?q?qwGFdyCBhQX1+GGuaPivnFBfgJc+eTBIgkK+zZ5ZUaQeFgVVYx7jbx5lfyedahdrB?= =?utf-8?q?EZiRFhFfs5vvYtfAaj+vpnqa7FsFPi4p9NvyTFEL/fQPr2yduMwrzr6c1/L/+wBJ7?= =?utf-8?q?+fmmH0sr3nwZLGlymHeEd9q2k3p66p+sRTlyHex5wMFKt7aGVfzfK6ik8TkRw0r/3?= =?utf-8?q?EWtTTyo8i4QHKrz3SlG388delDGJFKc7ydh74t6Z5tsThdYtCMUSwo60ic0z5KdCs?= =?utf-8?q?Z89SnLWzY826KMW/cqYCbeoD7MbvCtyDS69eslhoZD3NdhSxSdZxPTh2Zc4Jk9Yqu?= =?utf-8?q?EJDBEudpPxYru7V+O638gZxr/1O9k7FuTFpVCADYnAEA+EOOvX+ePXI4DteDjlUrB?= =?utf-8?q?p0+opmFnM+UFWy/hIDjN2LUTRhHlGFg4L2LjyejfQgFg5/0GR/iZU9D3nMU9LbUc0?= =?utf-8?q?UD3rHpw6eX7L6otqpEtWrOLaP/TWZeTH9I10WZW+R3Xr/9ES8lXXU6PzT9ZfODBr1?= =?utf-8?q?GOkOchiP26fRKt8YNlDrkcEfbfch/k33HHulbMYDqhnyUOgmKOr28+dfWEi8ySg2s?= =?utf-8?q?LcBYP37zbzNz05fzkrA2hzTsJomv0icZXtISC0e3UiUic58d4oGY9KnGnb9KUASz0?= =?utf-8?q?m1Ha8YFfczsSIc1i8GP5d5hNp2wixzJVFNuO5e/gGsVHYwJvOBHwPLxvlbh9Cq0Td?= =?utf-8?q?05KL0Nq9v237uwbDuRW2R2qQyNWH8smkB49FRSMsuyJC0bn7COlHVfnc/UPoNZo16?= =?utf-8?q?L264G4JvWxMZ2OtiIjHWTxT3DXSRuH9Y4yE3Bn23hPzLiviH0wD90YABQw5FKiDHR?= =?utf-8?q?Ww3KigU/s4vE4+vasCCQ38SiVxM6XmC8gNcFqa2bK38hsZIOni8v+mRE95coXwdBU?= =?utf-8?q?ulZJVVQiar8eDZRzO/k3ecPCrLT44xk/LNAJYas36wjmvA5aujL+Bfl2l+l4iMdQk?= =?utf-8?q?/UikLZI0bhnm017q2jvE6NokgSxGQ9ODqMcNsjBjdlFvh81kF8fDacbYU+UJUVcG/?= =?utf-8?q?wuPAyO14X23P+gWynha0T3987Mdbs74I1H8qAmws2D5y/CA5jR+c/pP8Iyaxd+KOj?= =?utf-8?q?hYr32kXkLZK4grC++1zCmivLBlNQJTZMgfSG61/zdoLqOL7ZydjIaTQ4U8LtlQ/MW?= =?utf-8?q?KxktixME/UXlKjnS5dGOSuVXnv4P/DnUqQ5MbPNdcQWMC/kVbxpRvbd3kKYEJP4MO?= =?utf-8?q?ZqoKmGAY37L7z7S4HIVlqaoU6eum8+ddIPRvtUZZuwYyahX2MS4WiAgPcONMBZqG4?= =?utf-8?q?sq3sjxY4SMn0yf5hh8Jto2TNAhmTfMTkMSbL6cMM/tDKZ0VEydC9GXDEc69jG+9Zu?= =?utf-8?q?0jd4HiaJ7ai8zvt1a9bdjKl0TbehTxZCGUQq+QIGhjhHYlO9GaY4FmrxhoSK3rxr7?= =?utf-8?q?n0mrhmo3Etrd5GQ8gwZ2a0QpG4PcZzNjwgVN0uCtoi3eltgalauxYGZ9fOa1cKph/?= =?utf-8?q?lO+RZa+y5E1N?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 330b7724-358c-4e29-32e9-08dc23b87cf8 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 06:30:45.8310 (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: vIOm2y5Acm/Adwrpzm24d+6bnHZK2lKRvI+SmXSpzA88LE26mqu91cXwhT7UGgnN5fiYSQWxJKBfDriyxtEoUQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8604 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240201_223050_879183_E1E14FAA X-CRM114-Status: GOOD ( 16.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan The i.MX95 System manager exports SCMI MISC protocol for linux to do various settings, such as set board gpio expander as wakeup source. The driver is to add the support. Signed-off-by: Peng Fan --- drivers/firmware/imx/Makefile | 1 + drivers/firmware/imx/sm-misc.c | 92 +++++++++++++++++++++++++++++++++++++++++ include/linux/firmware/imx/sm.h | 33 +++++++++++++++ 3 files changed, 126 insertions(+) diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index fb20e22074e1..cb9c361d9b81 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_IMX_DSP) += imx-dsp.o obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o rm.o imx-scu-soc.o obj-${CONFIG_IMX_SCMI_BBM_EXT} += sm-bbm.o +obj-${CONFIG_IMX_SCMI_MISC_EXT} += sm-misc.o diff --git a/drivers/firmware/imx/sm-misc.c b/drivers/firmware/imx/sm-misc.c new file mode 100644 index 000000000000..4410e69d256b --- /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