From: Kever Yang <kever.yang@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] regmap: add support for address cell 2
Date: Mon, 13 Feb 2017 16:28:04 +0800 [thread overview]
Message-ID: <1486974484-5684-1-git-send-email-kever.yang@rock-chips.com> (raw)
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>
---
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
next reply other threads:[~2017-02-13 8:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-13 8:28 Kever Yang [this message]
2017-02-16 20:43 ` [U-Boot] [PATCH] regmap: add support for address cell 2 Simon Glass
2017-03-06 9:43 ` Kever Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486974484-5684-1-git-send-email-kever.yang@rock-chips.com \
--to=kever.yang@rock-chips.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.