From patchwork Tue Aug 19 04:36:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vince Hsu X-Patchwork-Id: 4740591 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C67059F39D for ; Tue, 19 Aug 2014 04:40:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E9C8C20123 for ; Tue, 19 Aug 2014 04:40:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A19E92011D for ; Tue, 19 Aug 2014 04:40:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJb95-00021H-Tr; Tue, 19 Aug 2014 04:35:43 +0000 Received: from hqemgate15.nvidia.com ([216.228.121.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XJb94-0001zx-3R for linux-arm-kernel@lists.infradead.org; Tue, 19 Aug 2014 04:35:42 +0000 Received: from hqnvupgp07.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com id ; Mon, 18 Aug 2014 21:35:28 -0700 Received: from hqemhub01.nvidia.com ([172.20.12.94]) by hqnvupgp07.nvidia.com (PGP Universal service); Mon, 18 Aug 2014 21:21:40 -0700 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Mon, 18 Aug 2014 21:21:40 -0700 Received: from [10.19.108.126] (172.20.144.16) by hqemhub01.nvidia.com (172.20.150.30) with Microsoft SMTP Server id 8.3.342.0; Mon, 18 Aug 2014 21:35:20 -0700 Message-ID: <53F2D454.2020000@nvidia.com> Date: Tue, 19 Aug 2014 12:36:36 +0800 From: Vince Hsu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Tuomas Tynkkynen , , , , Subject: Re: [PATCH v3 03/15] clk: tegra: Add closed loop support for the DFLL References: <1408419205-10048-1-git-send-email-tuomas.tynkkynen@iki.fi> <1408419205-10048-4-git-send-email-tuomas.tynkkynen@iki.fi> In-Reply-To: <1408419205-10048-4-git-send-email-tuomas.tynkkynen@iki.fi> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140818_213542_149363_29822DAD X-CRM114-Status: GOOD ( 19.05 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, Prashant Gaikwad , Mike Turquette , Stephen Warren , Viresh Kumar , Peter De Schrijver , "Rafael J. Wysocki" , Thierry Reding , Tuomas Tynkkynen , Paul Walmsley X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On 08/19/2014 11:33 AM, Tuomas Tynkkynen wrote: > From: Tuomas Tynkkynen > > With closed loop support, the clock rate of the DFLL can be adjusted. > > The oscillator itself in the DFLL is a free-running oscillator whose > rate is directly determined the supply voltage. However, the DFLL > module contains logic to compare the DFLL output rate to a fixed > reference clock (51 MHz) and make a decision to either lower or raise > the DFLL supply voltage. The DFLL module can then autonomously change > the supply voltage by communicating with an off-chip PMIC via either I2C > or PWM signals. This driver currently supports only I2C. > > Signed-off-by: Tuomas Tynkkynen > > --- > v3: Fix incorrect order of arguments to dfll_scale_dvco_rate > --- > drivers/clk/tegra/clk-dfll.c | 656 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 653 insertions(+), 3 deletions(-) ... > + > +/** > + * dfll_init_out_if - prepare DFLL-to-PMIC interface > + * @td: DFLL instance > + * > + * During DFLL driver initialization or resume from context loss, > + * disable the I2C command output to the PMIC, set safe voltage and > + * output limits, and disable and clear limit interrupts. > + */ > +static void dfll_init_out_if(struct tegra_dfll *td) > +{ > + u32 val; > + > + td->lut_min = 0; > + td->lut_max = td->i2c_lut_size - 1; > + td->lut_safe = td->lut_min + 1; > + > + dfll_i2c_writel(td, 0, DFLL_OUTPUT_CFG); > + val = (td->lut_safe << DFLL_OUTPUT_CFG_SAFE_SHIFT) | > + (td->lut_max << DFLL_OUTPUT_CFG_MAX_SHIFT) | > + (td->lut_min << DFLL_OUTPUT_CFG_MIN_SHIFT); > + dfll_writel(td, val, DFLL_OUTPUT_CFG); > + dfll_wmb(td); Sorry that I forgot to mention this in v2's comment. Could you squash the change below in this patch? And actually it's pretty easy to misuse the dfll read/write/wmb functions. We might want to have some generic functions for these, and let the generic functions handle the offset to different register blocks. commit 4a1fdd54141b4f8f9425d54cdad13c42763e6186 Author: Vince Hsu Date: Thu Aug 14 18:19:20 2014 +0800 clk: tegra: use the correct write funtion for DFLL_OUTPUT_CFG Signed-off-by: Vince Hsu seq_puts(s, "\nI2C and INTR REGISTERS:\n"); for (offs = DFLL_I2C_CFG; offs <= DFLL_I2C_STS; offs += 4) Thanks, Vince diff --git a/drivers/clk/tegra/clk-dfll.c b/drivers/clk/tegra/clk-dfll.c index 9b3eded6b880..71e4b256ea0d 100644 --- a/drivers/clk/tegra/clk-dfll.c +++ b/drivers/clk/tegra/clk-dfll.c @@ -645,7 +645,7 @@ static void dfll_init_out_if(struct tegra_dfll *td) val = (td->lut_safe << DFLL_OUTPUT_CFG_SAFE_SHIFT) | (td->lut_max << DFLL_OUTPUT_CFG_MAX_SHIFT) | (td->lut_min << DFLL_OUTPUT_CFG_MIN_SHIFT); - dfll_writel(td, val, DFLL_OUTPUT_CFG); + dfll_i2c_writel(td, val, DFLL_OUTPUT_CFG); - dfll_wmb(td); + dfll_i2c_wmb(td); dfll_writel(td, 0, DFLL_OUTPUT_FORCE); @@ -1146,7 +1146,8 @@ static int attr_registers_show(struct seq_file *s, void *data) seq_puts(s, "CONTROL REGISTERS:\n"); for (offs = 0; offs <= DFLL_MONITOR_DATA; offs += 4) seq_printf(s, "[0x%02x] = 0x%08x\n", offs, - dfll_readl(td, offs)); + offs == DFLL_OUTPUT_CFG ? dfll_i2c_readl(td, offs) : + dfll_readl(td, offs));