summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/clock.c
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2011-02-21 15:47:24 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:34:13 -0800
commit50983012b693831e04c73741de5d31496945c144 (patch)
treecfc2793f89a869a76fbf93babe62633c7cb05a11 /arch/arm/mach-tegra/clock.c
parentf8f07bb03a90aefe7edc5f7bc7df2b86c7fe4c9a (diff)
ARM: tegra: clock: Disable clocks left on by bootloader
Iterates through all clocks, disabling any for which the refcount is 0 but the clock init detected the bootloader left the clock on. Can be disabled with command line tegra_keep_boot_clocks Signed-off-by: Colin Cross <ccross@android.com>
Diffstat (limited to 'arch/arm/mach-tegra/clock.c')
-rw-r--r--arch/arm/mach-tegra/clock.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index f8d41ffc0ca9..48d50d3cbde7 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -416,6 +416,51 @@ void tegra_sdmmc_tap_delay(struct clk *c, int delay)
spin_unlock_irqrestore(&c->spinlock, flags);
}
+static bool tegra_keep_boot_clocks = false;
+static int __init tegra_keep_boot_clocks_setup(char *__unused)
+{
+ tegra_keep_boot_clocks = true;
+ return 1;
+}
+__setup("tegra_keep_boot_clocks", tegra_keep_boot_clocks_setup);
+
+/*
+ * Iterate through all clocks, disabling any for which the refcount is 0
+ * but the clock init detected the bootloader left the clock on.
+ */
+static int __init tegra_init_disable_boot_clocks(void)
+{
+ struct clk *c;
+
+ mutex_lock(&clock_list_lock);
+
+ list_for_each_entry(c, &clocks, node) {
+ spin_lock_irq(&c->spinlock);
+
+ if (c->refcnt == 0 && c->state == ON &&
+ c->ops && c->ops->disable) {
+ pr_warn_once("%s clocks left on by bootloader:\n",
+ tegra_keep_boot_clocks ?
+ "Prevented disabling" :
+ "Disabling");
+
+ pr_warn(" %s\n", c->name);
+
+ if (!tegra_keep_boot_clocks) {
+ c->ops->disable(c);
+ c->state = OFF;
+ }
+ }
+
+ spin_unlock_irq(&c->spinlock);
+ }
+
+ mutex_unlock(&clock_list_lock);
+
+ return 0;
+}
+late_initcall(tegra_init_disable_boot_clocks);
+
#ifdef CONFIG_DEBUG_FS
static int __clk_lock_all_spinlocks(void)