u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: Simon Glass <sjg@chromium.org>, Rick Chen <rick@andestech.com>,
	Leo Yu-Chi Liang <ycliang@andestech.com>,
	u-boot@lists.denx.de
Subject: [PATCH 5/9] dm: core: Add a new API devfdt_get_addr_index_ptr()
Date: Sun, 12 Sep 2021 11:15:12 +0800	[thread overview]
Message-ID: <20210912031516.24885-5-bmeng.cn@gmail.com> (raw)
In-Reply-To: <20210912031516.24885-1-bmeng.cn@gmail.com>

At present there is only devfdt_get_addr_ptr() which only returns
the first <addr, size> pair in the 'reg' property. Add a new API
devfdt_get_addr_index_ptr() to return the indexed pointer.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/core/fdtaddr.c | 11 ++++++++---
 include/dm/fdtaddr.h   | 12 ++++++++++++
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/core/fdtaddr.c b/drivers/core/fdtaddr.c
index 4ffbd6b2eb..8dbb06ab03 100644
--- a/drivers/core/fdtaddr.c
+++ b/drivers/core/fdtaddr.c
@@ -93,6 +93,13 @@ fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index)
 #endif
 }
 
+void *devfdt_get_addr_index_ptr(const struct udevice *dev, int index)
+{
+	fdt_addr_t addr = devfdt_get_addr_index(dev, index);
+
+	return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr;
+}
+
 fdt_addr_t devfdt_get_addr_size_index(const struct udevice *dev, int index,
 				      fdt_size_t *size)
 {
@@ -155,9 +162,7 @@ fdt_addr_t devfdt_get_addr(const struct udevice *dev)
 
 void *devfdt_get_addr_ptr(const struct udevice *dev)
 {
-	fdt_addr_t addr = devfdt_get_addr_index(dev, 0);
-
-	return (addr == FDT_ADDR_T_NONE) ? NULL : (void *)(uintptr_t)addr;
+	return devfdt_get_addr_index_ptr(dev, 0);
 }
 
 void *devfdt_remap_addr_index(const struct udevice *dev, int index)
diff --git a/include/dm/fdtaddr.h b/include/dm/fdtaddr.h
index a4fda581a7..d2c1994291 100644
--- a/include/dm/fdtaddr.h
+++ b/include/dm/fdtaddr.h
@@ -92,6 +92,18 @@ void *devfdt_map_physmem(const struct udevice *dev, unsigned long size);
  */
 fdt_addr_t devfdt_get_addr_index(const struct udevice *dev, int index);
 
+/**
+ * devfdt_get_addr_index_ptr() - Return indexed pointer to the address of the
+ *                               reg property of a device
+ *
+ * @dev: Pointer to a device
+ * @index: the 'reg' property can hold a list of <addr, size> pairs
+ *	   and @index is used to select which one is required
+ *
+ * @return Pointer to addr, or NULL if there is no such property
+ */
+void *devfdt_get_addr_index_ptr(const struct udevice *dev, int index);
+
 /**
  * devfdt_get_addr_size_index() - Get the indexed reg property of a device
  *
-- 
2.25.1


  parent reply	other threads:[~2021-09-12  3:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-12  3:15 [PATCH 1/9] cache: sifive: Fix -Wint-to-pointer-cast warning Bin Meng
2021-09-12  3:15 ` [PATCH 2/9] clk: " Bin Meng
2021-09-15  3:46   ` Leo Liang
2021-09-12  3:15 ` [PATCH 3/9] gpio: " Bin Meng
2021-09-15  3:57   ` Leo Liang
2021-09-12  3:15 ` [PATCH 4/9] i2c: ocores: " Bin Meng
2021-09-15  4:39   ` Leo Liang
2021-09-12  3:15 ` Bin Meng [this message]
2021-09-15  7:21   ` [PATCH 5/9] dm: core: Add a new API devfdt_get_addr_index_ptr() Leo Liang
2021-09-30  4:09   ` Simon Glass
2021-09-12  3:15 ` [PATCH 6/9] dm: Provide dev_read_addr_index_ptr() wrapper Bin Meng
2021-09-15  7:23   ` Leo Liang
2021-09-30  4:09   ` Simon Glass
2021-09-12  3:15 ` [PATCH 7/9] net: macb: Fix -Wint-to-pointer-cast warnings Bin Meng
2021-09-13 18:40   ` Ramon Fried
2021-09-12  3:15 ` [PATCH 8/9] ram: sifive: " Bin Meng
2021-09-15  7:25   ` Leo Liang
2021-09-12  3:15 ` [PATCH 9/9] board: sifive: Fix -Wint-to-pointer-cast warning Bin Meng
2021-09-15  7:26   ` Leo Liang
2021-09-15  3:40 ` [PATCH 1/9] cache: " Leo Liang
2021-10-11  3:14   ` Bin Meng
2021-10-12  7:43     ` Leo Liang

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=20210912031516.24885-5-bmeng.cn@gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=rick@andestech.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=ycliang@andestech.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).