From patchwork Tue Apr 9 08:26:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Bachraty X-Patchwork-Id: 2413371 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id EE2DF3FC71 for ; Tue, 9 Apr 2013 08:28:14 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UPTtu-0005Jt-6B; Tue, 09 Apr 2013 08:27:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UPTtS-0003Tg-Nz; Tue, 09 Apr 2013 08:27:06 +0000 Received: from mx01.lb01.inode.at ([62.99.145.1] helo=mx.inode.at) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UPTtO-0003TL-9W for linux-arm-kernel@lists.infradead.org; Tue, 09 Apr 2013 08:27:03 +0000 Received: from [81.89.61.168] (port=3480 helo=localhost.localdomain) by smartmx-01.inode.at with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1UPTtG-0004Wo-Fz; Tue, 09 Apr 2013 10:26:54 +0200 From: Michal Bachraty To: grant.likely@secretlab.ca, rob.herring@calxeda.com, rob@landley.net, mturquette@linaro.org Subject: [PATCH] clk: si5351: Add gapless tuning for SI5351 PLL Date: Tue, 9 Apr 2013 10:26:15 +0200 Message-Id: <1365495975-792-1-git-send-email-michal.bachraty@streamunlimited.com> X-Mailer: git-send-email 1.7.9.5 X-Authenticated-Sender: michal.bachraty@streamunlimited.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130409_042702_594674_916A104F X-CRM114-Status: GOOD ( 12.98 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [62.99.145.1 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Michal Bachraty , linux-doc@vger.kernel.org, devicetree-discuss@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, sebastian.hesselbarth@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For gapless tuning, there is no need for PLL reset and clkout power-down when tuning output. "silabs,gapless-tuning" parameter enables gapless tuning for specific clock output. Signed-off-by: Michal Bachraty --- .../devicetree/bindings/clock/silabs,si5351.txt | 2 ++ drivers/clk/clk-si5351.c | 27 +++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/clock/silabs,si5351.txt b/Documentation/devicetree/bindings/clock/silabs,si5351.txt index cc37465..e16ab2b 100644 --- a/Documentation/devicetree/bindings/clock/silabs,si5351.txt +++ b/Documentation/devicetree/bindings/clock/silabs,si5351.txt @@ -44,6 +44,8 @@ Optional child node properties: - silabs,multisynth-source: source pll A(0) or B(1) of corresponding multisynth divider. - silabs,pll-master: boolean, multisynth can change pll frequency. +- silabs,gapless-tuning: boolean, enable gapless (glitch-free) tuning. Depends on + "silabs,multisynth-source" parameter. ==Example== diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c index e259cec..d3933a9 100644 --- a/drivers/clk/clk-si5351.c +++ b/drivers/clk/clk-si5351.c @@ -54,6 +54,7 @@ struct si5351_hw_data { struct si5351_driver_data *drvdata; struct si5351_parameters params; unsigned char num; + unsigned char gapless_tuning; }; struct si5351_driver_data { @@ -526,8 +527,10 @@ static int si5351_pll_set_rate(struct clk_hw *hw, unsigned long rate, (hwdata->params.p2 == 0) ? SI5351_CLK_INTEGER_MODE : 0); /* reset pll */ - val = (hwdata->num == 0) ? SI5351_PLL_RESET_A : SI5351_PLL_RESET_B; - si5351_set_bits(hwdata->drvdata, SI5351_PLL_RESET, val, val); + if (!hwdata->gapless_tuning) { + val = (hwdata->num == 0) ? SI5351_PLL_RESET_A : SI5351_PLL_RESET_B; + si5351_set_bits(hwdata->drvdata, SI5351_PLL_RESET, val, val); + } dev_dbg(&hwdata->drvdata->client->dev, "%s - %s: p1 = %lu, p2 = %lu, p3 = %lu, parent_rate = %lu, rate = %lu\n", @@ -1064,8 +1067,9 @@ static int si5351_clkout_set_rate(struct clk_hw *hw, unsigned long rate, } while (1); /* powerdown clkout */ - si5351_set_bits(hwdata->drvdata, SI5351_CLK0_CTRL + hwdata->num, - SI5351_CLK_POWERDOWN, SI5351_CLK_POWERDOWN); + if (!hwdata->gapless_tuning) + si5351_set_bits(hwdata->drvdata, SI5351_CLK0_CTRL + hwdata->num, + SI5351_CLK_POWERDOWN, SI5351_CLK_POWERDOWN); /* write output divider */ switch (hwdata->num) { @@ -1117,6 +1121,7 @@ static void si5351_dt_setup( struct property *prop; const __be32 *p; unsigned int num, val; + int pll = -1; if (np == NULL) return; @@ -1167,6 +1172,8 @@ static void si5351_dt_setup( dev_warn(&client->dev, "unable to reparent multisynth %d to %d\n", num, val); + else + pll = val; } if (!of_property_read_u32(np, "silabs,clock-source", &val)) { @@ -1178,6 +1185,15 @@ static void si5351_dt_setup( if (!of_property_read_u32(np, "clock-frequency", &val)) clk_set_rate(drvdata->onecell.clks[num], val); + + if (of_property_read_bool(np, "silabs,gapless-tuning")) { + if (pll >= 0) { + drvdata->clkout[num].gapless_tuning = 1; + drvdata->pll[pll].gapless_tuning = 1; + } else + dev_warn(&client->dev, + "unable to set gapless tuning"); + } } } @@ -1294,6 +1310,7 @@ static int si5351_i2c_probe(struct i2c_client *client, drvdata->pll[0].num = 0; drvdata->pll[0].drvdata = drvdata; drvdata->pll[0].hw.init = &init; + drvdata->pll[0].gapless_tuning = 0; memset(&init, 0, sizeof(init)); init.name = si5351_pll_names[0]; init.ops = &si5351_pll_ops; @@ -1310,6 +1327,7 @@ static int si5351_i2c_probe(struct i2c_client *client, drvdata->pll[1].num = 1; drvdata->pll[1].drvdata = drvdata; drvdata->pll[1].hw.init = &init; + drvdata->pll[1].gapless_tuning = 0; memset(&init, 0, sizeof(init)); if (drvdata->variant == SI5351_VARIANT_B) { init.name = si5351_pll_names[2]; @@ -1380,6 +1398,7 @@ static int si5351_i2c_probe(struct i2c_client *client, drvdata->clkout[n].num = n; drvdata->clkout[n].drvdata = drvdata; drvdata->clkout[n].hw.init = &init; + drvdata->clkout[n].gapless_tuning = 0; memset(&init, 0, sizeof(init)); init.name = si5351_clkout_names[n]; init.ops = &si5351_clkout_ops;