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

Kever Yang kever.yang at rock-chips.com
Mon Feb 13 08:28:04 UTC 2017


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)
+{
+	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
+	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



More information about the U-Boot mailing list