dm: core: add functions to get/remap I/O addresses by name
This functions allow us to get and remap I/O addresses by name, which is useful when there are multiple reg addresses indexed by reg-names property. This is needed in bmips dma/eth patch series, but can also be used on many other drivers. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Simon Glass
parent
bb48470df2
commit
7959882049
@@ -69,6 +69,26 @@ void *dev_remap_addr_index(struct udevice *dev, int index)
|
||||
return map_physmem(addr, 0, MAP_NOCACHE);
|
||||
}
|
||||
|
||||
fdt_addr_t dev_read_addr_name(struct udevice *dev, const char *name)
|
||||
{
|
||||
int index = dev_read_stringlist_search(dev, "reg-names", name);
|
||||
|
||||
if (index < 0)
|
||||
return FDT_ADDR_T_NONE;
|
||||
else
|
||||
return dev_read_addr_index(dev, index);
|
||||
}
|
||||
|
||||
void *dev_remap_addr_name(struct udevice *dev, const char *name)
|
||||
{
|
||||
fdt_addr_t addr = dev_read_addr_name(dev, name);
|
||||
|
||||
if (addr == FDT_ADDR_T_NONE)
|
||||
return NULL;
|
||||
|
||||
return map_physmem(addr, 0, MAP_NOCACHE);
|
||||
}
|
||||
|
||||
fdt_addr_t dev_read_addr(struct udevice *dev)
|
||||
{
|
||||
return dev_read_addr_index(dev, 0);
|
||||
|
||||
Reference in New Issue
Block a user