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