Home | History | Annotate | Line # | Download | only in obio
obio.c revision 1.2.2.2
      1  1.2.2.2  bouyer /*	$NetBSD: obio.c,v 1.2.2.2 2000/11/20 20:14:11 bouyer Exp $	*/
      2  1.2.2.2  bouyer 
      3  1.2.2.2  bouyer /*-
      4  1.2.2.2  bouyer  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  1.2.2.2  bouyer  * All rights reserved.
      6  1.2.2.2  bouyer  *
      7  1.2.2.2  bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2.2.2  bouyer  * by Wayne Knowles
      9  1.2.2.2  bouyer  *
     10  1.2.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
     11  1.2.2.2  bouyer  * modification, are permitted provided that the following conditions
     12  1.2.2.2  bouyer  * are met:
     13  1.2.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     14  1.2.2.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     15  1.2.2.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.2.2.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     17  1.2.2.2  bouyer  *    documentation and/or other materials provided with the distribution.
     18  1.2.2.2  bouyer  * 3. All advertising materials mentioning features or use of this software
     19  1.2.2.2  bouyer  *    must display the following acknowledgement:
     20  1.2.2.2  bouyer  *        This product includes software developed by the NetBSD
     21  1.2.2.2  bouyer  *        Foundation, Inc. and its contributors.
     22  1.2.2.2  bouyer  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.2.2.2  bouyer  *    contributors may be used to endorse or promote products derived
     24  1.2.2.2  bouyer  *    from this software without specific prior written permission.
     25  1.2.2.2  bouyer  *
     26  1.2.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.2.2.2  bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.2.2.2  bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.2.2.2  bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.2.2.2  bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.2.2.2  bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.2.2.2  bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.2.2.2  bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.2.2.2  bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.2.2.2  bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.2.2.2  bouyer  * POSSIBILITY OF SUCH DAMAGE.
     37  1.2.2.2  bouyer  */
     38  1.2.2.2  bouyer 
     39  1.2.2.2  bouyer #include <sys/param.h>
     40  1.2.2.2  bouyer #include <sys/systm.h>
     41  1.2.2.2  bouyer #include <sys/device.h>
     42  1.2.2.2  bouyer 
     43  1.2.2.2  bouyer #include <machine/autoconf.h>
     44  1.2.2.2  bouyer #include <machine/mainboard.h>
     45  1.2.2.2  bouyer #include <machine/bus.h>
     46  1.2.2.2  bouyer #include <machine/sysconf.h>
     47  1.2.2.2  bouyer 
     48  1.2.2.2  bouyer static int	obio_match __P((struct device *, struct cfdata *, void *));
     49  1.2.2.2  bouyer static void	obio_attach __P((struct device *, struct device *, void *));
     50  1.2.2.2  bouyer static int	obio_search __P((struct device *, struct cfdata *, void *));
     51  1.2.2.2  bouyer static int	obio_print __P((void *, const char *));
     52  1.2.2.2  bouyer static void	obio_intr_establish  __P((bus_space_tag_t, int, int, int,
     53  1.2.2.2  bouyer 					  int (*)(void *), void *));
     54  1.2.2.2  bouyer 
     55  1.2.2.2  bouyer struct cfattach obio_ca = {
     56  1.2.2.2  bouyer 	sizeof(struct device), obio_match, obio_attach
     57  1.2.2.2  bouyer };
     58  1.2.2.2  bouyer 
     59  1.2.2.2  bouyer extern struct cfdriver obio_cd;
     60  1.2.2.2  bouyer 
     61  1.2.2.2  bouyer struct mipsco_bus_space obio_bustag;
     62  1.2.2.2  bouyer struct mipsco_bus_dma_tag obio_dmatag;
     63  1.2.2.2  bouyer 
     64  1.2.2.2  bouyer static int
     65  1.2.2.2  bouyer obio_match(parent, cf, aux)
     66  1.2.2.2  bouyer 	struct device *parent;
     67  1.2.2.2  bouyer 	struct cfdata *cf;
     68  1.2.2.2  bouyer 	void *aux;
     69  1.2.2.2  bouyer {
     70  1.2.2.2  bouyer 	struct confargs *ca = aux;
     71  1.2.2.2  bouyer 
     72  1.2.2.2  bouyer 	if (strcmp(ca->ca_name, obio_cd.cd_name) != 0)
     73  1.2.2.2  bouyer 		return 0;
     74  1.2.2.2  bouyer 
     75  1.2.2.2  bouyer 	return 1;
     76  1.2.2.2  bouyer }
     77  1.2.2.2  bouyer 
     78  1.2.2.2  bouyer static void
     79  1.2.2.2  bouyer obio_attach(parent, self, aux)
     80  1.2.2.2  bouyer 	struct device *parent;
     81  1.2.2.2  bouyer 	struct device *self;
     82  1.2.2.2  bouyer 	void *aux;
     83  1.2.2.2  bouyer {
     84  1.2.2.2  bouyer 	struct confargs *ca = aux;
     85  1.2.2.2  bouyer 
     86  1.2.2.2  bouyer 	/* PIZAZZ (Mips 3000 Magnum)  Address Map */
     87  1.2.2.2  bouyer 	mipsco_bus_space_init(&obio_bustag, "obio",
     88  1.2.2.2  bouyer 			      0x18000000, 0xb8000000,
     89  1.2.2.2  bouyer 			      0xb8000000, 0x08000000);
     90  1.2.2.2  bouyer 
     91  1.2.2.2  bouyer 	_bus_dma_tag_init(&obio_dmatag);
     92  1.2.2.2  bouyer 	obio_bustag.bs_intr_establish = obio_intr_establish; /* XXX */
     93  1.2.2.2  bouyer 
     94  1.2.2.2  bouyer 	ca->ca_bustag = &obio_bustag;
     95  1.2.2.2  bouyer 	ca->ca_dmatag = &obio_dmatag;
     96  1.2.2.2  bouyer 
     97  1.2.2.2  bouyer 	printf("\n");
     98  1.2.2.2  bouyer 	config_search(obio_search, self, ca);
     99  1.2.2.2  bouyer }
    100  1.2.2.2  bouyer 
    101  1.2.2.2  bouyer static int
    102  1.2.2.2  bouyer obio_search(parent, cf, aux)
    103  1.2.2.2  bouyer 	struct device *parent;
    104  1.2.2.2  bouyer 	struct cfdata *cf;
    105  1.2.2.2  bouyer 	void *aux;
    106  1.2.2.2  bouyer {
    107  1.2.2.2  bouyer 	struct confargs *ca = aux;
    108  1.2.2.2  bouyer 
    109  1.2.2.2  bouyer 	ca->ca_addr = cf->cf_addr;
    110  1.2.2.2  bouyer 	ca->ca_name = cf->cf_driver->cd_name;
    111  1.2.2.2  bouyer 
    112  1.2.2.2  bouyer 	if ((*cf->cf_attach->ca_match)(parent, cf, ca) != 0)
    113  1.2.2.2  bouyer 		config_attach(parent, cf, ca, obio_print);
    114  1.2.2.2  bouyer 
    115  1.2.2.2  bouyer 	return 0;
    116  1.2.2.2  bouyer }
    117  1.2.2.2  bouyer 
    118  1.2.2.2  bouyer /*
    119  1.2.2.2  bouyer  * Print out the confargs.  The (parent) name is non-NULL
    120  1.2.2.2  bouyer  * when there was no match found by config_found().
    121  1.2.2.2  bouyer  */
    122  1.2.2.2  bouyer static int
    123  1.2.2.2  bouyer obio_print(args, name)
    124  1.2.2.2  bouyer 	void *args;
    125  1.2.2.2  bouyer 	const char *name;
    126  1.2.2.2  bouyer {
    127  1.2.2.2  bouyer 	struct confargs *ca = args;
    128  1.2.2.2  bouyer 
    129  1.2.2.2  bouyer 	if (name)
    130  1.2.2.2  bouyer 		return(QUIET);
    131  1.2.2.2  bouyer 
    132  1.2.2.2  bouyer 	if (ca->ca_addr != -1)
    133  1.2.2.2  bouyer 		printf(" addr 0x%x", ca->ca_addr);
    134  1.2.2.2  bouyer 
    135  1.2.2.2  bouyer 	return(UNCONF);
    136  1.2.2.2  bouyer }
    137  1.2.2.2  bouyer 
    138  1.2.2.2  bouyer void
    139  1.2.2.2  bouyer obio_intr_establish(bst, level, pri, flags, func, arg)
    140  1.2.2.2  bouyer 	bus_space_tag_t bst;
    141  1.2.2.2  bouyer 	int level;
    142  1.2.2.2  bouyer 	int pri;
    143  1.2.2.2  bouyer 	int flags;
    144  1.2.2.2  bouyer 	int (*func) __P((void *));
    145  1.2.2.2  bouyer 	void *arg;
    146  1.2.2.2  bouyer {
    147  1.2.2.2  bouyer 	(*platform.intr_establish)(level, func, arg);
    148  1.2.2.2  bouyer }
    149