pcib.c revision 1.2 1 /* $NetBSD: pcib.c,v 1.2 2001/06/01 15:20:06 thorpej Exp $ */
2
3 /*-
4 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
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> /* RCS ID & Copyright macro defns */
40
41 __KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.2 2001/06/01 15:20:06 thorpej Exp $");
42
43 #include "opt_algor_p5064.h"
44 #include "opt_algor_p6032.h"
45
46 #include <sys/param.h>
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
49 #include <sys/device.h>
50 #include <sys/malloc.h>
51
52 #include <machine/intr.h>
53 #include <machine/bus.h>
54
55 #include <dev/isa/isavar.h>
56
57 #include <dev/pci/pcireg.h>
58 #include <dev/pci/pcivar.h>
59 #include <dev/pci/pcidevs.h>
60
61 #ifdef ALGOR_P5064
62 #include <algor/algor/algor_p5064var.h>
63 #endif
64
65 #ifdef ALGOR_P6032
66 #include <algor/algor/algor_p6032var.h>
67 #endif
68
69
70 struct pcib_softc {
71 struct device sc_dev;
72 };
73
74 int pcib_match(struct device *, struct cfdata *, void *);
75 void pcib_attach(struct device *, struct device *, void *);
76
77 struct cfattach pcib_ca = {
78 sizeof(struct pcib_softc), pcib_match, pcib_attach,
79 };
80
81 int pcib_print(void *, const char *pnp);
82 void pcib_isa_attach_hook(struct device *, struct device *,
83 struct isabus_attach_args *);
84
85 void pcib_bridge_callback(struct device *);
86
87 int
88 pcib_match(struct device *parent, struct cfdata *match, void *aux)
89 {
90 struct pci_attach_args *pa = aux;
91
92 if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
93 PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_ISA)
94 return (1);
95
96 return (0);
97 }
98
99 void
100 pcib_attach(struct device *parent, struct device *self, void *aux)
101 {
102 struct pci_attach_args *pa = aux;
103 char devinfo[256];
104
105 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
106 printf(": %s (rev. 0x%02x)\n", devinfo,
107 PCI_REVISION(pa->pa_class));
108
109 config_defer(self, pcib_bridge_callback);
110 }
111
112 void
113 pcib_bridge_callback(self)
114 struct device *self;
115 {
116 struct pcib_softc *sc = (struct pcib_softc *)self;
117 struct isabus_attach_args iba;
118
119 memset(&iba, 0, sizeof(iba));
120
121 iba.iba_busname = "isa";
122 #if defined(ALGOR_P5064)
123 {
124 struct p5064_config *acp = &p5064_configuration;
125
126 iba.iba_iot = &acp->ac_iot;
127 iba.iba_memt = &acp->ac_memt;
128 iba.iba_dmat = &acp->ac_isa_dmat;
129 iba.iba_ic = &acp->ac_ic;
130 }
131 #elif defined(ALGOR_P6032)
132 {
133 /* XXX */
134 }
135 #endif
136
137 iba.iba_ic->ic_attach_hook = pcib_isa_attach_hook;
138
139 (void) config_found(&sc->sc_dev, &iba, pcib_print);
140 }
141
142 int
143 pcib_print(void *aux, const char *pnp)
144 {
145 struct isabus_attach_args *iba;
146
147 if (pnp)
148 printf("%s at %s", iba->iba_busname, pnp);
149 return (UNCONF);
150 }
151
152 void
153 pcib_isa_attach_hook(struct device *parent, struct device *self,
154 struct isabus_attach_args *iba)
155 {
156
157 /* Nothing to do. */
158 }
159