xref: /netbsd-src/sys/arch/arm/ixp12x0/ixpsip.c (revision e5548b402ae4c44fb816de42c7bba9581ce23ef5)
1 /*	$NetBSD: ixpsip.c,v 1.10 2005/12/11 12:16:51 christos 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 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: ixpsip.c,v 1.10 2005/12/11 12:16:51 christos Exp $");
38 
39 /*
40  * Slow peripheral bus of ixp12x0 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/ixp12x0/ixp12x0var.h>
51 #include <arm/ixp12x0/ixpsipvar.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 *,
58 			      const int *, void *);
59 static int	ixpsip_print(void *, const char *);
60 
61 CFATTACH_DECL(ixpsip, sizeof(struct ixpsip_softc),
62     ixpsip_match, ixpsip_attach, NULL, NULL);
63 
64 int
65 ixpsip_match(struct device *parent, struct cfdata *cf, void *aux)
66 {
67 	return (1);
68 }
69 
70 void
71 ixpsip_attach(struct device *parent, struct device *self, void *aux)
72 {
73 	struct ixpsip_softc *sc = (void *) self;
74 	sc->sc_iot = &ixp12x0_bs_tag;
75 
76 	printf("\n");
77 
78 	/*
79 	 *  Attach each devices
80 	 */
81 	config_search_ia(ixpsip_search, self, "ixpsip", NULL);
82 }
83 
84 int
85 ixpsip_search(parent, cf, ldesc, aux)
86 	struct device *parent;
87 	struct cfdata *cf;
88 	const int *ldesc;
89 	void *aux;
90 {
91 	struct ixpsip_softc *sc = (struct ixpsip_softc *)parent;
92 	struct ixpsip_attach_args sa;
93 
94 	sa.sa_iot = sc->sc_iot;
95 	sa.sa_addr = cf->cf_loc[IXPSIPCF_ADDR];
96 	sa.sa_size = cf->cf_loc[IXPSIPCF_SIZE];
97 	sa.sa_intr = cf->cf_loc[IXPSIPCF_INTR];
98 
99 	if (config_match(parent, cf, &sa) > 0)
100 		config_attach(parent, cf, &sa, ixpsip_print);
101 
102 	return (0);
103 }
104 
105 static int
106 ixpsip_print(aux, name)
107 	void *aux;
108 	const char *name;
109 {
110         struct ixpsip_attach_args *sa = (struct ixpsip_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(" intr %d", sa->sa_intr);
118 
119 	return (UNCONF);
120 }
121