U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bastien Curutchet <bastien.curutchet@bootlin.com>
To: u-boot@lists.denx.de
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 Tom Rini <trini@konsulko.com>, Lukasz Majewski <lukma@denx.de>,
	 Peng Fan <peng.fan@nxp.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	 Heiko Schocher <hs@nabladev.com>,
	 Patrice Chotard <patrice.chotard@foss.st.com>,
	 Anshul Dalal <anshuld@ti.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	 Mattijs Korpershoek <mkorpershoek@kernel.org>,
	 Quentin Schulz <quentin.schulz@cherry.de>,
	 Andre Przywara <andre.przywara@arm.com>,
	 Hrushikesh Salunke <h-salunke@ti.com>,
	 Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	 Alif Zakuan Yuslaimi <alif.zakuan.yuslaimi@altera.com>,
	 Casey Connolly <casey.connolly@linaro.org>,
	 Justin Swartz <justin.swartz@risingedge.co.za>,
	 Daniel Palmer <daniel@thingy.jp>, Andrew Davis <afd@ti.com>,
	 Tien Fong Chee <tien.fong.chee@altera.com>,
	 Rasmus Villemoes <ravi@prevas.dk>,
	 Neil Armstrong <neil.armstrong@linaro.org>,
	 Alexey Charkov <alchark@gmail.com>,
	 Bastien Curutchet <bastien.curutchet@bootlin.com>
Subject: [PATCH 3/6] clk: ti: Remove AM33xx dependency
Date: Tue, 19 May 2026 08:45:40 +0200	[thread overview]
Message-ID: <20260519-omap4-support-v1-3-b4a2a7435775@bootlin.com> (raw)
In-Reply-To: <20260519-omap4-support-v1-0-b4a2a7435775@bootlin.com>

The clock controller driven by this driver exists on other OMAP platforms
than the AM33xx. Yet, it uses functions provided by
arch/arm/mach-omap2/am33xx/clock.c making it unusable by other OMAPs.

Replace am33xx-specific do_{enable/disable}_clocks() with new static
functions implemented locally.
Replace the am33xx-specific clock header with the one shared by all OMAP
platforms.

Signed-off-by: Bastien Curutchet <bastien.curutchet@bootlin.com>
---
 drivers/clk/ti/clk-ctrl.c | 48 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/ti/clk-ctrl.c b/drivers/clk/ti/clk-ctrl.c
index c5c97dc35c4..08f7410edce 100644
--- a/drivers/clk/ti/clk-ctrl.c
+++ b/drivers/clk/ti/clk-ctrl.c
@@ -8,7 +8,11 @@
 #include <dm.h>
 #include <dm/device_compat.h>
 #include <clk-uclass.h>
-#include <asm/arch-am33xx/clock.h>
+#include <asm/ti-common/omap_clock.h>
+#include <asm/io.h>
+#include <linux/iopoll.h>
+
+#define TRANSITION_TIMEOUT_US	10000
 
 struct clk_ti_ctrl_offs {
 	fdt_addr_t start;
@@ -33,10 +37,37 @@ static int clk_ti_ctrl_check_offs(struct clk *clk, fdt_addr_t offs)
 	return -EFAULT;
 }
 
+#define IDLEST_DISABLED		(MODULE_CLKCTRL_IDLEST_DISABLED << MODULE_CLKCTRL_IDLEST_SHIFT)
+#define IDLEST_TRANSITION	(MODULE_CLKCTRL_IDLEST_TRANSITIONING << MODULE_CLKCTRL_IDLEST_SHIFT)
+static int clk_ti_ctrl_disable_clock_module(u32 addr)
+{
+	int val;
+
+	clrsetbits_le32(addr, MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_DISABLE <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+
+	return readl_relaxed_poll_timeout(addr, val,
+					  (val & MODULE_CLKCTRL_IDLEST_MASK) == IDLEST_DISABLED,
+					  TRANSITION_TIMEOUT_US);
+}
+
+static int clk_ti_ctrl_enable_clock_module(u32 addr)
+{
+	int val;
+
+	clrsetbits_le32(addr, MODULE_CLKCTRL_MODULEMODE_MASK,
+			MODULE_CLKCTRL_MODULEMODE_SW_EXPLICIT_EN <<
+			MODULE_CLKCTRL_MODULEMODE_SHIFT);
+	return readl_relaxed_poll_timeout(addr, val,
+					  ((val & MODULE_CLKCTRL_IDLEST_MASK) != IDLEST_DISABLED) &&
+					  ((val & MODULE_CLKCTRL_IDLEST_MASK) != IDLEST_TRANSITION),
+					  TRANSITION_TIMEOUT_US);
+}
+
 static int clk_ti_ctrl_disable(struct clk *clk)
 {
 	struct clk_ti_ctrl_priv *priv = dev_get_priv(clk->dev);
-	u32 *clk_modules[2] = { };
 	fdt_addr_t offs;
 	int err;
 
@@ -47,16 +78,13 @@ static int clk_ti_ctrl_disable(struct clk *clk)
 		return err;
 	}
 
-	clk_modules[0] = (u32 *)(offs);
-	dev_dbg(clk->dev, "disable module @ %p\n", clk_modules[0]);
-	do_disable_clocks(NULL, clk_modules, 1);
-	return 0;
+	dev_dbg(clk->dev, "disable module @ %x\n", offs);
+	return clk_ti_ctrl_disable_clock_module(offs);
 }
 
 static int clk_ti_ctrl_enable(struct clk *clk)
 {
 	struct clk_ti_ctrl_priv *priv = dev_get_priv(clk->dev);
-	u32 *clk_modules[2] = { };
 	fdt_addr_t offs;
 	int err;
 
@@ -67,10 +95,8 @@ static int clk_ti_ctrl_enable(struct clk *clk)
 		return err;
 	}
 
-	clk_modules[0] = (u32 *)(offs);
-	dev_dbg(clk->dev, "enable module @ %p\n", clk_modules[0]);
-	do_enable_clocks(NULL, clk_modules, 1);
-	return 0;
+	dev_dbg(clk->dev, "enable module @ %x\n", offs);
+	return clk_ti_ctrl_enable_clock_module(offs);
 }
 
 static ulong clk_ti_ctrl_get_rate(struct clk *clk)

-- 
2.54.0


  parent reply	other threads:[~2026-05-19  6:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19  6:45 [PATCH 0/6] arm: omap: Add back omap4 support Bastien Curutchet
2026-05-19  6:45 ` [PATCH 1/6] arm: omap: Move PRM I2C channel frequency to vc.c Bastien Curutchet
2026-05-19  6:45 ` [PATCH 2/6] arm: ti: omap: Extract common clock definitions Bastien Curutchet
2026-05-19  6:45 ` Bastien Curutchet [this message]
2026-05-19  6:45 ` [PATCH 4/6] configs: omap4: remove unused boot target devices Bastien Curutchet
2026-05-19  6:45 ` [PATCH 5/6] arm: ti: Introduce back omap4 support Bastien Curutchet
2026-05-19  6:45 ` [PATCH 6/6] board: variscite: add support for the omap4_var_som Bastien Curutchet
2026-05-19 14:03   ` Tom Rini
2026-05-19 14:55     ` Bastien Curutchet
2026-05-19 15:01       ` Tom Rini
2026-05-20  7:03         ` Bastien Curutchet
2026-05-20 14:29           ` Tom Rini

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=20260519-omap4-support-v1-3-b4a2a7435775@bootlin.com \
    --to=bastien.curutchet@bootlin.com \
    --cc=afd@ti.com \
    --cc=alchark@gmail.com \
    --cc=alif.zakuan.yuslaimi@altera.com \
    --cc=andre.przywara@arm.com \
    --cc=anshuld@ti.com \
    --cc=casey.connolly@linaro.org \
    --cc=daniel@thingy.jp \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=h-salunke@ti.com \
    --cc=hs@nabladev.com \
    --cc=jh80.chung@samsung.com \
    --cc=justin.swartz@risingedge.co.za \
    --cc=lukma@denx.de \
    --cc=mkorpershoek@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=patrice.chotard@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=quentin.schulz@cherry.de \
    --cc=ravi@prevas.dk \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tien.fong.chee@altera.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox