[U-Boot] [PATCH] regmap: add support for address cell 2

Simon Glass sjg at chromium.org
Thu Feb 16 20:43:24 UTC 2017


Hi Kever,

On 13 February 2017 at 01:28, Kever Yang <kever.yang at rock-chips.com> wrote:
> ARM64 is using 64bit address which address cell is 2 instead of 1,
> update to support it when of-platdata enabled.
>
> Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
> ---
>
>  drivers/core/regmap.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
> index c68bcba..a1c0983 100644
> --- a/drivers/core/regmap.c
> +++ b/drivers/core/regmap.c
> @@ -39,6 +39,16 @@ static struct regmap *regmap_alloc_count(int count)
>  }
>
>  #if CONFIG_IS_ENABLED(OF_PLATDATA)
> +u64 fdtdec_get_number(const u32 *ptr, unsigned int cells)

This name is already used and seems misleading. How about of_plat_get_number()?

> +{
> +       u64 number = 0;
> +
> +       while (cells--)
> +               number = (number << 32) | (*ptr++);
> +
> +       return number;
> +}
> +
>  int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int count,
>                              struct regmap **mapp)
>  {
> @@ -48,13 +58,19 @@ int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int count,
>         map = regmap_alloc_count(count);
>         if (!map)
>                 return -ENOMEM;
> -
> +#ifdef CONFIG_ARM64

Can you use #ifdef CONFIG_PHYS_64BIT?

> +       map->base = fdtdec_get_number(reg, 2);
> +       for (range = map->range; count > 0; reg += 4, range++, count--) {
> +               range->start = fdtdec_get_number(reg, 2);
> +               range->size = fdtdec_get_number(reg + 2, 2);
> +       }
> +#else
>         map->base = *reg;
>         for (range = map->range; count > 0; reg += 2, range++, count--) {
>                 range->start = *reg;
>                 range->size = reg[1];
>         }
> -
> +#endif
>         *mapp = map;
>
>         return 0;
> --
> 1.9.1
>

Regards,
Simon


More information about the U-Boot mailing list