Home | History | Annotate | Line # | Download | only in gio
gio.c revision 1.10
      1 /*	$NetBSD: gio.c,v 1.10 2003/07/15 03:35:52 lukem Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2000 Soren S. Jorvang
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *          This product includes software developed for the
     18  *          NetBSD Project.  See http://www.netbsd.org/ for
     19  *          information about NetBSD.
     20  * 4. The name of the author may not be used to endorse or promote products
     21  *    derived from this software without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33  */
     34 
     35 #include <sys/cdefs.h>
     36 __KERNEL_RCSID(0, "$NetBSD: gio.c,v 1.10 2003/07/15 03:35:52 lukem Exp $");
     37 
     38 #include "opt_ddb.h"
     39 
     40 #include <sys/param.h>
     41 #include <sys/systm.h>
     42 #include <sys/device.h>
     43 
     44 #include <sgimips/gio/gioreg.h>
     45 #include <sgimips/gio/giovar.h>
     46 
     47 #include "locators.h"
     48 
     49 struct gio_softc {
     50 	struct	device sc_dev;
     51 };
     52 
     53 static int	gio_match(struct device *, struct cfdata *, void *);
     54 static void	gio_attach(struct device *, struct device *, void *);
     55 static int	gio_print(void *, const char *);
     56 static int	gio_search(struct device *, struct cfdata *, void *);
     57 
     58 CFATTACH_DECL(gio, sizeof(struct gio_softc),
     59     gio_match, gio_attach, NULL, NULL);
     60 
     61 static int
     62 gio_match(parent, match, aux)
     63 	struct device *parent;
     64 	struct cfdata *match;
     65 	void *aux;
     66 {
     67 	struct giobus_attach_args *gba = aux;
     68 
     69 	if (strcmp(gba->gba_busname, match->cf_name) != 0)
     70 		return 0;
     71 
     72 	return 1;
     73 }
     74 
     75 static void
     76 gio_attach(parent, self, aux)
     77 	struct device *parent;
     78 	struct device *self;
     79 	void *aux;
     80 {
     81 	struct gio_attach_args ga;
     82 
     83 	printf("\n");
     84 
     85 	config_search(gio_search, self, &ga);
     86 }
     87 
     88 static int
     89 gio_print(aux, pnp)
     90 	void *aux;
     91 	const char *pnp;
     92 {
     93 	struct gio_attach_args *ga = aux;
     94 
     95 	if (pnp != 0)
     96 		return QUIET;
     97 
     98 	if (ga->ga_slot != GIOCF_SLOT_DEFAULT)
     99 		aprint_normal(" slot %d", ga->ga_slot);
    100 	if (ga->ga_addr != (uint32_t) GIOCF_ADDR_DEFAULT)
    101 		aprint_normal(" addr 0x%x", ga->ga_addr);
    102 
    103 	return UNCONF;
    104 }
    105 
    106 static int
    107 gio_search(parent, cf, aux)
    108 	struct device *parent;
    109 	struct cfdata *cf;
    110 	void *aux;
    111 {
    112 	struct gio_attach_args *ga = aux;
    113 
    114 	do {
    115 		ga->ga_slot = cf->cf_loc[GIOCF_SLOT];
    116 		ga->ga_addr = cf->cf_loc[GIOCF_ADDR];
    117 		ga->ga_iot = 0;
    118 		ga->ga_ioh = MIPS_PHYS_TO_KSEG1(ga->ga_addr);
    119 		if (config_match(parent, cf, ga) > 0)
    120 			config_attach(parent, cf, ga, gio_print);
    121 	} while (cf->cf_fstate == FSTATE_STAR);
    122 
    123 	return 0;
    124 }
    125