[U-Boot] [PATCH 02/13] dm: core: Add a new api to get indexed device address

Simon Glass sjg at chromium.org
Thu Oct 29 18:17:42 CET 2015


Hi Mugunthan,

On 27 October 2015 at 05:12, Mugunthan V N <mugunthanvnm at ti.com> wrote:
> Add new api to get device address based on index.
>
> Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
> ---
>  drivers/core/device.c | 20 ++++++++++++++++++++
>  include/dm/device.h   |  9 +++++++++
>  2 files changed, 29 insertions(+)
>
> diff --git a/drivers/core/device.c b/drivers/core/device.c
> index a3dc2ca..7557e5c 100644
> --- a/drivers/core/device.c
> +++ b/drivers/core/device.c
> @@ -620,6 +620,26 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
>  #endif
>  }
>
> +fdt_addr_t dev_get_addr_index(struct udevice *dev, int index)
> +{
> +#if CONFIG_IS_ENABLED(OF_CONTROL)
> +       fdt_addr_t addr;
> +

I think you are missing the 'if (CONFIG_IS_ENABLED(OF_TRANSLATE)) {'
logic from dev_get_addr(). Also that function should call your new
function I think to avoid duplicated code.

> +       addr = fdtdec_get_addr_size_auto_parent(gd->fdt_blob,
> +                                               dev->parent->of_offset,
> +                                               dev->of_offset, "reg",
> +                                               index, NULL);
> +       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);
> +       }
> +
> +       return addr;
> +#else
> +       return FDT_ADDR_T_NONE;
> +#endif
> +}
> +
>  bool device_has_children(struct udevice *dev)
>  {
>         return !list_empty(&dev->child_head);
> diff --git a/include/dm/device.h b/include/dm/device.h
> index 8519612..e6506b4 100644
> --- a/include/dm/device.h
> +++ b/include/dm/device.h
> @@ -441,6 +441,15 @@ int device_find_next_child(struct udevice **devp);
>  fdt_addr_t dev_get_addr(struct udevice *dev);
>
>  /**
> + * dev_get_addr() - Get the reg property of a device
> + *
> + * @dev: Pointer to a device
> + *
> + * @return addr

Please update the comment here with the new parameter and what it does.

> + */
> +fdt_addr_t dev_get_addr_index(struct udevice *dev, int index);
> +
> +/**
>   * device_has_children() - check if a device has any children
>   *
>   * @dev:       Device to check
> --
> 2.6.2.280.g74301d6
>

Regards,
Simon


More information about the U-Boot mailing list