Devicetree
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Prabhakar <prabhakar.csengg@gmail.com>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Magnus Damm <magnus.damm@gmail.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	linux-rtc@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Prabhakar <prabhakar.csengg+renesas@gmail.com>,
	Biju Das <biju.das.jz@bp.renesas.com>,
	Fabrizio Castro <fabrizio.castro.jz@renesas.com>,
	Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: Re: [PATCH v5 15/17] rtc: rzn1: Add OF match data to gate SUBU register access
Date: Fri, 21 Aug 2026 18:40:50 +0200	[thread overview]
Message-ID: <20260821164050abd3ceed@mail.local> (raw)
In-Reply-To: <20260821135608.275233-16-prabhakar.mahadev-lad.rj@bp.renesas.com>

Hello,

On 21/08/2026 14:56:06+0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> 
> The RZ/N1 RTC driver selects SCMP mode only when an optional xtal clock
> is provided at a valid rate other than 32768 Hz. Without an xtal clock,
> or when it runs at 32768 Hz, the driver uses SUBU mode.
> 
> However, the RTCA0SUBU register used by SUBU mode is not present on all
> SoCs that integrate a similar variant of the RTC block. Allowing SUBU
> mode on those variants would expose RTC offset operations that access a
> non-existent register.
> 
> Add OF match data to describe whether the RTC supports the SUBU register.
> Reject probe with -EOPNOTSUPP when SUBU mode would be selected on a
> variant without SUBU support.
> 
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Suggested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> v4->v5:
> - Renamed rzn1_data to rzn1_rtc_rzn1_data
> - Added a print message to indicate that SUBU mode is not supported
>   on the variant.
> - Added a comment to indicate that the xtal clock is NULL when SUBU
>   mode is not supported.
> - Added Suggested-by tag from Wolfram.
> 
> v3->v4:
> - New patch
> ---
>  drivers/rtc/rtc-rzn1.c | 22 ++++++++++++++++++++--
>  1 file changed, 20 insertions(+), 2 deletions(-)
> 

This doesn't apply cleanly, can you rebase on rtc-next? If you do so
today, I'll include the series this merge window.

> diff --git a/drivers/rtc/rtc-rzn1.c b/drivers/rtc/rtc-rzn1.c
> index 8b68a5ad19c0..35770bff129f 100644
> --- a/drivers/rtc/rtc-rzn1.c
> +++ b/drivers/rtc/rtc-rzn1.c
> @@ -18,6 +18,7 @@
>  #include <linux/init.h>
>  #include <linux/iopoll.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
>  #include <linux/rtc.h>
> @@ -65,6 +66,10 @@
>  #define RZN1_RTC_TIMEC 0x68
>  #define RZN1_RTC_CALC 0x6c
>  
> +struct rzn1_rtc_data {
> +	bool has_subu;
> +};
> +
>  struct rzn1_rtc {
>  	struct rtc_device *rtcdev;
>  	void __iomem *base;
> @@ -404,6 +409,7 @@ static void rzn1_rtc_disable_hardware(void *data)
>  
>  static int rzn1_rtc_probe(struct platform_device *pdev)
>  {
> +	const struct rzn1_rtc_data *data;
>  	struct device *dev = &pdev->dev;
>  	unsigned long rate = 32768;
>  	struct rzn1_rtc *rtc;
> @@ -411,6 +417,10 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
>  	struct clk *xtal;
>  	int irq, ret;
>  
> +	data = of_device_get_match_data(dev);
> +	if (!data)
> +		return -ENODEV;
> +
>  	rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);
>  	if (!rtc)
>  		return -ENOMEM;
> @@ -454,8 +464,12 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
>  		if (rate < 32000 || rate > BIT(22))
>  			return -EOPNOTSUPP;
>  
> -		if (rate != 32768)
> +		if (rate != 32768 || !data->has_subu)
>  			scmp_val = RZN1_RTC_CTL0_SLSB_SCMP;
> +	} else if (!data->has_subu) {
> +		/* xtal is NULL here */
> +		return dev_err_probe(dev, -EOPNOTSUPP,
> +				     "No valid XTAL provided and SUBU mode not supported\n");
>  	}
>  
>  	/* Calculate the duration of two RTC_PCLK clock cycles */
> @@ -508,8 +522,12 @@ static int rzn1_rtc_probe(struct platform_device *pdev)
>  	return devm_rtc_register_device(rtc->rtcdev);
>  }
>  
> +static const struct rzn1_rtc_data rzn1_rtc_rzn1_data = {
> +	.has_subu = true,
> +};
> +
>  static const struct of_device_id rzn1_rtc_of_match[] = {
> -	{ .compatible	= "renesas,rzn1-rtc" },
> +	{ .compatible	= "renesas,rzn1-rtc", .data = &rzn1_rtc_rzn1_data },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, rzn1_rtc_of_match);
> -- 
> 2.43.0
> 

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  parent reply	other threads:[~2026-08-21 16:41 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 13:55 [PATCH v5 00/17] Add RTC support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-08-21 13:55 ` [PATCH v5 01/17] dt-bindings: rtc: renesas,rzn1-rtc: Add RZ/T2H and RZ/N2H support Prabhakar
2026-08-21 14:05   ` sashiko-bot
2026-08-21 15:03     ` Wolfram Sang
2026-08-21 13:55 ` [PATCH v5 02/17] rtc: rzn1: Handle EPROBE_DEFER for optional pps interrupt Prabhakar
2026-08-21 14:07   ` sashiko-bot
2026-08-21 13:55 ` [PATCH v5 03/17] rtc: rzn1: Fix weekday underflow when alarm crosses month boundary Prabhakar
2026-08-21 14:08   ` sashiko-bot
2026-08-21 13:55 ` [PATCH v5 04/17] rtc: rzn1: Handle unset alarm weekday in rzn1_rtc_read_alarm Prabhakar
2026-08-21 14:10   ` sashiko-bot
2026-08-21 15:08     ` Wolfram Sang
2026-08-21 15:08   ` Wolfram Sang
2026-08-21 13:55 ` [PATCH v5 05/17] rtc: rzn1: Fix alarm range check truncation on 32-bit systems Prabhakar
2026-08-21 14:06   ` sashiko-bot
2026-08-21 13:55 ` [PATCH v5 06/17] rtc: rzn1: Disable alarm interrupt before reprogramming alarm registers Prabhakar
2026-08-21 14:10   ` sashiko-bot
2026-08-21 15:10     ` Wolfram Sang
2026-08-21 15:11   ` Wolfram Sang
2026-08-21 13:55 ` [PATCH v5 07/17] rtc: rzn1: Fix malformed MODULE_AUTHOR string Prabhakar
2026-08-21 14:01   ` sashiko-bot
2026-08-21 13:55 ` [PATCH v5 08/17] rtc: Kconfig: Broaden RTC_DRV_RZN1 dependency to ARCH_RENESAS Prabhakar
2026-08-21 14:02   ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 09/17] rtc: rzn1: Use pm_runtime_put_sync() Prabhakar
2026-08-21 14:08   ` sashiko-bot
2026-08-21 15:14   ` Wolfram Sang
2026-08-21 13:56 ` [PATCH v5 10/17] rtc: rzn1: Replace remove callback with devm_add_action_or_reset() Prabhakar
2026-08-21 14:07   ` sashiko-bot
2026-08-21 15:15     ` Wolfram Sang
2026-08-21 13:56 ` [PATCH v5 11/17] rtc: rzn1: Dynamically calculate synchronization delay based on clock rate Prabhakar
2026-08-21 14:05   ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 12/17] rtc: rzn1: Use temporary variable for struct device Prabhakar
2026-08-21 14:05   ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 13/17] rtc: rzn1: Consistently use dev_err_probe() Prabhakar
2026-08-21 14:03   ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 14/17] rtc: rzn1: use FIELD_PREP/FIELD_GET and GENMASK for register access Prabhakar
2026-08-21 14:06   ` sashiko-bot
2026-08-21 13:56 ` [PATCH v5 15/17] rtc: rzn1: Add OF match data to gate SUBU " Prabhakar
2026-08-21 14:08   ` sashiko-bot
2026-08-21 15:16   ` Wolfram Sang
2026-08-21 16:40   ` Alexandre Belloni [this message]
2026-08-21 13:56 ` [PATCH v5 16/17] rtc: rzn1: Drop trailing comma from OF match table sentinel Prabhakar
2026-08-21 14:07   ` sashiko-bot
2026-08-21 15:18     ` Wolfram Sang
2026-08-21 13:56 ` [PATCH v5 17/17] rtc: rzn1: Add support for Renesas RZ/T2H and RZ/N2H SoCs Prabhakar
2026-08-21 14:09   ` sashiko-bot

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=20260821164050abd3ceed@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fabrizio.castro.jz@renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=prabhakar.csengg+renesas@gmail.com \
    --cc=prabhakar.csengg@gmail.com \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=robh@kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    /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