Multiple rtc devices for todr_attach (Re: RTC todr for mips/alchemy)

Shigeyuki Fukushima <[email protected]>
Newsgroups gmane.os.netbsd.ports.evbmips
Organization NetBSD Developper
Message-ID <[email protected]>
Thank you for your works (clock.c, aurtc.c, and so on)

Garrett D'Amore wrote:
> You should probably create a custom evbmips/omsal400 directory and stick
> your RTC driver there.  You should probably model it after the aurrtc code.
> 
> In your kernel config, you must *only* have one of aurrtc or your rtc. 
> multiple devices trying to clockattach() will panic.

I have a plan for multiple rtc devices support.
I sent a patch in this e-mail.
Would you like to review this fix?

And, do you have something better idea?

-- 
Kind Regards,
--- shige
Shigeyuki Fukushima <shige@{FreeBSD,jp.FreeBSD,NetBSD}.org>
rtc.diff (text/plain, 1.3 KB)
? sys/arch/evbmips/conf/INSTALL_OMSAL400
Index: sys/arch/evbmips/conf/OMSAL400
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/conf/OMSAL400,v
retrieving revision 1.3
diff -u -r1.3 OMSAL400
--- sys/arch/evbmips/conf/OMSAL400	28 Mar 2006 15:12:01 -0000	1.3
+++ sys/arch/evbmips/conf/OMSAL400	28 Mar 2006 15:35:09 -0000
@@ -15,6 +15,7 @@
 options		ALCHEMY_AU1550
 options		ALCHEMY_OMSAL400
 options		PCI_NETBSD_CONFIGURE
+options		TODRDEV="\"r2025rtc0\""
 
 # Alchemy On-chip Programmable Serial Controllers
 aupsc*		at aubus? addr ?
Index: sys/arch/evbmips/evbmips/clock.c
===================================================================
RCS file: /cvsroot/src/sys/arch/evbmips/evbmips/clock.c,v
retrieving revision 1.8
diff -u -r1.8 clock.c
--- sys/arch/evbmips/evbmips/clock.c	28 Mar 2006 12:02:36 -0000	1.8
+++ sys/arch/evbmips/evbmips/clock.c	28 Mar 2006 15:35:09 -0000
@@ -126,9 +126,15 @@
 void
 todr_attach(todr_chip_handle_t todr)
 {
+	struct device *sc = (struct device *)todr->cookie;
 
-        if (todr_handle)
-                panic("todr_attach: realtime-clock already configured");
+	if ((strcmp(sc->dv_xname, TODRDEV) != 0)
+		&& (todr_handle != NULL)) {
+		aprint_normal(
+			"%s: other realtime-clock device already configured\n",
+			sc->dv_xname);
+		return;
+	}
         todr_handle = todr;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.