1998-05-28 20:59:31 +04:00
|
|
|
/* $NetBSD: pci_machdep.c,v 1.13 1998/05/28 16:59:32 drochner Exp $ */
|
1995-06-28 05:24:50 +04:00
|
|
|
|
|
|
|
/*
|
1996-04-12 10:07:05 +04:00
|
|
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
1995-11-23 05:33:17 +03:00
|
|
|
* All rights reserved.
|
1995-06-28 05:24:50 +04:00
|
|
|
*
|
1995-11-23 05:33:17 +03:00
|
|
|
* Author: Chris G. Demetriou
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
1995-06-28 05:24:50 +04:00
|
|
|
*
|
1995-11-23 05:33:17 +03:00
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
1995-06-28 05:24:50 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Machine-specific functions for PCI autoconfiguration.
|
|
|
|
*/
|
|
|
|
|
1997-04-08 03:39:37 +04:00
|
|
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
|
|
|
|
1998-05-28 20:59:31 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.13 1998/05/28 16:59:32 drochner Exp $");
|
1997-04-07 06:01:16 +04:00
|
|
|
|
1995-06-28 05:24:50 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
1995-11-23 05:33:17 +03:00
|
|
|
#include <dev/pci/pcivar.h>
|
1995-08-03 04:33:58 +04:00
|
|
|
#include <dev/pci/pcidevs.h>
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1996-11-19 07:57:32 +03:00
|
|
|
#include "vga_pci.h"
|
|
|
|
#if NVGA_PCI
|
1998-05-28 20:59:31 +04:00
|
|
|
#include <dev/ic/mc6845reg.h>
|
|
|
|
#include <dev/ic/pcdisplayvar.h>
|
1998-04-16 00:46:34 +04:00
|
|
|
#include <dev/pci/vga_pcivar.h>
|
1995-11-23 05:33:17 +03:00
|
|
|
#endif
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1995-11-23 05:33:17 +03:00
|
|
|
#include "tga.h"
|
|
|
|
#if NTGA
|
1998-04-16 00:46:34 +04:00
|
|
|
#include <dev/pci/tgavar.h>
|
1995-11-23 05:33:17 +03:00
|
|
|
#endif
|
1995-08-03 04:33:58 +04:00
|
|
|
|
|
|
|
void
|
1996-10-23 08:12:13 +04:00
|
|
|
pci_display_console(iot, memt, pc, bus, device, function)
|
|
|
|
bus_space_tag_t iot, memt;
|
1996-04-12 08:31:48 +04:00
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
int bus, device, function;
|
1995-08-03 04:33:58 +04:00
|
|
|
{
|
1996-04-12 08:31:48 +04:00
|
|
|
pcitag_t tag;
|
|
|
|
pcireg_t id, class;
|
|
|
|
int match, nmatch;
|
1998-04-16 00:46:34 +04:00
|
|
|
int (*fn) __P((bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
|
1996-10-23 08:12:13 +04:00
|
|
|
int, int, int));
|
1995-08-03 04:33:58 +04:00
|
|
|
|
1996-04-12 08:31:48 +04:00
|
|
|
tag = pci_make_tag(pc, bus, device, function);
|
|
|
|
id = pci_conf_read(pc, tag, PCI_ID_REG);
|
1995-08-03 04:33:58 +04:00
|
|
|
if (id == 0 || id == 0xffffffff)
|
|
|
|
panic("pci_display_console: no device at %d/%d/%d",
|
|
|
|
bus, device, function);
|
1996-04-12 08:31:48 +04:00
|
|
|
class = pci_conf_read(pc, tag, PCI_CLASS_REG);
|
|
|
|
|
1997-03-08 22:25:49 +03:00
|
|
|
nmatch = match = 0; /* XXX really only if we've got FBs configured */
|
1996-04-12 08:31:48 +04:00
|
|
|
fn = NULL;
|
1995-08-03 04:33:58 +04:00
|
|
|
|
1996-11-19 07:57:32 +03:00
|
|
|
#if NVGA_PCI
|
|
|
|
nmatch = DEVICE_IS_VGA_PCI(class, id);
|
1996-04-12 08:31:48 +04:00
|
|
|
if (nmatch > match) {
|
|
|
|
match = nmatch;
|
1998-04-16 00:46:34 +04:00
|
|
|
fn = vga_pci_cnattach;
|
1995-08-03 04:33:58 +04:00
|
|
|
}
|
1995-11-23 05:33:17 +03:00
|
|
|
#endif
|
1995-08-03 04:33:58 +04:00
|
|
|
#if NTGA
|
1996-04-12 08:31:48 +04:00
|
|
|
nmatch = DEVICE_IS_TGA(class, id);
|
|
|
|
if (nmatch > match) {
|
|
|
|
match = nmatch;
|
1998-04-16 00:46:34 +04:00
|
|
|
fn = tga_cnattach;
|
1995-08-03 04:33:58 +04:00
|
|
|
}
|
1995-11-23 05:33:17 +03:00
|
|
|
#endif
|
1995-08-03 04:33:58 +04:00
|
|
|
|
1996-04-12 08:31:48 +04:00
|
|
|
if (fn != NULL)
|
1996-10-23 08:12:13 +04:00
|
|
|
(*fn)(iot, memt, pc, bus, device, function);
|
1996-04-12 08:31:48 +04:00
|
|
|
else
|
|
|
|
panic("pci_display_console: unconfigured device at %d/%d/%d",
|
1995-08-03 04:33:58 +04:00
|
|
|
bus, device, function);
|
|
|
|
}
|