svn commit: r200987 - head/sys/sparc64/pci

Marius Strobl marius at FreeBSD.org
Fri Dec 25 15:03:05 UTC 2009


Author: marius
Date: Fri Dec 25 15:03:05 2009
New Revision: 200987
URL: http://svn.freebsd.org/changeset/base/200987

Log:
  - Hook up the default implementations of the MSI/MSI-X pcib_if methods
    so requests may bubble up to a host-PCI bridge driver.
  - Distinguish between PCI and PCIe bridges in the device description
    so it's a bit easier to follow what hangs off of what in the dmesg.
    Unfortunately we can't also tell PCI and PCI-X apart based on the
    information provided in the OFW device tree.
  - Add quirk handling for the ALi M5249 found in Fire-based machines
    which are used as a PCIe-PCIe bridge there. These are obviously
    subtractive decoding as as they have a PCI-ISA bridge on their
    secondary side (and likewise don't include the ISA I/O range in
    their bridge decode) but don't indicate this via the class code.
    Given that this quirk isn't likely to apply to all ALi M5249 and
    I have no datasheet for these chips so I could implement a check
    using the chip specific bits enabling subtractive decoding this
    quirk handling is added to the MD code rather than the MI one.

Modified:
  head/sys/sparc64/pci/ofw_pcib.c

Modified: head/sys/sparc64/pci/ofw_pcib.c
==============================================================================
--- head/sys/sparc64/pci/ofw_pcib.c	Fri Dec 25 14:59:54 2009	(r200986)
+++ head/sys/sparc64/pci/ofw_pcib.c	Fri Dec 25 15:03:05 2009	(r200987)
@@ -3,6 +3,7 @@
  * Copyright (c) 2000 Michael Smith <msmith at freebsd.org>
  * Copyright (c) 2000 BSDi
  * Copyright (c) 2001 - 2003 Thomas Moestl <tmm at FreeBSD.org>
+ * Copyright (c) 2009 by Marius Strobl <marius at FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,8 +38,9 @@ __FBSDID("$FreeBSD$");
 #include "opt_ofw_pci.h"
 
 #include <sys/param.h>
-#include <sys/kernel.h>
 #include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/libkern.h>
 #include <sys/module.h>
 
 #include <dev/ofw/ofw_bus.h>
@@ -82,6 +84,11 @@ static device_method_t ofw_pcib_methods[
 	DEVMETHOD(pcib_read_config,	pcib_read_config),
 	DEVMETHOD(pcib_write_config,	pcib_write_config),
 	DEVMETHOD(pcib_route_interrupt,	ofw_pcib_gen_route_interrupt),
+	DEVMETHOD(pcib_alloc_msi,	pcib_alloc_msi),
+	DEVMETHOD(pcib_release_msi,	pcib_release_msi),
+	DEVMETHOD(pcib_alloc_msix,	pcib_alloc_msix),
+	DEVMETHOD(pcib_release_msix,	pcib_release_msix),
+	DEVMETHOD(pcib_map_msi,		pcib_map_msi),
 
 	/* ofw_bus interface */
 	DEVMETHOD(ofw_bus_get_node,	ofw_pcib_gen_get_node),
@@ -100,19 +107,49 @@ MODULE_DEPEND(ofw_pcib, pci, 1, 1, 1);
 static int
 ofw_pcib_probe(device_t dev)
 {
+	char desc[sizeof("OFW PCIe-PCIe bridge")];
+	const char *dtype, *pbdtype;
+
+#define	ISDTYPE(dtype, type)						\
+	(((dtype) != NULL) && strcmp((dtype), (type)) == 0)
 
 	if ((pci_get_class(dev) == PCIC_BRIDGE) &&
 	    (pci_get_subclass(dev) == PCIS_BRIDGE_PCI) &&
 	    ofw_bus_get_node(dev) != 0) {
-		device_set_desc(dev, "OFW PCI-PCI bridge");
+		dtype = ofw_bus_get_type(dev);
+		pbdtype = ofw_bus_get_type(device_get_parent(
+		    device_get_parent(dev)));
+		snprintf(desc, sizeof(desc), "OFW PCI%s-PCI%s bridge",
+		    ISDTYPE(pbdtype, OFW_TYPE_PCIE) ? "e" : "",
+		    ISDTYPE(dtype, OFW_TYPE_PCIE) ? "e" : "");
+		device_set_desc_copy(dev, desc);
 		return (0);
 	}
+
+#undef ISDTYPE
+
 	return (ENXIO);
 }
 
 static int
 ofw_pcib_attach(device_t dev)
 {
+	struct ofw_pcib_gen_softc *sc;
+
+	sc = device_get_softc(dev);
+
+	/* Quirk handling */
+	switch (pci_get_devid(dev)) {
+	/*
+	 * The ALi M5249 found in Fire-based machines by definition must me
+	 * subtractive as they have a ISA bridge on their secondary side but
+	 * don't indicate this in the class code although the ISA I/O range
+	 * isn't included in their bridge decode.
+	 */
+	case 0x524910b9:
+		sc->ops_pcib_sc.flags |= PCIB_SUBTRACTIVE;
+		break;
+	}
 
 	ofw_pcib_gen_setup(dev);
 	pcib_attach_common(dev);


More information about the svn-src-all mailing list