x86/pci: AMD one chain system to use pci read out res
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / x86 / pci / bus_numa.c
blob3411687b676e88eacd635e10c7f7c2fd5ee31265
1 #include <linux/init.h>
2 #include <linux/pci.h>
4 #include "bus_numa.h"
6 int pci_root_num;
7 struct pci_root_info pci_root_info[PCI_ROOT_NR];
9 void x86_pci_root_bus_res_quirks(struct pci_bus *b)
11 int i;
12 int j;
13 struct pci_root_info *info;
15 /* don't go for it if _CRS is used already */
16 if (b->resource[0] != &ioport_resource ||
17 b->resource[1] != &iomem_resource)
18 return;
20 if (!pci_root_num)
21 return;
23 for (i = 0; i < pci_root_num; i++) {
24 if (pci_root_info[i].bus_min == b->number)
25 break;
28 if (i == pci_root_num)
29 return;
31 printk(KERN_DEBUG "PCI: peer root bus %02x res updated from pci conf\n",
32 b->number);
34 info = &pci_root_info[i];
35 for (j = 0; j < info->res_num; j++) {
36 struct resource *res;
37 struct resource *root;
39 res = &info->res[j];
40 b->resource[j] = res;
41 if (res->flags & IORESOURCE_IO)
42 root = &ioport_resource;
43 else
44 root = &iomem_resource;
45 insert_resource(root, res);
49 void __devinit update_res(struct pci_root_info *info, resource_size_t start,
50 resource_size_t end, unsigned long flags, int merge)
52 int i;
53 struct resource *res;
55 if (start > end)
56 return;
58 if (!merge)
59 goto addit;
61 /* try to merge it with old one */
62 for (i = 0; i < info->res_num; i++) {
63 resource_size_t final_start, final_end;
64 resource_size_t common_start, common_end;
66 res = &info->res[i];
67 if (res->flags != flags)
68 continue;
70 common_start = max(res->start, start);
71 common_end = min(res->end, end);
72 if (common_start > common_end + 1)
73 continue;
75 final_start = min(res->start, start);
76 final_end = max(res->end, end);
78 res->start = final_start;
79 res->end = final_end;
80 return;
83 addit:
85 /* need to add that */
86 if (info->res_num >= RES_NUM)
87 return;
89 res = &info->res[info->res_num];
90 res->name = info->name;
91 res->flags = flags;
92 res->start = start;
93 res->end = end;
94 res->child = NULL;
95 info->res_num++;