xref: /openbsd-src/sys/arch/macppc/pci/pchb.c (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1 /*	$OpenBSD: pchb.c,v 1.14 2014/03/26 14:41:41 mpi 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/types.h>
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
37 #include <sys/rwlock.h>
38 
39 #include <machine/bus.h>
40 
41 #include <dev/pci/pcivar.h>
42 #include <dev/pci/pcireg.h>
43 #include <dev/pci/pcidevs.h>
44 
45 #include <dev/pci/agpvar.h>
46 
47 #include "agp.h"
48 
49 int	pchbmatch(struct device *, void *, void *);
50 void	pchbattach(struct device *, struct device *, void *);
51 
52 struct cfattach pchb_ca = {
53 	sizeof(struct device), pchbmatch, pchbattach
54 };
55 
56 struct cfdriver pchb_cd = {
57 	NULL, "pchb", DV_DULL
58 };
59 
60 int
61 pchbmatch(struct device *parent, void *cf, void *aux)
62 {
63 	struct pci_attach_args *pa = aux;
64 
65 	/*
66 	 * Match all known PCI host chipsets.
67 	 */
68 	switch (PCI_VENDOR(pa->pa_id)) {
69 	case PCI_VENDOR_APPLE:
70 		switch (PCI_PRODUCT(pa->pa_id)) {
71 		case PCI_PRODUCT_APPLE_BANDIT:
72 		case PCI_PRODUCT_APPLE_UNINORTH:
73 		case PCI_PRODUCT_APPLE_UNINORTHETH:
74 		case PCI_PRODUCT_APPLE_UNINORTH_AGP:
75 		case PCI_PRODUCT_APPLE_PANGEA:
76 		case PCI_PRODUCT_APPLE_PANGEA_PCI:
77 		case PCI_PRODUCT_APPLE_PANGEA_AGP:
78 		case PCI_PRODUCT_APPLE_UNINORTH2:
79 		case PCI_PRODUCT_APPLE_UNINORTH2ETH:
80 		case PCI_PRODUCT_APPLE_UNINORTH2_AGP:
81 		case PCI_PRODUCT_APPLE_UNINORTH_AGP3:
82 		case PCI_PRODUCT_APPLE_UNINORTH5:
83 		case PCI_PRODUCT_APPLE_UNINORTH6:
84 		case PCI_PRODUCT_APPLE_SHASTA_HT:
85 		case PCI_PRODUCT_APPLE_K2:
86 		case PCI_PRODUCT_APPLE_INTREPID2_AGP:
87 		case PCI_PRODUCT_APPLE_INTREPID2_PCI1:
88 		case PCI_PRODUCT_APPLE_INTREPID2_PCI2:
89 		case PCI_PRODUCT_APPLE_U3_AGP:
90 		case PCI_PRODUCT_APPLE_U3L_AGP:
91 		case PCI_PRODUCT_APPLE_K2_AGP:
92 			return (1);
93 		}
94 		break;
95 
96 	case PCI_VENDOR_MOT:
97 		switch (PCI_PRODUCT(pa->pa_id)) {
98 		case PCI_PRODUCT_MOT_MPC106:
99 			return (1);
100 		}
101 		break;
102 	}
103 
104 	return (0);
105 }
106 
107 /*ARGSUSED*/
108 void
109 pchbattach(struct device *parent, struct device  *self, void *aux)
110 {
111 #if NAGP > 0
112 	struct pci_attach_args *pa = aux;
113 #endif /* NAGP > 0 */
114 
115 	printf("\n");
116 
117 #if NAGP > 0
118 	if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_AGP,
119 	    NULL, NULL) != 0) {
120 		struct agp_attach_args	aa;
121 		aa.aa_busname = "agp";
122 		aa.aa_pa = pa;
123 
124 		config_found(self, &aa, agpdev_print);
125 	}
126 #endif /* NAGP > 0 */
127 }
128