pci_machdep.c revision 1.15.2.2 1 1.15.2.2 elric /* $NetBSD: pci_machdep.c,v 1.15.2.2 2001/07/16 00:55:18 elric Exp $ */
2 1.15.2.2 elric
3 1.15.2.2 elric /*
4 1.15.2.2 elric * Copyright (c) 1995, 1996 Carnegie-Mellon University.
5 1.15.2.2 elric * All rights reserved.
6 1.15.2.2 elric *
7 1.15.2.2 elric * Author: Chris G. Demetriou
8 1.15.2.2 elric *
9 1.15.2.2 elric * Permission to use, copy, modify and distribute this software and
10 1.15.2.2 elric * its documentation is hereby granted, provided that both the copyright
11 1.15.2.2 elric * notice and this permission notice appear in all copies of the
12 1.15.2.2 elric * software, derivative works or modified versions, and any portions
13 1.15.2.2 elric * thereof, and that both notices appear in supporting documentation.
14 1.15.2.2 elric *
15 1.15.2.2 elric * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 1.15.2.2 elric * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 1.15.2.2 elric * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 1.15.2.2 elric *
19 1.15.2.2 elric * Carnegie Mellon requests users of this software to return to
20 1.15.2.2 elric *
21 1.15.2.2 elric * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 1.15.2.2 elric * School of Computer Science
23 1.15.2.2 elric * Carnegie Mellon University
24 1.15.2.2 elric * Pittsburgh PA 15213-3890
25 1.15.2.2 elric *
26 1.15.2.2 elric * any improvements or extensions that they make and grant Carnegie the
27 1.15.2.2 elric * rights to redistribute these changes.
28 1.15.2.2 elric */
29 1.15.2.2 elric
30 1.15.2.2 elric /*
31 1.15.2.2 elric * Machine-specific functions for PCI autoconfiguration.
32 1.15.2.2 elric */
33 1.15.2.2 elric
34 1.15.2.2 elric #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
35 1.15.2.2 elric
36 1.15.2.2 elric __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.15.2.2 2001/07/16 00:55:18 elric Exp $");
37 1.15.2.2 elric
38 1.15.2.2 elric #include <sys/types.h>
39 1.15.2.2 elric #include <sys/param.h>
40 1.15.2.2 elric #include <sys/time.h>
41 1.15.2.2 elric #include <sys/systm.h>
42 1.15.2.2 elric #include <sys/errno.h>
43 1.15.2.2 elric #include <sys/device.h>
44 1.15.2.2 elric
45 1.15.2.2 elric #include <uvm/uvm_extern.h>
46 1.15.2.2 elric
47 1.15.2.2 elric #include <dev/isa/isavar.h>
48 1.15.2.2 elric #include <dev/pci/pcireg.h>
49 1.15.2.2 elric #include <dev/pci/pcivar.h>
50 1.15.2.2 elric #include <dev/pci/pcidevs.h>
51 1.15.2.2 elric
52 1.15.2.2 elric #include "vga_pci.h"
53 1.15.2.2 elric #if NVGA_PCI
54 1.15.2.2 elric #include <dev/ic/mc6845reg.h>
55 1.15.2.2 elric #include <dev/ic/pcdisplayvar.h>
56 1.15.2.2 elric #include <dev/pci/vga_pcivar.h>
57 1.15.2.2 elric #endif
58 1.15.2.2 elric
59 1.15.2.2 elric #include "tga.h"
60 1.15.2.2 elric #if NTGA
61 1.15.2.2 elric #include <dev/pci/tgavar.h>
62 1.15.2.2 elric #endif
63 1.15.2.2 elric
64 1.15.2.2 elric void
65 1.15.2.2 elric pci_display_console(iot, memt, pc, bus, device, function)
66 1.15.2.2 elric bus_space_tag_t iot, memt;
67 1.15.2.2 elric pci_chipset_tag_t pc;
68 1.15.2.2 elric int bus, device, function;
69 1.15.2.2 elric {
70 1.15.2.2 elric pcitag_t tag;
71 1.15.2.2 elric pcireg_t id, class;
72 1.15.2.2 elric int match, nmatch;
73 1.15.2.2 elric int (*fn) __P((bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
74 1.15.2.2 elric int, int, int));
75 1.15.2.2 elric
76 1.15.2.2 elric tag = pci_make_tag(pc, bus, device, function);
77 1.15.2.2 elric id = pci_conf_read(pc, tag, PCI_ID_REG);
78 1.15.2.2 elric if (id == 0 || id == 0xffffffff)
79 1.15.2.2 elric panic("pci_display_console: no device at %d/%d/%d",
80 1.15.2.2 elric bus, device, function);
81 1.15.2.2 elric class = pci_conf_read(pc, tag, PCI_CLASS_REG);
82 1.15.2.2 elric
83 1.15.2.2 elric nmatch = match = 0; /* XXX really only if we've got FBs configured */
84 1.15.2.2 elric fn = NULL;
85 1.15.2.2 elric
86 1.15.2.2 elric #if NVGA_PCI
87 1.15.2.2 elric nmatch = DEVICE_IS_VGA_PCI(class, id);
88 1.15.2.2 elric if (nmatch > match) {
89 1.15.2.2 elric match = nmatch;
90 1.15.2.2 elric fn = vga_pci_cnattach;
91 1.15.2.2 elric }
92 1.15.2.2 elric #endif
93 1.15.2.2 elric #if NTGA
94 1.15.2.2 elric nmatch = DEVICE_IS_TGA(class, id);
95 1.15.2.2 elric if (nmatch > match)
96 1.15.2.2 elric nmatch = tga_cnmatch(iot, memt, pc, tag);
97 1.15.2.2 elric if (nmatch > match) {
98 1.15.2.2 elric match = nmatch;
99 1.15.2.2 elric fn = tga_cnattach;
100 1.15.2.2 elric }
101 1.15.2.2 elric #endif
102 1.15.2.2 elric
103 1.15.2.2 elric if (fn != NULL)
104 1.15.2.2 elric (*fn)(iot, memt, pc, bus, device, function);
105 1.15.2.2 elric else
106 1.15.2.2 elric panic("pci_display_console: unconfigured device at %d/%d/%d",
107 1.15.2.2 elric bus, device, function);
108 1.15.2.2 elric }
109