public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robherring2@gmail.com>
To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org
Cc: Mike Turquette <mturquette@linaro.org>,
	Mark Langsdorf <mark.langsdorf@calxeda.com>,
	Rob Herring <rob.herring@calxeda.com>
Subject: [PATCH 4/7] clk: highbank: prevent glitching when going into bypass mode
Date: Wed,  4 Dec 2013 17:35:24 -0600	[thread overview]
Message-ID: <1386200127-23143-5-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1386200127-23143-1-git-send-email-robherring2@gmail.com>

From: Mark Langsdorf <mark.langsdorf@calxeda.com>

Under very rare circumstances, the clock multiplexer can take around
100 ns to enter bypass mode. Attempting to reprogram the clock PLL
before the clock has fully entered bypass mode can cause errors in the
system, up to and including kernel panics. Add a 300 ns delay after
programming the bypass enable to make sure that bypass mode has been
enabled.

This patch should be added to the stable series.

Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com>
Cc: Mike Turquette <mturquette@linaro.org>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
---
 drivers/clk/clk-highbank.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/clk/clk-highbank.c b/drivers/clk/clk-highbank.c
index 2e7e9d9..dc7ca30 100644
--- a/drivers/clk/clk-highbank.c
+++ b/drivers/clk/clk-highbank.c
@@ -21,6 +21,7 @@
 #include <linux/io.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/delay.h>
 
 #define HB_PLL_LOCK_500		0x20000000
 #define HB_PLL_LOCK		0x10000000
@@ -167,6 +168,8 @@ static int clk_pll_set_rate(struct clk_hw *hwclk, unsigned long rate,
 		/* Need to re-lock PLL, so put it into bypass mode */
 		reg |= HB_PLL_EXT_BYPASS;
 		writel(reg | HB_PLL_EXT_BYPASS, hbclk->reg);
+		/* delay to make sure we are in bypass */
+		ndelay(300);
 
 		writel(reg | HB_PLL_RESET, hbclk->reg);
 		reg &= ~(HB_PLL_DIVF_MASK | HB_PLL_DIVQ_MASK);
@@ -182,6 +185,9 @@ static int clk_pll_set_rate(struct clk_hw *hwclk, unsigned long rate,
 		reg &= ~HB_PLL_EXT_BYPASS;
 	} else {
 		writel(reg | HB_PLL_EXT_BYPASS, hbclk->reg);
+		/* delay to make sure we are in bypass */
+		ndelay(300);
+
 		reg &= ~HB_PLL_DIVQ_MASK;
 		reg |= divq << HB_PLL_DIVQ_SHIFT;
 		writel(reg | HB_PLL_EXT_BYPASS, hbclk->reg);
-- 
1.8.3.2


  parent reply	other threads:[~2013-12-04 23:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-04 23:35 [PATCH 0/7] Calxeda arm64 clock updates Rob Herring
2013-12-04 23:35 ` [PATCH 1/7] dt-bindings: add Calxeda ECX-3000 clock binding Rob Herring
2013-12-04 23:35 ` [PATCH 2/7] dt-bindings: Add property calxeda,pll-max-hz for Calxeda clocks Rob Herring
2013-12-04 23:35 ` [PATCH 3/7] dt-bindings: Add Calxeda system registers binding Rob Herring
2013-12-04 23:35 ` Rob Herring [this message]
2013-12-04 23:35 ` [PATCH 5/7] clk: highbank: allow for different PLL frequency range Rob Herring
2013-12-04 23:35 ` [PATCH 6/7] clk: highbank: allow enabling by user Rob Herring
2013-12-04 23:35 ` [PATCH 7/7] clk: highbank: add DT match for calxeda,ecx-3000-sregs Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1386200127-23143-5-git-send-email-robherring2@gmail.com \
    --to=robherring2@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.langsdorf@calxeda.com \
    --cc=mturquette@linaro.org \
    --cc=rob.herring@calxeda.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox