Home | History | Annotate | Line # | Download | only in dev
intio.c revision 1.6.32.1
      1  1.6.32.1  nathanw /*	$NetBSD: intio.c,v 1.6.32.1 2002/01/08 00:24:35 nathanw Exp $	*/
      2       1.1  thorpej 
      3       1.1  thorpej /*-
      4  1.6.32.1  nathanw  * Copyright (c) 1996, 1998, 2001 The NetBSD Foundation, Inc.
      5       1.1  thorpej  * All rights reserved.
      6       1.1  thorpej  *
      7       1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1  thorpej  * by Jason R. Thorpe.
      9       1.1  thorpej  *
     10       1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     11       1.1  thorpej  * modification, are permitted provided that the following conditions
     12       1.1  thorpej  * are met:
     13       1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     14       1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     15       1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17       1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     18       1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     19       1.1  thorpej  *    must display the following acknowledgement:
     20       1.1  thorpej  *        This product includes software developed by the NetBSD
     21       1.1  thorpej  *        Foundation, Inc. and its contributors.
     22       1.1  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23       1.1  thorpej  *    contributors may be used to endorse or promote products derived
     24       1.1  thorpej  *    from this software without specific prior written permission.
     25       1.1  thorpej  *
     26       1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27       1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28       1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29       1.3      jtc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30       1.3      jtc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31       1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32       1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33       1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34       1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35       1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36       1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37       1.1  thorpej  */
     38       1.1  thorpej 
     39       1.1  thorpej /*
     40       1.1  thorpej  * Autoconfiguration support for hp300 internal i/o space.
     41       1.1  thorpej  */
     42       1.1  thorpej 
     43       1.1  thorpej #include <sys/param.h>
     44       1.1  thorpej #include <sys/systm.h>
     45       1.1  thorpej #include <sys/device.h>
     46  1.6.32.1  nathanw 
     47  1.6.32.1  nathanw #include <machine/hp300spu.h>
     48  1.6.32.1  nathanw 
     49  1.6.32.1  nathanw #include <hp300/dev/intioreg.h>
     50       1.1  thorpej #include <hp300/dev/intiovar.h>
     51       1.1  thorpej 
     52  1.6.32.1  nathanw int	intiomatch(struct device *, struct cfdata *, void *);
     53  1.6.32.1  nathanw void	intioattach(struct device *, struct device *, void *);
     54  1.6.32.1  nathanw int	intioprint(void *, const char *);
     55       1.1  thorpej 
     56  1.6.32.1  nathanw const struct cfattach intio_ca = {
     57       1.1  thorpej 	sizeof(struct device), intiomatch, intioattach
     58       1.1  thorpej };
     59       1.1  thorpej 
     60  1.6.32.1  nathanw #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \
     61  1.6.32.1  nathanw     defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \
     62  1.6.32.1  nathanw     defined(HP380) || defined(HP385)
     63  1.6.32.1  nathanw const struct intio_builtins intio_3xx_builtins[] = {
     64  1.6.32.1  nathanw 	{ "rtc     ",	0x020000,	-1},
     65  1.6.32.1  nathanw 	{ "hil     ",	0x028000,	1},
     66  1.6.32.1  nathanw 	{ "fb      ",	0x160000,	-1},
     67  1.6.32.1  nathanw };
     68  1.6.32.1  nathanw #define nintio_3xx_builtins \
     69  1.6.32.1  nathanw 	(sizeof(intio_3xx_builtins) / sizeof(intio_3xx_builtins[0]))
     70  1.6.32.1  nathanw #endif
     71  1.6.32.1  nathanw 
     72  1.6.32.1  nathanw #if defined(HP400) || defined(HP425) || defined(HP433)
     73  1.6.32.1  nathanw const struct intio_builtins intio_4xx_builtins[] = {
     74  1.6.32.1  nathanw 	{ "rtc     ",	0x020000,	-1},
     75  1.6.32.1  nathanw 	{ "frodo   ",	0x01c000,	5},
     76  1.6.32.1  nathanw 	{ "hil     ",	0x028000,	1},
     77  1.6.32.1  nathanw 	{ "fb      ",	0x160000,	-1},
     78  1.6.32.1  nathanw };
     79  1.6.32.1  nathanw #define nintio_4xx_builtins \
     80  1.6.32.1  nathanw 	(sizeof(intio_4xx_builtins) / sizeof(intio_4xx_builtins[0]))
     81  1.6.32.1  nathanw #endif
     82  1.6.32.1  nathanw 
     83  1.6.32.1  nathanw static int intio_matched = 0;
     84  1.6.32.1  nathanw 
     85       1.1  thorpej int
     86       1.1  thorpej intiomatch(parent, match, aux)
     87       1.1  thorpej 	struct device *parent;
     88       1.1  thorpej 	struct cfdata *match;
     89       1.1  thorpej 	void *aux;
     90       1.1  thorpej {
     91       1.1  thorpej 	/* Allow only one instance. */
     92       1.1  thorpej 	if (intio_matched)
     93       1.1  thorpej 		return (0);
     94       1.1  thorpej 
     95       1.1  thorpej 	intio_matched = 1;
     96       1.1  thorpej 	return (1);
     97       1.1  thorpej }
     98       1.1  thorpej 
     99       1.1  thorpej void
    100       1.1  thorpej intioattach(parent, self, aux)
    101       1.1  thorpej 	struct device *parent, *self;
    102       1.1  thorpej 	void *aux;
    103       1.1  thorpej {
    104  1.6.32.1  nathanw 	struct intio_attach_args ia;
    105  1.6.32.1  nathanw 	const struct intio_builtins *ib;
    106  1.6.32.1  nathanw 	int ndevs;
    107  1.6.32.1  nathanw 	int i;
    108       1.1  thorpej 
    109       1.1  thorpej 	printf("\n");
    110       1.1  thorpej 
    111  1.6.32.1  nathanw 	switch (machineid) {
    112  1.6.32.1  nathanw #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \
    113  1.6.32.1  nathanw     defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \
    114  1.6.32.1  nathanw     defined(HP380) || defined(HP385)
    115  1.6.32.1  nathanw 	case HP_320:
    116  1.6.32.1  nathanw 	case HP_330:
    117  1.6.32.1  nathanw 	case HP_340:
    118  1.6.32.1  nathanw 	case HP_345:
    119  1.6.32.1  nathanw 	case HP_350:
    120  1.6.32.1  nathanw 	case HP_360:
    121  1.6.32.1  nathanw 	case HP_370:
    122  1.6.32.1  nathanw 	case HP_375:
    123  1.6.32.1  nathanw 	case HP_380:
    124  1.6.32.1  nathanw 	case HP_385:
    125  1.6.32.1  nathanw 		ib = intio_3xx_builtins;
    126  1.6.32.1  nathanw 		ndevs = nintio_3xx_builtins;
    127  1.6.32.1  nathanw 		break;
    128  1.6.32.1  nathanw #endif
    129  1.6.32.1  nathanw #if defined(HP400) || defined(HP425) || defined(HP433)
    130  1.6.32.1  nathanw 	case HP_400:
    131  1.6.32.1  nathanw 	case HP_425:
    132  1.6.32.1  nathanw 	case HP_433:
    133  1.6.32.1  nathanw 		ib = intio_4xx_builtins;
    134  1.6.32.1  nathanw 		ndevs = nintio_4xx_builtins;
    135  1.6.32.1  nathanw 		break;
    136  1.6.32.1  nathanw #endif
    137  1.6.32.1  nathanw 	default:
    138  1.6.32.1  nathanw 		return;
    139  1.6.32.1  nathanw 	}
    140  1.6.32.1  nathanw 
    141  1.6.32.1  nathanw 	memset(&ia, 0, sizeof(ia));
    142  1.6.32.1  nathanw 
    143  1.6.32.1  nathanw 	for (i=0; i<ndevs; i++) {
    144  1.6.32.1  nathanw 		strncpy(ia.ia_modname, ib[i].ib_modname, INTIO_MOD_LEN);
    145  1.6.32.1  nathanw 		ia.ia_modname[INTIO_MOD_LEN] = '\0';
    146  1.6.32.1  nathanw 		ia.ia_bst = HP300_BUS_SPACE_INTIO;
    147  1.6.32.1  nathanw 		ia.ia_iobase = ib[i].ib_offset;
    148  1.6.32.1  nathanw 		ia.ia_addr = (bus_addr_t)(intiobase + ib[i].ib_offset);
    149  1.6.32.1  nathanw 		ia.ia_ipl = ib[i].ib_ipl;
    150  1.6.32.1  nathanw 		config_found(self, &ia, intioprint);
    151  1.6.32.1  nathanw 	}
    152       1.1  thorpej }
    153       1.1  thorpej 
    154       1.1  thorpej int
    155       1.1  thorpej intioprint(aux, pnp)
    156       1.1  thorpej 	void *aux;
    157       1.1  thorpej 	const char *pnp;
    158       1.1  thorpej {
    159       1.1  thorpej 	struct intio_attach_args *ia = aux;
    160       1.1  thorpej 
    161  1.6.32.1  nathanw 	if (pnp)
    162  1.6.32.1  nathanw 		printf("%s at %s", ia->ia_modname, pnp);
    163  1.6.32.1  nathanw 	if (ia->ia_addr != 0) {
    164  1.6.32.1  nathanw 		printf(" addr 0x%lx", INTIOBASE + ia->ia_iobase);
    165  1.6.32.1  nathanw 		if (ia->ia_ipl != -1)
    166  1.6.32.1  nathanw 			printf(" ipl %d", ia->ia_ipl);
    167  1.6.32.1  nathanw 	}
    168       1.1  thorpej 	return (UNCONF);
    169       1.1  thorpej }
    170