summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@chromium.org>2012-10-25 16:31:05 +0000
committerGerald Van Baren <gvb@unssw.com>2012-11-12 23:14:57 -0500
commitaadef0a1bc3db81708471c9d18eb6c756659196f (patch)
treea08327dfcaab8d16aec6d534164ee526419f002b /lib
parent79289c0b5ff4a8c7869d7ca629cddc660dd06095 (diff)
downloadu-boot-aadef0a1bc3db81708471c9d18eb6c756659196f.tar.gz
u-boot-aadef0a1bc3db81708471c9d18eb6c756659196f.tar.xz
u-boot-aadef0a1bc3db81708471c9d18eb6c756659196f.zip
fdt: Add fdtdec_get_uint64 to decode a 64-bit value from a property
It decodes a 64-bit value from a property that is at least 8 bytes long. Signed-off-by: Che-Liang Chiou <clchiou@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/fdtdec.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index da12df209c..150512e5a8 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -111,6 +111,19 @@ s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
return default_val;
}
+uint64_t fdtdec_get_uint64(const void *blob, int node, const char *prop_name,
+ uint64_t default_val)
+{
+ const uint64_t *cell64;
+ int length;
+
+ cell64 = fdt_getprop(blob, node, prop_name, &length);
+ if (!cell64 || length < sizeof(*cell64))
+ return default_val;
+
+ return fdt64_to_cpu(*cell64);
+}
+
int fdtdec_get_is_enabled(const void *blob, int node)
{
const char *cell;