From patchwork Wed Feb 28 05:43:05 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: 13574899 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 56613C54E41 for ; Wed, 28 Feb 2024 05:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hF7JVVE6JApXgJYp0fJQ6kuhzdPRb4QSYnVZiGeKBIA=; b=PHClYkBbEWDDEiwo83y9dWgD7W 6c3XoXQHjSqPg1Lpbd72Hodl2nVeXvqWeP0XKhz4Tq6tGczqbBNnhm7WMEFGOL9iwy/T5FNpleQbx rRkko0uUpy4W0xqWWZKuzCM17URUkTADm76u+3vDK+/eMbO43XY2ftZw9YovN41cXd6ruX2j1v+lF 7FOJVD/T6GjBlzgUUU3/QhhTVFC16k3ZzRHwGS++09NCcwV0QEvF2i6PMsrVSPl1sB7t2o+5ugr15 jRAiXsCOqKjH4d6Z555dvv/034X3h6duR1Mqek7yCrbvdW9eGdcQwyIalEiR83bvuoP8QrH4ll6sI 9Iu27GUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfCb8-0000000861w-3jvc; Wed, 28 Feb 2024 05:35:18 +0000 Received: from mail-vi1eur04on20601.outbound.protection.outlook.com ([2a01:111:f403:2611::601] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfCav-000000085uw-055U for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2024 05:35:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LAbN5/QHbd4GWjmx4blEacOURqnmoNX/PieStt5mBF1vO2OXIoj3InnhEqQgwZUjwP7PNLMIvzt41bjD6l8LwTv/pPWblReiZnip8cumKdpHgfWaU6Fupnx3YvHYdMGp3U44B4lMxByKlupbrlZxcXxyf0QCpA/ViPzxtaoR62PT+6Rjj/aAeULfjSGMMBC+DEJuunl2vYVZt0uBlTUcKLuZ3s/KPt05axHuTkBto4kGUQI9mW30wzag6QQd7luFURmdZfDtNAAlEC2ylNqYynqoRM/mCes9R0KyMkx5A52f62r9U0fl26K9VJnwYd6d2lxI/Pc2YRhwhEKmK6+jkQ== 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=2x81XcX79x4a2Hn+MWwZJ/ftPFjjeLx5eIYSL/f/Dwg=; b=KzbcPWeqOQXKj7xri9WAphQXNPBNt1BPLnQDzDaA5rj3Rzijbl0UUiE0ranAV2JJp8UkhW5aln7raYn5rRozQzsEWq2PK1/H88fCwfxfLBFcpbTa2dH2NfOOunGHCUhE9e9BVjmiCXD3KEhOPfPOKQkLW5VEWlP63bWN5hCxVS2qL7pBK7/xvCa76nJPjhNkr9M43NPBojKXP0Dq+LHviBN4jeAY5WvYvizzfMJ/y/yUV0EIPaqV2i9mF59Me3iOvUvtuBXtZFjfbn3wMNRGRNT3v1De6RgRY9x7XbXUmNt3wOAQ3Oo8wMJ/6F9qdvj7txzvQU6+05u5eloGgYQR0w== 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=2x81XcX79x4a2Hn+MWwZJ/ftPFjjeLx5eIYSL/f/Dwg=; b=gSB7YasxfOQR8RYqRUs6izpTrdIEtUramUC0maLCiB94GGjpSNCH6sXVlQFnPpoUF43AML+hGrKhB8zbqZ49dIvJQA9MGx8AhdeW4p+9VMyG3MJaq/z+pNoLivJWQvBQtPb3IaHdM2g9pNM/ROElwtEisz8nWlknsXI93t1GrUg= 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 AS8PR04MB7525.eurprd04.prod.outlook.com (2603:10a6:20b:29b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Wed, 28 Feb 2024 05:34:56 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::1232:ed97:118f:72fd]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::1232:ed97:118f:72fd%4]) with mapi id 15.20.7316.034; Wed, 28 Feb 2024 05:34:56 +0000 From: "Peng Fan (OSS)" Date: Wed, 28 Feb 2024 13:43:05 +0800 Subject: [PATCH v2 1/2] dt-bindindgs: clock: support NXP i.MX95 BLK CTL module Message-Id: <20240228-imx95-blk-ctl-v2-1-ffb7eefb6dcd@nxp.com> References: <20240228-imx95-blk-ctl-v2-0-ffb7eefb6dcd@nxp.com> In-Reply-To: <20240228-imx95-blk-ctl-v2-0-ffb7eefb6dcd@nxp.com> To: Abel Vesa , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-clk@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1709098992; l=3472; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=lwTL7UDSac8mQFBZK5JoP0xi1Q5SdnWerxBEk85GvmI=; b=ma/8jMSztn6vUaLXt8ZG+eqOxkq12PI5guFPeTa2chsmGp5ywDV391JBJO5iSSzJnE54S5uDe ILeC4RhQ0GXCu5rLQ5R3khpzivx2Fq+nYZPm+eN3lQ40L9eR6wdaNCK X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0034.apcprd02.prod.outlook.com (2603:1096:4:1f6::10) 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_|AS8PR04MB7525:EE_ X-MS-Office365-Filtering-Correlation-Id: 12f62755-aa07-4fc1-b6c8-08dc381eff87 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: eR1WYjyFwNrr7JuSX4kSFXRBb/43DtLZc5jNJHtMix1SVZ3gUoIktjIBeD1tYXAR/3+CNE7c91cGGKbGtZAAWaLtyub4D+FHYxrBfqNV0tqPAKpc8L/eJdj2sZYbdyuFJmfmudRxmY81kykRz4KoZXEbZZb5qYQrV3gcEw/cJHunHc/GMlp4bvWwTN6TZxsDcTbij6K8nkJZtFmn28j9JZc+NQvrF9724lvkAbAJmPxE7TIdOba9ecZjIRkSOZXGdbaosA6UiEOFiGU+8Z9OJEtluRGmI8TmZL3DSmSqC7CPCb1J0FwG72MCZDtJacjOeUhimjm7Vbd3CGoHmuMccYYD4xXgVgDORIt+mVo/DgmN5AzrhctQwR/aoPVSnsAoRNwyMm4HsZHAAtxHrYZj0DcLOegRS5qfzOGqoYjwmXRdZlpfiyP+Xz+7ji804tFCpNxXxSeiKDZIcHuTiawFyw448ZEo6VMGxqvVIKEGT7QVqo3sdyAQCDVhUEfMOoLSi8DxoPitOdsYnvTay99EKmL3t2LYDrN3gDRO0rOX33EUpkAxVix7nmJJEPfVNGjJKL6Z7reqRsDoJQNABFkjlMhEO0c0C0lSzV8BIY6Urdh9qSpOzsw/rlAzjfVUUMSG2PbBW1xbIhvoYdGeTOynHu18Q1znut1Cp5Havr0Zu5KoGKlqSsbS/zcPvP7Kw4rKFNtDUl4hGOnNDuUHndd+nW7LvpdYnwaZPwm1hwhCNoY= 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)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?g/ro3in3UVZH23IuSHhVgonoXFBB?= =?utf-8?q?ujl5YGuULI7THMz0ZllgYAQxt5tJugHiaSyx5/zRgaRXA0L/ub0hQvakywd6UCS2z?= =?utf-8?q?LIlSXvHn662njexU74cadf6WS9sIH69L5HWpbpBoNXorhZKUpJRtXHHcr32Rnj/XS?= =?utf-8?q?pMGaXU8vmNz+6SH4bpA/x366oxmGIjHR2LwgoKvYa6jq8QXAFlZLI0by5NbmCZDiD?= =?utf-8?q?Fgw+XGlFTLoBbJBGddfAhvsCYAdCrQPQvcBZqdPYdN8c+nEgkfZW2Vpt2ex6XNpBn?= =?utf-8?q?NL8rrTjgVDqUdVFpH2qmw6gaKeNyizNzTYXXkYFB4dMm1QE8N/KsaLn20nLdgT3u1?= =?utf-8?q?N6LcUyUR5VsToNl5O0IgZGtEw+7fdxYT6Y2HWShs6P48/HIs7dllV3rWs/oC+1G8y?= =?utf-8?q?HXxDFQf2VXJAiXmgLTW4hP50WDdKVuk+LH8wjcp6BnqSSMw0v/ggvzc76nlU19YDW?= =?utf-8?q?/S2omACEOPTioDugBVr64dZzC2QLZNPQHodvsanrVNCdO7WdzGzQL6M98uX8k6Xmw?= =?utf-8?q?8VVNmjCVcTqkoBLow4tCih3rYTi9K4lPbLujOmesA7UDaZwVonMOz2Bh9YNbky347?= =?utf-8?q?rSX7k3MqoMfDEvs3L9m1IIEh/zh37hvzCL/5VtiV7xXCNCYu5OujyoCcsQ4kkmrmK?= =?utf-8?q?Ipmm+poZrhs5evFZDsZ4y2AFxuQoQi1qotK5oOwjxIZ11M8zBNwYuRrxkAIGgDBZH?= =?utf-8?q?Ba6h1lnbcfyJG5IRDEUHDxelFOLtoyJrb3v117cX5O3lBdoqM0bw72C9LGbxYXdTS?= =?utf-8?q?mSD6G3IIpptlwiG92qhIq2yVI2bQuLog1djN/XNVaINNdHccCG73+TISe1k1DZy9+?= =?utf-8?q?gTfGGcAV5znXUcjzPwwPo213livBNob5vu8iN+FqE37+jkSTiEgB5Nhuvf4IK0X79?= =?utf-8?q?3PCSDretBC4cIRkdoDh61EHOFke709co/SdF/9M72jp9xV5Q25feBHkh5nMUx6BkD?= =?utf-8?q?uts8IrIGOUntb5frtSqFC8oXjyrA8QpOCOEacsfJz/zagB/KihEzDKJdReQ9y7Vh1?= =?utf-8?q?smTVu+X44jvvLNP1iwwAgtxaeufOnTVjbFm3R8Iqw6mPMICengV85V2ap80sETdPK?= =?utf-8?q?IwB9tfuKkQWv1rdKdpb0xI0gyja6JKEMK5Fg+83v+oezUoJFGTR4av/SsMWtjvqOd?= =?utf-8?q?IAmSE7uR/XoKIEYcvbASa31YQoCv/tOdAsX8NymlrPeFlmIGfTNqUO271+TLfYHIA?= =?utf-8?q?pqx/XN5USYolHNAP7IqukRsY7MEMd/ymXYwaYWYHQfFFP1iuAEIUtODP9LgZJWC0B?= =?utf-8?q?MbVscy9/VdxsV82uoSIxEMstbpAT3Rt9kJeP8k1H2UIbKXMecE3wTBdfeyn/blsQ5?= =?utf-8?q?851w+FjCOHepQo/JgVjcasK5xo9btx1DJyviNo35sDWFmXLOxRM5yFOo0qZGpkuYF?= =?utf-8?q?wCfXHNGGzNfQWTpiGMo/N/stpzsdgGjlV7gKpzYrshE6o9rp/xCaoVmE1kGO3hP8J?= =?utf-8?q?NEXx6Dcsl98WQICo4X/LAb+1AbMncDRBPAnGmuQG/t5i/ixB7wxRVnxjnbdNlOKAm?= =?utf-8?q?SDT0V33wt+Ms?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12f62755-aa07-4fc1-b6c8-08dc381eff87 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 05:34:56.8025 (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: 6pl5vGkhPQMwD+3clI8e7CWUdncNzkqNMfIsCtKfVw8AH31VVOaGUyfXJLFmtdccqFybvYxhga01sz2YndruQg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7525 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_213505_117233_A9683FC7 X-CRM114-Status: GOOD ( 12.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan i.MX95 includes BLK CTL module in several MIXes, such as VPU_CSR in VPUMIX, BLK_CTRL_NETCMIX in NETCMIX, CAMERA_CSR in CAMERAMIX and etc. The BLK CTL module is used for various settings of a specific MIX, such as clock, QoS and etc. This patch is to add some BLK CTL modules that has clock features. Signed-off-by: Peng Fan --- .../devicetree/bindings/clock/imx95-blk-ctl.yaml | 61 ++++++++++++++++++++++ include/dt-bindings/clock/nxp,imx95-clock.h | 32 ++++++++++++ 2 files changed, 93 insertions(+) diff --git a/Documentation/devicetree/bindings/clock/imx95-blk-ctl.yaml b/Documentation/devicetree/bindings/clock/imx95-blk-ctl.yaml new file mode 100644 index 000000000000..6d33601034ae --- /dev/null +++ b/Documentation/devicetree/bindings/clock/imx95-blk-ctl.yaml @@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/imx95-blk-ctl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP i.MX95 Block Control + +maintainers: + - Peng Fan + +properties: + compatible: + items: + - enum: + - nxp,imx95-cameramix-csr + - nxp,imx95-display-master-csr + - nxp,imx95-dispmix-lvds-csr + - nxp,imx95-dispmix-csr + - nxp,imx95-netcmix-blk-ctrl + - nxp,imx95-vpumix-csr + - const: syscon + + reg: + maxItems: 1 + + power-domains: + maxItems: 1 + + clocks: + maxItems: 1 + + '#clock-cells': + const: 1 + description: + The clock consumer should specify the desired clock by having the clock + ID in its "clocks" phandle cell. See + include/dt-bindings/clock/nxp,imx95-clock.h + + mux-controller: + type: object + $ref: /schemas/mux/reg-mux.yaml + +required: + - compatible + - reg + - '#clock-cells' + +additionalProperties: false + +examples: + # Clock Control Module node: + - | + #include + + syscon@4c410000 { + compatible = "fsl,imx95-vpumix-csr", "syscon"; + reg = <0x4c410000 0x10000>; + #clock-cells = <1>; + }; +... diff --git a/include/dt-bindings/clock/nxp,imx95-clock.h b/include/dt-bindings/clock/nxp,imx95-clock.h new file mode 100644 index 000000000000..09120e098a97 --- /dev/null +++ b/include/dt-bindings/clock/nxp,imx95-clock.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* + * Copyright 2024 NXP + */ + +#ifndef __DT_BINDINGS_CLOCK_IMX95_H +#define __DT_BINDINGS_CLOCK_IMX95_H + +#define IMX95_CLK_DISPMIX_ENG0_SEL 0 +#define IMX95_CLK_DISPMIX_ENG1_SEL 1 +#define IMX95_CLK_DISPMIX_END 2 + +#define IMX95_CLK_DISPMIX_LVDS_PHY_DIV 0 +#define IMX95_CLK_DISPMIX_LVDS_CH0_GATE 1 +#define IMX95_CLK_DISPMIX_LVDS_CH1_GATE 2 +#define IMX95_CLK_DISPMIX_PIX_DI0_GATE 3 +#define IMX95_CLK_DISPMIX_PIX_DI1_GATE 4 +#define IMX95_CLK_DISPMIX_LVDS_CSR_END 5 + +#define IMX95_CLK_VPUBLK_WAVE 0 +#define IMX95_CLK_VPUBLK_JPEG_ENC 1 +#define IMX95_CLK_VPUBLK_JPEG_DEC 2 +#define IMX95_CLK_VPUBLK_END 3 + +#define IMX95_CLK_CAMBLK_CSI2_FOR0 0 +#define IMX95_CLK_CAMBLK_CSI2_FOR1 1 +#define IMX95_CLK_CAMBLK_ISP_AXI 2 +#define IMX95_CLK_CAMBLK_ISP_PIXEL 3 +#define IMX95_CLK_CAMBLK_ISP 4 +#define IMX95_CLK_CAMBLK_END 5 + +#endif /* __DT_BINDINGS_CLOCK_IMX95_H */ From patchwork Wed Feb 28 05:43:06 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: 13574900 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 9D66FC47DD9 for ; Wed, 28 Feb 2024 05:35:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rg3FZmH/y+w77TGh0CtYriswarALoAmSK/4bCsbM3A8=; b=LGjPcBozg2gTWs+EEfF/dj08nI Ne41Y/jkdhMNZGfS2JERcC6Jc3gh9d7HBP/Qb2Rre4P2VfnjN3TMNDDkrNezkIFC2U1s0ahaPyy30 dsV3rD7D30m9uyA9EpbokHAmfnYzW3P23HCPVzz4MgIPBCsvlthX7TRBjg7Uk6wokxTiPZCr7HY1J SIaltvfY46TbOfGVFyfzwvrr1Z7xiENigurEuSCFTR0H2J6+CJvDWkCzeYhaFkP5T4E9DJfJSb95K OWRzGM75iIpjDKTjOXZEoKfaAAYGlgoVdgQAqrPwxsm296OP6C1Xw+jZ/kbmKr5nZm7FkdG/aZt65 xP947YGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfCb9-0000000862P-2Ujc; Wed, 28 Feb 2024 05:35:19 +0000 Received: from mail-vi1eur04on20601.outbound.protection.outlook.com ([2a01:111:f403:2611::601] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfCax-000000085uw-0Fqk for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2024 05:35:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fvbB9EmQQK8U3LjafLfcTVsj/OeZ1pVT61LJiX4+v69cNbMUd/BLOzNICj9DOUeCwcwbFlCdlGdJMUZ6Uc6du25AKZ3fQdjtjd0+NQ4TpBMuS6lpWoHwe229RvGQ433Ja/Wpmtgn8Qi87SrStbmj1AMPh/qd8SSw9hDSy7uDE2zhJtxJK+MrS8DECVZowUOlNHSNRxKCy988HTmHgeuQSbs1kD396JOTIWiLWUjsUZJ2Gfot3EsQkM8evybuDO01gqQ2LhomHA5E4Fit4dr4lTLH4nwGjUEwYqe5tEOQ+nNKyiDEuzZD5mZ//BxXOQsKuK6GGhcvoxJiSOhfmFbI1Q== 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=VWFZDVTupKRHqGzPzOcozEj38Hip9TgR0m5LQhPIOCE=; b=boAo3WD2rBmAkH9l/4rkrbycJP0qHfeXW38Y6KiQDPDm5urYTdU0QeDqjJhTNwDfPKwwtyjk1mFmTTYVd19l7mxbhejpkeJIL/aDTWvvEhVAFytQSAYiCLqbfQru0RgkJ/UuvnHOhjrPRIwKvlkv39zyQtg07kFDdwbEztXOzHIGucXUoq6/NF8/xcp/mehXzky1hhxF+txGqmRBlKB07JlVAKSl9F8uyNSmWgnngbOFTmuleUX7WR9ArTvvqll40nAU+IGrO6ngxksmldRiUf0mFeHcIyeW1lok6czkuJKN9GyEaSYW8tsB+2njTTII/sGbDq/p7SiP7pkawK0ZvA== 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=VWFZDVTupKRHqGzPzOcozEj38Hip9TgR0m5LQhPIOCE=; b=YEKuBjinq5IfiKDTh7KwQ3Lqqb4XPegV6ubbGTbuIS82n6aEcQwuwdR74TrLihk16CkKSfd8sZ2m6z8O/Ts851OokLNlAI/5EbtZIs6Vp0m24qygmLQMGNrYr7IWyTfzU3pwGsmKd41UkmTD8vsKvv4MJPWIHy7o55xWXex03OA= 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 AS8PR04MB7525.eurprd04.prod.outlook.com (2603:10a6:20b:29b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.36; Wed, 28 Feb 2024 05:35:02 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::1232:ed97:118f:72fd]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::1232:ed97:118f:72fd%4]) with mapi id 15.20.7316.034; Wed, 28 Feb 2024 05:35:01 +0000 From: "Peng Fan (OSS)" Date: Wed, 28 Feb 2024 13:43:06 +0800 Subject: [PATCH v2 2/2] clk: imx: add i.MX95 BLK CTL clk driver Message-Id: <20240228-imx95-blk-ctl-v2-2-ffb7eefb6dcd@nxp.com> References: <20240228-imx95-blk-ctl-v2-0-ffb7eefb6dcd@nxp.com> In-Reply-To: <20240228-imx95-blk-ctl-v2-0-ffb7eefb6dcd@nxp.com> To: Abel Vesa , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-clk@vger.kernel.org, imx@lists.linux.dev, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1709098992; l=13492; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=xdgyrgvjxybTyzDq8X/GTHuUjGIxReFNUQBlt7Wg4qY=; b=f9YFYxZSOWqKPqciCGeucA2E7VHpuRFnz0L7kbuHPCzs5l45CeaGfETmDDMXMButZmoao1z/S eVWZIs2/uVbAcCRHdhqBbitj4q3zqrgja0wymAosk4YQMPY5XFBHj0a X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI1PR02CA0034.apcprd02.prod.outlook.com (2603:1096:4:1f6::10) 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_|AS8PR04MB7525:EE_ X-MS-Office365-Filtering-Correlation-Id: d67fad88-177a-4c9b-e49d-08dc381f0292 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: FVT1nnSrpMr+52UcuWgLCaBgrthTqCIoN+qJkcvTeNWB9FBub6aP5Hiv3AFEMMDLGRYbNCFI/hgu5LDOzgY5bGALPhW5JR5v1jntHpMBoIRdREv7fDllakJoeGf7zi96RjuBctrV7RfKjddoSA/VBFJRi+Vj9MBdUGO2DsuPwMbCnZz4cug/5AxgmyBFEP3ry2nLxlrwapT/6KofSrIMB019Klmdp7ADUkpaV/n7uuhJs6kMO1BA9QVT270noj3HEU0KyuXeAA4FuUHFLT4qE38xGs7idWlVFq7P6FNExfom6omyRFP0/IiNyQ+naxhf2Jc8IQTyT6Mkxcft4bAyMB5ZN/cF9Fy6UAjTrwmQ2GQyKOb+hXIlJWdZgsl1IrumQxkpjKD8Skq0JA+ZDoTgmH6KOdoVcTtSD8lUn/PCrv6msnj95L+sCGLZysR5CBOwlGLnohnWF5CSK4kQNTKVvjIfc5KqJerRWQOK8uTPkFrWCUQdvKeSgqFOQSwsDU/c7tZACNwwaN/geVoSmn7o1cKNPrIcz6sw3LFo9uGYp1U9IVFsaLT5+ez+vY0SqYbtiqvG9bsuCi/eSs+ycEYEgOp6L+JecbRakwe1nyWnT7BUxMngwglErb7TheCLzygjPbPQpekbu++Uv7cXvxq7Di2YcLv/GJob7WTSpCNlu2UmEFc50iORaJ3txUShLegTrvIrs9J1QIIcl4Oo1uQG16WC1REiuKqkiRsxFa5txRs= 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)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?n250vnGahK0jrnFExIyjr/KsNF2i?= =?utf-8?q?ENqESiTtp1rrVFBktC42IG4DGT85aTrOMA+dpMRaTxpdevYSdizfNyAoHi3a9EWm4?= =?utf-8?q?Gc844NVnBCS7hd0EkGyC/L7aJhx0Ju9/PwubCcZQ2upfXjOjAR07LM5KbQRZRY+be?= =?utf-8?q?KIEp4Cs0NGJsbpUcH+9iVeDCDC+QayYKD1+jerF0UDmH9Ykw1j1m676Z91cp7ei/C?= =?utf-8?q?b2dxFSXjIztYV7nkfkNR3csAafhdoeZbANrg8s3hnjciXjcJlbIULYCBOpAAJyz/F?= =?utf-8?q?ngNLQFsTvEETDZtv9d3V8GHg7OB3WFuHu+5DNtCa0aJ5oWRCkFMPu41NuMwZ1kUkB?= =?utf-8?q?icWhUXrUQn0U5mWfd6Ubhpc1ynoj5vaMoHjxYHcZh/TaSmkh560HKZ8iekOIjKnwA?= =?utf-8?q?D0D6hmk0ZAYriTtoa8t2trbYs0OaU05UHEWLTC/KBk8M+xK6/4v5Doo+CneCcJYwE?= =?utf-8?q?5P6nLWP1JqBTsO3i15pDq5X1WFH+bCt7NINccda0iaYh/CfshrTbW+i8wJgv+hn5i?= =?utf-8?q?NRjySkDBQHHThfaQo3m8SQZZpOg7Bj4ky58X55BrIUfrGOJbYOAM9nql5j9zpzrn5?= =?utf-8?q?TmtmZaSU7WorkemXnoYWxNo242D8Wdda2Yb/hBbSWeODZk+8MEaaD4LeG/laN7mqJ?= =?utf-8?q?Su/whKLq/8NdHl9JPEfbZO6aYReQYuSjbCCDIocdSz382HP/6+DRWAHl4Iq5nFlDZ?= =?utf-8?q?fj3uBKSPpt8aDkZSo4lGMxXjh6ol1tsCAciWMYaHkh+JRvkL/fVjI2r6B8KcSqhS/?= =?utf-8?q?iwrL0yNyO37mtIYx6e4cCgp5Aeml9qSuCueLoEor4V9yjuJwJhTNXQ8O9cOFZ1s4y?= =?utf-8?q?NTXlbNl3MIXAVZnosOjzDYOp1hpGonxJd3ZQqQfFgO7F0FCeeP3O2Sya8hQFaRPLj?= =?utf-8?q?zl6mh1vL+5jwPSvhIG7A91Od4WUxu0Y7/XyMXG+a4mLS7uvb33svtWStZKyMIe90l?= =?utf-8?q?34OvoRxrsAyi+vi7iAeeTVjG/K5mdXzun/84exdfX63AVqTo6s1+3XA27f17Uq6lN?= =?utf-8?q?fAOfUQIaHqQ2YcCfDdftaJoPIJS8fGLtnaOpUzM2/9qYXLZ4mKeFBZOLDemsKrbC9?= =?utf-8?q?5Et6etfibMxAui04DgsHu3fQU2lSl90+c/Oya7TrzHkgkwo/46xWq9qzWksRwrmxh?= =?utf-8?q?GTJ4/3if3nP1GiVEx9iZmCJ2HCF+roCMGIaSKAaTw1Cf28TKH98BtAp0/NIojbSWN?= =?utf-8?q?kf5Lctw3AkSTrCNX/NeINeOw0K1dcH9PCkXnakJcsAI37NsGX7uP4wBMMsrntfR3n?= =?utf-8?q?WftdqE7cGLveLEzRd/gT/VXNS2o29q5y4JBuBV4yKSemdVcvnSnxddcw2Dz6SjzL6?= =?utf-8?q?NlGGnLqWwzeIycjwxxb8STdWxmJX4I5aR7wTED6YHIRnvNqf8DXnvFTX4NqoEsP39?= =?utf-8?q?OBvsLIyqnkq68UnNSkS3U37U89rqJQPMgrFqP8XIxpo6vgthb6rHP98T7MYHa5Uaf?= =?utf-8?q?BKlJzP4MddxI4Mq8dL49K5ywe4WibOBoNXjlrMOn/QQOsjy0pSJpJ5+Pv830dyfRv?= =?utf-8?q?aQwGZ0QwP4wV?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d67fad88-177a-4c9b-e49d-08dc381f0292 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 05:35:01.8996 (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: lrlyRdJS0R5cU0NX/Hj6vzJCCSAe/vRKUyI8200sOEouirH5KV1bmRtx5Kl5uz5/RNviQMjEZs0hv8X9kbZvaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7525 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_213507_178187_F1DFAFFB X-CRM114-Status: GOOD ( 16.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan i.MX95 has BLK CTL modules in various MIXes, the BLK CTL modules support clock features such as mux/gate/div. This patch is to add the clock feature of BLK CTL modules Signed-off-by: Peng Fan --- drivers/clk/imx/Kconfig | 7 + drivers/clk/imx/Makefile | 1 + drivers/clk/imx/clk-imx95-blk-ctl.c | 438 ++++++++++++++++++++++++++++++++++++ 3 files changed, 446 insertions(+) diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig index db3bca5f4ec9..6da0fba68225 100644 --- a/drivers/clk/imx/Kconfig +++ b/drivers/clk/imx/Kconfig @@ -114,6 +114,13 @@ config CLK_IMX93 help Build the driver for i.MX93 CCM Clock Driver +config CLK_IMX95_BLK_CTL + tristate "IMX95 Clock Driver for BLK CTL" + depends on ARCH_MXC || COMPILE_TEST + select MXC_CLK + help + Build the clock driver for i.MX95 BLK CTL + config CLK_IMXRT1050 tristate "IMXRT1050 CCM Clock Driver" depends on SOC_IMXRT || COMPILE_TEST diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile index d4b8e10b1970..03f2b2a1ab63 100644 --- a/drivers/clk/imx/Makefile +++ b/drivers/clk/imx/Makefile @@ -31,6 +31,7 @@ obj-$(CONFIG_CLK_IMX8MP) += clk-imx8mp.o clk-imx8mp-audiomix.o obj-$(CONFIG_CLK_IMX8MQ) += clk-imx8mq.o obj-$(CONFIG_CLK_IMX93) += clk-imx93.o +obj-$(CONFIG_CLK_IMX95_BLK_CTL) += clk-imx95-blk-ctl.o obj-$(CONFIG_MXC_CLK_SCU) += clk-imx-scu.o clk-imx-lpcg-scu.o clk-imx-acm.o clk-imx-scu-$(CONFIG_CLK_IMX8QXP) += clk-scu.o clk-imx8qxp.o \ diff --git a/drivers/clk/imx/clk-imx95-blk-ctl.c b/drivers/clk/imx/clk-imx95-blk-ctl.c new file mode 100644 index 000000000000..4448b7a3a2a3 --- /dev/null +++ b/drivers/clk/imx/clk-imx95-blk-ctl.c @@ -0,0 +1,438 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2024 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + CLK_GATE, + CLK_DIVIDER, + CLK_MUX, +}; + +struct imx95_blk_ctl { + struct device *dev; + spinlock_t lock; + struct clk *clk_apb; + + void __iomem *base; + /* clock gate register */ + u32 clk_reg_restore; +}; + +struct imx95_blk_ctl_clk_dev_data { + const char *name; + const char * const *parent_names; + u32 num_parents; + u32 reg; + u32 bit_idx; + u32 bit_width; + u32 clk_type; + u32 flags; + u32 flags2; + u32 type; +}; + +struct imx95_blk_ctl_dev_data { + const struct imx95_blk_ctl_clk_dev_data *clk_dev_data; + u32 num_clks; + bool rpm_enabled; + u32 clk_reg_offset; +}; + +static const struct imx95_blk_ctl_clk_dev_data vpublk_clk_dev_data[] = { + [IMX95_CLK_VPUBLK_WAVE] = { + .name = "vpublk_wave_vpu", + .parent_names = (const char *[]){ "vpu", }, + .num_parents = 1, + .reg = 8, + .bit_idx = 0, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_VPUBLK_JPEG_ENC] = { + .name = "vpublk_jpeg_enc", + .parent_names = (const char *[]){ "vpujpeg", }, + .num_parents = 1, + .reg = 8, + .bit_idx = 1, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_VPUBLK_JPEG_DEC] = { + .name = "vpublk_jpeg_dec", + .parent_names = (const char *[]){ "vpujpeg", }, + .num_parents = 1, + .reg = 8, + .bit_idx = 2, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + } +}; + +static const struct imx95_blk_ctl_dev_data vpublk_dev_data = { + .num_clks = IMX95_CLK_VPUBLK_END, + .clk_dev_data = vpublk_clk_dev_data, + .rpm_enabled = true, + .clk_reg_offset = 8, +}; + +static const struct imx95_blk_ctl_clk_dev_data camblk_clk_dev_data[] = { + [IMX95_CLK_CAMBLK_CSI2_FOR0] = { + .name = "camblk_csi2_for0", + .parent_names = (const char *[]){ "camisi", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 0, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_CAMBLK_CSI2_FOR1] = { + .name = "camblk_csi2_for1", + .parent_names = (const char *[]){ "camisi", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 1, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_CAMBLK_ISP_AXI] = { + .name = "camblk_isp_axi", + .parent_names = (const char *[]){ "camaxi", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 4, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_CAMBLK_ISP_PIXEL] = { + .name = "camblk_isp_pixel", + .parent_names = (const char *[]){ "camisi", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 5, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_CAMBLK_ISP] = { + .name = "camblk_isp", + .parent_names = (const char *[]){ "camisi", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 6, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + } +}; + +static const struct imx95_blk_ctl_dev_data camblk_dev_data = { + .num_clks = IMX95_CLK_CAMBLK_END, + .clk_dev_data = camblk_clk_dev_data, + .clk_reg_offset = 0, +}; + +static const struct imx95_blk_ctl_clk_dev_data lvds_clk_dev_data[] = { + [IMX95_CLK_DISPMIX_LVDS_PHY_DIV] = { + .name = "ldb_phy_div", + .parent_names = (const char *[]){ "ldbpll", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 0, + .bit_width = 1, + .type = CLK_DIVIDER, + .flags2 = CLK_DIVIDER_POWER_OF_TWO, + }, + [IMX95_CLK_DISPMIX_LVDS_CH0_GATE] = { + .name = "lvds_ch0_gate", + .parent_names = (const char *[]){ "ldb_phy_div", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 1, + .bit_width = 1, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_DISPMIX_LVDS_CH1_GATE] = { + .name = "lvds_ch1_gate", + .parent_names = (const char *[]){ "ldb_phy_div", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 2, + .bit_width = 1, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_DISPMIX_PIX_DI0_GATE] = { + .name = "lvds_di0_gate", + .parent_names = (const char *[]){ "ldb_pll_div7", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 3, + .bit_width = 1, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, + [IMX95_CLK_DISPMIX_PIX_DI1_GATE] = { + .name = "lvds_di1_gate", + .parent_names = (const char *[]){ "ldb_pll_div7", }, + .num_parents = 1, + .reg = 0, + .bit_idx = 4, + .bit_width = 1, + .type = CLK_GATE, + .flags = CLK_SET_RATE_PARENT, + .flags2 = CLK_GATE_SET_TO_DISABLE, + }, +}; + +static const struct imx95_blk_ctl_dev_data lvds_csr_dev_data = { + .num_clks = IMX95_CLK_DISPMIX_LVDS_CSR_END, + .clk_dev_data = lvds_clk_dev_data, + .clk_reg_offset = 0, +}; + +static const struct imx95_blk_ctl_clk_dev_data dispmix_csr_clk_dev_data[] = { + [IMX95_CLK_DISPMIX_ENG0_SEL] = { + .name = "disp_engine0_sel", + .parent_names = (const char *[]){"videopll1", "dsi_pll", "ldb_pll_div7", }, + .num_parents = 4, + .reg = 0, + .bit_idx = 0, + .bit_width = 2, + .type = CLK_MUX, + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, + }, + [IMX95_CLK_DISPMIX_ENG1_SEL] = { + .name = "disp_engine1_sel", + .parent_names = (const char *[]){"videopll1", "dsi_pll", "ldb_pll_div7", }, + .num_parents = 4, + .reg = 0, + .bit_idx = 2, + .bit_width = 2, + .type = CLK_MUX, + .flags = CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, + } +}; + +static const struct imx95_blk_ctl_dev_data dispmix_csr_dev_data = { + .num_clks = IMX95_CLK_DISPMIX_END, + .clk_dev_data = dispmix_csr_clk_dev_data, + .clk_reg_offset = 0, +}; + +static int imx95_bc_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + const struct imx95_blk_ctl_dev_data *bc_data; + struct imx95_blk_ctl *bc; + struct clk_hw_onecell_data *clk_hw_data; + struct clk_hw **hws; + void __iomem *base; + int i, ret; + + bc = devm_kzalloc(dev, sizeof(*bc), GFP_KERNEL); + if (!bc) + return -ENOMEM; + bc->dev = dev; + dev_set_drvdata(&pdev->dev, bc); + + spin_lock_init(&bc->lock); + + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + bc->base = base; + bc->clk_apb = devm_clk_get(dev, NULL); + if (IS_ERR(bc->clk_apb)) + return dev_err_probe(dev, PTR_ERR(bc->clk_apb), "failed to get APB clock\n"); + + ret = clk_prepare_enable(bc->clk_apb); + if (ret) { + dev_err(dev, "failed to enable apb clock: %d\n", ret); + return ret; + } + + bc_data = of_device_get_match_data(dev); + if (!bc_data) + return devm_of_platform_populate(dev); + + clk_hw_data = devm_kzalloc(dev, struct_size(clk_hw_data, hws, bc_data->num_clks), + GFP_KERNEL); + if (!clk_hw_data) + return -ENOMEM; + + if (bc_data->rpm_enabled) + pm_runtime_enable(&pdev->dev); + + clk_hw_data->num = bc_data->num_clks; + hws = clk_hw_data->hws; + + for (i = 0; i < bc_data->num_clks; i++) { + const struct imx95_blk_ctl_clk_dev_data *data = &bc_data->clk_dev_data[i]; + void __iomem *reg = base + data->reg; + + if (data->type == CLK_MUX) { + hws[i] = clk_hw_register_mux(dev, data->name, data->parent_names, + data->num_parents, data->flags, reg, + data->bit_idx, data->bit_width, + data->flags2, &bc->lock); + } else if (data->type == CLK_DIVIDER) { + hws[i] = clk_hw_register_divider(dev, data->name, data->parent_names[0], + data->flags, reg, data->bit_idx, + data->bit_width, data->flags2, &bc->lock); + } else { + hws[i] = clk_hw_register_gate(dev, data->name, data->parent_names[0], + data->flags, reg, data->bit_idx, + data->flags2, &bc->lock); + } + if (IS_ERR(hws[i])) { + ret = PTR_ERR(hws[i]); + dev_err(dev, "failed to register: %s:%d\n", data->name, ret); + goto cleanup; + } + } + + ret = of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, clk_hw_data); + if (ret) + goto cleanup; + + ret = devm_of_platform_populate(dev); + if (ret) { + of_clk_del_provider(dev->of_node); + goto cleanup; + } + + if (pm_runtime_enabled(bc->dev)) + clk_disable_unprepare(bc->clk_apb); + + return 0; + +cleanup: + for (i = 0; i < bc_data->num_clks; i++) { + if (IS_ERR_OR_NULL(hws[i])) + continue; + clk_hw_unregister(hws[i]); + } + + if (bc_data->rpm_enabled) + pm_runtime_disable(&pdev->dev); + + return ret; +} + +#ifdef CONFIG_PM +static int imx95_bc_runtime_suspend(struct device *dev) +{ + struct imx95_blk_ctl *bc = dev_get_drvdata(dev); + + clk_disable_unprepare(bc->clk_apb); + return 0; +} + +static int imx95_bc_runtime_resume(struct device *dev) +{ + struct imx95_blk_ctl *bc = dev_get_drvdata(dev); + + return clk_prepare_enable(bc->clk_apb); +} +#endif + +#ifdef CONFIG_PM_SLEEP +static int imx95_bc_suspend(struct device *dev) +{ + struct imx95_blk_ctl *bc = dev_get_drvdata(dev); + const struct imx95_blk_ctl_dev_data *bc_data; + int ret; + + bc_data = of_device_get_match_data(dev); + if (!bc_data) + return 0; + + if (bc_data->rpm_enabled) { + ret = pm_runtime_get_sync(bc->dev); + if (ret < 0) { + pm_runtime_put_noidle(bc->dev); + return ret; + } + } + + bc->clk_reg_restore = readl(bc->base + bc_data->clk_reg_offset); + + return 0; +} + +static int imx95_bc_resume(struct device *dev) +{ + struct imx95_blk_ctl *bc = dev_get_drvdata(dev); + const struct imx95_blk_ctl_dev_data *bc_data; + + bc_data = of_device_get_match_data(dev); + if (!bc_data) + return 0; + + writel(bc->clk_reg_restore, bc->base + bc_data->clk_reg_offset); + + if (bc_data->rpm_enabled) + pm_runtime_put(bc->dev); + + return 0; +} +#endif + +static const struct dev_pm_ops imx95_bc_pm_ops = { + SET_RUNTIME_PM_OPS(imx95_bc_runtime_suspend, imx95_bc_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(imx95_bc_suspend, imx95_bc_resume) +}; + +static const struct of_device_id imx95_bc_of_match[] = { + { .compatible = "nxp,imx95-cameramix-csr", .data = &camblk_dev_data }, + { .compatible = "nxp,imx95-display-master-csr", }, + { .compatible = "nxp,imx95-dispmix-lvds-csr", .data = &lvds_csr_dev_data }, + { .compatible = "nxp,imx95-dispmix-csr", .data = &dispmix_csr_dev_data }, + { .compatible = "nxp,imx95-netcmix-blk-ctrl", }, + { .compatible = "nxp,imx95-vpumix-csr", .data = &vpublk_dev_data }, + { /* Sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, imx95_blk_ctl_match); + +static struct platform_driver imx95_bc_driver = { + .probe = imx95_bc_probe, + .driver = { + .name = "imx95-blk-ctl", + .of_match_table = of_match_ptr(imx95_bc_of_match), + .pm = &imx95_bc_pm_ops, + }, +}; +module_platform_driver(imx95_bc_driver); + +MODULE_DESCRIPTION("NXP i.MX95 blk ctl driver"); +MODULE_LICENSE("GPL");