MVME: Adopt standard RTC driver
Subsystems (4)
v3 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.
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.39.5
PATCH v3 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.
---
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.
--- 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.39.5
Re: [PATCH v3 1/2] rtc: m48t59: Use platform_data struct for year offset value
Quoted 11 lines · Finn Thain
Instead of hard-coded values and ifdefs, store the year offset in the
platform_datastruct.Tested-by Daniel Palmer <[email protected]>Signed-off-by Finn Thain <[email protected]>---
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.
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
PATCH v3 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.
--- 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
@@ -506,6 +506,7 @@ CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_MSM6242=m CONFIG_RTC_DRV_RP5C01=m CONFIG_RTC_DRV_GENERIC=m +CONFIG_RTC_DRV_M48T59=m # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT is not set
arch/m68k/configs/mvme147_defconfig +1 -0
@@ -392,6 +392,7 @@ CONFIG_UHID=m CONFIG_RTC_CLASS=y # CONFIG_RTC_NVMEM is not set CONFIG_RTC_DRV_GENERIC=m +CONFIG_RTC_DRV_M48T59=y # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT is not set
arch/m68k/configs/mvme16x_defconfig +1 -0
@@ -393,6 +393,7 @@ CONFIG_UHID=m CONFIG_RTC_CLASS=y # CONFIG_RTC_NVMEM is not set CONFIG_RTC_DRV_GENERIC=m +CONFIG_RTC_DRV_M48T59=y # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT 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.39.5
Re: [PATCH v3 2/2] m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver
Quoted 11 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]>---
This patch depends upon the m48t59 driver changes in the preceding patch.Changed since v1:
- Initializeyy_offsetin structm48t59_plat_data.
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
Geert Uytterhoeven
maintainerRe: [PATCH v3 2/2] m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver
In reply to Finn ThainHi Finn,
Quoted 39 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]>---
This patch depends upon the m48t59 driver changes in the preceding patch.Changed since v1:
- Initializeyy_offsetin structm48t59_plat_data.arch/m68k/configs/multi_defconfig +1
-0@@ -506,6 +506,7 @@ CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_MSM6242=m CONFIG_RTC_DRV_RP5C01=m CONFIG_RTC_DRV_GENERIC=m +CONFIG_RTC_DRV_M48T59=m # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT is not setarch/m68k/configs/mvme147_defconfig +1
-0@@ -392,6 +392,7 @@ CONFIG_UHID=m CONFIG_RTC_CLASS=y # CONFIG_RTC_NVMEM is not set CONFIG_RTC_DRV_GENERIC=m +CONFIG_RTC_DRV_M48T59=y # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT is not setarch/m68k/configs/mvme16x_defconfig +0
-0
arch/m68k/configs/mvme16x_defconfig CONFIG_UHID=m · line 399
Quoted 7 lines
arch/m68k/configs/mvme16x_defconfig +1
-0@@ -393,6 +393,7 @@ CONFIG_UHID=m CONFIG_RTC_CLASS=y # CONFIG_RTC_NVMEM is not set CONFIG_RTC_DRV_GENERIC=m +CONFIG_RTC_DRV_M48T59=y # CONFIG_VIRTIO_MENU is not set # CONFIG_VHOST_MENU is not set # CONFIG_IOMMU_SUPPORT is not set
All of the above don't seem to be inserted at the right location?
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
Hi sparc maintainers
These two patches have now been reviewed by Geert. If you would be so kind as to review the sparc changes, I will ask the RTC maintainer to consider merging this series.
Regards
Finn
Quoted 35 lines · Finn Thain
This series removes some duplicated RTC driver code.
First rtc-m48t59 is tweaked to bring it into equivalence with the RTC drivers inarch/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 structm48t59_plat_data.Changed since v2:
- Use an int for the year offset in structm48t59_plat_data.Finn Thain (2):
rtc: m48t59: Useplatform_datastruct for year offset value
m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driverarch/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