dm: core: add function dev_write_u32_array() to write u32 array values
Change-Id: I6633395c7704eefff59c2145562fe239e21f3b35 Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
7b4692447b
commit
04539b46d5
|
|
@ -485,6 +485,25 @@ int of_read_u32_array(const struct device_node *np, const char *propname,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int of_write_u32_array(const struct device_node *np, const char *propname,
|
||||||
|
u32 *values, size_t sz)
|
||||||
|
{
|
||||||
|
__be32 *val;
|
||||||
|
|
||||||
|
debug("%s: %s: ", __func__, propname);
|
||||||
|
val = of_find_property_value_of_size(np, propname,
|
||||||
|
sz * sizeof(*values));
|
||||||
|
|
||||||
|
if (IS_ERR(val))
|
||||||
|
return PTR_ERR(val);
|
||||||
|
|
||||||
|
debug("size %zd\n", sz);
|
||||||
|
while (sz--)
|
||||||
|
*val++ = cpu_to_be32p(values++);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int of_property_match_string(const struct device_node *np, const char *propname,
|
int of_property_match_string(const struct device_node *np, const char *propname,
|
||||||
const char *string)
|
const char *string)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,21 @@ int ofnode_read_u32_array(ofnode node, const char *propname,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ofnode_write_u32_array(ofnode node, const char *propname,
|
||||||
|
u32 *values, size_t sz)
|
||||||
|
{
|
||||||
|
assert(ofnode_valid(node));
|
||||||
|
debug("%s: %s: ", __func__, propname);
|
||||||
|
|
||||||
|
if (ofnode_is_np(node)) {
|
||||||
|
return of_write_u32_array(ofnode_to_np(node), propname,
|
||||||
|
values, sz);
|
||||||
|
} else {
|
||||||
|
return fdt_setprop((void *)gd->fdt_blob, ofnode_to_offset(node),
|
||||||
|
propname, values, sz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ofnode ofnode_first_subnode(ofnode node)
|
ofnode ofnode_first_subnode(ofnode node)
|
||||||
{
|
{
|
||||||
assert(ofnode_valid(node));
|
assert(ofnode_valid(node));
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,14 @@ int dev_read_u32_array(struct udevice *dev, const char *propname,
|
||||||
return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz);
|
return ofnode_read_u32_array(dev_ofnode(dev), propname, out_values, sz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int dev_write_u32_array(struct udevice *dev, const char *propname,
|
||||||
|
u32 *values, size_t sz)
|
||||||
|
{
|
||||||
|
if (!dev_of_valid(dev))
|
||||||
|
return -EINVAL;
|
||||||
|
return ofnode_write_u32_array(dev_ofnode(dev), propname, values, sz);
|
||||||
|
}
|
||||||
|
|
||||||
const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *propname,
|
const uint8_t *dev_read_u8_array_ptr(struct udevice *dev, const char *propname,
|
||||||
size_t sz)
|
size_t sz)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,22 @@ int of_property_read_u64(const struct device_node *np, const char *propname,
|
||||||
int of_read_u32_array(const struct device_node *np, const char *propname,
|
int of_read_u32_array(const struct device_node *np, const char *propname,
|
||||||
u32 *out_values, size_t sz);
|
u32 *out_values, size_t sz);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* of_write_u32_array() - Find and write an array of 32 bit integers
|
||||||
|
*
|
||||||
|
* Search for a property in a device node and write 32-bit value(s) to
|
||||||
|
* it.
|
||||||
|
*
|
||||||
|
* @np: device node from which the property value is to be read.
|
||||||
|
* @propname: name of the property to be searched.
|
||||||
|
* @values: pointer to update value, modified only if return value is 0.
|
||||||
|
* @sz: number of array elements to read
|
||||||
|
* @return 0 on success, -EINVAL if the property does not exist, -ENODATA
|
||||||
|
* if property does not have a value, and -EOVERFLOW is longer than sz.
|
||||||
|
*/
|
||||||
|
int of_write_u32_array(const struct device_node *np, const char *propname,
|
||||||
|
u32 *values, size_t sz);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of_property_match_string() - Find string in a list and return index
|
* of_property_match_string() - Find string in a list and return index
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,19 @@ const char *ofnode_read_string(ofnode node, const char *propname);
|
||||||
int ofnode_read_u32_array(ofnode node, const char *propname,
|
int ofnode_read_u32_array(ofnode node, const char *propname,
|
||||||
u32 *out_values, size_t sz);
|
u32 *out_values, size_t sz);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ofnode_write_u32_array() - Find and write an array of 32 bit integers
|
||||||
|
*
|
||||||
|
* @node: valid node reference to read property from
|
||||||
|
* @propname: name of the property to read
|
||||||
|
* @values: pointer to update value, modified only if return value is 0
|
||||||
|
* @sz: number of array elements to read
|
||||||
|
* @return 0 on success, -EINVAL if the property does not exist, -ENODATA
|
||||||
|
* if property does not have a value, and -EOVERFLOW is longer than sz.
|
||||||
|
*/
|
||||||
|
int ofnode_write_u32_array(ofnode node, const char *propname,
|
||||||
|
u32 *values, size_t sz);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ofnode_read_bool() - read a boolean value from a property
|
* ofnode_read_bool() - read a boolean value from a property
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -341,6 +341,25 @@ int dev_read_alias_seq(struct udevice *dev, int *devnump);
|
||||||
int dev_read_u32_array(struct udevice *dev, const char *propname,
|
int dev_read_u32_array(struct udevice *dev, const char *propname,
|
||||||
u32 *out_values, size_t sz);
|
u32 *out_values, size_t sz);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* dev_write_u32_array() - Find and write an array of 32 bit integers
|
||||||
|
*
|
||||||
|
* Search for a property in a device node and write 32-bit value(s) to
|
||||||
|
* it.
|
||||||
|
*
|
||||||
|
* The out_values is modified only if a valid u32 value can be decoded.
|
||||||
|
*
|
||||||
|
* @dev: device to look up
|
||||||
|
* @propname: name of the property to read
|
||||||
|
* @values: pointer to update value, modified only if return value is 0
|
||||||
|
* @sz: number of array elements to read
|
||||||
|
* @return 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.
|
||||||
|
*/
|
||||||
|
int dev_write_u32_array(struct udevice *dev, const char *propname,
|
||||||
|
u32 *values, size_t sz);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dev_read_first_subnode() - find the first subnode of a device's node
|
* dev_read_first_subnode() - find the first subnode of a device's node
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue