xref: /netbsd-src/sys/arch/evbppc/explora/dev/elb.c (revision 001c68bd94f75ce9270b69227c4199fbf34ee396)
1 /*	$NetBSD: elb.c,v 1.1 2003/03/11 10:57:57 hannken Exp $	*/
2 
3 /*-
4  * Copyright (c) 2003 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Juergen Hannken-Illjes.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *      This product includes software developed by the NetBSD
21  *      Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #include <sys/param.h>
40 #include <sys/conf.h>
41 #include <sys/device.h>
42 #include <sys/systm.h>
43 
44 #include <machine/explora.h>
45 #define _IBM4XX_BUS_DMA_PRIVATE
46 #include <machine/bus.h>
47 
48 #include <powerpc/ibm4xx/dcr403cgx.h>
49 
50 #include <evbppc/explora/dev/elbvar.h>
51 
52 struct elb_dev {
53 	const char *elb_name;
54 	int elb_addr;
55 	int elb_addr2;
56 	int elb_irq;
57 };
58 
59 static int	elb_match(struct device *, struct cfdata *, void *);
60 static void	elb_attach(struct device *, struct device *, void *);
61 static int	elb_print(void *, const char *);
62 
63 static struct elb_dev elb_devs[] = {
64 	{ "cpu",	0,		0,		-1 },
65 	{ "pckbc",	BASE_PCKBC,	BASE_PCKBC2,	31 },
66 	{ "com",	BASE_COM,	0,		30 },
67 	{ "lpt",	BASE_LPT,	0,		-1 },
68 	{ "fb",		BASE_FB,	BASE_FB2,	-1 },
69 	{ "le",		BASE_LE,	0,		28 },
70 };
71 
72 CFATTACH_DECL(elb, sizeof(struct device),
73     elb_match, elb_attach, NULL, NULL);
74 
75 /*
76  * Probe for the elb; always succeeds.
77  */
78 static int
79 elb_match(struct device *parent, struct cfdata *cf, void *aux)
80 {
81 	return (1);
82 }
83 
84 /*
85  * Attach the Explora local bus.
86  */
87 static void
88 elb_attach(struct device *parent, struct device *self, void *aux)
89 {
90 	struct elb_attach_args eaa;
91 	int i;
92 
93 	printf("\n");
94 	for (i = 0; i < sizeof(elb_devs)/sizeof(elb_devs[0]); i++) {
95 		eaa.elb_name = elb_devs[i].elb_name;
96 		eaa.elb_bt = MAKE_BUS_TAG(elb_devs[i].elb_addr);
97 		eaa.elb_dmat = &ibm4xx_default_bus_dma_tag;
98 		eaa.elb_base = elb_devs[i].elb_addr;
99 		eaa.elb_base2 = elb_devs[i].elb_addr2;
100 		eaa.elb_irq = elb_devs[i].elb_irq;
101 
102 		(void) config_found_sm(self, &eaa, elb_print, NULL);
103 	}
104 }
105 
106 static int
107 elb_print(void *aux, const char *pnp)
108 {
109 	struct elb_attach_args *eaa = aux;
110 
111 	if (pnp)
112 		aprint_normal("%s at %s", eaa->elb_name, pnp);
113 	if (eaa->elb_irq != -1)
114 		aprint_normal(" irq %d", eaa->elb_irq);
115 
116 	return (UNCONF);
117 }
118