All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: RTC on 2.6.36 for PowerMac 8600
       [not found] <CAKTLLVQTt8aRFb2QpXkUUikTJshnV_ytTWJ778MZ1ACyoD8aOw__43210.997261531$1327806577$gmane$org@mail.gmail.com>
@ 2012-01-29  8:29 ` Andreas Schwab
  2012-01-31 19:31   ` kevin diggs
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2012-01-29  8:29 UTC (permalink / raw)
  To: kevin diggs; +Cc: Linux PPC Development

kevin diggs <diggskevin38@gmail.com> writes:

> [root@PowerMac8600B root]# hwclock --debug
> hwclock from util-linux-2.12pre
> Using /dev/rtc interface to clock.
> Last drift adjustment done at 1317444443 seconds after 1969
> Last calibration done at 1317444443 seconds after 1969
> Hardware clock is on local time
> Assuming hardware clock is kept in local time.
> Waiting for clock tick...
> /dev/rtc does not have interrupt functions. Waiting in loop for time
> from /dev/rtc to change
> RTC_RD_TIME: Invalid argument

Perhaps the RTC was reset due to battery running out?  That would set
the year to 1900, but the kernel RTC interface cannot represent dates
before 1970.  Unfortunately hwclock insists on reading the RTC even when
you just want to write to it, so you cannot fix that with hwclock -w.
When the battery of my iBook has run out I'm using the following to
reset RTC to current time so that it is usable again.

Andreas.

#include <time.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/rtc.h>

int
main (void)
{
  time_t now;
  struct tm gmt;
  struct rtc_time rtc;
  int fd;

  now = time (0);
  gmt = *gmtime (&now);
  rtc.tm_sec = gmt.tm_sec;
  rtc.tm_min = gmt.tm_min;
  rtc.tm_hour = gmt.tm_hour;
  rtc.tm_mday = gmt.tm_mday;
  rtc.tm_mon = gmt.tm_mon;
  rtc.tm_year = gmt.tm_year;
  rtc.tm_wday = gmt.tm_wday;
  rtc.tm_yday = gmt.tm_yday;
  rtc.tm_isdst = gmt.tm_isdst;
  fd = open ("/dev/rtc", O_RDONLY);
  if (fd < 0)
    fd = open ("/dev/rtc0", O_RDONLY);
  if (fd < 0)
    {
      perror ("/dev/rtc");
      return 1;
    }
  if (ioctl (fd, RTC_SET_TIME, &rtc) < 0)
    {
      perror ("RTC_SET_TIME");
      return 1;
    }
  return 0;
}

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RTC on 2.6.36 for PowerMac 8600
  2012-01-29  8:29 ` RTC on 2.6.36 for PowerMac 8600 Andreas Schwab
@ 2012-01-31 19:31   ` kevin diggs
  0 siblings, 0 replies; 4+ messages in thread
From: kevin diggs @ 2012-01-31 19:31 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Linux PPC Development

Hi,

On 1/29/12, Andreas Schwab <schwab@linux-m68k.org> wrote:
> kevin diggs <diggskevin38@gmail.com> writes:
>
>
> Perhaps the RTC was reset due to battery running out?  That would set
> the year to 1900, but the kernel RTC interface cannot represent dates
> before 1970.  Unfortunately hwclock insists on reading the RTC even when
> you just want to write to it, so you cannot fix that with hwclock -w.
> When the battery of my iBook has run out I'm using the following to
> reset RTC to current time so that it is usable again.
>
> Andreas.
>
>
Thanks! I did not know about this problem with the year. This vintage
of mac sets the year to 1956.

Yes, the battery is dead. It is one of those $20 1/3 AA lithium cells.
I can't afford to replace it. I went into the MacOS Classic date
control panel and set the year to 1971 and it worked!

Thanks for the tip. I would have never figured this one out!

kevin
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RTC on 2.6.36 for PowerMac 8600
  2012-01-29  3:08 kevin diggs
@ 2012-01-31  9:06 ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 4+ messages in thread
From: Benjamin Herrenschmidt @ 2012-01-31  9:06 UTC (permalink / raw)
  To: kevin diggs; +Cc: Linux PPC Development

On Sat, 2012-01-28 at 21:08 -0600, kevin diggs wrote:
> Hi,
> 
> What will give me access to the RTC hardware on an old PowerMac 8600?
> I modload rtc-generic. /proc/devices has:

should work with rtc generic, not sure what's up.

You can check with printk ... rtc_generic should call into get_rtc_time
which should go via ppc_md. into some powermac specific variants,
themselves calling into the cuda driver.

Cheers,
Ben.

> 254 rtc
> 
> and ls -l /dev/rtc*:
> 
> crw-r--r--  2 root root 254,   0 Sep  2  2010 /dev/rtc
> crw-r--r--  2 root root 254,   0 Sep  2  2010 /dev/rtc0
> crw-r--r--  1 root root  10, 135 Aug 10  2004 /dev/rtc.old
> 
> Trying to run hwclock gives:
> 
> [root@PowerMac8600B root]# hwclock --debug
> hwclock from util-linux-2.12pre
> Using /dev/rtc interface to clock.
> Last drift adjustment done at 1317444443 seconds after 1969
> Last calibration done at 1317444443 seconds after 1969
> Hardware clock is on local time
> Assuming hardware clock is kept in local time.
> Waiting for clock tick...
> /dev/rtc does not have interrupt functions. Waiting in loop for time
> from /dev/rtc to change
> RTC_RD_TIME: Invalid argument
> ioctl() to /dev/rtc to read the time failed.
> 
> I could have sworn this used to work on this system???
> 
> What am I forgetting?
> 
> gzip -dc /proc/config.gz|grep -i rtc lists:
> 
> CONFIG_RTC_LIB=m
> CONFIG_RTC_CLASS=m
> # RTC interfaces
> CONFIG_RTC_INTF_SYSFS=y
> CONFIG_RTC_INTF_PROC=y
> CONFIG_RTC_INTF_DEV=y
> # Platform RTC drivers
> CONFIG_RTC_DRV_CMOS=m
> # on-CPU RTC drivers
> CONFIG_RTC_DRV_GENERIC=m
> 
> Thanks!
> 
> kevin
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RTC on 2.6.36 for PowerMac 8600
@ 2012-01-29  3:08 kevin diggs
  2012-01-31  9:06 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 4+ messages in thread
From: kevin diggs @ 2012-01-29  3:08 UTC (permalink / raw)
  To: Linux PPC Development

Hi,

What will give me access to the RTC hardware on an old PowerMac 8600?
I modload rtc-generic. /proc/devices has:

254 rtc

and ls -l /dev/rtc*:

crw-r--r--  2 root root 254,   0 Sep  2  2010 /dev/rtc
crw-r--r--  2 root root 254,   0 Sep  2  2010 /dev/rtc0
crw-r--r--  1 root root  10, 135 Aug 10  2004 /dev/rtc.old

Trying to run hwclock gives:

[root@PowerMac8600B root]# hwclock --debug
hwclock from util-linux-2.12pre
Using /dev/rtc interface to clock.
Last drift adjustment done at 1317444443 seconds after 1969
Last calibration done at 1317444443 seconds after 1969
Hardware clock is on local time
Assuming hardware clock is kept in local time.
Waiting for clock tick...
/dev/rtc does not have interrupt functions. Waiting in loop for time
from /dev/rtc to change
RTC_RD_TIME: Invalid argument
ioctl() to /dev/rtc to read the time failed.

I could have sworn this used to work on this system???

What am I forgetting?

gzip -dc /proc/config.gz|grep -i rtc lists:

CONFIG_RTC_LIB=m
CONFIG_RTC_CLASS=m
# RTC interfaces
CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_INTF_PROC=y
CONFIG_RTC_INTF_DEV=y
# Platform RTC drivers
CONFIG_RTC_DRV_CMOS=m
# on-CPU RTC drivers
CONFIG_RTC_DRV_GENERIC=m

Thanks!

kevin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-31 19:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAKTLLVQTt8aRFb2QpXkUUikTJshnV_ytTWJ778MZ1ACyoD8aOw__43210.997261531$1327806577$gmane$org@mail.gmail.com>
2012-01-29  8:29 ` RTC on 2.6.36 for PowerMac 8600 Andreas Schwab
2012-01-31 19:31   ` kevin diggs
2012-01-29  3:08 kevin diggs
2012-01-31  9:06 ` Benjamin Herrenschmidt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.