summaryrefslogtreecommitdiff
path: root/arch/arm/mach-tegra/clock.c
diff options
context:
space:
mode:
authorScott Williams <scwilliams@nvidia.com>2010-12-07 11:19:20 -0800
committerDan Willemsen <dwillemsen@nvidia.com>2011-04-26 15:48:38 -0700
commit5e5807fa30957aeac0a6ce727e9ce98c79ec6b8b (patch)
tree65e08bdaeede5b93cc2db9c9ef9ed8e79c07703f /arch/arm/mach-tegra/clock.c
parent464936c9afcab046e38fb8f7851627a7ac0520de (diff)
[ARM/tegra] Add Tegra3 support
Bug 764354 Original-Change-Id: I8a390eb4dae87dceacb97461f23d13554868b046 Reviewed-on: http://git-master/r/12228 Reviewed-by: Scott Williams <scwilliams@nvidia.com> Tested-by: Scott Williams <scwilliams@nvidia.com> Change-Id: I8e6b8303898796419fb5a759cd16edff9aeac081
Diffstat (limited to 'arch/arm/mach-tegra/clock.c')
-rw-r--r--arch/arm/mach-tegra/clock.c42
1 files changed, 30 insertions, 12 deletions
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 2ee342f35e2d..ce90eb97cc08 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -142,6 +142,9 @@ static unsigned long clk_predict_rate_from_parent(struct clk *c, struct clk *p)
rate = clk_get_rate(p);
+ if (c->ops && c->ops->recalculate_rate)
+ c->ops->recalculate_rate(c);
+
if (c->mul != 0 && c->div != 0) {
rate *= c->mul;
rate += c->div / 2; /* round up */
@@ -351,7 +354,7 @@ int clk_set_rate(struct clk *c, unsigned long rate)
{
int ret = 0;
unsigned long flags;
- unsigned long old_rate;
+ unsigned long old_rate, max_rate;
long new_rate;
clk_lock_save(c, flags);
@@ -363,8 +366,11 @@ int clk_set_rate(struct clk *c, unsigned long rate)
old_rate = clk_get_rate_locked(c);
- if (rate > c->max_rate)
- rate = c->max_rate;
+ max_rate = c->max_rate;
+ if (c->ops && c->ops->get_max_rate)
+ max_rate = c->ops->get_max_rate(c);
+ if (rate > max_rate)
+ rate = max_rate;
if (c->ops && c->ops->round_rate) {
new_rate = c->ops->round_rate(c, rate);
@@ -406,6 +412,8 @@ unsigned long clk_get_rate_all_locked(struct clk *c)
while (p) {
c = p;
+ if (c->ops && c->ops->recalculate_rate)
+ c->ops->recalculate_rate(c);
if (c->mul != 0 && c->div != 0) {
mul *= c->mul;
div *= c->div;
@@ -422,7 +430,7 @@ unsigned long clk_get_rate_all_locked(struct clk *c)
long clk_round_rate(struct clk *c, unsigned long rate)
{
- unsigned long flags;
+ unsigned long flags, max_rate;
long ret;
clk_lock_save(c, flags);
@@ -432,8 +440,11 @@ long clk_round_rate(struct clk *c, unsigned long rate)
goto out;
}
- if (rate > c->max_rate)
- rate = c->max_rate;
+ max_rate = c->max_rate;
+ if (c->ops && c->ops->get_max_rate)
+ max_rate = c->ops->get_max_rate(c);
+ if (rate > max_rate)
+ rate = max_rate;
ret = c->ops->round_rate(c, rate);
@@ -506,20 +517,22 @@ EXPORT_SYMBOL(tegra_clk_init_from_table);
void tegra_periph_reset_deassert(struct clk *c)
{
- tegra2_periph_reset_deassert(c);
+ BUG_ON(!c->ops->reset);
+ c->ops->reset(c, false);
}
EXPORT_SYMBOL(tegra_periph_reset_deassert);
void tegra_periph_reset_assert(struct clk *c)
{
- tegra2_periph_reset_assert(c);
+ BUG_ON(!c->ops->reset);
+ c->ops->reset(c, true);
}
EXPORT_SYMBOL(tegra_periph_reset_assert);
void __init tegra_init_clock(void)
{
- tegra2_init_clocks();
- tegra2_init_dvfs();
+ tegra_soc_init_clocks();
+ tegra_soc_init_dvfs();
}
/*
@@ -697,6 +710,11 @@ static void clock_tree_show_one(struct seq_file *s, struct clk *c, int level)
struct clk *child;
const char *state = "uninit";
char div[8] = {0};
+ unsigned long rate = clk_get_rate_all_locked(c);
+ unsigned long max_rate = c->max_rate;
+
+ if (c->ops && c->ops->get_max_rate)
+ max_rate = c->ops->get_max_rate(c);
if (c->state == ON)
state = "on";
@@ -722,10 +740,10 @@ static void clock_tree_show_one(struct seq_file *s, struct clk *c, int level)
seq_printf(s, "%*s%c%c%-*s %-6s %-3d %-8s %-10lu\n",
level * 3 + 1, "",
- c->rate > c->max_rate ? '!' : ' ',
+ rate > max_rate ? '!' : ' ',
!c->set ? '*' : ' ',
30 - level * 3, c->name,
- state, c->refcnt, div, clk_get_rate_all_locked(c));
+ state, c->refcnt, div, rate);
if (c->dvfs)
dvfs_show_one(s, c->dvfs, level + 1);