No empty .Rs/.Re
[netbsd-mini2440.git] / sys / arch / x86 / pci / aapic.c
blob50366ba1b678627ca3d3d2f9ba64f262129b2904
1 /* $NetBSD: aapic.c,v 1.7 2008/07/09 21:07:55 joerg Exp $ */
3 #include <sys/cdefs.h>
4 __KERNEL_RCSID(0, "$NetBSD: aapic.c,v 1.7 2008/07/09 21:07:55 joerg Exp $");
6 #include <sys/param.h>
7 #include <sys/systm.h>
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>
17 #include "ioapic.h"
19 #if NIOAPIC > 0
20 extern int nioapics;
21 #endif
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);
28 static int
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)
35 return (1);
37 return (0);
40 static void
41 aapic_attach(device_t parent, device_t self, void *aux)
43 struct pci_attach_args *pa = aux;
44 char devinfo[256];
45 int bus, dev, func, rev;
46 pcitag_t tag;
47 pcireg_t reg;
49 pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo));
50 rev = PCI_REVISION(pa->pa_class);
51 aprint_naive("\n");
52 aprint_normal(": %s (rev. 0x%02x)\n", devinfo, rev);
54 #if NIOAPIC > 0
55 if (nioapics == 0)
56 return;
57 #else
58 return;
59 #endif
61 reg = pci_conf_read(pa->pa_pc, pa->pa_tag, AMD8131_IOAPIC_CTL);
62 reg |= AMD8131_IOAEN;
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);
66 func = 0;
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);