diff --git a/drivers/core/device.c b/drivers/core/device.c index dcf5d9df7ddcbbcc25ac9754d976f95c8a1972dd..ed553d70a6bc0d62e22513f68fb8d2f9419c0075 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -693,6 +693,28 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) #endif } +fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index, + fdt_size_t *size) +{ +#if CONFIG_IS_ENABLED(OF_CONTROL) + /* + * Only get the size in this first call. We'll get the addr in the + * next call to the exisiting dev_get_xxx function which handles + * all config options. + */ + fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev->of_offset, + "reg", index, size, false); + + /* + * Get the base address via the existing function which handles + * all Kconfig cases + */ + return dev_get_addr_index(dev, index); +#else + return FDT_ADDR_T_NONE; +#endif +} + fdt_addr_t dev_get_addr_name(struct udevice *dev, const char *name) { #if CONFIG_IS_ENABLED(OF_CONTROL) diff --git a/include/dm/device.h b/include/dm/device.h index babf8ac8f078c97e7f9e6c081dc7f1a68214dc36..9948bd49fa53b86b54ea0b2775f27b9cf5577b1f 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -496,6 +496,22 @@ void *dev_map_physmem(struct udevice *dev, unsigned long size); */ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index); +/** + * dev_get_addr_size_index() - Get the indexed reg property of a device + * + * Returns the address and size specified in the 'reg' property of a device. + * + * @dev: Pointer to a device + * @index: the 'reg' property can hold a list of <addr, size> pairs + * and @index is used to select which one is required + * @size: Pointer to size varible - this function returns the size + * specified in the 'reg' property here + * + * @return addr + */ +fdt_addr_t dev_get_addr_size_index(struct udevice *dev, int index, + fdt_size_t *size); + /** * dev_get_addr_name() - Get the reg property of a device, indexed by name *