qemu-neo1973: Incorrect setting of "Month" in pcf5060x.c

andrzej zaborowski balrogg at gmail.com
Thu Jan 24 23:05:49 CET 2008


Hi,

On 24/01/2008, Salil Bijur <salilbijur at gmail.com> wrote:
> I was testing qemu-neo1973 and came across the code in hw/pcf5060x.c.
>
> In the pcf_read and pcf_write functions, the month read from the
> system date is incremented/decremented
> eg.
> case PCF_RTCMT:
>         pcf_rtc_update(s);
>         return to_bcd(s->rtc.tm.tm_mon + 1);
>
> Please correct me if I'm wrong, but isn't this handled in the kernel
> in drivers/rtc/htosys.c?
> This causes the date to be displayed incorrectly, i.e. currently it
> shows the month as February.

I have been suspecting that for some time but was too lazy to look in
the PCF specs and correct this, to have the correct date in the
emulator.

However, I just took a look now and apparently the emulator code is
correct and the kernel is wrong:

Table 55: RTCMT register
                                      [1]
Bit        Mode        Symbol   Reset     Description
4-0        R/W         MONTH    000001    Current month value coded in BCD
                                          format; value = 01 to 12;
see Table 57.
                                [2]
7-5                    reserved

It's not really surprising - on the real Neo, the kernel is the only
authority to set and read the RTC, so if it decrements the month
number before it writes it to the chip, later when it reads it back
and increments it, it gets the correct date. In qemu however we have a
"real" date in the registers, irrespectively of the kernel bugs.

QEMU bug was also likely because hw/pcf5060x.c was written before the
kernel had a pcf50606 RTC driver, about a year ago, so it's quite
lucky that they now work together.

This gets printed on the serial port:

...
s3c2410-sdi s3c2410-sdi: powered down.
pcf50606_rtc_read_time: PCF_TIME: 24.01.08 22:50:46
pcf50606_rtc_read_time: RTC_TIME: 24.1.108 22:50:46
pcf50606 0-0008: setting the system clock to 2008-02-24 22:50:46 (1203893446)
VFS: Mounted root (jffs2 filesystem).
...

Regards



More information about the openmoko-devel mailing list