From: ccross@android.com (Colin Cross)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/7] ARM: tegra: clock: Check for clk_num == 0
Date: Mon, 21 Feb 2011 18:39:48 -0800 [thread overview]
Message-ID: <1298342392-21236-4-git-send-email-ccross@android.com> (raw)
In-Reply-To: <1298342392-21236-1-git-send-email-ccross@android.com>
Peripheral clocks that have no clock enable bit in the
enable registers have their clk_num set to 0. Bit 0
in the clock enable registers is the CPU clock.
Prevent disables on these peripheral clocks from
accidentally disabling the CPU clock.
Signed-off-by: Colin Cross <ccross@android.com>
---
arch/arm/mach-tegra/tegra2_clocks.c | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
index 73e112f..3015a2c 100644
--- a/arch/arm/mach-tegra/tegra2_clocks.c
+++ b/arch/arm/mach-tegra/tegra2_clocks.c
@@ -946,9 +946,14 @@ static void tegra2_periph_clk_init(struct clk *c)
}
c->state = ON;
+
+ if (!c->u.periph.clk_num)
+ return;
+
if (!(clk_readl(CLK_OUT_ENB + PERIPH_CLK_TO_ENB_REG(c)) &
PERIPH_CLK_TO_ENB_BIT(c)))
c->state = OFF;
+
if (!(c->flags & PERIPH_NO_RESET))
if (clk_readl(RST_DEVICES + PERIPH_CLK_TO_ENB_REG(c)) &
PERIPH_CLK_TO_ENB_BIT(c))
@@ -962,6 +967,9 @@ static int tegra2_periph_clk_enable(struct clk *c)
int refcount;
pr_debug("%s on clock %s\n", __func__, c->name);
+ if (!c->u.periph.clk_num)
+ return 0;
+
spin_lock_irqsave(&clock_register_lock, flags);
refcount = tegra_periph_clk_enable_refcount[c->u.periph.clk_num]++;
@@ -994,6 +1002,9 @@ static void tegra2_periph_clk_disable(struct clk *c)
pr_debug("%s on clock %s\n", __func__, c->name);
+ if (!c->u.periph.clk_num)
+ return;
+
spin_lock_irqsave(&clock_register_lock, flags);
if (c->refcnt)
@@ -1012,6 +1023,9 @@ static void tegra2_periph_clk_reset(struct clk *c, bool assert)
pr_debug("%s %s on clock %s\n", __func__,
assert ? "assert" : "deassert", c->name);
+
+ BUG_ON(!c->u.periph.clk_num);
+
if (!(c->flags & PERIPH_NO_RESET))
clk_writel(PERIPH_CLK_TO_ENB_BIT(c),
base + PERIPH_CLK_TO_ENB_SET_REG(c));
@@ -1182,6 +1196,10 @@ static void tegra2_clk_double_init(struct clk *c)
c->mul = 2;
c->div = 1;
c->state = ON;
+
+ if (!c->u.periph.clk_num)
+ return;
+
if (!(clk_readl(CLK_OUT_ENB + PERIPH_CLK_TO_ENB_REG(c)) &
PERIPH_CLK_TO_ENB_BIT(c)))
c->state = OFF;
@@ -1269,6 +1287,9 @@ static void tegra2_cdev_clk_init(struct clk *c)
/* We could un-tristate the cdev1 or cdev2 pingroup here; this is
* currently done in the pinmux code. */
c->state = ON;
+
+ BUG_ON(!c->u.periph.clk_num);
+
if (!(clk_readl(CLK_OUT_ENB + PERIPH_CLK_TO_ENB_REG(c)) &
PERIPH_CLK_TO_ENB_BIT(c)))
c->state = OFF;
@@ -1276,6 +1297,8 @@ static void tegra2_cdev_clk_init(struct clk *c)
static int tegra2_cdev_clk_enable(struct clk *c)
{
+ BUG_ON(!c->u.periph.clk_num);
+
clk_writel(PERIPH_CLK_TO_ENB_BIT(c),
CLK_OUT_ENB_SET + PERIPH_CLK_TO_ENB_SET_REG(c));
return 0;
@@ -1283,6 +1306,8 @@ static int tegra2_cdev_clk_enable(struct clk *c)
static void tegra2_cdev_clk_disable(struct clk *c)
{
+ BUG_ON(!c->u.periph.clk_num);
+
clk_writel(PERIPH_CLK_TO_ENB_BIT(c),
CLK_OUT_ENB_CLR + PERIPH_CLK_TO_ENB_SET_REG(c));
}
--
1.7.3.1
next prev parent reply other threads:[~2011-02-22 2:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-22 2:39 [PATCH 0/7] Second batch of Tegra clock updates for 2.6.39 Colin Cross
2011-02-22 2:39 ` [PATCH 1/7] ARM: tegra: clock: Refcount periph clock enables Colin Cross
2011-02-22 5:25 ` Olof Johansson
2011-02-22 2:39 ` [PATCH 2/7] ARM: tegra: clock: Round rate before setting rate Colin Cross
2011-02-22 5:26 ` Olof Johansson
2011-02-22 2:39 ` Colin Cross [this message]
2011-02-22 5:29 ` [PATCH 3/7] ARM: tegra: clock: Check for clk_num == 0 Olof Johansson
2011-02-22 2:39 ` [PATCH 4/7] ARM: tegra: Move tegra_common_init to tegra_init_early Colin Cross
2011-02-22 5:30 ` Olof Johansson
2011-02-22 2:39 ` [PATCH 5/7] ARM: tegra: timer: Enable timer and rtc clocks Colin Cross
2011-02-22 5:32 ` Olof Johansson
2011-02-22 8:00 ` Colin Cross
2011-02-22 15:28 ` Olof Johansson
2011-02-22 20:56 ` Russell King - ARM Linux
2011-02-23 17:39 ` Colin Cross
2011-02-22 2:39 ` [PATCH 6/7] ARM: tegra: common: Enable core clocks Colin Cross
2011-02-22 5:32 ` Olof Johansson
2011-02-22 2:39 ` [PATCH 7/7] ARM: tegra: clock: Disable clocks left on by bootloader Colin Cross
2011-02-22 5:43 ` Olof Johansson
2011-02-22 8:05 ` Colin Cross
2011-02-22 15:30 ` Olof Johansson
2011-02-22 19:38 ` [PATCH 0/7] Second batch of Tegra clock updates for 2.6.39 Colin Cross
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=1298342392-21236-4-git-send-email-ccross@android.com \
--to=ccross@android.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).