From patchwork Wed Feb 28 04:31:04 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: 13574858 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 9C74DC5478C for ; Wed, 28 Feb 2024 04:23:34 +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=Slry9q1B1+rBznMwVNvJWOzEvSqQl3ePEzcl4Ae4lSE=; b=XwJjm0zuHQdMlih7Yw+6pDQlqP OnX3XUzoCXoryg0ctEVDYrnzvueJHa/7js5+PCnsvxrA7BfxLOp9TzAtNRuv8/GvYtmO4+1hiqZ99 ZpwouPot3/symZEWd2x3KuxFTVkBf+yUhEi2aQXdPq9bvQX4DgF5fK46NvNeeo2WfxV6n+sH6Px3V rd1mNUIb7gPtvCWHzrxLcBW1YR/uyy0RuGPfWabua7rad+m+WfaFZt0r7MSaKFicmyUqsl7oHeAPi VsIvJJoJrggMmIqVt4+ZkednC5hALWxuXjELi4ssVdaA9EXPtoEmo3C5F3G9IkvyZG6BzV5SsIN/p qK0nVSyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfBTW-00000007xNn-16fS; Wed, 28 Feb 2024 04:23:22 +0000 Received: from mail-vi1eur05on20600.outbound.protection.outlook.com ([2a01:111:f403:2613::600] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfBTG-00000007xCS-1hPD for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2024 04:23:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bo52VduNkhNYc2kJ/qdKgeb4lgnMb7qm/B3bNMy3cI9xRdgWZJz4ngSz8aPJMBrGxuijs0+gicdg7lW7YcymBzvJsxrQ9yqfguEs6xwClOLF4iP3dYPL9an+tlSC6fcMUVbTNkanC2+Mcux1ac/4rHR4sosbG+VXHOibNf10TCg1eaAW0R1ax2F4us0ezZYha9cccFsKnnva79qlUT2mtZVKK3azxu2vF9PzyPrVzxrmssvW44Abeuj4x51mcOatWT4R1Vius216VLIts8Vd+0ayrBRXyd9r5TQvskGQadEkFEgrUBVLxuIvug84shVhUZhsefVZtXOiFqFfXStViA== 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=ORNNA6N6AjT7SXeItuRt8JCWRVDMfFhRORx5WAf2YcU=; b=QALe3Oe/Rvr9l4fOeDxIlIj/DCmTEfKuIRd/kFKE5iZqWpD3TiojbGaRdBa3ZPvwvkR/bbu9P6MvaZlqYo6kq8yIuB6/EDVfVY5HxQNssq20A+Tm4idueJp8I+aup4KMX8LsLuNdx9pngz7xLsI2/LMVK6KXBI89uMI5Tol/CfxsuSZSB6QyTpH5Etto8SVdPyXGrnVEmy67AsBnuOxrvTO8cFQibTjx3RVtRyCFrMrgAJgsBIDYMfOXwR61eh1Hndn7F+KdJW4m1RSbXpSMShufx0XMnQCQI7rsBDUX31z2RkwjBrgOgpgUsRDTfHF/u3FyVb6uSuB+kql1akLZ1Q== 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=ORNNA6N6AjT7SXeItuRt8JCWRVDMfFhRORx5WAf2YcU=; b=X1jP2W1SrQxSZwpG/VDj6UUyQOxeIhSL7ETRVaD+jiTg2QoXiBiY6ksUgg8QyyK/sHizaZAC8E+QPrJqpfATdKHrUUyUyf7esgq99jLB1oCK06u3Hga9AzScHBYliSQ8Q9xSKW+xbIJ+Gg26MZLQ0hvBN/mnxN82wQSXg7fDC3Q= 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 GVXPR04MB10071.eurprd04.prod.outlook.com (2603:10a6:150:11a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.34; Wed, 28 Feb 2024 04:22:58 +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 04:22:57 +0000 From: "Peng Fan (OSS)" Date: Wed, 28 Feb 2024 12:31:04 +0800 Subject: [PATCH 1/2] dt-bindindgs: clock: support NXP i.MX95 BLK CTL module Message-Id: <20240228-imx95-blk-ctl-v1-1-9b5ae3c14d83@nxp.com> References: <20240228-imx95-blk-ctl-v1-0-9b5ae3c14d83@nxp.com> In-Reply-To: <20240228-imx95-blk-ctl-v1-0-9b5ae3c14d83@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=1709094675; l=3477; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=l8DKBMnJPihRSjEjA5EKu1UUtQxQgZicRf3XlO1U4jk=; b=yCS7aqsZGnh5va/ERTHo/c5phirQISOxMD56HWimAO+PmHc0i1tlmPQtTm9ARPL7nqzlEAcsM OJB7eaUJBl9Bh2+3rc1ZXoPNeohadKPs8UBXmM00f1pdI2fyF4t0Bl/ X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:4:191::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|GVXPR04MB10071:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d535e3d-5e1e-43b0-4616-08dc3814f143 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: UcGyvfH+3Or3SEiMz1eii844I/QfxPKZIrVFL8E78Yf4toj8m8GCSExkIh4ucLQmXUmwgGCPUE3wcGKdmJStCDzJl9PoWGS7DBEeeI8mZsDYv+WjalmfrQmuLuAdQIWu3D96zQIUc+/SEFGstagiL+9Q/x0BEZatzwhOkUjGQLorjKkl6uO7hmtUSMMFbrmhISZvBpUiYE6TnipMNvk2eVXkvCLpZqzjZ7mxsFHuxSvG6RMRYw/PzqVfT4SyRUKi8J5iUh8AA5pbgXg6ze4NFCKRFyBcTHduzsXEuGHXfdjku8nH+9Kgf/fDLfdF1hln4RpubSAlFRmV7Vkyk4a5Hh5IIbIqon2oJjZjbrNLUzwKMlKgrP60D9jgnKcN9GxtEz1xG6pIkKDdRcme3Bx/PPrYG0o8jy4y6kp/Z0qIVQntMnLGxYhfiMYzDnzI7vab9nvDdcnvd2tc8TtfMHn9SHtHNbct+XTS79gdB9ylN3Z7pMI+eYEass4ZuVUkqcqxy+jT4fXGRaIUMVSjTuPNlgbPV6hcpz4Vpgmdka/6wN8VTMY8idpQrdfiXG8huiOGp3Qgz9wpL1rOvWyQan9zzEgfHI9r1+TfJfbnrGivqszhY9TIHuqqijuZ5BkQZOk3pAsQj+PX4OyzVDbzH2gJIwk/cRhdYVxgHnpCbJLQfEvwZ/IWqog1YkQl0bg9WX07aOJrfV5IyJ+3IzChzhBTCbj79JXcXwjSDkSCC5DCx7M= 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?v6XnVzkvoQdoUZ9sTLanUGUrByR7?= =?utf-8?q?DwWyhnEWnkFEaBzC91yZf6OJcZ0XMsO7Iw66YrlHkheF8L1iL57UY2RMFWesLuyVO?= =?utf-8?q?XORw0mMluoL+pTAFwtiMFQUtaCYV1AYTfwakVP8F+BWxCO7+56zukSVfbMCFkJGux?= =?utf-8?q?6zGxeQR+n0WCAEcEIVXVn4vh1prATenIafBmiCTkUpQ6gzEpJt8RXloQIOqAClsb4?= =?utf-8?q?wePKZJkJbOVhbDv6E25hzz1hB3CdCg+qAxxHQHvAsEmT8EKueMiyIVnDoPEhkeVmR?= =?utf-8?q?MTgNUpwq0p/gawflL4P8jxzEfMJNL2U1wEuWVKAgEfku6H99wd64J45AwlCrqAaBg?= =?utf-8?q?kYLygzZj8Frw7H66jk9MVSjuDj7M0EkPVPZ49Es5STwEZCZIX5/tRSNiTMroLDh5y?= =?utf-8?q?0fK3Xkax8jlGXQmZXhhT0Ezto3t8WjqszHyu/0kdu4MwBeWfSdcVY6foiUPgzFSoC?= =?utf-8?q?fV8K/VtmIXbugmhdTh1jOIIXpeJucA7Yx+XqofKKF4lGWOI0vbDRf7yrW8/iuDGkS?= =?utf-8?q?F69zMBjz4E/EUAtM7uMORFmc+kCgJx07ZC6fek6jsEuJKOIiBnuMjz8MuU4LGo1+N?= =?utf-8?q?OK/Q/Lq6m9CuNbIIyXMvVa4YFEHRg78sMFc8x0fTL+PwYpi7UApDym3p5iRQJ71Gf?= =?utf-8?q?MKM/ZF8vBTwTvtxAtSZU07NoXFu1nH4vTopZuoayqs8BjRFsFYc6bKb+Bvjewl9OL?= =?utf-8?q?RQu4Qx3isyzFEle6k51CfpdDB29yuIxlrNjOqFpUUxQyscJjkYA1MZd/byij5a+Ez?= =?utf-8?q?eZlunTai4ihu1NkZamBdBKpqVDp2a6w0WgXFvIjjDxKpNaDs4hzi50VU4q/JDR/+x?= =?utf-8?q?DwPfZevsVU1THghUj+HllSDxE7lVrlSWrzcox9Okf2QAJ8xaDFyGv30pnk1peXqyJ?= =?utf-8?q?feAiqrobW0xc2dDTZ2cMZwXXMCWmjID1/fVhXj08r5/1G+QJos8FFv52ZOY1gwoNd?= =?utf-8?q?5y6/DHqxNuJZyCkoULKqIJM4vku8Y6S6w7n3wqEllkPQvXC6kl9ZcqF7UtBAjjR6f?= =?utf-8?q?aZFfmqCoT2A7Fv6z0hjkYjNcVMx4ykz1lchGs3MXzqe4U1ujVW6afoZC/03Oh+z1G?= =?utf-8?q?Vg7AScrJVtgBN38kHDDO3PWgD4ijva5ooaHqKwp/OHCMWTBAYs7qUCRf7Dpl5IlQ7?= =?utf-8?q?RfoTnjTCZ3FSuyqnXC3vrd/jRkUf1tdWEuNrfg4dLKSPSMsrG0WxI3Kr/RHfXaIvH?= =?utf-8?q?kf+WPT2OczXj9SycNCR54+75fVV0VkCK/jVztGv/uMN3lNnUaWehpwJk+QAHGm3Xf?= =?utf-8?q?oESj3n/LCMr/hT3FF/rGIbmcjOgs3AzI9FQaIoiAUo6MIuOficxUDsrz88sEKx1T8?= =?utf-8?q?heGOnRSnepaJmsui18BzH2EZOTdikbZPZT72FrEzB7WJUUtnmLFVqSAgAHvrzIOW9?= =?utf-8?q?KPcZn57IuEYUhSieluiBzBwEID0Q4pPkyxTAfw3W008EXzCsj1N0Nhwn607pdGmhw?= =?utf-8?q?8Of/sqxDLRUSUaPffPrlN+gs0OVTPuFNwMtPwitY266Uef8V6cxvWk9Uk5Vh/oJKM?= =?utf-8?q?f6o13s5dl9o5?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d535e3d-5e1e-43b0-4616-08dc3814f143 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 04:22:57.9095 (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: uH2zt473zSNNeQ8HBKL4TfUAr3UBB09fLbSKXpW7fDSzim/llGYmH7+meVRg2ZyQ47YLkDXmuSUaIBfRl36D0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10071 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_202306_651126_E38B5A61 X-CRM114-Status: GOOD ( 12.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 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..179bdd33504c --- /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-blk-ctrl", "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 04:31: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: 13574857 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 45D37C47DD9 for ; Wed, 28 Feb 2024 04:23:33 +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=BYcfFNKA4N7soDdEMlTZSiugEl J15K2cqPkWtoAko5kxY6peSJFGYYnLX+IgdeKc2+E73sQUzgSDAACjaMXQWmwGsfyoqk87JcSwDjo q0A1W0WbpJ+XmeSX7rooicakrXKpPqgFCmQ/1oSQF+2mfFnhvxLvQsYbWNI9svQCFPGo7k+jQwU3w N8NckuIhqRpnTxrfESKBdFAXlMIuoMW87R648Q8tyGp0Tjhr6d2xVnDTYlpwu1TOZ3BeCyWRvobjm c2iBSMiEa/fLdPSZi8mcvhitpDVX08+hJQKeofkdLJVEkwTJMUrtbkBaSg58qbOKmEJU8D/NEA7/i ZjzV01+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfBTX-00000007xOI-0D8q; Wed, 28 Feb 2024 04:23:23 +0000 Received: from mail-vi1eur05on20600.outbound.protection.outlook.com ([2a01:111:f403:2613::600] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfBTI-00000007xCS-2LJJ for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2024 04:23:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PSaLLXLfuCx+wZJY8YfbgKYf48+3wBwYFfiz5ddya1+cwUQLUZIhYssVQo75zH9fR96I4gizJ5Y5GJSw3KS5Q4DnC6yD9bwL88Qdzu5baF+quHHLNRGIylaPHzxjODL8oj875rrTk9DZ0UAh27k4uB4K9PSZLckjfi6XnnjHWmaUbMHVW0FENDA4E6U+KlkcU+KXn+O7VkJ4dxldEftu7DrRCpU5ZR5H5w5Y+ZNOOl0BTMe08+iCSPuhxYoxoWsI3hlZDwtoFzBeWt6VjiEb1psPLNsJcPEmJwXGuajw3cRj3BeVkxE3PLtKfilxatpRDN+s7xXehgAcSmjLul5+Kg== 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=iJtsVrsu/RRLv3A7uvo/vMnOxW+tKnO1OO4tL6uhXVvClNes1UMJ4ZyBaR2kbEyt0Bh1af56fAo8kTGwef9Y+Oz6HoXTV/7ljVs/GrNppenL3wuGWS2j9nscCLCXRHDGOPd8I6DK6inBT2n/ADhnNdqzZ7wITj/xVOVsY2+xW3qqGUc6t1ItrI6ZObo2x8NWFjClQpjT1F0feFWG7e7AUweBlPLW6s/2BfvHyhT4uyC8CNDqrYonis9wf4XNrl+xOqOJdWHrkoyQA9xtB9rNfMzVOB7bf5b/Y+c7P7UfpWLzscE9aD0OLj2F+uonz44HnGhzU0G9kTWfCYPX177d8g== 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=Vab4CauhqeS5Xc6DwHmhy3aq8IgllZfXpNI9OAm/qj+Fop6ock/N0yZSOoWJumnNF05dDQqfgZRfmXpl2Oe7UhPYWkU6LLvff8TPIGfkqklvOlSdkJYQPwolEL6gkn27umnp6Z6OEUlr+50gV4xDl0xbk2I5nKcLkKhgmpXOcoQ= 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 GVXPR04MB10071.eurprd04.prod.outlook.com (2603:10a6:150:11a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.34; Wed, 28 Feb 2024 04:23: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 04:23:02 +0000 From: "Peng Fan (OSS)" Date: Wed, 28 Feb 2024 12:31:05 +0800 Subject: [PATCH 2/2] clk: imx: add i.MX95 BLK CTL clk driver Message-Id: <20240228-imx95-blk-ctl-v1-2-9b5ae3c14d83@nxp.com> References: <20240228-imx95-blk-ctl-v1-0-9b5ae3c14d83@nxp.com> In-Reply-To: <20240228-imx95-blk-ctl-v1-0-9b5ae3c14d83@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=1709094675; l=13492; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=xdgyrgvjxybTyzDq8X/GTHuUjGIxReFNUQBlt7Wg4qY=; b=WgblZVVeGQHSl14sz7C0ASKpaE7ZPRrECKgAvYIQimT5VlcHq4Nuwx4THNPsng0PajrtKRokz MEwzK7rH9xwC8Mvr23++B5Mq0kOfKDBb1nbLb/lacEWgVpKBj+u4Wug X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR01CA0017.apcprd01.prod.exchangelabs.com (2603:1096:4:191::19) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|GVXPR04MB10071:EE_ X-MS-Office365-Filtering-Correlation-Id: 30a2b881-aa73-4a34-4a3d-08dc3814f416 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: FJaONLvQUzkUBX2Uwvw1CZT0cDZJ7wNCMKFxT5qrEHlUPYkAUVnljcsyMyFOawc+/zYSNW0LLqa/m6iGpBEueyl6SR0Vw2japjbSOzZdmHkAZbbk6wj5dbMmho/Iq889b9tUh1HhDf7Ps/OpNDQKUtH6L0PBIeaNC3CBAzH1qV/R7eG2QrXsntnNfanpwrUsiufmN+HPpl4XrZ54tb/Jep3ZgKktnhx7nW3uNPuHgsxIoaplKVo3Lye68xCWcVPhyJHiB9lDjgapujeWi/6cKvoqzxgfsaGjuhejQojpkZ5vruCcarQ7ZXQ3Sjl7l5pASwPfbUwm8x4Z+F0nnJ/1SNVSjkJWhNI9foAXDcFdjW2fnvOyhjKPfmnBers4BZYQn94r+XT7coVYQLLM73KOF3fovcEydPlXJl4ensWWxG9BrpShBzHQU8r4PMaeI6VX7OgK2AiqGvU8McQC1WgZhmt75nkWTkIlhUObgJ6McdvpYtGb0i5W14cHZo/pyUwRY83+I6QcrUlw0Z3usuO1EONg8t5+CzpUV4DrqTh4tdbw5aiK8agBzuBsHlFi6wTtYjgRIGnQm43zepH1uX8Ha4k61BC6EK+DkUX/HwmiAnMzA53TjKDWcdLW3v4dAQNlQZJDJ0UNLzr2dvlYwH4DABE1LbTPLwTE1teHv7gSdgirvyRlQFb+YD3BEf2flHTM+TT5R+X1XuqWiTJIFaRIa8lHC49LA55WqEn1b/uoYPU= 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?6RJbsOSpc7tUnlBCmBmEybnXVSRz?= =?utf-8?q?lxClA+wwM8fdRM+f5h7q8ohZuTix4377B61gbZrrciUefJBShL9qiEsjk+onqKX34?= =?utf-8?q?Jc7S2Tjet52IVWS++HLMKuzPxV3YuT76KDrZ9WmLiVZjS5xx07tRrsDfRh6OF/Jnf?= =?utf-8?q?9Uw4SYvjPCx+5Dr/xeXKq2MWYHZ4rV4bcO1ZvxzanWd2rEtlTJhx58RyrhDdDyozh?= =?utf-8?q?0cvNqJefAhcP5OZe2U18qoXYkrFnmKBFtT7CFtpFJmNz+zL6iruKUbi89S67xrdDb?= =?utf-8?q?qnK8fYTsFBPZlzQe7T3/2dwf5C1bMGjmcc8aR/Oq2Gjv5T3cF9z/qllDUONIj0Q3t?= =?utf-8?q?UQ09oOWJ+kH/T6EvFL96fYmH/DDLIZdJVleTPYKFSqpuzo2Pzm+1YeS2Ml3lFwdTI?= =?utf-8?q?yLk6QkcbGjH4aBGdQT5DbSyCOdMNWbFkOXOikVez/U5UfsesaasiP+umr0LkbIcPZ?= =?utf-8?q?oXgx2LPo1BMVMW24HGZ079TS9ky9P6tlIqf8XTxafwVimP9AFhv3nlAT08N9q5Ahb?= =?utf-8?q?hF29ncVjET9fws9YvwIM79ZpUKsS0IT/mTzaYx0E/vYbAcVmt4UnVMv1YKMgGSbh+?= =?utf-8?q?/TTskh2ZHqsqVkPdV4AI0ByFL0s4hUbzNd1mVPJlrKFqULlxFs9lNd0GtecjkJO48?= =?utf-8?q?FfLMFEwz6S3kWJ/ukEI8bu/4UP2xnTPgugTzAOdFotQFbDrfLTuH9sQYZv3WLP0NE?= =?utf-8?q?zynG/cfPhvuFE2UW5s/uxA9uP7dnCHfQ15zzdM/4E/TXM8v5Dnyf9I9CGAYNwVnCr?= =?utf-8?q?FEKjfQvOMJXjnfcF9fY4qYyKMLa0luCQv8QOYOKG+V+Rq0Ic2xFHzDSgzUujwXX7c?= =?utf-8?q?UPo0c9J3+zO1qcKY5iCmRpKVzLacCP+64sHRwF1U29v13iSe4YzrwDAQ8jDI3LVgi?= =?utf-8?q?iYKbzdBYrSId9kO349USCXRTr8bdh8OtIXjMQKpvdoF3r8GCZanlL0VhgDLaC3UP4?= =?utf-8?q?6bn08mU+kTWdsXV/Hyef6JCxFSn2DauaBxM6RJQV1YnWt4S+10V68dsfFGY57JPVz?= =?utf-8?q?VbflazXhlQhXrpbdNI1JDxxg3yDdokt3N4UfNtzmeYFwbsm/jbd1hKnmB9vHJN1Kn?= =?utf-8?q?zIWIvYkgui9sC4n3rMnako2bjf43LnpghZ11vnFNOkFZKlo6xxOqsTmFivu/TO0ek?= =?utf-8?q?2KM4GgYN9IPtHGCU/gkMrLDxxigdnb0RbXBPeccscAgFfdaWZL+F+bLrlAAFO/lXh?= =?utf-8?q?3XQgimj83Ny0y7qWbn8Fy3NcHLqkGoiHOsSyiReFXhXsVMdE/8E/jHDkN02zheyaT?= =?utf-8?q?9U0wfyCsq9QCnvMOY6UJUKp8AbXUaLxKs67TmOpPN9xrLqwty9B1zattzh7wInAu1?= =?utf-8?q?6bkKoqCyTjrcsoy9Fzi9h8S8Lh8e9X4FmgUffPVP3YkiWkKQYwxX+i6xmIyt3qnxj?= =?utf-8?q?mWGr5Sqfe7OIBHKRBWobN+jU7nY+AlyjZg17XP/FACR27hUNTXZx+JgXK0lZpdPlz?= =?utf-8?q?SkDbzaBbveY+JkeSOWQZ9a25mc6IoC8kWsuuv20MDy/gcROma3xmM4XYIqt3rUvbI?= =?utf-8?q?yhZHac0zoal2?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30a2b881-aa73-4a34-4a3d-08dc3814f416 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 04:23:02.6791 (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: cwULBlt5HXbNnBtWIF4QrTN/nFG464teOP5et7Ev9AYeG+AyI02v0k8XOnivyMqWsB8IkYf6/VpVsk32hDYl2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10071 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_202308_914945_41F300D6 X-CRM114-Status: GOOD ( 15.59 ) 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");