
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@rock-chips.com ---
Changes in v3: - move of_plat_get_number() into lib/of_plat.c
Changes in v2: - rename the fdtdec_get_number() to of_plat_get_number()
drivers/core/regmap.c | 9 +++++++++ include/of_plat.h | 22 ++++++++++++++++++++++ lib/Makefile | 3 +++ lib/of_plat.c | 17 +++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 include/of_plat.h create mode 100644 lib/of_plat.c
diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c index 3bec3df..c03279e 100644 --- a/drivers/core/regmap.c +++ b/drivers/core/regmap.c @@ -12,6 +12,7 @@ #include <malloc.h> #include <mapmem.h> #include <regmap.h> +#include <of_plat.h>
#include <asm/io.h>
@@ -49,11 +50,19 @@ int regmap_init_mem_platdata(struct udevice *dev, u32 *reg, int 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;
diff --git a/include/of_plat.h b/include/of_plat.h new file mode 100644 index 0000000..0badabb --- /dev/null +++ b/include/of_plat.h @@ -0,0 +1,22 @@ +/* + * (C) Copyright 2017 Rockchip Electronics Co., Ltd + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __of_plat_h +#define __of_plat_h + +#include "libfdt_env.h" +/** + * Get a variable-sized number from a property + * + * This reads a number from one or more cells. + * + * @param ptr Pointer to property + * @param cells Number of cells containing the number + * @return the value in the cells + */ +u64 of_plat_get_number(const fdt32_t *ptr, unsigned int cells); + +#endif diff --git a/lib/Makefile b/lib/Makefile index 23e9f1e..a988965 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -55,6 +55,9 @@ obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec_common.o obj-$(CONFIG_$(SPL_)OF_CONTROL) += fdtdec.o endif
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_SPL_OF_PLATDATA),yy) +obj-$(CONFIG_$(SPL_)OF_CONTROL) += of_plat.o +endif ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_YMODEM_SUPPORT) += crc16.o obj-$(CONFIG_SPL_NET_SUPPORT) += net_utils.o diff --git a/lib/of_plat.c b/lib/of_plat.c new file mode 100644 index 0000000..cf1cd1e --- /dev/null +++ b/lib/of_plat.c @@ -0,0 +1,17 @@ +/* + * (C) Copyright 2017 Rockchip Electronics Co., Ltd + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include "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; +}