1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

dm: core: Add ofnode function to read a 64-bit int

We have a 32-bit version of this function. Add a 64-bit version as well so
we can easily read 64-bit ints from the device tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2018-06-11 13:07:10 -06:00
parent 90c08fa038
commit 7e5196c409
4 changed files with 78 additions and 0 deletions

View File

@@ -55,6 +55,38 @@ int ofnode_read_s32_default(ofnode node, const char *propname, s32 def)
return def;
}
int ofnode_read_u64(ofnode node, const char *propname, u64 *outp)
{
const fdt64_t *cell;
int len;
assert(ofnode_valid(node));
debug("%s: %s: ", __func__, propname);
if (ofnode_is_np(node))
return of_read_u64(ofnode_to_np(node), propname, outp);
cell = fdt_getprop(gd->fdt_blob, ofnode_to_offset(node), propname,
&len);
if (!cell || len < sizeof(*cell)) {
debug("(not found)\n");
return -EINVAL;
}
*outp = fdt64_to_cpu(cell[0]);
debug("%#llx (%lld)\n", (unsigned long long)*outp,
(unsigned long long)*outp);
return 0;
}
int ofnode_read_u64_default(ofnode node, const char *propname, u64 def)
{
assert(ofnode_valid(node));
ofnode_read_u64(node, propname, &def);
return def;
}
bool ofnode_read_bool(ofnode node, const char *propname)
{
const void *prop;