Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys So, the PowerStorm 4d20 a.k.a. 32bit TGA2 w/ IBM RGB561 ...
details: https://anonhg.NetBSD.org/src/rev/a69bced62256
branches: trunk
changeset: 512752:a69bced62256
user: elric <elric%NetBSD.org@localhost>
date: Mon Jul 16 00:55:16 2001 +0000
description:
So, the PowerStorm 4d20 a.k.a. 32bit TGA2 w/ IBM RGB561 RAMDAC was causing
the kernel to panic since it is recognised as a TGA and the TGA driver
doesn't [yet] know what to do with it.
This patch fixes that by:
o making tgamatch() try to actually figure out what kind
of TGA card is there, rather than simply relying on the
vendor/product ids.
o creating a tga_cnmatch() so that the console code in
arch/alpha/pci/pci_machdep.c can cause the same to occur.
o breaking up some of tga_getdevconfig() into a few different
functions to re-use code that would have been duplicated.
o changed arch/alpha/pci/pci_machdep.c so that it calls out
to tga_cnmatch() if DEVICE_IS_TGA() matches before it decides
to attach the console as a TGA.
Addresses PR: port-alpha/12923
diffstat:
sys/arch/alpha/pci/pci_machdep.c | 6 +-
sys/dev/pci/tga.c | 104 ++++++++++++++++++++++++++++----------
sys/dev/pci/tgavar.h | 4 +-
3 files changed, 83 insertions(+), 31 deletions(-)
diffs (239 lines):
diff -r 9783d9ed0d49 -r a69bced62256 sys/arch/alpha/pci/pci_machdep.c
--- a/sys/arch/alpha/pci/pci_machdep.c Sun Jul 15 23:29:13 2001 +0000
+++ b/sys/arch/alpha/pci/pci_machdep.c Mon Jul 16 00:55:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.14 2000/06/29 08:58:49 mrg Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.15 2001/07/16 00:55:17 elric Exp $ */
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.14 2000/06/29 08:58:49 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.15 2001/07/16 00:55:17 elric Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -92,6 +92,8 @@
#endif
#if NTGA
nmatch = DEVICE_IS_TGA(class, id);
+ if (nmatch > match)
+ nmatch = tga_cnmatch(iot, memt, pc, tag);
if (nmatch > match) {
match = nmatch;
fn = tga_cnattach;
diff -r 9783d9ed0d49 -r a69bced62256 sys/dev/pci/tga.c
--- a/sys/dev/pci/tga.c Sun Jul 15 23:29:13 2001 +0000
+++ b/sys/dev/pci/tga.c Mon Jul 16 00:55:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tga.c,v 1.33 2001/07/07 16:46:35 thorpej Exp $ */
+/* $NetBSD: tga.c,v 1.34 2001/07/16 00:55:16 elric Exp $ */
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -72,9 +72,13 @@
int tga_identify __P((struct tga_devconfig *));
const struct tga_conf *tga_getconf __P((int));
-static void tga_getdevconfig __P((bus_space_tag_t memt, pci_chipset_tag_t pc,
+static void tga_init __P((bus_space_tag_t memt, pci_chipset_tag_t pc,
pcitag_t tag, struct tga_devconfig *dc));
+static int tga_matchcommon __P((bus_space_tag_t, pci_chipset_tag_t, pcitag_t));
+static void tga_mapaddrs __P((bus_space_tag_t memt, pci_chipset_tag_t pc,
+ pcitag_t, bus_size_t *pcisize, struct tga_devconfig *dc));
+
struct tga_devconfig tga_console_dc;
int tga_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
@@ -154,6 +158,15 @@
static void tga_unblank __P((struct tga_devconfig *));
int
+tga_cnmatch(iot, memt, pc, tag)
+ bus_space_tag_t iot, memt;
+ pci_chipset_tag_t pc;
+ pcitag_t tag;
+{
+ return tga_matchcommon(memt, pc, tag);
+}
+
+int
tgamatch(parent, match, aux)
struct device *parent;
struct cfdata *match;
@@ -167,41 +180,66 @@
switch (PCI_PRODUCT(pa->pa_id)) {
case PCI_PRODUCT_DEC_21030:
case PCI_PRODUCT_DEC_PBXGB:
- return 10;
+ break;
default:
return 0;
}
- return (0);
+
+ /* short-circuit the following test, as we
+ * already have the memory mapped and hence
+ * cannot perform it---and we are the console
+ * anyway.
+ */
+ if (pa->pa_tag == tga_console_dc.dc_pcitag)
+ return 10;
+
+ return tga_matchcommon(pa->pa_memt, pa->pa_pc, pa->pa_tag);
}
-static void
-tga_getdevconfig(memt, pc, tag, dc)
+static int
+tga_matchcommon(memt, pc, tag)
bus_space_tag_t memt;
pci_chipset_tag_t pc;
pcitag_t tag;
+{
+ struct tga_devconfig tmp_dc;
+ struct tga_devconfig *dc = &tmp_dc;
+ bus_size_t pcisize;
+
+ tga_mapaddrs(memt, pc, tag, &pcisize, dc);
+ dc->dc_tga_type = tga_identify(dc);
+
+ dc->dc_tgaconf = tga_getconf(dc->dc_tga_type);
+ bus_space_unmap(memt, dc->dc_memh, pcisize);
+ if (dc->dc_tgaconf)
+ return 10;
+ return 0;
+}
+
+static void
+tga_mapaddrs(memt, pc, tag, pcisize, dc)
+ bus_space_tag_t memt;
+ pci_chipset_tag_t pc;
+ pcitag_t tag;
+ bus_size_t *pcisize;
struct tga_devconfig *dc;
{
- const struct tga_conf *tgac;
- struct rasops_info *rip;
- int cookie;
- bus_size_t pcisize;
- int i, flags;
+ int flags;
dc->dc_memt = memt;
-
- dc->dc_pcitag = tag;
+ dc->dc_tgaconf = NULL;
/* XXX magic number */
if (pci_mapreg_info(pc, tag, 0x10,
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT,
- &dc->dc_pcipaddr, &pcisize, &flags))
- return;
+ &dc->dc_pcipaddr, pcisize, &flags))
+ panic("tga_mapaddrs: pci_mapreg_info() failed");
if ((flags & BUS_SPACE_MAP_PREFETCHABLE) == 0) /* XXX */
panic("tga memory not prefetchable");
- if (bus_space_map(memt, dc->dc_pcipaddr, pcisize,
+ if (bus_space_map(memt, dc->dc_pcipaddr, *pcisize,
BUS_SPACE_MAP_PREFETCHABLE | BUS_SPACE_MAP_LINEAR, &dc->dc_memh))
- return;
+ panic("tga_mapaddrs: could not map TGA address space");
dc->dc_vaddr = (vaddr_t) bus_space_vaddr(memt, dc->dc_memh);
#ifdef __alpha__
dc->dc_paddr = ALPHA_K0SEG_TO_PHYS(dc->dc_vaddr); /* XXX */
@@ -213,16 +251,29 @@
bus_space_subregion(dc->dc_memt, dc->dc_memh,
TGA_MEM_CREGS, TGA_CREGS_SIZE,
&dc->dc_regs);
+}
+
+static void
+tga_init(memt, pc, tag, dc)
+ bus_space_tag_t memt;
+ pci_chipset_tag_t pc;
+ pcitag_t tag;
+ struct tga_devconfig *dc;
+{
+ const struct tga_conf *tgac;
+ struct rasops_info *rip;
+ int cookie;
+ bus_size_t pcisize;
+ int i;
+
+ dc->dc_pcitag = tag;
+ tga_mapaddrs(memt, pc, tag, &pcisize, dc);
dc->dc_tga_type = tga_identify(dc);
-
tgac = dc->dc_tgaconf = tga_getconf(dc->dc_tga_type);
- if (tgac == NULL)
- return;
-
#if 0
/* XXX on the Alpha, pcisize = 4 * cspace_size. */
if (tgac->tgac_cspace_size != pcisize) /* sanity */
- panic("tga_getdevconfig: memory size mismatch?");
+ panic("tga_init: memory size mismatch?");
#endif
switch (TGARREG(dc, TGA_REG_GREV) & 0xff) {
@@ -238,7 +289,7 @@
dc->dc_tga2 = 1;
break;
default:
- panic("tga_getdevconfig: TGA Revision not recognized");
+ panic("tga_init: TGA Revision not recognized");
}
if (dc->dc_tga2) {
@@ -377,8 +428,7 @@
sc->sc_dc = (struct tga_devconfig *)
malloc(sizeof(struct tga_devconfig), M_DEVBUF, M_WAITOK);
memset(sc->sc_dc, 0, sizeof(struct tga_devconfig));
- tga_getdevconfig(pa->pa_memt, pa->pa_pc, pa->pa_tag,
- sc->sc_dc);
+ tga_init(pa->pa_memt, pa->pa_pc, pa->pa_tag, sc->sc_dc);
}
if (sc->sc_dc->dc_vaddr == NULL) {
printf(": couldn't map memory space; punt!\n");
@@ -482,7 +532,6 @@
struct tga_softc *sc = (struct tga_softc *)d;
sc->sc_dc->dc_intrenabled = 1;
}
-
int
tga_ioctl(v, cmd, data, flag, p)
@@ -698,8 +747,7 @@
struct tga_devconfig *dcp = &tga_console_dc;
long defattr;
- tga_getdevconfig(memt, pc,
- pci_make_tag(pc, bus, device, function), dcp);
+ tga_init(memt, pc, pci_make_tag(pc, bus, device, function), dcp);
/* sanity checks */
if (dcp->dc_vaddr == NULL)
diff -r 9783d9ed0d49 -r a69bced62256 sys/dev/pci/tgavar.h
--- a/sys/dev/pci/tgavar.h Sun Jul 15 23:29:13 2001 +0000
+++ b/sys/dev/pci/tgavar.h Mon Jul 16 00:55:16 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tgavar.h,v 1.9 2000/04/20 05:25:20 nathanw Exp $ */
+/* $NetBSD: tgavar.h,v 1.10 2001/07/16 00:55:17 elric Exp $ */
/*
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -117,6 +117,8 @@
PCI_PRODUCT(id) == PCI_PRODUCT_DEC_21030) || \
PCI_PRODUCT(id) == PCI_PRODUCT_DEC_PBXGB) ? 10 : 0)
+int tga_cnmatch __P((bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
+ pcitag_t));
int tga_cnattach __P((bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
int, int, int));
Home |
Main Index |
Thread Index |
Old Index