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