aboutsummaryrefslogtreecommitdiff
path: root/arch/powerpc/sysdev/mpc5xxx_clocks.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-18 11:22:08 +1000
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2009-06-18 11:22:08 +1000
commitb71a107c66ad952c9d35ec046a803efc89a80556 (patch)
treeeb1f77af4f14974ba40a413d7679b3a451295a3d /arch/powerpc/sysdev/mpc5xxx_clocks.c
parent4b337c5f245b6587ba844ac7bb13c313a2912f7b (diff)
parente7c5a4f292e0d1f4ba9a3a94b2c8e8b71e35b25a (diff)
Merge commit 'gcl/merge' into next
Manual merge of: drivers/net/fec_mpc52xx.c
Diffstat (limited to 'arch/powerpc/sysdev/mpc5xxx_clocks.c')
-rw-r--r--arch/powerpc/sysdev/mpc5xxx_clocks.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/arch/powerpc/sysdev/mpc5xxx_clocks.c b/arch/powerpc/sysdev/mpc5xxx_clocks.c
new file mode 100644
index 00000000000..34e12f9995f
--- /dev/null
+++ b/arch/powerpc/sysdev/mpc5xxx_clocks.c
@@ -0,0 +1,33 @@
+/**
+ * mpc5xxx_get_bus_frequency - Find the bus frequency for a device
+ * @node: device node
+ *
+ * Returns bus frequency (IPS on MPC512x, IPB on MPC52xx),
+ * or 0 if the bus frequency cannot be found.
+ */
+
+#include <linux/kernel.h>
+#include <linux/of_platform.h>
+
+unsigned int
+mpc5xxx_get_bus_frequency(struct device_node *node)
+{
+ struct device_node *np;
+ const unsigned int *p_bus_freq = NULL;
+
+ of_node_get(node);
+ while (node) {
+ p_bus_freq = of_get_property(node, "bus-frequency", NULL);
+ if (p_bus_freq)
+ break;
+
+ np = of_get_parent(node);
+ of_node_put(node);
+ node = np;
+ }
+ if (node)
+ of_node_put(node);
+
+ return p_bus_freq ? *p_bus_freq : 0;
+}
+EXPORT_SYMBOL(mpc5xxx_get_bus_frequency);