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.h b/arch/arm/mach-msm/clock-rpm.h
index 24df9b6..27afd6f 100644
--- a/arch/arm/mach-msm/clock-rpm.h
+++ b/arch/arm/mach-msm/clock-rpm.h
@@ -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
@@ -18,6 +18,7 @@
 
 struct clk_ops;
 extern struct clk_ops clk_ops_rpm;
+extern struct clk_ops clk_ops_rpm_branch;
 
 struct rpm_clk {
 	const int rpm_clk_id;
@@ -27,6 +28,7 @@
 	/* 0 if active_only. Otherwise, same as last_set_khz. */
 	unsigned last_set_sleep_khz;
 	bool enabled;
+	bool branch; /* true: RPM only accepts 1 for ON and 0 for OFF */
 
 	struct rpm_clk *peer;
 	struct clk c;
@@ -65,4 +67,35 @@
 		}, \
 	};
 
+#define DEFINE_CLK_RPM_BRANCH(name, active, r_id, rate) \
+	static struct rpm_clk active; \
+	static struct rpm_clk name = { \
+		.rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \
+		.rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \
+		.peer = &active, \
+		.last_set_khz = ((rate) / 1000), \
+		.last_set_sleep_khz = ((rate) / 1000), \
+		.branch = true, \
+		.c = { \
+			.ops = &clk_ops_rpm_branch, \
+			.flags = CLKFLAG_SKIP_AUTO_OFF, \
+			.dbg_name = #name, \
+			CLK_INIT(name.c), \
+		}, \
+	}; \
+	static struct rpm_clk active = { \
+		.rpm_clk_id = MSM_RPM_ID_##r_id##_CLK, \
+		.rpm_status_id = MSM_RPM_STATUS_ID_##r_id##_CLK, \
+		.peer = &name, \
+		.last_set_khz = ((rate) / 1000), \
+		.active_only = true, \
+		.branch = true, \
+		.c = { \
+			.ops = &clk_ops_rpm_branch, \
+			.flags = CLKFLAG_SKIP_AUTO_OFF, \
+			.dbg_name = #active, \
+			CLK_INIT(active.c), \
+		}, \
+	};
+
 #endif