Author: jchandra
Date: Wed Oct  6 15:37:55 2010
New Revision: 213484
URL: http://svn.freebsd.org/changeset/base/213484

Log:
  PCI fix for XLR C revision chips, limit DMA address to the first 2GB
  physical address.  Adds a dma tag to the XLR/XLS pci bus with the
  lowaddr if the CPU happens to be a XLR C rev.
  
  Submitted by: Sreekanth M. S. (kanthms at netlogicmicro dot com))

Modified:
  head/sys/mips/rmi/board.h
  head/sys/mips/rmi/xlr_pci.c

Modified: head/sys/mips/rmi/board.h
==============================================================================
--- head/sys/mips/rmi/board.h   Wed Oct  6 15:01:37 2010        (r213483)
+++ head/sys/mips/rmi/board.h   Wed Oct  6 15:37:55 2010        (r213484)
@@ -117,6 +117,35 @@ xlr_processor_id(void)
 }
 
 /*
+ * The processor is XLR and C-Series
+ */
+static __inline unsigned int
+xlr_is_c_revision(void)
+{
+       int processor_id = xlr_processor_id();
+       int revision_id  = xlr_revision();
+
+       switch (processor_id) {
+       /* 
+        * These are the relevant PIDs for XLR
+        * steppings (hawk and above). For these,
+        * PIDs, Rev-Ids of [5-9] indicate 'C'.
+        */
+       case RMI_CHIP_XLR308_C:
+       case RMI_CHIP_XLR508_C:
+       case RMI_CHIP_XLR516_C:
+       case RMI_CHIP_XLR532_C:
+       case RMI_CHIP_XLR716:
+       case RMI_CHIP_XLR732:
+               if (revision_id >= 5 && revision_id <= 9) 
+                       return (1);
+       default:
+               return (0);
+       }
+       return (0);
+}
+
+/*
  * RMI Engineering boards which are PCI cards
  * These should come up in PCI device mode (not yet)
  */

Modified: head/sys/mips/rmi/xlr_pci.c
==============================================================================
--- head/sys/mips/rmi/xlr_pci.c Wed Oct  6 15:01:37 2010        (r213483)
+++ head/sys/mips/rmi/xlr_pci.c Wed Oct  6 15:37:55 2010        (r213484)
@@ -113,7 +113,7 @@ __FBSDID("$FreeBSD$");
 #endif
 
 struct xlr_pcib_softc {
-       int junk;               /* no softc */
+       bus_dma_tag_t   sc_pci_dmat;    /* PCI DMA tag pointer */
 };
 
 static devclass_t pcib_devclass;
@@ -300,7 +300,19 @@ xlr_pcib_write_config(device_t dev, u_in
 static int 
 xlr_pcib_attach(device_t dev)
 {
-
+       struct xlr_pcib_softc *sc;
+       sc = device_get_softc(dev);
+       
+       /*
+        * XLR C revision chips cannot do DMA above 2G physical address
+        * create a parent tag with this lowaddr
+        */
+       if (xlr_is_c_revision()) {
+               if (bus_dma_tag_create(bus_get_dma_tag(dev), 1, 0,
+                   0x7fffffff, ~0, NULL, NULL, 0x7fffffff,
+                   0xff, 0x7fffffff, 0, NULL, NULL, &sc->sc_pci_dmat) != 0)
+                       panic("%s: bus_dma_tag_create failed", __func__);
+       }
        device_add_child(dev, "pci", 0);
        bus_generic_attach(dev);
        return (0);
@@ -566,6 +578,15 @@ xlr_pci_release_resource(device_t bus, d
        return (rman_release_resource(r));
 }
 
+static bus_dma_tag_t
+xlr_pci_get_dma_tag(device_t bus, device_t child)
+{
+       struct xlr_pcib_softc *sc;
+
+       sc = device_get_softc(bus);
+       return (sc->sc_pci_dmat);
+}
+
 static int
 xlr_pci_activate_resource(device_t bus, device_t child, int type, int rid,
                       struct resource *r)
@@ -618,6 +639,7 @@ static device_method_t xlr_pcib_methods[
        DEVMETHOD(bus_write_ivar, xlr_pcib_write_ivar),
        DEVMETHOD(bus_alloc_resource, xlr_pci_alloc_resource),
        DEVMETHOD(bus_release_resource, xlr_pci_release_resource),
+       DEVMETHOD(bus_get_dma_tag, xlr_pci_get_dma_tag),
        DEVMETHOD(bus_activate_resource, xlr_pci_activate_resource),
        DEVMETHOD(bus_deactivate_resource, xlr_pci_deactivate_resource),
        DEVMETHOD(bus_setup_intr, mips_platform_pci_setup_intr),
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to