summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-11-29 16:27:17 -0800
committerGerrit <chrome-bot@google.com>2011-11-30 13:01:47 -0800
commite48f5d4d14f2e84593d262063b05797bc328dc83 (patch)
treebd83fa56dd618e920c9d6164d9e9783cee754821 /common
parent4a466bf48a887e3a2eba3e971a3a459b5cbc80be (diff)
fdt: Add function to read a clock rate from fdt
This reads the frequency of a named clock from the fdt. BUG=chromium-os:23496 TEST=build and boot on Seaboard, T33, Kaen Change-Id: Ib35bf7ef749f51862644218b1015057ca4e25203 Reviewed-on: https://gerrit.chromium.org/gerrit/12243 Reviewed-by: Che-Liang Chiou <clchiou@chromium.org> Commit-Ready: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/fdt_decode.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/fdt_decode.c b/common/fdt_decode.c
index 96807c47c9..3d956c3c16 100644
--- a/common/fdt_decode.c
+++ b/common/fdt_decode.c
@@ -718,3 +718,18 @@ int fdt_decode_region(const void *blob, int node,
debug("%s: size=%zx\n", __func__, *size);
return 0;
}
+
+int fdt_decode_clock_rate(const void *blob, const char *clock_name,
+ ulong default_rate)
+{
+ int node;
+
+ node = fdt_node_offset_by_compatible(blob, 0, "board-clocks");
+ if (node >= 0) {
+ node = lookup_phandle(blob, node, clock_name);
+ if (node >= 0)
+ return get_int(blob, node, "clock-frequency",
+ default_rate);
+ }
+ return default_rate;
+}