Home | History | Annotate | Line # | Download | only in dev
intio.c revision 1.4
      1 /*	$NetBSD: intio.c,v 1.4 2002/09/27 03:18:01 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 /*
     40  * Autoconfiguration support for next68k internal i/o space.
     41  */
     42 
     43 #include <sys/param.h>
     44 #include <sys/systm.h>
     45 #include <sys/device.h>
     46 #include <sys/reboot.h>
     47 
     48 #include <machine/autoconf.h>
     49 
     50 #include <next68k/dev/intiovar.h>
     51 
     52 int	intiomatch __P((struct device *, struct cfdata *, void *));
     53 void	intioattach __P((struct device *, struct device *, void *));
     54 int	intioprint __P((void *, const char *));
     55 int	intiosearch __P((struct device *, struct cfdata *, void *));
     56 
     57 struct cfattach intio_ca = {
     58 	sizeof(struct device), intiomatch, intioattach
     59 };
     60 
     61 #if 0
     62 struct cfdriver intio_cd = {
     63 	NULL, "intio", DV_DULL
     64 };
     65 #endif
     66 
     67 static int intio_attached = 0;
     68 
     69 int
     70 intiomatch(parent, match, aux)
     71 	struct device *parent;
     72 	struct cfdata *match;
     73 	void *aux;
     74 {
     75 	/* Allow only one instance. */
     76 	if (intio_attached)
     77 		return (0);
     78 
     79 	return (1);
     80 }
     81 
     82 void
     83 intioattach(parent, self, aux)
     84 	struct device *parent, *self;
     85 	void *aux;
     86 {
     87 
     88 	printf("\n");
     89 
     90 	/* Search for and attach children. */
     91 	config_search(intiosearch, self, aux);
     92 
     93 	intio_attached = 1;
     94 }
     95 
     96 int
     97 intioprint(aux, pnp)
     98 	void *aux;
     99 	const char *pnp;
    100 {
    101 	struct intio_attach_args *ia = aux;
    102 
    103 	if (bootverbose && ia->ia_addr)
    104 		printf(" addr %p", ia->ia_addr);
    105 
    106 	return (UNCONF);
    107 }
    108 
    109 int
    110 intiosearch(parent, cf, aux)
    111 	struct device *parent;
    112 	struct cfdata *cf;
    113 	void *aux;
    114 {
    115 	struct mainbus_attach_args *mba = (struct mainbus_attach_args *) aux;
    116 	struct intio_attach_args ia;
    117 
    118 	do {
    119 		ia.ia_addr = NULL;
    120 		ia.ia_bst = NEXT68K_INTIO_BUS_SPACE;
    121 		ia.ia_dmat = mba->mba_dmat;
    122 
    123 		if (config_match(parent, cf, &ia) == 0)
    124 			break;
    125 		config_attach(parent, cf, &ia, intioprint);
    126 	} while (cf->cf_fstate == FSTATE_STAR);
    127 
    128 	return (0);
    129 }
    130