2001-04-18 19:14:13

by Grant Erickson

[permalink] [raw]
Subject: Kernel Real Time Clock (RTC) Support for I2C Devices

I have been unable to find an answer for this in the LKML archives, so I
am hoping someone on this list might perhaps have some insight or pointers
thereto on this question.

I have an embedded board with a PowerPC 405GP on which Linux 2.4.2
(MontaVista's version thereof) is running swimmingly. Attached to that
PowerPC's I2C controller is a Dallas DS1307 I2C RTC.

>From the looks of drivers/char/rtc.c it would appear that this kernel
driver only supports bus-attached RTCs such as the mentioned MC146818. Is
this correct?

What is the correct access method / kernel tie-in for supporting such an
I2C-based RTC device using the "standard" interfaces?

My hope is to use 'hwclock' from util-linux w/o modification. Is this
reasonable?

Thanks,

Grant Erickson


--
Grant Erickson University of Minnesota Alumni
o mail:[email protected] 1996 BSEE
o http://www.umn.edu/~erick205 1998 MSEE



2001-04-18 19:36:19

by Gabriel Paubert

[permalink] [raw]
Subject: Re: Kernel Real Time Clock (RTC) Support for I2C Devices



On Wed, 18 Apr 2001, Grant Erickson wrote:

> >From the looks of drivers/char/rtc.c it would appear that this kernel
> driver only supports bus-attached RTCs such as the mentioned MC146818. Is
> this correct?

I think so.

>
> What is the correct access method / kernel tie-in for supporting such an
> I2C-based RTC device using the "standard" interfaces?

Adding a new kind of clock to the kernel and setting the correct pointers
in ppc_md seems the right (if not necessarily simple) solution to your
problem.

I wonder how you calibrate the decrementer frequency on this machine, I2C
is too slow to get any precision, unless you accept to wait for one minute
or so at boot. I still have problems of reproducibility of clock frequency
measurements with bus attached RTC (on machines on which the RTC is the
only moderately precise timing source and its interrupt line is
unfortunately not connected).

>
> My hope is to use 'hwclock' from util-linux w/o modification. Is this
> reasonable?

No.

Regards,
Gabriel.

2001-04-18 19:40:50

by Wolfgang Denk

[permalink] [raw]
Subject: Re: Kernel Real Time Clock (RTC) Support for I2C Devices

Dear Grant,

in message <[email protected]> you wrote:
>
> >From the looks of drivers/char/rtc.c it would appear that this kernel
> driver only supports bus-attached RTCs such as the mentioned MC146818. Is
> this correct?

This is correct; however, you can replace this driver by one of your
own (see for instance drivers/char/ip860_rtc.c in our version of the
2.4.x Linux sources which implements the RTC driver for a V3021 RTC
on a IP860 VMEBus system [MPC860 based]).

Right now I'm writing another driver for the Philips PCF8563 RTC,
which is much closer to what you have in mind.

> What is the correct access method / kernel tie-in for supporting such an
> I2C-based RTC device using the "standard" interfaces?

Assuming you have a working I2C driver, just add the necessary "glue"
code to provide the same interface as that of drivers/char/rtc.c .

> My hope is to use 'hwclock' from util-linux w/o modification. Is this
> reasonable?

Yes, this will work (it does for me on the MPC8xx).

Hope this helps,

Wolfgang Denk

--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: [email protected]
The universe does not have laws - it has habits, and habits can be
broken.

2001-04-19 11:31:22

by Johan Adolfsson

[permalink] [raw]
Subject: Re: Kernel Real Time Clock (RTC) Support for I2C Devices

Support for DS1302 is available in the CRIS port.
A patch for 2.4.3 (and a lot of other stuff you don't need) is available in
http://developer.axis.com/download/devboard_lx/R1_0_0/

/Johan

----- Original Message -----
From: Grant Erickson <[email protected]>
To: Linux I2C Mailing List <[email protected]>; Linux/PPC
Embedded Mailing List <[email protected]>; Linux Kernel
Mailing List <[email protected]>
Sent: Wednesday, April 18, 2001 9:13 PM
Subject: Kernel Real Time Clock (RTC) Support for I2C Devices


> I have been unable to find an answer for this in the LKML archives, so I
> am hoping someone on this list might perhaps have some insight or pointers
> thereto on this question.
>
> I have an embedded board with a PowerPC 405GP on which Linux 2.4.2
> (MontaVista's version thereof) is running swimmingly. Attached to that
> PowerPC's I2C controller is a Dallas DS1307 I2C RTC.
>
> >From the looks of drivers/char/rtc.c it would appear that this kernel
> driver only supports bus-attached RTCs such as the mentioned MC146818. Is
> this correct?
>
> What is the correct access method / kernel tie-in for supporting such an
> I2C-based RTC device using the "standard" interfaces?
>
> My hope is to use 'hwclock' from util-linux w/o modification. Is this
> reasonable?
>
> Thanks,
>
> Grant Erickson
>
>
> --
> Grant Erickson University of Minnesota Alumni
> o mail:[email protected] 1996 BSEE
> o http://www.umn.edu/~erick205 1998 MSEE
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>