mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Subject: [PATCH v2] mfd: syscon: enable specified clocks on syscon_base_lookup_by_phandle
Date: Wed, 15 Apr 2020 11:11:42 +0200	[thread overview]
Message-ID: <20200415091142.1639141-1-ahmad@a3f.at> (raw)

Since commit b36b7b72 ("mfd: syscon: clock peripheral if specified in
device tree"), we now clock syscons during access if the device tree nodes
indicate a clocks property. We haven't been doing this for
syscon_base_lookup_by_phandle though, because we did this as part of the
regmap access functions, but that function returns a direct pointer to
the MMIO region.

The best way forward is probably dropping the syscon_base API altogether
and change users to the regmap API instead, but for now, make the behavior
consistent by enabling it permanently.

This makes use safe from breakage that results from upstream device trees moving
a clock from the consumer to the syscon provider (like in [1])

I've reviewed the current driver code users of syscon_base_lookup_by_phandle
and all upstream device trees that match against the drivers lack
a clocks property, so this shouldn't alter behavior (for now).

[1]: c9322d4fe ("net: designware: eqos: stm32: drop no longer needed syscfg-clk")

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
v1 -> v2:
  - as clks are reference counted, we don't need to detach the regmap
    clock. This makes the patch smaller and easier to follow.
---
 drivers/mfd/syscon.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 67e2ebb6c2f5..f867c078e7ba 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -128,10 +128,20 @@ static struct syscon *node_to_syscon(struct device_node *np)
 static void __iomem *syscon_node_to_base(struct device_node *np)
 {
 	struct syscon *syscon = node_to_syscon(np);
+	struct clk *clk;
 
 	if (IS_ERR(syscon))
 		return ERR_CAST(syscon);
 
+	/* Returning the direct pointer here side steps the regmap
+	 * and any specified clock wouldn't be enabled on access.
+	 * Deal with this by enabling the clock permanently if any
+	 * syscon_node_to_base users exist.
+	 */
+	clk = of_clk_get(np, 0);
+	if (!IS_ERR(clk))
+		clk_enable(clk);
+
 	return syscon->base;
 }
 
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2020-04-15  9:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200415091142.1639141-1-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox