Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sgimips O2 RTC attachment, based on code from Antti...



details:   https://anonhg.NetBSD.org/src/rev/2f954035d92b
branches:  trunk
changeset: 518140:2f954035d92b
user:      soren <soren%NetBSD.org@localhost>
date:      Sun Nov 25 15:05:04 2001 +0000

description:
O2 RTC attachment, based on code from Antti Kantee.

diffstat:

 sys/arch/sgimips/conf/files.sgimips |   11 +-
 sys/arch/sgimips/dev/mcclock_mace.c |  191 +++++++++++++++++++++++++++++++++
 sys/arch/sgimips/hpc/ds1286.c       |  204 ------------------------------------
 sys/arch/sgimips/hpc/dsclock_hpc.c  |  195 ++++++++++++++++++++++++++++++++++
 sys/arch/sgimips/sgimips/clockvar.h |    4 +-
 5 files changed, 395 insertions(+), 210 deletions(-)

diffs (truncated from 653 to 300 lines):

diff -r 32904b89f1f3 -r 2f954035d92b sys/arch/sgimips/conf/files.sgimips
--- a/sys/arch/sgimips/conf/files.sgimips       Sun Nov 25 14:39:50 2001 +0000
+++ b/sys/arch/sgimips/conf/files.sgimips       Sun Nov 25 15:05:04 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.sgimips,v 1.16 2001/11/20 14:34:23 lukem Exp $
+#      $NetBSD: files.sgimips,v 1.17 2001/11/25 15:05:04 soren Exp $
 
 maxpartitions 16
 
@@ -39,8 +39,9 @@
 attach pckbc at mace with pckbc_mace
 file arch/sgimips/dev/pckbc_mace.c     pckbc_mace
 
-#attach mcclock at mace with mcclock_mace
-#file arch/sgimips/dev/mcclock_mace.c  mcclock_mace
+device mcclock # XXX
+attach mcclock at mace with mcclock_mace
+file arch/sgimips/dev/mcclock_mace.c   mcclock_mace
 
 device mec: arp, ether, ifnet, mii
 attach mec at mace
@@ -83,8 +84,6 @@
 file dev/clock_subr.c
 file dev/cons.c
 
-include "arch/sgimips/gio/files.gio"
-
 # Machine-independent I2O drivers.
 include "dev/i2o/files.i2o"
 
@@ -105,3 +104,5 @@
 major {cd = 12}
 include "dev/ata/files.ata"
 major {wd = 13}
+
+include "arch/sgimips/gio/files.gio"
diff -r 32904b89f1f3 -r 2f954035d92b sys/arch/sgimips/dev/mcclock_mace.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/sgimips/dev/mcclock_mace.c       Sun Nov 25 15:05:04 2001 +0000
@@ -0,0 +1,191 @@
+/*     $NetBSD: mcclock_mace.c,v 1.1 2001/11/25 15:05:05 soren Exp $   */
+
+/*
+ * Copyright (c) 1998 Mark Brinicombe.
+ * Copyright (c) 1998 Causality Limited.
+ * All rights reserved.
+ *
+ * Written by Mark Brinicombe, Causality Limited
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by Mark Brinicombe
+ *     for the NetBSD Project.
+ * 4. The name of the company nor the name of the author may be used to
+ *    endorse or promote products derived from this software without specific
+ *    prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY CAUASLITY LIMITED ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL CAUSALITY LIMITED OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <machine/cpu.h>
+#include <machine/autoconf.h>
+#include <machine/bus.h>
+#include <machine/machtype.h>
+
+#include <dev/clock_subr.h>
+#include <dev/ic/mc146818reg.h>
+
+#include <sgimips/dev/macevar.h>
+
+#include <sgimips/sgimips/clockvar.h>
+
+/*
+ * Following register acts different in MC146818A, that's why it's
+ * not found in mc146818reg.h, and we must define it separately.
+ */
+#define MC_REGA_DV1    0x20
+
+struct mcclock_mace_softc {
+       struct device           sc_dev;
+
+       bus_space_tag_t         sc_st;
+       bus_space_handle_t      sc_sh;
+};
+
+static int     mcclock_mace_match(struct device *, struct cfdata *, void *);
+static void    mcclock_mace_attach(struct device*, struct device *, void *);
+
+static void    mcclock_mace_init(struct device *);
+static void    mcclock_mace_get(struct device *, struct clock_ymdhms *);
+static void    mcclock_mace_set(struct device *, struct clock_ymdhms *);
+
+unsigned int   mc146818_read(void *arg, unsigned int addr);
+void           mc146818_write(void *arg, unsigned int addr, unsigned int data);
+
+const struct clockfns mcclock_mace_clockfns = {
+       mcclock_mace_init, mcclock_mace_get, mcclock_mace_set
+};
+
+struct cfattach mcclock_mace_ca = {
+       sizeof(struct mcclock_mace_softc),
+       mcclock_mace_match,
+       mcclock_mace_attach
+};
+
+static int
+mcclock_mace_match(struct device *parent, struct cfdata *match, void *aux)
+{
+               return 1;
+}
+
+void
+mcclock_mace_attach(struct device *parent, struct device *self, void *aux)
+{
+       struct mcclock_mace_softc *sc = (void *)self;
+       struct mace_attach_args *maa = aux;
+
+       sc->sc_st = maa->maa_st;
+       sc->sc_sh = maa->maa_sh;
+
+       mc146818_write(sc, MC_REGA, MC_REGA_DV1);
+       mc146818_write(sc, MC_REGB, MC_REGB_BINARY | MC_REGB_24HR);
+       if (!(mc146818_read(sc, MC_REGD) & MC_REGD_VRT))
+               printf(": lithium cell is dead, RTC unreliable");
+       printf("\n");
+
+       clockattach(&sc->sc_dev, &mcclock_mace_clockfns);
+}
+
+/*
+ * We need to use the following two functions from
+ * MC146818_PUT/GETTOD(). Hence the names.
+ */
+unsigned int
+mc146818_read(void *arg, unsigned int addr)
+{
+       struct mcclock_mace_softc *sc = (struct mcclock_mace_softc *)arg;
+
+       return (bus_space_read_1(sc->sc_st, sc->sc_sh, addr));
+}
+
+void
+mc146818_write(void *arg, unsigned int addr, unsigned int data)
+{
+       struct mcclock_mace_softc *sc = (struct mcclock_mace_softc *)arg;
+
+       bus_space_write_1(sc->sc_st, sc->sc_sh, addr, data);
+}
+
+static void
+mcclock_mace_init(struct device *dev)
+{
+       return;
+}
+
+static void
+mcclock_mace_get(struct device *dev, struct clock_ymdhms *dt)
+{
+       struct mcclock_mace_softc *sc = (struct mcclock_mace_softc *)dev;
+       mc_todregs regs;
+       int s;
+
+       s = splhigh();
+       MC146818_GETTOD(sc, &regs);
+       splx(s);
+
+       dt->dt_sec = FROMBCD(regs[MC_SEC]);
+       dt->dt_min = FROMBCD(regs[MC_MIN]);
+       dt->dt_hour = FROMBCD(regs[MC_HOUR]);
+       dt->dt_wday = FROMBCD(regs[MC_DOW]);
+       dt->dt_day = FROMBCD(regs[MC_DOM]);
+       dt->dt_mon = FROMBCD(regs[MC_MONTH]);
+       dt->dt_year = FROMBCD(regs[MC_YEAR]);
+
+       /* RTC base on IRIX is 1940, offsets < 45 are from 1970 */
+       if (dt->dt_year < 45)
+               dt->dt_year += 30;
+
+       dt->dt_year += IRIX_CLOCK_BASE; /* 1940 */
+}
+
+static void
+mcclock_mace_set(struct device *dev, struct clock_ymdhms *dt)
+{
+       struct mcclock_mace_softc *sc = (struct mcclock_mace_softc *)dev;
+       mc_todregs regs;
+       int s;
+
+       memset(&regs, 0, sizeof(regs));
+
+       regs[MC_SEC] = TOBCD(dt->dt_sec);
+       regs[MC_MIN] = TOBCD(dt->dt_min);
+       regs[MC_HOUR] = TOBCD(dt->dt_hour);
+       regs[MC_DOW] = TOBCD(dt->dt_wday);
+       regs[MC_DOM] = TOBCD(dt->dt_day);
+       regs[MC_MONTH] = TOBCD(dt->dt_mon);
+
+       /*
+        * If year < 1985, store (year - 1970), else (year - 1940).  This
+        * matches IRIX semantics.
+        */
+       if (dt->dt_year < 1985)
+               dt->dt_year -= 30;
+
+       regs[MC_YEAR] = TOBCD(dt->dt_year - IRIX_CLOCK_BASE);   /* - 1940 */
+
+       s = splhigh();
+       MC146818_PUTTOD(sc, &regs);
+       splx(s);
+}
diff -r 32904b89f1f3 -r 2f954035d92b sys/arch/sgimips/hpc/ds1286.c
--- a/sys/arch/sgimips/hpc/ds1286.c     Sun Nov 25 14:39:50 2001 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-/*     $NetBSD: ds1286.c,v 1.2 2001/11/18 08:16:16 thorpej Exp $       */
-
-/*
- * Copyright (c) 2001 Rafal K. Boni
- * Copyright (c) 2001 Christopher Sekiya
- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * Portions of this code are derived from software contributed to The 
- * NetBSD Foundation by Jason R. Thorpe of the Numerical Aerospace 
- * Simulation Facility, NASA Ames Research Center.
- * 
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/param.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-
-#include <machine/bus.h>
-#include <machine/sysconf.h>
-#include <machine/machtype.h>
-
-#include <dev/clock_subr.h>
-#include <dev/ic/ds1286reg.h>
-
-#include <sgimips/hpc/hpcvar.h>
-#include <sgimips/sgimips/clockvar.h>
-
-extern int mach_type;
-extern struct platform platform;
-void clockattach(struct device *, const struct clockfns *);
-
-struct dsclock_softc {
-        struct device sc_dev;
-
-       /* RTC registers */
-        bus_space_tag_t         sc_rtct;
-        bus_space_handle_t      sc_rtch;
-
-};
-
-static void    dsclock_init(struct device *);
-static int     dsclock_match(struct device *, struct cfdata *, void *);



Home | Main Index | Thread Index | Old Index