sio.c revision 1.1 1 1.1 cgd /* $NetBSD: sio.c,v 1.1 1995/06/28 01:26:07 cgd Exp $ */
2 1.1 cgd
3 1.1 cgd /*
4 1.1 cgd * Copyright (c) 1994, 1995 Carnegie-Mellon University.
5 1.1 cgd * All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Author: Chris G. Demetriou
8 1.1 cgd *
9 1.1 cgd * Permission to use, copy, modify and distribute this software and
10 1.1 cgd * its documentation is hereby granted, provided that both the copyright
11 1.1 cgd * notice and this permission notice appear in all copies of the
12 1.1 cgd * software, derivative works or modified versions, and any portions
13 1.1 cgd * thereof, and that both notices appear in supporting documentation.
14 1.1 cgd *
15 1.1 cgd * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 1.1 cgd * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 1.1 cgd * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 1.1 cgd *
19 1.1 cgd * Carnegie Mellon requests users of this software to return to
20 1.1 cgd *
21 1.1 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 1.1 cgd * School of Computer Science
23 1.1 cgd * Carnegie Mellon University
24 1.1 cgd * Pittsburgh PA 15213-3890
25 1.1 cgd *
26 1.1 cgd * any improvements or extensions that they make and grant Carnegie the
27 1.1 cgd * rights to redistribute these changes.
28 1.1 cgd */
29 1.1 cgd
30 1.1 cgd #include <sys/param.h>
31 1.1 cgd #include <sys/systm.h>
32 1.1 cgd #include <sys/kernel.h>
33 1.1 cgd #include <sys/device.h>
34 1.1 cgd
35 1.1 cgd #include <dev/pci/pcireg.h>
36 1.1 cgd #include <dev/pci/pcivar.h>
37 1.1 cgd #include <dev/pci/pcidevs.h>
38 1.1 cgd
39 1.1 cgd #include <machine/autoconf.h>
40 1.1 cgd
41 1.1 cgd int siomatch __P((struct device *, void *, void *));
42 1.1 cgd void sioattach __P((struct device *, struct device *, void *));
43 1.1 cgd
44 1.1 cgd struct cfdriver siocd = {
45 1.1 cgd NULL, "sio", siomatch, sioattach, DV_DULL, sizeof(struct device)
46 1.1 cgd };
47 1.1 cgd
48 1.1 cgd static int sioprint __P((void *, char *pnp));
49 1.1 cgd
50 1.1 cgd int
51 1.1 cgd siomatch(parent, match, aux)
52 1.1 cgd struct device *parent;
53 1.1 cgd void *match, *aux;
54 1.1 cgd {
55 1.1 cgd struct cfdata *cf = match;
56 1.1 cgd struct pci_attach_args *pa = aux;
57 1.1 cgd
58 1.1 cgd if (PCI_VENDOR(pa->pa_id) != PCI_VENDOR_INTEL ||
59 1.1 cgd PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_INTEL_SIO)
60 1.1 cgd return (0);
61 1.1 cgd
62 1.1 cgd return (1);
63 1.1 cgd }
64 1.1 cgd
65 1.1 cgd void
66 1.1 cgd sioattach(parent, self, aux)
67 1.1 cgd struct device *parent, *self;
68 1.1 cgd void *aux;
69 1.1 cgd {
70 1.1 cgd struct pci_attach_args *pa = aux;
71 1.1 cgd struct confargs nca;
72 1.1 cgd u_int rev;
73 1.1 cgd char *type;
74 1.1 cgd
75 1.1 cgd rev = pa->pa_class & 0xff;
76 1.1 cgd if (rev < 3) {
77 1.1 cgd type = "I";
78 1.1 cgd /* XXX PCI IRQ MAPPING FUNCTION */
79 1.1 cgd } else {
80 1.1 cgd type = "II";
81 1.1 cgd /* XXX PCI IRQ MAPPING FUNCTION */
82 1.1 cgd }
83 1.1 cgd printf(": Saturn %s PCI->ISA bridge (revision 0x%x)\n", type, rev);
84 1.1 cgd if (rev < 3)
85 1.1 cgd printf("%s: WARNING: SIO I SUPPORT UNTESTED\n",
86 1.1 cgd parent->dv_xname);
87 1.1 cgd
88 1.1 cgd /* attach the ISA bus that hangs off of it... */
89 1.1 cgd nca.ca_name = "isa";
90 1.1 cgd nca.ca_slot = 0;
91 1.1 cgd nca.ca_offset = 0;
92 1.1 cgd nca.ca_bus = NULL;
93 1.1 cgd if (!config_found(self, &nca, sioprint))
94 1.1 cgd panic("sioattach: couldn't attach ISA bus");
95 1.1 cgd }
96 1.1 cgd
97 1.1 cgd static int
98 1.1 cgd sioprint(aux, pnp)
99 1.1 cgd void *aux;
100 1.1 cgd char *pnp;
101 1.1 cgd {
102 1.1 cgd register struct confargs *ca = aux;
103 1.1 cgd
104 1.1 cgd if (pnp)
105 1.1 cgd printf("%s at %s", ca->ca_name, pnp);
106 1.1 cgd return (UNCONF);
107 1.1 cgd }
108