elb.c revision 1.2 1 /* $NetBSD: elb.c,v 1.2 2003/07/15 01:37:36 lukem 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/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: elb.c,v 1.2 2003/07/15 01:37:36 lukem Exp $");
41
42 #include <sys/param.h>
43 #include <sys/conf.h>
44 #include <sys/device.h>
45 #include <sys/systm.h>
46
47 #include <machine/explora.h>
48 #define _IBM4XX_BUS_DMA_PRIVATE
49 #include <machine/bus.h>
50
51 #include <powerpc/ibm4xx/dcr403cgx.h>
52
53 #include <evbppc/explora/dev/elbvar.h>
54
55 struct elb_dev {
56 const char *elb_name;
57 int elb_addr;
58 int elb_addr2;
59 int elb_irq;
60 };
61
62 static int elb_match(struct device *, struct cfdata *, void *);
63 static void elb_attach(struct device *, struct device *, void *);
64 static int elb_print(void *, const char *);
65
66 static struct elb_dev elb_devs[] = {
67 { "cpu", 0, 0, -1 },
68 { "pckbc", BASE_PCKBC, BASE_PCKBC2, 31 },
69 { "com", BASE_COM, 0, 30 },
70 { "lpt", BASE_LPT, 0, -1 },
71 { "fb", BASE_FB, BASE_FB2, -1 },
72 { "le", BASE_LE, 0, 28 },
73 };
74
75 CFATTACH_DECL(elb, sizeof(struct device),
76 elb_match, elb_attach, NULL, NULL);
77
78 /*
79 * Probe for the elb; always succeeds.
80 */
81 static int
82 elb_match(struct device *parent, struct cfdata *cf, void *aux)
83 {
84 return (1);
85 }
86
87 /*
88 * Attach the Explora local bus.
89 */
90 static void
91 elb_attach(struct device *parent, struct device *self, void *aux)
92 {
93 struct elb_attach_args eaa;
94 int i;
95
96 printf("\n");
97 for (i = 0; i < sizeof(elb_devs)/sizeof(elb_devs[0]); i++) {
98 eaa.elb_name = elb_devs[i].elb_name;
99 eaa.elb_bt = MAKE_BUS_TAG(elb_devs[i].elb_addr);
100 eaa.elb_dmat = &ibm4xx_default_bus_dma_tag;
101 eaa.elb_base = elb_devs[i].elb_addr;
102 eaa.elb_base2 = elb_devs[i].elb_addr2;
103 eaa.elb_irq = elb_devs[i].elb_irq;
104
105 (void) config_found_sm(self, &eaa, elb_print, NULL);
106 }
107 }
108
109 static int
110 elb_print(void *aux, const char *pnp)
111 {
112 struct elb_attach_args *eaa = aux;
113
114 if (pnp)
115 aprint_normal("%s at %s", eaa->elb_name, pnp);
116 if (eaa->elb_irq != -1)
117 aprint_normal(" irq %d", eaa->elb_irq);
118
119 return (UNCONF);
120 }
121