From patchwork Wed Feb 28 07:48:22 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: 13574950 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 85C7BC47DD9 for ; Wed, 28 Feb 2024 07:40:53 +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=pLWDQeIOzLNZbQKuH1O0pr8O7Y3tyPKVMjOFnoXdbi4=; b=keuriuNNVvf4U7/ZNrOOh58NuB qIjEU5CVmlOaHRqRMR8KLTeBCkFhJI50pN4MgGZNhbNEt09fjAkdy7kCb3bmDqQc3vnkHiYFLiq22 lnV+hzlKYLfwI1xG/gcpS5qon1N035xDCw7U9qg0yG7AB88pJ7uD6m850YnAozijYJxnCkAtWabMY SqWe88V7+6ML0l2PJLI/taLAXAV4v1mFyUveDXMhm8jX6D+AgOO5VxMHZ1bKVyBJSX+DpAmQiPD9L HK2tG6Qo7K5PfjRIdmQ6RUIAu8gDDx7v+xQn+PLjuYYI4pnmDP19Ud6xtQb8VVsgU7+uQ2A7mQUQ8 7n3qr58g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEYV-00000008Kvz-13Ot; Wed, 28 Feb 2024 07:40:43 +0000 Received: from mail-db3eur04on0622.outbound.protection.outlook.com ([2a01:111:f400:fe0c::622] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEYK-00000008KqW-35ir for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2024 07:40:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kFuow54R4h6bEGE1gfMNXwPr+IqV8KODADbcdlY8TTIERR2w/SSSaVyyWC0F4oDk+UpsHtf5y0LRGtm23NcXwkPULJVdv3/kKJMbgZg7ypzMedL5CJNAfIxdlL7EQdfH9/PxC9ETPF4S0BbjUw3Xkb27d3x75g3WfYoRw2C+vwpv+eYSMcqBlpfZjtlCEdQAJjYZIAsFJBBpitRjA12/iBOG2vD6IEBMmb50l8HyemLbLRWc07s9/YS0CCZQfwBcKWKrc6tO4QGBdLC0WKx0Peimjz3d8om2pmruw2QqhXaRqBJzOLg+LqrejhH0j32j4b1PnJSLmzqiqxKDH3gHIw== 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=vQc0GVce4gyfScQ0+2/NaBFXb/RM7XrxzLkMBjf6AsQ=; b=hphpGr79V+esGsRcVjEkoRNWvm5VFReTomjDVxXaHzHFKatpaOQOQBSVxeymnICNplqf21H4iMwZohkUFsd9Z0dH/GEn7UmjB/K+7u6fMFl9+LYSyY5iB9XeKFH6OKCo8VsE7rm9CrABehMhGk4k7Kj1M6ntJhwVluA3HRnNq5P1AvvyOHfPRAznyupsjQprF4bJYOT8MnrpeHa5jk8FLGcfFQjUaGH2kODOiGgg9dc8YMcsGbTpV+zBwRKEvgMr+mgbx94texltnLSlCq+WUUvruRmvMUnINcs4k17P0r5+jEvQ1QRjGKdccwNT+YVhqp3hUkPdMxEJbV4F2Dendw== 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=vQc0GVce4gyfScQ0+2/NaBFXb/RM7XrxzLkMBjf6AsQ=; b=izG0CWXAU1pZweR9aF5m4HIOXjQQMowQ74KmM9VDO3SJAEPWBWxawpmDhdoe7bH11PqmgwwHVoP+HAPbKeDO7m84HGEefwe573uyXvDu9L3O6V2p0yPyReXhf7i1Kh/0CpT2DnojHk/81GFvSFrJLcT+xQi0pD0EH9+NUCBGvQQ= 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 AM9PR04MB9015.eurprd04.prod.outlook.com (2603:10a6:20b:40b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.40; Wed, 28 Feb 2024 07:40:18 +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 07:40:18 +0000 From: "Peng Fan (OSS)" Date: Wed, 28 Feb 2024 15:48:22 +0800 Subject: [PATCH v3 1/2] dt-bindindgs: clock: support NXP i.MX95 BLK CTL module Message-Id: <20240228-imx95-blk-ctl-v3-1-40ceba01a211@nxp.com> References: <20240228-imx95-blk-ctl-v3-0-40ceba01a211@nxp.com> In-Reply-To: <20240228-imx95-blk-ctl-v3-0-40ceba01a211@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=1709106512; l=3472; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=JfHNDvv+LPGya/rrOIhnl+dRILQQPy4kzO230r884iA=; b=KdR3D4sYUsKM8Tl6fmjX9HJ279JCiNUr7srdHSFOuzfdsnWq6or6QwvtaWQHV6SyQpuQeRZHV 041st4q9MGMBW755hCHlHV+jT3gRfChcsjGinCrUsYSFGC9qL6mUU1A X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG3P274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::22) 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_|AM9PR04MB9015:EE_ X-MS-Office365-Filtering-Correlation-Id: 59fcb97e-bdf7-420d-c9db-08dc383082e1 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: NpgdY7bNvYdpuXhfGM7NoZkeWgRUyI3C2ZbNzYfoHWk8ksJY63sf2sLZ9y2GeFEgFW/am2XOcFU0+n2z/vTlZilpe1jycD2hMLiOUEArpI5gXSEepYpqWM8tKPuyJw/UDj7iTUJpgnMoFdhHsg72Fa3KvHnd0Up5xCyGcvVryKSvJPgRROtyCPsK/3nL/QeqlrqRI4eXnHGNfngF5bNxnDv2GhkBOQRlCFW61buy3juMBKRzOhYwHZKgWxQr5LHZlYM/JPs4aiPEybcJ9MO0rbtalUkRieWXba0pINU9x9spB59bCThet/f1T7yDY0pZBHnfekWkmtQ2RXM1/w36vtwTojcCho0pRLelqeSSAeNcwjOT/SLAUakKJOjEExARQEH/1HYQjVX4Lu4qS0rr95ryUFjCuFjV6dUSAXOP12MEdqaqAxzyS2AVezNbuFQoWpMQSqW9XimBFvqN11euOjBofNt466Zg1Z1k7UGsLHcdl5W4o293/oaQexIU6ERQgakrmXoOgA+RrmBHAz3wi+7Wko6WNrR2vHaqMcQ/2sm127KJ+joMylavJgez6WspmQoEQHRdKJbhOWsm6nE3GmiSbKymsdI/WKuIVbZO0AFidvWSzftPae8TwfB4UmKSr/Mf5RTU6zLwhNv+tYHsGL1jlAmkMw36MwfsYZDCNMc0jcoHAx5fb97aTfjCB216aaw6nv3Sk79r+WEqfpARounUrNEOmn24o3xW4ppfHoU= 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?ym+BDPSp8VZiN/ZN3C2F8ZkbW/cJ?= =?utf-8?q?16QKIfTNCyeBri+zZkM0CRVINxkPygxNc7TqjBdxt3/ipK2XYeibfFs2v0feC0x7u?= =?utf-8?q?BsarpSY8uqEvfxGhl0u21+kIw6LSnbyg/oRJAXf3RXdQnPcyREpMyR2G9bbUYlntH?= =?utf-8?q?Fi3ogIGWt/ILd2v611Xt5tadU9bohZnQUWMI5XzJz2Cr7CblokP9B4pI7zZfcBkfn?= =?utf-8?q?Ep4/X5d46XEjjD+Fvbqr9SIDesyLQQQnHN4T5eJAbD1OMmrc1CAw3E+5+YUIVFiv3?= =?utf-8?q?3NGj6zXvwgZUCrIAYgnJIbnoykhkp6mwIRYdANyX25lwykKqQQenQf1lQffGIEiQB?= =?utf-8?q?VzbEW6D9sK3fwo+PHYgU0YQYn8oqQmKauYmRVrEAJQk3gBNmLe6di64aEakp98TR0?= =?utf-8?q?D1KyQ7UCBotrSGuBD7tc2x4L0WZUG0++iYZ5fryNi3b/uWl06GnkCvrc5xOtaXSzK?= =?utf-8?q?DTziO1sSN1IJsWa+P8darmggy9ivewrU9RXuLRbuQEzn0KEmrkp57GCcPPqvPY087?= =?utf-8?q?YSLRpdM8ibAr7zw8A0UyKhKgUZaS/mB+5j9LSswfdjRmPkCsrEERGK+3B1Bi++vUz?= =?utf-8?q?wl6Trj1kIe336rwGpgiYIn4rDCbzxSu2Se21P8WrI1tb7iegKWME/AWmgqVUsu59f?= =?utf-8?q?XXODEnPMCTkjWqu5eH8967OIE6q8yo7ZzIEIGx+9W6wtDoQxTVnTg138nkW5/2Kf4?= =?utf-8?q?wio2SEvS9u14N6bwZ0zJFAgGtmFhokeQSTANxuXoOXDVlBjN97PtTdyRdjy1jq/Kc?= =?utf-8?q?ANd7WjCWHs22RgLaS0w5oqYIyPwM2qNjuJqVBL77cwFc2RhUtyC9kdRVo5RV4H5MJ?= =?utf-8?q?xYlV/yxjoGJSpYcBi1QhZ7W8f/R+P71ziScSr/snMmV7yjRndxS0Q3jx8Wll1dUrb?= =?utf-8?q?LnbWYhnwI0Ny3tfYDeKmiApmAiieQDUWI85IDOVRuRvQ0QV0wG9elGXFWW5ZlRKRX?= =?utf-8?q?8nFqFOJUpOkMEvlLqQNYe7/2IlRjFvsptJ+gPLOqASHkP6IUbzdchiBOK80TxeVSX?= =?utf-8?q?rAiVyC0CCMjuzsI/aIQYirK9jG7jDzMtr9SxOL3FZ+9QsnDiIqHPNpq61cqNrt7Qh?= =?utf-8?q?vRoe6UIGaP0eAKT2c7Dc6+c1iStUoN2o5+q9Z473tNAcXSMA+XUeIxdUl6Tj8GXB9?= =?utf-8?q?6r0RgogDMN7egbAkVkVO5VTEspVoesdILRpMgnSvfD1g+cjDnoPggEO+9dTLCp9vm?= =?utf-8?q?ib0Fqvc/n1fntKYgfMZQjar94WH2gUvGSRIEIas/9Ea9eLpH1wq/UiRD6YF9hQIvy?= =?utf-8?q?XL+bcdOTj1x7cM2rHWdTQRfp2P1s/bV3ZMSojtR8iKVGiV+zzKw2aW2+e45KtiNzF?= =?utf-8?q?o1fiCmaq2wAFyNSz0J1ds3UWPZKwHXbmw6x6pM6zdKSqUW81YtlBo3JEM17kCU4t/?= =?utf-8?q?3mDTPINEK1czO12t/Gph28kr7lj2UCYf+3O4zhRrWpPYTII4OveddCbsfY/53gKU5?= =?utf-8?q?duu72z0Z/yYSHgdDK8qdlW48rZPF73P9t8UXsj8DW5qpXcr3GsnTcdpKdT8U60p/V?= =?utf-8?q?gfQPMXpQBaVY?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59fcb97e-bdf7-420d-c9db-08dc383082e1 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 07:40:18.6619 (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: XekR2B8bxeu1OCItAeEuj+M5M7UYcq5WVA6T1b5fwYnUvccdD1I3sGdeyY0pUF9yN5/hvD49iqcd//8MuIyBWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB9015 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_234032_825797_30C092D2 X-CRM114-Status: GOOD ( 12.16 ) 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..c8974b927bee --- /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 = "nxp,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 07:48:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13574951 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 32A4AC54E41 for ; Wed, 28 Feb 2024 07:40:58 +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=QIU2lLIDq+q+zhlziQZA3+p5Mi DjY4sh42LlLKXR7Jj+3Vv7CLbE6kTHcrNKmd9YoJhjKw96Y8ySq+9ag9GVFf4himqiBu5bFNoZfCU DftalU+UOfU3rw/pTyGDc8T72IyhbZr0z+ODpS8oyd90HBv/z0MXbS2/KI4FUteFW40mKV7FMZNHr XRgD/DzSG6mAWOxhQ845MMIHnsdXSOUxGOfOPqcwrKXj4Lg+SOyPJQxWwXS2D5hn4hQUKnUVp+8m/ OhNaUSGSYjGI9ZLFTEAX4OMkqwkZ/49eLt8g9+RL+ikgmoyRYtojPjByP596YNZxB4o8G57NWTSYt dVtIjiKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEYV-00000008KwQ-446q; Wed, 28 Feb 2024 07:40:43 +0000 Received: from mail-db3eur04on0622.outbound.protection.outlook.com ([2a01:111:f400:fe0c::622] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rfEYM-00000008KqW-22mG for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2024 07:40:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hjMm0JyscwSEnygRYOQwh1S601ofR1431aCjmeAyv6ACDsY5VNWvnxu00YZ6OKnzUMHqN5HtsNp2uPi2O38ekrwjvhcijFAadj7eFfxlihuTkOPTJLDrOyCg9UVrIJRQuGyVhhvZbT/5+gqOhbvdHMI2iCrWqNkoF1uWv8JbmBvL/OEiH7SwIAmv5nMiv9L7/p7X5jHgb+HHidPiwtBHr3unnxjUwbAqNlPi7Z26b+Mg0vPpc6g1jts+YCG/roWCTOy+gg9luuEyGgSNhBWnUsMJsl5R7fEOQbMlAPwYbdciKSBvjCuE+jKG/JgKZVEbtjYbm55sJv4VF5gomp/Znw== 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=CLFuLarM5sJu2Ho46ztOP9e/EsHLmsyp23UBC0/5EJ0bZN+hkMlaabSaVm/a2rLTfVuKE1SUpou3YoFusWfYQmcholXJQdmVjfWU56GGwdfI0ceRG0jYAyDMedUy6w4V4oYyf8wlr9kKFy5Uu2vdr+hUByYEC44Yw6JprDb/njDiYf9er/5QDipAYqZcvGR6GOe7Oh2tM61gEqSL+iZbfyI00Y8H1xntbCZIKTJ4fCVZZPevLoQsRM18bYhErs0dvDrzdb5JwYzDr0OGB/gXsF1XyB4OGBUYO1bqGTlW0yx1pZAOlTXp78iRCR8hOYdUXQRwC2z0Os9P0qW+YJdq9w== 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=WbgPIxOhtF/xLxNuDsBnO/AH4yrCbfnjT/eYmgojOqlACCLSoiM/5EgocY3V0bTDGg/0yTu8osHfFhHdNcyfBceGZHTZJHJE7VDxSP4RMNvcqXYLu01+4bELIpRmQyeR8AJQV8s7PvQSj6rr349RbWcw/qAP7L+auBF543RN3fs= 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 AM9PR04MB9015.eurprd04.prod.outlook.com (2603:10a6:20b:40b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.40; Wed, 28 Feb 2024 07:40:24 +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 07:40:24 +0000 From: "Peng Fan (OSS)" Date: Wed, 28 Feb 2024 15:48:23 +0800 Subject: [PATCH v3 2/2] clk: imx: add i.MX95 BLK CTL clk driver Message-Id: <20240228-imx95-blk-ctl-v3-2-40ceba01a211@nxp.com> References: <20240228-imx95-blk-ctl-v3-0-40ceba01a211@nxp.com> In-Reply-To: <20240228-imx95-blk-ctl-v3-0-40ceba01a211@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=1709106512; l=13492; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=xdgyrgvjxybTyzDq8X/GTHuUjGIxReFNUQBlt7Wg4qY=; b=s1mN217LUoxdplJx26CqjKjkkixa+18xKYDuyjKDIvC6lT6VIomKJ92GD7/TMAHqRqJbDgxXc JBUFHrp1tRTD5MJXuzyi4v86S3KG3cTTGwHN2R2dY+Enos5qrqTxWYe X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG3P274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::22) 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_|AM9PR04MB9015:EE_ X-MS-Office365-Filtering-Correlation-Id: f7e5eef1-1a28-4caa-83d4-08dc38308623 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: z1Ip5yM3PSPTqdYEFX3OwCbkTiHen1i26pv3NFRvU+1yN9LnR5MRBmba4uF0J6mGZEX5OFM/1WwRKrnIh+b4Neq2CLdmb6se2zJq5z3O89Hc3c/ZRSO4Mg/BNkFmKIeYM3KXsN9hagmEwIN+jutRylK80cRBOyXXQXPdKyguordMQf4WmnvybA0Mm/YRSjPKOYGDI3IPBrzc44dMSYfT/3/b1IoYzqcT9x634jxStHGnVfRIos/xAht6uhP9gzWniHVf0DeFGAOHk9cw9if80iNu8sbA6sUqoGzoDv1Kt1F701XepphqzuxPK6GPZmFfJU6Zpw2zW3uMQuzPCetPUn+lsVCX7hDaTDL0OTe8uOcFXtfg8bqnIxZpIWqsGxVDgbSbcImVWOW2P+z2DuBOoZXZmzffyG4owzzWyLvCcklnJpsBsuGXCnaYjZifGthBC1I7Z/vv3XVA5hMo5mTzm6dn5+DSuV4FUB/nc3zVxexfQsy9DnrZclSJPhYPD0LfF/MypGmmDaw2/gFxJFnPy0KY83c+poCIwbJYsc2IDS0L3zWsyrU5U8iXf9yQS80HwP9Z6E5NOsYYf1cuf58gtBgH6B2JN47h7QDxn2oDJ/RhurIAQ3iBo2nghYQxlnhYHIm8/ZLL70ro6nw1NMNZ98UDa3qTFXlZAm9lxLV17DEJOruqrGdfzSlELV7tgtUaejmsA15ROnaJh5KGs9BYoBww2ufNBil8RqD16rNbIlE= 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?OoghayI74rXrCQ0DH8hx89Dj13xC?= =?utf-8?q?APQUXw+sc2YudKjrKr1BRjAvpmv/9yFRuUO5L0HGtz/2dWKoVvOrAis9VFJkeornU?= =?utf-8?q?1qIwY4oiTVA0eLXDPOLWDGfgq1cN6h2tn2j5S2/7eJ2hnh99th4fPu4jW3EBOthlV?= =?utf-8?q?rjKnW+XXrSCi3xgxZKVBkNVcYR9qXCCPlSKXzvSIHA4xVRV6epQY0J6+VEjRT7Aj3?= =?utf-8?q?7rF7y+598yhQU47Z0yxiPnSJJJfszORczPs/zAMOMrfy2aDNj6QqF7MPDrB3Al5t6?= =?utf-8?q?aLFT2CQcaKNZrxBFVApTRpiJLnYrmzV3JoXS3SmHDl/JBuUptBzCN3DbbZ/Jg/Yx4?= =?utf-8?q?5D7d99R3DbOCWeVQ4GUc65mHIt46STAQSOEpSVCxsVVf6xZIn5slkNLISxN0u1z8W?= =?utf-8?q?B66mt6lGPBoXymUjmeyI33eqiWZwkO8WcFZ73quKi1X/3oorezzJuTPOeoYFt55Am?= =?utf-8?q?WsjqcVTB23WZSK/lwuxLc5p3Optk9/oPSNfrbbaPa6i43ETEQc+/h3WxOz33cWr/F?= =?utf-8?q?mCyGQXgAu+ubU2FmpMqhQ40BprS8vGrXB+ZEhJ+CPeFLX6JYN/S1sGipqKtBYyIha?= =?utf-8?q?v9Jm1d5KQo8tlu0jdwLPS+OAIzEuaFHYU02AYWI6NET/QlddE5nddtvHIMw8DKNtY?= =?utf-8?q?rzuFfwewOrsUXnfDNgVaFQUhrlo8byozIKdrkolUxhs72gdGuUdFO7tm8pJEKqyNF?= =?utf-8?q?h/n0tCgFcoQNd0zc9VLn/bvAxnQb9O6ql49NWr4H5rMUe4+OacOna3oPGEnyMCDCU?= =?utf-8?q?PgzFXYKtyGP6pjZSXGtJKn+xl/tjsBy4PouU5HOEx7gfNzce4DFd+leuhG1A3oSHQ?= =?utf-8?q?BS2dR2hd/1Y/oLjZFCkKxIOLXVHdGcdBAcYHXS3uooPkaPTI0QiSaCmvLSbncZfDk?= =?utf-8?q?txHQOslYvQ5v3C4Ii+WXBp7OeYq2ujyt/8EIgBkOBiBdQl9v2S4Q0C9V3E9ZxcWhm?= =?utf-8?q?gb8HMFA6ueGm5RYOIAQP+88jhLaPap8OqjaedXqUzFzwLsC/CtU25Z6j5euezRCa3?= =?utf-8?q?jfkpfDubcIVJ1wo1IHqm+y5l9KlWeuE2NdEIqXA4vjlirmq1y/BIHRof+tXBBsufi?= =?utf-8?q?axkP+sXwB0aGtPW0VMyJbobjqtfylnp02sMWIqseB3/Ko/Qr1nEL8FFxB2UOflQE3?= =?utf-8?q?Lnjge7dpjPxXNkoXIIgf6Fdb4uxAqiXDj1wTffSVTjGt+9ljZaPCk3ot5hHb2fJgi?= =?utf-8?q?ht+3qNEnUddNcwVqzCeEJr4hk5lpm6CqI+YS081SbL1AxQBFphSOf5nPPtRC8izxf?= =?utf-8?q?tw2lruOTge1Vy5ofyT02as8X5JXpgRPRG94fKQlRWEPbo6v0LvOutqEEyAOvcwBz6?= =?utf-8?q?6yn+doS3HQ4lLeMteGs9+yX1EWGXNZwFoRJ7H7N136weJx5kq+QE+frvTrFt8cZpu?= =?utf-8?q?aOz68mhKmN0ikwrfFDzR0Cx2lUo7WrUW/DkIGuqSB11ye6OSEtc6Uyg+7xs7tSJvf?= =?utf-8?q?W6CZ775Td0smi71tBpWibJQ7SzX6+vBXVnwy5fXGk8cQBQ7Y2iv3E89lyNB2DaiRL?= =?utf-8?q?UwqiYTqzc8c2?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7e5eef1-1a28-4caa-83d4-08dc38308623 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Feb 2024 07:40:24.0969 (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: 4dc41IDd8q/ShHbhwAD/xY04RrSD/euwXDt8IEPybwnwhf61EGcz3aRyLD88eHkn37giNyxXo0LN54bM5tPfcw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB9015 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240227_234034_583329_1304F21B X-CRM114-Status: GOOD ( 15.98 ) 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");