Received: by 10.223.176.46 with SMTP id f43csp982634wra; Fri, 19 Jan 2018 05:14:27 -0800 (PST) X-Google-Smtp-Source: ACJfBovB0s6e9fyMKgFdwCiRO757lRO+l9BcrN4ivLiO8V9cbVw8KrZ9zMPRp+c3+V0jtNNoL0KR X-Received: by 10.99.178.19 with SMTP id x19mr8623269pge.31.1516367667146; Fri, 19 Jan 2018 05:14:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516367667; cv=none; d=google.com; s=arc-20160816; b=zcdPSdhbDW4AKkkoY8K3ubsxtSfE0K+ysHMV+z6RbXtYdWPEFrVz4srKxDjCL9dVM8 zf8db0VdDRTJxPNToqM1BdccRt5RykJqM5qeccdjiQWCBEsI5kvq09oIys16pWs39Jvc DlR35eL2erSob1pYI1F3WCbl4ldzBI7Ki/SqixBFUNRZLmY3lshueEa4bEXsXKtHptHI XOq8Wch+C8DYIBdutFZEBk39SrWQXqiQeeOC9HnKLMZ6QezbEAu9Q+P/TLg9aRDkN2Ah f65fYlXqw9V1B5rEC824cFUqsVXuz2WFYQZc1inks5I0H7vImBwogDch/WOy2xCwhtFt jcFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:arc-authentication-results; bh=Ce/7PvuuiXQiVy7FMSiSAkwsXDXHZS+5BbxLoyVKvXQ=; b=qAtKXoHCiLDe5e2FO8hWYLAIWvTLpvoCwkHre4NjkLfFbK0tmCiVND/XAncwFn6xX8 hb9ULbx7XDWPhy2GTvOj60QlxTAxsdKqMjEzjNdSbBx/156btv0XsGtqKnsIZX4AL9CK 7uS2xzNrMZaw0VeIu6YTD0kXWOjGe22PqJ1LFQZuGCARMgix4Co5CIgaArwP9zT8Bw8b aQ6k9Ihh6E7BfhBlOZrySbCWbZHBJgJZsG7zTThJt2vImYAUbCiR6qKKV6yjthY9/nXB iIrRKnuuVa7m5HUhH52RpVWXXUp09QTOPYC/2MxUHtj3H8kmV4QNMFwah33uaWK/M65X jqBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26si8349700pgv.636.2018.01.19.05.14.12; Fri, 19 Jan 2018 05:14:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755888AbeASNMm (ORCPT + 99 others); Fri, 19 Jan 2018 08:12:42 -0500 Received: from mail-dm3nam03on0060.outbound.protection.outlook.com ([104.47.41.60]:60160 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755739AbeASNMA (ORCPT ); Fri, 19 Jan 2018 08:12:00 -0500 Received: from MWHPR03CA0019.namprd03.prod.outlook.com (10.175.133.157) by DM5PR03MB2700.namprd03.prod.outlook.com (10.168.197.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Fri, 19 Jan 2018 13:11:58 +0000 Received: from BN1AFFO11FD047.protection.gbl (2a01:111:f400:7c10::145) by MWHPR03CA0019.outlook.office365.com (2603:10b6:300:117::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Fri, 19 Jan 2018 13:11:58 +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 BN1AFFO11FD047.mail.protection.outlook.com (10.58.53.62) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Fri, 19 Jan 2018 13:11:53 +0000 Received: from b29396-OptiPlex-7040.ap.freescale.net (b29396-OptiPlex-7040.ap.freescale.net [10.192.242.1]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0JDBGiT013190; Fri, 19 Jan 2018 06:11:49 -0700 From: Dong Aisheng To: CC: , , , , , , , , , Dong Aisheng Subject: [PATCH V3 09/10] clk: imx: add imx7ulp clk driver Date: Fri, 19 Jan 2018 21:11:09 +0800 Message-ID: <1516367470-24340-10-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516367470-24340-1-git-send-email-aisheng.dong@nxp.com> References: <1516367470-24340-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131608411178697152;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(7966004)(396003)(39380400002)(346002)(376002)(39860400002)(2980300002)(1110001)(1109001)(339900001)(189003)(199004)(54534003)(508600001)(966005)(6666003)(6916009)(2950100002)(2906002)(104016004)(36756003)(50466002)(48376002)(53936002)(6306002)(2351001)(106466001)(47776003)(50226002)(8936002)(105606002)(8656006)(316002)(59450400001)(26005)(51416003)(86362001)(81156014)(68736007)(81166006)(356003)(5660300001)(85426001)(77096007)(97736004)(4326008)(7416002)(16586007)(76176011)(8676002)(305945005)(54906003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR03MB2700;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD047;1:NTgxvnAMzEjOd4/i+POIkupVo8Sf9bUwlaA93g/jNM3xAxkn2vTao1QdL4789+J/PM9uDnxY2i5Grtif+7Q8yUbi/74Hh9b7YM5vvfHXqyVel6KkmDVVyIuDs4rb5zbe MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 534cfdd3-179c-4f0d-81c0-08d55f3e3839 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(5600026)(4604075)(2017052603307);SRVR:DM5PR03MB2700; X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB2700;3:rCrvNbPVncm0YsiKZUjUUoSSqC3xzeBUi1mXFoWvo0D7wKLY+YFXjU8l5gKrh5J8XCr7jp7I1KVdPn/F+Jg5Cn3sedtjaza9HwLEExUPiukmdjK35xqb6E7HYmUvZxhrmYbuGNw4SCzDypqjK3EKWJSTBtFJZK8nkis5RiQ1sm9laJxNStt47AWcGjX9WZ/0euiKiSOrjFwAclNFBaI87U2y1e01xznWSGNBYHFo+kJaPUubc3uqEClCdpjNS2Kl77LGTAYec39xZgqd821BW5hx6BN9ON2XMD6RXZIJYG03X6rfi2bxLlqlOUD1NGTaxtGGPDPxubllXwekJt98s1t8YM9xJT0OSurbfnFs1t0=;25:gZwSOsi+vU8tau3rIxdSXncwDesUbdco/CeGCUlg+JZVUpYTJXyMDNnqFfhD9VUBBrAxaObxgz3nS/r9j+GEoT5dg3J8ysHgKXCWzLVmRCOiN5jh2Qkv27UvS7p08bj6ccEc31+IeP3PnqWpKe4Q1b8KBGD1xgOCPJltLx0J8zpn0xjOdHFblvArF86qdLacdsANu17z079jh1RvUCKiDfenDUaHuKfHZ6YxIaa6vzkLZAQWA6rUXMb1NXBnFm/sXhIKRBJrN/R9TV3j6GiyH6AMaiMVE0eXMAaRosUKaGbJyIKuXTzhGplRQ+JBCDu/I5V+alRZ0WTsK7yq4Zw9AA== X-MS-TrafficTypeDiagnostic: DM5PR03MB2700: X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB2700;31:rGSOHwm29N58KQqvmpNtiGG6CmqigTiU5RgfV82Kbhq6K405wm9SDDocIIj0Ngs5yn/AF+Cg024dPk6v+lA9sT5I2AEW5sAKnbJbsHG1yDrtZTdK9CZNXsaCwDbKr0W/46x3S6RNeujnZ9oI9gPkXmYiD9KYz5uAVo/tzcN2A0nYDEcj2lxlnbgG75iqLc0eZrYTvQMlh5JDd5EpATnSz8TPFKRB0ZxQF2UFt6okx4Q=;4:sVX+ZWP6zpdlId9NiJEwBhiwPPVpYz3nHeCBLQbIPX+GnVC1YHRqucwz5pVcw86QLRbMGsWTHvo5gdA2HPdxeQQscsJ1iAwMf+wVNiKsjYnyjLw86PHsEpKZCGVZ4KBcJIYIC8Dig6PTiX7T0gayWAxNQOMY9rKAYAiaYiZo+sjhasUIEEHe9Dy3sQPJl2ZCbl/YOZ+Ho3dniZ6Fgu4lDR7npCa1Lv1WUyJDQt6q4fbP3iVwdtWT5n45RqE0Mse972iUov1BtFCozzh9aPbWMSGcr0wcFd27MV33frzVeWxwGBp9DuNO6ZVWWe3hPg/1Mf3mvCc6t4jLMD89XRigZyKIQ2zyAgfBZVGNxHZ6aqi6t8QdJqcQjapGoAb2zSSZ 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)(2401047)(5005006)(8121501046)(3002001)(3231023)(2400077)(944501161)(93006095)(93001095)(10201501046)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(20161123565025)(20161123556025)(20161123561025)(20161123563025)(20161123559100)(201708071742011);SRVR:DM5PR03MB2700;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:DM5PR03MB2700; X-Forefront-PRVS: 0557CBAD84 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM5PR03MB2700;23:3o3PEh3JawT+tElZUjazr9Rr2a4ERp37oFHZbUHd7?= =?us-ascii?Q?FFGDxI7kGH8WOQ5dFLlYxo/ScsktkGgEkI34l4MRztVDXqmMnoWgvKjJ0L9J?= =?us-ascii?Q?9iczHwUCdJ5hVpZHddOA4Ek6cnPL01sBy9iFp7FfLs+CV2SEF48JbbMa+zMg?= =?us-ascii?Q?uhyKnwBEpnfCXUlMqReDYmQxHRqBjNKMVXpFC0HTbBsF2wbxM5vUCJPkG6ww?= =?us-ascii?Q?sqlFmCCtPS0VvFPc/+W/P3BKO0xxhDVBtmhUrckUQPpfEZ1Me+NS5lRzl9xN?= =?us-ascii?Q?xNW0fsaP9oADrGxjHMIqdxMppIyddMCnOnznrsRQ1B5j8zyEi1HH454fxBU0?= =?us-ascii?Q?JJqjyTwcyUoTQneq+n51ZBvx9XC6GitffKlbqh5SAknhc+Nx6mjLiwPvUu0C?= =?us-ascii?Q?C4lXsIoXhIKH38Ij63ZdJuw2PufTSr24QDBFI44eG3uLAcOekcTXk/Tw7SE+?= =?us-ascii?Q?pjqOCQQzmd8qOdenbFs6sWpcRW/TZ5zQFoCmIp17pwx0fTLbGSEfgazduIUV?= =?us-ascii?Q?spHinaItLCXUnz5OWC4tgYT87tVAH/dyVggvlD8RuYdJrb9pjPjldrK/L10f?= =?us-ascii?Q?Yon0vrG0CsFbA43ujYUPg+owjNOJXkxpHHzyOKT+t76+a+oKY4gzf92KlTYH?= =?us-ascii?Q?1AtbNTKCyUt5Sb6Ue+hZ6V9ZL7cs7E8YNpnGSTgrkulaSq9G3SjlpijRJxW2?= =?us-ascii?Q?KXww/sL7j0XAAR0ZfTKAvg8xGcNEC1GO0XpcZal/cEEOIDGX4ql0c6hvwFB+?= =?us-ascii?Q?Zs8FJCheJJMLYm9/VFOUEoNnvlAdZkEoEeaHijvvVJeLxH/f5GR0pIryuWiY?= =?us-ascii?Q?J6mzxPGuoT4uoWcM3+Ohl39bEcJK8t1PStFMCLvrzwnMMXHnYC34eObZ1HNz?= =?us-ascii?Q?HVQ3Y8+b9VwybZOZEt4dMob+X9fQu91JoK+TNiarAfUuLv+Ui+2TUtwPKeCv?= =?us-ascii?Q?lo6WTsyg181vb4ZWVn6lcQa6RADqU9t1bKXFet3SqrfMrz/6xU8FHG3+GBPI?= =?us-ascii?Q?/RCH47Mm1qnieovYOhQoHD1bv6brWw7oNQ7oW70vzZii+8ou5wnnamgVogo2?= =?us-ascii?Q?4DN/vXhY8ivec1IEh8T+CkZt4IrLe30Z+29sfEmWVDSMwpZnvlJXk4SwbkxD?= =?us-ascii?Q?RNsz/qs849L4Oi4V0RetGcjRBMDDTZbJUaKWF62ARr7CyTmUwhmlE/oNdAUz?= =?us-ascii?Q?2mK5+X39WJ+V/IWoB3nvuvarebGwJ2CEjhc?= X-Microsoft-Exchange-Diagnostics: 1;DM5PR03MB2700;6:ofpubMaZwJOowSfrOw8ReCoaHBubBzZ3G4uPKPQ3TXz5S2mKNXq/yOy2i5giuISmQncn14yShH50NedidLByjBgH9VEkkb+HVKwmgC1LFFyaKd7zhcPE9fyaRadFFEvbxBp7ZtgAd4cwicAq3xKYbY6vUzASGHE51mB6VvC1Apy04o9SO++wJ4MdTzV3LhY9X0yK2/J8rrPcVkpgS8vwRYececxt78RJXlb7tfIKei2CSgXAJLvl5qDc1mGEIftgoxdAFXYzhO7s+n4VIDo0R58FYBpOr2MO5BIGfQjkU4MvSQWbQ/HI6845EPE1O3hS5WF8vg1WAXNLVPpuCU2mXYz9EZkx4stwnPkM2TnFqJ8=;5:Igyuw15MlcNXt1SnoHFhxxDYu0mGaBRy0J9yIrvPC7QHS7iqLx4ZfykP33QZXnic/R28ftfRuewbmEGGD9ZeJcdhdu5zpIE9t4JnbiHH3XXxuh0UOfDYdI35RwLglkC7jKTbXx+NCJGalBUFFYc07FgQqnlCAKGaJTPNSYbywtU=;24:7WjiZToeIvqRSZSsdYw0v5naSIfwIMzl+i99vElxmyA83MkYXRHEyKE6kCdxq+Bzwi7JjVPK2EIlmUGOFmQiNxgFwD3w79l/T6irTLAcU7s=;7:1xpWhErufdvicww71BxID+1eAWIidz3f9EUCySYYS25Cv8aohFSCE96DH72UBhASSopJDPM2CwwK85nIghCkM7ZH0+5bojy3qghRBdxVBi0EEuAHsoMlCmcLYe6MIyic2g67y//Qdq+OMpuRGXAWIn7sRM3AWxTkTuQxOTYqODDVqv3S2P+rYRiWCVZvd06D5gv460vHCbjOsV8IUmCtnvN77W1t2TWroeaKwyV78gvU+y5w0hpt0ReXwPhuazTo SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 13:11:53.7981 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 534cfdd3-179c-4f0d-81c0-08d55f3e3839 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: DM5PR03MB2700 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- ChangeLog: v2->v3: * no changes v1->v2: * use of_clk_add_hw_provider instead * split the clocks register process into two parts: early part for possible timers clocks registered by CLK_OF_DECLARE_DRIVER and the later part for the left normal peripheral clocks registered by a platform driver. --- drivers/clk/imx/Makefile | 1 + drivers/clk/imx/clk-imx7ulp.c | 232 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 233 insertions(+) create mode 100644 drivers/clk/imx/clk-imx7ulp.c diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile index eab606c..f5ff925 100644 --- a/drivers/clk/imx/Makefile +++ b/drivers/clk/imx/Makefile @@ -28,4 +28,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..1245efc --- /dev/null +++ b/drivers/clk/imx/clk-imx7ulp.c @@ -0,0 +1,232 @@ +/* + * 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 +#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_hw_onecell_data *clk_data; + +static void __init imx7ulp_clocks_early_init(struct device_node *scg_node) +{ + struct device_node *np = scg_node; + void __iomem *base; + struct clk_hw **clks; + + clk_data = kzalloc(sizeof(*clk_data) + + sizeof(*clk_data->hws) * IMX7ULP_CLK_END, + GFP_KERNEL); + if (!clk_data) + return; + + clk_data->num = IMX7ULP_CLK_END; + clks = clk_data->hws; + + clks[IMX7ULP_CLK_DUMMY] = imx_clk_hw_fixed("dummy", 0); + + clks[IMX7ULP_CLK_ROSC] = imx_obtain_fixed_clk_hw(np, "rosc"); + clks[IMX7ULP_CLK_SOSC] = imx_obtain_fixed_clk_hw(np, "sosc"); + clks[IMX7ULP_CLK_SIRC] = imx_obtain_fixed_clk_hw(np, "sirc"); + clks[IMX7ULP_CLK_FIRC] = imx_obtain_fixed_clk_hw(np, "firc"); + clks[IMX7ULP_CLK_MIPI_PLL] = imx_obtain_fixed_clk_hw(np, "mpll"); + clks[IMX7ULP_CLK_UPLL] = imx_obtain_fixed_clk_hw(np, "upll"); + + /* SCG1 */ + base = of_iomap(np, 0); + WARN_ON(!base); + + /* NOTE: xPLL config can't be changed when xPLL is enabled */ + clks[IMX7ULP_CLK_APLL_PRE_SEL] = imx_clk_hw_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_hw_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_hw_divider_flags("apll_pre_div", "apll_pre_sel", base + 0x508, 8, 3, CLK_SET_RATE_GATE); + clks[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 */ + 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_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); + clks[IMX7ULP_CLK_SPLL_PFD_SEL] = imx_clk_hw_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_hw_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_hw_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_hw_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_hw_mux2("scs_sel", base + 0x14, 24, 4, scs_sels, ARRAY_SIZE(scs_sels)); + clks[IMX7ULP_CLK_NIC_SEL] = imx_clk_hw_mux2("nic_sel", base + 0x40, 28, 1, nic_sels, ARRAY_SIZE(nic_sels)); + clks[IMX7ULP_CLK_DDR_SEL] = imx_clk_hw_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_hw_divider_flags("divcore", "scs_sel", base + 0x14, 16, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + + clks[IMX7ULP_CLK_DDR_DIV] = clk_hw_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_hw_divider_flags("nic0_clk", "nic_sel", base + 0x40, 24, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + clks[IMX7ULP_CLK_NIC1_DIV] = imx_clk_hw_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_hw_divider_flags("nic1_bus_clk", "nic1_clk", base + 0x40, 4, 4, CLK_SET_RATE_PARENT | CLK_IS_CRITICAL); + + clks[IMX7ULP_CLK_SOSC_BUS_CLK] = clk_hw_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_hw_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_iomap(np, 1); + WARN_ON(!base); + + 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("lptpm5", 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); + + /* PCC3 */ + base = of_iomap(np, 2); + 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_MMDC] = clk_hw_register_gate(NULL, "mmdc", "nic1_clk", CLK_SET_RATE_PARENT | CLK_IS_CRITICAL, + base + 0xac, 30, 0, &imx_ccm_lock); + + imx_check_clk_hws(clks, clk_data->num); + + of_clk_add_hw_provider(scg_node, of_clk_hw_onecell_get, clk_data); +} +CLK_OF_DECLARE_DRIVER(imx7ulp, "fsl,imx7ulp-clock", imx7ulp_clocks_early_init); + +static const struct of_device_id imx7ulp_clk_dt_ids[] = { + { .compatible = "fsl,imx7ulp-clock" }, + { /* sentinel */ } +}; + +static int imx7ulp_clk_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct clk_hw **clks = clk_data->hws; + struct resource *res; + void __iomem *base; + + /* PCC2 */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "scg1"); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + clks[IMX7ULP_CLK_GPU_DIV] = imx_clk_hw_divider("gpu_clk", "nic0_clk", base + 0x40, 20, 4); + + /* PCC2 */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcc2"); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + clks[IMX7ULP_CLK_DMA1] = imx_clk_hw_gate("dma1", "nic1_clk", base + 0x20, 30); + clks[IMX7ULP_CLK_RGPIO2P1] = imx_clk_hw_gate("rgpio2p1", "nic1_bus_clk", base + 0x3c, 30); + clks[IMX7ULP_CLK_DMA_MUX1] = imx_clk_hw_gate("dma_mux1", "nic1_bus_clk", base + 0x84, 30); + clks[IMX7ULP_CLK_SNVS] = imx_clk_hw_gate("snvs", "nic1_bus_clk", base + 0x8c, 30); + clks[IMX7ULP_CLK_CAAM] = imx_clk_hw_gate("caam", "nic1_clk", base + 0x90, 30); + 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_hw_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 */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pcc3"); + base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(base)) + return PTR_ERR(base); + + 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_VIU] = imx_clk_hw_gate("viu", "nic1_clk", base + 0xa0, 30); + clks[IMX7ULP_CLK_PCTLC] = imx_clk_hw_gate("pctlc", "nic1_bus_clk", base + 0xb8, 30); + clks[IMX7ULP_CLK_PCTLD] = imx_clk_hw_gate("pctld", "nic1_bus_clk", base + 0xbc, 30); + clks[IMX7ULP_CLK_PCTLE] = imx_clk_hw_gate("pctle", "nic1_bus_clk", base + 0xc0, 30); + clks[IMX7ULP_CLK_PCTLF] = imx_clk_hw_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_clk_hws(clks, clk_data->num); + + of_clk_add_hw_provider(np, of_clk_hw_onecell_get, clk_data); + + pr_debug("i.MX7ULP clock tree init done.\n"); + + return 0; +} + +static struct platform_driver imx7ulp_clk_driver = { + .driver = { + .name = "imx7ulp-clock", + .of_match_table = imx7ulp_clk_dt_ids, + }, + .probe = imx7ulp_clk_probe, +}; + +static int __init imx7ulp_clk_init(void) +{ + return platform_driver_register(&imx7ulp_clk_driver); +} +core_initcall(imx7ulp_clk_init); -- 2.7.4