Module Name: src Committed By: tsutsui Date: Sat Feb 12 05:15:39 UTC 2011
Modified Files: src/sys/arch/hp300/conf: GENERIC INSTALL files.hp300 src/sys/arch/hp300/hp300: bus_space.c src/sys/arch/hp300/include: bus.h Added Files: src/sys/arch/hp300/dev: sgc.c sgcreg.h sgcvar.h Log Message: Pull basic SGC bus attachment from OpenBSD to test devices. Disabled by default since there is no SGC drivers yet. To generate a diff of this commit: cvs rdiff -u -r1.162 -r1.163 src/sys/arch/hp300/conf/GENERIC cvs rdiff -u -r1.43 -r1.44 src/sys/arch/hp300/conf/INSTALL cvs rdiff -u -r1.80 -r1.81 src/sys/arch/hp300/conf/files.hp300 cvs rdiff -u -r0 -r1.1 src/sys/arch/hp300/dev/sgc.c \ src/sys/arch/hp300/dev/sgcreg.h src/sys/arch/hp300/dev/sgcvar.h cvs rdiff -u -r1.19 -r1.20 src/sys/arch/hp300/hp300/bus_space.c cvs rdiff -u -r1.15 -r1.16 src/sys/arch/hp300/include/bus.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/hp300/conf/GENERIC diff -u src/sys/arch/hp300/conf/GENERIC:1.162 src/sys/arch/hp300/conf/GENERIC:1.163 --- src/sys/arch/hp300/conf/GENERIC:1.162 Sat Feb 12 05:08:40 2011 +++ src/sys/arch/hp300/conf/GENERIC Sat Feb 12 05:15:39 2011 @@ -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 Index: src/sys/arch/hp300/conf/INSTALL diff -u src/sys/arch/hp300/conf/INSTALL:1.43 src/sys/arch/hp300/conf/INSTALL:1.44 --- src/sys/arch/hp300/conf/INSTALL:1.43 Sat Feb 12 05:08:40 2011 +++ src/sys/arch/hp300/conf/INSTALL Sat Feb 12 05:15:39 2011 @@ -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? Index: src/sys/arch/hp300/conf/files.hp300 diff -u src/sys/arch/hp300/conf/files.hp300:1.80 src/sys/arch/hp300/conf/files.hp300:1.81 --- src/sys/arch/hp300/conf/files.hp300:1.80 Sat Feb 12 05:08:40 2011 +++ src/sys/arch/hp300/conf/files.hp300 Sat Feb 12 05:15:39 2011 @@ -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 # Index: src/sys/arch/hp300/hp300/bus_space.c diff -u src/sys/arch/hp300/hp300/bus_space.c:1.19 src/sys/arch/hp300/hp300/bus_space.c:1.20 --- src/sys/arch/hp300/hp300/bus_space.c:1.19 Sat Feb 12 04:52:28 2011 +++ src/sys/arch/hp300/hp300/bus_space.c Sat Feb 12 05:15:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: bus_space.c,v 1.19 2011/02/12 04:52:28 tsutsui Exp $ */ +/* $NetBSD: bus_space.c,v 1.20 2011/02/12 05:15:39 tsutsui Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.19 2011/02/12 04:52:28 tsutsui Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bus_space.c,v 1.20 2011/02/12 05:15:39 tsutsui Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -65,7 +65,8 @@ return 0; } - if (t->bustype != HP300_BUS_SPACE_DIO) + if (t->bustype != HP300_BUS_SPACE_DIO && + t->bustype != HP300_BUS_SPACE_SGC) panic("%s: bad space tag", __func__); /* @@ -129,7 +130,8 @@ return; } - if (t->bustype != HP300_BUS_SPACE_DIO) + if (t->bustype != HP300_BUS_SPACE_DIO && + t->bustype != HP300_BUS_SPACE_SGC) panic("%s: bad space tag", __func__); kva = m68k_trunc_page(bsh); Index: src/sys/arch/hp300/include/bus.h diff -u src/sys/arch/hp300/include/bus.h:1.15 src/sys/arch/hp300/include/bus.h:1.16 --- src/sys/arch/hp300/include/bus.h:1.15 Mon Apr 28 20:23:19 2008 +++ src/sys/arch/hp300/include/bus.h Sat Feb 12 05:15:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: bus.h,v 1.15 2008/04/28 20:23:19 martin Exp $ */ +/* $NetBSD: bus.h,v 1.16 2011/02/12 05:15:39 tsutsui Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -64,6 +64,7 @@ */ #define HP300_BUS_SPACE_INTIO 0 /* space is intio space */ #define HP300_BUS_SPACE_DIO 1 /* space is dio space */ +#define HP300_BUS_SPACE_SGC 2 /* space is sgc space */ /* * Bus address and size types Added files: Index: src/sys/arch/hp300/dev/sgc.c diff -u /dev/null src/sys/arch/hp300/dev/sgc.c:1.1 --- /dev/null Sat Feb 12 05:15:39 2011 +++ src/sys/arch/hp300/dev/sgc.c Sat Feb 12 05:15:39 2011 @@ -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; +} Index: src/sys/arch/hp300/dev/sgcreg.h diff -u /dev/null src/sys/arch/hp300/dev/sgcreg.h:1.1 --- /dev/null Sat Feb 12 05:15:39 2011 +++ src/sys/arch/hp300/dev/sgcreg.h Sat Feb 12 05:15:39 2011 @@ -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 Index: src/sys/arch/hp300/dev/sgcvar.h diff -u /dev/null src/sys/arch/hp300/dev/sgcvar.h:1.1 --- /dev/null Sat Feb 12 05:15:39 2011 +++ src/sys/arch/hp300/dev/sgcvar.h Sat Feb 12 05:15:39 2011 @@ -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. + * + * 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. + * + */ + +/* + * Autoconfiguration definitions and prototypes for the SGC bus. + */ + +struct sgc_attach_args { + int saa_slot; /* slot number */ + bus_space_tag_t saa_iot; +}; + +#ifdef _KERNEL +paddr_t sgc_slottopa(int); +#endif /* _KERNEL */ + +/* Macros to switch between SGC slot numbers and kernel conscode */ +#define SGC_SLOT_TO_CONSCODE(slot) (256 + (slot)) +#define CONSCODE_TO_SGC_SLOT(code) ((code) - 256)