* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
@ 2008-09-08 1:26 ` David Miller
2008-09-10 2:07 ` Robert Reif
` (18 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: David Miller @ 2008-09-08 1:26 UTC (permalink / raw)
To: sparclinux
From: Krzysztof Helt <krzysztof.h1@poczta.fm>
Date: Thu, 4 Sep 2008 18:57:04 +0200
> Fix setting of a year in m48t08 and m48t02 clocks.
> They do not have century bits and setting them
> causes the year to overflow (bit 0x80 set).
>
> Problem found by Robert Reif on Sun Sparcstation 20.
>
> Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Applied to sparc-next-2.6, thanks a lot!
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
2008-09-08 1:26 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 David Miller
@ 2008-09-10 2:07 ` Robert Reif
2008-09-10 2:30 ` David Miller
` (17 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Robert Reif @ 2008-09-10 2:07 UTC (permalink / raw)
To: sparclinux
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
Krzysztof Helt wrote:
> From: Krzysztof Helt <krzysztof.h1@wp.pl>
>
> Fix setting of a year in m48t08 and m48t02 clocks.
> They do not have century bits and setting them
> causes the year to overflow (bit 0x80 set).
>
I think this fix is also needed.
Signed-off-by: Robert Reif <reif@earthlink.net>
[-- Attachment #2: rtc.diff.txt --]
[-- Type: text/plain, Size: 591 bytes --]
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index 761e9d7..ce4eff6 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -82,7 +82,8 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm)
tm->tm_mday = BCD2BIN(M48T59_READ(M48T59_MDAY));
val = M48T59_READ(M48T59_WDAY);
- if ((val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) {
+ if ((pdata->type == M48T59RTC_TYPE_M48T59) &&
+ (val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) {
dev_dbg(dev, "Century bit is enabled\n");
tm->tm_year += 100; /* one century */
}
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
2008-09-08 1:26 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 David Miller
2008-09-10 2:07 ` Robert Reif
@ 2008-09-10 2:30 ` David Miller
2008-09-10 2:30 ` David Miller
` (16 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: David Miller @ 2008-09-10 2:30 UTC (permalink / raw)
To: sparclinux
From: Robert Reif <reif@earthlink.net>
Date: Tue, 09 Sep 2008 22:07:47 -0400
> Krzysztof Helt wrote:
> > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> >
> > Fix setting of a year in m48t08 and m48t02 clocks.
> > They do not have century bits and setting them
> > causes the year to overflow (bit 0x80 set).
> >
> I think this fix is also needed.
>
> Signed-off-by: Robert Reif <reif@earthlink.net>
It should already be in sparc-next-2.6
Let me know if it isn't there :-)
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (2 preceding siblings ...)
2008-09-10 2:30 ` David Miller
@ 2008-09-10 2:30 ` David Miller
2008-09-10 2:38 ` David Miller
` (15 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: David Miller @ 2008-09-10 2:30 UTC (permalink / raw)
To: sparclinux
From: Robert Reif <reif@earthlink.net>
Date: Tue, 09 Sep 2008 22:07:47 -0400
> Krzysztof Helt wrote:
> > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> >
> > Fix setting of a year in m48t08 and m48t02 clocks.
> > They do not have century bits and setting them
> > causes the year to overflow (bit 0x80 set).
> >
> I think this fix is also needed.
>
> Signed-off-by: Robert Reif <reif@earthlink.net>
Ignore previous email :-)
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (3 preceding siblings ...)
2008-09-10 2:30 ` David Miller
@ 2008-09-10 2:38 ` David Miller
2008-09-10 5:16 ` Krzysztof Helt
` (14 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: David Miller @ 2008-09-10 2:38 UTC (permalink / raw)
To: sparclinux
From: Robert Reif <reif@earthlink.net>
Date: Tue, 09 Sep 2008 22:07:47 -0400
> Krzysztof Helt wrote:
> > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> >
> > Fix setting of a year in m48t08 and m48t02 clocks.
> > They do not have century bits and setting them
> > causes the year to overflow (bit 0x80 set).
> >
> I think this fix is also needed.
>
> Signed-off-by: Robert Reif <reif@earthlink.net>
Looks good to me, applied, thanks Robert.
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (4 preceding siblings ...)
2008-09-10 2:38 ` David Miller
@ 2008-09-10 5:16 ` Krzysztof Helt
2008-09-10 10:53 ` Robert Reif
` (13 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Helt @ 2008-09-10 5:16 UTC (permalink / raw)
To: sparclinux
On Tue, 09 Sep 2008 22:07:47 -0400
Robert Reif <reif@earthlink.net> wrote:
> Krzysztof Helt wrote:
> > From: Krzysztof Helt <krzysztof.h1@wp.pl>
> >
> > Fix setting of a year in m48t08 and m48t02 clocks.
> > They do not have century bits and setting them
> > causes the year to overflow (bit 0x80 set).
> >
> I think this fix is also needed.
>
> Signed-off-by: Robert Reif <reif@earthlink.net>
>
It should not be needed because these bits are always 0
on m48t08 and m48t02. The previous fix did not set them
so they should not change.
Have you needed this?
Anyway, this patch does not hurt, either.
Regards,
Krzysztof
>
>
[rtc.diff.txt text/plain (592B)]
diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
index 761e9d7..ce4eff6 100644
--- a/drivers/rtc/rtc-m48t59.c
+++ b/drivers/rtc/rtc-m48t59.c
@@ -82,7 +82,8 @@ static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm)
tm->tm_mday = BCD2BIN(M48T59_READ(M48T59_MDAY));
val = M48T59_READ(M48T59_WDAY);
- if ((val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) {
+ if ((pdata->type = M48T59RTC_TYPE_M48T59) &&
+ (val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) {
dev_dbg(dev, "Century bit is enabled\n");
tm->tm_year += 100; /* one century */
}
----------------------------------------------------------------------
Tanie polaczenia z Polska i ze swiatem
Sprawdz >> http://link.interia.pl/f1f00
^ permalink raw reply related [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (5 preceding siblings ...)
2008-09-10 5:16 ` Krzysztof Helt
@ 2008-09-10 10:53 ` Robert Reif
2008-09-11 10:04 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Alexander Beregalov
` (12 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Robert Reif @ 2008-09-10 10:53 UTC (permalink / raw)
To: sparclinux
Krzysztof Helt wrote:
> Have you needed this?
>
This is what I was getting without my patch. The century
bit may have been set by the driver before the first patch
was applied.
Aug 3 14:21:35 ss20-1 kernel: rtc-m48t59 rtc-m48t59.0: Century bit is
enabled
Aug 3 14:21:35 ss20-1 kernel: rtc-m48t59 rtc-m48t59.0: RTC read time
2108-08-10 00/49/26
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (6 preceding siblings ...)
2008-09-10 10:53 ` Robert Reif
@ 2008-09-11 10:04 ` Alexander Beregalov
2008-09-13 10:33 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 Krzysztof Helt
` (11 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Alexander Beregalov @ 2008-09-11 10:04 UTC (permalink / raw)
To: sparclinux
Hi
Is that a different problem?
2.6.27-rc6
$ date
Sat Sep 11 13:55:09 MSK 1976 <<<--
$ dmesg|cut -c 16-|egrep -i "clock|rtc"
clocksource: mult[245d1] shift[16]
clockevent: mult[70a3d70a] shift[32]
device class 'rtc': registering
bus: 'of': add driver clock
bus: 'of': driver_probe_device: matched device f0066438 with driver clock
bus: 'of': really_probe: probing driver clock with device f0066438
/pci@1f,0/pci@1,1/ebus@1/eeprom@14,0: Clock regs at 000001fff1000000
driver: 'f0066438': driver_bound: bound to device 'clock'
bus: 'of': really_probe: bound device f0066438 to driver clock
Mini RTC Driver
device: 'rtc': device_add
Registering sysdev class 'clocksource'
Registering sys device of class 'clocksource'
Registering sys device 'clocksource0'
bus: 'platform': add driver rtc-m48t59
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
There is a topic in LKML http://lkml.org/lkml/2008/9/10/189
Probably it is related to that topic.
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (7 preceding siblings ...)
2008-09-11 10:04 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Alexander Beregalov
@ 2008-09-13 10:33 ` Krzysztof Helt
2008-10-03 20:38 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Alexander Beregalov
` (10 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Helt @ 2008-09-13 10:33 UTC (permalink / raw)
To: sparclinux
On Thu, 11 Sep 2008 14:04:12 +0400
"Alexander Beregalov" <a.beregalov@gmail.com> wrote:
> Hi
>
> Is that a different problem?
>
> 2.6.27-rc6
>
What kernel version have you used?
If it was plain 2.6.27-rc6 there was no rtc layer support yet. Please try the linux-next.
> $ date
> Sat Sep 11 13:55:09 MSK 1976 <<<--
>
> $ dmesg|cut -c 16-|egrep -i "clock|rtc"
> clocksource: mult[245d1] shift[16]
> clockevent: mult[70a3d70a] shift[32]
> device class 'rtc': registering
> bus: 'of': add driver clock
> bus: 'of': driver_probe_device: matched device f0066438 with driver clock
> bus: 'of': really_probe: probing driver clock with device f0066438
> /pci@1f,0/pci@1,1/ebus@1/eeprom@14,0: Clock regs at 000001fff1000000
> driver: 'f0066438': driver_bound: bound to device 'clock'
> bus: 'of': really_probe: bound device f0066438 to driver clock
> Mini RTC Driver
^^^ MiniRTC should be gone (or at least disabled) if you try to use the rtc layer (if you applied patches).
> device: 'rtc': device_add
> Registering sysdev class 'clocksource'
> Registering sys device of class 'clocksource'
> Registering sys device 'clocksource0'
> bus: 'platform': add driver rtc-m48t59
> drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
>
> There is a topic in LKML http://lkml.org/lkml/2008/9/10/189
> Probably it is related to that topic.
>
Regards,
Krzysztof
----------------------------------------------------------------------
Wygraj SUZUKI GRAND VITARA 4x4 - TYSIACE CENNYCH NAGROD czekaja
wejdz na www.variant.pl
GRAJ i WYGRYWAJ - Codziennie 100 nagrod !!!
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (8 preceding siblings ...)
2008-09-13 10:33 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 Krzysztof Helt
@ 2008-10-03 20:38 ` Alexander Beregalov
2008-10-04 10:27 ` krzysztof.h1
` (9 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Alexander Beregalov @ 2008-10-03 20:38 UTC (permalink / raw)
To: sparclinux
2008/9/13 Krzysztof Helt <krzysztof.h1@poczta.fm>:
> On Thu, 11 Sep 2008 14:04:12 +0400
> "Alexander Beregalov" <a.beregalov@gmail.com> wrote:
>
>> Hi
>>
>> Is that a different problem?
>>
>> 2.6.27-rc6
>>
>
> What kernel version have you used?
> If it was plain 2.6.27-rc6 there was no rtc layer support yet. Please try the linux-next.
Yes, it was mainline kernel.
I have the same issue from time to time on mainline kernel and on
`davem/sparc-next-2.6.git master`.
Clock appears to be in the future or in the past (I suppose it is
actually far in the future)
after boot from time to time.
I set it properly by NTP, save hw clock, but after several reboots
story happens again.
bus: 'platform': add driver rtc-m48t59
bus: 'platform': driver_probe_device: matched device rtc-m48t59.0 with
driver rtc-m48t59
bus: 'platform': really_probe: probing driver rtc-m48t59 with device
rtc-m48t59.0
device: 'rtc0': device_add
rtc-m48t59 rtc-m48t59.0: rtc core: registered m48t59 as rtc0
driver: 'rtc-m48t59.0': driver_bound: bound to device 'rtc-m48t59'
bus: 'platform': really_probe: bound device rtc-m48t59.0 to driver rtc-m48t59
bus: 'platform': add driver rtc-bq4802
bus: 'platform': add driver rtc-sun4v
bus: 'platform': add driver rtc-starfire
...
rtc-m48t59 rtc-m48t59.0: setting system clock to 2108-10-03 23:46:02
UTC (83783866)
At the moment I write it system time is Sun Aug 27 18:04:42 UTC 1972 (83786677).
The hardware is Ultra 10.
How can I help?
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (9 preceding siblings ...)
2008-10-03 20:38 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Alexander Beregalov
@ 2008-10-04 10:27 ` krzysztof.h1
2008-10-04 11:26 ` Alexander Beregalov
` (8 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: krzysztof.h1 @ 2008-10-04 10:27 UTC (permalink / raw)
To: sparclinux
> 2008/9/13 Krzysztof Helt <krzysztof.h1@poczta.fm>:
> > On Thu, 11 Sep 2008 14:04:12 +0400
> > "Alexander Beregalov" <a.beregalov@gmail.com> wrote:
> >
> >> Hi
> >>
> >> Is that a different problem?
> >>
> >> 2.6.27-rc6
> >>
> >
> > What kernel version have you used?
> > If it was plain 2.6.27-rc6 there was no rtc layer support yet. Please
> try the linux-next.
> Yes, it was mainline kernel.
>
> I have the same issue from time to time on mainline kernel and on
> `davem/sparc-next-2.6.git master`.
> Clock appears to be in the future or in the past (I suppose it is
> actually far in the future)
> after boot from time to time.
> I set it properly by NTP, save hw clock, but after several reboots
> story happens again.
>
> bus: 'platform': add driver rtc-m48t59
> bus: 'platform': driver_probe_device: matched device rtc-m48t59.0 with
> driver rtc-m48t59
> bus: 'platform': really_probe: probing driver rtc-m48t59 with device
> rtc-m48t59.0
> device: 'rtc0': device_add
> rtc-m48t59 rtc-m48t59.0: rtc core: registered m48t59 as rtc0
> driver: 'rtc-m48t59.0': driver_bound: bound to device 'rtc-m48t59'
> bus: 'platform': really_probe: bound device rtc-m48t59.0 to driver
> rtc-m48t59
> bus: 'platform': add driver rtc-bq4802
> bus: 'platform': add driver rtc-sun4v
> bus: 'platform': add driver rtc-starfire
> ...
> rtc-m48t59 rtc-m48t59.0: setting system clock to 2108-10-03 23:46:02
> UTC (83783866)
>
> At the moment I write it system time is Sun Aug 27 18:04:42 UTC 1972
> (83786677).
>
> The hardware is Ultra 10.
>
> How can I help?
>
>
Do you reboot your system with different kernel versions (-next and mainline) or other systems?
I am away from my Sun box so I'll retest this on Monday.
Kind regards,
Krzysztof
----------------------------------------------------------------------
Dzwon taniej na zagraniczne komorki!
Sprawdz >> http://link.interia.pl/f1f26
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (10 preceding siblings ...)
2008-10-04 10:27 ` krzysztof.h1
@ 2008-10-04 11:26 ` Alexander Beregalov
2008-10-07 21:39 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 Krzysztof Helt
` (7 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Alexander Beregalov @ 2008-10-04 11:26 UTC (permalink / raw)
To: sparclinux
2008/10/4 <krzysztof.h1@poczta.fm>:
> Do you reboot your system with different kernel versions (-next and mainline) or other systems?
Yes, I tested mainline and sparc-next kernels on two Ultra 10s, but I
could not find the rule how it happens.
It means it does not happen every time I use sparc-next or every time
I use mainline right after sparc-next.
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (11 preceding siblings ...)
2008-10-04 11:26 ` Alexander Beregalov
@ 2008-10-07 21:39 ` Krzysztof Helt
2008-10-07 21:40 ` David Miller
` (6 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Helt @ 2008-10-07 21:39 UTC (permalink / raw)
To: sparclinux
On Sat, 4 Oct 2008 15:26:07 +0400
"Alexander Beregalov" <a.beregalov@gmail.com> wrote:
> 2008/10/4 <krzysztof.h1@poczta.fm>:
> > Do you reboot your system with different kernel versions (-next and mainline) or other systems?
> Yes, I tested mainline and sparc-next kernels on two Ultra 10s, but I
> could not find the rule how it happens.
> It means it does not happen every time I use sparc-next or every time
> I use mainline right after sparc-next.
>
Ok.
I found the problem. The rtc-m48t59 driver sets a century bit if the year is over 2000. It is not correct on sparc as the first year is 1968 (so the century bit is needed in year 2168).
The only sane solution is to reduce mostek_read_byte() and mostek_write_byte() and move the sparc specific year offset (1968) into the rtc-m48t59 driver.
I'll prepare a patch.
Thank you for reporting this,
Krzysztof
----------------------------------------------------------------------
Dodaj strone www do katalogu. Pokaz ze istniejesz!
Sprawdz jak >> http://link.interia.pl/f1f2a
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (12 preceding siblings ...)
2008-10-07 21:39 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 Krzysztof Helt
@ 2008-10-07 21:40 ` David Miller
2008-10-13 20:51 ` Krzysztof Helt
` (5 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: David Miller @ 2008-10-07 21:40 UTC (permalink / raw)
To: sparclinux
From: Krzysztof Helt <krzysztof.h1@poczta.fm>
Date: Tue, 7 Oct 2008 23:39:09 +0200
> I found the problem. The rtc-m48t59 driver sets a century bit if the
> year is over 2000. It is not correct on sparc as the first year is
> 1968 (so the century bit is needed in year 2168).
>
> The only sane solution is to reduce mostek_read_byte() and
> mostek_write_byte() and move the sparc specific year offset (1968)
> into the rtc-m48t59 driver.
>
> I'll prepare a patch.
>
> Thank you for reporting this,
Thanks for tracking this down.
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (13 preceding siblings ...)
2008-10-07 21:40 ` David Miller
@ 2008-10-13 20:51 ` Krzysztof Helt
2008-10-13 22:12 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Alexander Beregalov
` (4 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Helt @ 2008-10-13 20:51 UTC (permalink / raw)
To: sparclinux
Hi Alexander,
Please try the patch below if it fixes your problem. You need to set
correct date (year) after the patched kernel is run.
It is tested on Ultra60 but not tested on sparc32.
Kind regards,
Krzysztof
----
From: Krzysztof Helt <krzysztof.h1@wp.pl>
Shift the first year to 1968 for Sun SPARC machines.
Move this logic from platform specific files to rtc driver
as this fixes problems with correctly calculating a century
bit.
Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
---
diff -urp linux-ref/arch/sparc/kernel/time.c linux-new/arch/sparc/kernel/time.c
--- linux-ref/arch/sparc/kernel/time.c 2008-10-13 12:03:18.861547000 -0400
+++ linux-new/arch/sparc/kernel/time.c 2008-10-14 00:12:39.263787485 -0400
@@ -119,35 +119,16 @@ static unsigned char mostek_read_byte(st
{
struct platform_device *pdev = to_platform_device(dev);
struct m48t59_plat_data *pdata = pdev->dev.platform_data;
- void __iomem *regs = pdata->ioaddr;
- unsigned char val = readb(regs + ofs);
- /* the year 0 is 1968 */
- if (ofs = pdata->offset + M48T59_YEAR) {
- val += 0x68;
- if ((val & 0xf) > 9)
- val += 6;
- }
- return val;
+ return readb(pdata->ioaddr + ofs);
}
static void mostek_write_byte(struct device *dev, u32 ofs, u8 val)
{
struct platform_device *pdev = to_platform_device(dev);
struct m48t59_plat_data *pdata = pdev->dev.platform_data;
- void __iomem *regs = pdata->ioaddr;
- if (ofs = pdata->offset + M48T59_YEAR) {
- if (val < 0x68)
- val += 0x32;
- else
- val -= 0x68;
- if ((val & 0xf) > 9)
- val += 6;
- if ((val & 0xf0) > 0x9A)
- val += 0x60;
- }
- writeb(val, regs + ofs);
+ writeb(val, pdata->ioaddr + ofs);
}
static struct m48t59_plat_data m48t59_data = {
diff -urp linux-ref/arch/sparc64/kernel/time.c linux-new/arch/sparc64/kernel/time.c
--- linux-ref/arch/sparc64/kernel/time.c 2008-10-13 12:03:18.993543000 -0400
+++ linux-new/arch/sparc64/kernel/time.c 2008-10-14 00:13:29.991786912 -0400
@@ -503,39 +503,16 @@ static struct of_platform_driver bq4802_
static unsigned char mostek_read_byte(struct device *dev, u32 ofs)
{
struct platform_device *pdev = to_platform_device(dev);
- struct m48t59_plat_data *pdata = pdev->dev.platform_data;
- void __iomem *regs;
- unsigned char val;
-
- regs = (void __iomem *) pdev->resource[0].start;
- val = readb(regs + ofs);
-
- /* the year 0 is 1968 */
- if (ofs = pdata->offset + M48T59_YEAR) {
- val += 0x68;
- if ((val & 0xf) > 9)
- val += 6;
- }
- return val;
+ void __iomem *regs = (void __iomem *) pdev->resource[0].start;
+
+ return readb(regs + ofs);
}
static void mostek_write_byte(struct device *dev, u32 ofs, u8 val)
{
struct platform_device *pdev = to_platform_device(dev);
- struct m48t59_plat_data *pdata = pdev->dev.platform_data;
- void __iomem *regs;
+ void __iomem *regs = (void __iomem *) pdev->resource[0].start;
- regs = (void __iomem *) pdev->resource[0].start;
- if (ofs = pdata->offset + M48T59_YEAR) {
- if (val < 0x68)
- val += 0x32;
- else
- val -= 0x68;
- if ((val & 0xf) > 9)
- val += 6;
- if ((val & 0xf0) > 0x9A)
- val += 0x60;
- }
writeb(val, regs + ofs);
}
diff -urp linux-ref/drivers/rtc/rtc-m48t59.c linux-new/drivers/rtc/rtc-m48t59.c
--- linux-ref/drivers/rtc/rtc-m48t59.c 2008-10-13 12:03:34.261538000 -0400
+++ linux-new/drivers/rtc/rtc-m48t59.c 2008-10-14 00:15:15.947787512 -0400
@@ -87,6 +87,10 @@ static int m48t59_rtc_read_time(struct d
dev_dbg(dev, "Century bit is enabled\n");
tm->tm_year += 100; /* one century */
}
+#if defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
+ /* 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);
@@ -110,11 +114,20 @@ static int m48t59_rtc_set_time(struct de
struct m48t59_private *m48t59 = platform_get_drvdata(pdev);
unsigned long flags;
u8 val = 0;
+ int year = tm->tm_year;
+
+#if defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
+ /* Sun SPARC machines count years since 1968 */
+ year -= 68;
+#endif
dev_dbg(dev, "RTC set time %04d-%02d-%02d %02d/%02d/%02d\n",
- tm->tm_year + 1900, tm->tm_mon, tm->tm_mday,
+ year + 1900, tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
+ if (year < 0)
+ return -EINVAL;
+
spin_lock_irqsave(&m48t59->lock, flags);
/* Issue the WRITE command */
M48T59_SET_BITS(M48T59_CNTL_WRITE, M48T59_CNTL);
@@ -125,7 +138,7 @@ static int m48t59_rtc_set_time(struct de
M48T59_WRITE((BIN2BCD(tm->tm_mday) & 0x3F), M48T59_MDAY);
/* tm_mon is 0-11 */
M48T59_WRITE((BIN2BCD(tm->tm_mon + 1) & 0x1F), M48T59_MONTH);
- M48T59_WRITE(BIN2BCD(tm->tm_year % 100), M48T59_YEAR);
+ M48T59_WRITE(BIN2BCD(year % 100), M48T59_YEAR);
if (pdata->type = M48T59RTC_TYPE_M48T59 && (tm->tm_year / 100))
val = (M48T59_WDAY_CEB | M48T59_WDAY_CB);
@@ -159,6 +172,10 @@ static int m48t59_rtc_readalarm(struct d
M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL);
tm->tm_year = BCD2BIN(M48T59_READ(M48T59_YEAR));
+#if defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
+ /* Sun SPARC machines count years since 1968 */
+ tm->tm_year += 68;
+#endif
/* tm_mon is 0-11 */
tm->tm_mon = BCD2BIN(M48T59_READ(M48T59_MONTH)) - 1;
@@ -192,11 +209,20 @@ static int m48t59_rtc_setalarm(struct de
struct rtc_time *tm = &alrm->time;
u8 mday, hour, min, sec;
unsigned long flags;
+ int year = tm->tm_year;
+
+#if defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
+ /* Sun SPARC machines count years since 1968 */
+ year -= 68;
+#endif
/* If no irq, we don't support ALARM */
if (m48t59->irq = NO_IRQ)
return -EIO;
+ if (year < 0)
+ return -EINVAL;
+
/*
* 0xff means "always match"
*/
@@ -228,7 +254,7 @@ static int m48t59_rtc_setalarm(struct de
spin_unlock_irqrestore(&m48t59->lock, flags);
dev_dbg(dev, "RTC set alarm time %04d-%02d-%02d %02d/%02d/%02d\n",
- tm->tm_year + 1900, tm->tm_mon, tm->tm_mday,
+ year + 1900, tm->tm_mon, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
return 0;
}
----------------------------------------------------------------------
Doladuj w promocji telefon!
Sprawdz >> http://link.interia.pl/f1f45
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (14 preceding siblings ...)
2008-10-13 20:51 ` Krzysztof Helt
@ 2008-10-13 22:12 ` Alexander Beregalov
2008-10-19 14:12 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 Krzysztof Helt
` (3 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Alexander Beregalov @ 2008-10-13 22:12 UTC (permalink / raw)
To: sparclinux
2008/10/14 Krzysztof Helt <krzysztof.h1@poczta.fm>:
> Hi Alexander,
Hi
>
> Please try the patch below if it fixes your problem. You need to set
> correct date (year) after the patched kernel is run.
Unfortunatelly, it does not work for me.
I patch kernel and reboot.
I set correct date and save it (hwclock --systohc (from
util-linux-2.14)) and reboot.
Kernel sets date to
rtc-m48t59 rtc-m48t59.0: setting system clock to 2108-10-14 01:32:24
UTC (84654248)
Then I do not set correct date and reboot again, the kernel sets date to
rtc-m48t59 rtc-m48t59.0: setting system clock to 1972-09-06 21:49:09
UTC (84664149)
(these two dates (unixtime) are not in that order that I mentioned, I
did reboot many times, these messages are from last sessions)
>
> It is tested on Ultra60 but not tested on sparc32.
Unfortunatelly, I have only sparc64.
The kernel is
2.6.27-03543-ga447c09-dirty
commit a447c0932445f92ce6f4c1bd020f62c5097a7842
Author: Steven Whitehouse <swhiteho@redhat.com>
Date: Mon Oct 13 10:46:57 2008 +0100
vfs: Use const for kernel parser table
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (15 preceding siblings ...)
2008-10-13 22:12 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Alexander Beregalov
@ 2008-10-19 14:12 ` Krzysztof Helt
2008-10-19 22:17 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Alexander Beregalov
` (2 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Helt @ 2008-10-19 14:12 UTC (permalink / raw)
To: sparclinux
On Tue, 14 Oct 2008 02:12:54 +0400
"Alexander Beregalov" <a.beregalov@gmail.com> wrote:
> 2008/10/14 Krzysztof Helt <krzysztof.h1@poczta.fm>:
> > Hi Alexander,
> Hi
> >
> > Please try the patch below if it fixes your problem. You need to set
> > correct date (year) after the patched kernel is run.
> Unfortunatelly, it does not work for me.
>
> I patch kernel and reboot.
> I set correct date and save it (hwclock --systohc (from
> util-linux-2.14)) and reboot.
> Kernel sets date to
> rtc-m48t59 rtc-m48t59.0: setting system clock to 2108-10-14 01:32:24
> UTC (84654248)
> Then I do not set correct date and reboot again, the kernel sets date to
> rtc-m48t59 rtc-m48t59.0: setting system clock to 1972-09-06 21:49:09
> UTC (84664149)
>
> (these two dates (unixtime) are not in that order that I mentioned, I
> did reboot many times, these messages are from last sessions)
>
> >
> > It is tested on Ultra60 but not tested on sparc32.
> Unfortunatelly, I have only sparc64.
>
> The kernel is
> 2.6.27-03543-ga447c09-dirty
>
> commit a447c0932445f92ce6f4c1bd020f62c5097a7842
> Author: Steven Whitehouse <swhiteho@redhat.com>
> Date: Mon Oct 13 10:46:57 2008 +0100
> vfs: Use const for kernel parser table
>
I am trying to reproduce your problem on Ultra60 and Ubuntu 7.10
with kernel from 17 October (commit: 0cfd81031a26717fe14380d18275f8e217571615)
but I have failed so far. I'll do more test.
Regards,
Krzysztof
----------------------------------------------------------------------
Drinkomat - aplikacja na telefon!
Pobierz >> http://link.interia.pl/f1f38
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (16 preceding siblings ...)
2008-10-19 14:12 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 Krzysztof Helt
@ 2008-10-19 22:17 ` Alexander Beregalov
2008-10-19 23:31 ` Alexander Beregalov
2008-10-23 17:32 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 Krzysztof Helt
19 siblings, 0 replies; 21+ messages in thread
From: Alexander Beregalov @ 2008-10-19 22:17 UTC (permalink / raw)
To: sparclinux
2008/10/19 Krzysztof Helt <krzysztof.h1@poczta.fm>:
> On Tue, 14 Oct 2008 02:12:54 +0400
> "Alexander Beregalov" <a.beregalov@gmail.com> wrote:
>
>> 2008/10/14 Krzysztof Helt <krzysztof.h1@poczta.fm>:
>> > Hi Alexander,
>> Hi
>> >
>> > Please try the patch below if it fixes your problem. You need to set
>> > correct date (year) after the patched kernel is run.
>> Unfortunatelly, it does not work for me.
>>
>> I patch kernel and reboot.
>> I set correct date and save it (hwclock --systohc (from
>> util-linux-2.14)) and reboot.
>> Kernel sets date to
>> rtc-m48t59 rtc-m48t59.0: setting system clock to 2108-10-14 01:32:24
It seems to me the problem is here:
drivers/rtc/rtc-m48t59.c
static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm)
/* tm->tm_year is 108 here */
val = M48T59_READ(M48T59_WDAY);
if ((pdata->type = M48T59RTC_TYPE_M48T59) &&
(val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) {
dev_dbg(dev, "Century bit is enabled\n");
tm->tm_year += 100; /* one century */
}
/* tm->tm_year is 208 here */
Finally year becomes 2108.
It should not enter this condition.
Is it obvously how to rewrite the condition or is the problem in another place?
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (17 preceding siblings ...)
2008-10-19 22:17 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Alexander Beregalov
@ 2008-10-19 23:31 ` Alexander Beregalov
2008-10-23 17:32 ` [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 Krzysztof Helt
19 siblings, 0 replies; 21+ messages in thread
From: Alexander Beregalov @ 2008-10-19 23:31 UTC (permalink / raw)
To: sparclinux
> It seems to me the problem is here:
>
> drivers/rtc/rtc-m48t59.c
> static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm)
>
> /* tm->tm_year is 108 here */
> val = M48T59_READ(M48T59_WDAY);
M48T59_READ(M48T59_WDAY) is 0x31 on my host
M48T59_WDAY_CEB | M48T59_WDAY_CB | M48T59_UNUSED ??
What is wrong?
Should BCD2BIN(M48T59_READ(M48T59_YEAR)) return "8" ?
> if ((pdata->type = M48T59RTC_TYPE_M48T59) &&
> (val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) {
> dev_dbg(dev, "Century bit is enabled\n");
> tm->tm_year += 100; /* one century */
> }
> /* tm->tm_year is 208 here */
>
> Finally year becomes 2108.
>
> It should not enter this condition.
> Is it obvously how to rewrite the condition or is the problem in another place?
>
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02
2008-09-04 16:57 [PATCH] rtc-m48t59: fix setting of a year on m48t08 and m48t02 rtcs Krzysztof Helt
` (18 preceding siblings ...)
2008-10-19 23:31 ` Alexander Beregalov
@ 2008-10-23 17:32 ` Krzysztof Helt
19 siblings, 0 replies; 21+ messages in thread
From: Krzysztof Helt @ 2008-10-23 17:32 UTC (permalink / raw)
To: sparclinux
On Mon, 20 Oct 2008 03:31:52 +0400
"Alexander Beregalov" <a.beregalov@gmail.com> wrote:
> > It seems to me the problem is here:
> >
> > drivers/rtc/rtc-m48t59.c
> > static int m48t59_rtc_read_time(struct device *dev, struct rtc_time *tm)
> >
> > /* tm->tm_year is 108 here */
> > val = M48T59_READ(M48T59_WDAY);
>
> M48T59_READ(M48T59_WDAY) is 0x31 on my host
> M48T59_WDAY_CEB | M48T59_WDAY_CB | M48T59_UNUSED ??
>
> What is wrong?
>
It is ok. It is M48T59_WDAY_CEB | M48T59_WDAY_CB and 0x1 means Monday (week day number).
> Should BCD2BIN(M48T59_READ(M48T59_YEAR)) return "8" ?
>
Yes. It should be 8 if you have not applied the last patch I sent ("Shift the first year to 1968 for Sun SPARC machines").
If the patch has been applied it would be 40 (decimal) means 1968+40 = 2008.
> > if ((pdata->type = M48T59RTC_TYPE_M48T59) &&
> > (val & M48T59_WDAY_CEB) && (val & M48T59_WDAY_CB)) {
> > dev_dbg(dev, "Century bit is enabled\n");
> > tm->tm_year += 100; /* one century */
> > }
> > /* tm->tm_year is 208 here */
> >
> > Finally year becomes 2108.
> >
> > It should not enter this condition.
> > Is it obvously how to rewrite the condition or is the problem in another place?
It should enter the condition if the century bit is set. The error is that the century bit is set somehow.
It is possible in one of the previous versions of the rtc layer conversion code. The mentioned patch should fix it.
If the patch is applied could you reproduce the bug by rebooting the machine with the patched version of the kernel? (Set the correct date once then reboot).
Regards,
Krzysztof
PS. The easy way to reset the century bit should be to set the year before 2000 for a moment.
----------------------------------------------------------------------
Dzwon taniej na zagraniczne komorki!
Sprawdz >> http://link.interia.pl/f1f4e
^ permalink raw reply [flat|nested] 21+ messages in thread