Skip to contentSkip to conversation

rtc-m48t59 on an Ultra 5

DISCUSSION Josip Rodin 4 participants 6 messages Sep 6, 2008 – Sep 8, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

Current sparc-next-2.6 on my Ultra 5 works fine, but the new RTC driver prints the following during boot:

rtc-m48t59 rtc-m48t59.0: rtc core: registered m48t59 as rtc0 rtc-m48t59 rtc-m48t59.0: hctosys: invalid date/time

The system time is okay after boot, though.

% sudo ln -s rtc0 /dev/rtc
% sudo hwclock --debug; echo; date
hwclock from util-linux-2.12r
Using /dev/rtc interface to clock.
Last drift adjustment done at 1220663753 seconds after 1969
Last calibration done at 1220663753 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc does not have interrupt functions. Waiting in loop for time from /dev/rtc to change ...got clock tick
Time read from Hardware Clock: 1940/09/06 01:42:03
Hw clock time : 1940/09/06 01:42:03 = -925251477 seconds since 1969
Fri Sep 6 02:42:03 1940 -0.646109 seconds

Sat Sep 6 03:42:03 CEST 2008

Should I be worried? :)

Signature · 1 line
     2. That which causes joy or happiness.
#1 lore raw

From: Josip Rodin <[email protected]>
Date: Sat, 6 Sep 2008 03:44:32 +0200

Quoted 7 lines

Current sparc-next-2.6 on my Ultra 5 works fine, but the new RTC driver prints the following during boot:

rtc-m48t59 rtc-m48t59.0: rtc core: registered m48t59 as rtc0 rtc-m48t59 rtc-m48t59.0: hctosys: invalid date/time

The system time is okay after boot, though.

It might be related to this bug fix I just added to the sparc-next-2.6 tree:

sparc64: fix wrong m48t59 RTC year

Correctly calculate offset to the year register for Mostek RTC.

---
 arch/sparc64/kernel/time.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
arch/sparc64/kernel/time.c +4 -2
index 209e7d2..226a004 100644
@@ -500,6 +500,7 @@ static struct of_platform_driver bq4802_driver = {
 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;
 
@@ -507,7 +508,7 @@ static unsigned char mostek_read_byte(struct device *dev, u32 ofs)
 	val = readb(regs + ofs);
 
 	/* the year 0 is 1968 */
-	if (ofs = M48T59_YEAR) {
+	if (ofs = pdata->offset + M48T59_YEAR) {
 		val += 0x68;
 		if ((val & 0xf) > 9)
 			val += 6;
@@ -518,10 +519,11 @@ static unsigned char mostek_read_byte(struct device *dev, u32 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;
 
 	regs = (void __iomem *) pdev->resource[0].start;
-	if (ofs = M48T59_YEAR) {
+	if (ofs = pdata->offset + M48T59_YEAR) {
 		if (val < 0x68)
 			val += 0x32;
 		else
Signature · 1 line
1.5.6.5.GIT
#2 lore raw
In reply to Josip Rodin
Quoted 8 lines · David Miller
Quoted 7 lines

Current sparc-next-2.6 on my Ultra 5 works fine, but the new RTC driver prints the following during boot:

rtc-m48t59 rtc-m48t59.0: rtc core: registered m48t59 as rtc0 rtc-m48t59 rtc-m48t59.0: hctosys: invalid date/time

The system time is okay after boot, though.

Quoted 7 lines

It might be related to this bug fix I just added to the sparc-next-2.6 tree:

sparc64: fix wrong m48t59 RTC year

Correctly calculate offset to the year register for Mostek RTC.

Oh yeah, I forgot to report my test of that patch, sorry. Now the kernel said:

rtc-m48t59 rtc-m48t59.0: setting system clock to 1970-09-06 17:38:55 UTC (21490735)

Userland says:

% sudo hwclock --debug; echo; date
hwclock from util-linux-2.12r
Using /dev/rtc interface to clock.
Last drift adjustment done at 1220722547 seconds after 1969
Last calibration done at 1220722547 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
/dev/rtc does not have interrupt functions. Waiting in loop for time from /dev/rtc to change ...got clock tick
Time read from Hardware Clock: 1970/09/08 01:49:11
Hw clock time : 1970/09/08 01:49:11 = 21606551 seconds since 1969
Tue Sep 8 02:49:11 1970 -0.803853 seconds

Mon Sep 8 03:49:10 CEST 2008

Is this now ready for a hwclock --systohc or?

Signature · 1 line
     2. That which causes joy or happiness.
#3 lore raw
In reply to Josip Rodin
Quoted 4 lines · Josip Rodin

% sudo hwclock --debug; echo; date
hwclock from util-linux-2.12r
Using /dev/rtc interface to clock.

I have similar problems with debian etch on sparc32. hwclock only supports /dev/rtc. Upgrading hwclock is problematic because there are 3 different versions (original hwclock, linux-util and linux-util-ng) and they require init.d script changes. Superblock times are also corrupted with bad dates and fails fsck which immediately causes a reboot. Fixing it requires mounting the drive on another system and running fsck to fix the times. This is a real pain because I haven't been able to find a combination that boots both the stock debian etch kernel and sparc-next.

Is there any way to have the the rtc device show up as /dev/rtc?

#4 lore raw
In reply to Josip Rodin
Quoted 15 lines · On Sun, 07 Sep 2008 23:25:13 -0400 Robert Reif <[email protected]> wrote:
Quoted 4 lines · Josip Rodin

% sudo hwclock --debug; echo; date
hwclock from util-linux-2.12r
Using /dev/rtc interface to clock.

I have similar problems with debian etch on sparc32. hwclock only supports /dev/rtc. Upgrading hwclock is problematic because there are 3 different versions (original hwclock, linux-util and linux-util-ng) and they require init.d script changes. Superblock times are also corrupted with bad dates and fails fsck which immediately causes a reboot. Fixing it requires mounting the drive on another system and running fsck to fix the times. This is a real pain because I haven't been able to find a combination that boots both the stock debian etch kernel and sparc-next.

Quoted 2 lines

Is there any way to have the the rtc device show up as /dev/rtc?

There are few things which can improve your situation:

1. Rebuild the kernel with CONFIG_RTC_HCTOSYS option set. It is named "Set system time from RTC on startup and resume" This make system use the rtc0 (you can set it up in configuration as well) to get initial time and date.

2. Add "ln -s /dev/rtc0 /dev/rtc" to your booting scripts before the hwclock (or ntp) is used for the first time.

3. Define udev rule (if you use udev) to create /dev/rtc link to the /dev/rtc0.

Regards,
Krzysztof

#5 lore raw
In reply to Josip Rodin

From: Krzysztof Helt <[email protected]>
Date: Mon, 8 Sep 2008 17:13:13 +0200

Quoted 7 lines

There are few things which can improve your situation:

1. Rebuild the kernel with CONFIG_RTC_HCTOSYS option set. It is named "Set system time from RTC on startup and resume" This make system use the rtc0 (you can set it up in configuration as well) to get initial time and date.

Quoted 5 lines

2. Add "ln -s /dev/rtc0 /dev/rtc" to your booting scripts before the hwclock (or ntp) is used for the first time.

3. Define udev rule (if you use udev) to create /dev/rtc link to the /dev/rtc0.

These all work, but I really think there should be at least a kernel config controlled way for an automatic alias to show up.

Even something as simple as just creating a /sys/class/misc/rtc/dev file that outputs the major and minor device numbers of /dev/rtc0, udev would just "do the right thing" and create that alias /dev/rtc node for the user.

This whole /dev/rtc0 business is just unnecessary pain, it makes transition of a platform to the RTC subsystem harder rather than easier.