1 /* $OpenBSD: pchb.c,v 1.17 2023/03/08 04:43:07 guenther Exp $ */
2 /* $NetBSD: pchb.c,v 1.4 2000/01/25 07:19:11 tsubai Exp $ */
3
4 /*-
5 * Copyright (c) 1996 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Jason R. Thorpe.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/device.h>
36 #include <sys/rwlock.h>
37
38 #include <machine/bus.h>
39
40 #include <dev/pci/pcivar.h>
41 #include <dev/pci/pcireg.h>
42 #include <dev/pci/pcidevs.h>
43
44 #include <dev/pci/agpvar.h>
45
46 #include "agp.h"
47
48 int pchbmatch(struct device *, void *, void *);
49 void pchbattach(struct device *, struct device *, void *);
50
51 const struct cfattach pchb_ca = {
52 sizeof(struct device), pchbmatch, pchbattach
53 };
54
55 struct cfdriver pchb_cd = {
56 NULL, "pchb", DV_DULL
57 };
58
59 int
pchbmatch(struct device * parent,void * cf,void * aux)60 pchbmatch(struct device *parent, void *cf, void *aux)
61 {
62 struct pci_attach_args *pa = aux;
63
64 /*
65 * Match all known PCI host chipsets.
66 */
67 switch (PCI_VENDOR(pa->pa_id)) {
68 case PCI_VENDOR_APPLE:
69 switch (PCI_PRODUCT(pa->pa_id)) {
70 case PCI_PRODUCT_APPLE_BANDIT:
71 case PCI_PRODUCT_APPLE_UNINORTH:
72 case PCI_PRODUCT_APPLE_UNINORTHETH:
73 case PCI_PRODUCT_APPLE_UNINORTH_AGP:
74 case PCI_PRODUCT_APPLE_PANGEA:
75 case PCI_PRODUCT_APPLE_PANGEA_PCI:
76 case PCI_PRODUCT_APPLE_PANGEA_AGP:
77 case PCI_PRODUCT_APPLE_UNINORTH2:
78 case PCI_PRODUCT_APPLE_UNINORTH2ETH:
79 case PCI_PRODUCT_APPLE_UNINORTH2_AGP:
80 case PCI_PRODUCT_APPLE_UNINORTH_AGP3:
81 case PCI_PRODUCT_APPLE_UNINORTH5:
82 case PCI_PRODUCT_APPLE_UNINORTH6:
83 case PCI_PRODUCT_APPLE_SHASTA_HT:
84 case PCI_PRODUCT_APPLE_K2:
85 case PCI_PRODUCT_APPLE_INTREPID2_AGP:
86 case PCI_PRODUCT_APPLE_INTREPID2_PCI1:
87 case PCI_PRODUCT_APPLE_INTREPID2_PCI2:
88 case PCI_PRODUCT_APPLE_U3_AGP:
89 case PCI_PRODUCT_APPLE_U3L_AGP:
90 case PCI_PRODUCT_APPLE_K2_AGP:
91 return (1);
92 }
93 break;
94
95 case PCI_VENDOR_MOT:
96 switch (PCI_PRODUCT(pa->pa_id)) {
97 case PCI_PRODUCT_MOT_MPC106:
98 return (1);
99 }
100 break;
101 }
102
103 return (0);
104 }
105
106 void
pchbattach(struct device * parent,struct device * self,void * aux)107 pchbattach(struct device *parent, struct device *self, void *aux)
108 {
109 #if NAGP > 0
110 struct pci_attach_args *pa = aux;
111 #endif /* NAGP > 0 */
112
113 printf("\n");
114
115 #if NAGP > 0
116 if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP,
117 NULL, NULL) != 0) {
118 struct agp_attach_args aa;
119 aa.aa_busname = "agp";
120 aa.aa_pa = pa;
121
122 config_found(self, &aa, agpdev_print);
123 }
124 #endif /* NAGP > 0 */
125 }
126