msm: clock-rpm: Add support for CXO/PXO clock resources
The CXO_CLK and PXO_CLK resources have historically been
controlled by the msm_xo driver. Add support for these to the
clock driver so that consumers of these clocks can use the clock
APIs instead of an MSM specific API.
Change-Id: I76b8dbcf6bbe26494186f68faff1b2e41ce2c2e3
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/arch/arm/mach-msm/clock-rpm.c b/arch/arm/mach-msm/clock-rpm.c
index 4757f7d..fc2e83f 100644
--- a/arch/arm/mach-msm/clock-rpm.c
+++ b/arch/arm/mach-msm/clock-rpm.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -23,9 +23,9 @@
static int rpm_clk_enable(struct clk *clk)
{
unsigned long flags;
- struct msm_rpm_iv_pair iv;
- int rc = 0;
struct rpm_clk *r = to_rpm_clk(clk);
+ struct msm_rpm_iv_pair iv = { .id = r->rpm_clk_id };
+ int rc = 0;
unsigned long this_khz, this_sleep_khz;
unsigned long peer_khz = 0, peer_sleep_khz = 0;
struct rpm_clk *peer = r->peer;
@@ -39,8 +39,6 @@
this_sleep_khz = r->last_set_sleep_khz;
- iv.id = r->rpm_clk_id;
-
/* Take peer clock's rate into account only if it's enabled. */
if (peer->enabled) {
peer_khz = peer->last_set_khz;
@@ -48,11 +46,16 @@
}
iv.value = max(this_khz, peer_khz);
+ if (r->branch)
+ iv.value = !!iv.value;
+
rc = msm_rpmrs_set_noirq(MSM_RPM_CTX_SET_0, &iv, 1);
if (rc)
goto out;
iv.value = max(this_sleep_khz, peer_sleep_khz);
+ if (r->branch)
+ iv.value = !!iv.value;
rc = msm_rpmrs_set_noirq(MSM_RPM_CTX_SET_SLEEP, &iv, 1);
if (rc) {
iv.value = peer_khz;
@@ -76,25 +79,23 @@
spin_lock_irqsave(&rpm_clock_lock, flags);
if (r->last_set_khz) {
- struct msm_rpm_iv_pair iv;
+ struct msm_rpm_iv_pair iv = { .id = r->rpm_clk_id };
struct rpm_clk *peer = r->peer;
unsigned long peer_khz = 0, peer_sleep_khz = 0;
int rc;
- iv.id = r->rpm_clk_id;
-
/* Take peer clock's rate into account only if it's enabled. */
if (peer->enabled) {
peer_khz = peer->last_set_khz;
peer_sleep_khz = peer->last_set_sleep_khz;
}
- iv.value = peer_khz;
+ iv.value = r->branch ? !!peer_khz : peer_khz;
rc = msm_rpmrs_set_noirq(MSM_RPM_CTX_SET_0, &iv, 1);
if (rc)
goto out;
- iv.value = peer_sleep_khz;
+ iv.value = r->branch ? !!peer_sleep_khz : peer_sleep_khz;
rc = msm_rpmrs_set_noirq(MSM_RPM_CTX_SET_SLEEP, &iv, 1);
}
r->enabled = false;
@@ -186,6 +187,12 @@
return false;
}
+static unsigned long rpm_branch_clk_get_rate(struct clk *clk)
+{
+ struct rpm_clk *r = to_rpm_clk(clk);
+ return r->last_set_khz * 1000;
+}
+
struct clk_ops clk_ops_rpm = {
.enable = rpm_clk_enable,
.disable = rpm_clk_disable,
@@ -195,3 +202,10 @@
.round_rate = rpm_clk_round_rate,
.is_local = rpm_clk_is_local,
};
+
+struct clk_ops clk_ops_rpm_branch = {
+ .enable = rpm_clk_enable,
+ .disable = rpm_clk_disable,
+ .is_local = rpm_clk_is_local,
+ .get_rate = rpm_branch_clk_get_rate,
+};