Re: [PATCH v4 13/15] rtc: rzn1: Add OF match data to gate SUBU register access
"Lad, Prabhakar" <[email protected]>
| Newsgroups | org.kernel.vger.linux-rtc,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-renesas-soc |
|---|---|
| Message-ID | <CA+V-a8tpo2Rc9xsvsj9LLqD2ZjoHzRAVsox=7xURAtwA-GYVEw@mail.gmail.com> |
Hi Wolfram, Thank you for the review. On Thu, Aug 20, 2026 at 12:20 PM Wolfram Sang <[email protected]> wrote: > > On Wed, Aug 19, 2026 at 11:39:24AM +0100, Prabhakar wrote: > > From: Lad Prabhakar <[email protected]> > > > > 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 <[email protected]> > > Suggested-by: Wolfram Sang <[email protected]> > > I still think, this code needs a change: > > 454 if (rate != 32768) > 455 scmp_val = RZN1_RTC_CTL0_SLSB_SCMP; > > if (rate != 32768 || !data->has_subu) > > otherwise having a xtal with 32768 on a SCMP-only device will not be > accepted despite it should work. > Agreed. > Haven't checked if that could simplify your later has_subu-check or not. > To reduce the checks I can add a else if check like below: /* Only switch to scmp if we have an xtal clock with a valid rate and != 32768 */ xtal = devm_clk_get_optional(dev, "xtal"); if (IS_ERR(xtal)) { return PTR_ERR(xtal); } else if (xtal) { rate = clk_get_rate(xtal); if (rate < 32000 || rate > BIT(22)) return -EOPNOTSUPP; if (rate != 32768 || !data->has_subu) scmp_val = RZN1_RTC_CTL0_SLSB_SCMP; } else if (!data->has_subu) { return dev_err_probe(dev, -EOPNOTSUPP, "No valid XTAL provided and SUBU mode not supported\n"); } Cheers, Prabhakar