From: Markus B. <sup...@go...> - 2007-08-02 22:09:18
|
Hi Paul, this patch adds the SH_RTC_4_DIGIT_YEAR kernel configuration option. It is set for all SH4 CPUs and for the 7705 and 7710 SH3 CPUs. Unfortunately I wasn't able to get a SH7712 datasheet, so I couldn't check the register for that. Hopefully somebody else has one and can check this. All other SH3 CPUs only have a 2 digit year register. Signed-off by: Markus Brunner <sup...@gm...> --- diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index ceceb05..4dc2d68 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -457,6 +457,10 @@ config SH_CLK_MD help MD2 - MD0 pin setting. +config SH_RTC_4_DIGIT_YEAR + bool + default n + source "kernel/time/Kconfig" endmenu diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig index eca68da..6e00121 100644 --- a/arch/sh/mm/Kconfig +++ b/arch/sh/mm/Kconfig @@ -18,6 +18,7 @@ config CPU_SH4 select CPU_HAS_INTEVT select CPU_HAS_SR_RB select CPU_HAS_PTEA if (!CPU_SUBTYPE_ST40 && !CPU_SH4A) || CPU_SHX2 + select SH_RTC_4_DIGIT_YEAR config CPU_SH4A bool @@ -66,6 +67,7 @@ config CPU_SUBTYPE_SH7705 bool "Support SH7705 processor" select CPU_SH3 select CPU_HAS_INTC_IRQ + select SH_RTC_4_DIGIT_YEAR config CPU_SUBTYPE_SH7706 bool "Support SH7706 processor" @@ -101,6 +103,7 @@ config CPU_SUBTYPE_SH7710 select CPU_SH3 select CPU_HAS_INTC_IRQ select CPU_HAS_DSP + select SH_RTC_4_DIGIT_YEAR help Select SH7710 if you have a SH3-DSP SH7710 CPU. diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 93ee05e..e40552a 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c @@ -319,7 +319,7 @@ static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm) tm->tm_mday = BCD2BIN(readb(rtc->regbase + RDAYCNT)); tm->tm_mon = BCD2BIN(readb(rtc->regbase + RMONCNT)) - 1; -#if defined(CONFIG_CPU_SH4) +#if defined(CONFIG_SH_RTC_4_DIGIT_YEAR) yr = readw(rtc->regbase + RYRCNT); yr100 = BCD2BIN(yr >> 8); yr &= 0xff; @@ -375,13 +375,13 @@ static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm) writeb(BIN2BCD(tm->tm_mday), rtc->regbase + RDAYCNT); writeb(BIN2BCD(tm->tm_mon + 1), rtc->regbase + RMONCNT); -#ifdef CONFIG_CPU_SH3 - year = tm->tm_year % 100; - writeb(BIN2BCD(year), rtc->regbase + RYRCNT); -#else +#if defined(CONFIG_SH_RTC_4_DIGIT_YEAR) year = (BIN2BCD((tm->tm_year + 1900) / 100) << 8) | BIN2BCD(tm->tm_year % 100); writew(year, rtc->regbase + RYRCNT); +#else + year = tm->tm_year % 100; + writeb(BIN2BCD(year), rtc->regbase + RYRCNT); #endif /* Start RTC */ |