dm: core: Add dev_get_addr_size_index() to retrieve addr and size
PATCH v2 1/1 dm: core: Add dev_get_addr_size_index() to retrieve addr and size
The currently available functions accessing the 'reg' property of a device only retrieve the address. Sometimes its also necessary to retrieve the size described by the 'reg' property. This patch adds the new function dev_get_addr_size_index() which retrieves both, the address and the size described by the 'reg' property.
---
v2:
- Account 'index' in fdtdec_get_addr_size_auto_noparent() as spotted by Simon
drivers/core/device.c | 22 ++++++++++++++++++++++ include/dm/device.h | 16 ++++++++++++++++ 2 files changed, 38 insertions(+)
drivers/core/device.c +22 -0
@@ -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 )
include/dm/device.h +16 -0
@@ -497,6 +497,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 * * @dev: Pointer to a device
Signature · 1 line
2.11.0
PATCH v2 1/1 dm: core: Add dev_get_addr_size_index() to retrieve addr and size
Quoted 8 lines · Stefan Roese
The currently available functions accessing the 'reg' property of a device only retrieve the address. Sometimes its also necessary to retrieve the size described by the 'reg' property. This patch adds the new function
dev_get_addr_size_index()which retrieves both, the address and the size described by the 'reg' property.Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>
Quoted 9 lines
---
v2:
- Account 'index' infdtdec_get_addr_size_auto_noparent()as spotted by Simondrivers/core/device.c | 22 ++++++++++++++++++++++ include/dm/device.h | 16 ++++++++++++++++ 2 files changed, 38 insertions(+)
But please check below.
Quoted 9 lines
drivers/core/device.c +1
-0@@ -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,
drivers/core/device.c fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) · line 706
Quoted 10 lines
drivers/core/device.c +10
-0+ 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);
The return value is not checked here. Is this because the dev_get_addr_index() function will return the same error?
drivers/core/device.c fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) · line 717
Quoted 11 lines
drivers/core/device.c +11
-0+ +/* +* 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 +} +
[...]
Regards,
Simon
PATCH v2 1/1 dm: core: Add dev_get_addr_size_index() to retrieve addr and size
Hi Simon,
Quoted 31 lines · Simon Glass
Quoted 8 lines · Stefan Roese
The currently available functions accessing the 'reg' property of a device only retrieve the address. Sometimes its also necessary to retrieve the size described by the 'reg' property. This patch adds the new function
dev_get_addr_size_index()which retrieves both, the address and the size described by the 'reg' property.Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Quoted 9 lines
---
v2:
- Account 'index' infdtdec_get_addr_size_auto_noparent()as spotted by Simondrivers/core/device.c | 22 ++++++++++++++++++++++ include/dm/device.h | 16 ++++++++++++++++ 2 files changed, 38 insertions(+)Acked-by Simon Glass <[email protected]>But please check below.
Quoted 8 lines
drivers/core/device.c +0
-0@@ -693,6 +693,28 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)#endif }
Quoted 14 lines
drivers/core/device.c fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) · line 706
Quoted 11 lines
drivers/core/device.c +11
-0+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);The return value is not checked here. Is this because the
dev_get_addr_index()function will return the same error?
Exactly. I didn't check the return value deliberately, as mentioned in the comment above. I thought this would be clear enough but if you don't think so, I can extend the comment a bit more.
Thanks,
Stefan
PATCH v2 1/1 dm: core: Add dev_get_addr_size_index() to retrieve addr and size
Quoted 56 lines · Stefan Roese
Hi Simon,
Quoted 34 lines · Simon Glass
Quoted 9 lines · Stefan Roese
The currently available functions accessing the 'reg' property of a device only retrieve the address. Sometimes its also necessary to retrieve the size described by the 'reg' property. This patch adds the new function
dev_get_addr_size_index()which retrieves both, the address and the size described by the 'reg' property.Signed-off-by Stefan Roese <[email protected]>Cc Simon Glass <[email protected]>Quoted 9 lines
---
v2:
- Account 'index' infdtdec_get_addr_size_auto_noparent()as spotted by Simondrivers/core/device.c | 22 ++++++++++++++++++++++ include/dm/device.h | 16 ++++++++++++++++ 2 files changed, 38 insertions(+)Acked-by Simon Glass <[email protected]>But please check below.
Quoted 9 lines
drivers/core/device.c +0
-0@@ -693,6 +693,28 @@ fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)#endif }Quoted 16 lines
drivers/core/device.c fdt_addr_t dev_get_addr_index(struct udevice *dev, int index) · line 706
Quoted 12 lines
drivers/core/device.c +6
-0+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
drivers/core/device.c +5
-0+* 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);The return value is not checked here. Is this because the
dev_get_addr_index()function will return the same error?
Quoted 6 lines
Exactly. I didn't check the return value deliberately, as mentioned in the comment above. I thought this would be clear enough but if you don't think so, I can extend the comment a bit more.
Thanks,
Stefan
Applied to u-boot-dm, thanks!