mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 1/2] hw_random: omap-rng: ignore clocks for OMAP3/4
Date: Tue, 10 Jun 2025 22:37:25 +0200	[thread overview]
Message-ID: <20250610203726.2769570-1-a.fatoum@pengutronix.de> (raw)

We do not have clock drivers for OMAP, including the AM33xx.
The omap-rng driver calls clk_get_optional and so far this returned
NULL, because CONFIG_COMMON_CLK_OF_PROVIDER was disabled.

In configurations with the option enabled, we get understandably an
error code, which makes the drive defer probe indefinitely.

We are unlikely to add clock drivers for am33xx after all these years,
so just tweak the RNG driver to require clock driver support only on K3
SoCs.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - add missing hunks for actually acting on ignore_clocks..
---
 drivers/hw_random/omap-rng.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/hw_random/omap-rng.c b/drivers/hw_random/omap-rng.c
index 6b69994aad0b..e6974d7769f4 100644
--- a/drivers/hw_random/omap-rng.c
+++ b/drivers/hw_random/omap-rng.c
@@ -133,6 +133,7 @@ struct omap_rng_dev;
  * @data_present: Callback to determine if data is available.
  * @init: Callback for IP specific initialization sequence.
  * @cleanup: Callback for IP specific cleanup sequence.
+ * @ignore_clocks: assume clocks are enabled (barebox-specific)
  */
 struct omap_rng_pdata {
 	u16	*regs;
@@ -140,6 +141,7 @@ struct omap_rng_pdata {
 	u32	(*data_present)(struct omap_rng_dev *priv);
 	int	(*init)(struct omap_rng_dev *priv);
 	void	(*cleanup)(struct omap_rng_dev *priv);
+	bool	ignore_clocks;
 };
 
 struct omap_rng_dev {
@@ -230,6 +232,7 @@ static struct omap_rng_pdata omap2_rng_pdata = {
 	.data_present	= omap2_rng_data_present,
 	.init		= omap2_rng_init,
 	.cleanup	= omap2_rng_cleanup,
+	.ignore_clocks	= true,
 };
 
 static inline u32 omap4_rng_data_present(struct omap_rng_dev *priv)
@@ -299,6 +302,7 @@ static struct omap_rng_pdata omap4_rng_pdata = {
 	.data_present	= omap4_rng_data_present,
 	.init		= omap4_rng_init,
 	.cleanup	= omap4_rng_cleanup,
+	.ignore_clocks	= true,
 };
 
 static struct omap_rng_pdata eip76_rng_pdata = {
@@ -336,10 +340,14 @@ static int of_get_omap_rng_device_details(struct omap_rng_dev *priv,
 	return 0;
 }
 
-static struct clk *ti_sysc_clk_get_enabled(struct device *dev, const char *clk_id)
+static struct clk *ti_sysc_clk_get_enabled(struct omap_rng_dev *priv,
+					   struct device *dev, const char *clk_id)
 {
 	struct clk *clk;
 
+	if (priv->pdata->ignore_clocks)
+		return NULL;
+
 	clk = clk_get_optional_enabled(dev, clk_id);
 	if (!clk)
 		clk = clk_get_optional_enabled(dev->parent, clk_id);
@@ -377,22 +385,22 @@ static int omap_rng_probe(struct device *dev)
 		goto err_ioremap;
 	}
 
-	priv->clk = ti_sysc_clk_get_enabled(dev, NULL);
+	ret = of_get_omap_rng_device_details(priv, dev);
+	if (ret)
+		goto err_ioremap;
+
+	priv->clk = ti_sysc_clk_get_enabled(priv, dev, NULL);
 	if (IS_ERR(priv->clk)) {
 		ret = PTR_ERR(priv->clk);
 		goto err_ioremap;
 	}
 
-	priv->clk_reg = ti_sysc_clk_get_enabled(dev, "reg");
+	priv->clk_reg = ti_sysc_clk_get_enabled(priv, dev, "reg");
 	if (IS_ERR(priv->clk_reg)) {
 		ret = PTR_ERR(priv->clk_reg);
 		goto err_ioremap;
 	}
 
-	ret = of_get_omap_rng_device_details(priv, dev);
-	if (ret)
-		goto err_register;
-
 	ret = hwrng_register(dev, &priv->rng);
 	if (ret)
 		goto err_register;
-- 
2.39.5




             reply	other threads:[~2025-06-10 22:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10 20:37 Ahmad Fatoum [this message]
2025-06-10 20:37 ` [PATCH v2 2/2] ARM: configs: omap_defconfig: enable HW_RANDOM_OMAP Ahmad Fatoum
2025-06-11  6:56 ` [PATCH v2 1/2] hw_random: omap-rng: ignore clocks for OMAP3/4 Sascha Hauer

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=20250610203726.2769570-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --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