pcib.c revision 1.10 1 /* $NetBSD: pcib.c,v 1.10 2009/03/14 14:45:58 dsl Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 1998 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 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * from: i386/pci/pcib.c,v 1.12
32 */
33
34 #include <sys/cdefs.h>
35 __KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.10 2009/03/14 14:45:58 dsl Exp $");
36
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/device.h>
40
41 #include <machine/bus.h>
42
43 #include <dev/isa/isavar.h>
44
45 #include <dev/pci/pcivar.h>
46 #include <dev/pci/pcireg.h>
47
48 #include <dev/pci/pcidevs.h>
49
50 #include "isadma.h"
51
52 int pcibmatch(struct device *, struct cfdata *, void *);
53 void pcibattach(struct device *, struct device *, void *);
54
55 CFATTACH_DECL(pcib, sizeof(struct device),
56 pcibmatch, pcibattach, NULL, NULL);
57
58 void pcib_callback(struct device *);
59
60 int
61 pcibmatch(parent, match, aux)
62 struct device *parent;
63 struct cfdata *match;
64 void *aux;
65 {
66 struct pci_attach_args *pa = aux;
67
68 /*
69 * Match tested PCI-ISA bridges.
70 */
71 switch (PCI_VENDOR(pa->pa_id)) {
72 case PCI_VENDOR_ALI:
73 switch (PCI_PRODUCT(pa->pa_id)) {
74 case PCI_PRODUCT_ALI_M1543:
75 return (1);
76 }
77 break;
78 }
79
80 return (0);
81 }
82
83 void
84 pcibattach(parent, self, aux)
85 struct device *parent, *self;
86 void *aux;
87 {
88 struct pci_attach_args *pa = aux;
89 char devinfo[256];
90
91 printf("\n");
92
93 /*
94 * Just print out a description and set the ISA bus
95 * callback.
96 */
97 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
98 printf("%s: %s (rev. 0x%02x)\n", self->dv_xname, devinfo,
99 PCI_REVISION(pa->pa_class));
100
101 /* Set the ISA bus callback */
102 config_defer(self, pcib_callback);
103 }
104
105 void
106 pcib_callback(self)
107 struct device *self;
108 {
109 struct isabus_attach_args iba;
110
111 /*
112 * Attach the ISA bus behind this bridge.
113 */
114 memset(&iba, 0, sizeof(iba));
115 iba.iba_iot = &isa_io_bs_tag;
116 iba.iba_memt = &isa_mem_bs_tag;
117 #if NISADMA > 0
118 iba.iba_dmat = &isa_bus_dma_tag;
119 #endif
120 config_found_ia(self, "isabus", &iba, isabusprint);
121 }
122