Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hp300 Pull basic SGC bus attachment from OpenBSD to...



details:   https://anonhg.NetBSD.org/src/rev/5af2cd272170
branches:  trunk
changeset: 761956:5af2cd272170
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sat Feb 12 05:15:39 2011 +0000

description:
Pull basic SGC bus attachment from OpenBSD to test devices.
Disabled by default since there is no SGC drivers yet.

diffstat:

 sys/arch/hp300/conf/GENERIC      |    5 +-
 sys/arch/hp300/conf/INSTALL      |    3 +-
 sys/arch/hp300/conf/files.hp300  |   10 ++-
 sys/arch/hp300/dev/sgc.c         |  164 +++++++++++++++++++++++++++++++++++++++
 sys/arch/hp300/dev/sgcreg.h      |   42 +++++++++
 sys/arch/hp300/dev/sgcvar.h      |   46 ++++++++++
 sys/arch/hp300/hp300/bus_space.c |   10 +-
 sys/arch/hp300/include/bus.h     |    3 +-
 8 files changed, 274 insertions(+), 9 deletions(-)

diffs (truncated from 386 to 300 lines):

diff -r 4a31ef8837e9 -r 5af2cd272170 sys/arch/hp300/conf/GENERIC
--- a/sys/arch/hp300/conf/GENERIC       Sat Feb 12 05:09:15 2011 +0000
+++ b/sys/arch/hp300/conf/GENERIC       Sat Feb 12 05:15:39 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.162 2011/02/12 05:08:40 tsutsui Exp $
+# $NetBSD: GENERIC,v 1.163 2011/02/12 05:15:39 tsutsui Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.162 $"
+#ident                 "GENERIC-$Revision: 1.163 $"
 
 maxusers       32              # estimated number of users
 
@@ -194,6 +194,7 @@
 
 intio0         at mainbus0             # internal i/o space
 dio0           at mainbus0             # DIO/DIO-II bus
+#sgc0          at mainbus0             # SGC bus
 
 # Human Interface Loop devices
 hil0           at intio?               # HIL controller
diff -r 4a31ef8837e9 -r 5af2cd272170 sys/arch/hp300/conf/INSTALL
--- a/sys/arch/hp300/conf/INSTALL       Sat Feb 12 05:09:15 2011 +0000
+++ b/sys/arch/hp300/conf/INSTALL       Sat Feb 12 05:15:39 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: INSTALL,v 1.43 2011/02/12 05:08:40 tsutsui Exp $
+# $NetBSD: INSTALL,v 1.44 2011/02/12 05:15:39 tsutsui Exp $
 #
 # INSTALL machine description file
 #
@@ -135,6 +135,7 @@
 
 intio0         at mainbus0     # internal i/o space
 dio0           at mainbus0     # DIO/DIO-II bus
+#sgc0          at mainbus0     # SGC bus
 
 # Real-time clock (not optional)
 rtc*           at intio?
diff -r 4a31ef8837e9 -r 5af2cd272170 sys/arch/hp300/conf/files.hp300
--- a/sys/arch/hp300/conf/files.hp300   Sat Feb 12 05:09:15 2011 +0000
+++ b/sys/arch/hp300/conf/files.hp300   Sat Feb 12 05:15:39 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.hp300,v 1.80 2011/02/12 05:08:40 tsutsui Exp $
+#      $NetBSD: files.hp300,v 1.81 2011/02/12 05:15:39 tsutsui Exp $
 #
 # hp300-specific configuration info
 
@@ -43,6 +43,14 @@
 file   arch/hp300/dev/dio.c            dio
 
 #
+# SGC bus
+#
+
+device sgc { scode = -1 }
+attach sgc at mainbus
+file   arch/hp300/dev/sgc.c            sgc
+
+#
 # Devices in Internal i/o space
 #
 
diff -r 4a31ef8837e9 -r 5af2cd272170 sys/arch/hp300/dev/sgc.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hp300/dev/sgc.c  Sat Feb 12 05:15:39 2011 +0000
@@ -0,0 +1,164 @@
+/*     $NetBSD: sgc.c,v 1.1 2011/02/12 05:15:39 tsutsui Exp $  */
+/*     $OpenBSD: sgc.c,v 1.6 2010/04/15 20:35:21 miod Exp $    */
+
+/*
+ * Copyright (c) 2005, Miodrag Vallat
+ *
+ * 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.
+ *
+ * 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.
+ *
+ */
+
+/*
+ * SGC bus attachment and mapping glue.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/cpu.h>
+
+#include <machine/autoconf.h>
+#include <machine/hp300spu.h>
+
+#include <hp300/dev/sgcreg.h>
+#include <hp300/dev/sgcvar.h>
+
+#ifdef SGC_DEBUG
+#define DPRINTF(x)     printf x
+#else
+#define DPRINTF(x)     do {} while (/* CONSTCOND */ 0)
+#endif
+
+struct sgc_softc {
+       device_t sc_dev;
+       struct bus_space_tag sc_tag;
+};
+
+int    sgcmatch(device_t, cfdata_t, void *);
+void   sgcattach(device_t, device_t, void *);
+int    sgcprint(void *, const char *);
+
+CFATTACH_DECL_NEW(sgc, sizeof(struct sgc_softc),
+    sgcmatch, sgcattach, NULL, NULL);
+
+int
+sgcmatch(device_t parent, cfdata_t cf, void *aux)
+{
+       static int sgc_matched = 0;
+
+       /* Allow only one instance. */
+       if (sgc_matched)
+               return 0;
+
+       /*
+        * Leave out machines which can not have an SGC bus.
+        */
+
+       switch (machineid) {
+#if 0
+       case HP_362:
+       case HP_382:
+#endif
+       case HP_400:
+       case HP_425:
+       case HP_433:
+               return sgc_matched = 1;
+       default:
+               return 0;
+       }
+}
+
+void
+sgcattach(device_t parent, device_t self, void *aux)
+{
+       struct sgc_softc *sc;
+       struct sgc_attach_args saa;
+       paddr_t pa;
+       void *va;
+       int slot, rv;
+       bus_space_tag_t bst;
+       bus_space_handle_t bsh;
+
+       sc = device_private(self);
+       sc->sc_dev = self;
+       aprint_normal("\n");
+
+       bst = &sc->sc_tag;
+       memset(bst, 0, sizeof(struct bus_space_tag));
+       bst->bustype = HP300_BUS_SPACE_SGC;
+
+       for (slot = 0; slot < SGC_NSLOTS; slot++) {
+               pa = sgc_slottopa(slot);
+               if (bus_space_map(bst, pa, PAGE_SIZE, 0, &bsh) != 0) {
+                       aprint_error_dev(self, "can't map slot %d\n", slot);
+                       continue;
+               }
+               va = bus_space_vaddr(bst, bsh);
+
+               /* Check for hardware. */
+               rv = badaddr(va);
+               bus_space_unmap(bst, bsh, PAGE_SIZE);
+
+               if (rv != 0) {
+                       DPRINTF(("%s: no valid device at slot %d\n",
+                           device_xname(self), slot));
+                       continue;
+               }
+
+               memset(&saa, 0, sizeof(saa));
+               saa.saa_iot = bst;
+               saa.saa_slot = slot;
+
+               /* Attach matching device. */
+               config_found(self, &saa, sgcprint);
+       }
+}
+
+int
+sgcprint(void *aux, const char *pnp)
+{
+       struct sgc_attach_args *saa = aux;
+
+       if (pnp)
+               aprint_normal("unknown SGC card at %s", pnp);
+       aprint_normal(" slot %d", saa->saa_slot);
+       return UNCONF;
+}
+
+/*
+ * Convert a slot number to a system physical address.
+ * This is needed for bus_space.
+ */
+paddr_t
+sgc_slottopa(int slot)
+{
+       paddr_t rval;
+
+       if (slot < 0 || slot >= SGC_NSLOTS)
+               rval = 0;
+       else
+               rval = SGC_BASE + (slot * SGC_DEVSIZE);
+
+       return rval;
+}
diff -r 4a31ef8837e9 -r 5af2cd272170 sys/arch/hp300/dev/sgcreg.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hp300/dev/sgcreg.h       Sat Feb 12 05:15:39 2011 +0000
@@ -0,0 +1,42 @@
+/*     $NetBSD: sgcreg.h,v 1.1 2011/02/12 05:15:39 tsutsui Exp $       */
+/*     $OpenBSD: sgcreg.h,v 1.1 2005/01/14 22:39:26 miod Exp $ */
+
+/*
+ * Copyright (c) 2005, Miodrag Vallat
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Register definitions for the SGC bus.
+ */
+
+/*
+ * SGC ranges from slots 0-3 at physical addresses given by:
+ *     0x20000000 + slot * 0x04000000
+ */
+
+#define        SGC_BASE                0x20000000
+#define        SGC_END                 0x30000000
+#define        SGC_DEVSIZE             0x04000000
+
+#define        SGC_NSLOTS              4
diff -r 4a31ef8837e9 -r 5af2cd272170 sys/arch/hp300/dev/sgcvar.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hp300/dev/sgcvar.h       Sat Feb 12 05:15:39 2011 +0000
@@ -0,0 +1,46 @@
+/*     $NetBSD: sgcvar.h,v 1.1 2011/02/12 05:15:39 tsutsui Exp $       */
+/*     $OpenBSD: sgcvar.h,v 1.2 2007/01/06 20:09:12 miod Exp $ */
+
+/*
+ * Copyright (c) 2005, Miodrag Vallat.
+ * All rights reserved.
+ *
+ * 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.



Home | Main Index | Thread Index | Old Index