From patchwork Tue May 7 08:14:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Belisko Marek X-Patchwork-Id: 2532411 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 A2C993FC5A for ; Tue, 7 May 2013 08:16:12 +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 1UZd3s-0006nt-O6; Tue, 07 May 2013 08:15:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UZd3k-00066F-Mc; Tue, 07 May 2013 08:15:40 +0000 Received: from mail-ea0-x22b.google.com ([2a00:1450:4013:c01::22b]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UZd3c-00064n-IJ for linux-arm-kernel@lists.infradead.org; Tue, 07 May 2013 08:15:33 +0000 Received: by mail-ea0-f171.google.com with SMTP id b10so136389eae.30 for ; Tue, 07 May 2013 01:15:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=pnhS/xM590CjNaEHbgAgccd0qAg7hmv85QlwTpMr7sc=; b=MdiepvEJNH3bA4UhA9j8+hWrjwQMBJ8xzh5exJFROJUbXPQrJT3j0Nxp2lbKraeesZ dD3Vz1g4/fW/iILmHEUgnAaRgnuLOWBtvUytyiP6FFPgXYr22iBn+w4H8lkYSy6n7X7L EDx/+tmYeFyfay5ZrGhh4RR6hPFTQrL8432g6U8ulyCzn9Si8niLNvD2NqN56fPPf6is Sx8Ta4Opj5o/hwTJaL99y0TFvQWejShjnQw1Jm+YiSyouQvfPsvjVNSkp+32W2cWAbhl fXYPoq0bLe/9HtjCahSJdI7CYKe/r3oCJp+V0riZN20Ppl/6L33J4t55KDnZ+au2zkmU f4qA== X-Received: by 10.15.67.203 with SMTP id u51mr2912430eex.22.1367914509245; Tue, 07 May 2013 01:15:09 -0700 (PDT) Received: from localhost.localdomain (81.89.61.168.vnet.sk. [81.89.61.168]) by mx.google.com with ESMTPSA id bj12sm37697575eeb.8.2013.05.07.01.15.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 07 May 2013 01:15:08 -0700 (PDT) From: Marek Belisko To: mturquette@linaro.org Subject: [PATCH 2/2] clk: si5351: Powerdown output when clock rate is 0. Date: Tue, 7 May 2013 10:14:51 +0200 Message-Id: <1367914491-17445-2-git-send-email-marek.belisko@streamunlimited.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1367914491-17445-1-git-send-email-marek.belisko@streamunlimited.com> References: <1367914491-17445-1-git-send-email-marek.belisko@streamunlimited.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130507_041532_781201_77DA8564 X-CRM114-Status: GOOD ( 13.29 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (marek.belisko[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Marek Belisko , daniel@zonque.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 When rate is 0 powerdown clock output. Signed-off-by: Marek Belisko --- drivers/clk/clk-si5351.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/clk/clk-si5351.c b/drivers/clk/clk-si5351.c index a8fc0f4..e254e76 100644 --- a/drivers/clk/clk-si5351.c +++ b/drivers/clk/clk-si5351.c @@ -1042,20 +1042,22 @@ static int si5351_clkout_set_rate(struct clk_hw *hw, unsigned long rate, struct si5351_hw_data *hwdata = container_of(hw, struct si5351_hw_data, hw); unsigned long new_rate, new_err, err; - unsigned char rdiv; + unsigned char rdiv, pdn = 0; /* round to closed rdiv */ rdiv = SI5351_OUTPUT_CLK_DIV_1; - new_rate = parent_rate; - err = abs(new_rate - rate); - do { - new_rate >>= 1; - new_err = abs(new_rate - rate); - if (new_err > err || rdiv == SI5351_OUTPUT_CLK_DIV_128) - break; - rdiv++; - err = new_err; - } while (1); + if (rate) { + new_rate = parent_rate; + err = abs(new_rate - rate); + do { + new_rate >>= 1; + new_err = abs(new_rate - rate); + if (new_err > err || rdiv == SI5351_OUTPUT_CLK_DIV_128) + break; + rdiv++; + err = new_err; + } while (1); + } /* write output divider */ switch (hwdata->num) { @@ -1075,9 +1077,13 @@ static int si5351_clkout_set_rate(struct clk_hw *hw, unsigned long rate, rdiv << SI5351_OUTPUT_CLK_DIV_SHIFT); } - /* powerup clkout */ + /* when rate is 0 powerdown output */ + if (rate == 0) + pdn = SI5351_CLK_POWERDOWN; + + /* powerup/down clkout */ si5351_set_bits(hwdata->drvdata, SI5351_CLK0_CTRL + hwdata->num, - SI5351_CLK_POWERDOWN, 0); + SI5351_CLK_POWERDOWN, pdn); dev_dbg(&hwdata->drvdata->client->dev, "%s - %s: rdiv = %u, parent_rate = %lu, rate = %lu\n",