Home | History | Annotate | Line # | Download | only in eb7500atx
rsbus.c revision 1.3
      1  1.3  drochner /* $NetBSD: rsbus.c,v 1.3 2005/08/26 13:19:34 drochner Exp $ */
      2  1.1     chris 
      3  1.1     chris /*
      4  1.1     chris  * Copyright (c) 2002
      5  1.1     chris  *	Ichiro FUKUHARA <ichiro (at) ichiro.org>.
      6  1.1     chris  * All rights reserved.
      7  1.1     chris  *
      8  1.1     chris  * Redistribution and use in source and binary forms, with or without
      9  1.1     chris  * modification, are permitted provided that the following conditions
     10  1.1     chris  * are met:
     11  1.1     chris  * 1. Redistributions of source code must retain the above copyright
     12  1.1     chris  *    notice, this list of conditions and the following disclaimer.
     13  1.1     chris  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1     chris  *    notice, this list of conditions and the following disclaimer in the
     15  1.1     chris  *    documentation and/or other materials provided with the distribution.
     16  1.1     chris  * 3. All advertising materials mentioning features or use of this software
     17  1.1     chris  *    must display the following acknowledgement:
     18  1.1     chris  *	This product includes software developed by Ichiro FUKUHARA.
     19  1.1     chris  * 4. The name of the company nor the name of the author may be used to
     20  1.1     chris  *    endorse or promote products derived from this software without specific
     21  1.1     chris  *    prior written permission.
     22  1.1     chris  *
     23  1.1     chris  * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
     24  1.1     chris  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25  1.1     chris  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.1     chris  * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
     27  1.1     chris  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.1     chris  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.1     chris  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1     chris  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1     chris  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1     chris  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1     chris  * SUCH DAMAGE.
     34  1.1     chris  */
     35  1.1     chris 
     36  1.1     chris #include <sys/param.h>
     37  1.1     chris 
     38  1.3  drochner __KERNEL_RCSID(0, "$NetBSD: rsbus.c,v 1.3 2005/08/26 13:19:34 drochner Exp $");
     39  1.1     chris 
     40  1.1     chris #include <sys/param.h>
     41  1.1     chris #include <sys/systm.h>
     42  1.1     chris #include <sys/device.h>
     43  1.1     chris 
     44  1.1     chris #include <machine/bus.h>
     45  1.1     chris 
     46  1.1     chris #include <acorn32/eb7500atx/rsbus.h>
     47  1.1     chris 
     48  1.1     chris #include "locators.h"
     49  1.1     chris 
     50  1.1     chris extern struct bus_space rsbus_bs_tag;
     51  1.1     chris 
     52  1.1     chris /* Declare prototypes */
     53  1.1     chris 
     54  1.1     chris static int	rsbus_match(struct device *, struct cfdata *, void *);
     55  1.1     chris static void	rsbus_attach(struct device *, struct device *, void *);
     56  1.1     chris static int	rsbus_print(void *, const char *);
     57  1.2  drochner static int	rsbus_search(struct device *, struct cfdata *,
     58  1.3  drochner 			     const int *, void *);
     59  1.1     chris 
     60  1.1     chris CFATTACH_DECL(rsbus, sizeof(struct rsbus_softc),
     61  1.1     chris     rsbus_match, rsbus_attach, NULL, NULL);
     62  1.1     chris 
     63  1.1     chris static int
     64  1.1     chris rsbus_match(parent, cf, aux)
     65  1.1     chris 	struct device *parent;
     66  1.1     chris 	struct cfdata *cf;
     67  1.1     chris 	void *aux;
     68  1.1     chris {
     69  1.1     chris 	return(1);
     70  1.1     chris }
     71  1.1     chris 
     72  1.1     chris static void
     73  1.1     chris rsbus_attach(struct device *parent, struct device *self, void *aux)
     74  1.1     chris {
     75  1.1     chris 	struct rsbus_softc *sc = (void *) self;
     76  1.1     chris 	sc->sc_iot = &rsbus_bs_tag;
     77  1.1     chris 
     78  1.1     chris 	printf("\n");
     79  1.1     chris 
     80  1.1     chris 	/*
     81  1.1     chris 	 *  Attach each devices
     82  1.1     chris 	 */
     83  1.2  drochner 	config_search_ia(rsbus_search, self, "rsbus", NULL);
     84  1.1     chris }
     85  1.1     chris 
     86  1.1     chris static int
     87  1.2  drochner rsbus_search(parent, cf, ldesc, aux)
     88  1.1     chris 	struct device *parent;
     89  1.1     chris 	struct cfdata *cf;
     90  1.3  drochner 	const int *ldesc;
     91  1.1     chris 	void *aux;
     92  1.1     chris {
     93  1.1     chris 	struct rsbus_softc *sc = (struct rsbus_softc *)parent;
     94  1.1     chris 	struct rsbus_attach_args sa;
     95  1.1     chris 
     96  1.1     chris 	sa.sa_iot = sc->sc_iot;
     97  1.1     chris 	sa.sa_addr = cf->cf_loc[RSBUSCF_ADDR];
     98  1.1     chris 	sa.sa_size = cf->cf_loc[RSBUSCF_SIZE];
     99  1.1     chris 	sa.sa_intr = cf->cf_loc[RSBUSCF_IRQ];
    100  1.1     chris 
    101  1.1     chris 	if (config_match(parent, cf, &sa) > 0)
    102  1.1     chris 		config_attach(parent, cf, &sa, rsbus_print);
    103  1.1     chris 
    104  1.1     chris 	return (0);
    105  1.1     chris }
    106  1.1     chris 
    107  1.1     chris static int
    108  1.1     chris rsbus_print(aux, name)
    109  1.1     chris 	void *aux;
    110  1.1     chris 	const char *name;
    111  1.1     chris {
    112  1.1     chris         struct rsbus_attach_args *sa = (struct rsbus_attach_args*)aux;
    113  1.1     chris 
    114  1.1     chris 	if (sa->sa_size)
    115  1.1     chris 		aprint_normal(" addr 0x%lx", sa->sa_addr);
    116  1.1     chris 	if (sa->sa_size > 1)
    117  1.1     chris 		aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
    118  1.1     chris 	if (sa->sa_intr > 1)
    119  1.1     chris 		aprint_normal(" irq %d", sa->sa_intr);
    120  1.1     chris 
    121  1.1     chris 	return (UNCONF);
    122  1.1     chris }
    123  1.1     chris 
    124