2 * SHPCHPRM ACPI: PHP Resource Manager for ACPI platform
4 * Copyright (C) 2003-2004 Intel Corporation
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
16 * NON INFRINGEMENT. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * Send feedback to <dely.l.sy@intel.com>
27 #include <linux/config.h>
28 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/types.h>
31 #include <linux/pci.h>
32 #include <linux/init.h>
33 #include <linux/acpi.h>
34 #include <linux/efi.h>
35 #include <asm/uaccess.h>
36 #include <asm/system.h>
38 #include <asm/iosapic.h>
40 #include <acpi/acpi.h>
41 #include <acpi/acpi_bus.h>
42 #include <acpi/actypes.h>
46 #define PCI_MAX_BUS 0x100
47 #define ACPI_STA_DEVICE_PRESENT 0x01
49 #define METHOD_NAME__SUN "_SUN"
50 #define METHOD_NAME__HPP "_HPP"
51 #define METHOD_NAME_OSHP "OSHP"
53 #define PHP_RES_BUS 0xA0
54 #define PHP_RES_IO 0xA1
55 #define PHP_RES_MEM 0xA2
56 #define PHP_RES_PMEM 0xA3
58 #define BRIDGE_TYPE_P2P 0x00
59 #define BRIDGE_TYPE_HOST 0x01
61 /* this should go to drivers/acpi/include/ */
69 struct acpi_php_slot {
70 struct acpi_php_slot *next;
71 struct acpi_bridge *bridge;
78 struct pci_resource *mem_head;
79 struct pci_resource *p_mem_head;
80 struct pci_resource *io_head;
81 struct pci_resource *bus_head;
82 void *slot_ops; /* _STA, _EJx, etc */
87 struct acpi_bridge *parent;
88 struct acpi_bridge *next;
89 struct acpi_bridge *child;
92 int pbus; /* pdev->bus->number */
93 int pdevice; /* PCI_SLOT(pdev->devfn) */
94 int pfunction; /* PCI_DEVFN(pdev->devfn) */
95 int bus; /* pdev->subordinate->number */
96 struct acpi__hpp *_hpp;
97 struct acpi_php_slot *slots;
98 struct pci_resource *tmem_head; /* total from crs */
99 struct pci_resource *tp_mem_head; /* total from crs */
100 struct pci_resource *tio_head; /* total from crs */
101 struct pci_resource *tbus_head; /* total from crs */
102 struct pci_resource *mem_head; /* available */
103 struct pci_resource *p_mem_head; /* available */
104 struct pci_resource *io_head; /* available */
105 struct pci_resource *bus_head; /* available */
110 static struct acpi_bridge *acpi_bridges_head;
112 static u8 * acpi_path_name( acpi_handle handle)
115 static u8 path_name[ACPI_PATHNAME_MAX];
116 struct acpi_buffer ret_buf = { ACPI_PATHNAME_MAX, path_name };
118 memset(path_name, 0, sizeof (path_name));
119 status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf);
121 if (ACPI_FAILURE(status))
127 static void acpi_get__hpp ( struct acpi_bridge *ab);
128 static void acpi_run_oshp ( struct acpi_bridge *ab);
130 static int acpi_add_slot_to_php_slots(
131 struct acpi_bridge *ab,
138 struct acpi_php_slot *aps;
139 static long samesun = -1;
141 aps = (struct acpi_php_slot *) kmalloc (sizeof(struct acpi_php_slot), GFP_KERNEL);
143 err ("acpi_shpchprm: alloc for aps fail\n");
146 memset(aps, 0, sizeof(struct acpi_php_slot));
148 aps->handle = handle;
150 aps->dev = (adr >> 16) & 0xffff;
151 aps->fun = adr & 0xffff;
154 aps->next = ab->slots; /* cling to the bridge */
164 if (sun != samesun) {
165 info("acpi_shpchprm: Slot sun(%x) at s:b:d:f=0x%02x:%02x:%02x:%02x\n", aps->sun, ab->seg,
166 aps->bus, aps->dev, aps->fun);
172 static void acpi_get__hpp ( struct acpi_bridge *ab)
176 struct acpi_buffer ret_buf = { 0, NULL};
177 union acpi_object *ext_obj, *package;
178 u8 *path_name = acpi_path_name(ab->handle);
182 status = acpi_evaluate_object(ab->handle, METHOD_NAME__HPP, NULL, &ret_buf);
184 case AE_BUFFER_OVERFLOW:
185 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL);
186 if (!ret_buf.pointer) {
187 err ("acpi_shpchprm:%s alloc for _HPP fail\n", path_name);
190 status = acpi_evaluate_object(ab->handle, METHOD_NAME__HPP, NULL, &ret_buf);
191 if (ACPI_SUCCESS(status))
194 if (ACPI_FAILURE(status)) {
195 err("acpi_shpchprm:%s _HPP fail=0x%x\n", path_name, status);
200 ext_obj = (union acpi_object *) ret_buf.pointer;
201 if (ext_obj->type != ACPI_TYPE_PACKAGE) {
202 err ("acpi_shpchprm:%s _HPP obj not a package\n", path_name);
203 goto free_and_return;
206 len = ext_obj->package.count;
207 package = (union acpi_object *) ret_buf.pointer;
208 for ( i = 0; (i < len) || (i < 4); i++) {
209 ext_obj = (union acpi_object *) &package->package.elements[i];
210 switch (ext_obj->type) {
211 case ACPI_TYPE_INTEGER:
212 nui[i] = (u8)ext_obj->integer.value;
215 err ("acpi_shpchprm:%s _HPP obj type incorrect\n", path_name);
216 goto free_and_return;
220 ab->_hpp = kmalloc (sizeof (struct acpi__hpp), GFP_KERNEL);
222 err ("acpi_shpchprm:%s alloc for _HPP failed\n", path_name);
223 goto free_and_return;
225 memset(ab->_hpp, 0, sizeof(struct acpi__hpp));
227 ab->_hpp->cache_line_size = nui[0];
228 ab->_hpp->latency_timer = nui[1];
229 ab->_hpp->enable_serr = nui[2];
230 ab->_hpp->enable_perr = nui[3];
232 dbg(" _HPP: cache_line_size=0x%x\n", ab->_hpp->cache_line_size);
233 dbg(" _HPP: latency timer =0x%x\n", ab->_hpp->latency_timer);
234 dbg(" _HPP: enable SERR =0x%x\n", ab->_hpp->enable_serr);
235 dbg(" _HPP: enable PERR =0x%x\n", ab->_hpp->enable_perr);
238 kfree(ret_buf.pointer);
241 static void acpi_run_oshp ( struct acpi_bridge *ab)
244 u8 *path_name = acpi_path_name(ab->handle);
247 status = acpi_evaluate_object(ab->handle, METHOD_NAME_OSHP, NULL, NULL);
248 if (ACPI_FAILURE(status)) {
249 err("acpi_pciehprm:%s OSHP fails=0x%x\n", path_name, status);
251 dbg("acpi_pciehprm:%s OSHP passes =0x%x\n", path_name, status);
255 static acpi_status acpi_evaluate_crs(
257 struct acpi_resource **retbuf
261 struct acpi_buffer crsbuf;
262 u8 *path_name = acpi_path_name(handle);
265 crsbuf.pointer = NULL;
267 status = acpi_get_current_resources (handle, &crsbuf);
270 case AE_BUFFER_OVERFLOW:
273 dbg("acpi_shpchprm:%s _CRS not found\n", path_name);
276 err ("acpi_shpchprm:%s _CRS fail=0x%x\n", path_name, status);
280 crsbuf.pointer = kmalloc (crsbuf.length, GFP_KERNEL);
281 if (!crsbuf.pointer) {
282 err ("acpi_shpchprm: alloc %ld bytes for %s _CRS fail\n", (ulong)crsbuf.length, path_name);
286 status = acpi_get_current_resources (handle, &crsbuf);
287 if (ACPI_FAILURE(status)) {
288 err("acpi_shpchprm: %s _CRS fail=0x%x.\n", path_name, status);
289 kfree(crsbuf.pointer);
293 *retbuf = crsbuf.pointer;
298 static void free_pci_resource ( struct pci_resource *aprh)
300 struct pci_resource *res, *next;
302 for (res = aprh; res; res = next) {
308 static void print_pci_resource ( struct pci_resource *aprh)
310 struct pci_resource *res;
312 for (res = aprh; res; res = res->next)
313 dbg(" base= 0x%x length= 0x%x\n", res->base, res->length);
316 static void print_slot_resources( struct acpi_php_slot *aps)
319 dbg(" BUS Resources:\n");
320 print_pci_resource (aps->bus_head);
324 dbg(" IO Resources:\n");
325 print_pci_resource (aps->io_head);
329 dbg(" MEM Resources:\n");
330 print_pci_resource (aps->mem_head);
333 if (aps->p_mem_head) {
334 dbg(" PMEM Resources:\n");
335 print_pci_resource (aps->p_mem_head);
339 static void print_pci_resources( struct acpi_bridge *ab)
342 dbg(" Total BUS Resources:\n");
343 print_pci_resource (ab->tbus_head);
346 dbg(" BUS Resources:\n");
347 print_pci_resource (ab->bus_head);
351 dbg(" Total IO Resources:\n");
352 print_pci_resource (ab->tio_head);
355 dbg(" IO Resources:\n");
356 print_pci_resource (ab->io_head);
360 dbg(" Total MEM Resources:\n");
361 print_pci_resource (ab->tmem_head);
364 dbg(" MEM Resources:\n");
365 print_pci_resource (ab->mem_head);
368 if (ab->tp_mem_head) {
369 dbg(" Total PMEM Resources:\n");
370 print_pci_resource (ab->tp_mem_head);
372 if (ab->p_mem_head) {
373 dbg(" PMEM Resources:\n");
374 print_pci_resource (ab->p_mem_head);
377 dbg(" _HPP: cache_line_size=0x%x\n", ab->_hpp->cache_line_size);
378 dbg(" _HPP: latency timer =0x%x\n", ab->_hpp->latency_timer);
379 dbg(" _HPP: enable SERR =0x%x\n", ab->_hpp->enable_serr);
380 dbg(" _HPP: enable PERR =0x%x\n", ab->_hpp->enable_perr);
384 static int shpchprm_delete_resource(
385 struct pci_resource **aprh,
389 struct pci_resource *res;
390 struct pci_resource *prevnode;
391 struct pci_resource *split_node;
394 shpchp_resource_sort_and_combine(aprh);
396 for (res = *aprh; res; res = res->next) {
397 if (res->base > base)
400 if ((res->base + res->length) < (base + size))
403 if (res->base < base) {
406 if ((res->length - (tbase - res->base)) < size)
409 split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
413 split_node->base = res->base;
414 split_node->length = tbase - res->base;
416 res->length -= split_node->length;
418 split_node->next = res->next;
419 res->next = split_node;
422 if (res->length >= size) {
423 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
427 split_node->base = res->base + size;
428 split_node->length = res->length - size;
431 split_node->next = res->next;
432 res->next = split_node;
439 while (prevnode->next != res)
440 prevnode = prevnode->next;
442 prevnode->next = res->next;
452 static int shpchprm_delete_resources(
453 struct pci_resource **aprh,
454 struct pci_resource *this
457 struct pci_resource *res;
459 for (res = this; res; res = res->next)
460 shpchprm_delete_resource(aprh, res->base, res->length);
465 static int shpchprm_add_resource(
466 struct pci_resource **aprh,
470 struct pci_resource *res;
472 for (res = *aprh; res; res = res->next) {
473 if ((res->base + res->length) == base) {
478 if (res->next == *aprh)
483 res = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
485 err ("acpi_shpchprm: alloc for res fail\n");
488 memset(res, 0, sizeof (struct pci_resource));
499 static int shpchprm_add_resources(
500 struct pci_resource **aprh,
501 struct pci_resource *this
504 struct pci_resource *res;
507 for (res = this; res && !rc; res = res->next)
508 rc = shpchprm_add_resource(aprh, res->base, res->length);
513 static void acpi_parse_io (
514 struct acpi_bridge *ab,
515 union acpi_resource_data *data
518 struct acpi_resource_io *dataio;
519 dataio = (struct acpi_resource_io *) data;
521 dbg("Io Resource\n");
522 dbg(" %d bit decode\n", ACPI_DECODE_16 == dataio->io_decode ? 16:10);
523 dbg(" Range minimum base: %08X\n", dataio->min_base_address);
524 dbg(" Range maximum base: %08X\n", dataio->max_base_address);
525 dbg(" Alignment: %08X\n", dataio->alignment);
526 dbg(" Range Length: %08X\n", dataio->range_length);
529 static void acpi_parse_fixed_io (
530 struct acpi_bridge *ab,
531 union acpi_resource_data *data
534 struct acpi_resource_fixed_io *datafio;
535 datafio = (struct acpi_resource_fixed_io *) data;
537 dbg("Fixed Io Resource\n");
538 dbg(" Range base address: %08X", datafio->base_address);
539 dbg(" Range length: %08X", datafio->range_length);
542 static void acpi_parse_address16_32 (
543 struct acpi_bridge *ab,
544 union acpi_resource_data *data,
545 acpi_resource_type id
549 * acpi_resource_address16 == acpi_resource_address32
550 * acpi_resource_address16 *data16 = (acpi_resource_address16 *) data;
552 struct acpi_resource_address32 *data32 = (struct acpi_resource_address32 *) data;
553 struct pci_resource **aprh, **tprh;
555 if (id == ACPI_RSTYPE_ADDRESS16)
556 dbg("acpi_shpchprm:16-Bit Address Space Resource\n");
558 dbg("acpi_shpchprm:32-Bit Address Space Resource\n");
560 switch (data32->resource_type) {
561 case ACPI_MEMORY_RANGE:
562 dbg(" Resource Type: Memory Range\n");
563 aprh = &ab->mem_head;
564 tprh = &ab->tmem_head;
566 switch (data32->attribute.memory.cache_attribute) {
567 case ACPI_NON_CACHEABLE_MEMORY:
568 dbg(" Type Specific: Noncacheable memory\n");
570 case ACPI_CACHABLE_MEMORY:
571 dbg(" Type Specific: Cacheable memory\n");
573 case ACPI_WRITE_COMBINING_MEMORY:
574 dbg(" Type Specific: Write-combining memory\n");
576 case ACPI_PREFETCHABLE_MEMORY:
577 aprh = &ab->p_mem_head;
578 dbg(" Type Specific: Prefetchable memory\n");
581 dbg(" Type Specific: Invalid cache attribute\n");
585 dbg(" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == data32->attribute.memory.read_write_attribute ? "/Write":" Only");
589 dbg(" Resource Type: I/O Range\n");
591 tprh = &ab->tio_head;
593 switch (data32->attribute.io.range_attribute) {
594 case ACPI_NON_ISA_ONLY_RANGES:
595 dbg(" Type Specific: Non-ISA Io Addresses\n");
597 case ACPI_ISA_ONLY_RANGES:
598 dbg(" Type Specific: ISA Io Addresses\n");
600 case ACPI_ENTIRE_RANGE:
601 dbg(" Type Specific: ISA and non-ISA Io Addresses\n");
604 dbg(" Type Specific: Invalid range attribute\n");
609 case ACPI_BUS_NUMBER_RANGE:
610 dbg(" Resource Type: Bus Number Range(fixed)\n");
611 /* fixup to be compatible with the rest of php driver */
612 data32->min_address_range++;
613 data32->address_length--;
614 aprh = &ab->bus_head;
615 tprh = &ab->tbus_head;
618 dbg(" Resource Type: Invalid resource type. Exiting.\n");
622 dbg(" Resource %s\n", ACPI_CONSUMER == data32->producer_consumer ? "Consumer":"Producer");
623 dbg(" %s decode\n", ACPI_SUB_DECODE == data32->decode ? "Subtractive":"Positive");
624 dbg(" Min address is %s fixed\n", ACPI_ADDRESS_FIXED == data32->min_address_fixed ? "":"not");
625 dbg(" Max address is %s fixed\n", ACPI_ADDRESS_FIXED == data32->max_address_fixed ? "":"not");
626 dbg(" Granularity: %08X\n", data32->granularity);
627 dbg(" Address range min: %08X\n", data32->min_address_range);
628 dbg(" Address range max: %08X\n", data32->max_address_range);
629 dbg(" Address translation offset: %08X\n", data32->address_translation_offset);
630 dbg(" Address Length: %08X\n", data32->address_length);
632 if (0xFF != data32->resource_source.index) {
633 dbg(" Resource Source Index: %X\n", data32->resource_source.index);
634 /* dbg(" Resource Source: %s\n", data32->resource_source.string_ptr); */
637 shpchprm_add_resource(aprh, data32->min_address_range, data32->address_length);
640 static acpi_status acpi_parse_crs(
641 struct acpi_bridge *ab,
642 struct acpi_resource *crsbuf
645 acpi_status status = AE_OK;
646 struct acpi_resource *resource = crsbuf;
651 dbg("acpi_shpchprm: PCI bus 0x%x Resource structure %x.\n", ab->bus, count++);
652 switch (resource->id) {
653 case ACPI_RSTYPE_IRQ:
654 dbg("Irq -------- Resource\n");
656 case ACPI_RSTYPE_DMA:
657 dbg("DMA -------- Resource\n");
659 case ACPI_RSTYPE_START_DPF:
660 dbg("Start DPF -------- Resource\n");
662 case ACPI_RSTYPE_END_DPF:
663 dbg("End DPF -------- Resource\n");
666 acpi_parse_io (ab, &resource->data);
668 case ACPI_RSTYPE_FIXED_IO:
669 acpi_parse_fixed_io (ab, &resource->data);
671 case ACPI_RSTYPE_VENDOR:
672 dbg("Vendor -------- Resource\n");
674 case ACPI_RSTYPE_END_TAG:
675 dbg("End_tag -------- Resource\n");
678 case ACPI_RSTYPE_MEM24:
679 dbg("Mem24 -------- Resource\n");
681 case ACPI_RSTYPE_MEM32:
682 dbg("Mem32 -------- Resource\n");
684 case ACPI_RSTYPE_FIXED_MEM32:
685 dbg("Fixed Mem32 -------- Resource\n");
687 case ACPI_RSTYPE_ADDRESS16:
688 acpi_parse_address16_32(ab, &resource->data, ACPI_RSTYPE_ADDRESS16);
690 case ACPI_RSTYPE_ADDRESS32:
691 acpi_parse_address16_32(ab, &resource->data, ACPI_RSTYPE_ADDRESS32);
693 case ACPI_RSTYPE_ADDRESS64:
694 info("Address64 -------- Resource unparsed\n");
696 case ACPI_RSTYPE_EXT_IRQ:
697 dbg("Ext Irq -------- Resource\n");
700 dbg("Invalid -------- resource type 0x%x\n", resource->id);
704 resource = (struct acpi_resource *) ((char *)resource + resource->length);
710 static acpi_status acpi_get_crs( struct acpi_bridge *ab)
713 struct acpi_resource *crsbuf;
715 status = acpi_evaluate_crs(ab->handle, &crsbuf);
716 if (ACPI_SUCCESS(status)) {
717 status = acpi_parse_crs(ab, crsbuf);
720 shpchp_resource_sort_and_combine(&ab->bus_head);
721 shpchp_resource_sort_and_combine(&ab->io_head);
722 shpchp_resource_sort_and_combine(&ab->mem_head);
723 shpchp_resource_sort_and_combine(&ab->p_mem_head);
725 shpchprm_add_resources (&ab->tbus_head, ab->bus_head);
726 shpchprm_add_resources (&ab->tio_head, ab->io_head);
727 shpchprm_add_resources (&ab->tmem_head, ab->mem_head);
728 shpchprm_add_resources (&ab->tp_mem_head, ab->p_mem_head);
734 /* find acpi_bridge downword from ab. */
735 static struct acpi_bridge *
736 find_acpi_bridge_by_bus(
737 struct acpi_bridge *ab,
739 int bus /* pdev->subordinate->number */
742 struct acpi_bridge *lab = NULL;
747 if ((ab->bus == bus) && (ab->seg == seg))
751 lab = find_acpi_bridge_by_bus(ab->child, seg, bus);
755 lab = find_acpi_bridge_by_bus(ab->next, seg, bus);
761 * Build a device tree of ACPI PCI Bridges
763 static void shpchprm_acpi_register_a_bridge (
764 struct acpi_bridge **head,
765 struct acpi_bridge *pab, /* parent bridge to which child bridge is added */
766 struct acpi_bridge *cab /* child bridge to add */
769 struct acpi_bridge *lpab;
770 struct acpi_bridge *lcab;
772 lpab = find_acpi_bridge_by_bus(*head, pab->seg, pab->bus);
774 if (!(pab->type & BRIDGE_TYPE_HOST))
775 warn("PCI parent bridge s:b(%x:%x) not in list.\n", pab->seg, pab->bus);
781 if ((cab->type & BRIDGE_TYPE_HOST) && (pab == cab))
784 lcab = find_acpi_bridge_by_bus(*head, cab->seg, cab->bus);
786 if ((pab->bus != lcab->parent->bus) || (lcab->bus != cab->bus))
787 err("PCI child bridge s:b(%x:%x) in list with diff parent.\n", cab->seg, cab->bus);
793 lcab->next = lpab->child;
797 static acpi_status shpchprm_acpi_build_php_slots_callback(
808 acpi_handle phandle = NULL;
809 struct acpi_bridge *pab = (struct acpi_bridge *)context;
810 struct acpi_bridge *lab;
812 u8 *path_name = acpi_path_name(handle);
815 status = acpi_evaluate_integer(handle, METHOD_NAME__SUN, NULL, &sun);
820 if (ACPI_FAILURE(status)) {
821 err("acpi_shpchprm:%s _SUN fail=0x%x\n", path_name, status);
826 /* get _ADR. _ADR must exist if _SUN exists */
827 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
828 if (ACPI_FAILURE(status)) {
829 err("acpi_shpchprm:%s _ADR fail=0x%x\n", path_name, status);
833 dbg("acpi_shpchprm:%s sun=0x%08x adr=0x%08x\n", path_name, (u32)sun, (u32)adr);
835 status = acpi_get_parent(handle, &phandle);
836 if (ACPI_FAILURE(status)) {
837 err("acpi_shpchprm:%s get_parent fail=0x%x\n", path_name, status);
844 if (pab->bus == bus_num) {
847 dbg("WARN: pab is not parent\n");
848 lab = find_acpi_bridge_by_bus(pab, seg_num, bus_num);
850 dbg("acpi_shpchprm: alloc new P2P bridge(%x) for sun(%08x)\n", (u32)bus_num, (u32)sun);
851 lab = (struct acpi_bridge *)kmalloc(sizeof(struct acpi_bridge), GFP_KERNEL);
853 err("acpi_shpchprm: alloc for ab fail\n");
856 memset(lab, 0, sizeof(struct acpi_bridge));
858 lab->handle = phandle;
859 lab->pbus = pab->bus;
860 lab->pdevice = (int)(padr >> 16) & 0xffff;
861 lab->pfunction = (int)(padr & 0xffff);
862 lab->bus = (int)bus_num;
864 lab->type = BRIDGE_TYPE_P2P;
866 shpchprm_acpi_register_a_bridge (&acpi_bridges_head, pab, lab);
868 dbg("acpi_shpchprm: found P2P bridge(%x) for sun(%08x)\n", (u32)bus_num, (u32)sun);
871 acpi_add_slot_to_php_slots(lab, (int)bus_num, handle, (u32)adr, (u32)sun);
875 static int shpchprm_acpi_build_php_slots(
876 struct acpi_bridge *ab,
881 u8 *path_name = acpi_path_name(ab->handle);
883 /* Walk down this pci bridge to get _SUNs if any behind P2P */
884 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
887 shpchprm_acpi_build_php_slots_callback,
890 if (ACPI_FAILURE(status)) {
891 dbg("acpi_shpchprm:%s walk for _SUN on pci bridge seg:bus(%x:%x) fail=0x%x\n", path_name, ab->seg, ab->bus, status);
898 static void build_a_bridge(
899 struct acpi_bridge *pab,
900 struct acpi_bridge *ab
903 u8 *path_name = acpi_path_name(ab->handle);
905 shpchprm_acpi_register_a_bridge (&acpi_bridges_head, pab, ab);
908 case BRIDGE_TYPE_HOST:
909 dbg("acpi_shpchprm: Registered PCI HOST Bridge(%02x) on s:b:d:f(%02x:%02x:%02x:%02x) [%s]\n",
910 ab->bus, ab->seg, ab->pbus, ab->pdevice, ab->pfunction, path_name);
912 case BRIDGE_TYPE_P2P:
913 dbg("acpi_shpchprm: Registered PCI P2P Bridge(%02x-%02x) on s:b:d:f(%02x:%02x:%02x:%02x) [%s]\n",
914 ab->pbus, ab->bus, ab->seg, ab->pbus, ab->pdevice, ab->pfunction, path_name);
918 /* build any immediate PHP slots under this pci bridge */
919 shpchprm_acpi_build_php_slots(ab, 1);
922 static struct acpi_bridge * add_p2p_bridge(
924 struct acpi_bridge *pab, /* parent */
928 struct acpi_bridge *ab;
929 struct pci_dev *pdev;
930 ulong devnum, funcnum;
931 u8 *path_name = acpi_path_name(handle);
933 ab = (struct acpi_bridge *) kmalloc (sizeof(struct acpi_bridge), GFP_KERNEL);
935 err("acpi_shpchprm: alloc for ab fail\n");
938 memset(ab, 0, sizeof(struct acpi_bridge));
940 devnum = (adr >> 16) & 0xffff;
941 funcnum = adr & 0xffff;
943 pdev = pci_find_slot(pab->bus, PCI_DEVFN(devnum, funcnum));
944 if (!pdev || !pdev->subordinate) {
945 err("acpi_shpchprm:%s is not a P2P Bridge\n", path_name);
952 ab->pbus = pab->bus; /* or pdev->bus->number */
953 ab->pdevice = devnum; /* or PCI_SLOT(pdev->devfn) */
954 ab->pfunction = funcnum; /* or PCI_FUNC(pdev->devfn) */
955 ab->bus = pdev->subordinate->number;
957 ab->type = BRIDGE_TYPE_P2P;
959 dbg("acpi_shpchprm: P2P(%x-%x) on pci=b:d:f(%x:%x:%x) acpi=b:d:f(%x:%x:%x) [%s]\n",
960 pab->bus, ab->bus, pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
961 pab->bus, (u32)devnum, (u32)funcnum, path_name);
963 build_a_bridge(pab, ab);
968 static acpi_status scan_p2p_bridge(
975 struct acpi_bridge *pab = (struct acpi_bridge *)context;
976 struct acpi_bridge *ab;
979 u8 *path_name = acpi_path_name(handle);
980 ulong devnum, funcnum;
981 struct pci_dev *pdev;
983 /* get device, function */
984 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
985 if (ACPI_FAILURE(status)) {
986 if (status != AE_NOT_FOUND)
987 err("acpi_shpchprm:%s _ADR fail=0x%x\n", path_name, status);
991 devnum = (adr >> 16) & 0xffff;
992 funcnum = adr & 0xffff;
994 pdev = pci_find_slot(pab->bus, PCI_DEVFN(devnum, funcnum));
997 if (!pdev->subordinate)
1000 ab = add_p2p_bridge(handle, pab, adr);
1002 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
1008 if (ACPI_FAILURE(status))
1009 dbg("acpi_shpchprm:%s find_p2p fail=0x%x\n", path_name, status);
1015 static struct acpi_bridge * add_host_bridge(
1023 struct acpi_bridge *ab;
1024 u8 *path_name = acpi_path_name(handle);
1026 /* get device, function: host br adr is always 0000 though. */
1027 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
1028 if (ACPI_FAILURE(status)) {
1029 err("acpi_shpchprm:%s _ADR fail=0x%x\n", path_name, status);
1032 dbg("acpi_shpchprm: ROOT PCI seg(0x%x)bus(0x%x)dev(0x%x)func(0x%x) [%s]\n", (u32)segnum, (u32)busnum,
1033 (u32)(adr >> 16) & 0xffff, (u32)adr & 0xffff, path_name);
1035 ab = (struct acpi_bridge *) kmalloc (sizeof(struct acpi_bridge), GFP_KERNEL);
1037 err("acpi_shpchprm: alloc for ab fail\n");
1040 memset(ab, 0, sizeof(struct acpi_bridge));
1042 ab->handle = handle;
1043 ab->seg = (int)segnum;
1044 ab->bus = ab->pbus = (int)busnum;
1045 ab->pdevice = (int)(adr >> 16) & 0xffff;
1046 ab->pfunction = (int)(adr & 0xffff);
1048 ab->type = BRIDGE_TYPE_HOST;
1050 /* get root pci bridge's current resources */
1051 status = acpi_get_crs(ab);
1052 if (ACPI_FAILURE(status)) {
1053 err("acpi_shpchprm:%s evaluate _CRS fail=0x%x\n", path_name, status);
1057 build_a_bridge(ab, ab);
1062 static acpi_status acpi_scan_from_root_pci_callback (
1072 struct acpi_bridge *ab;
1073 u8 *path_name = acpi_path_name(handle);
1075 /* get bus number of this pci root bridge */
1076 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &segnum);
1077 if (ACPI_FAILURE(status)) {
1078 if (status != AE_NOT_FOUND) {
1079 err("acpi_shpchprm:%s evaluate _SEG fail=0x%x\n", path_name, status);
1085 /* get bus number of this pci root bridge */
1086 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL, &busnum);
1087 if (ACPI_FAILURE(status)) {
1088 err("acpi_shpchprm:%s evaluate _BBN fail=0x%x\n", path_name, status);
1092 ab = add_host_bridge(handle, segnum, busnum);
1094 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
1100 if (ACPI_FAILURE(status))
1101 dbg("acpi_shpchprm:%s find_p2p fail=0x%x\n", path_name, status);
1107 static int shpchprm_acpi_scan_pci (void)
1112 * TBD: traverse LDM device tree with the help of
1113 * unified ACPI augmented for php device population.
1115 status = acpi_get_devices ( PCI_ROOT_HID_STRING,
1116 acpi_scan_from_root_pci_callback,
1119 if (ACPI_FAILURE(status)) {
1120 err("acpi_shpchprm:get_device PCI ROOT HID fail=0x%x\n", status);
1127 int shpchprm_init(enum php_ctlr_type ctlr_type)
1131 if (ctlr_type != PCI)
1134 dbg("shpchprm ACPI init <enter>\n");
1135 acpi_bridges_head = NULL;
1137 /* construct PCI bus:device tree of acpi_handles */
1138 rc = shpchprm_acpi_scan_pci();
1142 dbg("shpchprm ACPI init %s\n", (rc)?"fail":"success");
1146 static void free_a_slot(struct acpi_php_slot *aps)
1148 dbg(" free a php func of slot(0x%02x) on PCI b:d:f=0x%02x:%02x:%02x\n", aps->sun, aps->bus, aps->dev, aps->fun);
1150 free_pci_resource (aps->io_head);
1151 free_pci_resource (aps->bus_head);
1152 free_pci_resource (aps->mem_head);
1153 free_pci_resource (aps->p_mem_head);
1158 static void free_a_bridge( struct acpi_bridge *ab)
1160 struct acpi_php_slot *aps, *next;
1163 case BRIDGE_TYPE_HOST:
1164 dbg("Free ACPI PCI HOST Bridge(%x) [%s] on s:b:d:f(%x:%x:%x:%x)\n",
1165 ab->bus, acpi_path_name(ab->handle), ab->seg, ab->pbus, ab->pdevice, ab->pfunction);
1167 case BRIDGE_TYPE_P2P:
1168 dbg("Free ACPI PCI P2P Bridge(%x-%x) [%s] on s:b:d:f(%x:%x:%x:%x)\n",
1169 ab->pbus, ab->bus, acpi_path_name(ab->handle), ab->seg, ab->pbus, ab->pdevice, ab->pfunction);
1173 /* free slots first */
1174 for (aps = ab->slots; aps; aps = next) {
1179 free_pci_resource (ab->io_head);
1180 free_pci_resource (ab->tio_head);
1181 free_pci_resource (ab->bus_head);
1182 free_pci_resource (ab->tbus_head);
1183 free_pci_resource (ab->mem_head);
1184 free_pci_resource (ab->tmem_head);
1185 free_pci_resource (ab->p_mem_head);
1186 free_pci_resource (ab->tp_mem_head);
1191 static void shpchprm_free_bridges ( struct acpi_bridge *ab)
1197 shpchprm_free_bridges (ab->child);
1200 shpchprm_free_bridges (ab->next);
1205 void shpchprm_cleanup(void)
1207 shpchprm_free_bridges (acpi_bridges_head);
1210 static int get_number_of_slots (
1211 struct acpi_bridge *ab,
1215 struct acpi_php_slot *aps;
1219 for ( aps = ab->slots; aps; aps = aps->next)
1220 if (aps->dev != prev_slot) {
1221 prev_slot = aps->dev;
1226 slot_num += get_number_of_slots (ab->child, 0);
1232 slot_num += get_number_of_slots (ab->next, 0);
1237 static int print_acpi_resources (struct acpi_bridge *ab)
1239 struct acpi_php_slot *aps;
1243 case BRIDGE_TYPE_HOST:
1244 dbg("PCI HOST Bridge (%x) [%s]\n", ab->bus, acpi_path_name(ab->handle));
1246 case BRIDGE_TYPE_P2P:
1247 dbg("PCI P2P Bridge (%x-%x) [%s]\n", ab->pbus, ab->bus, acpi_path_name(ab->handle));
1251 print_pci_resources (ab);
1253 for ( i = -1, aps = ab->slots; aps; aps = aps->next) {
1256 dbg(" Slot sun(%x) s:b:d:f(%02x:%02x:%02x:%02x)\n", aps->sun, aps->seg, aps->bus, aps->dev, aps->fun);
1257 print_slot_resources(aps);
1262 print_acpi_resources (ab->child);
1265 print_acpi_resources (ab->next);
1270 int shpchprm_print_pirt(void)
1272 dbg("SHPCHPRM ACPI Slots\n");
1273 if (acpi_bridges_head)
1274 print_acpi_resources (acpi_bridges_head);
1278 static struct acpi_php_slot * get_acpi_slot (
1279 struct acpi_bridge *ab,
1283 struct acpi_php_slot *aps = NULL;
1285 for ( aps = ab->slots; aps; aps = aps->next)
1286 if (aps->sun == sun)
1289 if (!aps && ab->child) {
1290 aps = (struct acpi_php_slot *)get_acpi_slot (ab->child, sun);
1295 if (!aps && ab->next) {
1296 aps = (struct acpi_php_slot *)get_acpi_slot (ab->next, sun);
1306 static void * shpchprm_get_slot(struct slot *slot)
1308 struct acpi_bridge *ab = acpi_bridges_head;
1309 struct acpi_php_slot *aps = get_acpi_slot (ab, slot->number);
1313 dbg("Got acpi slot sun(%x): s:b:d:f(%x:%x:%x:%x)\n", aps->sun, aps->seg, aps->bus, aps->dev, aps->fun);
1319 static void shpchprm_dump_func_res( struct pci_func *fun)
1321 struct pci_func *func = fun;
1323 if (func->bus_head) {
1324 dbg(": BUS Resources:\n");
1325 print_pci_resource (func->bus_head);
1327 if (func->io_head) {
1328 dbg(": IO Resources:\n");
1329 print_pci_resource (func->io_head);
1331 if (func->mem_head) {
1332 dbg(": MEM Resources:\n");
1333 print_pci_resource (func->mem_head);
1335 if (func->p_mem_head) {
1336 dbg(": PMEM Resources:\n");
1337 print_pci_resource (func->p_mem_head);
1341 static void shpchprm_dump_ctrl_res( struct controller *ctlr)
1343 struct controller *ctrl = ctlr;
1345 if (ctrl->bus_head) {
1346 dbg(": BUS Resources:\n");
1347 print_pci_resource (ctrl->bus_head);
1349 if (ctrl->io_head) {
1350 dbg(": IO Resources:\n");
1351 print_pci_resource (ctrl->io_head);
1353 if (ctrl->mem_head) {
1354 dbg(": MEM Resources:\n");
1355 print_pci_resource (ctrl->mem_head);
1357 if (ctrl->p_mem_head) {
1358 dbg(": PMEM Resources:\n");
1359 print_pci_resource (ctrl->p_mem_head);
1363 static int shpchprm_get_used_resources (
1364 struct controller *ctrl,
1365 struct pci_func *func
1368 return shpchp_save_used_resources (ctrl, func, !DISABLE_CARD);
1371 static int configure_existing_function(
1372 struct controller *ctrl,
1373 struct pci_func *func
1378 /* see how much resources the func has used. */
1379 rc = shpchprm_get_used_resources (ctrl, func);
1382 /* subtract the resources used by the func from ctrl resources */
1383 rc = shpchprm_delete_resources (&ctrl->bus_head, func->bus_head);
1384 rc |= shpchprm_delete_resources (&ctrl->io_head, func->io_head);
1385 rc |= shpchprm_delete_resources (&ctrl->mem_head, func->mem_head);
1386 rc |= shpchprm_delete_resources (&ctrl->p_mem_head, func->p_mem_head);
1388 warn("aCEF: cannot del used resources\n");
1390 err("aCEF: cannot get used resources\n");
1395 static int bind_pci_resources_to_slots ( struct controller *ctrl)
1397 struct pci_func *func, new_func;
1398 int busn = ctrl->slot_bus;
1402 for (devn = 0; devn < 32; devn++) {
1403 for (funn = 0; funn < 8; funn++) {
1405 if (devn == ctrl->device && funn == ctrl->function)
1408 /* find out if this entry is for an occupied slot */
1410 pci_bus_read_config_dword(ctrl->pci_dev->subordinate, PCI_DEVFN(devn, funn), PCI_VENDOR_ID, &vid);
1412 if (vid != 0xFFFFFFFF) {
1413 func = shpchp_slot_find(busn, devn, funn);
1415 memset(&new_func, 0, sizeof(struct pci_func));
1416 new_func.bus = busn;
1417 new_func.device = devn;
1418 new_func.function = funn;
1419 new_func.is_a_board = 1;
1420 configure_existing_function(ctrl, &new_func);
1421 shpchprm_dump_func_res(&new_func);
1423 configure_existing_function(ctrl, func);
1424 shpchprm_dump_func_res(func);
1426 dbg("aCCF:existing PCI 0x%x Func ResourceDump\n", ctrl->bus);
1434 static int bind_pci_resources(
1435 struct controller *ctrl,
1436 struct acpi_bridge *ab
1442 dbg("bapr: BUS Resources add on PCI 0x%x\n", ab->bus);
1443 status = shpchprm_add_resources (&ctrl->bus_head, ab->bus_head);
1444 if (shpchprm_delete_resources (&ab->bus_head, ctrl->bus_head))
1445 warn("bapr: cannot sub BUS Resource on PCI 0x%x\n", ab->bus);
1447 err("bapr: BUS Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1451 info("bapr: No BUS Resource on PCI 0x%x.\n", ab->bus);
1454 dbg("bapr: IO Resources add on PCI 0x%x\n", ab->bus);
1455 status = shpchprm_add_resources (&ctrl->io_head, ab->io_head);
1456 if (shpchprm_delete_resources (&ab->io_head, ctrl->io_head))
1457 warn("bapr: cannot sub IO Resource on PCI 0x%x\n", ab->bus);
1459 err("bapr: IO Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1463 info("bapr: No IO Resource on PCI 0x%x.\n", ab->bus);
1466 dbg("bapr: MEM Resources add on PCI 0x%x\n", ab->bus);
1467 status = shpchprm_add_resources (&ctrl->mem_head, ab->mem_head);
1468 if (shpchprm_delete_resources (&ab->mem_head, ctrl->mem_head))
1469 warn("bapr: cannot sub MEM Resource on PCI 0x%x\n", ab->bus);
1471 err("bapr: MEM Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1475 info("bapr: No MEM Resource on PCI 0x%x.\n", ab->bus);
1477 if (ab->p_mem_head) {
1478 dbg("bapr: PMEM Resources add on PCI 0x%x\n", ab->bus);
1479 status = shpchprm_add_resources (&ctrl->p_mem_head, ab->p_mem_head);
1480 if (shpchprm_delete_resources (&ab->p_mem_head, ctrl->p_mem_head))
1481 warn("bapr: cannot sub PMEM Resource on PCI 0x%x\n", ab->bus);
1483 err("bapr: PMEM Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1487 info("bapr: No PMEM Resource on PCI 0x%x.\n", ab->bus);
1492 static int no_pci_resources( struct acpi_bridge *ab)
1494 return !(ab->p_mem_head || ab->mem_head || ab->io_head || ab->bus_head);
1497 static int find_pci_bridge_resources (
1498 struct controller *ctrl,
1499 struct acpi_bridge *ab
1503 struct pci_func func;
1505 memset(&func, 0, sizeof(struct pci_func));
1507 func.bus = ab->pbus;
1508 func.device = ab->pdevice;
1509 func.function = ab->pfunction;
1510 func.is_a_board = 1;
1512 /* Get used resources for this PCI bridge */
1513 rc = shpchp_save_used_resources (ctrl, &func, !DISABLE_CARD);
1515 ab->io_head = func.io_head;
1516 ab->mem_head = func.mem_head;
1517 ab->p_mem_head = func.p_mem_head;
1518 ab->bus_head = func.bus_head;
1520 shpchprm_delete_resource(&ab->bus_head, ctrl->bus, 1);
1525 static int get_pci_resources_from_bridge(
1526 struct controller *ctrl,
1527 struct acpi_bridge *ab
1532 dbg("grfb: Get Resources for PCI 0x%x from actual PCI bridge 0x%x.\n", ctrl->bus, ab->bus);
1534 rc = find_pci_bridge_resources (ctrl, ab);
1536 shpchp_resource_sort_and_combine(&ab->bus_head);
1537 shpchp_resource_sort_and_combine(&ab->io_head);
1538 shpchp_resource_sort_and_combine(&ab->mem_head);
1539 shpchp_resource_sort_and_combine(&ab->p_mem_head);
1541 shpchprm_add_resources (&ab->tbus_head, ab->bus_head);
1542 shpchprm_add_resources (&ab->tio_head, ab->io_head);
1543 shpchprm_add_resources (&ab->tmem_head, ab->mem_head);
1544 shpchprm_add_resources (&ab->tp_mem_head, ab->p_mem_head);
1549 static int get_pci_resources(
1550 struct controller *ctrl,
1551 struct acpi_bridge *ab
1556 if (no_pci_resources(ab)) {
1557 dbg("spbr:PCI 0x%x has no resources. Get parent resources.\n", ab->bus);
1558 rc = get_pci_resources_from_bridge(ctrl, ab);
1564 int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum)
1566 int offset = devnum - ctrl->slot_device_offset;
1568 dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, ctrl->slot_num_inc, offset);
1569 *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc *offset);
1574 * Get resources for this ctrl.
1575 * 1. get total resources from ACPI _CRS or bridge (this ctrl)
1576 * 2. find used resources of existing adapters
1577 * 3. subtract used resources from total resources
1579 int shpchprm_find_available_resources( struct controller *ctrl)
1582 struct acpi_bridge *ab;
1584 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->pci_dev->subordinate->number);
1586 err("pfar:cannot locate acpi bridge of PCI 0x%x.\n", ctrl->pci_dev->subordinate->number);
1589 if (no_pci_resources(ab)) {
1590 rc = get_pci_resources(ctrl, ab);
1592 err("pfar:cannot get pci resources of PCI 0x%x.\n",ctrl->pci_dev->subordinate->number);
1597 rc = bind_pci_resources(ctrl, ab);
1598 dbg("pfar:pre-Bind PCI 0x%x Ctrl Resource Dump\n", ctrl->pci_dev->subordinate->number);
1599 shpchprm_dump_ctrl_res(ctrl);
1601 bind_pci_resources_to_slots (ctrl);
1603 dbg("pfar:post-Bind PCI 0x%x Ctrl Resource Dump\n", ctrl->pci_dev->subordinate->number);
1604 shpchprm_dump_ctrl_res(ctrl);
1609 int shpchprm_set_hpp(
1610 struct controller *ctrl,
1611 struct pci_func *func,
1615 struct acpi_bridge *ab;
1616 struct pci_bus lpci_bus, *pci_bus;
1619 u8 cls= 0x08; /* default cache line size */
1620 u8 lt = 0x40; /* default latency timer */
1624 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
1625 pci_bus = &lpci_bus;
1626 pci_bus->number = func->bus;
1627 devfn = PCI_DEVFN(func->device, func->function);
1629 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus);
1633 lt = (u8)ab->_hpp->latency_timer;
1634 cls = (u8)ab->_hpp->cache_line_size;
1635 ep = (u8)ab->_hpp->enable_perr;
1636 es = (u8)ab->_hpp->enable_serr;
1638 dbg("_hpp: no _hpp for B/D/F=%#x/%#x/%#x. use default value\n", func->bus, func->device, func->function);
1640 dbg("_hpp: no acpi bridge for B/D/F = %#x/%#x/%#x. use default value\n", func->bus, func->device, func->function);
1643 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
1644 /* set subordinate Latency Timer */
1645 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, lt);
1648 /* set base Latency Timer */
1649 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_LATENCY_TIMER, lt);
1650 dbg(" set latency timer =0x%02x: %x\n", lt, rc);
1652 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, cls);
1653 dbg(" set cache_line_size=0x%02x: %x\n", cls, rc);
1658 void shpchprm_enable_card(
1659 struct controller *ctrl,
1660 struct pci_func *func,
1663 u16 command, cmd, bcommand, bcmd;
1664 struct pci_bus lpci_bus, *pci_bus;
1665 struct acpi_bridge *ab;
1669 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
1670 pci_bus = &lpci_bus;
1671 pci_bus->number = func->bus;
1672 devfn = PCI_DEVFN(func->device, func->function);
1674 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &command);
1676 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
1677 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcommand);
1680 cmd = command = command | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
1681 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
1682 bcmd = bcommand = bcommand | PCI_BRIDGE_CTL_NO_ISA;
1684 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus);
1687 if (ab->_hpp->enable_perr) {
1688 command |= PCI_COMMAND_PARITY;
1689 bcommand |= PCI_BRIDGE_CTL_PARITY;
1691 command &= ~PCI_COMMAND_PARITY;
1692 bcommand &= ~PCI_BRIDGE_CTL_PARITY;
1694 if (ab->_hpp->enable_serr) {
1695 command |= PCI_COMMAND_SERR;
1696 bcommand |= PCI_BRIDGE_CTL_SERR;
1698 command &= ~PCI_COMMAND_SERR;
1699 bcommand &= ~PCI_BRIDGE_CTL_SERR;
1702 dbg("no _hpp for B/D/F = %#x/%#x/%#x.\n", func->bus, func->device, func->function);
1704 dbg("no acpi bridge for B/D/F = %#x/%#x/%#x.\n", func->bus, func->device, func->function);
1706 if (command != cmd) {
1707 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
1709 if ((card_type == PCI_HEADER_TYPE_BRIDGE) && (bcommand != bcmd)) {
1710 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, bcommand);