plb.c revision 1.3 1 /* $NetBSD: plb.c,v 1.3 2002/08/23 15:01:08 scw Exp $ */
2
3 /*
4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved.
6 *
7 * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
23 * written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 */
37
38 /*
39 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 * 1. Redistributions of source code must retain the above copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. All advertising materials mentioning features or use of this software
50 * must display the following acknowledgement:
51 * This product includes software developed by Christopher G. Demetriou
52 * for the NetBSD Project.
53 * 4. The name of the author may not be used to endorse or promote products
54 * derived from this software without specific prior written permission
55 *
56 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
57 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
58 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
59 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
60 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
62 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
63 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
64 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
65 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
66 */
67
68 #include "locators.h"
69
70 #include <sys/param.h>
71 #include <sys/systm.h>
72 #include <sys/device.h>
73 #include <sys/extent.h>
74 #include <sys/malloc.h>
75
76 #define _IBM4XX_BUS_DMA_PRIVATE
77 #include <powerpc/ibm4xx/dev/plbvar.h>
78 #include <powerpc/ibm4xx/ibm405gp.h>
79
80 /*
81 * The devices that attach to the processor local bus on the 405GP cpu.
82 */
83 const struct plb_dev plb_devs [] = {
84 { "cpu", },
85 { "ecc", },
86 { "opb", },
87 { "pchb", },
88 { NULL }
89 };
90
91 static int plb_match(struct device *, struct cfdata *, void *);
92 static void plb_attach(struct device *, struct device *, void *);
93 static int plb_submatch(struct device *, struct cfdata *, void *);
94 static int plb_print(void *, const char *);
95
96 struct cfattach plb_ca = {
97 sizeof(struct device), plb_match, plb_attach
98 };
99
100
101 /*
102 * Probe for the plb; always succeeds.
103 */
104 static int
105 plb_match(struct device *parent, struct cfdata *cf, void *aux)
106 {
107
108 return (1);
109 }
110
111 static int
112 plb_submatch(struct device *parent, struct cfdata *cf, void *aux)
113 {
114
115 return ((*cf->cf_attach->ca_match)(parent, cf, aux));
116 }
117
118 /*
119 * Attach the processor local bus.
120 */
121 static void
122 plb_attach(struct device *parent, struct device *self, void *aux)
123 {
124 struct plb_attach_args paa;
125 struct plb_dev *local_plb_devs = aux;
126 int i;
127
128 printf("\n");
129
130 for (i = 0; plb_devs[i].plb_name != NULL; i++) {
131 paa.plb_name = plb_devs[i].plb_name;
132 paa.plb_bt = ibm4xx_make_bus_space_tag(0, 0);
133 paa.plb_dmat = &ibm4xx_default_bus_dma_tag;
134 paa.plb_irq = PLBCF_IRQ_DEFAULT;
135
136 (void) config_found_sm(self, &paa, plb_print, plb_submatch);
137 }
138
139 while (local_plb_devs && local_plb_devs->plb_name != NULL) {
140 paa.plb_name = local_plb_devs->plb_name;
141 paa.plb_bt = ibm4xx_make_bus_space_tag(0, 0);
142 paa.plb_dmat = &ibm4xx_default_bus_dma_tag;
143 paa.plb_irq = PLBCF_IRQ_DEFAULT;
144
145 (void) config_found_sm(self, &paa, plb_print, plb_submatch);
146 local_plb_devs++;
147 }
148 }
149
150 static int
151 plb_print(void *aux, const char *pnp)
152 {
153 struct plb_attach_args *paa = aux;
154
155 if (pnp)
156 printf("%s at %s", paa->plb_name, pnp);
157 if (paa->plb_irq != PLBCF_IRQ_DEFAULT)
158 printf(" irq %d", paa->plb_irq);
159
160 return (UNCONF);
161 }
162