Devicetree
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Andreas Kemnade <andreas@kemnade.info>
Cc: Russell King <linux@armlinux.org.uk>, Frank Li <Frank.Li@nxp.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Daniel Lezcano <daniel.lezcano@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux@yoavmoshe.com
Subject: Re: [PATCH v2 2/3] timer-imx-gpt: Allow 32K clock to be used as a clock source
Date: Thu, 26 Nov 2026 10:56:35 -0600	[thread overview]
Message-ID: <awhkwx0O9MPwJxdt@SMW015318> (raw)
In-Reply-To: <20261126-imx6-idlestop-v2-2-c6987e7a392f@kemnade.info>

On Thu, Nov 26, 2026 at 12:00:55PM +0100, Andreas Kemnade wrote:
> To avoid depending on PLL infrastructure for timekeeping, prepare for
> using the 32K clock by configuring the clock source accordingly.
>
> Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
> ---
>  drivers/clocksource/timer-imx-gpt.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/clocksource/timer-imx-gpt.c b/drivers/clocksource/timer-imx-gpt.c
> index 8335bd7f8c6ce..85fd36fe1c760 100644
> --- a/drivers/clocksource/timer-imx-gpt.c
> +++ b/drivers/clocksource/timer-imx-gpt.c
> @@ -50,8 +50,10 @@ enum imx_gpt_type {
>
>  /* MX31, MX35, MX25, MX5, MX6 */
>  #define V2_TCTL_WAITEN		(1 << 3) /* Wait enable mode */
> +#define V2_TCTL_STOPEN		(1 << 5) /* Stop enable mode */
>  #define V2_TCTL_CLK_IPG		(1 << 6)
>  #define V2_TCTL_CLK_PER		(2 << 6)
> +#define V2_TCTL_CLK_32K		(4 << 6)
>  #define V2_TCTL_CLK_OSC_DIV8	(5 << 6)
>  #define V2_TCTL_FRR		(1 << 9)
>  #define V2_TCTL_24MEN		(1 << 10)
> @@ -271,6 +273,7 @@ static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id)
>  static int __init mxc_clockevent_init(struct imx_timer *imxtm)
>  {
>  	struct clock_event_device *ced = &imxtm->ced;
> +	unsigned long rate = clk_get_rate(imxtm->clk_per);
>
>  	ced->name = "mxc_timer1";
>  	ced->features = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_DYNIRQ;
> @@ -281,8 +284,7 @@ static int __init mxc_clockevent_init(struct imx_timer *imxtm)
>  	ced->rating = 200;
>  	ced->cpumask = cpumask_of(0);
>  	ced->irq = imxtm->irq;
> -	clockevents_config_and_register(ced, clk_get_rate(imxtm->clk_per),
> -					0xff, 0xfffffffe);
> +	clockevents_config_and_register(ced, rate, rate == 32768 ? 3 : 0xff, 0xfffffffe);

Check 32768 is not good enough, in case board use 32000 osc. Add optional
clock osc? Or check clk_per is NULL?  OSC clk should always existing.

Frank

>
>  	return request_irq(imxtm->irq, mxc_timer_interrupt,
>  			   IRQF_TIMER | IRQF_IRQPOLL, "i.MX Timer Tick", ced);
> @@ -314,14 +316,19 @@ static void imx6dl_gpt_setup_tctl(struct imx_timer *imxtm)
>  	u32 tctl_val;
>
>  	tctl_val = V2_TCTL_FRR | V2_TCTL_WAITEN | MXC_TCTL_TEN;
> -	if (clk_get_rate(imxtm->clk_per) == V2_TIMER_RATE_OSC_DIV8) {
> +	if (clk_get_rate(imxtm->clk_per) == V2_TIMER_RATE_OSC_DIV8)  {
>  		tctl_val |= V2_TCTL_CLK_OSC_DIV8;
>  		/* 24 / 8 = 3 MHz */
>  		writel_relaxed(7 << V2_TPRER_PRE24M, imxtm->base + MXC_TPRER);
>  		tctl_val |= V2_TCTL_24MEN;
> -	} else {
> +	} else if (clk_get_rate(imxtm->clk_per) == 32768)
> +		/*
> +		 * if powered by that always on clock, it is feasible to let
> +		 * it run in stop mode, too, allowing lower idle states
> +		 */
> +		tctl_val |= V2_TCTL_CLK_32K | V2_TCTL_STOPEN;
> +	else
>  		tctl_val |= V2_TCTL_CLK_PER;
> -	}
>
>  	writel_relaxed(tctl_val, imxtm->base + MXC_TCTL);
>  }
>
> --
> 2.47.3
>
>

  parent reply	other threads:[~2026-11-26 16:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 11:00 [PATCH v2 0/3] ARM: imx: Add a more agressive idle mode on i.MX6SLL Andreas Kemnade
2026-11-26 11:00 ` [PATCH v2 1/3] ARM: imx: enable STOP-ON mode in idle if wakeup requirements permit Andreas Kemnade
2026-11-26 11:13   ` sashiko-bot
2026-11-26 12:46     ` Andreas Kemnade
2026-11-26 11:00 ` [PATCH v2 2/3] timer-imx-gpt: Allow 32K clock to be used as a clock source Andreas Kemnade
2026-11-26 11:14   ` sashiko-bot
2026-11-26 16:56   ` Frank Li [this message]
2026-11-26 11:00 ` [PATCH v2 3/3] ARM: dts: imx: kobo-clarahd: Use 32K clock for the timer Andreas Kemnade
2026-11-26 17:01 ` [PATCH v2 0/3] ARM: imx: Add a more agressive idle mode on i.MX6SLL Frank Li

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=awhkwx0O9MPwJxdt@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=andreas@kemnade.info \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linux@yoavmoshe.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=tglx@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox