Received: by 10.223.176.46 with SMTP id f43csp981548wra; Fri, 19 Jan 2018 05:13:27 -0800 (PST) X-Google-Smtp-Source: ACJfBouJch88ukUzNh4MynOpESTk4YG7AEFWqQHOlf5HW/eUon+3HPKan0MkUv3PcKpXY7ZDxlhi X-Received: by 10.98.11.17 with SMTP id t17mr10117868pfi.201.1516367607754; Fri, 19 Jan 2018 05:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516367607; cv=none; d=google.com; s=arc-20160816; b=bkOBIBeGnLRqq4Tw++KQuKUJGchis/H8t5rfU+4LCeMWKnHOSn00x+nyZUtTTPVIGv a/iTZWiJE+Q4xRQjtzltKSokkyCkx1XGePqX2vU0TPJTtSXb+9WLatp1qLM9W5j3ToGK qYS5tQW32RCiCW8kkiMc1LgVpdym6N7hPvR6Gm/F6yo2FqFQuCYMl2Ma5D3R+7GiA1mW yaNTHpuiEDkJug8lCdmWFvZJCOPhBJUdjDFCnexzNnDE5YKtmUy8sg/z5+ODnM370PWx ClAmNVduScCVxeJX6aa1xlbje8NAjdAG3J1jEMC2l7Mt9V2rE51oL/LA7n0STTPh9CBs 4aJw== 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=o18kRijGVDFL6dzSaHMpNTEiROXdGKIwyElU47DuAqY=; b=Ty7T2JJhH1Yazfyqdui+6ODk/MXpMtuLKgcbfmb0YH0e3i4rMxbxcX9oE2qV8uF6mk A3E7ievBlFmJVpSwrvC6+n6p8GAxxc6osBh8JCrgT6pwwyWp9AiToHJFnEUgMFNO8P5W 68AlODSn9ORpyu2w5aAhbofq5FdQvUht+P5KVeFlRrgzNcNsPEbh7CXkWmm6lemEFuB+ dMizvcNA0Fcofj6hnjuA2cq2uTScv3+yxegxZivcaAF9AetMPPMdPrJOPcVOqTONWXwT e+qTeT9CEr3hwQbXkP67oWfkT4XxedYib+4izlGBF8zK75TBMAJC8GyaIxiVk7G4xx4O LWwQ== 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 j13si5815632pfh.78.2018.01.19.05.13.13; Fri, 19 Jan 2018 05:13: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 S1755828AbeASNMS (ORCPT + 99 others); Fri, 19 Jan 2018 08:12:18 -0500 Received: from mail-dm3nam03on0058.outbound.protection.outlook.com ([104.47.41.58]:53195 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755197AbeASNLm (ORCPT ); Fri, 19 Jan 2018 08:11:42 -0500 Received: from MWHPR03CA0002.namprd03.prod.outlook.com (10.175.133.140) by BN3PR03MB2353.namprd03.prod.outlook.com (10.166.74.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Fri, 19 Jan 2018 13:11:39 +0000 Received: from BL2FFO11FD014.protection.gbl (2a01:111:f400:7c09::160) by MWHPR03CA0002.outlook.office365.com (2603:10b6:300:117::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.428.17 via Frontend Transport; Fri, 19 Jan 2018 13:11:39 +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 BL2FFO11FD014.mail.protection.outlook.com (10.173.160.222) 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:38 +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 w0JDBGiP013190; Fri, 19 Jan 2018 06:11:35 -0700 From: Dong Aisheng To: CC: , , , , , , , , , Dong Aisheng Subject: [PATCH V3 05/10] clk: imx: add composite clk support Date: Fri, 19 Jan 2018 21:11:05 +0800 Message-ID: <1516367470-24340-6-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: 131608410989590885;(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)(376002)(39860400002)(39380400002)(346002)(2980300002)(1109001)(1110001)(339900001)(189003)(54534003)(199004)(54906003)(508600001)(316002)(305945005)(36756003)(356003)(6306002)(77096007)(26005)(966005)(48376002)(50466002)(8656006)(85426001)(16586007)(86362001)(4326008)(81156014)(53936002)(2351001)(2906002)(97736004)(5660300001)(106466001)(6916009)(7416002)(2950100002)(104016004)(8936002)(6666003)(50226002)(8676002)(81166006)(76176011)(68736007)(47776003)(51416003)(105606002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR03MB2353;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD014;1:9Uh44H9v2UO2q+/N2aAnqUTl/eYp8P3cQq9I2CdOl1rjt5Iv6f6jCJ8TcT17mbl/+0XjJ54Bf5KabYjnPtdgreqhkQkl8DgJlHNh8bNCxkNJzKJ8+lffsx3KTDPN3Vyt MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 14158d51-183f-41ee-f965-08d55f3e2cf3 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(5600026)(4604075)(2017052603307);SRVR:BN3PR03MB2353; X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB2353;3:Lmi+ffFn5zt51dcswQE40KzuEVkzUcyjs4o0yIWqtQmGLBaMUXEpUr2G/cAg+waDdEXVFdGXKZSf68qt2QCLwjGXzZI5VKO15j1zf7ddSEENxPnbzV1+VjjyoNTPmTzP5CLU8aNZf71ZMwkZWVhjVLpANCltecnLw2XMjPE4gpc+K7qaVtUwWHqIB/H82cl2y7djGSmvEqOvGkb7+QM+7zI/dOMMRC4pDuffOfDCqfn5OogJH/Ds/QZ4L+6EFy1d00NXZgZxXbFOB4Nl76MPYsf1KRnPt69HLBKtRexCg10INbNA2etPpVjlJ2Z7GrxexetmOzDrhNJbNTLGiKvn/c2DqJjW7drW0BJmrLNXsiI=;25:MH0u9hbbTGn8M7TzKpWJC14gjIqKojeBHvlO2Su1w8IZGkHZ8JdNAnlkYI7jMT/s4WSoiu6Vk31m0VAyzJ8KvUcfDuRuUEtA0PkTf6pUGmqQIWrLjdgj8crbq7Y9R/VGpA47UqLofyPuiipNFWf6zB0+vW64SU8GBMtm6XQjIAtZaEVIeQDE0mhwyTYAcz0VZ78hu3NoAOXktusTQlOCuO7yo70iSGyKuqQVU7DuBufhkdBAWyIuNpF3QztOHcWj9g+cAw7ZdAVtmD0BqwsE/D5Gys2w32CHp4TLQspU/laEMA3KqHeFn12GWilF4W6pCKA0v0F0lhjTFPJ1Gkx9SQ== X-MS-TrafficTypeDiagnostic: BN3PR03MB2353: X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB2353;31:dc51uRg/FyxBOPz/ii7oGXCNEIVPtVTK7agAuo39MixTZfUqAS3SfHJo1RHE8xhu3SfftsihARN5ZVRvdjmrdfWJ9BoUtzqsqR+TGxZ+VpAz59GR7wJ7SGG0O+0Isa5kYVjRNDo3VUQLZH+PRd3gQFjFJipQRLUlzQfRwt5N9bqlZvSUwUze4CFoNh4+tT4uLs1OjUPP5d3ck4WOibDxslFhaEl1WavrV481fNmK6mU=;4:CZGLiVyxSC5QouDY3nT1+qHxL/YWOcoxmepnP4hIHY9dE5ImWCv8EEY85P42RaMw4JNnGjdB7iuJ8L0bJ/RrEN6mEE6DpfF9jemEso7NLM4TKoyTRf95Fh+C5YEC4tLntD/4+NDlSq4jeQ0o7UrYvAw9/Jjhk1dpGQ5Ka8wlYORvnwHd104t5NqM1eOEtTUFMlS/0mmHnKPr/H9ZIfCmG6n9BK9278r/J+RXzIQZew0BMaNUlXGsCv1o64Ob8Dr88nu+9KQz659GAtCwOY+QipWqsNY+/pqXf5gBiR50xs+ut2Bx7P2GZNdXxH3LcbXg9CA8AaJ48GdZsv3cC+2pfSz56QIGQqDjglBfasdjr4G87XLmCF4ty7u8JMlYHBW8 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)(8121501046)(5005006)(3002001)(3231023)(2400077)(944501161)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123561025)(20161123565025)(20161123559100)(20161123556025)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(20161123563025)(201708071742011);SRVR:BN3PR03MB2353;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:BN3PR03MB2353; X-Forefront-PRVS: 0557CBAD84 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR03MB2353;23:ZmomsxU7kY3rX8MUbEuABjp/5sHUDPhjdqhG8S2BG?= =?us-ascii?Q?y2hswcqspf1f9ApgqdZjI5NmiDKyQU4w5VsWN530kQoHXRYC0OR3juEi055F?= =?us-ascii?Q?NDKxC+UtMCXnYgOsFeB1QflDQpcQQ+m63fGNebKdCxaJ8o5FSddoy7jZdhfs?= =?us-ascii?Q?I3CEl5GiFcch+5Cio4r64/JsWE7Y66QIEdBsqrneCEBw43nCamjEq+JqQMsn?= =?us-ascii?Q?aoaynlpADWWcGEa1ycsLZoqWBY3p0z17QOcatU0PB1snurAijLMDVq1UiFAZ?= =?us-ascii?Q?QHtkpUwSVDEExtJlTvusWrwTJpRrMu7JGXwhU0/1IyPfSllQOjQj4sAr6ozP?= =?us-ascii?Q?jXs7pXwlxZdUYbrMlhICp/itqawcfFBTijtkHrtlrNScgwYPDqsvyrxF5P9d?= =?us-ascii?Q?ym1kXltTkj4Y20GrTkRfZjwggFAxST+wTFjp/D56Pd183STWfYDfzhoHT2hl?= =?us-ascii?Q?V8+FhWh5xzLXcBFKr8ndPHXQYU04rTcMfsLQ2DEBMohnX1NMNuDJMz/1yj4J?= =?us-ascii?Q?rP0etz9sebq88YLDk+RDSGKvLfKLovrNq8JJigQhRgdYlyFWfCMXbw6E7oVw?= =?us-ascii?Q?ad6QN8SjyDDqa4ejxVFobY13VDtSqlkQ88jWAehHaFfA4g0FJ/pi+nxyevig?= =?us-ascii?Q?aBypUgsWBff6u1iCUkKGhy+VytXP6fIF42xBz9zMEzpsSuTaJNnKIidixe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wPWpUZLG7sWQPKujQ5TzhEJD2VLO7GMUbdvzzWkOxM3KdVQP4qlkUaOH9s9SvnaeUenaWOiDK+jZqGpPsD0mDo2ZeSy0bqgI8du7sbnHaRb78rvxDT3GiExhxSzo0=;24:rXgRsgDOlN4fH7iZIVDovpDS29GX4cpS/I4f9gBSPqdTVluMDsJ85u+ACyPHSvMFnwC/CRXrkvzEsNaMnPH6NMn2KJBxdNBkEWkjzv2FLGg=;7:oVCMuI+JyJLI//e+LmzqiFE3/yTQrnawKQtoFx41nZpNHnGoIOB6dKyF/wkR7UBxrUUVqUFTTjIhrB7YU1k7HoFg85bJ8oSFtjNOfhrW3IKcsM2WFazbXCtYPUQ2SQwGN83pg5y490flRJC3+ax+s2G2mU8roqo0hQzUpTEOoBfaqee/hk29TitVYscOr4eLTK7oVEiu+Zc/vCp2ubhT2hZQWOsIegldow6bvqRs6yenDbw+OfzZfl7hA0Alh/Nu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 13:11:38.7874 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 14158d51-183f-41ee-f965-08d55f3e2cf3 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: BN3PR03MB2353 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The imx composite clk is designed for Peripheral Clock Control (PCC) module observed in IMX ULP SoC series. e.g. i.MX7ULP. NOTE pcc can only be operated when clk is gated. 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: * remove an unneeded blank line change * use clk_hw_register --- drivers/clk/imx/Makefile | 1 + drivers/clk/imx/clk-composite.c | 90 +++++++++++++++++++++++++++++++++++++++++ drivers/clk/imx/clk.h | 6 +++ 3 files changed, 97 insertions(+) create mode 100644 drivers/clk/imx/clk-composite.c diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile index 9c04ae4..eab606c 100644 --- a/drivers/clk/imx/Makefile +++ b/drivers/clk/imx/Makefile @@ -4,6 +4,7 @@ obj-y += \ clk.o \ clk-busy.o \ clk-cpu.o \ + clk-composite.o \ clk-fixup-div.o \ clk-fixup-mux.o \ clk-gate-exclusive.o \ diff --git a/drivers/clk/imx/clk-composite.c b/drivers/clk/imx/clk-composite.c new file mode 100644 index 0000000..78b891e --- /dev/null +++ b/drivers/clk/imx/clk-composite.c @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * Copyright 2017 NXP + * + * 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 + +#define PCG_PCS_SHIFT 24 +#define PCG_PCS_MASK 0x7 +#define PCG_CGC_SHIFT 30 +#define PCG_FRAC_SHIFT 3 +#define PCG_FRAC_WIDTH 1 +#define PCG_FRAC_MASK BIT(3) +#define PCG_PCD_SHIFT 0 +#define PCG_PCD_WIDTH 3 +#define PCG_PCD_MASK 0x7 + +struct clk_hw *imx_clk_composite(const char *name, + const char * const *parent_names, + int num_parents, bool mux_present, + bool rate_present, bool gate_present, + void __iomem *reg) +{ + struct clk_hw *mux_hw = NULL, *fd_hw = NULL, *gate_hw = NULL; + struct clk_fractional_divider *fd = NULL; + struct clk_gate *gate = NULL; + struct clk_mux *mux = NULL; + struct clk_hw *hw; + + if (mux_present) { + mux = kzalloc(sizeof(*mux), GFP_KERNEL); + if (!mux) + return ERR_PTR(-ENOMEM); + mux_hw = &mux->hw; + mux->reg = reg; + mux->shift = PCG_PCS_SHIFT; + mux->mask = PCG_PCS_MASK; + } + + if (rate_present) { + fd = kzalloc(sizeof(*fd), GFP_KERNEL); + if (!fd) { + kfree(mux); + return ERR_PTR(-ENOMEM); + } + fd_hw = &fd->hw; + fd->reg = reg; + fd->mshift = PCG_FRAC_SHIFT; + fd->mwidth = PCG_FRAC_WIDTH; + fd->mmask = PCG_FRAC_MASK; + fd->nshift = PCG_PCD_SHIFT; + fd->nwidth = PCG_PCD_WIDTH; + fd->nmask = PCG_PCD_MASK; + fd->flags = CLK_FRAC_DIVIDER_ZERO_BASED; + } + + if (gate_present) { + gate = kzalloc(sizeof(*gate), GFP_KERNEL); + if (!gate) { + kfree(mux); + kfree(fd); + return ERR_PTR(-ENOMEM); + } + gate_hw = &gate->hw; + gate->reg = reg; + gate->bit_idx = PCG_CGC_SHIFT; + } + + 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 | + CLK_SET_PARENT_GATE); + if (IS_ERR(hw)) { + kfree(mux); + kfree(fd); + kfree(gate); + } + + return hw; +} diff --git a/drivers/clk/imx/clk.h b/drivers/clk/imx/clk.h index ccd7181..fed7660 100644 --- a/drivers/clk/imx/clk.h +++ b/drivers/clk/imx/clk.h @@ -71,6 +71,12 @@ struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg, u8 shift, u8 width, void __iomem *busy_reg, u8 busy_shift, const char **parent_names, int num_parents); +struct clk_hw *imx_clk_composite(const char *name, + const char * const *parent_names, + int num_parents, bool mux_present, + bool rate_present, bool gate_present, + void __iomem *reg); + struct clk *imx_clk_fixup_divider(const char *name, const char *parent, void __iomem *reg, u8 shift, u8 width, void (*fixup)(u32 *val)); -- 2.7.4