dm: of_access: add ofnode_read_u64() support

only support of-live.

Change-Id: I37c10efa30ef46369f4a4ad7f16c4c758d6ad563
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
Joseph Chen 2018-10-24 15:57:05 +08:00 committed by Jianhong Chen
parent 03af66d3ee
commit d59cf5aebb
4 changed files with 68 additions and 0 deletions

View File

@ -439,6 +439,33 @@ int of_read_u32(const struct device_node *np, const char *propname, u32 *outp)
return 0;
}
/**
* of_property_read_u64 - Find and read a 64 bit integer from a property
* @np: device node from which the property value is to be read.
* @propname: name of the property to be searched.
* @out_value: pointer to return value, modified only if return value is 0.
*
* Search for a property in a device node and read a 64-bit value from
* it. Returns 0 on success, -EINVAL if the property does not exist,
* -ENODATA if property does not have a value, and -EOVERFLOW if the
* property data isn't large enough.
*
* The out_value is modified only if a valid u64 value can be decoded.
*/
int of_property_read_u64(const struct device_node *np, const char *propname,
u64 *out_value)
{
const __be32 *val = of_find_property_value_of_size(np, propname,
sizeof(*out_value));
if (IS_ERR(val))
return PTR_ERR(val);
*out_value = of_read_number(val, 2);
return 0;
}
int of_read_u32_array(const struct device_node *np, const char *propname,
u32 *out_values, size_t sz)
{

View File

@ -56,6 +56,21 @@ 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)
{
assert(ofnode_valid(node));
debug("%s: %s: ", __func__, propname);
if (ofnode_is_np(node)) {
return of_property_read_u64(ofnode_to_np(node), propname, outp);
} else {
printf("%s: not implement\n", __func__);
return -EINVAL;
}
return 0;
}
bool ofnode_read_bool(ofnode node, const char *propname)
{
const void *prop;

View File

@ -219,6 +219,22 @@ struct device_node *of_find_node_by_phandle(phandle handle);
*/
int of_read_u32(const struct device_node *np, const char *propname, u32 *outp);
/**
* of_property_read_u64 - Find and read a 64 bit integer from a property
* @np: device node from which the property value is to be read.
* @propname: name of the property to be searched.
* @out_value: pointer to return value, modified only if return value is 0.
*
* Search for a property in a device node and read a 64-bit value from
* it. Returns 0 on success, -EINVAL if the property does not exist,
* -ENODATA if property does not have a value, and -EOVERFLOW if the
* property data isn't large enough.
*
* The out_value is modified only if a valid u64 value can be decoded.
*/
int of_property_read_u64(const struct device_node *np, const char *propname,
u64 *out_value);
/**
* of_read_u32_array() - Find and read an array of 32 bit integers
*

View File

@ -227,6 +227,16 @@ static inline int ofnode_read_s32(ofnode node, const char *propname,
*/
int ofnode_read_u32_default(ofnode ref, const char *propname, u32 def);
/**
* ofnode_read_u64() - Read a 64-bit integer from a property
*
* @ref: valid node reference to read property from
* @propname: name of the property to read from
* @outp: place to put value (if found)
* @return 0 if OK, -ve on error
*/
int ofnode_read_u64(ofnode node, const char *propname, u64 *outp);
/**
* ofnode_read_s32_default() - Read a 32-bit integer from a property
*