From patchwork Mon May 15 13:59:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9727053 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0AEE760380 for ; Mon, 15 May 2017 14:01:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF2B12885B for ; Mon, 15 May 2017 14:01:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E385728965; Mon, 15 May 2017 14:01:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9BE72885B for ; Mon, 15 May 2017 14:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965249AbdEOOAu (ORCPT ); Mon, 15 May 2017 10:00:50 -0400 Received: from mail-sn1nam02on0049.outbound.protection.outlook.com ([104.47.36.49]:51200 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965338AbdEON7u (ORCPT ); Mon, 15 May 2017 09:59:50 -0400 Received: from DM5PR03CA0004.namprd03.prod.outlook.com (10.175.104.14) by BLUPR03MB166.namprd03.prod.outlook.com (10.255.212.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16; Mon, 15 May 2017 13:59:48 +0000 Received: from BY2FFO11FD034.protection.gbl (2a01:111:f400:7c0c::119) by DM5PR03CA0004.outlook.office365.com (2603:10b6:3:118::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1084.16 via Frontend Transport; Mon, 15 May 2017 13:59:48 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD034.mail.protection.outlook.com (10.1.14.219) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1075.5 via Frontend Transport; Mon, 15 May 2017 13:59:47 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.182]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v4FDxEqp015180; Mon, 15 May 2017 06:59:44 -0700 From: Dong Aisheng To: CC: , , , , , , , Dong Aisheng Subject: [PATCH 9/9] clk: imx: add imx7ulp clk driver Date: Mon, 15 May 2017 21:59:23 +0800 Message-ID: <1494856763-6543-10-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1494856763-6543-1-git-send-email-aisheng.dong@nxp.com> References: <1494856763-6543-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131393303877210167; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39400400002)(39380400002)(39410400002)(39840400002)(39450400003)(39860400002)(39850400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(9170700003)(36756003)(2950100002)(6666003)(6916009)(38730400002)(110136004)(8676002)(2906002)(76176999)(50986999)(4326008)(356003)(5660300001)(68736007)(305945005)(5003940100001)(81166006)(8936002)(86362001)(105606002)(77096006)(50226002)(106466001)(33646002)(50466002)(2351001)(85426001)(189998001)(104016004)(48376002)(53936002)(47776003)(8656002)(54906002)(6306002)(498600001)(966004); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR03MB166; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD034; 1:9WTgSSEXpHzMXcilO2eRxpIhHV5Mhw8rsqnbHU0FSxYPrGEa4kR2/7EDbPlbt1UDYTDgteNENLA3WYLVHVlyWd6ZTFR3nKW1ao5u04XR0ijvXVte7a6DnDPKV1aIeIl7FujrfhZv9q7wkK0b4MAwkhl8Np/sFM4FUTi4f53JnDD/Iw8rJsB/FIcwvFmJZDBHSMRmzECVSsSholXMR+6b9JILMP0ba/04Hp6cvH7Q0Svfk2Ldj4OWrrutjxdI0WmREt+hClYP2DUUED+GfTtC5Koatd0iH1TunsPkaf2qJ5449qX8PIYoWDnBV4VXWL+jEKxcNsmoOy7K/RTiH5pW3pI3GjzESA4cRcBdwmnjaVwuyGnEyyWf1mw8lbiSjdbqhhYRwkDeHUIRTn0ZlA9IzLz135cabqLpQxfxyWcN6BPMV/SYR+OHJEADExWe+t0JdJ9OA/LupFDQ9hKg30Wlb13u1dsH7kVichgjQbgDgJJ9MsiuXyr2usipyoF4N3McY1V2KfLQ05hKTfip4oXo5OFmZ3FXIiB6UvopdHYIRwARac6rgawyS99zNULkx/LEVuN/kZb+f/RYRe0RXH/ms3XoPHpTqUDCSMAGazqCiwcIbezXXXVGORMgtXd/BeNqQpqqTJClgCKQqGkQMVdU4K+/OZuDXgJG4it/mpViU70NwXXbp/4C5u4Ck4c4dxuQIi1MbBy2jurRNK4cfaqChp23SCtVumBeRWlfVksfLdQ= MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 337bf783-d90c-40ca-4537-08d49b9aa5db X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BLUPR03MB166; X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB166; 3:GMG0HyimP0BXR+oXjhQOM8nzwsRSpdjbsy9RcFpQd1EaIsiPEtFpBxmoT8m+0FYRTbQgzFWb4r9uBR2NZwT9liJczBdeSnkEKpD9jkyDJqX6FR9akdUZm7Mj3XkJUr50Bxk5k7ojNDUyVwjS0THao3qGoe2vIRlexGo15Ys/+xy9pSQS7FNQPXTLTroGycWLMeo5Vd0/2qf/aXeC2in5+F+UBUxfa//BhvA/6VRp+eKslHWBi2VuPOe8kDaQBczMxeL2a0WWHHMGJP/GBTF0Ji3A7Eo0nBQ2WvFVeMlZdAqD98zNUIsFA+K+1G/sI7SDkRm3Bi2RRD6V7l6WyT0KQr1p462E9j+EExMgU2nrtIqPpVc+GBb52BuakPnQD3yQAaPAVsxS9wEczf2nxw66nl3cNWQed14zGlzxo59qWUx+K72sucyPeGzSDskI12Al; 25:94nFoiFNXGl5/TA2wVFKXobmftIwURJUtZTtIad8JAZlK1Pqi1PawHzKdudaPPhGsrbKq4FFXTgVkXVtPw/e1aRAF5m9HXKENqjqJrqkbI+gl1strnijoHLoKAWkmgyKtF3OzqfSY/sgIGwUXd6UAlrFuJVKtOEBboyZZqPeroaFzVCoVyAIIU06cM+7dVdN0OsrqY60R+UPBe1Jei+TEFNZ2cnjqObl2pGn8iFrhDL/0hbeUG+Z0OAq89w0ypwCHfeNScZFPiCZYha6LYrH63ZrtW3evMcy5RwulDHyq8nx4BoGvuQpjH9c3kZ/jAWKaglSJ0LFwf7MKYqa5Xs8qkXMMlNaYtx1rwDJiSoA3G0KzCODCovT2HXCdNdSczdW23dA9FltpqqbXWUN6pPweyU3833Ut1HFsA3IupCQykFvCETOpma2zTxn3cRM8X19nPRaKqwkX3JDaPI7o3lhiQ== X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB166; 31:xrVX1ZN7s0BDGRw8fgtbEUyldZ6o3C77uMeYW7U0B4CGtTVks0Gt6qf6GiblVH9sXpALl1l2OIBtbldn7t9cbSPb82qCBhKBIGJNXhu+EC6czjhjh7ZM87ewXDquXzOcRvQjJM3dGbm/r1H85ZaAb0NlpIDNYcQOF1QkjGDjtSOK/jGmn4LffJcqS4Rl5pqnyxg04TFjjmPm4jCOCWToLaPzEVkx5FmWneE4XZQ1JmbQl4sx1ti2VDFAO8KJgGkC X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030)(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13023025)(13024025)(13018025)(13015025)(5005006)(8121501046)(13017025)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123561025)(20161123565025)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123556025)(20161123559100)(20161123563025); SRVR:BLUPR03MB166; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR03MB166; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB166; 4:GSMB40Rj3wmfg5qoJVY2iE4WmazZ/GKx6aTv/RxEL7G?= =?us-ascii?Q?R5cj6EBBdpqa5LPlz0xLU/g/OP64RaZHfVwczvfELHEjNJUC1pIryOARYbXw?= =?us-ascii?Q?sL7xs23X+vuuPZ9vtl99a/Lf5DVMSN0rsYOZkfOffUBbODfT/M8nNdU0Wz5Z?= =?us-ascii?Q?UBUl+Xdelg6QRu4gHkaR1UjB0lf6OLs/a7nyGN7Xsp/tYWRXvQvdpY86sFNJ?= =?us-ascii?Q?rhcflPx2yaV+71xuJvnfmPqeBQB2iRJPQkEoIqf0LSxcDT7zUN0Mie76CMQ/?= =?us-ascii?Q?kXL0ODn1vmn4O69U8arnt11DG4NSwCmp8qih5pjebFxmv3YGsHy1kqpqBhYD?= =?us-ascii?Q?EAWFhOm+j19cfHjGkh9hq9ng0i6RQoNVLAM9thMY8wek7iNrsiD0tMDJ09YW?= =?us-ascii?Q?IqeDtmcPjA0qlSL8+BkseAhXKEcIfeC8oUPCVscBf4nNgiAnUGeQzMzVjTU8?= =?us-ascii?Q?V+lydGr2sR0dlItNI63oxOjIW0c0vjXVyKlWKIHSkcIC9MLr01hxbIU4vlfh?= =?us-ascii?Q?7H6NxhCG+M623J/0rpM6q9aXQQMxeVKvXuu7Yu4abjp8A8+zysLoJ7CYdKVT?= =?us-ascii?Q?ioqp8Zbk7QdybasqEIai16P2GsAyuqW/YVLsKdQES5Amk9LEa+YmJmipww5z?= =?us-ascii?Q?E8WUYD0/GAo7rFig2KA5U5LrZHl7qkDAswHJtDv9etTyLZrSZ8fL11pj3SHM?= =?us-ascii?Q?TYwc7DTk7FhJU0tmmyji2EnVQJW5ev588kVjxPArS3jsbalzId7jJcibHh3a?= =?us-ascii?Q?J0H46kUQpUrC2u6L1I2nKLkUN9duxSOCE7F/HltYLqvgBv+7Algg1J/8GIBz?= =?us-ascii?Q?Mbp74WnqsB2gbpsL0jWYQLXAPJgSTAypRJRyjVijOrEbKhQZBAN+tSBPrmby?= =?us-ascii?Q?ntzxej3Fve7ZSoKd9DszBDJ3LI4o3f4OdjYkMXwVuRa0oLAMbbH1M9rV3xd6?= =?us-ascii?Q?sLcw7pCM2ujFEH+h77INVGvV23YpFvirMzs8SR5aE7TOZ6uszzLDZD4GJ8Di?= =?us-ascii?Q?DISabj+UH2d+weohpJMDRMHuWC7wo9kxXupgKyr5edA=3D=3D?= X-Forefront-PRVS: 0308EE423E X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR03MB166; 23:76Wt07kwoSV2/op+Pt4+jZMC56gIHKR+0Z6Sp+sxHv?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==; 5:IyPtz18+4NwSTreu+N9nGLLf8pS3jFZk6imlpcOZwYYaCdavtwLtvF6AAp7/ufMtUE+mk3jiUtCmIknYFJFjDaY6PZYgIAAmy/lt2n1JOcSALaNdqwfb6DNQB9dg1rrGchdFO9amXZ6sWWt7OXh0H354MAF5+OQOcQODvYudziWhAKpZdQwZOeczcb87piQq; 24:Elaf4ZZAlTSA7tgVgq8+AHLmXMescQ7OPsiw/85fW2xXw35vZ4dzfQcnevu6iM0kunRsBBTHlUU2MBkSwbhn+C7Tl1o4HmS1g0Skk9ZTXEE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR03MB166; 7:Q5Suc656KbwybzHw6zrrBP4AyvntFQwvYpnjOPZpYp8pSCAetiUatDUX8Y4eUSnPLAecef9owATDh18kn+GdKMovCjcJkRiZ72RNsPareZFNCXOXff1yACFF4TcSpTqsBUXyFI68Lp7lVrwBKcM9CQIFBr7/y9Hib5sGyFuc4ylD7BLI/rgAAsWdfIxEhhvkZxhKU3cWPs9C02tQs2j7Q02uxnyzS7F+b7M4kTuE7Fmpi2xRZMdl+OViFVIaxnIV2m4Mlxl80CGhoZqyTo5wJmtfCB1aVNNCUyieyJyF62L8WWCyQwz6Zx2zZQ4j0j+FFLaazyGnEEmiPOdiEMab3g== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2017 13:59:47.4090 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB166 Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP i.MX7ULP Clock functions are under joint control of the System Clock Generation (SCG) modules, Peripheral Clock Control (PCC) modules, and Core Mode Controller (CMC)1 blocks The clocking scheme provides clear separation between M4 domain and A7 domain. Except for a few clock sources shared between two domains, such as the System Oscillator clock, the Slow IRC (SIRC), and and the Fast IRC clock (FIRCLK), clock sources and clock management are separated and contained within each domain. M4 clock management consists of SCG0, PCC0, PCC1, and CMC0 modules. A7 clock management consists of SCG1, PCC2, PCC3, and CMC1 modules. This driver only adds clock support in A7 domain. Note that most clocks required to be operated when gated, e.g. pll, pfd, pcc. And more special cases that scs/ddr/nic mux selecting different clock source requires that clock to be enabled first, then we need set CLK_OPS_PARENT_ENABLE flag for them properly. Cc: Stephen Boyd Cc: Michael Turquette Cc: Shawn Guo Cc: Anson Huang Cc: Bai Ping Signed-off-by: Dong Aisheng --- drivers/clk/imx/Makefile | 1 + drivers/clk/imx/clk-imx7ulp.c | 171 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 drivers/clk/imx/clk-imx7ulp.c diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile index bf001ce..6f013e0 100644 --- a/drivers/clk/imx/Makefile +++ b/drivers/clk/imx/Makefile @@ -27,4 +27,5 @@ obj-$(CONFIG_SOC_IMX6SL) += clk-imx6sl.o obj-$(CONFIG_SOC_IMX6SX) += clk-imx6sx.o obj-$(CONFIG_SOC_IMX6UL) += clk-imx6ul.o obj-$(CONFIG_SOC_IMX7D) += clk-imx7d.o +obj-$(CONFIG_SOC_IMX7ULP) += clk-imx7ulp.o obj-$(CONFIG_SOC_VF610) += clk-vf610.o diff --git a/drivers/clk/imx/clk-imx7ulp.c b/drivers/clk/imx/clk-imx7ulp.c new file mode 100644 index 0000000..de229ba --- /dev/null +++ b/drivers/clk/imx/clk-imx7ulp.c @@ -0,0 +1,171 @@ +/* + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * Copyright 2017 NXP + * + * Author: Dong Aisheng + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include +#include +#include +#include +#include +#include +#include + +#include "clk.h" + +static const char * const pll_pre_sels[] = { "sosc", "firc", }; +static const char * const spll_pfd_sels[] = { "spll_pfd0", "spll_pfd1", "spll_pfd2", "spll_pfd3", }; +static const char * const spll_sels[] = { "spll", "spll_pfd_sel", }; +static const char * const apll_pfd_sels[] = { "apll_pfd0", "apll_pfd1", "apll_pfd2", "apll_pfd3", }; +static const char * const apll_sels[] = { "apll", "apll_pfd_sel", }; +static const char * const scs_sels[] = { "dummy", "sosc", "sirc", "firc", "dummy", "apll_sel", "spll_sel", "upll", }; +static const char * const ddr_sels[] = { "apll_pfd_sel", "upll", }; +static const char * const nic_sels[] = { "firc", "ddr_clk", }; +static const char * const periph_plat_sels[] = { "dummy", "nic1_bus_clk", "nic1_clk", "ddr_clk", "apll_pfd2", "apll_pfd1", "apll_pfd0", "upll", }; +static const char * const periph_bus_sels[] = { "dummy", "sosc_bus_clk", "mpll", "firc_bus_clk", "rosc", "nic1_bus_clk", "nic1_clk", "spll_bus_clk", }; + +static struct clk *clks[IMX7ULP_CLK_END]; +static struct clk_onecell_data clk_data; + +static void __init imx7ulp_clocks_init(struct device_node *scg_node) +{ + struct device_node *np; + void __iomem *base; + + clks[IMX7ULP_CLK_DUMMY] = imx_clk_fixed("dummy", 0); + + clks[IMX7ULP_CLK_ROSC] = of_clk_get_by_name(scg_node, "rosc"); + clks[IMX7ULP_CLK_SOSC] = of_clk_get_by_name(scg_node, "sosc"); + clks[IMX7ULP_CLK_SIRC] = of_clk_get_by_name(scg_node, "sirc"); + clks[IMX7ULP_CLK_FIRC] = of_clk_get_by_name(scg_node, "firc"); + clks[IMX7ULP_CLK_MIPI_PLL] = of_clk_get_by_name(scg_node, "mpll"); + clks[IMX7ULP_CLK_UPLL] = of_clk_get_by_name(scg_node, "upll"); + + np = scg_node; + base = of_io_request_and_map(np, 0, "scg1"); + WARN_ON(!base); + + /* NOTE: xPLL config can't be changed when xPLL is enabled */ + clks[IMX7ULP_CLK_APLL_PRE_SEL] = imx_clk_mux_flags("apll_pre_sel", base + 0x508, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); + clks[IMX7ULP_CLK_SPLL_PRE_SEL] = imx_clk_mux_flags("spll_pre_sel", base + 0x608, 0, 1, pll_pre_sels, ARRAY_SIZE(pll_pre_sels), CLK_SET_PARENT_GATE); + + /* name parent_name reg shift width flags */ + clks[IMX7ULP_CLK_APLL_PRE_DIV] = imx_clk_divider_flags("apll_pre_div", "apll_pre_sel", base + 0x508, 8, 3, CLK_SET_RATE_GATE); + clks[IMX7ULP_CLK_SPLL_PRE_DIV] = imx_clk_divider_flags("spll_pre_div", "spll_pre_sel", base + 0x608, 8, 3, CLK_SET_RATE_GATE); + + /* name parent_name base */ + clks[IMX7ULP_CLK_APLL] = imx_clk_pllv4("apll", "apll_pre_div", base + 0x500); + clks[IMX7ULP_CLK_SPLL] = imx_clk_pllv4("spll", "spll_pre_div", base + 0x600); + + /* APLL PFDs */ + clks[IMX7ULP_CLK_APLL_PFD0] = imx_clk_pfdv2("apll_pfd0", "apll", base + 0x50C, 0); + clks[IMX7ULP_CLK_APLL_PFD1] = imx_clk_pfdv2("apll_pfd1", "apll", base + 0x50C, 1); + clks[IMX7ULP_CLK_APLL_PFD2] = imx_clk_pfdv2("apll_pfd2", "apll", base + 0x50C, 2); + clks[IMX7ULP_CLK_APLL_PFD3] = imx_clk_pfdv2("apll_pfd3", "apll", base + 0x50C, 3); + + /* SPLL PFDs */ + clks[IMX7ULP_CLK_SPLL_PFD0] = imx_clk_pfdv2("spll_pfd0", "spll", base + 0x60C, 0); + clks[IMX7ULP_CLK_SPLL_PFD1] = imx_clk_pfdv2("spll_pfd1", "spll", base + 0x60C, 1); + clks[IMX7ULP_CLK_SPLL_PFD2] = imx_clk_pfdv2("spll_pfd2", "spll", base + 0x60C, 2); + clks[IMX7ULP_CLK_SPLL_PFD3] = imx_clk_pfdv2("spll_pfd3", "spll", base + 0x60C, 3); + + /* PLL Mux */ + clks[IMX7ULP_CLK_APLL_PFD_SEL] = imx_clk_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); + clks[IMX7ULP_CLK_SPLL_PFD_SEL] = imx_clk_mux_flags("spll_pfd_sel", base + 0x608, 14, 2, spll_pfd_sels, ARRAY_SIZE(spll_pfd_sels), CLK_SET_RATE_PARENT | CLK_SET_PARENT_GATE); + clks[IMX7ULP_CLK_APLL_SEL] = imx_clk_mux_flags("apll_sel", base + 0x508, 1, 1, apll_sels, ARRAY_SIZE(apll_sels), CLK_SET_RATE_PARENT | CLK_SET_PARENT_GATE); + clks[IMX7ULP_CLK_SPLL_SEL] = imx_clk_mux_flags("spll_sel", base + 0x608, 1, 1, spll_sels, ARRAY_SIZE(spll_sels), CLK_SET_RATE_PARENT | CLK_SET_PARENT_GATE); + + clks[IMX7ULP_CLK_SPLL_BUS_CLK] = clk_register_divider(NULL, "spll_bus_clk", "spll_sel", CLK_SET_RATE_GATE, base + 0x604, 8, 3, CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ZERO_GATE, &imx_ccm_lock); + + /* scs/ddr/nic select different clock source requires that clock to be enabled first */ + clks[IMX7ULP_CLK_SYS_SEL] = imx_clk_mux2("scs_sel", base + 0x14, 24, 4, scs_sels, ARRAY_SIZE(scs_sels)); + clks[IMX7ULP_CLK_NIC_SEL] = imx_clk_mux2("nic_sel", base + 0x40, 28, 1, nic_sels, ARRAY_SIZE(nic_sels)); + clks[IMX7ULP_CLK_DDR_SEL] = imx_clk_mux_flags("ddr_sel", base + 0x30, 24, 1, ddr_sels, ARRAY_SIZE(ddr_sels), CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE); + + clks[IMX7ULP_CLK_CORE_DIV] = imx_clk_divider_flags("divcore", "scs_sel", base + 0x14, 16, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + + clks[IMX7ULP_CLK_DDR_DIV] = clk_register_divider(NULL, "ddr_clk", "ddr_sel", CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, base + 0x30, 0, 3, + CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ZERO_GATE, &imx_ccm_lock); + + clks[IMX7ULP_CLK_NIC0_DIV] = imx_clk_divider_flags("nic0_clk", "nic_sel", base + 0x40, 24, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + clks[IMX7ULP_CLK_NIC1_DIV] = imx_clk_divider_flags("nic1_clk", "nic0_clk", base + 0x40, 16, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + clks[IMX7ULP_CLK_NIC1_BUS_DIV] = imx_clk_divider_flags("nic1_bus_clk", "nic1_clk", base + 0x40, 4, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + + clks[IMX7ULP_CLK_GPU_DIV] = imx_clk_divider("gpu_clk", "nic0_clk", base + 0x40, 20, 4); + + clks[IMX7ULP_CLK_SOSC_BUS_CLK] = clk_register_divider(NULL, "sosc_bus_clk", "sosc", 0, base + 0x104, 8, 3, + CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ZERO_GATE, &imx_ccm_lock); + clks[IMX7ULP_CLK_FIRC_BUS_CLK] = clk_register_divider(NULL, "firc_bus_clk", "firc", 0, base + 0x304, 8, 3, + CLK_DIVIDER_READ_ONLY | CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ZERO_GATE, &imx_ccm_lock); + + /* PCC2 */ + base = of_io_request_and_map(np, 1, "pcc2"); + WARN_ON(!base); + + clks[IMX7ULP_CLK_DMA1] = imx_clk_gate("dma1", "nic1_clk", base + 0x20, 30); + clks[IMX7ULP_CLK_RGPIO2P1] = imx_clk_gate("rgpio2p1", "nic1_bus_clk", base + 0x3c, 30); + clks[IMX7ULP_CLK_DMA_MUX1] = imx_clk_gate("dma_mux1", "nic1_bus_clk", base + 0x84, 30); + clks[IMX7ULP_CLK_SNVS] = imx_clk_gate("snvs", "nic1_bus_clk", base + 0x8c, 30); + clks[IMX7ULP_CLK_CAAM] = imx_clk_gate("caam", "nic1_clk", base + 0x90, 30); + clks[IMX7ULP_CLK_LPTPM4] = imx_clk_composite("lptpm4", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x94); + clks[IMX7ULP_CLK_LPTPM5] = imx_clk_composite("lptmp5", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x98); + clks[IMX7ULP_CLK_LPIT1] = imx_clk_composite("lpit1", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x9C); + clks[IMX7ULP_CLK_LPSPI2] = imx_clk_composite("lpspi2", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xA4); + clks[IMX7ULP_CLK_LPSPI3] = imx_clk_composite("lpspi3", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xA8); + clks[IMX7ULP_CLK_LPI2C4] = imx_clk_composite("lpi2c4", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xAC); + clks[IMX7ULP_CLK_LPI2C5] = imx_clk_composite("lpi2c5", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xB0); + clks[IMX7ULP_CLK_LPUART4] = imx_clk_composite("lpuart4", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xB4); + clks[IMX7ULP_CLK_LPUART5] = imx_clk_composite("lpuart5", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xB8); + clks[IMX7ULP_CLK_FLEXIO1] = imx_clk_composite("flexio1", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0xC4); + clks[IMX7ULP_CLK_USB0] = imx_clk_composite("usb0", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xCC); + clks[IMX7ULP_CLK_USB1] = imx_clk_composite("usb1", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xD0); + clks[IMX7ULP_CLK_USB_PHY] = imx_clk_gate("usb_phy", "nic1_bus_clk", base + 0xD4, 30); + clks[IMX7ULP_CLK_USDHC0] = imx_clk_composite("usdhc0", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xDC); + clks[IMX7ULP_CLK_USDHC1] = imx_clk_composite("usdhc1", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xE0); + clks[IMX7ULP_CLK_WDG1] = imx_clk_composite("wdg1", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, true, true, base + 0xF4); + clks[IMX7ULP_CLK_WDG2] = imx_clk_composite("sdg2", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, true, true, base + 0x10C); + + /* PCC3 */ + base = of_io_request_and_map(np, 2, "pcc3"); + WARN_ON(!base); + + clks[IMX7ULP_CLK_LPTPM6] = imx_clk_composite("lptpm6", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x84); + clks[IMX7ULP_CLK_LPTPM7] = imx_clk_composite("lptpm7", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x88); + clks[IMX7ULP_CLK_LPI2C6] = imx_clk_composite("lpi2c6", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x90); + clks[IMX7ULP_CLK_LPI2C7] = imx_clk_composite("lpi2c7", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x94); + clks[IMX7ULP_CLK_LPUART6] = imx_clk_composite("lpuart6", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x98); + clks[IMX7ULP_CLK_LPUART7] = imx_clk_composite("lpuart7", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, false, true, base + 0x9C); + clks[IMX7ULP_CLK_DSI] = imx_clk_composite("dsi", periph_bus_sels, ARRAY_SIZE(periph_bus_sels), true, true, true, base + 0xA4); + clks[IMX7ULP_CLK_LCDIF] = imx_clk_composite("lcdif", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, true, true, base + 0xA8); + + clks[IMX7ULP_CLK_MMDC] = clk_register_gate(NULL, "mmdc", "nic1_clk", CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, + base + 0xAC, 30, 0, &imx_ccm_lock); + + clks[IMX7ULP_CLK_VIU] = imx_clk_gate("viu", "nic1_clk", base + 0xA0, 30); + clks[IMX7ULP_CLK_PCTLC] = imx_clk_gate("pctlc", "nic1_bus_clk", base + 0xB8, 30); + clks[IMX7ULP_CLK_PCTLD] = imx_clk_gate("pctld", "nic1_bus_clk", base + 0xBC, 30); + clks[IMX7ULP_CLK_PCTLE] = imx_clk_gate("pctle", "nic1_bus_clk", base + 0xc0, 30); + clks[IMX7ULP_CLK_PCTLF] = imx_clk_gate("pctlf", "nic1_bus_clk", base + 0xc4, 30); + + clks[IMX7ULP_CLK_GPU3D] = imx_clk_composite("gpu3d", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, false, true, base + 0x140); + clks[IMX7ULP_CLK_GPU2D] = imx_clk_composite("gpu2d", periph_plat_sels, ARRAY_SIZE(periph_plat_sels), true, false, true, base + 0x144); + + imx_check_clocks(clks, ARRAY_SIZE(clks)); + + clk_data.clks = clks; + clk_data.clk_num = ARRAY_SIZE(clks); + of_clk_add_provider(scg_node, of_clk_src_onecell_get, &clk_data); + + pr_info("i.MX7ULP clock tree init done.\n"); +} + +CLK_OF_DECLARE(imx7ulp, "fsl,imx7ulp-clock", imx7ulp_clocks_init);