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