diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/x86_64/pci |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/x86_64/pci')
-rw-r--r-- | arch/x86_64/pci/Makefile | 24 | ||||
-rw-r--r-- | arch/x86_64/pci/Makefile-BUS | 22 | ||||
-rw-r--r-- | arch/x86_64/pci/k8-bus.c | 78 | ||||
-rw-r--r-- | arch/x86_64/pci/mmconfig.c | 104 |
4 files changed, 228 insertions, 0 deletions
diff --git a/arch/x86_64/pci/Makefile b/arch/x86_64/pci/Makefile new file mode 100644 index 000000000000..37c92e841dec --- /dev/null +++ b/arch/x86_64/pci/Makefile | |||
@@ -0,0 +1,24 @@ | |||
1 | # | ||
2 | # Makefile for X86_64 specific PCI routines | ||
3 | # | ||
4 | # Reuse the i386 PCI subsystem | ||
5 | # | ||
6 | CFLAGS += -Iarch/i386/pci | ||
7 | |||
8 | obj-y := i386.o | ||
9 | obj-$(CONFIG_PCI_DIRECT)+= direct.o | ||
10 | obj-y += fixup.o | ||
11 | obj-$(CONFIG_ACPI_PCI) += acpi.o | ||
12 | obj-y += legacy.o irq.o common.o | ||
13 | # mmconfig has a 64bit special | ||
14 | obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o | ||
15 | |||
16 | obj-$(CONFIG_NUMA) += k8-bus.o | ||
17 | |||
18 | direct-y += ../../i386/pci/direct.o | ||
19 | acpi-y += ../../i386/pci/acpi.o | ||
20 | legacy-y += ../../i386/pci/legacy.o | ||
21 | irq-y += ../../i386/pci/irq.o | ||
22 | common-y += ../../i386/pci/common.o | ||
23 | fixup-y += ../../i386/pci/fixup.o | ||
24 | i386-y += ../../i386/pci/i386.o | ||
diff --git a/arch/x86_64/pci/Makefile-BUS b/arch/x86_64/pci/Makefile-BUS new file mode 100644 index 000000000000..291985f0d2e4 --- /dev/null +++ b/arch/x86_64/pci/Makefile-BUS | |||
@@ -0,0 +1,22 @@ | |||
1 | # | ||
2 | # Makefile for X86_64 specific PCI routines | ||
3 | # | ||
4 | # Reuse the i386 PCI subsystem | ||
5 | # | ||
6 | CFLAGS += -I arch/i386/pci | ||
7 | |||
8 | obj-y := i386.o | ||
9 | obj-$(CONFIG_PCI_DIRECT)+= direct.o | ||
10 | obj-y += fixup.o | ||
11 | obj-$(CONFIG_ACPI_PCI) += acpi.o | ||
12 | obj-y += legacy.o irq.o common.o | ||
13 | # mmconfig has a 64bit special | ||
14 | obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o | ||
15 | |||
16 | direct-y += ../../i386/pci/direct.o | ||
17 | acpi-y += ../../i386/pci/acpi.o | ||
18 | legacy-y += ../../i386/pci/legacy.o | ||
19 | irq-y += ../../i386/pci/irq.o | ||
20 | common-y += ../../i386/pci/common.o | ||
21 | fixup-y += ../../i386/pci/fixup.o | ||
22 | i386-y += ../../i386/pci/i386.o | ||
diff --git a/arch/x86_64/pci/k8-bus.c b/arch/x86_64/pci/k8-bus.c new file mode 100644 index 000000000000..62349c78db57 --- /dev/null +++ b/arch/x86_64/pci/k8-bus.c | |||
@@ -0,0 +1,78 @@ | |||
1 | #include <linux/init.h> | ||
2 | #include <linux/pci.h> | ||
3 | #include <asm/mpspec.h> | ||
4 | #include <linux/cpumask.h> | ||
5 | |||
6 | /* | ||
7 | * This discovers the pcibus <-> node mapping on AMD K8. | ||
8 | * | ||
9 | * RED-PEN need to call this again on PCI hotplug | ||
10 | * RED-PEN empty cpus get reported wrong | ||
11 | */ | ||
12 | |||
13 | #define NODE_ID_REGISTER 0x60 | ||
14 | #define NODE_ID(dword) (dword & 0x07) | ||
15 | #define LDT_BUS_NUMBER_REGISTER_0 0x94 | ||
16 | #define LDT_BUS_NUMBER_REGISTER_1 0xB4 | ||
17 | #define LDT_BUS_NUMBER_REGISTER_2 0xD4 | ||
18 | #define NR_LDT_BUS_NUMBER_REGISTERS 3 | ||
19 | #define SECONDARY_LDT_BUS_NUMBER(dword) ((dword >> 8) & 0xFF) | ||
20 | #define SUBORDINATE_LDT_BUS_NUMBER(dword) ((dword >> 16) & 0xFF) | ||
21 | #define PCI_DEVICE_ID_K8HTCONFIG 0x1100 | ||
22 | |||
23 | /** | ||
24 | * fill_mp_bus_to_cpumask() | ||
25 | * fills the mp_bus_to_cpumask array based according to the LDT Bus Number | ||
26 | * Registers found in the K8 northbridge | ||
27 | */ | ||
28 | __init static int | ||
29 | fill_mp_bus_to_cpumask(void) | ||
30 | { | ||
31 | struct pci_dev *nb_dev = NULL; | ||
32 | int i, j, printed; | ||
33 | u32 ldtbus, nid; | ||
34 | static int lbnr[3] = { | ||
35 | LDT_BUS_NUMBER_REGISTER_0, | ||
36 | LDT_BUS_NUMBER_REGISTER_1, | ||
37 | LDT_BUS_NUMBER_REGISTER_2 | ||
38 | }; | ||
39 | |||
40 | while ((nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, | ||
41 | PCI_DEVICE_ID_K8HTCONFIG, nb_dev))) { | ||
42 | pci_read_config_dword(nb_dev, NODE_ID_REGISTER, &nid); | ||
43 | |||
44 | for (i = 0; i < NR_LDT_BUS_NUMBER_REGISTERS; i++) { | ||
45 | pci_read_config_dword(nb_dev, lbnr[i], &ldtbus); | ||
46 | /* | ||
47 | * if there are no busses hanging off of the current | ||
48 | * ldt link then both the secondary and subordinate | ||
49 | * bus number fields are set to 0. | ||
50 | */ | ||
51 | if (!(SECONDARY_LDT_BUS_NUMBER(ldtbus) == 0 | ||
52 | && SUBORDINATE_LDT_BUS_NUMBER(ldtbus) == 0)) { | ||
53 | for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus); | ||
54 | j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus); | ||
55 | j++) | ||
56 | pci_bus_to_cpumask[j] = | ||
57 | node_to_cpumask(NODE_ID(nid)); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | |||
62 | /* quick sanity check */ | ||
63 | printed = 0; | ||
64 | for (i = 0; i < 256; i++) { | ||
65 | if (cpus_empty(pci_bus_to_cpumask[i])) { | ||
66 | pci_bus_to_cpumask[i] = CPU_MASK_ALL; | ||
67 | if (printed) | ||
68 | continue; | ||
69 | printk(KERN_ERR | ||
70 | "k8-bus.c: some busses have empty cpu mask\n"); | ||
71 | printed = 1; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | fs_initcall(fill_mp_bus_to_cpumask); | ||
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c new file mode 100644 index 000000000000..b693c232fd07 --- /dev/null +++ b/arch/x86_64/pci/mmconfig.c | |||
@@ -0,0 +1,104 @@ | |||
1 | /* | ||
2 | * mmconfig.c - Low-level direct PCI config space access via MMCONFIG | ||
3 | * | ||
4 | * This is an 64bit optimized version that always keeps the full mmconfig | ||
5 | * space mapped. This allows lockless config space operation. | ||
6 | */ | ||
7 | |||
8 | #include <linux/pci.h> | ||
9 | #include <linux/init.h> | ||
10 | #include "pci.h" | ||
11 | |||
12 | #define MMCONFIG_APER_SIZE (256*1024*1024) | ||
13 | |||
14 | /* The physical address of the MMCONFIG aperture. Set from ACPI tables. */ | ||
15 | u32 pci_mmcfg_base_addr; | ||
16 | |||
17 | /* Static virtual mapping of the MMCONFIG aperture */ | ||
18 | char *pci_mmcfg_virt; | ||
19 | |||
20 | static inline char *pci_dev_base(unsigned int bus, unsigned int devfn) | ||
21 | { | ||
22 | return pci_mmcfg_virt + ((bus << 20) | (devfn << 12)); | ||
23 | } | ||
24 | |||
25 | static int pci_mmcfg_read(unsigned int seg, unsigned int bus, | ||
26 | unsigned int devfn, int reg, int len, u32 *value) | ||
27 | { | ||
28 | char *addr = pci_dev_base(bus, devfn); | ||
29 | |||
30 | if (unlikely(!value || (bus > 255) || (devfn > 255) || (reg > 4095))) | ||
31 | return -EINVAL; | ||
32 | |||
33 | switch (len) { | ||
34 | case 1: | ||
35 | *value = readb(addr + reg); | ||
36 | break; | ||
37 | case 2: | ||
38 | *value = readw(addr + reg); | ||
39 | break; | ||
40 | case 4: | ||
41 | *value = readl(addr + reg); | ||
42 | break; | ||
43 | } | ||
44 | |||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static int pci_mmcfg_write(unsigned int seg, unsigned int bus, | ||
49 | unsigned int devfn, int reg, int len, u32 value) | ||
50 | { | ||
51 | char *addr = pci_dev_base(bus,devfn); | ||
52 | |||
53 | if (unlikely((bus > 255) || (devfn > 255) || (reg > 4095))) | ||
54 | return -EINVAL; | ||
55 | |||
56 | switch (len) { | ||
57 | case 1: | ||
58 | writeb(value, addr + reg); | ||
59 | break; | ||
60 | case 2: | ||
61 | writew(value, addr + reg); | ||
62 | break; | ||
63 | case 4: | ||
64 | writel(value, addr + reg); | ||
65 | break; | ||
66 | } | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static struct pci_raw_ops pci_mmcfg = { | ||
72 | .read = pci_mmcfg_read, | ||
73 | .write = pci_mmcfg_write, | ||
74 | }; | ||
75 | |||
76 | static int __init pci_mmcfg_init(void) | ||
77 | { | ||
78 | if ((pci_probe & PCI_PROBE_MMCONF) == 0) | ||
79 | return 0; | ||
80 | if (!pci_mmcfg_base_addr) | ||
81 | return 0; | ||
82 | |||
83 | /* Kludge for now. Don't use mmconfig on AMD systems because | ||
84 | those have some busses where mmconfig doesn't work, | ||
85 | and we don't parse ACPI MCFG well enough to handle that. | ||
86 | Remove when proper handling is added. */ | ||
87 | if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) | ||
88 | return 0; | ||
89 | |||
90 | /* RED-PEN i386 doesn't do _nocache right now */ | ||
91 | pci_mmcfg_virt = ioremap_nocache(pci_mmcfg_base_addr, MMCONFIG_APER_SIZE); | ||
92 | if (!pci_mmcfg_virt) { | ||
93 | printk("PCI: Cannot map mmconfig aperture\n"); | ||
94 | return 0; | ||
95 | } | ||
96 | |||
97 | printk(KERN_INFO "PCI: Using MMCONFIG at %x\n", pci_mmcfg_base_addr); | ||
98 | raw_pci_ops = &pci_mmcfg; | ||
99 | pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | arch_initcall(pci_mmcfg_init); | ||