提交 43c4d44e 编写于 作者: S Stephen Warren 提交者: Simon Glass

fdt: implement dev_get_addr_name()

This function parses the reg property based on an index found in the
reg-names property. This is required for bindings that are written
using reg-names rather than hard-coding indices in reg.
Signed-off-by: NStephen Warren <swarren@nvidia.com>
Acked-by: NSimon Glass <sjg@chromium.org>
上级 690d8a92
...@@ -652,6 +652,22 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) ...@@ -652,6 +652,22 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
#endif #endif
} }
fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name)
{
#if CONFIG_IS_ENABLED(OF_CONTROL)
int index;
index = fdt_find_string(gd->fdt_blob, dev->parent->of_offset,
"reg-names", name);
if (index < 0)
return index;
return dev_get_addr_index(dev, index);
#else
return FDT_ADDR_T_NONE;
#endif
}
fdt_addr_t dev_get_addr(struct udevice *dev) fdt_addr_t dev_get_addr(struct udevice *dev)
{ {
return dev_get_addr_index(dev, 0); return dev_get_addr_index(dev, 0);
......
...@@ -464,6 +464,18 @@ fdt_addr_t dev_get_addr(struct udevice *dev); ...@@ -464,6 +464,18 @@ fdt_addr_t dev_get_addr(struct udevice *dev);
*/ */
fdt_addr_t dev_get_addr_index(struct udevice *dev, int index); fdt_addr_t dev_get_addr_index(struct udevice *dev, int index);
/**
* dev_get_addr_name() - Get the reg property of a device, indexed by name
*
* @dev: Pointer to a device
* @name: the 'reg' property can hold a list of <addr, size> pairs, with the
* 'reg-names' property providing named-based identification. @index
* indicates the value to search for in 'reg-names'.
*
* @return addr
*/
fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name);
/** /**
* device_has_children() - check if a device has any children * device_has_children() - check if a device has any children
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册