* [PATCH v4 0/2] MVME: Adopt standard RTC driver @ 2024-11-12 22:32 Finn Thain 2024-11-12 22:32 ` [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value Finn Thain 0 siblings, 1 reply; 8+ messages in thread From: Finn Thain @ 2024-11-12 22:32 UTC (permalink / raw) To: Alexandre Belloni, Andreas Larsson, David S. Miller, Geert Uytterhoeven Cc: Daniel Palmer, linux-kernel, linux-m68k, linux-rtc, Michael Pavone, sparclinux This series removes some duplicated RTC driver code. First rtc-m48t59 is tweaked to bring it into equivalence with the RTC drivers in arch/m68k/mvme*. Then platform devices are added for the former driver and the latter drivers are removed. --- Changed since v1: - Instead of adding ifdefs to the portable driver, store the year offset in struct m48t59_plat_data. Changed since v2: - Use an int for the year offset in struct m48t59_plat_data. Changed since v3: - Re-ordered m68k defconfig symbols. - Added reviewed-by tag from Geert. Finn Thain (2): rtc: m48t59: Use platform_data struct for year offset value m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver arch/m68k/configs/multi_defconfig | 1 + arch/m68k/configs/mvme147_defconfig | 1 + arch/m68k/configs/mvme16x_defconfig | 1 + arch/m68k/include/asm/mvme147hw.h | 19 +--- arch/m68k/include/asm/mvme16xhw.h | 18 +-- arch/m68k/mvme147/config.c | 55 ++++------ arch/m68k/mvme16x/Makefile | 2 +- arch/m68k/mvme16x/config.c | 57 ++++------ arch/m68k/mvme16x/rtc.c | 165 ---------------------------- arch/sparc/kernel/time_32.c | 1 + arch/sparc/kernel/time_64.c | 1 + drivers/rtc/rtc-m48t59.c | 26 +---- include/linux/rtc/m48t59.h | 3 + 13 files changed, 63 insertions(+), 287 deletions(-) delete mode 100644 arch/m68k/mvme16x/rtc.c -- 2.44.2 ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value 2024-11-12 22:32 [PATCH v4 0/2] MVME: Adopt standard RTC driver Finn Thain @ 2024-11-12 22:32 ` Finn Thain 2024-11-15 15:49 ` Andreas Larsson 2024-11-18 13:32 ` (subset) " Alexandre Belloni 0 siblings, 2 replies; 8+ messages in thread From: Finn Thain @ 2024-11-12 22:32 UTC (permalink / raw) To: David S. Miller, Andreas Larsson, Alexandre Belloni Cc: Daniel Palmer, Michael Pavone, linux-m68k, linux-rtc, sparclinux, linux-kernel Instead of hard-coded values and ifdefs, store the year offset in the platform_data struct. Tested-by: Daniel Palmer <daniel@0x0f.com> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Finn Thain <fthain@linux-m68k.org> --- David, Andreas - with your acknowledgement, I will ask Alexandre to merge this. --- I tested this for regressions using qemu-system-sparc64. Also, Daniel tested the RTC functionality on his MVME147 system. Changed since v2: - Use an int for the year offset in struct m48t59_plat_data. Changed since v3: - Added reviewed-by tag from Geert. --- arch/sparc/kernel/time_32.c | 1 + arch/sparc/kernel/time_64.c | 1 + drivers/rtc/rtc-m48t59.c | 26 ++++---------------------- include/linux/rtc/m48t59.h | 3 +++ 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/arch/sparc/kernel/time_32.c b/arch/sparc/kernel/time_32.c index 08bbdc458596..578fd0d49f30 100644 --- a/arch/sparc/kernel/time_32.c +++ b/arch/sparc/kernel/time_32.c @@ -255,6 +255,7 @@ static void mostek_write_byte(struct device *dev, u32 ofs, u8 val) static struct m48t59_plat_data m48t59_data = { .read_byte = mostek_read_byte, .write_byte = mostek_write_byte, + .yy_offset = 68, }; /* resource is set at runtime */ diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c index 60f1c8cc5363..b32f27f929d1 100644 --- a/arch/sparc/kernel/time_64.c +++ b/arch/sparc/kernel/time_64.c @@ -544,6 +544,7 @@ static void mostek_write_byte(struct device *dev, u32 ofs, u8 val) static struct m48t59_plat_data m48t59_data = { .read_byte = mostek_read_byte, .write_byte = mostek_write_byte, + .yy_offset = 68, }; static struct platform_device m48t59_rtc = { diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c index 5d30ce8e13ca..4e608bc8bbd3 100644 --- a/drivers/rtc/rtc-m48t59.c +++ b/drivers/rtc/rtc-m48t59.c @@ -71,7 +71,7 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) /* Issue the READ command */ M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); - tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); + tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)) + pdata->yy_offset; /* tm_mon is 0-11 */ tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; tm->tm_mday = bcd2bin(M48T59_READ(M48T59_MDAY)); @@ -82,10 +82,6 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) dev_dbg(dev, "Century bit is enabled\n"); tm->tm_year += 100; /* one century */ } -#ifdef CONFIG_SPARC - /* Sun SPARC machines count years since 1968 */ - tm->tm_year += 68; -#endif tm->tm_wday = bcd2bin(val & 0x07); tm->tm_hour = bcd2bin(M48T59_READ(M48T59_HOUR) & 0x3F); @@ -106,12 +102,7 @@ static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm) struct m48t59_private *m48t59 = dev_get_drvdata(dev); unsigned long flags; u8 val = 0; - int year = tm->tm_year; - -#ifdef CONFIG_SPARC - /* Sun SPARC machines count years since 1968 */ - year -= 68; -#endif + int year = tm->tm_year - pdata->yy_offset; dev_dbg(dev, "RTC set time %04d-%02d-%02d %02d/%02d/%02d\n", year + 1900, tm->tm_mon, tm->tm_mday, @@ -162,11 +153,7 @@ static int m48t59_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) /* Issue the READ command */ M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); - tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); -#ifdef CONFIG_SPARC - /* Sun SPARC machines count years since 1968 */ - tm->tm_year += 68; -#endif + tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)) + pdata->yy_offset; /* tm_mon is 0-11 */ tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; @@ -197,12 +184,7 @@ static int m48t59_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) struct rtc_time *tm = &alrm->time; u8 mday, hour, min, sec; unsigned long flags; - int year = tm->tm_year; - -#ifdef CONFIG_SPARC - /* Sun SPARC machines count years since 1968 */ - year -= 68; -#endif + int year = tm->tm_year - pdata->yy_offset; /* If no irq, we don't support ALARM */ if (m48t59->irq == NO_IRQ) diff --git a/include/linux/rtc/m48t59.h b/include/linux/rtc/m48t59.h index 9465d5405fe2..373ba77071c6 100644 --- a/include/linux/rtc/m48t59.h +++ b/include/linux/rtc/m48t59.h @@ -56,6 +56,9 @@ struct m48t59_plat_data { void __iomem *ioaddr; /* offset to RTC registers, automatically set according to the type */ unsigned int offset; + + /* YY digits (in RTC) are offset, i.e. year is 1900 + yy_offset + YY */ + int yy_offset; }; #endif /* _LINUX_RTC_M48T59_H_ */ -- 2.44.2 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value 2024-11-12 22:32 ` [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value Finn Thain @ 2024-11-15 15:49 ` Andreas Larsson 2024-11-18 13:32 ` (subset) " Alexandre Belloni 1 sibling, 0 replies; 8+ messages in thread From: Andreas Larsson @ 2024-11-15 15:49 UTC (permalink / raw) To: Finn Thain, David S. Miller, Alexandre Belloni Cc: Daniel Palmer, Michael Pavone, linux-m68k, linux-rtc, sparclinux, linux-kernel On 2024-11-12 23:32, Finn Thain wrote: > Instead of hard-coded values and ifdefs, store the year offset in the > platform_data struct. > > Tested-by: Daniel Palmer <daniel@0x0f.com> > Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> > Signed-off-by: Finn Thain <fthain@linux-m68k.org> > --- > David, Andreas - with your acknowledgement, I will ask Alexandre to merge > this. > --- > I tested this for regressions using qemu-system-sparc64. > Also, Daniel tested the RTC functionality on his MVME147 system. > > Changed since v2: > - Use an int for the year offset in struct m48t59_plat_data. > > Changed since v3: > - Added reviewed-by tag from Geert. > --- > arch/sparc/kernel/time_32.c | 1 + > arch/sparc/kernel/time_64.c | 1 + > drivers/rtc/rtc-m48t59.c | 26 ++++---------------------- > include/linux/rtc/m48t59.h | 3 +++ > 4 files changed, 9 insertions(+), 22 deletions(-) > > diff --git a/arch/sparc/kernel/time_32.c b/arch/sparc/kernel/time_32.c > index 08bbdc458596..578fd0d49f30 100644 > --- a/arch/sparc/kernel/time_32.c > +++ b/arch/sparc/kernel/time_32.c > @@ -255,6 +255,7 @@ static void mostek_write_byte(struct device *dev, u32 ofs, u8 val) > static struct m48t59_plat_data m48t59_data = { > .read_byte = mostek_read_byte, > .write_byte = mostek_write_byte, > + .yy_offset = 68, > }; > > /* resource is set at runtime */ > diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c > index 60f1c8cc5363..b32f27f929d1 100644 > --- a/arch/sparc/kernel/time_64.c > +++ b/arch/sparc/kernel/time_64.c > @@ -544,6 +544,7 @@ static void mostek_write_byte(struct device *dev, u32 ofs, u8 val) > static struct m48t59_plat_data m48t59_data = { > .read_byte = mostek_read_byte, > .write_byte = mostek_write_byte, > + .yy_offset = 68, > }; > > static struct platform_device m48t59_rtc = { > diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c > index 5d30ce8e13ca..4e608bc8bbd3 100644 > --- a/drivers/rtc/rtc-m48t59.c > +++ b/drivers/rtc/rtc-m48t59.c > @@ -71,7 +71,7 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) > /* Issue the READ command */ > M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); > > - tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); > + tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)) + pdata->yy_offset; > /* tm_mon is 0-11 */ > tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; > tm->tm_mday = bcd2bin(M48T59_READ(M48T59_MDAY)); > @@ -82,10 +82,6 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm) > dev_dbg(dev, "Century bit is enabled\n"); > tm->tm_year += 100; /* one century */ > } > -#ifdef CONFIG_SPARC > - /* Sun SPARC machines count years since 1968 */ > - tm->tm_year += 68; > -#endif > > tm->tm_wday = bcd2bin(val & 0x07); > tm->tm_hour = bcd2bin(M48T59_READ(M48T59_HOUR) & 0x3F); > @@ -106,12 +102,7 @@ static int m48t59_rtc_set_time(struct device *dev, struct rtc_time *tm) > struct m48t59_private *m48t59 = dev_get_drvdata(dev); > unsigned long flags; > u8 val = 0; > - int year = tm->tm_year; > - > -#ifdef CONFIG_SPARC > - /* Sun SPARC machines count years since 1968 */ > - year -= 68; > -#endif > + int year = tm->tm_year - pdata->yy_offset; > > dev_dbg(dev, "RTC set time %04d-%02d-%02d %02d/%02d/%02d\n", > year + 1900, tm->tm_mon, tm->tm_mday, > @@ -162,11 +153,7 @@ static int m48t59_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm) > /* Issue the READ command */ > M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); > > - tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); > -#ifdef CONFIG_SPARC > - /* Sun SPARC machines count years since 1968 */ > - tm->tm_year += 68; > -#endif > + tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)) + pdata->yy_offset; > /* tm_mon is 0-11 */ > tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; > > @@ -197,12 +184,7 @@ static int m48t59_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) > struct rtc_time *tm = &alrm->time; > u8 mday, hour, min, sec; > unsigned long flags; > - int year = tm->tm_year; > - > -#ifdef CONFIG_SPARC > - /* Sun SPARC machines count years since 1968 */ > - year -= 68; > -#endif > + int year = tm->tm_year - pdata->yy_offset; > > /* If no irq, we don't support ALARM */ > if (m48t59->irq == NO_IRQ) > diff --git a/include/linux/rtc/m48t59.h b/include/linux/rtc/m48t59.h > index 9465d5405fe2..373ba77071c6 100644 > --- a/include/linux/rtc/m48t59.h > +++ b/include/linux/rtc/m48t59.h > @@ -56,6 +56,9 @@ struct m48t59_plat_data { > void __iomem *ioaddr; > /* offset to RTC registers, automatically set according to the type */ > unsigned int offset; > + > + /* YY digits (in RTC) are offset, i.e. year is 1900 + yy_offset + YY */ > + int yy_offset; > }; > > #endif /* _LINUX_RTC_M48T59_H_ */ Tested-by: Andreas Larsson <andreas@gaisler.com> Acked-by: Andreas Larsson <andreas@gaisler.com> Thanks, Andreas ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value 2024-11-12 22:32 ` [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value Finn Thain 2024-11-15 15:49 ` Andreas Larsson @ 2024-11-18 13:32 ` Alexandre Belloni 2024-11-20 22:13 ` Finn Thain 1 sibling, 1 reply; 8+ messages in thread From: Alexandre Belloni @ 2024-11-18 13:32 UTC (permalink / raw) To: David S. Miller, Andreas Larsson, Finn Thain Cc: Daniel Palmer, Michael Pavone, linux-m68k, linux-rtc, sparclinux, linux-kernel On Wed, 13 Nov 2024 09:32:15 +1100, Finn Thain wrote: > Instead of hard-coded values and ifdefs, store the year offset in the > platform_data struct. > > Applied, thanks! [1/2] rtc: m48t59: Use platform_data struct for year offset value https://git.kernel.org/abelloni/c/a06e4a93067c Best regards, -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value 2024-11-18 13:32 ` (subset) " Alexandre Belloni @ 2024-11-20 22:13 ` Finn Thain 2024-11-21 17:46 ` Alexandre Belloni 0 siblings, 1 reply; 8+ messages in thread From: Finn Thain @ 2024-11-20 22:13 UTC (permalink / raw) To: Alexandre Belloni Cc: Geert Uytterhoeven, David S. Miller, Andreas Larsson, Daniel Palmer, Michael Pavone, linux-m68k, linux-rtc, sparclinux, linux-kernel On Mon, 18 Nov 2024, Alexandre Belloni wrote: > On Wed, 13 Nov 2024 09:32:15 +1100, Finn Thain wrote: > > Instead of hard-coded values and ifdefs, store the year offset in the > > platform_data struct. > > > > > > Applied, thanks! > > [1/2] rtc: m48t59: Use platform_data struct for year offset value > https://git.kernel.org/abelloni/c/a06e4a93067c > Thanks, Alexandre. Would you also take patch 2/2, please? Geert has sent a reviewed-by tag for that one too. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value 2024-11-20 22:13 ` Finn Thain @ 2024-11-21 17:46 ` Alexandre Belloni 2024-11-21 18:52 ` Geert Uytterhoeven 2024-11-21 22:24 ` Finn Thain 0 siblings, 2 replies; 8+ messages in thread From: Alexandre Belloni @ 2024-11-21 17:46 UTC (permalink / raw) To: Finn Thain Cc: Geert Uytterhoeven, David S. Miller, Andreas Larsson, Daniel Palmer, Michael Pavone, linux-m68k, linux-rtc, sparclinux, linux-kernel On 21/11/2024 09:13:32+1100, Finn Thain wrote: > > On Mon, 18 Nov 2024, Alexandre Belloni wrote: > > > On Wed, 13 Nov 2024 09:32:15 +1100, Finn Thain wrote: > > > Instead of hard-coded values and ifdefs, store the year offset in the > > > platform_data struct. > > > > > > > > > > Applied, thanks! > > > > [1/2] rtc: m48t59: Use platform_data struct for year offset value > > https://git.kernel.org/abelloni/c/a06e4a93067c > > > > Thanks, Alexandre. Would you also take patch 2/2, please? Geert has sent a > reviewed-by tag for that one too. I thought Geert would take it as this only touches arch/m68k -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value 2024-11-21 17:46 ` Alexandre Belloni @ 2024-11-21 18:52 ` Geert Uytterhoeven 2024-11-21 22:24 ` Finn Thain 1 sibling, 0 replies; 8+ messages in thread From: Geert Uytterhoeven @ 2024-11-21 18:52 UTC (permalink / raw) To: Alexandre Belloni Cc: Finn Thain, David S. Miller, Andreas Larsson, Daniel Palmer, Michael Pavone, linux-m68k, linux-rtc, sparclinux, linux-kernel Hi Alexandre, On Thu, Nov 21, 2024 at 6:46 PM Alexandre Belloni <alexandre.belloni@bootlin.com> wrote: > On 21/11/2024 09:13:32+1100, Finn Thain wrote: > > On Mon, 18 Nov 2024, Alexandre Belloni wrote: > > > On Wed, 13 Nov 2024 09:32:15 +1100, Finn Thain wrote: > > > > Instead of hard-coded values and ifdefs, store the year offset in the > > > > platform_data struct. > > > > > > Applied, thanks! > > > > > > [1/2] rtc: m48t59: Use platform_data struct for year offset value > > > https://git.kernel.org/abelloni/c/a06e4a93067c > > > > Thanks, Alexandre. Would you also take patch 2/2, please? Geert has sent a > > reviewed-by tag for that one too. > > I thought Geert would take it as this only touches arch/m68k I can do that only after v6.13-rc1 has been released, due to the hard dependency on the new m48t59_plat_data.yy_offset member. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value 2024-11-21 17:46 ` Alexandre Belloni 2024-11-21 18:52 ` Geert Uytterhoeven @ 2024-11-21 22:24 ` Finn Thain 1 sibling, 0 replies; 8+ messages in thread From: Finn Thain @ 2024-11-21 22:24 UTC (permalink / raw) To: Alexandre Belloni Cc: Geert Uytterhoeven, David S. Miller, Andreas Larsson, Daniel Palmer, Michael Pavone, linux-m68k, linux-rtc, sparclinux, linux-kernel On Thu, 21 Nov 2024, Alexandre Belloni wrote: > On 21/11/2024 09:13:32+1100, Finn Thain wrote: > > > > On Mon, 18 Nov 2024, Alexandre Belloni wrote: > > > > > On Wed, 13 Nov 2024 09:32:15 +1100, Finn Thain wrote: > > > > Instead of hard-coded values and ifdefs, store the year offset in the > > > > platform_data struct. > > > > > > > > > > > > > > Applied, thanks! > > > > > > [1/2] rtc: m48t59: Use platform_data struct for year offset value > > > https://git.kernel.org/abelloni/c/a06e4a93067c > > > > > > > Thanks, Alexandre. Would you also take patch 2/2, please? Geert has sent a > > reviewed-by tag for that one too. > > I thought Geert would take it as this only touches arch/m68k > That's quite understandable -- I accidentally addressed it "To: Geert". Sorry for any confusion caused. Anyway, would you please pick up patch 2/2 also? After all, patch 2/2 is the reason why patch 1/2 exists. Indeed, 1/2 was written several years after 2/2, in response to your recent review of 2/2. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-11-21 22:24 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-11-12 22:32 [PATCH v4 0/2] MVME: Adopt standard RTC driver Finn Thain 2024-11-12 22:32 ` [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value Finn Thain 2024-11-15 15:49 ` Andreas Larsson 2024-11-18 13:32 ` (subset) " Alexandre Belloni 2024-11-20 22:13 ` Finn Thain 2024-11-21 17:46 ` Alexandre Belloni 2024-11-21 18:52 ` Geert Uytterhoeven 2024-11-21 22:24 ` Finn Thain
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).