[U-Boot] [PATCH] dm: core: Enable optional use of fdt_translate_address()
Simon Glass
sjg at chromium.org
Fri Sep 4 05:56:25 CEST 2015
Hi Stefan,
On 2 September 2015 at 00:22, Stefan Roese <sr at denx.de> wrote:
> The current "simple" address translation simple_bus_translate() is not
> working on some platforms (e.g. MVEBU). As here more complex "ranges"
> properties are used in many nodes (multiple tuples etc). This patch
> enables the optional use of the common fdt_translate_address() function
> which handles this translation correctly.
>
> Signed-off-by: Stefan Roese <sr at denx.de>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Bin Meng <bmeng.cn at gmail.com>
> Cc: Marek Vasut <marex at denx.de>
> Cc: Masahiro Yamada <yamada.masahiro at socionext.com>
> ---
> drivers/core/Kconfig | 30 ++++++++++++++++++++++++++++++
> drivers/core/device.c | 8 +++++++-
> 2 files changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig
> index 41f4e69..15681df 100644
> --- a/drivers/core/Kconfig
> +++ b/drivers/core/Kconfig
> @@ -120,4 +120,34 @@ config SPL_SIMPLE_BUS
> Supports the 'simple-bus' driver, which is used on some systems
> in SPL.
>
> +config OF_TRANSLATE
> + bool "Translate addresses using fdt_translate_address"
> + depends on DM && OF_CONTROL
> + default y
> + help
> + If this option is enabled, the reg property will be translated
> + using the fdt_translate_address() function. This is necessary
> + on some platforms (e.g. MVEBU) using complex "ranges"
> + properties in many nodes. As this translation is not handled
> + correctly in the default simple_bus_translate() function.
> +
> + If this option is not enabled, simple_bus_translate() will be
> + used for the address translation. This function is faster and
> + smaller in size than fdt_translate_address().
> +
> +config SPL_OF_TRANSLATE
> + bool "Translate addresses using fdt_translate_address"
> + depends on SPL_DM && SPL_OF_CONTROL
> + default n
> + help
> + If this option is enabled, the reg property will be translated
> + using the fdt_translate_address() function. This is necessary
> + on some platforms (e.g. MVEBU) using complex "ranges"
> + properties in many nodes. As this translation is not handled
> + correctly in the default simple_bus_translate() function.
> +
> + If this option is not enabled, simple_bus_translate() will be
> + used for the address translation. This function is faster and
> + smaller in size than fdt_translate_address().
> +
> endmenu
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index a6cd936..0cf73cf 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -11,6 +11,7 @@
>
> #include <common.h>
> #include <fdtdec.h>
> +#include <fdt_support.h>
> #include <malloc.h>
> #include <dm/device.h>
> #include <dm/device-internal.h>
> @@ -580,7 +581,12 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
> fdt_addr_t addr;
>
> addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
> - if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
> + if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {
> + const fdt32_t *reg = fdt_getprop(gd->fdt_blob, dev->of_offset,
> + "reg", NULL);
You could put the assignment in a separate statement. Also check if
!reg and return FDT_ADDR_T_NONE.
> + addr = fdt_translate_address((void *)gd->fdt_blob,
> + dev->of_offset, reg);
> + } else if (CONFIG_IS_ENABLED(SIMPLE_BUS) && addr != FDT_ADDR_T_NONE) {
> if (device_get_uclass_id(dev->parent) == UCLASS_SIMPLE_BUS)
> addr = simple_bus_translate(dev->parent, addr);
> }
> --
> 2.5.1
>
Regards,
Simon
More information about the U-Boot
mailing list