MVME: Adopt standard RTC driver
Subsystems (4)
v4 cover MVME: Adopt standard RTC driver
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
Signature · 1 line
2.44.2
PATCH v4 1/2 rtc: m48t59: Use platform_data struct for year offset value
Instead of hard-coded values and ifdefs, store the year offset in the platform_data struct.
---
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(-)
arch/sparc/kernel/time_32.c +1 -0
@@ -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 */
arch/sparc/kernel/time_64.c +1 -0
@@ -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 = {
drivers/rtc/rtc-m48t59.c +4 -22
@@ -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 )
include/linux/rtc/m48t59.h +3 -0
@@ -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_ */
Signature · 1 line
2.44.2
Re: [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value
Quoted 119 lines · Finn Thain
Instead of hard-coded values and ifdefs, store the year offset in the
platform_datastruct.Tested-by Daniel Palmer <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>Signed-off-by Finn Thain <[email protected]>---
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 structm48t59_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(-)arch/sparc/kernel/time_32.c +1
-0@@ -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 */ arch/sparc/kernel/time_64.c +1
-0@@ -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 = {drivers/rtc/rtc-m48t59.c +4
-22@@ -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 )include/linux/rtc/m48t59.h +0
-0
include/linux/rtc/m48t59.h struct m48t59_plat_data { · line 64
Quoted 9 lines
include/linux/rtc/m48t59.h +3
-0@@ -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_ */
Thanks,
Andreas
Re: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value
In reply to Finn ThainQuoted 4 lines · Finn Thain
Instead of hard-coded values and ifdefs, store the year offset in the
platform_datastruct.
Applied, thanks!
[1/2] rtc: m48t59: Use platform_data struct for year offset value
https://git.kernel.org/abelloni/c/a06e4a93067c
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value
Quoted 11 lines · Alexandre Belloni
Quoted 4 lines · Finn Thain
Instead of hard-coded values and ifdefs, store the year offset in the
platform_datastruct.Applied, thanks!
[1/2] rtc: m48t59: Use
platform_datastruct for year offset valuehttps://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.
Alexandre Belloni
maintainerRe: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value
Quoted 9 lines · Finn Thain
Quoted 6 lines · Alexandre Belloni
Quoted 4 lines · Finn Thain
Instead of hard-coded values and ifdefs, store the year offset in the
platform_datastruct.
Quoted 8 lines
Quoted 5 lines
Applied, thanks!
[1/2] rtc: m48t59: Use
platform_datastruct for year offset valuehttps://git.kernel.org/abelloni/c/a06e4a93067cThanks, 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
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Geert Uytterhoeven
maintainerRe: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value
Hi Alexandre,
Quoted 8 lines · Alexandre Belloni
Quoted 7 lines · Finn Thain
Quoted 6 lines · Alexandre Belloni
Quoted 2 lines · Finn Thain
Instead of hard-coded values and ifdefs, store the year offset in the
platform_datastruct.Applied, thanks!
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
[1/2] rtc: m48t59: Use
platform_datastruct for year offset valuehttps://git.kernel.org/abelloni/c/a06e4a93067cThanks, 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
Signature · 5 lines
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
Re: (subset) [PATCH v4 1/2] rtc: m48t59: Use platform_data struct for year offset value
In reply to Alexandre BelloniQuoted 12 lines · Alexandre Belloni
Quoted 11 lines · Finn Thain
Quoted 8 lines · Alexandre Belloni
Quoted 4 lines · Finn Thain
Instead of hard-coded values and ifdefs, store the year offset in the
platform_datastruct.Applied, thanks!
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
[1/2] rtc: m48t59: Use
platform_datastruct for year offset valuehttps://git.kernel.org/abelloni/c/a06e4a93067cThanks, 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.
PATCH v4 2/2 m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver
In reply to Finn ThainBoth mvme147 and mvme16x platforms have their own RTC driver implementations that duplicate functionality provided by the rtc-m48t59 driver. Adopt the rtc-m48t59 driver and remove the other ones.
---
This patch depends upon the m48t59 driver changes in the preceding patch.
Changed since v1:
- Initialize yy_offset in struct m48t59_plat_data.
Changed Since v3:
- Re-ordered defconfig symbols.
- Added reviewed-by tag from arch maintainer.
--- 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 ---------------------------- 9 files changed, 54 insertions(+), 265 deletions(-) delete mode 100644 arch/m68k/mvme16x/rtc.c
arch/m68k/configs/multi_defconfig +1 -0
@@ -503,6 +503,7 @@ CONFIG_UHID=m # CONFIG_USB_SUPPORT is not set CONFIG_RTC_CLASS=y # CONFIG_RTC_NVMEM is not set +CONFIG_RTC_DRV_M48T59=m CONFIG_RTC_DRV_MSM6242=m CONFIG_RTC_DRV_RP5C01=m CONFIG_RTC_DRV_GENERIC=m
arch/m68k/configs/mvme147_defconfig +1 -0
@@ -391,6 +391,7 @@ CONFIG_UHID=m # CONFIG_USB_SUPPORT is not set CONFIG_RTC_CLASS=y # CONFIG_RTC_NVMEM is not set +CONFIG_RTC_DRV_M48T59=y CONFIG_RTC_DRV_GENERIC=m # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set
arch/m68k/configs/mvme16x_defconfig +1 -0
@@ -392,6 +392,7 @@ CONFIG_UHID=m # CONFIG_USB_SUPPORT is not set CONFIG_RTC_CLASS=y # CONFIG_RTC_NVMEM is not set +CONFIG_RTC_DRV_M48T59=y CONFIG_RTC_DRV_GENERIC=m # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set
arch/m68k/include/asm/mvme147hw.h +1 -18
@@ -4,24 +4,7 @@#include <asm/irq.h> -typedef struct { -unsigned char - ctrl, - bcd_sec, - bcd_min, - bcd_hr, - bcd_dow, - bcd_dom, - bcd_mth, - bcd_year; -}MK48T02 ; - -#define RTC_WRITE 0x80 -#define RTC_READ 0x40 -#define RTC_STOP 0x20 - -#define m147_rtc ((MK48T02 * volatile)0xfffe07f8) - +#define MVME147_RTC_BASE 0xfffe0000struct pcc_regs {volatile u_long dma_tadr;
arch/m68k/include/asm/mvme16xhw.h +1 -17
@@ -24,23 +24,7 @@ typedef struct {#define mvmelp ((*(volatile MVMElpPtr)(MVME_LPR_BASE))) -typedef struct { -unsigned char - ctrl, - bcd_sec, - bcd_min, - bcd_hr, - bcd_dow, - bcd_dom, - bcd_mth, - bcd_year; -}MK48T08_t , *MK48T08ptr_t ; - -#define RTC_WRITE 0x80 -#define RTC_READ 0x40 -#define RTC_STOP 0x20 - -#define MVME_RTC_BASE 0xfffc1ff8 +#define MVME_RTC_BASE 0xfffc0000#define MVME_I596_BASE 0xfff46000
arch/m68k/mvme147/config.c +24 -31
89 lines not on this page · raw message
arch/m68k/mvme16x/Makefile +1 -1
@@ -3,4 +3,4 @@ # Makefile for Linux arch/m68k/mvme16x source directory # -obj-y := config.o rtc.o +obj-y := config.o
arch/m68k/mvme16x/config.c +24 -33
90 lines not on this page · raw message
arch/m68k/mvme16x/rtc.c deleted +0 -165
165 lines not on this page · raw message
Signature · 1 line
2.44.2
Re: [PATCH v4 2/2] m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver
Quoted 10 lines · Finn Thain
Both mvme147 and mvme16x platforms have their own RTC driver implementations that duplicate functionality provided by the rtc-m48t59 driver. Adopt the rtc-m48t59 driver and remove the other ones.
Tested-by Daniel Palmer <[email protected]>Signed-off-by Finn Thain <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>---
This patch depends upon the m48t59 driver changes in the preceding patch.
Quoted 6 lines
Changed since v1:
- Initializeyy_offsetin structm48t59_plat_data.Changed Since v3:
- Re-ordered defconfig symbols.
- Added reviewed-by tag from arch maintainer.
so it still can make it into v6.13-rc1 via RTC?
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
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
Alexandre Belloni
maintainerRe: [PATCH v4 2/2] m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver
Quoted 14 lines · Geert Uytterhoeven
Quoted 13 lines · Finn Thain
Both mvme147 and mvme16x platforms have their own RTC driver implementations that duplicate functionality provided by the rtc-m48t59 driver. Adopt the rtc-m48t59 driver and remove the other ones.
Tested-by Daniel Palmer <[email protected]>Signed-off-by Finn Thain <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>---
This patch depends upon the m48t59 driver changes in the preceding patch.Changed since v1:
- Initializeyy_offsetin structm48t59_plat_data.
Quoted 6 lines
Quoted 3 lines
Changed Since v3:
- Re-ordered defconfig symbols.
- Added reviewed-by tag from arch maintainer.so it still can make it into v6.13-rc1 via RTC?
It is now applied, it is going to conflict with your tree as it didn't cleanly apply. I don't think this is going to cause issues but I'll let it sit in linux-next for a few days before sending to Linus.
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Geert Uytterhoeven
maintainerRe: [PATCH v4 2/2] m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver
Hi Alexandre,
Quoted 19 lines · Alexandre Belloni
Quoted 18 lines · Geert Uytterhoeven
Quoted 16 lines · Finn Thain
Both mvme147 and mvme16x platforms have their own RTC driver implementations that duplicate functionality provided by the rtc-m48t59 driver. Adopt the rtc-m48t59 driver and remove the other ones.
Tested-by Daniel Palmer <[email protected]>Signed-off-by Finn Thain <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>---
This patch depends upon the m48t59 driver changes in the preceding patch.Changed since v1:
- Initializeyy_offsetin structm48t59_plat_data.Changed Since v3:
- Re-ordered defconfig symbols.
- Added reviewed-by tag from arch maintainer.
Quoted 6 lines
Quoted 2 lines
so it still can make it into v6.13-rc1 via RTC?
It is now applied, it is going to conflict with your tree as it didn't cleanly apply. I don't think this is going to cause issues but I'll let it sit in linux-next for a few days before sending to Linus.
Thanks! It indeed conflicts with what I sent to Linus, and thus with Linus' current tree, due to nearby changes. If you think the conflict is too serious, feel free to drop the commit, and I'll pick it up for v6.14-rc1.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
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