1 /* $NetBSD: ixpsip.c,v 1.4 2002/10/02 05:02:30 thorpej Exp $ */ 2 3 /* 4 * Copyright (c) 2002 5 * Ichiro FUKUHARA <ichiro@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 /* 37 * Slow peripheral bus of ixp12x0 Processor 38 */ 39 40 #include <sys/param.h> 41 #include <sys/systm.h> 42 #include <sys/device.h> 43 44 #include <machine/autoconf.h> 45 #include <machine/bus.h> 46 47 #include <arm/ixp12x0/ixpsipvar.h> 48 49 #include "locators.h" 50 51 static int ixpsip_match(struct device *, struct cfdata *, void *); 52 static void ixpsip_attach(struct device *, struct device *, void *); 53 static int ixpsip_search(struct device *, struct cfdata *, void *); 54 static int ixpsip_print(void *, const char *); 55 56 CFATTACH_DECL(ixpsip, sizeof(struct ixpsip_softc), 57 ixpsip_match, ixpsip_attach, NULL, NULL); 58 59 extern struct bus_space ixpsip_bs_tag; 60 61 int 62 ixpsip_match(struct device *parent, struct cfdata *cf, void *aux) 63 { 64 return (1); 65 } 66 67 void 68 ixpsip_attach(struct device *parent, struct device *self, void *aux) 69 { 70 struct ixpsip_softc *sc = (void *) self; 71 sc->sc_iot = &ixpsip_bs_tag; 72 73 printf("\n"); 74 75 /* 76 * Attach each devices 77 */ 78 config_search(ixpsip_search, self, NULL); 79 } 80 81 int 82 ixpsip_search(parent, cf, aux) 83 struct device *parent; 84 struct cfdata *cf; 85 void *aux; 86 { 87 struct ixpsip_softc *sc = (struct ixpsip_softc *)parent; 88 struct ixpsip_attach_args sa; 89 90 sa.sa_iot = sc->sc_iot; 91 sa.sa_addr = cf->cf_loc[IXPSIPCF_ADDR]; 92 sa.sa_size = cf->cf_loc[IXPSIPCF_SIZE]; 93 sa.sa_intr = cf->cf_loc[IXPSIPCF_INTR]; 94 95 if (config_match(parent, cf, &sa) > 0) 96 config_attach(parent, cf, &sa, ixpsip_print); 97 98 return (0); 99 } 100 101 static int 102 ixpsip_print(aux, name) 103 void *aux; 104 const char *name; 105 { 106 struct ixpsip_attach_args *sa = (struct ixpsip_attach_args*)aux; 107 108 if (sa->sa_size) 109 printf(" addr 0x%lx", sa->sa_addr); 110 if (sa->sa_size > 1) 111 printf("-0x%lx", sa->sa_addr + sa->sa_size - 1); 112 if (sa->sa_intr > 1) 113 printf(" intr %d", sa->sa_intr); 114 115 return (UNCONF); 116 } 117