linux-mips
[Top] [All Lists]

[RFC] generic MIPS RTC driver

To: linux-mips@oss.sgi.com
Subject: [RFC] generic MIPS RTC driver
From: Jun Sun <jsun@mvista.com>
Date: Sat, 10 Nov 2001 23:17:46 -0800
Sender: owner-linux-mips@oss.sgi.com
User-agent: Mutt/1.2.5i
For many MIPS boards that start to use CONFIG_NEW_TIME_C, two rtc operations
are implemented, rtc_get_time() and rtc_set_time().

It is possible to write a simple generic RTC driver that is based on
these two ops and can do simple RTC read&write ops.  

In other words, with such a driver, once you implemented rtc_get_time() 
and rtc_set_time(), which is required by the kernel anyway, you will 
automatically get a free /dev/rtc/ driver.

This is the idea behind the generic MIPS rtc driver.  See the patch below.

Right now the feature is rather limited, due to the thin abstraction
we are having with rtc ops.  But apparently the implementation is good
enough to make hwclock program happy.

Any comments?

Jun

/*
 *      A simple generic Real Time Clock interface for Linux/MIPS
 *
 *      Copyright (C) 1996 Paul Gortmaker
 *
 *      Copyright (C) 2001 Monta Vista Software
 *      Author Jun Sun, jsun@mvista.com or jsun@junsun.net
 *
 *      This is a simple generic RTC driver for MIPS boards configured 
 *      with CONFIG_NEW_TIME_C.  For now, it makes use of the two
 *      abstract kernel RTC functions introduced in include/asm-mips/time.h:
 *
 *              extern unsigned long (*rtc_get_time)(void);
 *              extern int (*rtc_set_time)(unsigned long);
 *
 *      It uses the same protocol as the original drivers/char/rtc.c driver,
 *      but only implements two ioctls: RTC_RD_TIME and RTC_SET_TIME.
 *
 *      TODO :
 *
 *      1. we can extend the null rtc ops defined in arch/mips/time.c to
 *         at least record the elapsed time (by recording/checking jiffies)
 *         This way RTC_RD_TIME and RTC_SET_TIME will make more sense.
 *         (Maybe not.  A machine without a real RTC is broken anymore.
 *         Just a thought.)
 *
 *      2. If we make use of timer bh, we can emulate many RTC functions
 *         such as RTC alarm interrupt, periodic interrupts, etc.
 *
 *      3. It is possible to extend the kernel RTC abstractions to more
 *         than two functions, so that perhaps we can implement more
 *         full-featured RTC driver and also have a better abstraction
 *         to support more RTC hardware than the original RTC driver.
 *         It needs to be done very carefully.
 *
 * Change Log :
 *      v1.0    - [jsun] initial version
 */


Attachment: mips-rtc.011110.1900.011110.patch
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>