linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* 860 rtc problem
@ 2002-10-17  2:19 leeyang
  2002-10-17 14:24 ` Hollis Blanchard
  2002-10-17 16:02 ` Alex Zeffertt
  0 siblings, 2 replies; 15+ messages in thread
From: leeyang @ 2002-10-17  2:19 UTC (permalink / raw)
  To: linuxppc-embedded


Hi, all!
HW:860T custom board
SW:devel kernel 2.4.20-pre7 nfs mount on eldk

Problem:Can not adjust time in linux shell(with 'date -s' command)

RTC really runs when I use 'date' it says sometime around 1970's
and it runs when power up.
With 'date -s' command it returned time had been changed.
However after a reset,the time go back to 1970's again :-(

I try with 'hwclock' and it says below:

bash-2.04# hwclock --debug
hwclock 2.4c/util-linux-2.11f
Using /dev/rtc interface to clock.
Last drift adjustment done at 0 seconds after 1969
Last calibration done at 0 seconds after 1969
Hardware clock is on unknown 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
...got clock tick
Time read from Hardware Clock: 1970/01/09 21:28:28
Hw clock time : 1970/01/09 21:28:28 = 786508 seconds since 1969
Fri Jan  9 21:28:28 1970  -0.188839 seconds


I guess it never really write value to RTC reg!!!
Hope help!

ps:I open /dev/rtc option in the kernel.

Regards!


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17  2:19 860 rtc problem leeyang
@ 2002-10-17 14:24 ` Hollis Blanchard
  2002-10-17 15:42   ` Wolfgang Denk
  2002-10-17 16:02 ` Alex Zeffertt
  1 sibling, 1 reply; 15+ messages in thread
From: Hollis Blanchard @ 2002-10-17 14:24 UTC (permalink / raw)
  To: leeyang; +Cc: linuxppc-embedded


On Wed, 2002-10-16 at 21:19, leeyang wrote:
>
> With 'date -s' command it returned time had been changed.
> However after a reset,the time go back to 1970's again :-(
>
> I try with 'hwclock' and it says below:
>
> bash-2.04# hwclock --debug
> hwclock 2.4c/util-linux-2.11f
> Using /dev/rtc interface to clock.
> Last drift adjustment done at 0 seconds after 1969
> Last calibration done at 0 seconds after 1969
> Hardware clock is on unknown 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
> ...got clock tick
> Time read from Hardware Clock: 1970/01/09 21:28:28
> Hw clock time : 1970/01/09 21:28:28 = 786508 seconds since 1969
> Fri Jan  9 21:28:28 1970  -0.188839 seconds

`hwclock` with no arguments seems to be the same as `hwclock --show`. I
would recommend `hwclock -w`.

-Hollis

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17 14:24 ` Hollis Blanchard
@ 2002-10-17 15:42   ` Wolfgang Denk
  0 siblings, 0 replies; 15+ messages in thread
From: Wolfgang Denk @ 2002-10-17 15:42 UTC (permalink / raw)
  To: Hollis Blanchard; +Cc: leeyang, linuxppc-embedded


In message <1034864663.8254.19.camel@granite.austin.ibm.com> you wrote:
>
> > With 'date -s' command it returned time had been changed.
> > However after a reset,the time go back to 1970's again :-(
...
> `hwclock` with no arguments seems to be the same as `hwclock --show`. I
> would recommend `hwclock -w`.

hwclock expects a standard /dev/rtc interface, which is not available
for the MPC8xx in some versions of the Linux kernel.

If you're  looking  for  an  implementation,  check  out  our  kernel
sources. It includes a MPC8xx RTC driver.

Best regards,

Wolfgang Denk

--
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-4596-87  Fax: (+49)-8142-4596-88  Email: wd@denx.de
How many seconds are there in a year? If I tell you there are 3.155 x
10^7, you won't even try to remember it. On the other hand, who could
forget that, to within half a percent, pi seconds is  a  nanocentury.
                                               -- Tom Duff, Bell Labs

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17  2:19 860 rtc problem leeyang
  2002-10-17 14:24 ` Hollis Blanchard
@ 2002-10-17 16:02 ` Alex Zeffertt
  2002-10-17 16:13   ` Tom Rini
  1 sibling, 1 reply; 15+ messages in thread
From: Alex Zeffertt @ 2002-10-17 16:02 UTC (permalink / raw)
  To: leeyang; +Cc: linuxppc-embedded

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1980 bytes --]

On Thu, 17 Oct 2002, leeyang wrote:

Hi,

I've written a rtc driver for the mpc860.  See attached files.

HOWTO BUILD

1.	Edit KERNEL_DIR in Makefile
2.	make   (builds rtc.o and rtc)

HOWTO USE

root@860# insmod rtc.o
root@860# mknod /dev/rtc c 10 135
root@860# rtc                        # (help text)

root@860# rtc r                      # (read RTC)

root@860# rtc w [opts]               # (write to RTC)


NOTES

1.	date and "date -s" only set a software clock ("xtime")
2.	the software clock is initialised from a h/w RTC at boot
3.	to make a date change persistent across reboots make sure you set
	the RTC using rtc.
4.	"rtc w" without further opts will set the RTC to equal the
	software clock ("xtime")
5.	Make sure your 860 has a 32k RTC xtal oscilator, and Keep Alive
	PoWeR seperate from the main supply and XIN.

Alex

>
> Hi, all!
> HW:860T custom board
> SW:devel kernel 2.4.20-pre7 nfs mount on eldk
>
> Problem:Can not adjust time in linux shell(with 'date -s' command)
>
> RTC really runs when I use 'date' it says sometime around 1970's
> and it runs when power up.
> With 'date -s' command it returned time had been changed.
> However after a reset,the time go back to 1970's again :-(
>
> I try with 'hwclock' and it says below:
>
> bash-2.04# hwclock --debug
> hwclock 2.4c/util-linux-2.11f
> Using /dev/rtc interface to clock.
> Last drift adjustment done at 0 seconds after 1969
> Last calibration done at 0 seconds after 1969
> Hardware clock is on unknown 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
> ...got clock tick
> Time read from Hardware Clock: 1970/01/09 21:28:28
> Hw clock time : 1970/01/09 21:28:28 = 786508 seconds since 1969
> Fri Jan  9 21:28:28 1970  -0.188839 seconds
>
>
> I guess it never really write value to RTC reg!!!
> Hope help!
>
> ps:I open /dev/rtc option in the kernel.
>
> Regards!
>
>
>

[-- Attachment #2: Makefile --]
[-- Type: TEXT/PLAIN, Size: 931 bytes --]

##########################################################################
#
#            Copyright (C) 2001 Cambridge Broadband Ltd,
#                    Edinburgh House, Cowley Road
#                        Cambridge, England
#                              CB4 0DS
#
#                         ++44 1223 713000
#
#                   enquiries@cambridgebroadband.com
#
#                   http://www.cambridgebroadband.com                    
#
##########################################################################

CC = ppc_8xx-gcc
KERNELDIR = ../../kernel
DEBUG = -g
NODEBUG =
KERN_CFLAGS = -DMODULE -D__KERNEL__ -I$(KERNELDIR)/include -O2 -Wall $(NODEBUG)
USER_CFLAGS = -DUSERLAND_TESTCODE -I$(KERNELDIR)/include -O2 -Wall $(NODEBUG)
TARGETS = rtc.o rtc


all: $(TARGETS)

rtc.o: rtc.c
	$(CC) $(KERN_CFLAGS) -c rtc.c

rtc: rtc.c
	$(CC) $(USER_CFLAGS) -o $@ rtc.c

clean:
	rm -f $(TARGETS)

[-- Attachment #3: rtc.c --]
[-- Type: APPLICATION/OCTET-STREAM, Size: 7952 bytes --]

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

* Re: 860 rtc problem
  2002-10-17 16:02 ` Alex Zeffertt
@ 2002-10-17 16:13   ` Tom Rini
  2002-10-17 16:18     ` Alex Zeffertt
  2002-10-18  8:33     ` 860 rtc problem(sloved!!) leeyang
  0 siblings, 2 replies; 15+ messages in thread
From: Tom Rini @ 2002-10-17 16:13 UTC (permalink / raw)
  To: Alex Zeffertt; +Cc: leeyang, linuxppc-embedded


On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> On Thu, 17 Oct 2002, leeyang wrote:
>
> Hi,
>
> I've written a rtc driver for the mpc860.  See attached files.
>
> HOWTO BUILD
>
> 1.	Edit KERNEL_DIR in Makefile
> 2.	make   (builds rtc.o and rtc)

This appears to be a binary file.  And the easiest way to do this is to
make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions which
do what their name implies.  Then enable CONFIG_PPC_RTC

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
       [not found] <200210171510.g9HFAKX11154@hofr.at>
@ 2002-10-17 16:14 ` Alex Zeffertt
  0 siblings, 0 replies; 15+ messages in thread
From: Alex Zeffertt @ 2002-10-17 16:14 UTC (permalink / raw)
  To: Der Herr Hofrat; +Cc: linuxppc-embedded

[-- Attachment #1: Type: TEXT/PLAIN, Size: 338 bytes --]

On Thu, 17 Oct 2002, Der Herr Hofrat wrote:


> > On Thu, 17 Oct 2002, leeyang wrote:
> >
> > Hi,
> >
> > I've written a rtc driver for the mpc860.  See attached files.
>
> you seem to have atached the object file not the source file - could
> you resend ?
>

Yes, sorry everyone!  See attached.

Alex

> thx !
> hofrat
>

Hope it helps.

[-- Attachment #2: rtc.c --]
[-- Type: TEXT/PLAIN, Size: 6537 bytes --]

/*
 * Linux/PowerPC Real Time Clock Driver
 *
 * heavily based on:
 * Linux/SPARC Real Time Clock Driver
 * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
 *
 * This is a little driver that lets a user-level program access
 * the PPC clocks chip. It is no use unless you
 * use the modified clock utility.
 *
 * Get the modified clock utility from:
 *   ftp://vger.rutgers.edu/pub/linux/Sparc/userland/clock.c
 */

#ifndef USERLAND_TESTCODE
#include <linux/module.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
#include <linux/slab.h>
#include <linux/fcntl.h>
#include <linux/poll.h>
#include <linux/init.h>
#include <linux/mc146818rtc.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <asm/machdep.h>

#include <asm/time.h>

static int rtc_busy = 0;

/* Retrieve the current date and time from the real time clock. */
void get_rtc_time(struct rtc_time *t)
{
	unsigned long nowtime;
    
	nowtime = (ppc_md.get_rtc_time)();

	to_tm(nowtime, t);

	t->tm_year -= 1900;
	t->tm_mon -= 1;
	t->tm_wday -= 1;
}

/* Set the current date and time in the real time clock. */
void set_rtc_time(struct rtc_time *t)
{
	unsigned long nowtime;

	printk(KERN_INFO "rtc.c:set_rtc_time: %04d-%02d-%02d %02d:%02d:%02d.\n", t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);

	nowtime = mktime(t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);

	printk(KERN_INFO "rtc.c:set_rtc_time: set rtc time to %ld seconds.\n", nowtime);

	(ppc_md.set_rtc_time)(nowtime);
}

static loff_t rtc_lseek(struct file *file, loff_t offset, int origin)
{
	return -ESPIPE;
}

static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
	unsigned long arg)
{
	struct rtc_time rtc_tm;

	switch (cmd)
	{
	case RTC_RD_TIME:
		if (ppc_md.get_rtc_time)
		{
			get_rtc_time(&rtc_tm);

			if (copy_to_user((struct rtc_time*)arg, &rtc_tm, sizeof(struct rtc_time)))
				return -EFAULT;

			return 0;
		}
		else
			return -EINVAL;

	case RTC_SET_TIME:
		if (!capable(CAP_SYS_TIME))
			return -EPERM;

		if (ppc_md.set_rtc_time)
		{
			if (copy_from_user(&rtc_tm, (struct rtc_time*)arg, sizeof(struct rtc_time)))
				return -EFAULT;

			set_rtc_time(&rtc_tm);

			return 0;
		}
		else
			return -EINVAL;

	default:
		return -EINVAL;
	}
}

static int rtc_open(struct inode *inode, struct file *file)
{
	if (rtc_busy)
		return -EBUSY;

	rtc_busy = 1;

	MOD_INC_USE_COUNT;

	return 0;
}

static int rtc_release(struct inode *inode, struct file *file)
{
	MOD_DEC_USE_COUNT;
	rtc_busy = 0;
	return 0;
}

static struct file_operations rtc_fops = {
	owner:		THIS_MODULE,
	llseek:		rtc_lseek,
	ioctl:		rtc_ioctl,
	open:		rtc_open,
	release:	rtc_release
};

static struct miscdevice rtc_dev = { RTC_MINOR, "rtc", &rtc_fops };

EXPORT_NO_SYMBOLS;

static int __init rtc_init(void)
{
	int error;

	error = misc_register(&rtc_dev);
	if (error) {
		printk(KERN_ERR "rtc: unable to get misc minor\n");
		return error;
	}

	return 0;
}

static void __exit rtc_exit(void)
{
	misc_deregister(&rtc_dev);
}

module_init(rtc_init);
module_exit(rtc_exit);

#else /* ifndef USERLAND_TESTCODE */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <asm/ioctls.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <time.h>
#include <linux/rtc.h>			/* get the user-level API */

static char * days[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"};
static char * months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
static void print_time(struct rtc_time * t)
{
    printf("%s %s %d %02d:%02d:%02d (DST=%s) %d\n",
           days[t->tm_wday],
           months[t->tm_mon],
           t->tm_mday,
           t->tm_hour,t->tm_min,t->tm_sec,
           (t->tm_isdst)?"On":"Off",
           t->tm_year+1900);
}

int main (int argc, char **argv)
{
    int s; 
    struct rtc_time rtctime;

    s = open("/dev/rtc", O_RDWR);

    if (argc < 2)
        goto usage;
    
    if (strcmp(argv[1],"r") == 0)
    {
        if(ioctl(s, RTC_RD_TIME, &rtctime))
            perror("ioctl");
        else
            print_time(&rtctime);
    }
    else if (strcmp(argv[1],"w") == 0)
    {
        if (argc == 2) {
            time_t t = time(NULL);
            struct tm *systime = localtime(&t);
            rtctime.tm_sec = systime->tm_sec;
            rtctime.tm_min = systime->tm_min;
            rtctime.tm_hour = systime->tm_hour;
            rtctime.tm_mday = systime->tm_mday;
            rtctime.tm_mon = systime->tm_mon;
            rtctime.tm_year = systime->tm_year;
            rtctime.tm_wday = systime->tm_wday;
            rtctime.tm_yday = 0; /* unused by mpc8xx */
            rtctime.tm_isdst = systime->tm_isdst;
        } else {
            if (argc < 10)
                goto usage;
            if (sscanf(argv[2],"%d", &rtctime.tm_sec) != 1)
                goto usage;
            if (sscanf(argv[3],"%d", &rtctime.tm_min) != 1)
                goto usage;
            if (sscanf(argv[4],"%d", &rtctime.tm_hour) != 1)
                goto usage;
            if (sscanf(argv[5],"%d", &rtctime.tm_mday) != 1)
                goto usage;
            if (sscanf(argv[6],"%d", &rtctime.tm_mon) != 1)
                goto usage;
            if (sscanf(argv[7],"%d", &rtctime.tm_year) != 1)
                goto usage;
            if (sscanf(argv[8],"%d", &rtctime.tm_wday) != 1)
                goto usage;
            rtctime.tm_yday = 0; /* unused by mpc8xx */
            if (sscanf(argv[9],"%d", &rtctime.tm_isdst) != 1)
                goto usage;
        }
        if(ioctl(s, RTC_SET_TIME, &rtctime))
            perror("ioctl");
    }
    else
        goto usage;

    close(s);        
    return 0;

 usage:
    close(s);
    printf("i)   %s r\n"
           "ii)  %s w\n"
           "iii) %s w sec min hour mday mon year wday isdst\n"
           "Notes:\n"
           "\t(i)   reads time from RTC.\n"
           "\t(ii)  writes current system time to RTC.\n"
           "\t(iii) writes remaining params to RTC.\n"
           "\t(All parameters are decimal integers\n"
           "\tSee man mktime for parameter ranges)\n", argv[0],argv[0],argv[0]);
    return -1;
}

#endif /* USERLAND_TESTCODE */

[-- Attachment #3: Makefile --]
[-- Type: TEXT/PLAIN, Size: 931 bytes --]

##########################################################################
#
#            Copyright (C) 2001 Cambridge Broadband Ltd,
#                    Edinburgh House, Cowley Road
#                        Cambridge, England
#                              CB4 0DS
#
#                         ++44 1223 713000
#
#                   enquiries@cambridgebroadband.com
#
#                   http://www.cambridgebroadband.com                    
#
##########################################################################

CC = ppc_8xx-gcc
KERNELDIR = ../../kernel
DEBUG = -g
NODEBUG =
KERN_CFLAGS = -DMODULE -D__KERNEL__ -I$(KERNELDIR)/include -O2 -Wall $(NODEBUG)
USER_CFLAGS = -DUSERLAND_TESTCODE -I$(KERNELDIR)/include -O2 -Wall $(NODEBUG)
TARGETS = rtc.o rtc


all: $(TARGETS)

rtc.o: rtc.c
	$(CC) $(KERN_CFLAGS) -c rtc.c

rtc: rtc.c
	$(CC) $(USER_CFLAGS) -o $@ rtc.c

clean:
	rm -f $(TARGETS)

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

* Re: 860 rtc problem
  2002-10-17 16:13   ` Tom Rini
@ 2002-10-17 16:18     ` Alex Zeffertt
  2002-10-17 16:23       ` Tom Rini
  2002-10-18  8:33     ` 860 rtc problem(sloved!!) leeyang
  1 sibling, 1 reply; 15+ messages in thread
From: Alex Zeffertt @ 2002-10-17 16:18 UTC (permalink / raw)
  To: Tom Rini; +Cc: leeyang, linuxppc-embedded


On Thu, 17 Oct 2002, Tom Rini wrote:

> On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> > On Thu, 17 Oct 2002, leeyang wrote:
> >
> > Hi,
> >
> > I've written a rtc driver for the mpc860.  See attached files.
> >
> > HOWTO BUILD
> >
> > 1.	Edit KERNEL_DIR in Makefile
> > 2.	make   (builds rtc.o and rtc)
>
> This appears to be a binary file.  And the easiest way to do this is to
> make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions which
> do what their name implies.  Then enable CONFIG_PPC_RTC
>
>


You're right.  This is actually what the module I have sent you does!
The reason I wrote the module was merely to provide a way for userland
programs to set the RTC.

Alex


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17 16:18     ` Alex Zeffertt
@ 2002-10-17 16:23       ` Tom Rini
  2002-10-17 16:34         ` Marius Groeger
  2002-10-17 16:36         ` Alex Zeffertt
  0 siblings, 2 replies; 15+ messages in thread
From: Tom Rini @ 2002-10-17 16:23 UTC (permalink / raw)
  To: Alex Zeffertt; +Cc: leeyang, linuxppc-embedded


On Thu, Oct 17, 2002 at 05:18:21PM +0100, Alex Zeffertt wrote:
> On Thu, 17 Oct 2002, Tom Rini wrote:
>
> > On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> > > On Thu, 17 Oct 2002, leeyang wrote:
> > >
> > > Hi,
> > >
> > > I've written a rtc driver for the mpc860.  See attached files.
> > >
> > > HOWTO BUILD
> > >
> > > 1.	Edit KERNEL_DIR in Makefile
> > > 2.	make   (builds rtc.o and rtc)
> >
> > This appears to be a binary file.  And the easiest way to do this is to
> > make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions which
> > do what their name implies.  Then enable CONFIG_PPC_RTC
>
> You're right.  This is actually what the module I have sent you does!
> The reason I wrote the module was merely to provide a way for userland
> programs to set the RTC.

Er, okay.  But why not just modify
m8xx_setup.c::m8xx_get_rtc_time/m8xx_set_rtc_time to allow for the
get/set routines there to be overriden ? Doing that would be nice and
clean, and also allow the 'new' genrtc driver in 2.5 to just work as
well.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17 16:23       ` Tom Rini
@ 2002-10-17 16:34         ` Marius Groeger
  2002-10-17 16:38           ` Tom Rini
  2002-10-17 16:41           ` Alex Zeffertt
  2002-10-17 16:36         ` Alex Zeffertt
  1 sibling, 2 replies; 15+ messages in thread
From: Marius Groeger @ 2002-10-17 16:34 UTC (permalink / raw)
  To: Tom Rini; +Cc: Alex Zeffertt, leeyang, linuxppc-embedded


On Thu, 17 Oct 2002, Tom Rini wrote:

> On Thu, Oct 17, 2002 at 05:18:21PM +0100, Alex Zeffertt wrote:
> > On Thu, 17 Oct 2002, Tom Rini wrote:
> >
> > > On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> > > > On Thu, 17 Oct 2002, leeyang wrote:
> > > >
> > > > Hi,
> > > >
> > > > I've written a rtc driver for the mpc860.  See attached files.
> > > >
> > > > HOWTO BUILD
> > > >
> > > > 1.	Edit KERNEL_DIR in Makefile
> > > > 2.	make   (builds rtc.o and rtc)
> > >
> > > This appears to be a binary file.  And the easiest way to do this is to
> > > make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions which
> > > do what their name implies.  Then enable CONFIG_PPC_RTC
> >
> > You're right.  This is actually what the module I have sent you does!
> > The reason I wrote the module was merely to provide a way for userland
> > programs to set the RTC.
>
> Er, okay.  But why not just modify
> m8xx_setup.c::m8xx_get_rtc_time/m8xx_set_rtc_time to allow for the
> get/set routines there to be overriden ? Doing that would be nice and
> clean, and also allow the 'new' genrtc driver in 2.5 to just work as
> well.

Probably a little late, but: see also drivers/macintosh/rtc.c which is
a perfectly generic rtc driver at a perfectly non-generic location.
Don't mix this up with drivers/char/rtc.c, which is the other way
round. Shudder.

Regards,
Marius

-----------------------------------------------------------------------------
Marius Groeger           SYSGO Real-Time Solutions AG       mgroeger@sysgo.de
Software Engineering     Embedded and Real-Time Software    www.sysgo.de
Voice: +49-6136-9948-0   Am Pfaffenstein 14                 www.osek.de
FAX:   +49-6136-9948-10  55270 Klein-Winternheim, Germany   www.elinos.com


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17 16:23       ` Tom Rini
  2002-10-17 16:34         ` Marius Groeger
@ 2002-10-17 16:36         ` Alex Zeffertt
  2002-10-17 17:05           ` Tom Rini
  1 sibling, 1 reply; 15+ messages in thread
From: Alex Zeffertt @ 2002-10-17 16:36 UTC (permalink / raw)
  To: Tom Rini; +Cc: leeyang, linuxppc-embedded


On Thu, 17 Oct 2002, Tom Rini wrote:

>
> On Thu, Oct 17, 2002 at 05:18:21PM +0100, Alex Zeffertt wrote:
> > On Thu, 17 Oct 2002, Tom Rini wrote:
> >
> > > On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> > > > On Thu, 17 Oct 2002, leeyang wrote:
> > > >
> > > > Hi,
> > > >
> > > > I've written a rtc driver for the mpc860.  See attached files.
> > > >
> > > > HOWTO BUILD
> > > >
> > > > 1.	Edit KERNEL_DIR in Makefile
> > > > 2.	make   (builds rtc.o and rtc)
> > >
> > > This appears to be a binary file.  And the easiest way to do this is to
> > > make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions which
> > > do what their name implies.  Then enable CONFIG_PPC_RTC
> >
> > You're right.  This is actually what the module I have sent you does!
> > The reason I wrote the module was merely to provide a way for userland
> > programs to set the RTC.
>
> Er, okay.  But why not just modify
> m8xx_setup.c::m8xx_get_rtc_time/m8xx_set_rtc_time to allow for the
> get/set routines there to be overriden ? Doing that would be nice and
> clean, and also allow the 'new' genrtc driver in 2.5 to just work as
> well.
>

I don't understand.  Why do you need to modify these functions?  They
already work!  All I have done is to create a character driver that calls
them (via their pointers ppc_md.set_rtc_time, and ppc_md.get_rtc_time).

The driver registers itself on the standard rtc major and minor numbers
and supports the standard RTC_RD_TIME/RTC_SET_TIME ioctls.

What is genrtc?  (I'm not using 2.5 yet.)

Alex


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17 16:34         ` Marius Groeger
@ 2002-10-17 16:38           ` Tom Rini
  2002-10-17 16:41           ` Alex Zeffertt
  1 sibling, 0 replies; 15+ messages in thread
From: Tom Rini @ 2002-10-17 16:38 UTC (permalink / raw)
  To: Marius Groeger; +Cc: Alex Zeffertt, leeyang, linuxppc-embedded


On Thu, Oct 17, 2002 at 06:34:56PM +0200, Marius Groeger wrote:
> On Thu, 17 Oct 2002, Tom Rini wrote:
>
> > On Thu, Oct 17, 2002 at 05:18:21PM +0100, Alex Zeffertt wrote:
> > > On Thu, 17 Oct 2002, Tom Rini wrote:
> > >
> > > > On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> > > > > On Thu, 17 Oct 2002, leeyang wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I've written a rtc driver for the mpc860.  See attached files.
> > > > >
> > > > > HOWTO BUILD
> > > > >
> > > > > 1.	Edit KERNEL_DIR in Makefile
> > > > > 2.	make   (builds rtc.o and rtc)
> > > >
> > > > This appears to be a binary file.  And the easiest way to do this is to
> > > > make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions which
> > > > do what their name implies.  Then enable CONFIG_PPC_RTC
> > >
> > > You're right.  This is actually what the module I have sent you does!
> > > The reason I wrote the module was merely to provide a way for userland
> > > programs to set the RTC.
> >
> > Er, okay.  But why not just modify
> > m8xx_setup.c::m8xx_get_rtc_time/m8xx_set_rtc_time to allow for the
> > get/set routines there to be overriden ? Doing that would be nice and
> > clean, and also allow the 'new' genrtc driver in 2.5 to just work as
> > well.
>
> Probably a little late, but: see also drivers/macintosh/rtc.c which is
> a perfectly generic rtc driver at a perfectly non-generic location.
> Don't mix this up with drivers/char/rtc.c, which is the other way
> round. Shudder.

Right.  drivers/macintosh/rtc.c is what makes use of
ppc_md.set/get_rtc_time.  Thankfully in 2.5 there's now
drivers/char/genrtc.c, which is generic and has replaced
drivers/macintosh/rtc.c (and uses the same ppc_md hooks, when the driver
is compiled on PPC).

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17 16:34         ` Marius Groeger
  2002-10-17 16:38           ` Tom Rini
@ 2002-10-17 16:41           ` Alex Zeffertt
  1 sibling, 0 replies; 15+ messages in thread
From: Alex Zeffertt @ 2002-10-17 16:41 UTC (permalink / raw)
  To: Marius Groeger; +Cc: Tom Rini, leeyang, linuxppc-embedded


On Thu, 17 Oct 2002, Marius Groeger wrote:

>
> On Thu, 17 Oct 2002, Tom Rini wrote:
>
> > On Thu, Oct 17, 2002 at 05:18:21PM +0100, Alex Zeffertt wrote:
> > > On Thu, 17 Oct 2002, Tom Rini wrote:
> > >
> > > > On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> > > > > On Thu, 17 Oct 2002, leeyang wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I've written a rtc driver for the mpc860.  See attached files.
> > > > >
> > > > > HOWTO BUILD
> > > > >
> > > > > 1.	Edit KERNEL_DIR in Makefile
> > > > > 2.	make   (builds rtc.o and rtc)
> > > >
> > > > This appears to be a binary file.  And the easiest way to do this is to
> > > > make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions which
> > > > do what their name implies.  Then enable CONFIG_PPC_RTC
> > >
> > > You're right.  This is actually what the module I have sent you does!
> > > The reason I wrote the module was merely to provide a way for userland
> > > programs to set the RTC.
> >
> > Er, okay.  But why not just modify
> > m8xx_setup.c::m8xx_get_rtc_time/m8xx_set_rtc_time to allow for the
> > get/set routines there to be overriden ? Doing that would be nice and
> > clean, and also allow the 'new' genrtc driver in 2.5 to just work as
> > well.
>
> Probably a little late, but: see also drivers/macintosh/rtc.c which is
> a perfectly generic rtc driver at a perfectly non-generic location.
> Don't mix this up with drivers/char/rtc.c, which is the other way
> round. Shudder.

Actually, that's where I got the kernel part of the code I just sent.  :-)
The userland bit I wrote myself.

I've just remembered.  To get this driver to work you have to change a
line in m8xx_setup.c from:

unsigned long __init m8xx_get_rtc_time(void)

to:

unsigned long m8xx_get_rtc_time(void)

Alex


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17 16:36         ` Alex Zeffertt
@ 2002-10-17 17:05           ` Tom Rini
  2002-10-18  1:38             ` leeyang
  0 siblings, 1 reply; 15+ messages in thread
From: Tom Rini @ 2002-10-17 17:05 UTC (permalink / raw)
  To: Alex Zeffertt; +Cc: leeyang, linuxppc-embedded


On Thu, Oct 17, 2002 at 05:36:17PM +0100, Alex Zeffertt wrote:
> On Thu, 17 Oct 2002, Tom Rini wrote:
>
> >
> > On Thu, Oct 17, 2002 at 05:18:21PM +0100, Alex Zeffertt wrote:
> > > On Thu, 17 Oct 2002, Tom Rini wrote:
> > >
> > > > On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> > > > > On Thu, 17 Oct 2002, leeyang wrote:
> > > > >
> > > > > Hi,
> > > > >
> > > > > I've written a rtc driver for the mpc860.  See attached files.
> > > > >
> > > > > HOWTO BUILD
> > > > >
> > > > > 1.	Edit KERNEL_DIR in Makefile
> > > > > 2.	make   (builds rtc.o and rtc)
> > > >
> > > > This appears to be a binary file.  And the easiest way to do this is to
> > > > make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions which
> > > > do what their name implies.  Then enable CONFIG_PPC_RTC
> > >
> > > You're right.  This is actually what the module I have sent you does!
> > > The reason I wrote the module was merely to provide a way for userland
> > > programs to set the RTC.
> >
> > Er, okay.  But why not just modify
> > m8xx_setup.c::m8xx_get_rtc_time/m8xx_set_rtc_time to allow for the
> > get/set routines there to be overriden ? Doing that would be nice and
> > clean, and also allow the 'new' genrtc driver in 2.5 to just work as
> > well.
>
> I don't understand.  Why do you need to modify these functions?  They
> already work!  All I have done is to create a character driver that calls
> them (via their pointers ppc_md.set_rtc_time, and ppc_md.get_rtc_time).
>
> The driver registers itself on the standard rtc major and minor numbers
> and supports the standard RTC_RD_TIME/RTC_SET_TIME ioctls.

I don't understand what you did at all then (and you sent a binary file,
not rtc.c so I can't really see).  drivers/macintosh/rtc.c is already a
'generic' RTC driver for PPC, which already works on 8xx (and has,
officially since maybe 2.4.18 or 2.4.19, and much longer in the PPC
community trees).  So why did you have to write anything, if you used
the m8xx_set_rtc_time / m8xx_get_rtc_time functions in m8xx_setup.c ?

> What is genrtc?  (I'm not using 2.5 yet.)

It's a generic RTC driver, which lets arch specific (which can then be
board-specific) files determine how to exactly access the RTC hw, since
most things like date checking, some ioctls (except for the hw-specific
parts) are all generic.

--
Tom Rini (TR1265)
http://gate.crashing.org/~trini/

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem
  2002-10-17 17:05           ` Tom Rini
@ 2002-10-18  1:38             ` leeyang
  0 siblings, 0 replies; 15+ messages in thread
From: leeyang @ 2002-10-18  1:38 UTC (permalink / raw)
  To: Tom Rini, Alex Zeffertt; +Cc: linuxppc-embedded


I am sure that I have defined the CONFIG_PPC_RTC in the kernel
(General setup--->Support for /dev/rtc).

In order to track whether m8xx_get_rtc_time/m8xx_set_rtc_time
been called in hwclock I and 2 printk in them as following:

/* The RTC on the MPC8xx is an internal register.
 * We want to protect this during power down, so we need to unlock,
 * modify, and re-lock.
 */
static int
m8xx_set_rtc_time(unsigned long time)
{
 printk("enter set rtc\n");
 ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = KAPWR_KEY;
 ((volatile immap_t *)IMAP_ADDR)->im_sit.sit_rtc = time;
 ((volatile immap_t *)IMAP_ADDR)->im_sitk.sitk_rtck = ~KAPWR_KEY;
 return(0);
}

static unsigned long
m8xx_get_rtc_time(void)
{
 /* Get time from the RTC. */
 printk("enter get rtc\n");
 return((unsigned long)(((immap_t *)IMAP_ADDR)->im_sit.sit_rtc));
}

and when booting the kernel and when using hwclock --show
many "enter get rtc" pop up (about 1000),
so I am sure get function is called.

but when call hwclock -s --date 'Oct 18 2002',it hangs serveral
seconds and return no "enter set rtc' msg.

bash-2.04# hwclock -s --date 'Oct 18 9:00 2002' --debug
hwclock 2.4c/util-linux-2.11f
Using /dev/rtc interface to clock.
Last drift adjustment done at 0 seconds after 1969
Last calibration done at 0 seconds after 1969
Hardware clock is on unknown 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/r
tc to change
Timed out waiting for time change.
...got clock tick

So I am not sure the set function works or not?


----- Original Message -----
From: "Tom Rini" <trini@kernel.crashing.org>
To: "Alex Zeffertt" <ajz@cambridgebroadband.com>
Cc: "leeyang" <leeyang@ycig.com>; <linuxppc-embedded@lists.linuxppc.org>
Sent: Friday, October 18, 2002 1:05 AM
Subject: Re: 860 rtc problem


> On Thu, Oct 17, 2002 at 05:36:17PM +0100, Alex Zeffertt wrote:
> > On Thu, 17 Oct 2002, Tom Rini wrote:
> >
> > >
> > > On Thu, Oct 17, 2002 at 05:18:21PM +0100, Alex Zeffertt wrote:
> > > > On Thu, 17 Oct 2002, Tom Rini wrote:
> > > >
> > > > > On Thu, Oct 17, 2002 at 05:02:23PM +0100, Alex Zeffertt wrote:
> > > > > > On Thu, 17 Oct 2002, leeyang wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I've written a rtc driver for the mpc860.  See attached files.
> > > > > >
> > > > > > HOWTO BUILD
> > > > > >
> > > > > > 1. Edit KERNEL_DIR in Makefile
> > > > > > 2. make   (builds rtc.o and rtc)
> > > > >
> > > > > This appears to be a binary file.  And the easiest way to do this
is to
> > > > > make ppc_md.set_rtc_time / ppc_md.get_rtc_time point to functions
which
> > > > > do what their name implies.  Then enable CONFIG_PPC_RTC
> > > >
> > > > You're right.  This is actually what the module I have sent you
does!
> > > > The reason I wrote the module was merely to provide a way for
userland
> > > > programs to set the RTC.
> > >
> > > Er, okay.  But why not just modify
> > > m8xx_setup.c::m8xx_get_rtc_time/m8xx_set_rtc_time to allow for the
> > > get/set routines there to be overriden ? Doing that would be nice and
> > > clean, and also allow the 'new' genrtc driver in 2.5 to just work as
> > > well.
> >
> > I don't understand.  Why do you need to modify these functions?  They
> > already work!  All I have done is to create a character driver that
calls
> > them (via their pointers ppc_md.set_rtc_time, and ppc_md.get_rtc_time).
> >
> > The driver registers itself on the standard rtc major and minor numbers
> > and supports the standard RTC_RD_TIME/RTC_SET_TIME ioctls.
>
> I don't understand what you did at all then (and you sent a binary file,
> not rtc.c so I can't really see).  drivers/macintosh/rtc.c is already a
> 'generic' RTC driver for PPC, which already works on 8xx (and has,
> officially since maybe 2.4.18 or 2.4.19, and much longer in the PPC
> community trees).  So why did you have to write anything, if you used
> the m8xx_set_rtc_time / m8xx_get_rtc_time functions in m8xx_setup.c ?
>
> > What is genrtc?  (I'm not using 2.5 yet.)
>
> It's a generic RTC driver, which lets arch specific (which can then be
> board-specific) files determine how to exactly access the RTC hw, since
> most things like date checking, some ioctls (except for the hw-specific
> parts) are all generic.
>
> --
> Tom Rini (TR1265)
> http://gate.crashing.org/~trini/
>
>


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

* Re: 860 rtc problem(sloved!!)
  2002-10-17 16:13   ` Tom Rini
  2002-10-17 16:18     ` Alex Zeffertt
@ 2002-10-18  8:33     ` leeyang
  1 sibling, 0 replies; 15+ messages in thread
From: leeyang @ 2002-10-18  8:33 UTC (permalink / raw)
  To: Tom Rini, Alex Zeffertt; +Cc: linuxppc-embedded


Thanks for all your replys and it had been sloved!

Very shy to say that I type wrong shell command with hwclock.
I used 'hwclock -s --date 'Oct 19 2002' 'before and it is wrong,
I miss an equation mark!!!
It should be 'hwclock -s --date='Oct 19 2002'.
without that mark hwclock think nothing to write and do nothing
so did not really write rtc.

Thx again to your kind fellows:-)


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

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

end of thread, other threads:[~2002-10-18  8:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-17  2:19 860 rtc problem leeyang
2002-10-17 14:24 ` Hollis Blanchard
2002-10-17 15:42   ` Wolfgang Denk
2002-10-17 16:02 ` Alex Zeffertt
2002-10-17 16:13   ` Tom Rini
2002-10-17 16:18     ` Alex Zeffertt
2002-10-17 16:23       ` Tom Rini
2002-10-17 16:34         ` Marius Groeger
2002-10-17 16:38           ` Tom Rini
2002-10-17 16:41           ` Alex Zeffertt
2002-10-17 16:36         ` Alex Zeffertt
2002-10-17 17:05           ` Tom Rini
2002-10-18  1:38             ` leeyang
2002-10-18  8:33     ` 860 rtc problem(sloved!!) leeyang
     [not found] <200210171510.g9HFAKX11154@hofr.at>
2002-10-17 16:14 ` 860 rtc problem Alex Zeffertt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).