All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Binacchi <dariobin@libero.it>
To: linux-kernel@vger.kernel.org
Cc: Dario Binacchi <dariobin@libero.it>,
	Bin Meng <bmeng.cn@gmail.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>, Tero Kristo <kristo@kernel.org>,
	linux-clk@vger.kernel.org, linux-omap@vger.kernel.org
Subject: [PATCH 2/2] clk: ti: get register address from device tree
Date: Fri,  2 Apr 2021 21:20:54 +0200	[thread overview]
Message-ID: <20210402192054.7934-3-dariobin@libero.it> (raw)
In-Reply-To: <20210402192054.7934-1-dariobin@libero.it>

Until now, only the register offset was retrieved from the device tree
to be added, during access, to a common base address for the clocks.
If possible, we try to retrieve the physical address of the register
directly from the device tree.

Signed-off-by: Dario Binacchi <dariobin@libero.it>

---

 drivers/clk/ti/clk.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index 3da33c786d77..938f5a2cb425 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -265,9 +265,21 @@ int __init ti_clk_retry_init(struct device_node *node, void *user,
 int ti_clk_get_reg_addr(struct device_node *node, int index,
 			struct clk_omap_reg *reg)
 {
+	const __be32 *addrp;
+	u64 size, addr = OF_BAD_ADDR;
+	unsigned int flags;
 	u32 val;
 	int i;
 
+	addrp = of_get_address(node, index, &size, &flags);
+	if (addrp)
+		addr = of_translate_address(node, addrp);
+
+	if (addr != OF_BAD_ADDR) {
+		reg->ptr = ioremap(addr, sizeof(u32));
+		return 0;
+	}
+
 	for (i = 0; i < CLK_MAX_MEMMAPS; i++) {
 		if (clocks_node_ptr[i] == node->parent)
 			break;
@@ -287,7 +299,6 @@ int ti_clk_get_reg_addr(struct device_node *node, int index,
 
 	reg->offset = val;
 	reg->ptr = NULL;
-
 	return 0;
 }
 
-- 
2.17.1


  parent reply	other threads:[~2021-04-02 19:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 19:20 [PATCH 0/2] fdt: translate address if #size-cells = <0> Dario Binacchi
2021-04-02 19:20 ` [PATCH 1/2] " Dario Binacchi
2021-04-02 19:20 ` Dario Binacchi [this message]
2021-04-06  6:02   ` [PATCH 2/2] clk: ti: get register address from device tree Tero Kristo
2021-04-06 14:06 ` [PATCH 0/2] fdt: translate address if #size-cells = <0> Rob Herring
2021-04-06 22:02   ` Dario Binacchi
2021-04-07  1:16     ` Rob Herring
2021-04-07  7:07       ` Dario Binacchi
2021-04-07 12:52         ` Rob Herring
2021-04-07 13:21           ` Tero Kristo
2021-04-08 20:24             ` Dario Binacchi
2021-04-09 10:32               ` Tero Kristo
2021-04-11 19:30                 ` Dario Binacchi
2021-04-12  7:41                   ` Tero Kristo
2021-04-14 20:39                     ` Dario Binacchi
2021-04-17  8:37                       ` Tony Lindgren

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=20210402192054.7934-3-dariobin@libero.it \
    --to=dariobin@libero.it \
    --cc=bmeng.cn@gmail.com \
    --cc=kristo@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    /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.