Home | History | Annotate | Line # | Download | only in xscale
ixp425_sip.c revision 1.6
      1 /*	$NetBSD: ixp425_sip.c,v 1.6 2003/11/16 12:41:03 scw Exp $ */
      2 
      3 /*
      4  * Copyright (c) 2003
      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/cdefs.h>
     37 __KERNEL_RCSID(0, "$NetBSD: ixp425_sip.c,v 1.6 2003/11/16 12:41:03 scw Exp $");
     38 
     39 /*
     40  * Slow peripheral bus of IXP425 Processor
     41  */
     42 
     43 #include <sys/param.h>
     44 #include <sys/systm.h>
     45 #include <sys/device.h>
     46 
     47 #include <machine/autoconf.h>
     48 #include <machine/bus.h>
     49 
     50 #include <arm/xscale/ixp425var.h>
     51 #include <arm/xscale/ixp425_sipvar.h>
     52 
     53 #include "locators.h"
     54 
     55 static int	ixpsip_match(struct device *, struct cfdata *, void *);
     56 static void	ixpsip_attach(struct device *, struct device *, void *);
     57 static int	ixpsip_search(struct device *, struct cfdata *, void *);
     58 static int	ixpsip_print(void *, const char *);
     59 
     60 CFATTACH_DECL(ixpsip, sizeof(struct ixpsip_softc),
     61 		ixpsip_match, ixpsip_attach, NULL, NULL);
     62 
     63 struct ixpsip_softc *ixpsip_softc;
     64 
     65 int
     66 ixpsip_match(struct device *parent, struct cfdata *cf, void *aux)
     67 {
     68 	return (1);
     69 }
     70 
     71 void
     72 ixpsip_attach(struct device *parent, struct device *self, void *aux)
     73 {
     74 	struct ixpsip_softc *sc = (void *) self;
     75 	sc->sc_iot = &ixp425_bs_tag;
     76 
     77 	ixpsip_softc = sc;
     78 
     79 	printf("\n");
     80 
     81 	if (bus_space_map(sc->sc_iot, IXP425_EXP_HWBASE, IXP425_EXP_SIZE,
     82 	    0, &sc->sc_ioh)) {
     83 		printf("%s: Can't map expansion bus control registers!\n",
     84 		    sc->sc_dev.dv_xname);
     85 		return;
     86 	}
     87 
     88 	/*
     89 	 *  Attach each devices
     90 	 */
     91 	config_search(ixpsip_search, self, NULL);
     92 }
     93 
     94 int
     95 ixpsip_search(struct device *parent, struct cfdata *cf, void *aux)
     96 {
     97 	struct ixpsip_softc *sc = (struct ixpsip_softc *)parent;
     98 	struct ixpsip_attach_args sa;
     99 
    100 	sa.sa_iot = sc->sc_iot;
    101 	sa.sa_addr = cf->cf_loc[IXPSIPCF_ADDR];
    102 	sa.sa_size = cf->cf_loc[IXPSIPCF_SIZE];
    103 	sa.sa_index = cf->cf_loc[IXPSIPCF_INDEX];
    104 	sa.sa_intr = cf->cf_loc[IXPSIPCF_INTR];
    105 
    106 	if (config_match(parent, cf, &sa) > 0)
    107 		config_attach(parent, cf, &sa, ixpsip_print);
    108 
    109 	return (0);
    110 }
    111 
    112 static int
    113 ixpsip_print(void *aux, const char *name)
    114 {
    115         struct ixpsip_attach_args *sa = (struct ixpsip_attach_args*)aux;
    116 
    117 	if (sa->sa_size)
    118 		aprint_normal(" addr 0x%lx", sa->sa_addr);
    119 	if (sa->sa_size > 1)
    120 		aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
    121 	if (sa->sa_index > 1)
    122 		aprint_normal(" index %d", sa->sa_index);
    123 	if (sa->sa_intr > 1)
    124 		aprint_normal(" intr %d", sa->sa_intr);
    125 
    126 	return (UNCONF);
    127 }
    128