msm: clock: Move the common parts of the handoff code up to clock.c
This allows the clk_enable()/clk_disable() calls associated
with handoffs, as well as manipulation of CLKFLAG_HANDOFF_RATE,
to be contained entirely within clock.c instead of being spread
out in multiple SoC drivers.
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
diff --git a/arch/arm/mach-msm/clock-8960.c b/arch/arm/mach-msm/clock-8960.c
index 5d3c845..4a749d0 100644
--- a/arch/arm/mach-msm/clock-8960.c
+++ b/arch/arm/mach-msm/clock-8960.c
@@ -1186,7 +1186,7 @@
#define QDSS_CLK_ROOT_ENA BIT(1)
-static void qdss_clk_handoff(struct clk *c)
+static int qdss_clk_handoff(struct clk *c)
{
struct rcg_clk *clk = to_rcg_clk(c);
const struct qdss_bank *bank = clk->bank_info;
@@ -1195,7 +1195,7 @@
reg = readl_relaxed(clk->ns_reg);
if (!(reg & QDSS_CLK_ROOT_ENA))
- return;
+ return 0;
bank_sel = reg & bank->bank_sel_mask;
/* Force bank 1 to PXO if bank 0 is in use */
@@ -1209,11 +1209,11 @@
}
}
if (freq->freq_hz == FREQ_END)
- return;
+ return 0;
clk->current_freq = freq;
- c->flags |= CLKFLAG_HANDOFF_RATE;
- clk_enable(c);
+
+ return 1;
}
static void set_rate_qdss(struct rcg_clk *clk, struct clk_freq_tbl *nf)
diff --git a/arch/arm/mach-msm/clock-local.c b/arch/arm/mach-msm/clock-local.c
index cf75900..ea76512 100644
--- a/arch/arm/mach-msm/clock-local.c
+++ b/arch/arm/mach-msm/clock-local.c
@@ -712,7 +712,7 @@
return to_rcg_clk(clk)->current_freq->src_clk;
}
-void rcg_clk_handoff(struct clk *c)
+int rcg_clk_handoff(struct clk *c)
{
struct rcg_clk *clk = to_rcg_clk(c);
uint32_t ctl_val, ns_val, md_val, ns_mask;
@@ -720,7 +720,7 @@
ctl_val = readl_relaxed(clk->b.ctl_reg);
if (!(ctl_val & clk->root_en_mask))
- return;
+ return 0;
if (clk->bank_info) {
const struct bank_masks *bank_masks = clk->bank_info;
@@ -746,11 +746,11 @@
}
}
if (freq->freq_hz == FREQ_END)
- return;
+ return 0;
clk->current_freq = freq;
- c->flags |= CLKFLAG_HANDOFF_RATE;
- clk_enable(c);
+
+ return 1;
}
static int pll_vote_clk_enable(struct clk *clk)
diff --git a/arch/arm/mach-msm/clock-local.h b/arch/arm/mach-msm/clock-local.h
index 8448d07..f62e753 100644
--- a/arch/arm/mach-msm/clock-local.h
+++ b/arch/arm/mach-msm/clock-local.h
@@ -154,7 +154,7 @@
int rcg_clk_is_enabled(struct clk *clk);
long rcg_clk_round_rate(struct clk *clk, unsigned rate);
struct clk *rcg_clk_get_parent(struct clk *c);
-void rcg_clk_handoff(struct clk *c);
+int rcg_clk_handoff(struct clk *c);
/*
* SYS_VDD voltage levels
diff --git a/arch/arm/mach-msm/clock.c b/arch/arm/mach-msm/clock.c
index 1e3c38b..58a64a3 100644
--- a/arch/arm/mach-msm/clock.c
+++ b/arch/arm/mach-msm/clock.c
@@ -199,8 +199,12 @@
struct clk *clk = clock_tbl[n].clk;
struct clk *parent = clk_get_parent(clk);
clk_set_parent(clk, parent);
- if (clk->ops->handoff && !(clk->flags & CLKFLAG_HANDOFF_RATE))
- clk->ops->handoff(clk);
+ if (clk->ops->handoff && !(clk->flags & CLKFLAG_HANDOFF_RATE)) {
+ if (clk->ops->handoff(clk)) {
+ clk->flags |= CLKFLAG_HANDOFF_RATE;
+ clk_enable(clk);
+ }
+ }
}
clkdev_add_table(clock_tbl, num_clocks);
diff --git a/arch/arm/mach-msm/clock.h b/arch/arm/mach-msm/clock.h
index 44836be..5c1630c 100644
--- a/arch/arm/mach-msm/clock.h
+++ b/arch/arm/mach-msm/clock.h
@@ -37,7 +37,7 @@
int (*enable)(struct clk *clk);
void (*disable)(struct clk *clk);
void (*auto_off)(struct clk *clk);
- void (*handoff)(struct clk *clk);
+ int (*handoff)(struct clk *clk);
int (*reset)(struct clk *clk, enum clk_reset_action action);
int (*set_rate)(struct clk *clk, unsigned rate);
int (*set_min_rate)(struct clk *clk, unsigned rate);