From patchwork Tue Sep 14 06:52:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 512497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75CF8C433EF for ; Tue, 14 Sep 2021 06:41:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 568B761157 for ; Tue, 14 Sep 2021 06:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240218AbhINGmf (ORCPT ); Tue, 14 Sep 2021 02:42:35 -0400 Received: from mail-eopbgr70088.outbound.protection.outlook.com ([40.107.7.88]:35907 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232880AbhINGma (ORCPT ); Tue, 14 Sep 2021 02:42:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a1Yki5tneLQTrZc6s3Op/+BSpYUf4vXwcVlr9hSLntM5AWLS1t2PL/sLPe2cXL6gitfnPRw3Kiip3137z64zEN5Xh/vGDbQnlkeKtlWoFidIbDhr5TQ8EYpuuWKldmqCgJB3IxGPLqjVw0xCgkAyKfitJ3hn4kbhulqhOy4ZZ00ul11K9LQYE7shdylsD8DlqINBM5MITHP8z6sN8zHeW8clpTb+JozQgBmUcCJ7W4KljsCOgg2EK4LRwSrBRAbBJEtNz9RBKML8cpd0R6JwzCYrCZwp4fdrI495H9QzXXKgXz9MVD1tbAEGTbHwrJKmRHDJimGjhy2rUaNRC8470A== 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; bh=fS2//TSVLPDEmUJ8gt9QaI2dOo5ZfsuPKGYqMHMPorM=; b=oHy29H4+86oP6NMTz8Bnaw/RY8fIv8fCkrOCvekY/odvR3FvKQw9CVz4u1fD1ZtiEUZnhJywoYD2yP/DK0ijbOkxnPcgvJhMsBEKP/kUWZO54TY90u+F/WfqtVhEbYtxPCxocuNvpQ9FF1oMlTbAaj/zyjAtkryYEKPUelvXVHD0Z7bvZ8CZJCLZOG0VZTod2nox11tgTjAajDnxj+pc0MDYk33fq/WgC62VMFPSnAnOPCAXNOWPPBcx/8RVgot3U0KgqZ+MAE/SczRakujrb15DAknkFFd953cAvvfLHWWQeoLGrop3NRu6jxhV6S76wMYKj7NrElg2QYSyqq3Asw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fS2//TSVLPDEmUJ8gt9QaI2dOo5ZfsuPKGYqMHMPorM=; b=kCwFT4ZRofHt5RK3EWOqrURLsW7YwdAAl6JHiIOO5w01v6R2bch6WP97vRIC3Zfb0geGOstr9LxmM9N6H7D8XOjA3yAFf1Yb8j7SNAeTtcz9g86z2JlsR/Thn36rBSaLMIZBohEMBfr8tLhyke2sjGBFCr/E7fx7LSfrB4epSeI= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DBBPR04MB6028.eurprd04.prod.outlook.com (2603:10a6:10:c1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Tue, 14 Sep 2021 06:41:11 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:11 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 1/9] dt-bindings: clock: Add imx8ulp clock support Date: Tue, 14 Sep 2021 14:52:00 +0800 Message-Id: <20210914065208.3582128-2-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2feecaef-ae77-40f5-f1d1-08d9774aa405 X-MS-TrafficTypeDiagnostic: DBBPR04MB6028: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DSj9Eh9RfP1L/k5h5Pp3apeQjhm2S5DFLyQqfCPCi81RsYJCzx3XRc3qFpKq8oElmvpql5TEi4P+NKzg+cnGnKAXG4xaxgdqB0vDwye4xfXGuiNLxYRi3G166lkJ+xh+2AkAlFegVXA+/wpnGkbxtFIhr3CaaXbCv8bguSk7lpOQEM6tzOzEX/IXU+cSfDu5xM4GsK+FxHlPHzmufwdrDevLSZpr5zmHwSXnuqlEMB8No+4sxcwcIhiWHCG7hvbFdMrTADJbNBc+1Ytc+F/LGJfJn29H95E9sI8Bln+9ZfJZgGlYfT/Qi9FEryvEUwfNMmxRuivtJS/NRJcCKqvJ/KLcp/Bh43nGke4pDrm7Z4Inn5s6vLxxSprGPu6gK9qYXQF5BFz3Ull1dKM2h5dho6euY/x7Y/0RtLphNXDrrDCM46RCv4sRpcRmFPh8bdef91fD7s2DDKG5aQHqXSWQ+M/OdF5z8f3TB2zRv7BgKWdZzUfdde4bcWP7NFX2J0O19poyT7bHMoFxRv9Yfgo8iOO+sVumTP3ehg+50nqf7zLzM7f55zGHveQFE/Wisrucwa3cKL5binNG5RezJvw6OYXhe3qRgLxYv84HdREBK0nGi913qXUa6d0eelno0U5CVcNun7gG+8ltBI3EpbG6yb5I2qWqWEWaBHA/VPt78jQtroUntem0+Np0rT/aotMlFFBxRKod2qn3DXE/Ac5zV8qYJ7S7KAeOAy2B/x6D4Yj2oDMARjbeh7b6FLMOLUYBxsTKEQxzGQ1BE3W0jkdciBKhxeGKpdAV/BU2wYB9gQHMW6Ki0+mu5G0SNRm1mm2cnA/912EGkZp84kPhwxf2xbnrNsocejVP4ckYdIynqQ8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(136003)(366004)(376002)(396003)(956004)(6512007)(2906002)(83380400001)(6486002)(2616005)(4326008)(316002)(8676002)(30864003)(966005)(5660300002)(66946007)(66556008)(52116002)(6666004)(66476007)(1076003)(8936002)(38350700002)(6506007)(186003)(478600001)(26005)(86362001)(36756003)(38100700002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S4EUhlzF4T1sU7Iyj2MGwpJqcTU3s/TaTglaxCVdNqVZD/wVn3WV2PVHNHWu2AJ2quic4KK6pFPJA1WYtupzO+vOaMoRYbnm93zyIT2QOhQxtQiJAQY3co9Eo8LQOoMpouxSaB/WFSCAR0jis7NXqCp7qBioH1P+kQwSkDHOr2NLc4y+nyP42KwEGpC+hfSa6Kk0ZGuKEguL5OvXaOQn7TFdOoicPEuy/xZfTl/NYyAagOf1e56k/RR1gzUwRzeIJmqOyLSiS1EToufT8QC0ZXot7kd4xQB+/OwrzCLGwsn6moaunLAz7oqStVDO0Ots2FlgJmJtp6qRCKxr0e2kFmbw6dLrszaw1B8hQ6sri0uR+qgx3of7j6LqF4VwvZrkhUSbAQty2J6R1xxFDNh03wfgCUSxAmSCx5fjaiyuE1Oe1ZS2zVNXTWMiC3SBR3DCGRru86k+DiIsjTfmOO5ROqz0fuMEDwy3/wKD85+3z+OO4Gxy9/9MRp7kZrbfPylnIBE1WENRJ5knEjIc4HTfIu02iYCaIgReHcHilk3jA/KxjTBfOpQW8RXFcqKfE1qSaDXTLzJMbr+ySR3/nm9LSFIxvWLGGQSJ7Jn/lfJqaI3a9cckIHaVhzHmofh1tQJE6FerO83/KATx/N5l6VjVh5K2ksrsFPBKLuLqYee74VPAiynr5tBA2aqBhfwvuoxhszoZ3fM12byt4W9I5apymnQ8uB5Izuy6C2o8+XKPvnGi0zDY2bimtUyIdDAbDuuJNHOcVzyrOflaEXDx1X/I5oaEWqzhrAU84Y5tOAHv374zEfTSNhwPvRzmKSvBBqoA9V9Q/OE5+cV8GbYxPM6jRZ45RmuD4s831k8dnQ7lZ/lDcUbz5+SWK32cnundSD/XVSt68Bxj0xplKai2UtwFeAc0LBcsp8fBJXleybAcGNOvaqGJ67fMe8+4N0keIYGCqjwQ2KMYarpvvEtAJw7gmjyqUjTeSq3UF9DSJAweZOAKvyO/RLMulCTtcsWsumKNSrT9zubyZk5TLtb4UoApe0xGKl0TgcuIQOCDXbQWTJoh6qmv1jX6e7vc1e2BgCTPhjywH5q04ZFdkmbBlZzOqsDsTGQlMAEAN/s6PUv98Z3AT/CAUMsFCObMxYo0Qtd5tAqAmB633D1/7IUSkOxnhF2jV1G2tWSO3+xXqfnBhM507HqcrrIMdKQwgytS1zBLVw1ll+udw0AUGHrrLdSRh5OYJnVjBzWLU0oVSihZ6ANin6xQ4GCSH3QDF5VWLGQe7VRLsNZFHn5+lEaVJbq0WFEmyHF29huvUIFExZivBJNySDCW5jTflxiJI32yQwJP X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2feecaef-ae77-40f5-f1d1-08d9774aa405 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:11.5402 (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: uMo0NyRJxZV+RkMMZKLrzUfqH863mKI1i+dMhwM+jKZyf8GyJt4H1jszZRskn6tvqgG+VeUXfzYXxzFonNwM2Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB6028 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add the clock dt-binding file for i.MX8ULP. For pcc node, it will also be used as a reset controller, so add the '#reset-cells' property description and add the pcc reset IDs. Signed-off-by: Jacky Bai --- v3 changes: - split into two binding file, one for pcc, one for cgc v2 changes: - removed the redundant clocks & clock-names property v1 changes: - Move this patch from dts patchset into this patchset --- .../bindings/clock/imx8ulp-cgc-clock.yaml | 43 +++ .../bindings/clock/imx8ulp-pcc-clock.yaml | 50 ++++ include/dt-bindings/clock/imx8ulp-clock.h | 258 ++++++++++++++++++ include/dt-bindings/reset/imx8ulp-pcc-reset.h | 59 ++++ 4 files changed, 410 insertions(+) create mode 100644 Documentation/devicetree/bindings/clock/imx8ulp-cgc-clock.yaml create mode 100644 Documentation/devicetree/bindings/clock/imx8ulp-pcc-clock.yaml create mode 100644 include/dt-bindings/clock/imx8ulp-clock.h create mode 100644 include/dt-bindings/reset/imx8ulp-pcc-reset.h diff --git a/Documentation/devicetree/bindings/clock/imx8ulp-cgc-clock.yaml b/Documentation/devicetree/bindings/clock/imx8ulp-cgc-clock.yaml new file mode 100644 index 000000000000..71f7186b135b --- /dev/null +++ b/Documentation/devicetree/bindings/clock/imx8ulp-cgc-clock.yaml @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/imx8ulp-cgc-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP i.MX8ULP Clock Generation & Control(CGC) Module Binding + +maintainers: + - Jacky Bai + +description: | + On i.MX8ULP, The clock sources generation, distribution and management is + under the control of several CGCs & PCCs modules. The CGC modules generate + and distribute clocks on the device. + +properties: + compatible: + enum: + - fsl,imx8ulp-cgc1 + - fsl,imx8ulp-cgc2 + + reg: + maxItems: 1 + + '#clock-cells': + const: 1 + +required: + - compatible + - reg + - '#clock-cells' + +additionalProperties: false + +examples: + # Clock Generation & Control Module node: + - | + clock-controller@292c0000 { + compatible = "fsl,imx8ulp-cgc1"; + reg = <0x292c0000 0x10000>; + #clock-cells = <1>; + }; diff --git a/Documentation/devicetree/bindings/clock/imx8ulp-pcc-clock.yaml b/Documentation/devicetree/bindings/clock/imx8ulp-pcc-clock.yaml new file mode 100644 index 000000000000..00612725bf8b --- /dev/null +++ b/Documentation/devicetree/bindings/clock/imx8ulp-pcc-clock.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/clock/imx8ulp-pcc-clock.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP i.MX8ULP Peripheral Clock Controller(PCC) Module Binding + +maintainers: + - Jacky Bai + +description: | + On i.MX8ULP, The clock sources generation, distribution and management is + under the control of several CGCs & PCCs modules. The PCC modules control + software reset, clock selection, optional division and clock gating mode + for peripherals. + +properties: + compatible: + enum: + - fsl,imx8ulp-pcc3 + - fsl,imx8ulp-pcc4 + - fsl,imx8ulp-pcc5 + + reg: + maxItems: 1 + + '#clock-cells': + const: 1 + + '#reset-cells': + const: 1 + +required: + - compatible + - reg + - '#clock-cells' + - '#reset-cells' + +additionalProperties: false + +examples: + # Peripheral Clock Control Module node: + - | + clock-controller@292d0000 { + compatible = "fsl,imx8ulp-pcc3"; + reg = <0x292d0000 0x10000>; + #clock-cells = <1>; + #reset-cells = <1>; + }; diff --git a/include/dt-bindings/clock/imx8ulp-clock.h b/include/dt-bindings/clock/imx8ulp-clock.h new file mode 100644 index 000000000000..953ecfe8ebcc --- /dev/null +++ b/include/dt-bindings/clock/imx8ulp-clock.h @@ -0,0 +1,258 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR MIT */ +/* + * Copyright 2021 NXP + */ + +#ifndef __DT_BINDINGS_CLOCK_IMX8ULP_H +#define __DT_BINDINGS_CLOCK_IMX8ULP_H + +#define IMX8ULP_CLK_DUMMY 0 + +/* CGC1 */ +#define IMX8ULP_CLK_SPLL2 5 +#define IMX8ULP_CLK_SPLL3 6 +#define IMX8ULP_CLK_A35_SEL 7 +#define IMX8ULP_CLK_A35_DIV 8 +#define IMX8ULP_CLK_SPLL2_PRE_SEL 9 +#define IMX8ULP_CLK_SPLL3_PRE_SEL 10 +#define IMX8ULP_CLK_SPLL3_PFD0 11 +#define IMX8ULP_CLK_SPLL3_PFD1 12 +#define IMX8ULP_CLK_SPLL3_PFD2 13 +#define IMX8ULP_CLK_SPLL3_PFD3 14 +#define IMX8ULP_CLK_SPLL3_PFD0_DIV1 15 +#define IMX8ULP_CLK_SPLL3_PFD0_DIV2 16 +#define IMX8ULP_CLK_SPLL3_PFD1_DIV1 17 +#define IMX8ULP_CLK_SPLL3_PFD1_DIV2 18 +#define IMX8ULP_CLK_SPLL3_PFD2_DIV1 19 +#define IMX8ULP_CLK_SPLL3_PFD2_DIV2 20 +#define IMX8ULP_CLK_SPLL3_PFD3_DIV1 21 +#define IMX8ULP_CLK_SPLL3_PFD3_DIV2 22 +#define IMX8ULP_CLK_NIC_SEL 23 +#define IMX8ULP_CLK_NIC_AD_DIVPLAT 24 +#define IMX8ULP_CLK_NIC_PER_DIVPLAT 25 +#define IMX8ULP_CLK_XBAR_SEL 26 +#define IMX8ULP_CLK_XBAR_AD_DIVPLAT 27 +#define IMX8ULP_CLK_XBAR_DIVBUS 28 +#define IMX8ULP_CLK_XBAR_AD_SLOW 29 +#define IMX8ULP_CLK_SOSC_DIV1 30 +#define IMX8ULP_CLK_SOSC_DIV2 31 +#define IMX8ULP_CLK_SOSC_DIV3 32 +#define IMX8ULP_CLK_FROSC_DIV1 33 +#define IMX8ULP_CLK_FROSC_DIV2 34 +#define IMX8ULP_CLK_FROSC_DIV3 35 +#define IMX8ULP_CLK_SPLL3_VCODIV 36 +#define IMX8ULP_CLK_SPLL3_PFD0_DIV1_GATE 37 +#define IMX8ULP_CLK_SPLL3_PFD0_DIV2_GATE 38 +#define IMX8ULP_CLK_SPLL3_PFD1_DIV1_GATE 39 +#define IMX8ULP_CLK_SPLL3_PFD1_DIV2_GATE 40 +#define IMX8ULP_CLK_SPLL3_PFD2_DIV1_GATE 41 +#define IMX8ULP_CLK_SPLL3_PFD2_DIV2_GATE 42 +#define IMX8ULP_CLK_SPLL3_PFD3_DIV1_GATE 43 +#define IMX8ULP_CLK_SPLL3_PFD3_DIV2_GATE 44 +#define IMX8ULP_CLK_SOSC_DIV1_GATE 45 +#define IMX8ULP_CLK_SOSC_DIV2_GATE 46 +#define IMX8ULP_CLK_SOSC_DIV3_GATE 47 +#define IMX8ULP_CLK_FROSC_DIV1_GATE 48 +#define IMX8ULP_CLK_FROSC_DIV2_GATE 49 +#define IMX8ULP_CLK_FROSC_DIV3_GATE 50 +#define IMX8ULP_CLK_SAI4_SEL 51 +#define IMX8ULP_CLK_SAI5_SEL 52 +#define IMX8ULP_CLK_AUD_CLK1 53 +#define IMX8ULP_CLK_ARM 54 +#define IMX8ULP_CLK_ENET_TS_SEL 55 + +#define IMX8ULP_CLK_CGC1_END 56 + +/* CGC2 */ +#define IMX8ULP_CLK_PLL4_PRE_SEL 0 +#define IMX8ULP_CLK_PLL4 1 +#define IMX8ULP_CLK_PLL4_VCODIV 2 +#define IMX8ULP_CLK_DDR_SEL 3 +#define IMX8ULP_CLK_DDR_DIV 4 +#define IMX8ULP_CLK_LPAV_AXI_SEL 5 +#define IMX8ULP_CLK_LPAV_AXI_DIV 6 +#define IMX8ULP_CLK_LPAV_AHB_DIV 7 +#define IMX8ULP_CLK_LPAV_BUS_DIV 8 +#define IMX8ULP_CLK_PLL4_PFD0 9 +#define IMX8ULP_CLK_PLL4_PFD1 10 +#define IMX8ULP_CLK_PLL4_PFD2 11 +#define IMX8ULP_CLK_PLL4_PFD3 12 +#define IMX8ULP_CLK_PLL4_PFD0_DIV1_GATE 13 +#define IMX8ULP_CLK_PLL4_PFD0_DIV2_GATE 14 +#define IMX8ULP_CLK_PLL4_PFD1_DIV1_GATE 15 +#define IMX8ULP_CLK_PLL4_PFD1_DIV2_GATE 16 +#define IMX8ULP_CLK_PLL4_PFD2_DIV1_GATE 17 +#define IMX8ULP_CLK_PLL4_PFD2_DIV2_GATE 18 +#define IMX8ULP_CLK_PLL4_PFD3_DIV1_GATE 19 +#define IMX8ULP_CLK_PLL4_PFD3_DIV2_GATE 20 +#define IMX8ULP_CLK_PLL4_PFD0_DIV1 21 +#define IMX8ULP_CLK_PLL4_PFD0_DIV2 22 +#define IMX8ULP_CLK_PLL4_PFD1_DIV1 23 +#define IMX8ULP_CLK_PLL4_PFD1_DIV2 24 +#define IMX8ULP_CLK_PLL4_PFD2_DIV1 25 +#define IMX8ULP_CLK_PLL4_PFD2_DIV2 26 +#define IMX8ULP_CLK_PLL4_PFD3_DIV1 27 +#define IMX8ULP_CLK_PLL4_PFD3_DIV2 28 +#define IMX8ULP_CLK_CGC2_SOSC_DIV1_GATE 29 +#define IMX8ULP_CLK_CGC2_SOSC_DIV2_GATE 30 +#define IMX8ULP_CLK_CGC2_SOSC_DIV3_GATE 31 +#define IMX8ULP_CLK_CGC2_SOSC_DIV1 32 +#define IMX8ULP_CLK_CGC2_SOSC_DIV2 33 +#define IMX8ULP_CLK_CGC2_SOSC_DIV3 34 +#define IMX8ULP_CLK_CGC2_FROSC_DIV1_GATE 35 +#define IMX8ULP_CLK_CGC2_FROSC_DIV2_GATE 36 +#define IMX8ULP_CLK_CGC2_FROSC_DIV3_GATE 37 +#define IMX8ULP_CLK_CGC2_FROSC_DIV1 38 +#define IMX8ULP_CLK_CGC2_FROSC_DIV2 39 +#define IMX8ULP_CLK_CGC2_FROSC_DIV3 40 +#define IMX8ULP_CLK_AUD_CLK2 41 +#define IMX8ULP_CLK_SAI6_SEL 42 +#define IMX8ULP_CLK_SAI7_SEL 43 +#define IMX8ULP_CLK_SPDIF_SEL 44 +#define IMX8ULP_CLK_HIFI_SEL 45 +#define IMX8ULP_CLK_HIFI_DIVCORE 46 +#define IMX8ULP_CLK_HIFI_DIVPLAT 47 +#define IMX8ULP_CLK_DSI_PHY_REF 48 + +#define IMX8ULP_CLK_CGC2_END 49 + +/* PCC3 */ +#define IMX8ULP_CLK_WDOG3 0 +#define IMX8ULP_CLK_WDOG4 1 +#define IMX8ULP_CLK_LPIT1 2 +#define IMX8ULP_CLK_TPM4 3 +#define IMX8ULP_CLK_TPM5 4 +#define IMX8ULP_CLK_FLEXIO1 5 +#define IMX8ULP_CLK_I3C2 6 +#define IMX8ULP_CLK_LPI2C4 7 +#define IMX8ULP_CLK_LPI2C5 8 +#define IMX8ULP_CLK_LPUART4 9 +#define IMX8ULP_CLK_LPUART5 10 +#define IMX8ULP_CLK_LPSPI4 11 +#define IMX8ULP_CLK_LPSPI5 12 +#define IMX8ULP_CLK_DMA1_MP 13 +#define IMX8ULP_CLK_DMA1_CH0 14 +#define IMX8ULP_CLK_DMA1_CH1 15 +#define IMX8ULP_CLK_DMA1_CH2 16 +#define IMX8ULP_CLK_DMA1_CH3 17 +#define IMX8ULP_CLK_DMA1_CH4 18 +#define IMX8ULP_CLK_DMA1_CH5 19 +#define IMX8ULP_CLK_DMA1_CH6 20 +#define IMX8ULP_CLK_DMA1_CH7 21 +#define IMX8ULP_CLK_DMA1_CH8 22 +#define IMX8ULP_CLK_DMA1_CH9 23 +#define IMX8ULP_CLK_DMA1_CH10 24 +#define IMX8ULP_CLK_DMA1_CH11 25 +#define IMX8ULP_CLK_DMA1_CH12 26 +#define IMX8ULP_CLK_DMA1_CH13 27 +#define IMX8ULP_CLK_DMA1_CH14 28 +#define IMX8ULP_CLK_DMA1_CH15 29 +#define IMX8ULP_CLK_DMA1_CH16 30 +#define IMX8ULP_CLK_DMA1_CH17 31 +#define IMX8ULP_CLK_DMA1_CH18 32 +#define IMX8ULP_CLK_DMA1_CH19 33 +#define IMX8ULP_CLK_DMA1_CH20 34 +#define IMX8ULP_CLK_DMA1_CH21 35 +#define IMX8ULP_CLK_DMA1_CH22 36 +#define IMX8ULP_CLK_DMA1_CH23 37 +#define IMX8ULP_CLK_DMA1_CH24 38 +#define IMX8ULP_CLK_DMA1_CH25 39 +#define IMX8ULP_CLK_DMA1_CH26 40 +#define IMX8ULP_CLK_DMA1_CH27 41 +#define IMX8ULP_CLK_DMA1_CH28 42 +#define IMX8ULP_CLK_DMA1_CH29 43 +#define IMX8ULP_CLK_DMA1_CH30 44 +#define IMX8ULP_CLK_DMA1_CH31 45 +#define IMX8ULP_CLK_MU3_A 46 +#define IMX8ULP_CLK_MU0_B 47 + +#define IMX8ULP_CLK_PCC3_END 48 + +/* PCC4 */ +#define IMX8ULP_CLK_FLEXSPI2 0 +#define IMX8ULP_CLK_TPM6 1 +#define IMX8ULP_CLK_TPM7 2 +#define IMX8ULP_CLK_LPI2C6 3 +#define IMX8ULP_CLK_LPI2C7 4 +#define IMX8ULP_CLK_LPUART6 5 +#define IMX8ULP_CLK_LPUART7 6 +#define IMX8ULP_CLK_SAI4 7 +#define IMX8ULP_CLK_SAI5 8 +#define IMX8ULP_CLK_PCTLE 9 +#define IMX8ULP_CLK_PCTLF 10 +#define IMX8ULP_CLK_USDHC0 11 +#define IMX8ULP_CLK_USDHC1 12 +#define IMX8ULP_CLK_USDHC2 13 +#define IMX8ULP_CLK_USB0 14 +#define IMX8ULP_CLK_USB0_PHY 15 +#define IMX8ULP_CLK_USB1 16 +#define IMX8ULP_CLK_USB1_PHY 17 +#define IMX8ULP_CLK_USB_XBAR 18 +#define IMX8ULP_CLK_ENET 19 +#define IMX8ULP_CLK_SFA1 20 +#define IMX8ULP_CLK_RGPIOE 21 +#define IMX8ULP_CLK_RGPIOF 22 + +#define IMX8ULP_CLK_PCC4_END 23 + +/* PCC5 */ +#define IMX8ULP_CLK_TPM8 0 +#define IMX8ULP_CLK_SAI6 1 +#define IMX8ULP_CLK_SAI7 2 +#define IMX8ULP_CLK_SPDIF 3 +#define IMX8ULP_CLK_ISI 4 +#define IMX8ULP_CLK_CSI_REGS 5 +#define IMX8ULP_CLK_PCTLD 6 +#define IMX8ULP_CLK_CSI 7 +#define IMX8ULP_CLK_DSI 8 +#define IMX8ULP_CLK_WDOG5 9 +#define IMX8ULP_CLK_EPDC 10 +#define IMX8ULP_CLK_PXP 11 +#define IMX8ULP_CLK_SFA2 12 +#define IMX8ULP_CLK_GPU2D 13 +#define IMX8ULP_CLK_GPU3D 14 +#define IMX8ULP_CLK_DC_NANO 15 +#define IMX8ULP_CLK_CSI_CLK_UI 16 +#define IMX8ULP_CLK_CSI_CLK_ESC 17 +#define IMX8ULP_CLK_RGPIOD 18 +#define IMX8ULP_CLK_DMA2_MP 19 +#define IMX8ULP_CLK_DMA2_CH0 20 +#define IMX8ULP_CLK_DMA2_CH1 21 +#define IMX8ULP_CLK_DMA2_CH2 22 +#define IMX8ULP_CLK_DMA2_CH3 23 +#define IMX8ULP_CLK_DMA2_CH4 24 +#define IMX8ULP_CLK_DMA2_CH5 25 +#define IMX8ULP_CLK_DMA2_CH6 26 +#define IMX8ULP_CLK_DMA2_CH7 27 +#define IMX8ULP_CLK_DMA2_CH8 28 +#define IMX8ULP_CLK_DMA2_CH9 29 +#define IMX8ULP_CLK_DMA2_CH10 30 +#define IMX8ULP_CLK_DMA2_CH11 31 +#define IMX8ULP_CLK_DMA2_CH12 32 +#define IMX8ULP_CLK_DMA2_CH13 33 +#define IMX8ULP_CLK_DMA2_CH14 34 +#define IMX8ULP_CLK_DMA2_CH15 35 +#define IMX8ULP_CLK_DMA2_CH16 36 +#define IMX8ULP_CLK_DMA2_CH17 37 +#define IMX8ULP_CLK_DMA2_CH18 38 +#define IMX8ULP_CLK_DMA2_CH19 39 +#define IMX8ULP_CLK_DMA2_CH20 40 +#define IMX8ULP_CLK_DMA2_CH21 41 +#define IMX8ULP_CLK_DMA2_CH22 42 +#define IMX8ULP_CLK_DMA2_CH23 43 +#define IMX8ULP_CLK_DMA2_CH24 44 +#define IMX8ULP_CLK_DMA2_CH25 45 +#define IMX8ULP_CLK_DMA2_CH26 46 +#define IMX8ULP_CLK_DMA2_CH27 47 +#define IMX8ULP_CLK_DMA2_CH28 48 +#define IMX8ULP_CLK_DMA2_CH29 49 +#define IMX8ULP_CLK_DMA2_CH30 50 +#define IMX8ULP_CLK_DMA2_CH31 51 +#define IMX8ULP_CLK_MU2_B 52 +#define IMX8ULP_CLK_MU3_B 53 +#define IMX8ULP_CLK_AVD_SIM 54 +#define IMX8ULP_CLK_DSI_TX_ESC 55 + +#define IMX8ULP_CLK_PCC5_END 56 + +#endif diff --git a/include/dt-bindings/reset/imx8ulp-pcc-reset.h b/include/dt-bindings/reset/imx8ulp-pcc-reset.h new file mode 100644 index 000000000000..e99a4735c3c4 --- /dev/null +++ b/include/dt-bindings/reset/imx8ulp-pcc-reset.h @@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright 2021 NXP + */ + +#ifndef DT_BINDING_PCC_RESET_IMX8ULP_H +#define DT_BINDING_PCC_RESET_IMX8ULP_H + +/* PCC3 */ +#define PCC3_WDOG3_SWRST 0 +#define PCC3_WDOG4_SWRST 1 +#define PCC3_LPIT1_SWRST 2 +#define PCC3_TPM4_SWRST 3 +#define PCC3_TPM5_SWRST 4 +#define PCC3_FLEXIO1_SWRST 5 +#define PCC3_I3C2_SWRST 6 +#define PCC3_LPI2C4_SWRST 7 +#define PCC3_LPI2C5_SWRST 8 +#define PCC3_LPUART4_SWRST 9 +#define PCC3_LPUART5_SWRST 10 +#define PCC3_LPSPI4_SWRST 11 +#define PCC3_LPSPI5_SWRST 12 + +/* PCC4 */ +#define PCC4_FLEXSPI2_SWRST 0 +#define PCC4_TPM6_SWRST 1 +#define PCC4_TPM7_SWRST 2 +#define PCC4_LPI2C6_SWRST 3 +#define PCC4_LPI2C7_SWRST 4 +#define PCC4_LPUART6_SWRST 5 +#define PCC4_LPUART7_SWRST 6 +#define PCC4_SAI4_SWRST 7 +#define PCC4_SAI5_SWRST 8 +#define PCC4_USDHC0_SWRST 9 +#define PCC4_USDHC1_SWRST 10 +#define PCC4_USDHC2_SWRST 11 +#define PCC4_USB0_SWRST 12 +#define PCC4_USB0_PHY_SWRST 13 +#define PCC4_USB1_SWRST 14 +#define PCC4_USB1_PHY_SWRST 15 +#define PCC4_ENET_SWRST 16 + +/* PCC5 */ +#define PCC5_TPM8_SWRST 0 +#define PCC5_SAI6_SWRST 1 +#define PCC5_SAI7_SWRST 2 +#define PCC5_SPDIF_SWRST 3 +#define PCC5_ISI_SWRST 4 +#define PCC5_CSI_REGS_SWRST 5 +#define PCC5_CSI_SWRST 6 +#define PCC5_DSI_SWRST 7 +#define PCC5_WDOG5_SWRST 8 +#define PCC5_EPDC_SWRST 9 +#define PCC5_PXP_SWRST 10 +#define PCC5_GPU2D_SWRST 11 +#define PCC5_GPU3D_SWRST 12 +#define PCC5_DC_NANO_SWRST 13 + +#endif /*DT_BINDING_RESET_IMX8ULP_H */ From patchwork Tue Sep 14 06:52:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 511131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3D2FC433F5 for ; Tue, 14 Sep 2021 06:41:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9D326115C for ; Tue, 14 Sep 2021 06:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232880AbhINGmf (ORCPT ); Tue, 14 Sep 2021 02:42:35 -0400 Received: from mail-eopbgr70088.outbound.protection.outlook.com ([40.107.7.88]:35907 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239015AbhINGmf (ORCPT ); Tue, 14 Sep 2021 02:42:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=He5L2KL6i9oQOBzT5SwqV8vHKq1sZ1AGSLA9KEGUDywehOiZPis0fNO27k+JKbk7i7Pyp7hc2jetqIS/XkDzXT6LT34Jc17QUIQ8f3iidznAeFwaG1H2rOpFWFhBcLi/9eE0hOaCzHZcyAchni/QasS0MjLG+CzzeOobO71vpMXx1fosK4K91vFfy/YYBHKPoV1s4w4ZWA0plmePK4HNJYaRLJs9GAsiIPfV/ohg6JmpLRS6r0sxG36kceZs4GVn+lSUtHmVHrUJVG0rtEM8JFJvmHAYIG0nv95BrqefjbhJM5WZPpPzylcN4Vj0SpcpO3TB0kxH0f6dZCm62cxyPg== 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; bh=E7RyfDFJyAP5SnRXkPEGns3qwGSBHvkYZQHT6JsE6BI=; b=NJynomWrta/Y+522/mkHg2t4XAhd5jKOD8h+leLGeX09M3NP5cXpILDrUmrIk4XTwpdV2yZ1X9CuhNLGXW830RaXo66XaJP3PBmkUOdMkyaJDidrdqNG17xA+o51JLmscd12ZZJjveEWwf4xOkDgUB+wiuKaybgIK1FXYeA0AzFWvH9XiBwhNEm8Mv2eiC0SKRhorU/peOlWLEXkqd9yWrKR1277FUv+L3eYcif94ycfKkteqvg1XHhskJY9IbRVPfn2dV/WvpAx+0LG+azkuLDrzNImOuyNOrbYvNXR+vxmYzLLzzwJGlwbQZ8/wmikylS//qj4q7Rj7l4+Rat8Ww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E7RyfDFJyAP5SnRXkPEGns3qwGSBHvkYZQHT6JsE6BI=; b=f5iUv4oCnDktWnlWxjig+f4i4k8hR+Gtzsh+Ms1MVG4jQqWIXAtHI/6u9x6ydGh/ZfFqvysA+2OjpXqIRGkGv95h3OwvlE7AgL1tePVq8ILRpW/ik/I/QO0neihk6elDWONhX3/sN7nkW3SAbGUxsTfC95tkZ79H18OHIPAyjmg= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DBBPR04MB6028.eurprd04.prod.outlook.com (2603:10a6:10:c1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.17; Tue, 14 Sep 2021 06:41:16 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:16 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 2/9] clk: imx: Update the pllv4 to support imx8ulp Date: Tue, 14 Sep 2021 14:52:01 +0800 Message-Id: <20210914065208.3582128-3-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee7b70e3-72a5-4b62-d09a-08d9774aa6cf X-MS-TrafficTypeDiagnostic: DBBPR04MB6028: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zgcI/ZO+p3sMePKEwUvhxznWb9qkN6mYwhMGwcN6a/09Uxiaqyu3XeYsI0iGDtDE+DcG9KJmsntC+CWCYCWTyt5zhd5VxrdhDC0jVzPKxk7mAw9SZDDGJ2oONvUd/UCdaTabhKs/4ZmNd/gEMLemYaSTIdZQOvzwrcZDjx4t/4lJMWg7RboGxLA7XVBWsNwRG9VQdmkWDNUkckWIaFjoPwylDRRVEqmc8m8F9J3ODNumhGbcctHmpbQ9Wh2LvRxWXgx6o6bYMaDWduB4SIHO5c/dg0d2ayrikorKOBc1pAnT5J91lR4qtwq0i1IUrcSurazrYkCo+v8euwVtUahE3eFRzxz1SpegLxsMsRFkkjOZRc+YENg1AXB4NS/NqjIGV2hFuQiq4EKNnoZak9GSScUSURKjra0MfXQcLi6qth2OYUVESexJ5xqdgaV4BEvzKa0tnfmBGTh6ACbYFq3gmoZlEHpvVRaQSHAqHgmZVgU4NNSD8LUwf6zA4S6+zZmK+xEaamAo8JFfKZrvISU8/mhWFs9XDcdIeY6l1jNhU7vxujzNsKM7aAD5S9MMXkFoNM7MDRlf2Viedihhx361ITZJnDINA5v+BfycuQW+wsmzWsHqjNOyFtW+UyEVRxpdDk0OdM+V33U7ppFzuMGoc9YGMDHqD7CpAE87ofsM02mcSMHXcw6YDWlbgchQC3C04vFUcaqKOApa0wTqrsTvXJ8CQEVTpNxPK4mDfN2CGow= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(346002)(136003)(366004)(376002)(396003)(956004)(6512007)(2906002)(83380400001)(6486002)(2616005)(4326008)(316002)(8676002)(5660300002)(66946007)(66556008)(52116002)(6666004)(66476007)(1076003)(8936002)(38350700002)(6506007)(186003)(478600001)(26005)(86362001)(36756003)(38100700002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DjmNGczA2n1v9iYdZoRzlXhwue6O6R9BDNZbpkh9ocyh+0aCedvAG/eaYeMy+KEyfTg1raTPNpcBCvmYywssnSHbAkW/XA+9n/ngxwyJTzbfjD9nbuKwgkstxcYhZrUMj9bPyO2ms1ADTf3zR7U/ZruPZq67eqYLwPMch53pAhK8htuRopYrCKJ7C8rhX7lzC7w32Ea04pIF6MguYqRRM9NsXgXoTVIjb50eUP1IC2UZySu4HVvWwjbR3mYdvVIAH/Ktl+WnwD79glVAjV2I7Nd/Kvn5d3uN0uOvuRb40tv0DIBCXqRzEarxulfduVKdny3xHMmI2WNidlbrB8irSEuNIUvlb1d2YIS/M82zPYFKwhVGn4UQKzADdy5eNBygYccwp/ed7lvsQ/3QAIuk6DmegaO7iQ+XV8F4hqTILs/tayau+N3ewzDg6Vr+dE2wMhIh6OtnotAfRAeWWi0Tt37ySKeFr9ZRABKWL5cgY6w92wBLILsah0WgA957FBgWsrLeBIhNkPG1tykVbAtANdaLeV/Nq1NQT9lUAFWlJ+GIr1lFtyweebsnxqehiHF1E5T6VpRV0ElGbSlkgOYiHuYecGLlAxHyHj5mVnHFAIPFJ3RMdMCOnHUp6mwF24xIR0p0uGuM0eWQPoOmTs2RlsPvnPX9Tf4HZX5tbQR629FyY3wmxMH4KckfHCiW6dA2Gvl1dsI5eUFiPAXB8Q2V0QfcSWhcCW9p+ChAuyUFCD3dSdLGwW9ppIGjTxpmyDTdOv1bRdrW0IIjuvvxagkA2fOlvd11120LCI/GfsvKfrQ0RXDLb/2FmRqV1cETprlbi02Hl78WNRHThJhMH9GoZZ9BL/A05xyXELg3+/rh+mzrqxN/3lD7nLroZ9zggmaNcQFmqkgpqGNrFVZHOwNsqYewqv0uqMcZB08mXUmwh58TsYmRCt8Kpq+BNrNNfO8Gs5T2X48WPehgzQf1OedxKD5zVG4dgjwFVExhavjjcBNmJVTItTgsaEIA9qpVMd839aynQztppUAdhiZFPSaA7sWsHM6EPojYWlUAs46s+prroYb6DLuDi2I3+V2hwwDOZHGT6FjLzSMCQSiSC9NbLTMaP1+6jpUX06iKBY9FnSWYJTzIrU3doZeZKyVJNHBSudea0hWfn7MzRs2mA2LydyHNPVyPRNmbUCMFgkkER2j45DpQ7A8NPDk36s6uMQJvl3BVdvE1cdxPnNmnPv9qBIF9Og4jL5U4sQDzJSnd5IjBBTdXpz3Vgl/Ci54j/Qc9QG1KVDOjbAN3rEnvniOI9InGnLqohjxZDMpIw7Gcghu+wPmC77q8jy9Jb6wC77TC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ee7b70e3-72a5-4b62-d09a-08d9774aa6cf X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:16.1440 (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: YjwS865iMCRA/oVwZvs2IISiHcHezZU82v6j7QG/m6iaEuKy7IcFHRMluTccv+5uvagWVvnNE5hJr52DnuH1RA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB6028 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The PLLs used on i.MX8ULP is mostly the same as on i.MX7ULP, except the PLL register offset is changed. Change the PLLv4 driver for code reuse on i.MX7ULP and i.MX8ULP. Signed-off-by: Jacky Bai Reviewed-by: Abel Vesa --- v3 changes: no --- drivers/clk/imx/clk-imx7ulp.c | 4 ++-- drivers/clk/imx/clk-pllv4.c | 34 +++++++++++++++++++++++++--------- drivers/clk/imx/clk.h | 9 +++++++-- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/drivers/clk/imx/clk-imx7ulp.c b/drivers/clk/imx/clk-imx7ulp.c index 779e09105da7..ba50d6db8097 100644 --- a/drivers/clk/imx/clk-imx7ulp.c +++ b/drivers/clk/imx/clk-imx7ulp.c @@ -78,8 +78,8 @@ static void __init imx7ulp_clk_scg1_init(struct device_node *np) hws[IMX7ULP_CLK_SPLL_PRE_DIV] = imx_clk_hw_divider_flags("spll_pre_div", "spll_pre_sel", base + 0x608, 8, 3, CLK_SET_RATE_GATE); /* name parent_name base */ - hws[IMX7ULP_CLK_APLL] = imx_clk_hw_pllv4("apll", "apll_pre_div", base + 0x500); - hws[IMX7ULP_CLK_SPLL] = imx_clk_hw_pllv4("spll", "spll_pre_div", base + 0x600); + hws[IMX7ULP_CLK_APLL] = imx_clk_hw_pllv4(IMX_PLLV4_IMX7ULP, "apll", "apll_pre_div", base + 0x500); + hws[IMX7ULP_CLK_SPLL] = imx_clk_hw_pllv4(IMX_PLLV4_IMX7ULP, "spll", "spll_pre_div", base + 0x600); /* APLL PFDs */ hws[IMX7ULP_CLK_APLL_PFD0] = imx_clk_hw_pfdv2("apll_pfd0", "apll", base + 0x50c, 0); diff --git a/drivers/clk/imx/clk-pllv4.c b/drivers/clk/imx/clk-pllv4.c index 8ec703f27417..3c750ccbee25 100644 --- a/drivers/clk/imx/clk-pllv4.c +++ b/drivers/clk/imx/clk-pllv4.c @@ -23,14 +23,17 @@ /* PLL Configuration Register (xPLLCFG) */ #define PLL_CFG_OFFSET 0x08 +#define IMX8ULP_PLL_CFG_OFFSET 0x10 #define BP_PLL_MULT 16 #define BM_PLL_MULT (0x7f << 16) /* PLL Numerator Register (xPLLNUM) */ #define PLL_NUM_OFFSET 0x10 +#define IMX8ULP_PLL_NUM_OFFSET 0x1c /* PLL Denominator Register (xPLLDENOM) */ #define PLL_DENOM_OFFSET 0x14 +#define IMX8ULP_PLL_DENOM_OFFSET 0x18 #define MAX_MFD 0x3fffffff #define DEFAULT_MFD 1000000 @@ -38,6 +41,9 @@ struct clk_pllv4 { struct clk_hw hw; void __iomem *base; + u32 cfg_offset; + u32 num_offset; + u32 denom_offset; }; /* Valid PLL MULT Table */ @@ -72,12 +78,12 @@ static unsigned long clk_pllv4_recalc_rate(struct clk_hw *hw, u32 mult, mfn, mfd; u64 temp64; - mult = readl_relaxed(pll->base + PLL_CFG_OFFSET); + mult = readl_relaxed(pll->base + pll->cfg_offset); mult &= BM_PLL_MULT; mult >>= BP_PLL_MULT; - mfn = readl_relaxed(pll->base + PLL_NUM_OFFSET); - mfd = readl_relaxed(pll->base + PLL_DENOM_OFFSET); + mfn = readl_relaxed(pll->base + pll->num_offset); + mfd = readl_relaxed(pll->base + pll->denom_offset); temp64 = parent_rate; temp64 *= mfn; do_div(temp64, mfd); @@ -165,13 +171,13 @@ static int clk_pllv4_set_rate(struct clk_hw *hw, unsigned long rate, do_div(temp64, parent_rate); mfn = temp64; - val = readl_relaxed(pll->base + PLL_CFG_OFFSET); + val = readl_relaxed(pll->base + pll->cfg_offset); val &= ~BM_PLL_MULT; val |= mult << BP_PLL_MULT; - writel_relaxed(val, pll->base + PLL_CFG_OFFSET); + writel_relaxed(val, pll->base + pll->cfg_offset); - writel_relaxed(mfn, pll->base + PLL_NUM_OFFSET); - writel_relaxed(mfd, pll->base + PLL_DENOM_OFFSET); + writel_relaxed(mfn, pll->base + pll->num_offset); + writel_relaxed(mfd, pll->base + pll->denom_offset); return 0; } @@ -207,8 +213,8 @@ static const struct clk_ops clk_pllv4_ops = { .is_prepared = clk_pllv4_is_prepared, }; -struct clk_hw *imx_clk_hw_pllv4(const char *name, const char *parent_name, - void __iomem *base) +struct clk_hw *imx_clk_hw_pllv4(enum imx_pllv4_type type, const char *name, + const char *parent_name, void __iomem *base) { struct clk_pllv4 *pll; struct clk_hw *hw; @@ -221,6 +227,16 @@ struct clk_hw *imx_clk_hw_pllv4(const char *name, const char *parent_name, pll->base = base; + if (type == IMX_PLLV4_IMX8ULP) { + pll->cfg_offset = IMX8ULP_PLL_CFG_OFFSET; + pll->num_offset = IMX8ULP_PLL_NUM_OFFSET; + pll->denom_offset = IMX8ULP_PLL_DENOM_OFFSET; + } else { + pll->cfg_offset = PLL_CFG_OFFSET; + pll->num_offset = PLL_NUM_OFFSET; + pll->denom_offset = PLL_DENOM_OFFSET; + } + init.name = name; init.ops = &clk_pllv4_ops; init.parent_names = &parent_name; diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h index e144f983fd8c..3f518559b8f9 100644 --- a/drivers/clk/imx/clk.h +++ b/drivers/clk/imx/clk.h @@ -42,6 +42,11 @@ enum imx_pll14xx_type { PLL_1443X, }; +enum imx_pllv4_type { + IMX_PLLV4_IMX7ULP, + IMX_PLLV4_IMX8ULP, +}; + /* NOTE: Rate table should be kept sorted in descending order. */ struct imx_pll14xx_rate_table { unsigned int rate; @@ -191,8 +196,8 @@ struct clk_hw *imx_clk_hw_pllv3(enum imx_pllv3_type type, const char *name, .kdiv = (_k), \ } -struct clk_hw *imx_clk_hw_pllv4(const char *name, const char *parent_name, - void __iomem *base); +struct clk_hw *imx_clk_hw_pllv4(enum imx_pllv4_type type, const char *name, + const char *parent_name, void __iomem *base); struct clk_hw *clk_hw_register_gate2(struct device *dev, const char *name, const char *parent_name, unsigned long flags, From patchwork Tue Sep 14 06:52:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 511130 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABA60C433F5 for ; Tue, 14 Sep 2021 06:41:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 918F361159 for ; Tue, 14 Sep 2021 06:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240127AbhINGmk (ORCPT ); Tue, 14 Sep 2021 02:42:40 -0400 Received: from mail-vi1eur05on2067.outbound.protection.outlook.com ([40.107.21.67]:25056 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S240243AbhINGmj (ORCPT ); Tue, 14 Sep 2021 02:42:39 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UzuP8tmiZZ0xn6wHZHq46fZCaJ2bhmEEdZrLrWvT0XrxzpMBS5hV4CD/9on2UvBnltEb6FHDNEb+JJWXNxaDlyXuACAna1kuFKPRzOd7AsKXilD/s2Kd7nuZu5rqXTrvzFUE74Sqmj594K5tsTPKnUzzPyml5UPMJqlJhMn4Gf6d31Hp4p0gWBnlWBCY9FU97cWX2YZOStZGWUfNR3cc+C08nMRA5SzCBDfX4dAT0f+6wkyqlrHvOEQKzMb88yB3R7SiE0BlHvchS+WPq6prwxGb80sCA4plpgAAg+oPDnGHDtHZ1jbr+e0Jz4GUSRjKrdT7dvGSR2gzDZktGClQaA== 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; bh=KYf+JSNGL40wG181B8oHFyJKZebSuwNVaaU8fUNAvsY=; b=Heynsi1F+rQoJUIv/6WHbAxHMjiNeutiiA1EcXUYBGQfvJ9rIYSEosQA5VRlgk/ggqtpINEW4N3XCN7cNvx6TVAJGgV3dZkPa0gbqHzKIhodG5FKy7OaPddRoK04iehwZKhoNc/4luduqh6/cHHAa81Gea5LBv2q2n0uf9frzOIaHyTNZ+0qFBAKvlcDw2qV4TyoSdL7pFlGvvQVr+JDhu650pBbhDsQY1xUXVa/F3Snc6zpSQqfAGSB3sCMEdIjeMmfOLS6h6OqHRuz8PevMpmVGn+2wQ4OC5W55UWJYPu34fKO8grqqb9XrY2rQfTmrW87hGsVQ455xj4Sne8p9A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KYf+JSNGL40wG181B8oHFyJKZebSuwNVaaU8fUNAvsY=; b=NQYZHOa5f0ZUNTkmPHsH+YJOstyF7WqG0x5rLb1+Gztxt23sZBlJ/BHatGboLHscBi6UOC+FINmcA+BgOSh4nT6ikT4nOrzdsIbL28KGrtvrnql9/8uJiOSUhQV6I7Obe5WJdvwmpYr7L6a2D+gFsmwtgRTILuv+6ZJc9KZ9RK4= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DB7PR04MB4763.eurprd04.prod.outlook.com (2603:10a6:10:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Tue, 14 Sep 2021 06:41:20 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:20 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 3/9] clk: imx: Update the compsite driver to support imx8ulp Date: Tue, 14 Sep 2021 14:52:02 +0800 Message-Id: <20210914065208.3582128-4-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 600b264d-8374-48d1-63d7-08d9774aa91f X-MS-TrafficTypeDiagnostic: DB7PR04MB4763: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7/7nW4pDu6s3+d2bF0+9oR4VOpHMl3fhxSALH7qN5UIlcesH8fnGPBNxtH07Q3F2ewWfwZPB4F4UGnsXJh217eWJjLGW2Tsp6mdLCVQK3lC9xpldTQDg1OC5h+G3tjAEY8REK2L865MVBySCe/Tj8FBRMThjU17Jh7lvK/VuoJCWvhffAYEDBCVFXySJPthmt4yCAyUMuYYogVBpdQ2oWNmhwo7+uCAM0XazzP5WF5oj2SgLQJRRBmqSMTZCVhix/yJpWZawdf5VbhYkB4ijPdn/2l8TISi81FuRZeXxGW6CrAWLlr3OXoFRx5a92ypxp7ANwu6mWmKaPOocEqjifPxvxg4a3v00ZIQnIS8d6MCooXvZcG05u8TQ79m2GWMwzG/G1vEkWyA6sinUxoLB+cGV08UJDluYMQJySDup4kOP26C2pMY3mcwWum9N24Uvfnsmj8AulHVqv4jMbaP9PphSc64uYWQxCTvGUVdtVpNor3DuXW96jb8U3RF2v7vMslWmQG6z9TbrfxmT4wyGGaVY3+wdawsQLyC+bkD54rRh8Y1DB6v9Ru9GYhUmr8EghvqCs8SsqHYUn3uy/51ybMnYGpP16f25DGJEVJQLZcumV9S8uzbdya4Mwdvj3ClDKBHs0Ay7nsEgHyOkFJKUa4+E6O5enwhFPe4QfysF1YPLxn6bqoNZPp/Q3UoFJTROOnTmXWuQvxA6JsaQPnY53MqUWJyyFCy5Zn/YgByxnQ0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(136003)(396003)(39850400004)(5660300002)(6486002)(15650500001)(66476007)(36756003)(83380400001)(66556008)(86362001)(2906002)(316002)(66946007)(1076003)(8676002)(478600001)(8936002)(2616005)(52116002)(956004)(4326008)(26005)(6506007)(6666004)(6512007)(38350700002)(186003)(38100700002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EVnpNxbznZYgkyy3kK9HLS0Wbm4ixiBsloR+ymIJwOrWvYQvd1ZFbeQCKqdqbEHwSTKYp1Oo+OvfienVXry0Lr68EYRwwudCVe+YgRR/8xro/AJL4fwDqxMC9PSmE+bsJWAcUG8PwU8dCwP4TrQRKFeKag1Aym8PIYxeGnjCipMxXFCAJ9Kr5wblHHNi0U4V1LyBVI3Bgf5ViBhhA+rUMDnKPLFYrLGAEvynMCRfypRbKn+dsSqYkputU+7xLiMA5/F7/6O4t348nUDeM3tQLKcAt/DGXLonTSZS74y6HunOhTotDB0ytO5agKJL3w020cLIMdwZFX7eh0Xw6yDVjiRttmH3u/11xmH/il2S8Xwddd9Q2aO2JclJnXRTMLQTZWSlKTBysv7iOeafog3ZnAKeNJiMpdkLAPsOhjJnfADTNPcbgootB61NTUcMUkyz8gur0XB0KbZPOPxKgFnrsDVne90Obqc2W/zRXMuWr4G9puqW+wvw2JS823v9aZetIvv1jcm6WT6Hva2jiOeONeXkeGBPsGeDtM3qhj8YvQrvOE5BuEXODQQ8SyKUdOLGw9FwlMNTiKwBbKsf3pz7Fl2+WHcoEbu8hnbHQ4Rx+Nup2/H9zjDW7t9OkhmPLGFr09MF3OG1Q+NY9By6a1NHCvMwqOKu4cJdl4ijQMoHsx65LAme+bTnf20yeTDtZIcJLXSWjX2ZvBpAK+MA+A+3+ybIlU7m7qyqmRMn1zplfkaF+SOzG3zBTfoq0FTt0Mhg028qDEeQTowvH9190eiadgGn8M3IwNw2lHkIcDTbl2Jlmf6g3mlNSSFSOsLN7q/+Uht8Ah9/7bA88uhqhwpNw4YloEqIWtxIbd5oonG87mEOi8JAIVEoH7NyttZPv2b2GqEe2ORGWTPwY7/hQcUU+890m01XkHioY7gZ3nNlcXYQ2qApfATrN5VEhEPUF1poAo5Adib4OvmxyoZ/P5Y+g13dyfOo+e8P80Bg+Rs4KiEm1k+5nQfT54A8WKbxvQ1FSxsxH8nIwMu7JX0Cnc4b5thupQfhSHeN9hgcO3SrVNPEBiLSpPjjndEq+JCojaZGRrKnln2hxn726vVwDz6gX95vnaUzJK+Ncc+fMlzF3O5XoBkma1MSt8llOH7KAUt1J0e7AmSzyLBkfAvsz1jCgzDwE7c+8+O/uzXJgVXfdJUidBQ2xU3sjuDOmD3A7sSyG/SFDNujgMTnNt3MfmUP0Sc0lRd+5mno6uBYo/9Pr3ZNFDoJwl2bt4v8EptpYB5HRd4+rIpLzz7yqTdpm5/Uf9IzF507UFwYDp4P9uhC+oploqENXhrOtxJCvDUmFfMj X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 600b264d-8374-48d1-63d7-08d9774aa91f X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:20.0060 (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: xpGAByQvONAI4qIgigczelQUu9s4659iGBWKV9PbBmuoslokwlNIjLuXCfNG0vS1SOF8SN9akyazZ7du647iZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On i.MX8ULP, some peripherals have a sw_rst control resides in the per device PCC clock control register, all others are same as i.MX7ULP, so update the 7ulp clock composite driver to support i.MX8ULP to maxmimize the code reuse. Signed-off-by: Peng Fan Signed-off-by: Jacky Bai --- v3 changs: no --- drivers/clk/imx/clk-composite-7ulp.c | 61 ++++++++++++++++++++++++++-- drivers/clk/imx/clk.h | 6 +++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c index d85ba78abbb1..50ed383320bf 100644 --- a/drivers/clk/imx/clk-composite-7ulp.c +++ b/drivers/clk/imx/clk-composite-7ulp.c @@ -23,11 +23,50 @@ #define PCG_PCD_WIDTH 3 #define PCG_PCD_MASK 0x7 -struct clk_hw *imx7ulp_clk_hw_composite(const char *name, +#define SW_RST BIT(28) + +static int pcc_gate_enable(struct clk_hw *hw) +{ + struct clk_gate *gate = to_clk_gate(hw); + u32 val; + int ret; + + ret = clk_gate_ops.enable(hw); + if (ret) + return ret; + + /* + * release the sw reset for peripherals associated with + * with this pcc clock. + */ + val = readl(gate->reg); + val |= SW_RST; + writel(val, gate->reg); + + return 0; +} + +static void pcc_gate_disable(struct clk_hw *hw) +{ + clk_gate_ops.disable(hw); +} + +static int pcc_gate_is_enabled(struct clk_hw *hw) +{ + return clk_gate_ops.is_enabled(hw); +} + +static const struct clk_ops pcc_gate_ops = { + .enable = pcc_gate_enable, + .disable = pcc_gate_disable, + .is_enabled = pcc_gate_is_enabled, +}; + +static struct clk_hw *imx_ulp_clk_hw_composite(const char *name, const char * const *parent_names, int num_parents, bool mux_present, bool rate_present, bool gate_present, - void __iomem *reg) + void __iomem *reg, bool has_swrst) { struct clk_hw *mux_hw = NULL, *fd_hw = NULL, *gate_hw = NULL; struct clk_fractional_divider *fd = NULL; @@ -77,7 +116,7 @@ struct clk_hw *imx7ulp_clk_hw_composite(const char *name, hw = clk_hw_register_composite(NULL, name, parent_names, num_parents, mux_hw, &clk_mux_ops, fd_hw, &clk_fractional_divider_ops, gate_hw, - &clk_gate_ops, CLK_SET_RATE_GATE | + has_swrst ? &pcc_gate_ops : &clk_gate_ops, CLK_SET_RATE_GATE | CLK_SET_PARENT_GATE); if (IS_ERR(hw)) { kfree(mux); @@ -87,3 +126,19 @@ struct clk_hw *imx7ulp_clk_hw_composite(const char *name, return hw; } + +struct clk_hw *imx7ulp_clk_hw_composite(const char *name, const char * const *parent_names, + int num_parents, bool mux_present, bool rate_present, + bool gate_present, void __iomem *reg) +{ + return imx_ulp_clk_hw_composite(name, parent_names, num_parents, mux_present, rate_present, + gate_present, reg, false); +} + +struct clk_hw *imx8ulp_clk_hw_composite(const char *name, const char * const *parent_names, + int num_parents, bool mux_present, bool rate_present, + bool gate_present, void __iomem *reg, bool has_swrst) +{ + return imx_ulp_clk_hw_composite(name, parent_names, num_parents, mux_present, rate_present, + gate_present, reg, has_swrst); +} diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h index 3f518559b8f9..a9bcfee7a75b 100644 --- a/drivers/clk/imx/clk.h +++ b/drivers/clk/imx/clk.h @@ -237,6 +237,12 @@ struct clk_hw *imx7ulp_clk_hw_composite(const char *name, bool rate_present, bool gate_present, void __iomem *reg); +struct clk_hw *imx8ulp_clk_hw_composite(const char *name, + const char * const *parent_names, + int num_parents, bool mux_present, + bool rate_present, bool gate_present, + void __iomem *reg, bool has_swrst); + struct clk_hw *imx_clk_hw_fixup_divider(const char *name, const char *parent, void __iomem *reg, u8 shift, u8 width, void (*fixup)(u32 *val)); From patchwork Tue Sep 14 06:52:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 512496 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EC9CC433F5 for ; Tue, 14 Sep 2021 06:41:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A79B61164 for ; Tue, 14 Sep 2021 06:41:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240056AbhINGmn (ORCPT ); Tue, 14 Sep 2021 02:42:43 -0400 Received: from mail-am6eur05on2046.outbound.protection.outlook.com ([40.107.22.46]:29281 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239015AbhINGmm (ORCPT ); Tue, 14 Sep 2021 02:42:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OdW4CShRq5O3WNh4RI81Z8VMohKgKgWcevEE7W9d0k1yoZ0dVmHtnk/jzV6BtvJCZZw/bwp5K/ALf4X7b6cjQgRcqYkSHe387ihAOZalrReRCoBrttOifbwuS4AP5wVVgLO418ufvQxGRbvo5UG7LuLKriKhutBtQY9shS0rAj7c78ES9MfqA2V6yrXShDv7LY6EDtF6ImUhASxxHEA5lVT9jHSuJWMaFnjB1ZyWihQiHCwYDcDAr8Z0X98Bu4+8UNH6q3rH6yO3UVBjX2DeM4dO+sfpFZ6k7269HP36Sb7Z5oCrtyA1qPz+poh4Mo5Pn2umUB2NXB8Ld72jwbC+Jw== 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; bh=G+Q/Jyb0SIol5Cqm8djA7WjQq+KjCnzki+T982I2ID0=; b=cagTbvALJ/M4yVYpRUD+aqxw2TsGBVg69WkH0HRiy79V0b+0QJ9jboEdiPzbg/ki09LIxzlklc0ZWQlaB4WNISpqm0lUgcyN9pp9ICwrHymQKUhwoVSM9COy6bz0wafj7vxYn0jXjIeseptk/5CP/uYxG21YVG47smIWiGJpuYJyyciwSl746VoGHpsqJBaaP9tAoWJFBd37GtYq69cBto3xignZgUclmLcNJvOsRRbbpkAuaRQrKHh6m6QtA3sSGiDJ5Da3RdTAiRcWNXml99WfR6YDEaTagU8bewKG5ntkfYbI0mh5SJi1396WFR6ePU2Ru5dBTPlVMSKlaL9fuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G+Q/Jyb0SIol5Cqm8djA7WjQq+KjCnzki+T982I2ID0=; b=hbi6u1Usc0g6WKm50kIUws+CqQBtMSqGMU7ZAaBNoHaUtg4TtIGQespHavwmgtkn1TcYoXwmRqpRnX3fEJY4Y0TPt8yrCYzCudPBu05ebl2mlMfBAbKAf4pTM4oB8KKSJzKc4amAy1SiGF0ao4u6w3IeF5bSAdSrTwUZrk24MzI= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DB7PR04MB4763.eurprd04.prod.outlook.com (2603:10a6:10:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Tue, 14 Sep 2021 06:41:24 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:24 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 4/9] clk: imx: disable i.mx7ulp composite clock during initialization Date: Tue, 14 Sep 2021 14:52:03 +0800 Message-Id: <20210914065208.3582128-5-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b2c6eaaa-7248-4faa-c805-08d9774aab9b X-MS-TrafficTypeDiagnostic: DB7PR04MB4763: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qvQ4ZrZSX5SiPQ67Fu68flV0BtiD8pKyDnUO3L9i2RcQADdwHck0v1fqcsDgQVkrEa0IwfCeXsGu/EREnVMfcaTGbFRzmSj/7LtU+62WtqdZpJr+JeY4JMuy/9F3pfkk2WSnMiSI9OuDV7HprhQWUnUT9kcZie3Od7WMBgnuJEeQz17DLjOwC2tIE4+3ODMvO0LZjZKJByp4xvpypirwSIzOIOc98dIzxWEEn6qZ37rqrGHJc6xFEhmdXch/o5kU/Qv7GBmv6AR55B+iMhLiRnoRiQWwnT6AJ1rNd1obwLdsdobTQclZ1pAjf77lAenhROSS+WWzBUuFtgZ4x1/HDHQgWQ4ISMqS+QCnj4byokCrPXwi9eUs5wTnu3u9weSTnAvQ2k/ugd/sbW37a7wLhLMvPip+EI3/jEMU+I/jQOhFH35G0OzK3qWRIYkohfNOi2RepCz9JF7f/ZfFQ+RQvFXQ/cIK9D5MQYWSpU9SMVziBBylA6oJhO0rIuCzoz7i7/R30BChqw+fe8ub69S4i8sm7/lngahMrhXu+7wdnLQ2W3rZxXMDTOV4FCFTq4RXyuWshjvdQt1mdTolTvUXosQ48/2Uq786toUslaC2HXcrSzH2WSd87uNgwtf6zEOoqRxVNXfSDIEFJAEzUjeOwdZmNxHNCvRd1XJHUAJ7MF24oHIO97+Dzq00xJhndts+EQoJ9100h/1Oa8PaLZNBQw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(136003)(396003)(39850400004)(5660300002)(6486002)(66476007)(36756003)(83380400001)(66556008)(86362001)(2906002)(316002)(66946007)(1076003)(8676002)(478600001)(8936002)(2616005)(52116002)(956004)(4326008)(26005)(6506007)(6666004)(6512007)(38350700002)(186003)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: n+j/V+dxXd5y61BiuOye0wIAZDlqPA+HUO6cuH1sxPyAOdmYDrtgqpuB3fJRJ60dcFZ9aXKGfcIoEtnlnHxmRhb/IyVu8KKXRsxYYFw8RfnNP2JkE4FaGAuUCg12rt8F1hNkShFMrLuQ6Okxu9EmMPwRD9wVCyqEKHO2t9d5W1+yCHv4T5uo32BmG1ApCtZlyy23Y2Rp5QfuCQw4hDHrAaQ0iVNUq8D/l8bYWW51tynYX6CpbRXIaNP6SWezskQOGlTbkZT7C3m9FfiWNE//cCADu2RdsiSFhZnJOqH/Cp4AdkWYgzXAizhMIZtOTbR77dR1fDWuU2bowXwZR7ir26aobzrcNVvC4FjF7BpKWzbMf3yaPOECYkW34EqLGMjuVd7V2xnaW3HpEwdJ8ZWFGEzE2PKjCrDxZZ+uY2P6s8jOTF6E9OGxJl9vY9KSh0di10JymlsMX7M20ZB4oqf/jafWlwB81kX2JuXBSKoHcbgMCE6sU5WJ2tL5kdX8r/erDfvvKgIvUhfrtXUcqZNOKxDV6GVHTaVk9WIjMegS1ajshr4UlG1lfynWrgkso4do6uqOWuErZh8EecF99C2C8KcdWvoJKfAiA058o+ueVjyDnA4q1carA7vsyN6Bvgr/y45+klM1mTKpQTInlC+Pn3rsZfb3foHxoe+pbvicMBEqzdQxwFKnkQjgYIer2hzbFfsh7z0Ali690ZTYHdsKRUdY9IzD2lCD621UJD+ikRirXQNTJFp6eHQkfcVlDhM8FlHBXxQgdtv1TEwwzaoxL5NMn5vGu7L2BwPh1nxZW4/H9AuVQGaidLrHtQw7hcYm3ofFyECej9Sb3BQFM9duts+Juz3XpEDXp2Fw5MvRtxrT0Xu+wYvYtO2N9NAspMIE6AkkB9/9h4W9r1RzLswIF3dMZPEnSgU/QBCmQ5JiSoCVEmKbloyTHLkQCxhgdbVjpQM4n447X4UijiTuYruN09Ago+0qlhNTkAZoKDuKqtB2Fv/3ZXFJAyMSJ+hNRacsxMlEnlsfeAiuSyw58DUwC/rcLtYEOYbLfCUVrvld7O8g/cjoBhbPrWp+HzU8o/KQICb7CJ3HD5dOZkhjOFgl3Niv+mYzjlQtIGJYSMwGChkK0f6xWeHzqEhKMoMC439hBuQ61RHy1v5JJTQijQvIT3etAhfcI+vcFWuNmwHBUuYQO7bQvNN5CYcnNSTxgFDMo8gHojIrACs/fkFYBpUDvmDQYPzgGR1F9M1H2EUAs8ENbdDcga53/Q8Lcftrj4pejnkcKtSBMf+y5qW1UpHW4KpKH3R8iqVGVVUkD0GLeGvKbkAVLfZ3hSpgCLBbNaqk X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b2c6eaaa-7248-4faa-c805-08d9774aab9b X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:24.2025 (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: Mzlhi9JKASSUMIGGSONgcEJ0JfS9Hh+VMU0zKj6MP6XrW0LVeaUoMbqbzhC1GfaUpcJdRU2LCrRc89aDtBpypQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Anson Huang i.MX7ULP peripheral clock ONLY allow parent/rate to be changed with clock gated, however, during clock tree initialization, the peripheral clock could be enabled by bootloader, but the prepare count in clock tree is still zero, so clock core driver will allow parent/rate changed even with CLK_SET_RATE_GATE/CLK_SET_PARENT_GATE set, but the change will fail due to HW NOT allow parent/rate change with clock enabled. It will cause clock HW status mismatch with clock tree info and lead to function issue. Below is an example: usdhc0's pcc clock value is 0xC5000000 during kernel boot up, it means usdhc0 clock is enabled, its parent is APLL_PFD1. In DT file, the usdhc0 clock settings are as below: assigned-clocks = <&pcc2 IMX7ULP_CLK_USDHC0>; assigned-clock-parents = <&scg1 IMX7ULP_CLK_NIC1_DIV>; when kernel boot up, the clock tree info is as below, but the usdhc0 PCC register is still 0xC5000000, which means its parent is still from APLL_PFD1, which is incorrect and cause usdhc0 NOT work. nic1_clk 2 2 0 176000000 0 0 50000 usdhc0 0 0 0 176000000 0 0 50000 After making sure the peripheral clock is disabled during clock tree initialization, the usdhc0 is working, and this change is necessary for all i.MX7ULP peripheral clocks. Signed-off-by: Anson Huang --- v3 changes: no --- drivers/clk/imx/clk-composite-7ulp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c index 50ed383320bf..92908ee4509d 100644 --- a/drivers/clk/imx/clk-composite-7ulp.c +++ b/drivers/clk/imx/clk-composite-7ulp.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "../clk-fractional-divider.h" @@ -73,6 +74,7 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name, struct clk_gate *gate = NULL; struct clk_mux *mux = NULL; struct clk_hw *hw; + u32 val; if (mux_present) { mux = kzalloc(sizeof(*mux), GFP_KERNEL); @@ -111,6 +113,18 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name, gate_hw = &gate->hw; gate->reg = reg; gate->bit_idx = PCG_CGC_SHIFT; + /* + * make sure clock is gated during clock tree initialization, + * the HW ONLY allow clock parent/rate changed with clock gated, + * during clock tree initialization, clocks could be enabled + * by bootloader, so the HW status will mismatch with clock tree + * prepare count, then clock core driver will allow parent/rate + * change since the prepare count is zero, but HW actually + * prevent the parent/rate change due to the clock is enabled. + */ + val = readl_relaxed(reg); + val &= ~(1 << PCG_CGC_SHIFT); + writel_relaxed(val, reg); } hw = clk_hw_register_composite(NULL, name, parent_names, num_parents, From patchwork Tue Sep 14 06:52:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 511129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ED90C433F5 for ; Tue, 14 Sep 2021 06:41:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0564861157 for ; Tue, 14 Sep 2021 06:41:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240150AbhINGmr (ORCPT ); Tue, 14 Sep 2021 02:42:47 -0400 Received: from mail-am6eur05on2046.outbound.protection.outlook.com ([40.107.22.46]:4192 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239015AbhINGmq (ORCPT ); Tue, 14 Sep 2021 02:42:46 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mbJNWecYl3HjToLhbdnKWFYomdpVNGkCrWncv2a92LVbx0jQLVUwLo3qznvUve3pgAF0SrPLLvGK4KTydu9crs6LmVCYmxY3MdxgokYQtHjZPMFGNMhfCbkf9aJOAxTp1jQtkTrMEGIVBdDLidk/7vr9fNo/OSY1hEWWvaeQuApyOMGGHqhJ5F24kicdkGqtRIy1vCGdXIQ0mzaCBjIHS2p+tSfR+MFXMq41EBYo71gb8asiGD7NZLn2/eG91x6isBeb8qEv00QIsExHyBiwvcZregYeHk0Hxem9i9XWSuegc4hSKFFe+Df4Idzl5lqFTSv6Obj9dLwETVeHvLC6Rg== 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; bh=f7PTQbNswaC+CFwntSoo2JGfvOVHFErzZTAoq3zKOqA=; b=AuVX0YG4/EqEc1BZYECgYSNiaMMeJpqae5naB6UjS6lBjRSXgixjCxWxE6KZdAg41L0MD3Fyd+yssdDnosMe17F9FfBroLYGVlUvp3uQyBmMJZmHIuZ2LCyj0UGakVAkE3Bu09t2OOLhlFZ0BoGJJi4UUWtLR050qX94VBxX3JZGV0DFNvdfZHqCHxY3uKAlKp8Jbfm2z2IYJFoKygGvf1Bjqanik5qgKqrr5A89QAaGYt4fMccSlHjBMYR12sX6ForeuIecczDgxj4Arg2H90g5C1yXMeejv+GV95T5EEhBuBAzWvQAW9mPLbFxtSiZ9Zx3jWFjOVYavTfJMLeHHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f7PTQbNswaC+CFwntSoo2JGfvOVHFErzZTAoq3zKOqA=; b=GFTuZFhDaLWFn7XxeVIXLhQIwFyhw08UZSIzkwDCxaQ+vYD9e8rhOOeSS+nm6+nn3O1l7RfhrMvRjxFwNPWW1vGGxm21l2n7ILLtpgLxwunkqOXvpAdkuu+Cn0rF298xXTiu7V45CRMj8i85Olzjlg/t7iYLL6nIN4W4VOqq3S4= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DB7PR04MB4763.eurprd04.prod.outlook.com (2603:10a6:10:1c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Tue, 14 Sep 2021 06:41:28 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:28 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 5/9] clk: imx: Add 'CLK_SET_RATE_NO_REPARENT' for composite-7ulp Date: Tue, 14 Sep 2021 14:52:04 +0800 Message-Id: <20210914065208.3582128-6-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73814e7e-80b4-493a-81b4-08d9774aaddf X-MS-TrafficTypeDiagnostic: DB7PR04MB4763: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TCKRkU4/RdQYEhF7zQpPAWZ9w7pDaMWXz5LxXYk9seGLYyMc1J/zVUGLh4xj9bEMxsGr7kF4DwiZ7Nu+tKyleMJewNj0cwce0DyylZTfISBksONgIpOVjDveySrl4ujRhqQPUY3fmLkd3O4nT3xnSG5N51GYhZNs23CmFiOtvgfIZCHC07gQFqDxXy3/5Sh7xV+uSVW4Z0I3akzdcwtZVXiGtnQOPwby3GnI/im84USpHKhyHxrhvypbFDoqmuCNEtY01WLODsKUkTWOlq/wJZoyEX7XDl20UiEAxVtMG57gNqBuHjxqtoUJf2J+bzH5FDP1Y0RymAyrE41h6GKpIYNs9HWsWgv/fXAisdq5FQ6f2X7CVhr+ELA+7rXa+aggPWyQygTRh3MjKB7QnTzGXzSBskdxwnftc/h19HvHjKfRfCBWFvY/SuAxwQlhrScZifoX6V40Df/q1QIuxFrgq0S7aU01SFIzYPEVNAsle4lqxipb/Had2aYobH9XbHX8LwBRTPWnXsaeeg3kJWvnDnFfMuadHhreTUiwixAX6B5kzh1y8KIJR2GL39YHa6TCbaHe064gX8bz3fqa3gjz+8K65Ad8ZmAMeIRWiI9+xhGrIzL+yKyTmsIVdbj0sbUYTNooVBoN8O/Z4gBjQzuVbc6bZxNEg63VVvFSRQwc8vJ9mg/hcWyYwcC4xeDG4S1vmC/tGGpTUvPSR16wJhHE1Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(346002)(376002)(136003)(396003)(39850400004)(5660300002)(6486002)(66476007)(36756003)(83380400001)(66556008)(86362001)(2906002)(316002)(66946007)(1076003)(8676002)(478600001)(8936002)(2616005)(52116002)(956004)(4326008)(26005)(6506007)(6666004)(6512007)(38350700002)(186003)(38100700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4FxGrMXaqZciTEqflidOuQ6m77FVRSzssjC5IyTSbcRXyOnlqUrwqkEYKezglsYEsyElMCu9AOYGRb1rfyuGRO5a/UonUvCO7CZu9fmqaQzCRqXN3bcF8nqE3ojDmxuk51LZpsxLXP/gLnsexZzSLVmH8RN/00hqnlvrMlL6hlmTDf9kvddCsru6aVZRCd9i299AtqirUpeK9BTgUS9xyv+nVnsl95eZ5u16Kn7QVcBmVgheU7V1D6ynD1gXdjrh+c5Ljen+Hu7g3IXDtO+vChE/2a7qYQkBLPCMcpFEl4zZ3kSme20OiW/ZAuhu0bkd/2gLVAhjJ7bjD8pP5/wUoL3nAPvuRipb2X2zrQ01MogUXPn8MRtzzyxgcGE8kvD6aXLLJ5BpT6c1hi/zmkkBUPCZzfUxop4LUub6382XsIolhooc1ubSgefSlNlCTym0+dRS1RZyqOWI23XPqWBzMDIwWM2sqst0HrCs84RcREztKUTkEmYW/KN9ka0vqHksJNoFf7HKGEiJJGAKuyPPR5ZI6NsnxCbNfIZqZXbp9pk4tz+2SxpOeNbQh7iuYUmrfZ1qp4s7NziPprGP/xkMFe1sVR8T0DkwvmpUd8h50ZLWqZppV/ixG4MkREWj6VOOKolHMSF7TvTALz49Xxi+GvBz5Kvzv6gMiMCpPnH/4tfibVp6SoGSn6EZsJwhFRr7DLomRRn1GKzZzdndQv2DGaVHT8v7XDpto8rlXIHPPKe4dpNSyfq08TqHt3drmql9nvuSHZ6jai9pFceuHcx72AwwwhNY0Z6LCMQZqaKodXV7O6V4ARZZ4eczvvUMk4Es6c3Fo3W1KyudOHt+0kL1PJDSvwhrHnaAmMJWl2YLoLgRT7sfLB6isvHvQU+9hKVOCbFMTOiO2pqmAeVtwVhmnejLSzh92/+dgZQwLrCjARht0RC6ctgHYROLGJHmMvyzOwyHZa3VZANW9GIrdjbPjj2WPCPZUVKUXgJresSUK8tB39snADdE19UDt8zC9cihPQywudtGWXmSZQ2D9GQkL07J7ovRkWh/7NYswhfm4xFHYSsZaAHCJZDhpxLmVjES1wGLKidhRAHp7TfnNdI3v/V7HeE2h/SBN/wnkDM1nRhE3LFiwwv+ESJ6lmKBvxeWePFhh0NId4v7NqsG05vy54uq4yhLOEO9rA38ccKN6xVM4ZpWh3W3Mke7j1MWC9XfOks/8+LKLET6Af+ZhSqYJLutaGowHBbcDNWqKYikT6bTXkax07VikLomiGi289ujGCjQ1M0x408JENRk32/Poqu0Hx8oOtT5Me6AbpaZ4Gl31bLPltFDsDOwvWi7pp+1 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73814e7e-80b4-493a-81b4-08d9774aaddf X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:28.1143 (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: U0wKG3qs42rYjaj+K137mRKuQrMA8EksV7UV33MFMjpalOL6b/kiyqbPP5d1Lg1toccOMAvxId0xIBGSK3Hl6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR04MB4763 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org For the imx_composite-7ulp clock type, The clock parent should be changed explicitly by end user of this clock, if the the 'CLK_SET_RATE_NO_REPARENT' flag is not set, when user want to set a clock frequency that can NOT get from HW accurately, then the clock's parent will be switch to another clock parent sometimes. This is NOT what we expected and introduced some additional debug effort, so add the 'CLK_SET_RATE_NO_REPARENT' to avoid such unexpected result. Signed-off-by: Jacky Bai --- v3 changs: no --- drivers/clk/imx/clk-composite-7ulp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c index 92908ee4509d..9ce8c630ee32 100644 --- a/drivers/clk/imx/clk-composite-7ulp.c +++ b/drivers/clk/imx/clk-composite-7ulp.c @@ -131,7 +131,7 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name, mux_hw, &clk_mux_ops, fd_hw, &clk_fractional_divider_ops, gate_hw, has_swrst ? &pcc_gate_ops : &clk_gate_ops, CLK_SET_RATE_GATE | - CLK_SET_PARENT_GATE); + CLK_SET_PARENT_GATE | CLK_SET_RATE_NO_REPARENT); if (IS_ERR(hw)) { kfree(mux); kfree(fd); From patchwork Tue Sep 14 06:52:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 512495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0AC6C433F5 for ; Tue, 14 Sep 2021 06:41:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE0486115C for ; Tue, 14 Sep 2021 06:41:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240231AbhINGmw (ORCPT ); Tue, 14 Sep 2021 02:42:52 -0400 Received: from mail-eopbgr150043.outbound.protection.outlook.com ([40.107.15.43]:7852 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239015AbhINGmw (ORCPT ); Tue, 14 Sep 2021 02:42:52 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aHkecP4I1qc1UOop0jX/lPsyN31FmPRWBwtTx+wjzpqiVWbh6lOAFTGtyXbD6Ij0aS1n0EDXUI1hTA/glGzbumcB/iNevuRGNseNWVijeNm5NbohEcJOPrb+wx/Uc5l17ZGoEkLmwLZCln7pC5YYWDTgN5XTCRhDRh4x1F6SeAe8qsy+QyU90d4Ks96WjTS9zWEYqOhMehqE4VhObWxV4gccUI+SSxlLwDktheK1qSeJ6Olc61HkCH7dnWv0LyYNCDsHFkAb8bUdvMQ5m/uiezwa38PnPZ46pD442WMueRcnDPGNGXjsRnnyAbS3KbOVLGnm8SD4wQLEl9WxuvPuwA== 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; bh=cG9LAcGsHjNniSdoEZRNSQgTxojO2fN1yi2JQuSdTZ8=; b=Ff65blJ0leR6dsJ1q9isR5RXEumM2YBlhDQqU8XOiLJqcwD68NnkOBgWIqOp6DBaIQDdoYjf7+uDgGIv0gVUwfWcAZm10YyHdTi5iRPgEDD8kyubMLXWc2ah31QZpO1ARBfHsW1pay01cBClAE1nGxmm01TJysZzop7st65kvGaMZVwGVZno8SWbz8f9HILvQICl84K5F6RAMqm1bjCWRCVLSNb5kbcTWQprE66mtj2A8PfUwaWQGtkjJjuK3bu8R4Gy56TbvU+6xnJVx5NSbTisNbNwerjiPQEM7RD6DusOXcx1bvzj60VghlriVADCL3um4ICAZ0qSgSPggzykPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cG9LAcGsHjNniSdoEZRNSQgTxojO2fN1yi2JQuSdTZ8=; b=OBfd2bH4thP+6sSIfPyo2Fr5yDC/g+XihDuI1IKyFEfDxMLTr74dKauVvwGUYqNobKLhQtcYZ9rEZ0gFBGhBqc2oKzTK0W9q3ozDn07WZlgE2S0zLsYgMpiGhw+LvFq0/EGBY95XTJaSSgV/04/XBl9KWszLDAGN5BN4tCG7esE= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DB6PR04MB3013.eurprd04.prod.outlook.com (2603:10a6:6:4::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Tue, 14 Sep 2021 06:41:32 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:32 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 6/9] clk: imx: disable the pfd when set pfdv2 clock rate Date: Tue, 14 Sep 2021 14:52:05 +0800 Message-Id: <20210914065208.3582128-7-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b951c8a4-3fa5-4ff7-779f-08d9774ab059 X-MS-TrafficTypeDiagnostic: DB6PR04MB3013: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sArz2xaWYPHOu9EXUFUey7B4kOD3FB2y4ePSmHu31CjJAAwP7k1MTM0p8omLbFKbt3rE2e2II2TgiWn7TcExdms9EogEvAS+/Ypa9A6D35ZdbtNy81S9VJLLavqrfm5Dv+sbQJYHmd3vPWG1UcrEeJIcIRV1V3SOONxF8lDeq8hsVIhZwhP/36DX9Uf9goaurndVoebG2pgV1VZKvg6l0h//7+lNdmuyTLXYPZdrh7FjJMA9XGBLIB5CRTMFDimpysPyrYug3cAsHdRbM9CG1qCsUt6in4LpUK+bF4nfleLYoQqpj4XHy9E8tthMdab3DX3JqJQvMRHMaddO4BHXMr+aIU1QZsyxGlbv1ShYLbG/23Eqg8Bewgkz21fzcZ95Lmo5F5JVIhDxqmOQbc66nyohxVeZ3SfbIPr7Y2BffzIEWbBnqpVODJTf26JynvmWBTMP22TS4u6rwgS7PidlDydisk+ynOIO0oXXqdGAcPuFnDScGrSQlcDZb9zUiR/L1X9NYWeKzlMteUr8/OMa1ta/SXyhhz79L8oHr1aXuxFYpH4T1yhoAo8Wrg7UxqgPryaSFC4A5XYcmrRyBxxfaa5NQ9ifx9SHLLXjtxZuOgWxn/nnq3LYSCWWNr9h8WFTxPA/r5+QjXVzzssIuA8iK9ggsRFrFsPN2mKTa76OLy97+nCbQS/kUZJZYa1HwsBFq1O9uJUuI5Knpd2Qn46mrPzjyKhDIn5eITdk0ABQr5A= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(396003)(136003)(39850400004)(366004)(186003)(26005)(52116002)(6506007)(86362001)(66946007)(6512007)(956004)(2616005)(316002)(83380400001)(478600001)(8676002)(38350700002)(38100700002)(36756003)(4326008)(2906002)(6666004)(5660300002)(1076003)(8936002)(6486002)(66556008)(66476007)(21314003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aYt15Mwi0ZjxCm8gF2Ln9IkFLbjqRvZajLTTxOOJEBubfzpmkm0t9qqrvC7wyZ6OqX1eeTLRTZc8LpezSEyAVZoWqOP9NPyoon6rk9rsgCbzUxB7uQzt51/3Nnovsxcs2hrWLdcjOHayPhrOhbERtr+q5iRjPaa1otwduidC7stp1KoZ3j8Cte3+XO3whUBl06ajQuu+OpwPDa4IA2nFR29N3nCDgZ8qyzxxZ/tuyNuTtySUOs0AP1hAGdtLgkYJxZEqel44y2w6fXb/kgjxPbKz3wiOVBbhpW8LQvsdH8pJdZKv9kgnVzvXsDBfrfvG1vz/4OVHNV7d7dU45VkrMiNSA3FGicKggwH7Cd06leHrffpKjNePIPJ5NKiUi7a1gWdXtee3Ll8xtgZ+0COAYOlnMj8p0g83jpHwKPCs3ajY13puXMTZ7e5U53Y2SJIEkZiXpuEFM6xTI84x8tBJwLZngrDPN9u09oVytI/0Ojq9TF8m40GEQs2R6d3tev0TLVtxrgcTxqm8rgiQGQSmzTLTlMDDvrt+hiIIFoLgpMUdy+fdL82FzgoOfaottsN6fp/W/B2P3uVZx+L1MMy6tmNzKw7EwatJ0IZ1IsQoXbEDryTIpJdibLDReH2fXbel7BjclM2LUSCF1g3w+vq8weQV4SYMQ2TauS9MmvHLdFe/WR+WO627486noB1jLdwrINavkiWeEE/mb/iuydCC8YvrX8UZW6k/lZnKbCpP5E/znzmR56pKI/N57c9KmPJRbOzolVFnJvdGyyXVzGIG6tjEcXVeFWn4xi8LiH3Qfni427TeeLqVMIokNdhtObcLIvqEPOZtdsA7e1ev13WRN5XA2Rf33nYbprZ8lD8w5TU+C9MJP3rXBQRFRNRDv8feDBK6q74Hfl1yF3UKJQvdx5CEzU6rMqdfpsPs2vGddIca1Pl8pzvOgEb7tgad24sGYoci7d8sRgPLNDqub/1hqVakUlIfaTDIHvM9BiB/4DLUy0JPbjCBQp4soKt48aIteztqQCu7ennOg13TEmmxJDMdubQ0gZ9pxCmQgqr0kfDyPnKwi3wBW4KfK5KUNK8BpGkWU4rnSHrffQ1NAEc/ThSDssCrEPyqAQKvkRJSb8lSOpLU7yPuivyL9LOwU9CLuzL2MLWadZUbaj1PXjJd2BAAgKaeZh1JUvQ1+lwmzXFRtLAnB27SzG4651nvB6NwL5s2Hw7/gT9XIojjBGlhgoZ0XKExnqGfqtvrXOfY8XNA3K6W9JGnl+cY1nxn7gsjw4Asrs+HshLK+a9+ene/Nl9li5qK1q/9nQlLQgusXgWQpc7HgyNOa7PH1rcbx7fv X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b951c8a4-3fa5-4ff7-779f-08d9774ab059 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:32.3088 (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: RUYmcySfsBTwDRDfaZOo7Y7yovqllu0f+wYlh5yJHg9t4+4gZ6hGrkdobGePOwAhY/hOL+uic+V0U1G9siOCOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR04MB3013 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org It is possible that a PFD is enabled in HW but not in SW. That means the enable count & prepare count of the PFD clock is '0', so the 'CLK_SET_RATE' flag can do nothing when the rate is changed while the PFD is hw enabled. In order to safely change the pfd rate, we can disable the PFD directly if it is hw enabled but not used by SW end user. Signed-off-by: Jacky Bai --- v3 changs: no --- drivers/clk/imx/clk-pfdv2.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/clk/imx/clk-pfdv2.c b/drivers/clk/imx/clk-pfdv2.c index 6b744c84278e..9cba83521988 100644 --- a/drivers/clk/imx/clk-pfdv2.c +++ b/drivers/clk/imx/clk-pfdv2.c @@ -161,8 +161,17 @@ static int clk_pfdv2_set_rate(struct clk_hw *hw, unsigned long rate, if (!rate) return -EINVAL; - /* PFD can NOT change rate without gating */ - WARN_ON(clk_pfdv2_is_enabled(hw)); + /* + * PFD can NOT change rate without gating. + * as the PFDs may enabled in HW by default but no + * consumer used it, the enable count is '0', so the + * 'SET_RATE_GATE' can NOT help on blocking the set_rate + * ops especially for 'assigned-clock-xxx'. In order + * to simplify the case, just disable the PFD if it is + * enabled in HW but not in SW. + */ + if (clk_pfdv2_is_enabled(hw)) + clk_pfdv2_disable(hw); tmp = tmp * 18 + rate / 2; do_div(tmp, rate); From patchwork Tue Sep 14 06:52:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 511128 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00549C433F5 for ; Tue, 14 Sep 2021 06:41:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6FB160E90 for ; Tue, 14 Sep 2021 06:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240243AbhINGmz (ORCPT ); Tue, 14 Sep 2021 02:42:55 -0400 Received: from mail-db8eur05on2084.outbound.protection.outlook.com ([40.107.20.84]:58337 "EHLO EUR05-DB8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239015AbhINGmz (ORCPT ); Tue, 14 Sep 2021 02:42:55 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ageVDAycJ0/H51T2XDdFbyguXJrHzpPOUo5cTmI4rnVgeahtxW5R533ItF8aPPvCJUNcJdq9rpo0vQzxMx3m7Gi00atuX7MKhSA+vEIj9hwrGqMRabkQTpAh15X1mL1QxiOQDDoydRhcqJ5JaC8XkhSZXDeKf7wBMyMC3pu/qp6t2P/WlRAlvAizvHdIZK6FUinf9i/5ZKciPddBXfHm0DjAHHGPWv58zRMUEJeEANSZgIAlerVRvFDr5WR+2qbCePBzFuBXoZ9qfDj3R6aqAgzgINszV/wMsLJaGS9x/9imX1ClOd0rvKzuLGxFJBwpb8HPfq4zglfJxzMk0I4ejg== 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; bh=zyhG5vLu9L9K4v+CrCDeVCIkxJSIMM/FY0IVpJO1Ajg=; b=ZUECvMpLQeFKsAdBKyjMTHRy6eAlg9zW8duy2B/Ex3zRqJSsQw5B0DbYv1mUecgNz0aEJLw7yNBW+aUxE9E14Cs/Wkzf2sfSC+b8LPHrrqD5LNb7077rjspo9co+/RfHuG4aGEsLbfeDp73cIu0b3V3ojzJEYxBVjVAcvMGSrAk+XeNhxnv+MEcj/ysBoXE4wsbQOOBiNfyc+WF3AgLtLUeKp3LU8MOuoT6Ub152aDb7H8MCF2302VzJQqembk8BHqzHck6qwTs36zBHL/xTXnsV8xgAls00RFdKgeUOmEe4DNrYOv/xEVSwqD/bNoOvG0EbGdYQa4Rjgul/VtV80g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zyhG5vLu9L9K4v+CrCDeVCIkxJSIMM/FY0IVpJO1Ajg=; b=RBPfDK6BKmFa+LgudBHJNZvyFY/ZnssCLzodHAjzDLHc68U19+Ny1A52ilEWW1dtPZgY7au1QLwkXfjVDvj0st/V/stXsnABFKx4LZGhNDEwNabzjMc18jXqVm1TJ7OegRf0ZOwy0Lk1kbo6pDl73Rdxqk3jCvDeYHH3ioeFUng= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DB9PR04MB8316.eurprd04.prod.outlook.com (2603:10a6:10:246::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 14 Sep 2021 06:41:36 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:36 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 7/9] clk: imx: Update the pfdv2 for 8ulp specific support Date: Tue, 14 Sep 2021 14:52:06 +0800 Message-Id: <20210914065208.3582128-8-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c674fbe-6543-4914-0baa-08d9774ab2c1 X-MS-TrafficTypeDiagnostic: DB9PR04MB8316: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cl2aU4iBomV/OAL3HIRgSs9z3fdNxHxGxRPYRp3ObJn5I2tQsChaGiwIu6vbo7PUYZ/sV0RCKGmsVduiI9hXDUziKaTP2V6YkmWlFoHXtgCNud8daDPqudf4d8+rewcBTk7qWIV5QuNTx37iN++i4tmvQWQUveXP0u2MG1NS53L9a3umfZjlelLSfZUkqg3m/TkiA+HfvMsPvnGjp9X5PYdtnMyJdNjxR9EfnnF0JZI5Iayx7DXVBQJby6dE8MPdgzvMEiZYrT/qdG9zHvcKwvhSv42CDTZTJhnzo4bwpkn8iwV5R03Big7V9RC6aa3VHfoqKw8jYrvj/f7zOvhFM1c6SI0mKamIdOdAb1135HQWNTm5b3VsTCfyxpPpXCPLM/q8wtfwjac1fYuhWZ8rzaMNa/OjO6jmvZcxajmWVoF5TV7+8VClorUo/3wPjjoAALvHuIsvfPpRYmNNoAFJs2CVOuqjcZ0ikR1FncgY0n2GZFl9WfS3WriQuLL3GdcGbCdgrAYn9HOEI8yVsz4umJI2ucsfUxqopikfSI6UajvZLTz9G571HG8jlpiCHqW1eraJFXtsj0e4aG51LhvkDnEnWSM/uGyOeH7tI5f2B3vpY/nB+yquJmLuRVfjK4he0MnDIVl70l4+dwevaDB87Sui1ajyHS6PK7FHQcOs/sPVojfBGhwecmNZEZeP0YQa1KtBch8YvEmTD6+wD/BmTg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(346002)(136003)(376002)(396003)(5660300002)(83380400001)(86362001)(6666004)(6506007)(4326008)(2616005)(316002)(52116002)(956004)(66946007)(66476007)(66556008)(478600001)(15650500001)(6486002)(36756003)(38350700002)(38100700002)(26005)(6512007)(2906002)(186003)(1076003)(8676002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KtXU0lnnkd6VAHIlFirjWxQ8f37JNhp5dj4RZQcTbzYyN++u4O6i/OuM38zhF0GKK7WarO1GRVq+XuieHOrB2RuBnCh0qMmQ5+mGNa9RmcGtKmG5a4y20l/HOyXW/a7mfxDTZjZYEnFDJvxA5dSowelKrmIo3HwqHZRp5xdR0gj7oPNnqxNAoXTErm6trZIdFaf5ewqPX/RKpxjlt4RmbtTYEx4u6BO3bOzbwp3Jbtjam2a/sJGGoUEHoCQzoDr4p9FQvehJXr7XDKTeKXO21H5mmtdKdYEuWiBR2jDsmtn44g1ahDMhYCVGPx2rmIudIosfNX3kLrDgZ6cYKDEx6HhI9ex2+/jd9oxfzPnVXLM7XdtnOL4HeaXgoKnZHHbjiGjk66UuyHxL3C4FFo4YQAKcl3tJEzri2XCpROJFhdA4ughCzxtHdLyRxGha5d2l4X0MbaaB/DQfCBmVG+K3slPZ8c4foicr/VCC2yHESeMyiGVsrdqnyRyXsOa+7tJAPTevjkSm65tM7JLfdpMQleLA6QD7xS38+4fZaIq8Sx1MQ6K8KGFQsiHbgsBQr61rCLuk7HHv5rLVwnseKrB07rUz5xYvWSQ429OttE7mj4kdAUx/qN6yjxlLmU0pLBbSvKo1yWIh68HtSNU7GvAQ0Rh/d+blFz95wRqwUi612tW1lSeFT88ryDRuVL+Je0vTloEPbqQavWc/xF9tBtpP/gJd18Eijf9qZ5STedvEUo7FEJqksHbfeY6Gqqcu8sXIdIPaQrwQylLZvMG+1uDzGj/7eSfqwa0QLS1OwVmdfWQsNlXoXgiEBqO67N/F0YS7J7xM5fl4qs5j5hxFpA2srcTlNlJ0TQukCzyKkzIU6xqx8/+ABtW8w7MueCjppjYxp5mk4GpGIlC4QqFl5rxFfk8sOVZVsk+NLe2y+mJpskmCvpn4n/fjt3Mn9pJFndKrqNpUG6c8ttPQqmVXtdPoV3NC/69WkRhGWntPVk29l10LYGTfWCfUJtWuHF6IF5nzg7bsVfMU3QmZ5YIsm4ZazfBqlMa+EuJW2SCBhQwrXgbTuvG0lJUaUhl6yP5eMbQRwMPE+07aTPNV5oQ/ptPMxGVYhifbRjxRTI4UHMbRnAAEflmricawVQCKTP7B8/AUFIFA2c6lov5CvIJuQrfCU9M/zdUvTy0qqEs6dMjjkoWNF2Aqa9lHKqQy01FY//QePJS2mkSCjGm4GCQUCeKdzBFBIGoaVTjGXo+WylP/sgGRWTDmUGwJMVNSLINfXDNtyUP9MkRH74KC2p9E5XpK0u6X3CkbiMs19FiXXVy3VqFNsE2Fdn9ArXqTyOanE8Hb X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c674fbe-6543-4914-0baa-08d9774ab2c1 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:36.1948 (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: P9bBFqzIzSoOF6jCjoD5xDm0r7Irc5fWoL9fi+Sv6H2GVR9M+hXgJ+cQRVD5fouAFCvd3zGXQWh67bO2LLpT9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8316 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On i.MX8ULP, the 'CLK_SET_RATE_PARENT' flag should NOT be set and according to the laest RM, the PFD divider value range seems will be changed in the future, so update the pfdv2 to include the specific support for i.MX8ULP. Signed-off-by: Jacky Bai --- v3 changs: no --- drivers/clk/imx/clk-imx7ulp.c | 16 ++++++++-------- drivers/clk/imx/clk-pfdv2.c | 9 ++++++--- drivers/clk/imx/clk.h | 9 +++++++-- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/clk/imx/clk-imx7ulp.c b/drivers/clk/imx/clk-imx7ulp.c index ba50d6db8097..b6e45e77ee39 100644 --- a/drivers/clk/imx/clk-imx7ulp.c +++ b/drivers/clk/imx/clk-imx7ulp.c @@ -82,16 +82,16 @@ static void __init imx7ulp_clk_scg1_init(struct device_node *np) hws[IMX7ULP_CLK_SPLL] = imx_clk_hw_pllv4(IMX_PLLV4_IMX7ULP, "spll", "spll_pre_div", base + 0x600); /* APLL PFDs */ - hws[IMX7ULP_CLK_APLL_PFD0] = imx_clk_hw_pfdv2("apll_pfd0", "apll", base + 0x50c, 0); - hws[IMX7ULP_CLK_APLL_PFD1] = imx_clk_hw_pfdv2("apll_pfd1", "apll", base + 0x50c, 1); - hws[IMX7ULP_CLK_APLL_PFD2] = imx_clk_hw_pfdv2("apll_pfd2", "apll", base + 0x50c, 2); - hws[IMX7ULP_CLK_APLL_PFD3] = imx_clk_hw_pfdv2("apll_pfd3", "apll", base + 0x50c, 3); + hws[IMX7ULP_CLK_APLL_PFD0] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX7ULP, "apll_pfd0", "apll", base + 0x50c, 0); + hws[IMX7ULP_CLK_APLL_PFD1] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX7ULP, "apll_pfd1", "apll", base + 0x50c, 1); + hws[IMX7ULP_CLK_APLL_PFD2] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX7ULP, "apll_pfd2", "apll", base + 0x50c, 2); + hws[IMX7ULP_CLK_APLL_PFD3] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX7ULP, "apll_pfd3", "apll", base + 0x50c, 3); /* SPLL PFDs */ - hws[IMX7ULP_CLK_SPLL_PFD0] = imx_clk_hw_pfdv2("spll_pfd0", "spll", base + 0x60C, 0); - hws[IMX7ULP_CLK_SPLL_PFD1] = imx_clk_hw_pfdv2("spll_pfd1", "spll", base + 0x60C, 1); - hws[IMX7ULP_CLK_SPLL_PFD2] = imx_clk_hw_pfdv2("spll_pfd2", "spll", base + 0x60C, 2); - hws[IMX7ULP_CLK_SPLL_PFD3] = imx_clk_hw_pfdv2("spll_pfd3", "spll", base + 0x60C, 3); + hws[IMX7ULP_CLK_SPLL_PFD0] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX7ULP, "spll_pfd0", "spll", base + 0x60C, 0); + hws[IMX7ULP_CLK_SPLL_PFD1] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX7ULP, "spll_pfd1", "spll", base + 0x60C, 1); + hws[IMX7ULP_CLK_SPLL_PFD2] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX7ULP, "spll_pfd2", "spll", base + 0x60C, 2); + hws[IMX7ULP_CLK_SPLL_PFD3] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX7ULP, "spll_pfd3", "spll", base + 0x60C, 3); /* PLL Mux */ hws[IMX7ULP_CLK_APLL_PFD_SEL] = imx_clk_hw_mux_flags("apll_pfd_sel", base + 0x508, 14, 2, apll_pfd_sels, ARRAY_SIZE(apll_pfd_sels), CLK_SET_RATE_PARENT | CLK_SET_PARENT_GATE); diff --git a/drivers/clk/imx/clk-pfdv2.c b/drivers/clk/imx/clk-pfdv2.c index 9cba83521988..42505669cdfb 100644 --- a/drivers/clk/imx/clk-pfdv2.c +++ b/drivers/clk/imx/clk-pfdv2.c @@ -200,8 +200,8 @@ static const struct clk_ops clk_pfdv2_ops = { .is_enabled = clk_pfdv2_is_enabled, }; -struct clk_hw *imx_clk_hw_pfdv2(const char *name, const char *parent_name, - void __iomem *reg, u8 idx) +struct clk_hw *imx_clk_hw_pfdv2(enum imx_pfdv2_type type, const char *name, + const char *parent_name, void __iomem *reg, u8 idx) { struct clk_init_data init; struct clk_pfdv2 *pfd; @@ -223,7 +223,10 @@ struct clk_hw *imx_clk_hw_pfdv2(const char *name, const char *parent_name, init.ops = &clk_pfdv2_ops; init.parent_names = &parent_name; init.num_parents = 1; - init.flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT; + if (type == IMX_PFDV2_IMX7ULP) + init.flags = CLK_SET_RATE_GATE | CLK_SET_RATE_PARENT; + else + init.flags = CLK_SET_RATE_GATE; pfd->hw.init = &init; diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h index a9bcfee7a75b..45be7ba23fae 100644 --- a/drivers/clk/imx/clk.h +++ b/drivers/clk/imx/clk.h @@ -47,6 +47,11 @@ enum imx_pllv4_type { IMX_PLLV4_IMX8ULP, }; +enum imx_pfdv2_type { + IMX_PFDV2_IMX7ULP, + IMX_PFDV2_IMX8ULP, +}; + /* NOTE: Rate table should be kept sorted in descending order. */ struct imx_pll14xx_rate_table { unsigned int rate; @@ -220,8 +225,8 @@ struct clk_hw *imx_clk_hw_gate_exclusive(const char *name, const char *parent, struct clk_hw *imx_clk_hw_pfd(const char *name, const char *parent_name, void __iomem *reg, u8 idx); -struct clk_hw *imx_clk_hw_pfdv2(const char *name, const char *parent_name, - void __iomem *reg, u8 idx); +struct clk_hw *imx_clk_hw_pfdv2(enum imx_pfdv2_type type, const char *name, + const char *parent_name, void __iomem *reg, u8 idx); struct clk_hw *imx_clk_hw_busy_divider(const char *name, const char *parent_name, void __iomem *reg, u8 shift, u8 width, From patchwork Tue Sep 14 06:52:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 512494 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5D6DC433F5 for ; Tue, 14 Sep 2021 06:41:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1B6D61157 for ; Tue, 14 Sep 2021 06:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240042AbhINGnA (ORCPT ); Tue, 14 Sep 2021 02:43:00 -0400 Received: from mail-eopbgr40047.outbound.protection.outlook.com ([40.107.4.47]:19895 "EHLO EUR03-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239015AbhINGm7 (ORCPT ); Tue, 14 Sep 2021 02:42:59 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Iym6g+G741e/JakHCxXVOCanOVUSXbj3jqlx9KJbSkCAOMZswtZB2QHz3QekpqUdRoi4YcE7t40tWCAFMZt1XGauORURJw5CF0ecsvCiOkpFFBuuIG7eIG+XU2HlL/sR//MkNaaTno7etvW+Jt12wXMCIljwSfZ/UyG6rNpvu82oLk0ZHFD2V7cLO67Ebgj58IVEwzzMAkXUG3TSfIqgGGYYaB1qAbMLgBevJ6UhjwVhTiniOPMIVx3P3r4/5Hd2mT6yUGMPhIt7krX8A8Z6Klha6/iuhRUd+pqeSoYuEHHTnGi7qtblZkaE0HTXypWSVZ1fPxBGNKxVBtew5uACBA== 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; bh=wHMg6Gr8WZ2kwVpV7PXZ8tlZCKfNcZ0YcvrsbwFY72o=; b=AuATOzWTX1x5NJhmIt9Fq/Nudes1qFEN4lJe8ybVa3F58i6zaVTPXt7qaz7GL+r6t5opuss6WIIhoZD5yutIpu+03gd601s/cdEfxbiO+vysVJbJq2o20iaxYhoT73vh6L1igexZQX3E8hEQ/r5dUj0/IHyTIHu2q8ejg41/WvzsS1hUWMkp8pxqR/cPH7rk9JgVdyQnnafUaaHRWvBjwfa4rb3KwPTmKIdo0AXwWveLJWiEUpXnCs5XiXbwNGHqH1qxa5cOP4X5b+4DRGyZ8jiS5IXBVLL/jBWENFrXi+i2cdOOl6M8VumpQqZ62EWGvaC8LNyNfD5MbaklmMJDgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wHMg6Gr8WZ2kwVpV7PXZ8tlZCKfNcZ0YcvrsbwFY72o=; b=MeD/HLWy1bq6450Jq6FyQHxdJTCxLBhB248ngYqnKLkKx3/0EXatD2aqGrfcjjhVFDyNrF7srnoOGHUvxAtlw4G8+fNcZEK/91bxISn9UTxjf5wI3YVhqI0ogAcBd9wMB7cpE9oiirz5qbpto9hhW4mBBPpE3Gfv96Ff+63ISxc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DB9PR04MB8316.eurprd04.prod.outlook.com (2603:10a6:10:246::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 14 Sep 2021 06:41:40 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:40 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 8/9] clk: imx: Add clock driver for imx8ulp Date: Tue, 14 Sep 2021 14:52:07 +0800 Message-Id: <20210914065208.3582128-9-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 345e31f3-0d00-4af4-a923-08d9774ab51f X-MS-TrafficTypeDiagnostic: DB9PR04MB8316: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:792; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j9afOaPuuumSQjEEKEcWPROWJ/cUz+tq4YQ76Eyjr0+Dka7KuGwEYY5kS+qjG9wcfSb4Wn6k/+2gujGtcAUITP+KvLy6gULvFutuUxXRiPtApHvbLshH6/xzK1Yv/Cq7AQ2Snb4fmTd7wzPvuYwnJknOJmE65H+0eTKkzQXdDKNcJVT90u5/S2wBRTosgT6XMrHpTYmMP9yWm0ZY6R/MTFjQtXuA3wfQNGUbcaK1JlXrZMzRA8aQndvwk7nuD42dtO7LHkSvUw9WLKWpIlX12edNN/4rWkjf5oZbO26pZJ0tPc+xn+mrVJVG17r9UTmUVzWkw0MBIiUzXnk6z1t6hK0OQ46KmIi+nO137v1Jatag5t0OjYdZTvgK2WtuACs+g3bk/+PWTtkdc5p546trxKRyCgDiUtH9iHRUfqjJnekJzYC0Chg7skjK8GLe4wmn9qh6Hy/0bn2XdTrjcTVns2UVv0klzs6qaw5zrYPBj1zk2l9KPz8D/8Op1MaDT6qTTOIaspSjIS8QiHZqKWiKennNZFAdeM1lmvPTmHPg5L6HoXPbrVRYeAPJkk34RrOk0PrKCCNZNfMvhtPLDm/9581fCLPSeAYaK6iBSZPb03r10Cm+wkGGF/lNSqwJE+M9LlwMs71D5EarfJ9QmkYZvekD1LwVzZcNcYJrhccNYThKC/+YUngaOPxv6eAofqjvions4lJ5RUGe4cMN9rvYVyaWBmoupEb2JXcDETpgmaA= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(346002)(136003)(376002)(396003)(5660300002)(83380400001)(86362001)(6666004)(6506007)(4326008)(2616005)(316002)(52116002)(956004)(66946007)(66476007)(66556008)(478600001)(6486002)(36756003)(38350700002)(38100700002)(26005)(6512007)(2906002)(186003)(1076003)(30864003)(8676002)(8936002)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: N38IVYGQHYHlr/tcod4LRl/CARw/VjpCbhRov80Q4CXMD0VE/pYREpDketyDDWgKTlvGCjiwMdymb/ga2Mj/ZzreIK1Q6FQgpr882mX5r4Op9S9n8cGKKEg04uDWWrBJGZU6tXZYV+t984XPtQBWsnoyWfbXZkhU4olMUXMqGUilFNP24TT/FN8p+PgMeFgPbzniS3YNjK1ofNsEKYrpHuXO32oioZ6qx54nZWKVRM7NZdeCTiDmKRg1qRnvFLIR3r1BqgWwNoAL4n05Fny0QzXdOeZsnbya8SsEh+V9Rp+DJUMxXoqJnt4JG7JX2/A65YM08xra98b9W+TOwDTE/lTSDxiz0/dnYku7UekrAgavYF+qu5YEc6PXobp0zKfkLPqJJbgFZ7gOdzzf9dr6dpgYqMSppbrYMhkEwxtLnY3hoBGHhOMXCehnBZhnnctd0wAcC73zTikIkuZYlwZSOBbtnYJ631L9wiGYXRZHRpSKfF9YMKekReDqhjsDqjMsIgX3fGCrOO+/orUYb6fmnTIAAOGb6wC4PfV0qLJ3GT1yJcdprvW1Y/HfIulhzsIf0gJm3fA3RHryNQ4IBxCL2jMjIUDrd3zjajLBp8HCymvqGsiJjhgPx04XmA+ar8hGOcZcxKJLK4cpu6ww+VoQwAU82/F2u1eI79Z5cThVhwEfAGuJRBQqEvbZ1j+8KkPoxSlJMnZZpi6ha1r5501qV7svXnKrsn1DUSt0f0DsZM1FZ23SJlyhOYVPnq4pDB6RB0jfjEbBPPFotw+ESrnDt62X1GLrUb43EQp0LIsEjTvj+IngSy1S7hPmZq6F6fq2uGklEAXZyUnyYwSp8Gms9MqF7WU3k7xaOuGNa4WCFGsYtYJb7K6HCOdM7I8VdOAgQb4m+y4yUEzHE9Jr+W1R4uTx8oFiA68YWkmW5YjHCvnhZ7VrJ+8Y5VgYy7DC6VeIkP5jq5Tk4HEfA+JKTkutIxq1WynOzo9U5WwGE3Wr+PZIbKgdG0qas+icNvStnWdKyU5GnL16h77JeRdOey7Pxn4prw3eDCSCFaPnwPZov76IAeFVyXyUQFlIF3fNtBnXwBSAN+q7bA/0EFP52XNXK3Bjg3fbwSCE18fYD/DcPPhH9sK5BgdraAGlvIESWX4/FGlxgCFV97VKsaoYciZ8NkYKO/yE9KkrAKsfHaCyv33UnYdhuJlIJsDfRcppSYFL+n9I9W65TX8k6obyv4lePZKawNjG8IC0UI/BMOLOYp0XyzNe/SMYJo5eKLj6gp+J8zxlc3kx5CYiDzMrDEBHcfRzPeImEjuQylOD1Gd85yYGOHU7Sfnm705X2ipXLNnL X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 345e31f3-0d00-4af4-a923-08d9774ab51f X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:40.2977 (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: nZxU6Dv0Zx681S6idb6EOk/xN5KfPxlqqiVpQO/uE6QtQ3jItxPpbVJa2UbYPoGFlgMJLGX7M9fUAL2/+rSKKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8316 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add clock driver for i.MX8ULP. Signed-off-by: Peng Fan Signed-off-by: Jacky Bai --- v3 changes: - no v2 changes: - remove the redundent fixed sosc, fosc etc clock register --- drivers/clk/imx/Kconfig | 6 + drivers/clk/imx/Makefile | 2 + drivers/clk/imx/clk-imx8ulp.c | 459 ++++++++++++++++++++++++++++++++++ 3 files changed, 467 insertions(+) create mode 100644 drivers/clk/imx/clk-imx8ulp.c diff --git a/drivers/clk/imx/Kconfig b/drivers/clk/imx/Kconfig index 47d9ec3abd2f..b81d6437ed95 100644 --- a/drivers/clk/imx/Kconfig +++ b/drivers/clk/imx/Kconfig @@ -98,3 +98,9 @@ config CLK_IMX8QXP select MXC_CLK_SCU help Build the driver for IMX8QXP SCU based clocks. + +config CLK_IMX8ULP + tristate "IMX8ULP CCM Clock Driver" + depends on ARCH_MXC || COMPILE_TEST + help + Build the driver for i.MX8ULP CCM Clock Driver diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile index c24a2acbfa56..b5e040026dfb 100644 --- a/drivers/clk/imx/Makefile +++ b/drivers/clk/imx/Makefile @@ -31,6 +31,8 @@ clk-imx-scu-$(CONFIG_CLK_IMX8QXP) += clk-scu.o clk-imx8qxp.o \ clk-imx8qxp-rsrc.o clk-imx8qm-rsrc.o clk-imx-lpcg-scu-$(CONFIG_CLK_IMX8QXP) += clk-lpcg-scu.o clk-imx8qxp-lpcg.o +obj-$(CONFIG_CLK_IMX8ULP) += clk-imx8ulp.o + obj-$(CONFIG_CLK_IMX1) += clk-imx1.o obj-$(CONFIG_CLK_IMX25) += clk-imx25.o obj-$(CONFIG_CLK_IMX27) += clk-imx27.o diff --git a/drivers/clk/imx/clk-imx8ulp.c b/drivers/clk/imx/clk-imx8ulp.c new file mode 100644 index 000000000000..6aad04114658 --- /dev/null +++ b/drivers/clk/imx/clk-imx8ulp.c @@ -0,0 +1,459 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2021 NXP + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "clk.h" + +static const char * const pll_pre_sels[] = { "sosc", "frosc", }; +static const char * const a35_sels[] = { "frosc", "spll2", "sosc", "lvds", }; +static const char * const nic_sels[] = { "frosc", "spll3_pfd0", "sosc", "lvds", }; +static const char * const pcc3_periph_bus_sels[] = { "dummy", "lposc", "sosc_div2", + "frosc_div2", "xbar_divbus", "spll3_pfd1_div1", + "spll3_pfd0_div2", "spll3_pfd0_div1", }; +static const char * const pcc4_periph_bus_sels[] = { "dummy", "dummy", "lposc", + "sosc_div2", "frosc_div2", "xbar_divbus", + "spll3_vcodiv", "spll3_pfd0_div1", }; +static const char * const pcc4_periph_plat_sels[] = { "dummy", "sosc_div1", "frosc_div1", + "spll3_pfd3_div2", "spll3_pfd3_div1", + "spll3_pfd2_div2", "spll3_pfd2_div1", + "spll3_pfd1_div2", }; +static const char * const pcc5_periph_bus_sels[] = { "dummy", "dummy", "lposc", + "sosc_div2", "frosc_div2", "lpav_bus_clk", + "pll4_vcodiv", "pll4_pfd3_div1", }; +static const char * const pcc5_periph_plat_sels[] = { "dummy", "pll4_pfd3_div2", "pll4_pfd2_div2", + "pll4_pfd2_div1", "pll4_pfd1_div2", + "pll4_pfd1_div1", "pll4_pfd0_div2", + "pll4_pfd0_div1", }; +static const char * const hifi_sels[] = { "frosc", "pll4", "pll4_pfd0", "sosc", + "lvds", "dummy", "dummy", "dummy", }; +static const char * const ddr_sels[] = { "frosc", "pll4_pfd1", "sosc", "lvds", + "pll4", "pll4", "pll4", "pll4", }; +static const char * const lpav_sels[] = { "frosc", "pll4_pfd1", "sosc", "lvds", }; +static const char * const sai45_sels[] = { "spll3_pfd1_div1", "aud_clk1", "aud_clk2", "sosc", }; +static const char * const sai67_sels[] = { "spll1_pfd2_div", "spll3_pfd1_div1", "aud_clk0", "aud_clk1", "aud_clk2", "sosc", "dummy", "dummy", }; +static const char * const aud_clk1_sels[] = { "ext_aud_mclk2", "sai4_rx_bclk", "sai4_tx_bclk", "sai5_rx_bclk", "sai5_tx_bclk", "dummy", "dummy", "dummy", }; +static const char * const aud_clk2_sels[] = { "ext_aud_mclk3", "sai6_rx_bclk", "sai6_tx_bclk", "sai7_rx_bclk", "sai7_tx_bclk", "spdif_rx", "dummy", "dummy", }; +static const char * const enet_ts_sels[] = { "ext_rmii_clk", "ext_ts_clk", "rosc", "ext_aud_mclk", "sosc", "dummy", "dummy", "dummy"}; +static const char * const xbar_divbus[] = { "xbar_divbus" }; +static const char * const nic_per_divplat[] = { "nic_per_divplat" }; +static const char * const lpav_axi_div[] = { "lpav_axi_div" }; +static const char * const lpav_bus_div[] = { "lpav_bus_div" }; + +static int imx8ulp_clk_cgc1_init(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct clk_hw_onecell_data *clk_data; + struct clk_hw **clks; + void __iomem *base; + + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_CGC1_END), + GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + clk_data->num = IMX8ULP_CLK_CGC1_END; + clks = clk_data->hws; + + clks[IMX8ULP_CLK_DUMMY] = imx_clk_hw_fixed("dummy", 0); + + /* CGC1 */ + base = devm_platform_ioremap_resource(pdev, 0); + if (WARN_ON(IS_ERR(base))) + return PTR_ERR(base); + + clks[IMX8ULP_CLK_SPLL2_PRE_SEL] = imx_clk_hw_mux_flags("spll2_pre_sel", base + 0x510, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); + clks[IMX8ULP_CLK_SPLL3_PRE_SEL] = imx_clk_hw_mux_flags("spll3_pre_sel", base + 0x610, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); + + clks[IMX8ULP_CLK_SPLL2] = imx_clk_hw_pllv4(IMX_PLLV4_IMX8ULP, "spll2", "spll2_pre_sel", base + 0x500); + clks[IMX8ULP_CLK_SPLL3] = imx_clk_hw_pllv4(IMX_PLLV4_IMX8ULP, "spll3", "spll3_pre_sel", base + 0x600); + clks[IMX8ULP_CLK_SPLL3_VCODIV] = imx_clk_hw_divider("spll3_vcodiv", "spll3", base + 0x604, 0, 6); + + clks[IMX8ULP_CLK_SPLL3_PFD0] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "spll3_pfd0", "spll3_vcodiv", base + 0x614, 0); + clks[IMX8ULP_CLK_SPLL3_PFD1] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "spll3_pfd1", "spll3_vcodiv", base + 0x614, 1); + clks[IMX8ULP_CLK_SPLL3_PFD2] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "spll3_pfd2", "spll3_vcodiv", base + 0x614, 2); + clks[IMX8ULP_CLK_SPLL3_PFD3] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "spll3_pfd3", "spll3_vcodiv", base + 0x614, 3); + + clks[IMX8ULP_CLK_SPLL3_PFD0_DIV1_GATE] = imx_clk_hw_gate_dis("spll3_pfd0_div1_gate", "spll3_pfd0", base + 0x608, 7); + clks[IMX8ULP_CLK_SPLL3_PFD0_DIV2_GATE] = imx_clk_hw_gate_dis("spll3_pfd0_div2_gate", "spll3_pfd0", base + 0x608, 15); + clks[IMX8ULP_CLK_SPLL3_PFD1_DIV1_GATE] = imx_clk_hw_gate_dis("spll3_pfd1_div1_gate", "spll3_pfd1", base + 0x608, 23); + clks[IMX8ULP_CLK_SPLL3_PFD1_DIV2_GATE] = imx_clk_hw_gate_dis("spll3_pfd1_div2_gate", "spll3_pfd1", base + 0x608, 31); + clks[IMX8ULP_CLK_SPLL3_PFD2_DIV1_GATE] = imx_clk_hw_gate_dis("spll3_pfd2_div1_gate", "spll3_pfd2", base + 0x60c, 7); + clks[IMX8ULP_CLK_SPLL3_PFD2_DIV2_GATE] = imx_clk_hw_gate_dis("spll3_pfd2_div2_gate", "spll3_pfd2", base + 0x60c, 15); + clks[IMX8ULP_CLK_SPLL3_PFD3_DIV1_GATE] = imx_clk_hw_gate_dis("spll3_pfd3_div1_gate", "spll3_pfd3", base + 0x60c, 23); + clks[IMX8ULP_CLK_SPLL3_PFD3_DIV2_GATE] = imx_clk_hw_gate_dis("spll3_pfd3_div2_gate", "spll3_pfd3", base + 0x60c, 31); + clks[IMX8ULP_CLK_SPLL3_PFD0_DIV1] = imx_clk_hw_divider("spll3_pfd0_div1", "spll3_pfd0_div1_gate", base + 0x608, 0, 6); + clks[IMX8ULP_CLK_SPLL3_PFD0_DIV2] = imx_clk_hw_divider("spll3_pfd0_div2", "spll3_pfd0_div2_gate", base + 0x608, 8, 6); + clks[IMX8ULP_CLK_SPLL3_PFD1_DIV1] = imx_clk_hw_divider("spll3_pfd1_div1", "spll3_pfd1_div1_gate", base + 0x608, 16, 6); + clks[IMX8ULP_CLK_SPLL3_PFD1_DIV2] = imx_clk_hw_divider("spll3_pfd1_div2", "spll3_pfd1_div2_gate", base + 0x608, 24, 6); + clks[IMX8ULP_CLK_SPLL3_PFD2_DIV1] = imx_clk_hw_divider("spll3_pfd2_div1", "spll3_pfd2_div1_gate", base + 0x60c, 0, 6); + clks[IMX8ULP_CLK_SPLL3_PFD2_DIV2] = imx_clk_hw_divider("spll3_pfd2_div2", "spll3_pfd2_div2_gate", base + 0x60c, 8, 6); + clks[IMX8ULP_CLK_SPLL3_PFD3_DIV1] = imx_clk_hw_divider("spll3_pfd3_div1", "spll3_pfd3_div1_gate", base + 0x60c, 16, 6); + clks[IMX8ULP_CLK_SPLL3_PFD3_DIV2] = imx_clk_hw_divider("spll3_pfd3_div2", "spll3_pfd3_div2_gate", base + 0x60c, 24, 6); + + clks[IMX8ULP_CLK_A35_SEL] = imx_clk_hw_mux2("a35_sel", base + 0x14, 28, 2, a35_sels, ARRAY_SIZE(a35_sels)); + clks[IMX8ULP_CLK_A35_DIV] = imx_clk_hw_divider_flags("a35_div", "a35_sel", base + 0x14, 21, 6, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + + clks[IMX8ULP_CLK_NIC_SEL] = imx_clk_hw_mux2("nic_sel", base + 0x34, 28, 2, nic_sels, ARRAY_SIZE(nic_sels)); + clks[IMX8ULP_CLK_NIC_AD_DIVPLAT] = imx_clk_hw_divider_flags("nic_ad_divplat", "nic_sel", base + 0x34, 21, 6, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + clks[IMX8ULP_CLK_NIC_PER_DIVPLAT] = imx_clk_hw_divider_flags("nic_per_divplat", "nic_ad_divplat", base + 0x34, 14, 6, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + clks[IMX8ULP_CLK_XBAR_AD_DIVPLAT] = imx_clk_hw_divider_flags("xbar_ad_divplat", "nic_ad_divplat", base + 0x38, 14, 6, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + clks[IMX8ULP_CLK_XBAR_DIVBUS] = imx_clk_hw_divider_flags("xbar_divbus", "nic_ad_divplat", base + 0x38, 7, 6, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + clks[IMX8ULP_CLK_XBAR_AD_SLOW] = imx_clk_hw_divider_flags("xbar_ad_slow", "nic_ad_divplat", base + 0x38, 0, 6, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + + clks[IMX8ULP_CLK_SOSC_DIV1_GATE] = imx_clk_hw_gate_dis("sosc_div1_gate", "sosc", base + 0x108, 7); + clks[IMX8ULP_CLK_SOSC_DIV2_GATE] = imx_clk_hw_gate_dis("sosc_div2_gate", "sosc", base + 0x108, 15); + clks[IMX8ULP_CLK_SOSC_DIV3_GATE] = imx_clk_hw_gate_dis("sosc_div3_gate", "sosc", base + 0x108, 23); + clks[IMX8ULP_CLK_SOSC_DIV1] = imx_clk_hw_divider("sosc_div1", "sosc_div1_gate", base + 0x108, 0, 6); + clks[IMX8ULP_CLK_SOSC_DIV2] = imx_clk_hw_divider("sosc_div2", "sosc_div2_gate", base + 0x108, 8, 6); + clks[IMX8ULP_CLK_SOSC_DIV3] = imx_clk_hw_divider("sosc_div3", "sosc_div3_gate", base + 0x108, 16, 6); + + clks[IMX8ULP_CLK_FROSC_DIV1_GATE] = imx_clk_hw_gate_dis("frosc_div1_gate", "frosc", base + 0x208, 7); + clks[IMX8ULP_CLK_FROSC_DIV2_GATE] = imx_clk_hw_gate_dis("frosc_div2_gate", "frosc", base + 0x208, 15); + clks[IMX8ULP_CLK_FROSC_DIV3_GATE] = imx_clk_hw_gate_dis("frosc_div3_gate", "frosc", base + 0x208, 23); + clks[IMX8ULP_CLK_FROSC_DIV1] = imx_clk_hw_divider("frosc_div1", "frosc_div1_gate", base + 0x208, 0, 6); + clks[IMX8ULP_CLK_FROSC_DIV2] = imx_clk_hw_divider("frosc_div2", "frosc_div2_gate", base + 0x208, 8, 6); + clks[IMX8ULP_CLK_FROSC_DIV3] = imx_clk_hw_divider("frosc_div3", "frosc_div3_gate", base + 0x208, 16, 6); + clks[IMX8ULP_CLK_AUD_CLK1] = imx_clk_hw_mux2("aud_clk1", base + 0x900, 0, 3, aud_clk1_sels, ARRAY_SIZE(aud_clk1_sels)); + clks[IMX8ULP_CLK_SAI4_SEL] = imx_clk_hw_mux2("sai4_sel", base + 0x904, 0, 2, sai45_sels, ARRAY_SIZE(sai45_sels)); + clks[IMX8ULP_CLK_SAI5_SEL] = imx_clk_hw_mux2("sai5_sel", base + 0x904, 8, 2, sai45_sels, ARRAY_SIZE(sai45_sels)); + clks[IMX8ULP_CLK_ENET_TS_SEL] = imx_clk_hw_mux2("enet_ts", base + 0x700, 24, 3, enet_ts_sels, ARRAY_SIZE(enet_ts_sels)); + + imx_check_clk_hws(clks, clk_data->num); + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); +} + +static int imx8ulp_clk_cgc2_init(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct clk_hw_onecell_data *clk_data; + struct clk_hw **clks; + void __iomem *base; + + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_CGC2_END), + GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + clk_data->num = IMX8ULP_CLK_CGC2_END; + clks = clk_data->hws; + + /* CGC2 */ + base = devm_platform_ioremap_resource(pdev, 0); + if (WARN_ON(IS_ERR(base))) + return PTR_ERR(base); + + clks[IMX8ULP_CLK_PLL4_PRE_SEL] = imx_clk_hw_mux_flags("pll4_pre_sel", base + 0x610, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); + + clks[IMX8ULP_CLK_PLL4] = imx_clk_hw_pllv4(IMX_PLLV4_IMX8ULP, "pll4", "pll4_pre_sel", base + 0x600); + clks[IMX8ULP_CLK_PLL4_VCODIV] = imx_clk_hw_divider("pll4_vcodiv", "pll4", base + 0x604, 0, 6); + + clks[IMX8ULP_CLK_HIFI_SEL] = imx_clk_hw_mux_flags("hifi_sel", base + 0x14, 28, 3, hifi_sels, ARRAY_SIZE(hifi_sels), CLK_SET_PARENT_GATE); + clks[IMX8ULP_CLK_HIFI_DIVCORE] = imx_clk_hw_divider("hifi_core_div", "hifi_sel", base + 0x14, 21, 6); + clks[IMX8ULP_CLK_HIFI_DIVPLAT] = imx_clk_hw_divider("hifi_plat_div", "hifi_core_div", base + 0x14, 14, 6); + + clks[IMX8ULP_CLK_DDR_SEL] = imx_clk_hw_mux_flags("ddr_sel", base + 0x40, 28, 3, ddr_sels, ARRAY_SIZE(ddr_sels), CLK_SET_PARENT_GATE); + clks[IMX8ULP_CLK_DDR_DIV] = imx_clk_hw_divider_flags("ddr_div", "ddr_sel", base + 0x40, 21, 6, CLK_IS_CRITICAL); + clks[IMX8ULP_CLK_LPAV_AXI_SEL] = imx_clk_hw_mux("lpav_sel", base + 0x3c, 28, 2, lpav_sels, ARRAY_SIZE(lpav_sels)); + clks[IMX8ULP_CLK_LPAV_AXI_DIV] = imx_clk_hw_divider_flags("lpav_axi_div", "lpav_sel", base + 0x3c, 21, 6, CLK_IS_CRITICAL); + clks[IMX8ULP_CLK_LPAV_AHB_DIV] = imx_clk_hw_divider_flags("lpav_ahb_div", "lpav_axi_div", base + 0x3c, 14, 6, CLK_IS_CRITICAL); + clks[IMX8ULP_CLK_LPAV_BUS_DIV] = imx_clk_hw_divider_flags("lpav_bus_div", "lpav_axi_div", base + 0x3c, 7, 6, CLK_IS_CRITICAL); + + clks[IMX8ULP_CLK_PLL4_PFD0] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "pll4_pfd0", "pll4_vcodiv", base + 0x614, 0); + clks[IMX8ULP_CLK_PLL4_PFD1] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "pll4_pfd1", "pll4_vcodiv", base + 0x614, 1); + clks[IMX8ULP_CLK_PLL4_PFD2] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "pll4_pfd2", "pll4_vcodiv", base + 0x614, 2); + clks[IMX8ULP_CLK_PLL4_PFD3] = imx_clk_hw_pfdv2(IMX_PFDV2_IMX8ULP, "pll4_pfd3", "pll4_vcodiv", base + 0x614, 3); + + clks[IMX8ULP_CLK_PLL4_PFD0_DIV1_GATE] = imx_clk_hw_gate_dis("pll4_pfd0_div1_gate", "pll4_pfd0", base + 0x608, 7); + clks[IMX8ULP_CLK_PLL4_PFD0_DIV2_GATE] = imx_clk_hw_gate_dis("pll4_pfd0_div2_gate", "pll4_pfd0", base + 0x608, 15); + clks[IMX8ULP_CLK_PLL4_PFD1_DIV1_GATE] = imx_clk_hw_gate_dis("pll4_pfd1_div1_gate", "pll4_pfd1", base + 0x608, 23); + clks[IMX8ULP_CLK_PLL4_PFD1_DIV2_GATE] = imx_clk_hw_gate_dis("pll4_pfd1_div2_gate", "pll4_pfd1", base + 0x608, 31); + clks[IMX8ULP_CLK_PLL4_PFD2_DIV1_GATE] = imx_clk_hw_gate_dis("pll4_pfd2_div1_gate", "pll4_pfd2", base + 0x60c, 7); + clks[IMX8ULP_CLK_PLL4_PFD2_DIV2_GATE] = imx_clk_hw_gate_dis("pll4_pfd2_div2_gate", "pll4_pfd2", base + 0x60c, 15); + clks[IMX8ULP_CLK_PLL4_PFD3_DIV1_GATE] = imx_clk_hw_gate_dis("pll4_pfd3_div1_gate", "pll4_pfd3", base + 0x60c, 23); + clks[IMX8ULP_CLK_PLL4_PFD3_DIV2_GATE] = imx_clk_hw_gate_dis("pll4_pfd3_div2_gate", "pll4_pfd3", base + 0x60c, 31); + clks[IMX8ULP_CLK_PLL4_PFD0_DIV1] = imx_clk_hw_divider("pll4_pfd0_div1", "pll4_pfd0_div1_gate", base + 0x608, 0, 6); + clks[IMX8ULP_CLK_PLL4_PFD0_DIV2] = imx_clk_hw_divider("pll4_pfd0_div2", "pll4_pfd0_div2_gate", base + 0x608, 8, 6); + clks[IMX8ULP_CLK_PLL4_PFD1_DIV1] = imx_clk_hw_divider("pll4_pfd1_div1", "pll4_pfd1_div1_gate", base + 0x608, 16, 6); + clks[IMX8ULP_CLK_PLL4_PFD1_DIV2] = imx_clk_hw_divider("pll4_pfd1_div2", "pll4_pfd1_div2_gate", base + 0x608, 24, 6); + clks[IMX8ULP_CLK_PLL4_PFD2_DIV1] = imx_clk_hw_divider("pll4_pfd2_div1", "pll4_pfd2_div1_gate", base + 0x60c, 0, 6); + clks[IMX8ULP_CLK_PLL4_PFD2_DIV2] = imx_clk_hw_divider("pll4_pfd2_div2", "pll4_pfd2_div2_gate", base + 0x60c, 8, 6); + clks[IMX8ULP_CLK_PLL4_PFD3_DIV1] = imx_clk_hw_divider("pll4_pfd3_div1", "pll4_pfd3_div1_gate", base + 0x60c, 16, 6); + clks[IMX8ULP_CLK_PLL4_PFD3_DIV2] = imx_clk_hw_divider("pll4_pfd3_div2", "pll4_pfd3_div2_gate", base + 0x60c, 24, 6); + + clks[IMX8ULP_CLK_CGC2_SOSC_DIV1_GATE] = imx_clk_hw_gate_dis("cgc2_sosc_div1_gate", "sosc", base + 0x108, 7); + clks[IMX8ULP_CLK_CGC2_SOSC_DIV2_GATE] = imx_clk_hw_gate_dis("cgc2_sosc_div2_gate", "sosc", base + 0x108, 15); + clks[IMX8ULP_CLK_CGC2_SOSC_DIV3_GATE] = imx_clk_hw_gate_dis("cgc2_sosc_div3_gate", "sosc", base + 0x108, 23); + clks[IMX8ULP_CLK_CGC2_SOSC_DIV1] = imx_clk_hw_divider("cgc2_sosc_div1", "cgc2_sosc_div1_gate", base + 0x108, 0, 6); + clks[IMX8ULP_CLK_CGC2_SOSC_DIV2] = imx_clk_hw_divider("cgc2_sosc_div2", "cgc2_sosc_div2_gate", base + 0x108, 8, 6); + clks[IMX8ULP_CLK_CGC2_SOSC_DIV3] = imx_clk_hw_divider("cgc2_sosc_div3", "cgc2_sosc_div3_gate", base + 0x108, 16, 6); + + clks[IMX8ULP_CLK_CGC2_FROSC_DIV1_GATE] = imx_clk_hw_gate_dis("cgc2_frosc_div1_gate", "frosc", base + 0x208, 7); + clks[IMX8ULP_CLK_CGC2_FROSC_DIV2_GATE] = imx_clk_hw_gate_dis("cgc2_frosc_div2_gate", "frosc", base + 0x208, 15); + clks[IMX8ULP_CLK_CGC2_FROSC_DIV3_GATE] = imx_clk_hw_gate_dis("cgc2_frosc_div3_gate", "frosc", base + 0x208, 23); + clks[IMX8ULP_CLK_CGC2_FROSC_DIV1] = imx_clk_hw_divider("cgc2_frosc_div1", "cgc2_frosc_div1_gate", base + 0x208, 0, 6); + clks[IMX8ULP_CLK_CGC2_FROSC_DIV2] = imx_clk_hw_divider("cgc2_frosc_div2", "cgc2_frosc_div2_gate", base + 0x208, 8, 6); + clks[IMX8ULP_CLK_CGC2_FROSC_DIV3] = imx_clk_hw_divider("cgc2_frosc_div3", "cgc2_frosc_div3_gate", base + 0x208, 16, 6); + clks[IMX8ULP_CLK_AUD_CLK2] = imx_clk_hw_mux2("aud_clk2", base + 0x900, 0, 3, aud_clk2_sels, ARRAY_SIZE(aud_clk2_sels)); + clks[IMX8ULP_CLK_SAI6_SEL] = imx_clk_hw_mux2("sai6_sel", base + 0x904, 0, 3, sai67_sels, ARRAY_SIZE(sai67_sels)); + clks[IMX8ULP_CLK_SAI7_SEL] = imx_clk_hw_mux2("sai7_sel", base + 0x904, 8, 3, sai67_sels, ARRAY_SIZE(sai67_sels)); + clks[IMX8ULP_CLK_SPDIF_SEL] = imx_clk_hw_mux2("spdif_sel", base + 0x910, 0, 3, sai67_sels, ARRAY_SIZE(sai67_sels)); + clks[IMX8ULP_CLK_DSI_PHY_REF] = imx_clk_hw_fixed("dsi_phy_ref", 24000000); + + imx_check_clk_hws(clks, clk_data->num); + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); +} + +static int imx8ulp_clk_pcc3_init(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct clk_hw_onecell_data *clk_data; + struct clk_hw **clks; + void __iomem *base; + int ret; + + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_PCC3_END), + GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + clk_data->num = IMX8ULP_CLK_PCC3_END; + clks = clk_data->hws; + + /* PCC3 */ + base = devm_platform_ioremap_resource(pdev, 0); + if (WARN_ON(IS_ERR(base))) + return PTR_ERR(base); + + clks[IMX8ULP_CLK_WDOG3] = imx8ulp_clk_hw_composite("wdog3", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xa8, 1); + clks[IMX8ULP_CLK_WDOG4] = imx8ulp_clk_hw_composite("wdog4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xac, 1); + clks[IMX8ULP_CLK_LPIT1] = imx8ulp_clk_hw_composite("lpit1", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xc8, 1); + clks[IMX8ULP_CLK_TPM4] = imx8ulp_clk_hw_composite("tpm4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xcc, 1); + clks[IMX8ULP_CLK_TPM5] = imx8ulp_clk_hw_composite("tpm5", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xd0, 1); + clks[IMX8ULP_CLK_FLEXIO1] = imx8ulp_clk_hw_composite("flexio1", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xd4, 1); + clks[IMX8ULP_CLK_I3C2] = imx8ulp_clk_hw_composite("i3c2", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xd8, 1); + clks[IMX8ULP_CLK_LPI2C4] = imx8ulp_clk_hw_composite("lpi2c4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xdc, 1); + clks[IMX8ULP_CLK_LPI2C5] = imx8ulp_clk_hw_composite("lpi2c5", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xe0, 1); + clks[IMX8ULP_CLK_LPUART4] = imx8ulp_clk_hw_composite("lpuart4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xe4, 1); + clks[IMX8ULP_CLK_LPUART5] = imx8ulp_clk_hw_composite("lpuart5", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xe8, 1); + clks[IMX8ULP_CLK_LPSPI4] = imx8ulp_clk_hw_composite("lpspi4", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xec, 1); + clks[IMX8ULP_CLK_LPSPI5] = imx8ulp_clk_hw_composite("lpspi5", pcc3_periph_bus_sels, ARRAY_SIZE(pcc3_periph_bus_sels), true, true, true, base + 0xf0, 1); + + clks[IMX8ULP_CLK_DMA1_MP] = imx_clk_hw_gate("pcc_dma1_mp", "xbar_ad_divplat", base + 0x4, 30); + clks[IMX8ULP_CLK_DMA1_CH0] = imx_clk_hw_gate("pcc_dma1_ch0", "xbar_ad_divplat", base + 0x8, 30); + clks[IMX8ULP_CLK_DMA1_CH1] = imx_clk_hw_gate("pcc_dma1_ch1", "xbar_ad_divplat", base + 0xc, 30); + clks[IMX8ULP_CLK_DMA1_CH2] = imx_clk_hw_gate("pcc_dma1_ch2", "xbar_ad_divplat", base + 0x10, 30); + clks[IMX8ULP_CLK_DMA1_CH3] = imx_clk_hw_gate("pcc_dma1_ch3", "xbar_ad_divplat", base + 0x14, 30); + clks[IMX8ULP_CLK_DMA1_CH4] = imx_clk_hw_gate("pcc_dma1_ch4", "xbar_ad_divplat", base + 0x18, 30); + clks[IMX8ULP_CLK_DMA1_CH5] = imx_clk_hw_gate("pcc_dma1_ch5", "xbar_ad_divplat", base + 0x1c, 30); + clks[IMX8ULP_CLK_DMA1_CH6] = imx_clk_hw_gate("pcc_dma1_ch6", "xbar_ad_divplat", base + 0x20, 30); + clks[IMX8ULP_CLK_DMA1_CH7] = imx_clk_hw_gate("pcc_dma1_ch7", "xbar_ad_divplat", base + 0x24, 30); + clks[IMX8ULP_CLK_DMA1_CH8] = imx_clk_hw_gate("pcc_dma1_ch8", "xbar_ad_divplat", base + 0x28, 30); + clks[IMX8ULP_CLK_DMA1_CH9] = imx_clk_hw_gate("pcc_dma1_ch9", "xbar_ad_divplat", base + 0x2c, 30); + clks[IMX8ULP_CLK_DMA1_CH10] = imx_clk_hw_gate("pcc_dma1_ch10", "xbar_ad_divplat", base + 0x30, 30); + clks[IMX8ULP_CLK_DMA1_CH11] = imx_clk_hw_gate("pcc_dma1_ch11", "xbar_ad_divplat", base + 0x34, 30); + clks[IMX8ULP_CLK_DMA1_CH12] = imx_clk_hw_gate("pcc_dma1_ch12", "xbar_ad_divplat", base + 0x38, 30); + clks[IMX8ULP_CLK_DMA1_CH13] = imx_clk_hw_gate("pcc_dma1_ch13", "xbar_ad_divplat", base + 0x3c, 30); + clks[IMX8ULP_CLK_DMA1_CH14] = imx_clk_hw_gate("pcc_dma1_ch14", "xbar_ad_divplat", base + 0x40, 30); + clks[IMX8ULP_CLK_DMA1_CH15] = imx_clk_hw_gate("pcc_dma1_ch15", "xbar_ad_divplat", base + 0x44, 30); + clks[IMX8ULP_CLK_DMA1_CH16] = imx_clk_hw_gate("pcc_dma1_ch16", "xbar_ad_divplat", base + 0x48, 30); + clks[IMX8ULP_CLK_DMA1_CH17] = imx_clk_hw_gate("pcc_dma1_ch17", "xbar_ad_divplat", base + 0x4c, 30); + clks[IMX8ULP_CLK_DMA1_CH18] = imx_clk_hw_gate("pcc_dma1_ch18", "xbar_ad_divplat", base + 0x50, 30); + clks[IMX8ULP_CLK_DMA1_CH19] = imx_clk_hw_gate("pcc_dma1_ch19", "xbar_ad_divplat", base + 0x54, 30); + clks[IMX8ULP_CLK_DMA1_CH20] = imx_clk_hw_gate("pcc_dma1_ch20", "xbar_ad_divplat", base + 0x58, 30); + clks[IMX8ULP_CLK_DMA1_CH21] = imx_clk_hw_gate("pcc_dma1_ch21", "xbar_ad_divplat", base + 0x5c, 30); + clks[IMX8ULP_CLK_DMA1_CH22] = imx_clk_hw_gate("pcc_dma1_ch22", "xbar_ad_divplat", base + 0x60, 30); + clks[IMX8ULP_CLK_DMA1_CH23] = imx_clk_hw_gate("pcc_dma1_ch23", "xbar_ad_divplat", base + 0x64, 30); + clks[IMX8ULP_CLK_DMA1_CH24] = imx_clk_hw_gate("pcc_dma1_ch24", "xbar_ad_divplat", base + 0x68, 30); + clks[IMX8ULP_CLK_DMA1_CH25] = imx_clk_hw_gate("pcc_dma1_ch25", "xbar_ad_divplat", base + 0x6c, 30); + clks[IMX8ULP_CLK_DMA1_CH26] = imx_clk_hw_gate("pcc_dma1_ch26", "xbar_ad_divplat", base + 0x70, 30); + clks[IMX8ULP_CLK_DMA1_CH27] = imx_clk_hw_gate("pcc_dma1_ch27", "xbar_ad_divplat", base + 0x74, 30); + clks[IMX8ULP_CLK_DMA1_CH28] = imx_clk_hw_gate("pcc_dma1_ch28", "xbar_ad_divplat", base + 0x78, 30); + clks[IMX8ULP_CLK_DMA1_CH29] = imx_clk_hw_gate("pcc_dma1_ch29", "xbar_ad_divplat", base + 0x7c, 30); + clks[IMX8ULP_CLK_DMA1_CH30] = imx_clk_hw_gate("pcc_dma1_ch30", "xbar_ad_divplat", base + 0x80, 30); + clks[IMX8ULP_CLK_DMA1_CH31] = imx_clk_hw_gate("pcc_dma1_ch31", "xbar_ad_divplat", base + 0x84, 30); + clks[IMX8ULP_CLK_MU0_B] = imx_clk_hw_gate("mu0_b", "xbar_ad_divplat", base + 0x88, 30); + clks[IMX8ULP_CLK_MU3_A] = imx_clk_hw_gate("mu3_a", "xbar_ad_divplat", base + 0x8c, 30); + + imx_check_clk_hws(clks, clk_data->num); + + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + + imx_register_uart_clocks(1); + + return ret; +} + +static int imx8ulp_clk_pcc4_init(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct clk_hw_onecell_data *clk_data; + struct clk_hw **clks; + void __iomem *base; + + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_PCC4_END), + GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + clk_data->num = IMX8ULP_CLK_PCC4_END; + clks = clk_data->hws; + + /* PCC4 */ + base = devm_platform_ioremap_resource(pdev, 0); + if (WARN_ON(IS_ERR(base))) + return PTR_ERR(base); + + clks[IMX8ULP_CLK_FLEXSPI2] = imx8ulp_clk_hw_composite("flexspi2", pcc4_periph_plat_sels, ARRAY_SIZE(pcc4_periph_plat_sels), true, true, true, base + 0x4, 1); + clks[IMX8ULP_CLK_TPM6] = imx8ulp_clk_hw_composite("tpm6", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x8, 1); + clks[IMX8ULP_CLK_TPM7] = imx8ulp_clk_hw_composite("tpm7", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0xc, 1); + clks[IMX8ULP_CLK_LPI2C6] = imx8ulp_clk_hw_composite("lpi2c6", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x10, 1); + clks[IMX8ULP_CLK_LPI2C7] = imx8ulp_clk_hw_composite("lpi2c7", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x14, 1); + clks[IMX8ULP_CLK_LPUART6] = imx8ulp_clk_hw_composite("lpuart6", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x18, 1); + clks[IMX8ULP_CLK_LPUART7] = imx8ulp_clk_hw_composite("lpuart7", pcc4_periph_bus_sels, ARRAY_SIZE(pcc4_periph_bus_sels), true, true, true, base + 0x1c, 1); + clks[IMX8ULP_CLK_SAI4] = imx8ulp_clk_hw_composite("sai4", xbar_divbus, 1, false, false, true, base + 0x20, 1); /* sai ipg, NOT from sai sel */ + clks[IMX8ULP_CLK_SAI5] = imx8ulp_clk_hw_composite("sai5", xbar_divbus, 1, false, false, true, base + 0x24, 1); /* sai ipg */ + clks[IMX8ULP_CLK_PCTLE] = imx_clk_hw_gate("pctle", "xbar_divbus", base + 0x28, 30); + clks[IMX8ULP_CLK_PCTLF] = imx_clk_hw_gate("pctlf", "xbar_divbus", base + 0x2c, 30); + clks[IMX8ULP_CLK_USDHC0] = imx8ulp_clk_hw_composite("usdhc0", pcc4_periph_plat_sels, ARRAY_SIZE(pcc4_periph_plat_sels), true, false, true, base + 0x34, 1); + clks[IMX8ULP_CLK_USDHC1] = imx8ulp_clk_hw_composite("usdhc1", pcc4_periph_plat_sels, ARRAY_SIZE(pcc4_periph_plat_sels), true, false, true, base + 0x38, 1); + clks[IMX8ULP_CLK_USDHC2] = imx8ulp_clk_hw_composite("usdhc2", pcc4_periph_plat_sels, ARRAY_SIZE(pcc4_periph_plat_sels), true, false, true, base + 0x3c, 1); + clks[IMX8ULP_CLK_USB0] = imx8ulp_clk_hw_composite("usb0", nic_per_divplat, 1, false, false, true, base + 0x40, 1); + clks[IMX8ULP_CLK_USB0_PHY] = imx8ulp_clk_hw_composite("usb0_phy", xbar_divbus, 1, false, false, true, base + 0x44, 1); + clks[IMX8ULP_CLK_USB1] = imx8ulp_clk_hw_composite("usb1", nic_per_divplat, 1, false, false, true, base + 0x48, 1); + clks[IMX8ULP_CLK_USB1_PHY] = imx8ulp_clk_hw_composite("usb1_phy", xbar_divbus, 1, false, false, true, base + 0x4c, 1); + clks[IMX8ULP_CLK_USB_XBAR] = imx_clk_hw_gate("usb_xbar", "xbar_divbus", base + 0x50, 30); + clks[IMX8ULP_CLK_ENET] = imx8ulp_clk_hw_composite("enet", nic_per_divplat, 1, false, false, true, base + 0x54, 1); + clks[IMX8ULP_CLK_RGPIOE] = imx_clk_hw_gate("rgpioe", "nic_per_divplat", base + 0x78, 30); + clks[IMX8ULP_CLK_RGPIOF] = imx_clk_hw_gate("rgpiof", "nic_per_divplat", base + 0x7c, 30); + + imx_check_clk_hws(clks, clk_data->num); + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); +} + +static int imx8ulp_clk_pcc5_init(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct clk_hw_onecell_data *clk_data; + struct clk_hw **clks; + void __iomem *base; + + clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_PCC5_END), + GFP_KERNEL); + if (!clk_data) + return -ENOMEM; + + clk_data->num = IMX8ULP_CLK_PCC5_END; + clks = clk_data->hws; + + /* PCC5 */ + base = devm_platform_ioremap_resource(pdev, 0); + if (WARN_ON(IS_ERR(base))) + return PTR_ERR(base); + + clks[IMX8ULP_CLK_DMA2_MP] = imx_clk_hw_gate("pcc_dma2_mp", "lpav_axi_div", base + 0x0, 30); + clks[IMX8ULP_CLK_DMA2_CH0] = imx_clk_hw_gate("pcc_dma2_ch0", "lpav_axi_div", base + 0x4, 30); + clks[IMX8ULP_CLK_DMA2_CH1] = imx_clk_hw_gate("pcc_dma2_ch1", "lpav_axi_div", base + 0x8, 30); + clks[IMX8ULP_CLK_DMA2_CH2] = imx_clk_hw_gate("pcc_dma2_ch2", "lpav_axi_div", base + 0xc, 30); + clks[IMX8ULP_CLK_DMA2_CH3] = imx_clk_hw_gate("pcc_dma2_ch3", "lpav_axi_div", base + 0x10, 30); + clks[IMX8ULP_CLK_DMA2_CH4] = imx_clk_hw_gate("pcc_dma2_ch4", "lpav_axi_div", base + 0x14, 30); + clks[IMX8ULP_CLK_DMA2_CH5] = imx_clk_hw_gate("pcc_dma2_ch5", "lpav_axi_div", base + 0x18, 30); + clks[IMX8ULP_CLK_DMA2_CH6] = imx_clk_hw_gate("pcc_dma2_ch6", "lpav_axi_div", base + 0x1c, 30); + clks[IMX8ULP_CLK_DMA2_CH7] = imx_clk_hw_gate("pcc_dma2_ch7", "lpav_axi_div", base + 0x20, 30); + clks[IMX8ULP_CLK_DMA2_CH8] = imx_clk_hw_gate("pcc_dma2_ch8", "lpav_axi_div", base + 0x24, 30); + clks[IMX8ULP_CLK_DMA2_CH9] = imx_clk_hw_gate("pcc_dma2_ch9", "lpav_axi_div", base + 0x28, 30); + clks[IMX8ULP_CLK_DMA2_CH10] = imx_clk_hw_gate("pcc_dma2_ch10", "lpav_axi_div", base + 0x2c, 30); + clks[IMX8ULP_CLK_DMA2_CH11] = imx_clk_hw_gate("pcc_dma2_ch11", "lpav_axi_div", base + 0x30, 30); + clks[IMX8ULP_CLK_DMA2_CH12] = imx_clk_hw_gate("pcc_dma2_ch12", "lpav_axi_div", base + 0x34, 30); + clks[IMX8ULP_CLK_DMA2_CH13] = imx_clk_hw_gate("pcc_dma2_ch13", "lpav_axi_div", base + 0x38, 30); + clks[IMX8ULP_CLK_DMA2_CH14] = imx_clk_hw_gate("pcc_dma2_ch14", "lpav_axi_div", base + 0x3c, 30); + clks[IMX8ULP_CLK_DMA2_CH15] = imx_clk_hw_gate("pcc_dma2_ch15", "lpav_axi_div", base + 0x40, 30); + clks[IMX8ULP_CLK_DMA2_CH16] = imx_clk_hw_gate("pcc_dma2_ch16", "lpav_axi_div", base + 0x44, 30); + clks[IMX8ULP_CLK_DMA2_CH17] = imx_clk_hw_gate("pcc_dma2_ch17", "lpav_axi_div", base + 0x48, 30); + clks[IMX8ULP_CLK_DMA2_CH18] = imx_clk_hw_gate("pcc_dma2_ch18", "lpav_axi_div", base + 0x4c, 30); + clks[IMX8ULP_CLK_DMA2_CH19] = imx_clk_hw_gate("pcc_dma2_ch19", "lpav_axi_div", base + 0x50, 30); + clks[IMX8ULP_CLK_DMA2_CH20] = imx_clk_hw_gate("pcc_dma2_ch20", "lpav_axi_div", base + 0x54, 30); + clks[IMX8ULP_CLK_DMA2_CH21] = imx_clk_hw_gate("pcc_dma2_ch21", "lpav_axi_div", base + 0x58, 30); + clks[IMX8ULP_CLK_DMA2_CH22] = imx_clk_hw_gate("pcc_dma2_ch22", "lpav_axi_div", base + 0x5c, 30); + clks[IMX8ULP_CLK_DMA2_CH23] = imx_clk_hw_gate("pcc_dma2_ch23", "lpav_axi_div", base + 0x60, 30); + clks[IMX8ULP_CLK_DMA2_CH24] = imx_clk_hw_gate("pcc_dma2_ch24", "lpav_axi_div", base + 0x64, 30); + clks[IMX8ULP_CLK_DMA2_CH25] = imx_clk_hw_gate("pcc_dma2_ch25", "lpav_axi_div", base + 0x68, 30); + clks[IMX8ULP_CLK_DMA2_CH26] = imx_clk_hw_gate("pcc_dma2_ch26", "lpav_axi_div", base + 0x6c, 30); + clks[IMX8ULP_CLK_DMA2_CH27] = imx_clk_hw_gate("pcc_dma2_ch27", "lpav_axi_div", base + 0x70, 30); + clks[IMX8ULP_CLK_DMA2_CH28] = imx_clk_hw_gate("pcc_dma2_ch28", "lpav_axi_div", base + 0x74, 30); + clks[IMX8ULP_CLK_DMA2_CH29] = imx_clk_hw_gate("pcc_dma2_ch29", "lpav_axi_div", base + 0x78, 30); + clks[IMX8ULP_CLK_DMA2_CH30] = imx_clk_hw_gate("pcc_dma2_ch30", "lpav_axi_div", base + 0x7c, 30); + clks[IMX8ULP_CLK_DMA2_CH31] = imx_clk_hw_gate("pcc_dma2_ch31", "lpav_axi_div", base + 0x80, 30); + + clks[IMX8ULP_CLK_AVD_SIM] = imx_clk_hw_gate("avd_sim", "lpav_bus_div", base + 0x94, 30); + clks[IMX8ULP_CLK_TPM8] = imx8ulp_clk_hw_composite("tpm8", pcc5_periph_bus_sels, ARRAY_SIZE(pcc5_periph_bus_sels), true, true, true, base + 0xa0, 1); + clks[IMX8ULP_CLK_MU2_B] = imx_clk_hw_gate("mu2_b", "lpav_bus_div", base + 0x84, 30); + clks[IMX8ULP_CLK_MU3_B] = imx_clk_hw_gate("mu3_b", "lpav_bus_div", base + 0x88, 30); + clks[IMX8ULP_CLK_SAI6] = imx8ulp_clk_hw_composite("sai6", lpav_bus_div, 1, false, false, true, base + 0xa4, 1); + clks[IMX8ULP_CLK_SAI7] = imx8ulp_clk_hw_composite("sai7", lpav_bus_div, 1, false, false, true, base + 0xa8, 1); + clks[IMX8ULP_CLK_SPDIF] = imx8ulp_clk_hw_composite("spdif", lpav_bus_div, 1, false, false, true, base + 0xac, 1); + clks[IMX8ULP_CLK_ISI] = imx8ulp_clk_hw_composite("isi", lpav_axi_div, 1, false, false, true, base + 0xb0, 1); + clks[IMX8ULP_CLK_CSI_REGS] = imx8ulp_clk_hw_composite("csi_regs", lpav_bus_div, 1, false, false, true, base + 0xb4, 1); + clks[IMX8ULP_CLK_CSI] = imx8ulp_clk_hw_composite("csi", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xbc, 1); + clks[IMX8ULP_CLK_DSI] = imx8ulp_clk_hw_composite("dsi", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xc0, 1); + clks[IMX8ULP_CLK_WDOG5] = imx8ulp_clk_hw_composite("wdog5", pcc5_periph_bus_sels, ARRAY_SIZE(pcc5_periph_bus_sels), true, true, true, base + 0xc8, 1); + clks[IMX8ULP_CLK_EPDC] = imx8ulp_clk_hw_composite("epdc", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xcc, 1); + clks[IMX8ULP_CLK_PXP] = imx8ulp_clk_hw_composite("pxp", lpav_axi_div, 1, false, false, true, base + 0xd0, 1); + clks[IMX8ULP_CLK_GPU2D] = imx8ulp_clk_hw_composite("gpu2d", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xf0, 1); + clks[IMX8ULP_CLK_GPU3D] = imx8ulp_clk_hw_composite("gpu3d", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xf4, 1); + clks[IMX8ULP_CLK_DC_NANO] = imx8ulp_clk_hw_composite("dc_nano", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0xf8, 1); + clks[IMX8ULP_CLK_CSI_CLK_UI] = imx8ulp_clk_hw_composite("csi_clk_ui", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0x10c, 1); + clks[IMX8ULP_CLK_CSI_CLK_ESC] = imx8ulp_clk_hw_composite("csi_clk_esc", pcc5_periph_plat_sels, ARRAY_SIZE(pcc5_periph_plat_sels), true, true, true, base + 0x110, 1); + clks[IMX8ULP_CLK_RGPIOD] = imx_clk_hw_gate("rgpiod", "lpav_axi_div", base + 0x114, 30); + clks[IMX8ULP_CLK_DSI_TX_ESC] = imx_clk_hw_fixed_factor("mipi_dsi_tx_esc", "dsi", 1, 4); + + imx_check_clk_hws(clks, clk_data->num); + + return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); +} + +static int imx8ulp_clk_probe(struct platform_device *pdev) +{ + int (*probe)(struct platform_device *pdev); + + probe = of_device_get_match_data(&pdev->dev); + + if (probe) + return probe(pdev); + + return 0; +} + +static const struct of_device_id imx8ulp_clk_dt_ids[] = { + { .compatible = "fsl,imx8ulp-pcc3", .data = imx8ulp_clk_pcc3_init }, + { .compatible = "fsl,imx8ulp-pcc4", .data = imx8ulp_clk_pcc4_init }, + { .compatible = "fsl,imx8ulp-pcc5", .data = imx8ulp_clk_pcc5_init }, + { .compatible = "fsl,imx8ulp-cgc2", .data = imx8ulp_clk_cgc2_init }, + { .compatible = "fsl,imx8ulp-cgc1", .data = imx8ulp_clk_cgc1_init }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, imx8ulp_clk_dt_ids); + +static struct platform_driver imx8ulp_clk_driver = { + .probe = imx8ulp_clk_probe, + .driver = { + .name = KBUILD_MODNAME, + .of_match_table = imx8ulp_clk_dt_ids, + }, +}; +module_platform_driver(imx8ulp_clk_driver); + +MODULE_AUTHOR("Peng Fan "); +MODULE_DESCRIPTION("NXP i.MX8ULP clock driver"); +MODULE_LICENSE("GPL v2"); From patchwork Tue Sep 14 06:52:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Bai X-Patchwork-Id: 511127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79D0DC433F5 for ; Tue, 14 Sep 2021 06:41:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CFF861159 for ; Tue, 14 Sep 2021 06:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240136AbhINGnH (ORCPT ); Tue, 14 Sep 2021 02:43:07 -0400 Received: from mail-vi1eur05on2050.outbound.protection.outlook.com ([40.107.21.50]:22625 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239015AbhINGnF (ORCPT ); Tue, 14 Sep 2021 02:43:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fYV7aiFnStjOItNeLK/FOo/V391XoBhlMdikBHqApJhgvhF58lxFRjgXK4yrn24zBgOsMb/feil+MsweVNbZ0nIM1ZJDvAIRCyh0xUkideBlO1PboSLofSr8oO4eb6h8YjBGTosxj0PVBM49mKhUe62+4YfIzAIp1qW+KtvyegIImZWZ9vJfP2khqEaJ3osNnd0pmc7SiwxYIET9rsE7BegKmP6DeoQMyaE2bgI9sqveXu2NQb3Y23Y9NK6dBisqBUYtgR2qhZ+osk78xYEBzVS4wxHMtaF3cS4JSud4e910y29UKebten4btpV+U2QrC4EHR83PdcBtBqxT52xDNA== 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; bh=fdv8rIDEd3PXz1s1X5tqNDscqBBXgW2KfrZsS44Yegw=; b=eTCnYxcTdJwpTAVgKt2HQSIsw0hYIcQodY85xxo2IrYzOTZQP0PkQYCil99tXIlN7E8HQRUemFM0X1QtdnOa/TFo/n8GnySYz1T6l8z8SrkBf5wYTBVqYhkLgWrs2b60UDz9r+eCXXpyk2c0RN8wvqTsYwRfzpF26xFwMh7oD3X2/DW9ReNxrtMJ7Bi7c7veIo+DA8A9u1jyNBsSW/RpjaTTkGGeAxE0i+6gDVSr42kaOj4ZufyxoB4UTbTncH33eRKTXjligj/QOanWAj3MgTb3SiBO/bxL2Uo/HXhouJ1iF3y6MbuL0/fnqbFf9TFv4151WM/ySYhLTJucv1VtWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fdv8rIDEd3PXz1s1X5tqNDscqBBXgW2KfrZsS44Yegw=; b=mHkY/NjbyMfhRcUHS0J33HYr3tRBsJoiiVkAz2OxEbTDd8WQSe/07lC70TqRUV7FQbXiPiaCjtOvVWp78VFuF4Ks5SIHyn3J41+oF+szxqQ7v/g6Rz5CO2FtPiwPrvsxE6Mld7cVVzTnj1GCnchropPzH51+VFrpKYDkMCQOgz4= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) by DB3PR0402MB3658.eurprd04.prod.outlook.com (2603:10a6:8:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Tue, 14 Sep 2021 06:41:44 +0000 Received: from DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e]) by DBBPR04MB7930.eurprd04.prod.outlook.com ([fe80::55b5:93f6:50b1:a49e%3]) with mapi id 15.20.4500.018; Tue, 14 Sep 2021 06:41:44 +0000 From: Jacky Bai To: shawnguo@kernel.org, robh+dt@kernel.org, abel.vesa@nxp.com, sboyd@kernel.org, s.hauer@pengutronix.de, p.zabel@pengutronix.de Cc: kernel@pengutronix.de, linux-imx@nxp.com, devicetree@vger.kernel.org Subject: [PATCH v3 9/9] clk: imx: Add the pcc reset controller support on imx8ulp Date: Tue, 14 Sep 2021 14:52:08 +0800 Message-Id: <20210914065208.3582128-10-ping.bai@nxp.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210914065208.3582128-1-ping.bai@nxp.com> References: <20210914065208.3582128-1-ping.bai@nxp.com> X-ClientProxiedBy: SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) To DBBPR04MB7930.eurprd04.prod.outlook.com (2603:10a6:10:1ea::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (119.31.174.71) by SGAP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Tue, 14 Sep 2021 06:41:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d9dc45bd-79c0-4a3c-3fc0-08d9774ab774 X-MS-TrafficTypeDiagnostic: DB3PR0402MB3658: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0gFVr82+Il88uaZt0DEywhq0GozPu2tSi+KEDDfWVQQDzhcurxF3NWk7s3WfoGg6wfQKAjnpyE3lJDMjaTPAZ1q6BU1e8+lsFJe0q5L5lr0/yO9pTIR0p1ODWUZQ6tYfIzCEoHdUo6JlBXUkudEJ5jp1QqN5Fh9eSB3di6XEJQf1X5+yydQ3DuNj7g/+jdSrIp1robNSREAT/o1wO5OqsmbmFbqYj6nhqQovvz2FeFafdHPk+hwClIvxpUNKB6rdMHWJUadwCncEp5myToI8Mq+OCyT4YlmQrFQLGbeC+DeWc5DqBAvo59o8KkWeFxhcOWGwJm4uxHczQ40IhVvQoEk1r4AFuy53TDtxZR/Fz1/brab63K0gtUd+Sbm3gHVgKeI1E2jTzp1+ZH9E3elJnLt9lzlNWmIPYnjfm1ZAl8PL6wT3T0e13F+onQpFYEHt8fQJkLICC6fJdApDsJdvh6bnsYMAFJIELhsC4aATP3yXJuW2pA7q72PnIMEeay37EfASgmqQ1lUgcjwxx8lUV+LJzho8OJHYqlFTu94v1rEogRCqPW/YB8hiZ9Tcs+RzVylDUlkA5+yGGsWJgKpPumuDdp58kc5Wqxv4ENi+twsKMVrYdetr7PvQksPZR+xylySLJ3hVNLYiWFq0LkZUgVP0UTH9Mv/UQIfV02pqEadKE0JhMlQxHNoX0+WS8dgbtoNlh2pJBi/wCuG4oHLCFTGCAyz9KjRvHU24FDPg79g= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR04MB7930.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(136003)(346002)(39860400002)(376002)(366004)(316002)(4326008)(86362001)(52116002)(5660300002)(186003)(2906002)(6512007)(26005)(83380400001)(956004)(6666004)(66556008)(66946007)(66476007)(6486002)(8936002)(38350700002)(38100700002)(36756003)(8676002)(1076003)(6506007)(478600001)(2616005)(32563001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: D/AeAziRz7Btr4oqjPTCeYn127/7lDZK97BdQfZuPufEoUa8VEII6Yf/9w81oGFttTEgxHX1L3jtIrrsI5A4piwwbghwDkNFxl8Th66krpYbaMTu7V+ZivwyfCWcWFV3BfrNunwr0JT+z5rda00es5guxs7iTb7z6tSgNmVQNuaUdJ1VFWPCGhpoDX1MPgdRcjJ8r5kobSrvuV6/U/4udxczZx9UsUZPECT/ZNlJo2p0M+Y7iGuTqUJ+/5DQkhtEF+H8ALVB7ttU54LCTXNdVayRG4H2jU8ehd3gp9E3KEaJaXsKxQJiS4ocy3cpV+fWjWVbJ6kNkPoY+JCSoOVRL/Op8ZnM5L+VTrKflCzV1xDHJrolcfWg5bipn5lcxfDBP/H0/H7w5SPuGYwJ8OVnEVdOMCa29/yG8RdjJvkCYe3RynHPjuh2oeDkFNnkEv7EqrWD3rsEpasnkbvf2WY58lqcfXbREaRtHywbLaVVqF4o6u20baIDvdXmoKITqQxeQJFxIfE5wg4EpjLFf12RxRmT9QukGN8p5XgOD3U0l57MhzK9pof8gfOP3rPop3IUPxJZYCS2Pm2qN+8CsSbAWi376gP6o7YTPtMY7K5a1+3eSMxtBViAqKZLiCQT2OtJCrIjY7Oyly6/8P7IDkqRES5H0I6vgZE1vIDrkqvONVOongm0pEouTfDuODTdM6zN2JASCYBNlP6v2IjACucZbbpAjN32rewZZRU2x+iMd4Aw6la4JmRGiErrJfpmQLkH9CTuIbxItHPPWcmJdjQyaJh5pQPIMHspBVv+4FqCsM3ferksv6WG8BDsUqOExGmiYNyGbW0WTv/C1fMDosVpvKt7qrOUPC8xG+sk5PEE2jFj9mttULTGAFP2Axh1NQyDzICZE+/Gh/cdIbrWhn0bUJfnKH3oVhRZ5eDUczzIe9qmw0ipo6bf+a0GDuTfQ5bTJybgh3UkWKX4iwxzL6wxN0jZLVznYV0GYT0eO5mGDjq1aLlyO8gjOi8UdbAg294tf4no5ds0FakNdnTOTRkj1xwyVCb/noxQO5Pyq4PWIPevK0DaNlZxnmOgqN2R1upJQY8TG+FL/RcofJmr80POSRG4oWvaAUYCHtYtR7K9d3koHAH3cGa3ZsMeGmgbSVGGD8FSH5/dNucy4ULm/dHIO5sJ0HP6Kgy9XfCh4T/6jRxPui7S9oKhTznGQgpWi+MbJ73ytC43o3PuMhLGcG2BeYGrshGvceEn0xL2zBiCYhCKRvPal6SBaY3g/NW3hCVhjoTgNfwV53oDEpPHD04FFLJIUs96CLMjrVWlwUL1/XLnNgliOfHG4D8Rogbp6ixE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d9dc45bd-79c0-4a3c-3fc0-08d9774ab774 X-MS-Exchange-CrossTenant-AuthSource: DBBPR04MB7930.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 06:41:44.1836 (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: sEg1e+fwazhSLkNFMw/81qeCxImEt6MbV0nJCEdTByaUPJIj7sjBNl0KlHej2iu6BJYM+gVMNeBAGeRelJhAsw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3658 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On i.MX8ULP, for some of the PCCs, it has a peripheral SW RST bit resides in the same registers as the clock controller. So add this SW RST controller support alongs with the pcc clock initialization. the reset and clock shared the same register, to avoid accessing the same register by reset control and clock control concurrently, locking is necessary, so reuse the imx_ccm_lock spinlock to simplify the code. Suggested-by: Liu Ying Signed-off-by: Jacky Bai Reviewed-by: Abel Vesa --- v3 changes: - remove the explict selection of 'RESET_CONTROLLER' in kconfig - add some comments for the spinlock of reset driver v2 changes: - add 'Suggested-by' as suggested by Victor Liu --- drivers/clk/imx/clk-composite-7ulp.c | 10 +++ drivers/clk/imx/clk-imx8ulp.c | 116 ++++++++++++++++++++++++++- 2 files changed, 123 insertions(+), 3 deletions(-) diff --git a/drivers/clk/imx/clk-composite-7ulp.c b/drivers/clk/imx/clk-composite-7ulp.c index 9ce8c630ee32..89106de16a3f 100644 --- a/drivers/clk/imx/clk-composite-7ulp.c +++ b/drivers/clk/imx/clk-composite-7ulp.c @@ -29,6 +29,7 @@ static int pcc_gate_enable(struct clk_hw *hw) { struct clk_gate *gate = to_clk_gate(hw); + unsigned long flags; u32 val; int ret; @@ -36,6 +37,7 @@ static int pcc_gate_enable(struct clk_hw *hw) if (ret) return ret; + spin_lock_irqsave(gate->lock, flags); /* * release the sw reset for peripherals associated with * with this pcc clock. @@ -44,6 +46,8 @@ static int pcc_gate_enable(struct clk_hw *hw) val |= SW_RST; writel(val, gate->reg); + spin_unlock_irqrestore(gate->lock, flags); + return 0; } @@ -84,6 +88,8 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name, mux->reg = reg; mux->shift = PCG_PCS_SHIFT; mux->mask = PCG_PCS_MASK; + if (has_swrst) + mux->lock = &imx_ccm_lock; } if (rate_present) { @@ -101,6 +107,8 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name, fd->nwidth = PCG_PCD_WIDTH; fd->nmask = PCG_PCD_MASK; fd->flags = CLK_FRAC_DIVIDER_ZERO_BASED; + if (has_swrst) + fd->lock = &imx_ccm_lock; } if (gate_present) { @@ -113,6 +121,8 @@ static struct clk_hw *imx_ulp_clk_hw_composite(const char *name, gate_hw = &gate->hw; gate->reg = reg; gate->bit_idx = PCG_CGC_SHIFT; + if (has_swrst) + gate->lock = &imx_ccm_lock; /* * make sure clock is gated during clock tree initialization, * the HW ONLY allow clock parent/rate changed with clock gated, diff --git a/drivers/clk/imx/clk-imx8ulp.c b/drivers/clk/imx/clk-imx8ulp.c index 6aad04114658..6699437e17b8 100644 --- a/drivers/clk/imx/clk-imx8ulp.c +++ b/drivers/clk/imx/clk-imx8ulp.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "clk.h" @@ -48,6 +49,99 @@ static const char * const nic_per_divplat[] = { "nic_per_divplat" }; static const char * const lpav_axi_div[] = { "lpav_axi_div" }; static const char * const lpav_bus_div[] = { "lpav_bus_div" }; +struct pcc_reset_dev { + void __iomem *base; + struct reset_controller_dev rcdev; + const u32 *resets; + /* Set to imx_ccm_lock to protect register access shared with clock control */ + spinlock_t *lock; +}; + +#define PCC_SW_RST BIT(28) +#define to_pcc_reset_dev(_rcdev) container_of(_rcdev, struct pcc_reset_dev, rcdev) + +static const u32 pcc3_resets[] = { + 0xa8, 0xac, 0xc8, 0xcc, 0xd0, + 0xd4, 0xd8, 0xdc, 0xe0, 0xe4, + 0xe8, 0xec, 0xf0 +}; + +static const u32 pcc4_resets[] = { + 0x4, 0x8, 0xc, 0x10, 0x14, + 0x18, 0x1c, 0x20, 0x24, 0x34, + 0x38, 0x3c, 0x40, 0x44, 0x48, + 0x4c, 0x54 +}; + +static const u32 pcc5_resets[] = { + 0xa0, 0xa4, 0xa8, 0xac, 0xb0, + 0xb4, 0xbc, 0xc0, 0xc8, 0xcc, + 0xd0, 0xf0, 0xf4, 0xf8 +}; + +static int imx8ulp_pcc_assert(struct reset_controller_dev *rcdev, unsigned long id) +{ + struct pcc_reset_dev *pcc_reset = to_pcc_reset_dev(rcdev); + u32 offset = pcc_reset->resets[id]; + unsigned long flags; + u32 val; + + spin_lock_irqsave(pcc_reset->lock, flags); + + val = readl(pcc_reset->base + offset); + val &= ~PCC_SW_RST; + writel(val, pcc_reset->base + offset); + + spin_unlock_irqrestore(pcc_reset->lock, flags); + + return 0; +} + +static int imx8ulp_pcc_deassert(struct reset_controller_dev *rcdev, unsigned long id) +{ + struct pcc_reset_dev *pcc_reset = to_pcc_reset_dev(rcdev); + u32 offset = pcc_reset->resets[id]; + unsigned long flags; + u32 val; + + spin_lock_irqsave(pcc_reset->lock, flags); + + val = readl(pcc_reset->base + offset); + val |= PCC_SW_RST; + writel(val, pcc_reset->base + offset); + + spin_unlock_irqrestore(pcc_reset->lock, flags); + + return 0; +} + +static const struct reset_control_ops imx8ulp_pcc_reset_ops = { + .assert = imx8ulp_pcc_assert, + .deassert = imx8ulp_pcc_deassert, +}; + +static int imx8ulp_pcc_reset_init(struct platform_device *pdev, void __iomem *base, + const u32 *resets, unsigned int nr_resets) +{ + struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + struct pcc_reset_dev *pcc_reset; + + pcc_reset = devm_kzalloc(dev, sizeof(*pcc_reset), GFP_KERNEL); + if (!pcc_reset) + return -ENOMEM; + + pcc_reset->base = base; + pcc_reset->lock = &imx_ccm_lock; + pcc_reset->resets = resets; + pcc_reset->rcdev.owner = THIS_MODULE; + pcc_reset->rcdev.nr_resets = nr_resets; + pcc_reset->rcdev.ops = &imx8ulp_pcc_reset_ops; + pcc_reset->rcdev.of_node = np; + + return devm_reset_controller_register(dev, &pcc_reset->rcdev); +} + static int imx8ulp_clk_cgc1_init(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -288,10 +382,13 @@ static int imx8ulp_clk_pcc3_init(struct platform_device *pdev) imx_check_clk_hws(clks, clk_data->num); ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + if (ret) + return ret; imx_register_uart_clocks(1); - return ret; + /* register the pcc3 reset controller */ + return imx8ulp_pcc_reset_init(pdev, base, pcc3_resets, ARRAY_SIZE(pcc3_resets)); } static int imx8ulp_clk_pcc4_init(struct platform_device *pdev) @@ -300,6 +397,7 @@ static int imx8ulp_clk_pcc4_init(struct platform_device *pdev) struct clk_hw_onecell_data *clk_data; struct clk_hw **clks; void __iomem *base; + int ret; clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_PCC4_END), GFP_KERNEL); @@ -339,7 +437,13 @@ static int imx8ulp_clk_pcc4_init(struct platform_device *pdev) imx_check_clk_hws(clks, clk_data->num); - return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + if (ret) + return ret; + + /* register the pcc4 reset controller */ + return imx8ulp_pcc_reset_init(pdev, base, pcc4_resets, ARRAY_SIZE(pcc4_resets)); + } static int imx8ulp_clk_pcc5_init(struct platform_device *pdev) @@ -348,6 +452,7 @@ static int imx8ulp_clk_pcc5_init(struct platform_device *pdev) struct clk_hw_onecell_data *clk_data; struct clk_hw **clks; void __iomem *base; + int ret; clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, IMX8ULP_CLK_PCC5_END), GFP_KERNEL); @@ -420,7 +525,12 @@ static int imx8ulp_clk_pcc5_init(struct platform_device *pdev) imx_check_clk_hws(clks, clk_data->num); - return devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, clk_data); + if (ret) + return ret; + + /* register the pcc5 reset controller */ + return imx8ulp_pcc_reset_init(pdev, base, pcc5_resets, ARRAY_SIZE(pcc5_resets)); } static int imx8ulp_clk_probe(struct platform_device *pdev)