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

Simon Glass sjg at chromium.org
Thu Mar 16 01:40:06 UTC 2017


Hi Kever,

On 6 March 2017 at 04:20, 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(-)

Reviewed-by: Simon Glass <sjg at chromium.org>

But please see below.

>
> diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
> index 833cd78..b00c347 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)

It looks like this function should go in a new file, perhaps lib/of_plat.c
with the prototype in a header of_plat.h?

> +u64 of_plat_get_number(const u32 *ptr, unsigned int cells)
> +{
> + 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_PHYS_64BIT
> + map->base = of_plat_get_number(reg, 2);
> + for (range = map->range; count > 0; reg += 4, range++, count--) {
> + range->start = of_plat_get_number(reg, 2);
> + range->size = of_plat_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