Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/shark/ofw add a mmap() method so the xf86-video-igs...



details:   https://anonhg.NetBSD.org/src/rev/a0339890f9c1
branches:  trunk
changeset: 748929:a0339890f9c1
user:      macallan <macallan%NetBSD.org@localhost>
date:      Tue Nov 10 22:24:57 2009 +0000

description:
add a mmap() method so the xf86-video-igs driver can map the aperture and
IO space in a sane way.

diffstat:

 sys/arch/shark/ofw/igsfb_ofbus.c |  37 ++++++++++++++++++++++++++++++++-----
 1 files changed, 32 insertions(+), 5 deletions(-)

diffs (83 lines):

diff -r 18ffa5c65b67 -r a0339890f9c1 sys/arch/shark/ofw/igsfb_ofbus.c
--- a/sys/arch/shark/ofw/igsfb_ofbus.c  Tue Nov 10 22:23:22 2009 +0000
+++ b/sys/arch/shark/ofw/igsfb_ofbus.c  Tue Nov 10 22:24:57 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: igsfb_ofbus.c,v 1.8 2008/05/08 02:10:52 macallan Exp $ */
+/*     $NetBSD: igsfb_ofbus.c,v 1.9 2009/11/10 22:24:57 macallan Exp $ */
 
 /*
  * Copyright (c) 2006 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: igsfb_ofbus.c,v 1.8 2008/05/08 02:10:52 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: igsfb_ofbus.c,v 1.9 2009/11/10 22:24:57 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -66,6 +66,7 @@
 static int     igsfb_ofbus_match(struct device *, struct cfdata *, void *);
 static void    igsfb_ofbus_attach(struct device *, struct device *, void *);
 static int     igsfb_setup_dc(struct igsfb_devconfig *);
+static paddr_t igsfb_ofbus_mmap(void *, void *, off_t, int);
 
 CFATTACH_DECL(igsfb_ofbus, sizeof(struct igsfb_softc),
     igsfb_ofbus_match, igsfb_ofbus_attach, NULL, NULL);
@@ -74,6 +75,7 @@
 
 vaddr_t igsfb_mem_vaddr = 0, igsfb_mmio_vaddr = 0;
 paddr_t igsfb_mem_paddr;
+extern paddr_t isa_io_physaddr;
 struct bus_space igsfb_memt, igsfb_iot;
 
 #if (NIGSFB_OFBUS > 0) || (NVGA_OFBUS > 0)
@@ -106,8 +108,8 @@
                return ENXIO;
 
        igsfb_mem_paddr = be32toh(regs[13]);
-       /* 4MB VRAM */
-       igsfb_mem_vaddr = ofw_map(igsfb_mem_paddr, 0x00400000, 0);
+       /* 4MB VRAM aperture, bufferable and cacheable */
+       igsfb_mem_vaddr = ofw_map(igsfb_mem_paddr, 0x00400000, L2_B | L2_C);
        /* MMIO registers */
        igsfb_mmio_vaddr = ofw_map(igsfb_mem_paddr + IGS_MEM_MMIO_SELECT,
            0x00100000, 0);
@@ -163,7 +165,7 @@
        dc->dc_iot = &igsfb_iot;
        dc->dc_iobase = 0;
        dc->dc_ioflags = 0;
-
+       dc->dc_mmap = igsfb_ofbus_mmap;
        if (bus_space_map(dc->dc_iot,
                          dc->dc_iobase + IGS_REG_BASE, IGS_REG_SIZE,
                          dc->dc_ioflags,
@@ -229,3 +231,28 @@
 
        igsfb_attach_subr(sc, isconsole);
 }
+
+static paddr_t
+igsfb_ofbus_mmap(void *v, void *vs, off_t offset, int prot)
+{
+
+#ifdef PCI_MAGIC_IO_RANGE
+       /* access to IO ports */
+       if ((offset >= PCI_MAGIC_IO_RANGE) &&
+           (offset < (PCI_MAGIC_IO_RANGE + 0x10000))) {
+               paddr_t pa;
+
+               pa = isa_io_physaddr + offset - PCI_MAGIC_IO_RANGE;
+               return arm_btop(pa);
+       }
+#endif
+       /*
+        * we also need to allow mapping of the whole aperture, including MMIO  
+        * registers on CyberPro at its physical address
+        */
+       if ((offset >= igsfb_mem_paddr) && 
+           (offset < (igsfb_mem_paddr + 0x01000000)))
+               return arm_btop(offset);
+
+       return -1;
+}



Home | Main Index | Thread Index | Old Index