Re: [PATCH 1/2] rtc: m5441x: add MCF5441x on-chip RTC driver
Geert Uytterhoeven <[email protected]>
| Newsgroups | org.kernel.vger.linux-m68k,org.kernel.vger.linux-kernel,org.kernel.vger.linux-rtc |
|---|---|
| Message-ID | <CAMuHMdUNiUGnjRkhwVGpgHcjTSzoLsFmaPR_TfROsFhDbYqUUw@mail.gmail.com> |
Hi Jean-Michel, On Tue, 2 Jun 2026 at 13:05, Jean-Michel Hautbois <[email protected]> wrote: > Le 02/06/2026 à 12:04, Geert Uytterhoeven a écrit : > > On Tue, 2 Jun 2026 at 10:36, Jean-Michel Hautbois > > <[email protected]> wrote: > >> Add an rtc-class driver for the Freescale MCF5441x on-chip "robust" RTC. > >> It provides the time/calendar and alarm, and exposes the 2KB > >> battery-backed standby RAM through the nvmem framework so userspace can > >> preserve data across a main-power loss (the RAM is retained while > >> VSTBY_RTC is supplied). > >> > >> Register and standby-RAM writes go through the RTC_CR[WE] knock > >> sequence; the base-2112 year encoding and register map follow the > >> MCF54418 reference manual. Based on the out-of-tree Freescale 3.0.x > >> rtc-m5441x driver, rewritten for the current RTC and nvmem APIs. > >> > >> Signed-off-by: Jean-Michel Hautbois <[email protected]> > > > > Thanks for your patch! > > > >> +/* > >> + * The time counters are unstable for an oscillator cycle either side of > >> + * the one-second boundary. RTC_SR[INVAL] flags this; reads during the > >> + * window return 0xffff and writes are nullified. Spin until it clears. > >> + * The window is only a couple of 32kHz cycles (~60us), so bound the > >> + * busy-wait tightly: it runs with the lock held and interrupts off. > >> + * Caller holds p->lock. > >> + */ > >> +static int m5441x_rtc_wait_valid(struct m5441x_rtc *p) > >> +{ > >> + unsigned int tries = 10; > >> + > >> + while (rtc_rd(p, M5441X_RTC_SR) & M5441X_RTC_SR_INVAL) { > >> + if (!--tries) > >> + return -EIO; > >> + udelay(10); > >> + } > > > > Please use read_poll_timeout(). > > As wait_valid() is called after spin_lock_irqsave() is called, I suppose > I should use read_poll_timeout_atomic() ? Because read_poll_timeout() > sleeps ? Sorry, I copy and pasted the wrong function name, so you're right. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds