Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86_64/pci "driver" for AMD 8131 IO apic, appearing...



details:   https://anonhg.NetBSD.org/src/rev/f9e14a495846
branches:  trunk
changeset: 546225:f9e14a495846
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Tue Apr 22 22:34:28 2003 +0000

description:
"driver" for AMD 8131 IO apic, appearing in PCI space. Currently only
contains a workaround for a hardware bug.

diffstat:

 sys/arch/x86_64/pci/aapic.c      |  71 ++++++++++++++++++++++++++++++++++++++++
 sys/arch/x86_64/pci/amd8131reg.h |  12 ++++++
 2 files changed, 83 insertions(+), 0 deletions(-)

diffs (91 lines):

diff -r ef5f59bbc50d -r f9e14a495846 sys/arch/x86_64/pci/aapic.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x86_64/pci/aapic.c       Tue Apr 22 22:34:28 2003 +0000
@@ -0,0 +1,71 @@
+/*     $NetBSD: aapic.c,v 1.1 2003/04/22 22:34:28 fvdl Exp $   */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcidevs.h>
+
+#include <arch/x86_64/pci/amd8131reg.h>
+
+static int     aapic_match __P((struct device *, struct cfdata *, void *));
+static void    aapic_attach __P((struct device *, struct device *, void *));
+
+struct aapic_softc {
+       struct device sc_dev;
+};
+
+CFATTACH_DECL(aapic, sizeof(struct aapic_softc),
+    aapic_match, aapic_attach, NULL, NULL);
+
+static int
+aapic_match(parent, match, aux)
+       struct device *parent;
+       struct cfdata *match;
+       void *aux;
+{
+       struct pci_attach_args *pa = aux;
+
+       if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD &&
+           PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_PCIX8131_APIC)
+               return (1);
+
+       return (0);
+}
+
+static void
+aapic_attach(parent, self, aux)
+       struct device *parent, *self;
+       void *aux;
+{
+       struct pci_attach_args *pa = aux;
+       char devinfo[256];
+       int bus, dev, func, rev;
+       pcitag_t tag;
+       pcireg_t reg;
+
+       pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
+       rev = PCI_REVISION(pa->pa_class);
+       printf(": %s (rev. 0x%02x)\n", devinfo, rev);
+
+       reg = pci_conf_read(pa->pa_pc, pa->pa_tag, AMD8131_IOAPIC_CTL);
+       if ((reg & AMD8131_IOAEN) == 0) {
+               reg |= AMD8131_IOAEN;
+               pci_conf_write(pa->pa_pc, pa->pa_tag, AMD8131_IOAPIC_CTL, reg);
+       }
+
+       /*
+        * Work around erratum #22 for A0 and B0 revisions.
+        */
+       if (rev == 0x01 || rev == 0x11) {
+               pci_decompose_tag(pa->pa_pc, pa->pa_tag, &bus, &dev, &func);
+               func = 0;
+               tag = pci_make_tag(pa->pa_pc, bus, dev, func);
+               reg = pci_conf_read(pa->pa_pc, tag, AMD8131_PCIX_MISC);
+               reg &= ~0x00000001;
+               pci_conf_write(pa->pa_pc, tag, AMD8131_PCIX_MISC, reg);
+       }
+}
diff -r ef5f59bbc50d -r f9e14a495846 sys/arch/x86_64/pci/amd8131reg.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x86_64/pci/amd8131reg.h  Tue Apr 22 22:34:28 2003 +0000
@@ -0,0 +1,12 @@
+/*     $NetBSD: amd8131reg.h,v 1.1 2003/04/22 22:34:28 fvdl Exp $      */
+
+/*
+ * Some register definitions for the AMD 8131 PCI-X Tunnel / IO apic.
+ * Only the registers/bits that are currently used are defined here.
+ */
+
+#define AMD8131_PCIX_MISC      0x40
+#      define AMD8131_NIOAMODE         0x00000001
+
+#define AMD8131_IOAPIC_CTL     0x44
+#      define AMD8131_IOAEN            0x00000002



Home | Main Index | Thread Index | Old Index