1 /* $NetBSD: aapic.c,v 1.7 2008/07/09 21:07:55 joerg Exp $ */
4 __KERNEL_RCSID(0, "$NetBSD: aapic.c,v 1.7 2008/07/09 21:07:55 joerg Exp $");
8 #include <sys/kernel.h>
9 #include <sys/device.h>
11 #include <dev/pci/pcireg.h>
12 #include <dev/pci/pcivar.h>
13 #include <dev/pci/pcidevs.h>
15 #include <arch/x86/pci/amd8131reg.h>
23 static int aapic_match(device_t
, cfdata_t
, void *);
24 static void aapic_attach(device_t
, device_t
, void *);
26 CFATTACH_DECL_NEW(aapic
, 0, aapic_match
, aapic_attach
, NULL
, NULL
);
29 aapic_match(device_t parent
, cfdata_t match
, void *aux
)
31 struct pci_attach_args
*pa
= aux
;
33 if (PCI_VENDOR(pa
->pa_id
) == PCI_VENDOR_AMD
&&
34 PCI_PRODUCT(pa
->pa_id
) == PCI_PRODUCT_AMD_PCIX8131_APIC
)
41 aapic_attach(device_t parent
, device_t self
, void *aux
)
43 struct pci_attach_args
*pa
= aux
;
45 int bus
, dev
, func
, rev
;
49 pci_devinfo(pa
->pa_id
, pa
->pa_class
, 0, devinfo
, sizeof(devinfo
));
50 rev
= PCI_REVISION(pa
->pa_class
);
52 aprint_normal(": %s (rev. 0x%02x)\n", devinfo
, rev
);
61 reg
= pci_conf_read(pa
->pa_pc
, pa
->pa_tag
, AMD8131_IOAPIC_CTL
);
63 pci_conf_write(pa
->pa_pc
, pa
->pa_tag
, AMD8131_IOAPIC_CTL
, reg
);
65 pci_decompose_tag(pa
->pa_pc
, pa
->pa_tag
, &bus
, &dev
, &func
);
67 tag
= pci_make_tag(pa
->pa_pc
, bus
, dev
, func
);
68 reg
= pci_conf_read(pa
->pa_pc
, tag
, AMD8131_PCIX_MISC
);
69 reg
&= ~AMD8131_NIOAMODE
;
70 pci_conf_write(pa
->pa_pc
, tag
, AMD8131_PCIX_MISC
, reg
);