2 * PCI Express Hot Plug Controller Driver
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Send feedback to <greg@kroah.com>, <dely.l.sy@intel.com>
30 #include <linux/config.h>
31 #include <linux/module.h>
32 #include <linux/kernel.h>
33 #include <linux/types.h>
34 #include <linux/slab.h>
35 #include <linux/tqueue.h>
36 #include <linux/interrupt.h>
37 #include <linux/delay.h>
38 #include <linux/wait.h>
39 #include <linux/smp_lock.h>
40 #include <linux/pci.h>
44 static u32 configure_new_device(struct controller *ctrl, struct pci_func *func,
45 u8 behind_bridge, struct resource_lists *resources, u8 bridge_bus, u8 bridge_dev);
46 static int configure_new_function( struct controller *ctrl, struct pci_func *func,
47 u8 behind_bridge, struct resource_lists *resources, u8 bridge_bus, u8 bridge_dev);
48 static void interrupt_event_handler(struct controller *ctrl);
50 static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */
51 static struct semaphore event_exit; /* guard ensure thread has exited before calling it quits */
52 static int event_finished;
53 static unsigned long pushbutton_pending; /* = 0 */
55 u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
57 struct controller *ctrl = (struct controller *) inst_id;
61 struct pci_func *func;
62 struct event_info *taskInfo;
64 /* Attention Button Change */
65 dbg("pciehp: Attention button interrupt received.\n");
67 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
69 /* This is the structure that tells the worker thread what to do */
70 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
71 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
73 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
74 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
76 ctrl->next_event = (ctrl->next_event + 1) % 10;
77 taskInfo->hp_slot = hp_slot;
82 * Button pressed - See if need to TAKE ACTION!!!
84 info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot);
85 taskInfo->event_type = INT_BUTTON_PRESS;
87 if ((p_slot->state == BLINKINGON_STATE)
88 || (p_slot->state == BLINKINGOFF_STATE)) {
89 /* Cancel if we are still blinking; this means that we press the
90 * attention again before the 5 sec. limit expires to cancel hot-add
93 taskInfo->event_type = INT_BUTTON_CANCEL;
94 info("Button cancel on Slot(%d)\n", ctrl->first_slot + hp_slot);
95 } else if ((p_slot->state == POWERON_STATE)
96 || (p_slot->state == POWEROFF_STATE)) {
97 /* Ignore if the slot is on power-on or power-off state; this
98 * means that the previous attention button action to hot-add or
99 * hot-remove is undergoing
101 taskInfo->event_type = INT_BUTTON_IGNORE;
102 info("Button ignore on Slot(%d)\n", ctrl->first_slot + hp_slot);
105 up(&event_semaphore); /* signal event thread that new event is posted */
111 u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id)
113 struct controller *ctrl = (struct controller *) inst_id;
117 struct pci_func *func;
118 struct event_info *taskInfo;
121 dbg("pciehp: Switch interrupt received.\n");
123 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
125 /* this is the structure that tells the worker thread
128 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
129 ctrl->next_event = (ctrl->next_event + 1) % 10;
130 taskInfo->hp_slot = hp_slot;
133 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
134 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
135 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
141 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot);
142 func->switch_save = 0;
143 taskInfo->event_type = INT_SWITCH_OPEN;
148 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot);
149 func->switch_save = 0x10;
150 taskInfo->event_type = INT_SWITCH_CLOSE;
153 up(&event_semaphore); /* signal event thread that new event is posted */
158 u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
160 struct controller *ctrl = (struct controller *) inst_id;
163 struct pci_func *func;
164 struct event_info *taskInfo;
166 /* Presence Change */
167 dbg("pciehp: Presence/Notify input change.\n");
169 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
171 /* This is the structure that tells the worker thread
174 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
175 ctrl->next_event = (ctrl->next_event + 1) % 10;
176 taskInfo->hp_slot = hp_slot;
179 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
181 /* Switch is open, assume a presence change
182 * Save the presence state
184 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
185 if (func->presence_save) {
189 info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot);
190 taskInfo->event_type = INT_PRESENCE_ON;
195 info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot);
196 taskInfo->event_type = INT_PRESENCE_OFF;
199 up(&event_semaphore); /* signal event thread that new event is posted */
204 u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
206 struct controller *ctrl = (struct controller *) inst_id;
209 struct pci_func *func;
210 struct event_info *taskInfo;
213 dbg("pciehp: Power fault interrupt received.\n");
215 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
217 /* This is the structure that tells the worker thread
220 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
221 ctrl->next_event = (ctrl->next_event + 1) % 10;
222 taskInfo->hp_slot = hp_slot;
225 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
227 if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
229 * Power fault cleared
231 info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot);
233 taskInfo->event_type = INT_POWER_FAULT_CLEAR;
238 info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot);
239 taskInfo->event_type = INT_POWER_FAULT;
240 /* Set power fault status for this board */
242 info("power fault bit %x set\n", hp_slot);
245 up(&event_semaphore); /* Signal event thread that new event is posted */
254 * Sorts nodes on the list by their length.
258 static int sort_by_size(struct pci_resource **head)
260 struct pci_resource *current_res;
261 struct pci_resource *next_res;
262 int out_of_order = 1;
267 if (!((*head)->next))
270 while (out_of_order) {
273 /* Special case for swapping list head */
274 if (((*head)->next) &&
275 ((*head)->length > (*head)->next->length)) {
278 *head = (*head)->next;
279 current_res->next = (*head)->next;
280 (*head)->next = current_res;
285 while (current_res->next && current_res->next->next) {
286 if (current_res->next->length > current_res->next->next->length) {
288 next_res = current_res->next;
289 current_res->next = current_res->next->next;
290 current_res = current_res->next;
291 next_res->next = current_res->next;
292 current_res->next = next_res;
294 current_res = current_res->next;
296 } /* End of out_of_order loop */
305 * Sorts nodes on the list by their length.
309 static int sort_by_max_size(struct pci_resource **head)
311 struct pci_resource *current_res;
312 struct pci_resource *next_res;
313 int out_of_order = 1;
318 if (!((*head)->next))
321 while (out_of_order) {
324 /* Special case for swapping list head */
325 if (((*head)->next) &&
326 ((*head)->length < (*head)->next->length)) {
329 *head = (*head)->next;
330 current_res->next = (*head)->next;
331 (*head)->next = current_res;
336 while (current_res->next && current_res->next->next) {
337 if (current_res->next->length < current_res->next->next->length) {
339 next_res = current_res->next;
340 current_res->next = current_res->next->next;
341 current_res = current_res->next;
342 next_res->next = current_res->next;
343 current_res->next = next_res;
345 current_res = current_res->next;
347 } /* End of out_of_order loop */
354 * do_pre_bridge_resource_split
356 * Returns zero or one node of resources that aren't in use
359 static struct pci_resource *do_pre_bridge_resource_split (struct pci_resource **head, struct pci_resource **orig_head, u32 alignment)
361 struct pci_resource *prevnode = NULL;
362 struct pci_resource *node;
363 struct pci_resource *split_node;
366 dbg("do_pre_bridge_resource_split\n");
368 if (!(*head) || !(*orig_head))
371 rc = pciehp_resource_sort_and_combine(head);
376 if ((*head)->base != (*orig_head)->base)
379 if ((*head)->length == (*orig_head)->length)
383 /* If we got here, there the bridge requires some of the resource, but
384 * we may be able to split some off of the front
388 if (node->length & (alignment -1)) {
389 /* This one isn't an aligned length, so we'll make a new entry
392 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
397 temp_dword = (node->length | (alignment-1)) + 1 - alignment;
399 split_node->base = node->base;
400 split_node->length = temp_dword;
402 node->length -= temp_dword;
403 node->base += split_node->length;
405 /* Put it in the list */
407 split_node->next = node;
410 if (node->length < alignment) {
420 while (prevnode->next != node)
421 prevnode = prevnode->next;
423 prevnode->next = node->next;
432 * do_bridge_resource_split
434 * Returns zero or one node of resources that aren't in use
437 static struct pci_resource *do_bridge_resource_split (struct pci_resource **head, u32 alignment)
439 struct pci_resource *prevnode = NULL;
440 struct pci_resource *node;
447 rc = pciehp_resource_sort_and_combine(head);
460 if (node->length < alignment) {
465 if (node->base & (alignment - 1)) {
466 /* Short circuit if adjusted size is too small */
467 temp_dword = (node->base | (alignment-1)) + 1;
468 if ((node->length - (temp_dword - node->base)) < alignment) {
473 node->length -= (temp_dword - node->base);
474 node->base = temp_dword;
477 if (node->length & (alignment - 1)) {
478 /* There's stuff in use after this node */
490 * this function sorts the resource list by size and then
491 * returns the first node of "size" length that is not in the
492 * ISA aliasing window. If it finds a node larger than "size"
493 * it will split it up.
495 * size must be a power of two.
497 static struct pci_resource *get_io_resource (struct pci_resource **head, u32 size)
499 struct pci_resource *prevnode;
500 struct pci_resource *node;
501 struct pci_resource *split_node = NULL;
507 if ( pciehp_resource_sort_and_combine(head) )
510 if ( sort_by_size(head) )
513 for (node = *head; node; node = node->next) {
514 if (node->length < size)
517 if (node->base & (size - 1)) {
518 /* This one isn't base aligned properly
519 so we'll make a new entry and split it up */
520 temp_dword = (node->base | (size-1)) + 1;
522 /*/ Short circuit if adjusted size is too small */
523 if ((node->length - (temp_dword - node->base)) < size)
526 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
531 split_node->base = node->base;
532 split_node->length = temp_dword - node->base;
533 node->base = temp_dword;
534 node->length -= split_node->length;
536 /* Put it in the list */
537 split_node->next = node->next;
538 node->next = split_node;
539 } /* End of non-aligned base */
541 /* Don't need to check if too small since we already did */
542 if (node->length > size) {
543 /* This one is longer than we need
544 so we'll make a new entry and split it up */
545 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
550 split_node->base = node->base + size;
551 split_node->length = node->length - size;
554 /* Put it in the list */
555 split_node->next = node->next;
556 node->next = split_node;
557 } /* End of too big on top end */
559 /* For IO make sure it's not in the ISA aliasing space */
560 if (node->base & 0x300L)
563 /* If we got here, then it is the right size
564 Now take it out of the list */
569 while (prevnode->next != node)
570 prevnode = prevnode->next;
572 prevnode->next = node->next;
586 * Gets the largest node that is at least "size" big from the
587 * list pointed to by head. It aligns the node on top and bottom
588 * to "size" alignment before returning it.
589 * J.I. modified to put max size limits of; 64M->32M->16M->8M->4M->1M
590 * This is needed to avoid allocating entire ACPI _CRS res to one child bridge/slot.
592 static struct pci_resource *get_max_resource (struct pci_resource **head, u32 size)
594 struct pci_resource *max;
595 struct pci_resource *temp;
596 struct pci_resource *split_node;
598 u32 max_size[] = { 0x4000000, 0x2000000, 0x1000000, 0x0800000, 0x0400000, 0x0200000, 0x0100000, 0x00 };
604 if (pciehp_resource_sort_and_combine(head))
607 if (sort_by_max_size(head))
610 for (max = *head;max; max = max->next) {
612 /* If not big enough we could probably just bail,
613 instead we'll continue to the next. */
614 if (max->length < size)
617 if (max->base & (size - 1)) {
618 /* This one isn't base aligned properly
619 so we'll make a new entry and split it up */
620 temp_dword = (max->base | (size-1)) + 1;
622 /* Short circuit if adjusted size is too small */
623 if ((max->length - (temp_dword - max->base)) < size)
626 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
631 split_node->base = max->base;
632 split_node->length = temp_dword - max->base;
633 max->base = temp_dword;
634 max->length -= split_node->length;
636 /* Put it next in the list */
637 split_node->next = max->next;
638 max->next = split_node;
641 if ((max->base + max->length) & (size - 1)) {
642 /* This one isn't end aligned properly at the top
643 so we'll make a new entry and split it up */
644 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
648 temp_dword = ((max->base + max->length) & ~(size - 1));
649 split_node->base = temp_dword;
650 split_node->length = max->length + max->base
652 max->length -= split_node->length;
654 /* Put it in the list */
655 split_node->next = max->next;
656 max->next = split_node;
659 /* Make sure it didn't shrink too much when we aligned it */
660 if (max->length < size)
663 for ( i = 0; max_size[i] > size; i++) {
664 if (max->length > max_size[i]) {
665 split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
667 break; /* return (NULL); */
668 split_node->base = max->base + max_size[i];
669 split_node->length = max->length - max_size[i];
670 max->length = max_size[i];
671 /* Put it next in the list */
672 split_node->next = max->next;
673 max->next = split_node;
678 /* Now take it out of the list */
679 temp = (struct pci_resource*) *head;
683 while (temp && temp->next != max) {
687 temp->next = max->next;
694 /* If we get here, we couldn't find one */
702 * this function sorts the resource list by size and then
703 * returns the first node of "size" length. If it finds a node
704 * larger than "size" it will split it up.
706 * size must be a power of two.
708 static struct pci_resource *get_resource (struct pci_resource **head, u32 size)
710 struct pci_resource *prevnode;
711 struct pci_resource *node;
712 struct pci_resource *split_node;
718 if ( pciehp_resource_sort_and_combine(head) )
721 if ( sort_by_size(head) )
724 for (node = *head; node; node = node->next) {
725 dbg("%s: req_size =0x%x node=%p, base=0x%x, length=0x%x\n",
726 __FUNCTION__, size, node, node->base, node->length);
727 if (node->length < size)
730 if (node->base & (size - 1)) {
731 dbg("%s: not aligned\n", __FUNCTION__);
732 /* This one isn't base aligned properly
733 so we'll make a new entry and split it up */
734 temp_dword = (node->base | (size-1)) + 1;
736 /* Short circuit if adjusted size is too small */
737 if ((node->length - (temp_dword - node->base)) < size)
740 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
745 split_node->base = node->base;
746 split_node->length = temp_dword - node->base;
747 node->base = temp_dword;
748 node->length -= split_node->length;
750 /* Put it in the list */
751 split_node->next = node->next;
752 node->next = split_node;
753 } /* End of non-aligned base */
755 /* Don't need to check if too small since we already did */
756 if (node->length > size) {
757 dbg("%s: too big\n", __FUNCTION__);
758 /* This one is longer than we need
759 so we'll make a new entry and split it up */
760 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
765 split_node->base = node->base + size;
766 split_node->length = node->length - size;
769 /* Put it in the list */
770 split_node->next = node->next;
771 node->next = split_node;
772 } /* End of too big on top end */
774 dbg("%s: got one!!!\n", __FUNCTION__);
775 /* If we got here, then it is the right size
776 Now take it out of the list */
781 while (prevnode->next != node)
782 prevnode = prevnode->next;
784 prevnode->next = node->next;
795 * pciehp_resource_sort_and_combine
797 * Sorts all of the nodes in the list in ascending order by
798 * their base addresses. Also does garbage collection by
799 * combining adjacent nodes.
801 * returns 0 if success
803 int pciehp_resource_sort_and_combine(struct pci_resource **head)
805 struct pci_resource *node1;
806 struct pci_resource *node2;
807 int out_of_order = 1;
809 dbg("%s: head = %p, *head = %p\n", __FUNCTION__, head, *head);
814 dbg("*head->next = %p\n",(*head)->next);
817 return(0); /* Only one item on the list, already sorted! */
819 dbg("*head->base = 0x%x\n",(*head)->base);
820 dbg("*head->next->base = 0x%x\n",(*head)->next->base);
821 while (out_of_order) {
824 /* Special case for swapping list head */
825 if (((*head)->next) &&
826 ((*head)->base > (*head)->next->base)) {
828 (*head) = (*head)->next;
829 node1->next = (*head)->next;
830 (*head)->next = node1;
836 while (node1->next && node1->next->next) {
837 if (node1->next->base > node1->next->next->base) {
840 node1->next = node1->next->next;
842 node2->next = node1->next;
847 } /* End of out_of_order loop */
851 while (node1 && node1->next) {
852 if ((node1->base + node1->length) == node1->next->base) {
855 node1->length += node1->next->length;
857 node1->next = node1->next->next;
868 * pciehp_slot_create - Creates a node and adds it to the proper bus.
869 * @busnumber - bus where new node is to be located
871 * Returns pointer to the new node or NULL if unsuccessful
873 struct pci_func *pciehp_slot_create(u8 busnumber)
875 struct pci_func *new_slot;
876 struct pci_func *next;
877 dbg("%s: busnumber %x\n", __FUNCTION__, busnumber);
878 new_slot = (struct pci_func *) kmalloc(sizeof(struct pci_func), GFP_KERNEL);
880 if (new_slot == NULL) {
884 memset(new_slot, 0, sizeof(struct pci_func));
886 new_slot->next = NULL;
887 new_slot->configured = 1;
889 if (pciehp_slot_list[busnumber] == NULL) {
890 pciehp_slot_list[busnumber] = new_slot;
892 next = pciehp_slot_list[busnumber];
893 while (next->next != NULL)
895 next->next = new_slot;
902 * slot_remove - Removes a node from the linked list of slots.
903 * @old_slot: slot to remove
905 * Returns 0 if successful, !0 otherwise.
907 static int slot_remove(struct pci_func * old_slot)
909 struct pci_func *next;
911 if (old_slot == NULL)
914 next = pciehp_slot_list[old_slot->bus];
920 if (next == old_slot) {
921 pciehp_slot_list[old_slot->bus] = old_slot->next;
922 pciehp_destroy_board_resources(old_slot);
927 while ((next->next != old_slot) && (next->next != NULL)) {
931 if (next->next == old_slot) {
932 next->next = old_slot->next;
933 pciehp_destroy_board_resources(old_slot);
942 * bridge_slot_remove - Removes a node from the linked list of slots.
943 * @bridge: bridge to remove
945 * Returns 0 if successful, !0 otherwise.
947 static int bridge_slot_remove(struct pci_func *bridge)
949 u8 subordinateBus, secondaryBus;
951 struct pci_func *next;
956 secondaryBus = (bridge->config_space[0x06] >> 8) & 0xFF;
957 subordinateBus = (bridge->config_space[0x06] >> 16) & 0xFF;
959 for (tempBus = secondaryBus; tempBus <= subordinateBus; tempBus++) {
960 next = pciehp_slot_list[tempBus];
962 while (!slot_remove(next)) {
963 next = pciehp_slot_list[tempBus];
967 next = pciehp_slot_list[bridge->bus];
973 if (next == bridge) {
974 pciehp_slot_list[bridge->bus] = bridge->next;
979 while ((next->next != bridge) && (next->next != NULL)) {
983 if (next->next == bridge) {
984 next->next = bridge->next;
993 * pciehp_slot_find - Looks for a node by bus, and device, multiple functions accessed
995 * @device: device to find
996 * @index: is 0 for first function found, 1 for the second...
998 * Returns pointer to the node if successful, %NULL otherwise.
1000 struct pci_func *pciehp_slot_find(u8 bus, u8 device, u8 index)
1003 struct pci_func *func;
1005 func = pciehp_slot_list[bus];
1006 dbg("%s: bus %x device %x index %x\n",
1007 __FUNCTION__, bus, device, index);
1009 dbg("%s: func-> bus %x device %x function %x pci_dev %p\n",
1010 __FUNCTION__, func->bus, func->device, func->function,
1013 dbg("%s: func == NULL\n", __FUNCTION__);
1015 if ((func == NULL) || ((func->device == device) && (index == 0)))
1018 if (func->device == device)
1021 while (func->next != NULL) {
1024 dbg("%s: In while loop, func-> bus %x device %x function %x pci_dev %p\n",
1025 __FUNCTION__, func->bus, func->device, func->function,
1027 if (func->device == device)
1029 dbg("%s: while loop, found %d, index %d\n", __FUNCTION__,
1032 if ((found == index) ||(func->function == index)) {
1033 dbg("%s: Found bus %x dev %x func %x\n", __FUNCTION__,
1034 func->bus, func->device, func->function);
1042 static int is_bridge(struct pci_func * func)
1044 /* Check the header type */
1045 if (((func->config_space[0x03] >> 16) & 0xFF) == 0x01)
1052 /* the following routines constitute the bulk of the
1053 hotplug controller logic
1056 static void set_slot_off(struct controller *ctrl, struct slot * pslot)
1058 /* Wait for exclusive access to hardware */
1059 down(&ctrl->crit_sect);
1061 /* turn off slot, turn on Amber LED, turn off Green LED */
1062 if (pslot->hpc_ops->power_off_slot(pslot)) {
1063 err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__);
1064 up(&ctrl->crit_sect);
1067 wait_for_ctrl_irq (ctrl);
1069 pslot->hpc_ops->green_led_off(pslot);
1071 wait_for_ctrl_irq (ctrl);
1073 /* turn on Amber LED */
1074 if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
1075 err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__);
1076 up(&ctrl->crit_sect);
1079 wait_for_ctrl_irq (ctrl);
1081 /* Done with exclusive hardware access */
1082 up(&ctrl->crit_sect);
1086 * board_added - Called after a board has been added to the system.
1088 * Turns power on for the board
1092 static u32 board_added(struct pci_func * func, struct controller * ctrl)
1096 u32 temp_register = 0xFFFFFFFF;
1098 struct pci_func *new_func = NULL;
1099 struct slot *p_slot;
1100 struct resource_lists res_lists;
1102 p_slot = pciehp_find_slot(ctrl, func->device);
1103 hp_slot = func->device - ctrl->slot_device_offset;
1105 dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n",
1106 __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot);
1108 /* Wait for exclusive access to hardware */
1109 down(&ctrl->crit_sect);
1112 rc = p_slot->hpc_ops->power_on_slot(p_slot);
1114 up(&ctrl->crit_sect);
1118 /* Wait for the command to complete */
1119 wait_for_ctrl_irq(ctrl);
1121 dbg("%s: after power on\n", __FUNCTION__);
1123 p_slot->hpc_ops->green_led_blink(p_slot);
1125 /* Wait for the command to complete */
1126 wait_for_ctrl_irq(ctrl);
1127 dbg("%s: after green_led_blink", __FUNCTION__);
1129 /* Done with exclusive hardware access */
1130 up(&ctrl->crit_sect);
1132 /* Wait for ~1 second */
1133 dbg("%s: before long_delay\n", __FUNCTION__);
1134 wait_for_ctrl_irq (ctrl);
1135 dbg("%s: afterlong_delay\n", __FUNCTION__);
1137 dbg("%s: before check link status", __FUNCTION__);
1138 /* Check link training status */
1139 rc = p_slot->hpc_ops->check_lnk_status(ctrl);
1141 err("%s: Failed to check link status\n", __FUNCTION__);
1142 set_slot_off(ctrl, p_slot);
1146 dbg("%s: func status = %x\n", __FUNCTION__, func->status);
1148 /* Check for a power fault */
1149 if (func->status == 0xFF) {
1150 /* power fault occurred, but it was benign */
1151 temp_register = 0xFFFFFFFF;
1152 dbg("%s: temp register set to %x by power fault\n",
1153 __FUNCTION__, temp_register);
1157 /* Get vendor/device ID u32 */
1158 rc = pci_bus_read_config_dword (ctrl->pci_dev->subordinate,
1159 PCI_DEVFN(func->device, func->function), PCI_VENDOR_ID, &temp_register);
1160 dbg("%s: pci_bus_read_config_dword returns %d\n", __FUNCTION__, rc);
1161 dbg("%s: temp_register is %x\n", __FUNCTION__, temp_register);
1164 /* Something's wrong here */
1165 temp_register = 0xFFFFFFFF;
1166 dbg("%s: temp register set to %x by error\n", __FUNCTION__,
1169 /* Preset return code. It will be changed later if things go okay. */
1170 rc = NO_ADAPTER_PRESENT;
1173 /* All F's is an empty slot or an invalid board */
1174 if (temp_register != 0xFFFFFFFF) { /* Check for a board in the slot */
1175 res_lists.io_head = ctrl->io_head;
1176 res_lists.mem_head = ctrl->mem_head;
1177 res_lists.p_mem_head = ctrl->p_mem_head;
1178 res_lists.bus_head = ctrl->bus_head;
1179 res_lists.irqs = NULL;
1181 rc = configure_new_device(ctrl, func, 0, &res_lists, 0, 0);
1182 dbg("%s: back from configure_new_device\n", __FUNCTION__);
1184 ctrl->io_head = res_lists.io_head;
1185 ctrl->mem_head = res_lists.mem_head;
1186 ctrl->p_mem_head = res_lists.p_mem_head;
1187 ctrl->bus_head = res_lists.bus_head;
1189 pciehp_resource_sort_and_combine(&(ctrl->mem_head));
1190 pciehp_resource_sort_and_combine(&(ctrl->p_mem_head));
1191 pciehp_resource_sort_and_combine(&(ctrl->io_head));
1192 pciehp_resource_sort_and_combine(&(ctrl->bus_head));
1195 set_slot_off(ctrl, p_slot);
1198 pciehp_save_slot_config(ctrl, func);
1201 func->switch_save = 0x10;
1202 func->is_a_board = 0x01;
1204 /* Next, we will instantiate the linux pci_dev structures
1205 * (with appropriate driver notification, if already present)
1209 new_func = pciehp_slot_find(ctrl->slot_bus, func->device, index++);
1210 if (new_func && !new_func->pci_dev) {
1211 dbg("%s:call pci_hp_configure_dev, func %x\n",
1212 __FUNCTION__, index);
1213 pciehp_configure_device(ctrl, new_func);
1217 /* Wait for exclusive access to hardware */
1218 down(&ctrl->crit_sect);
1220 p_slot->hpc_ops->green_led_on(p_slot);
1222 /* Wait for the command to complete */
1223 wait_for_ctrl_irq(ctrl);
1225 /* Done with exclusive hardware access */
1226 up(&ctrl->crit_sect);
1229 set_slot_off(ctrl, p_slot);
1237 * remove_board - Turns off slot and LED's
1240 static u32 remove_board(struct pci_func *func, struct controller *ctrl)
1247 struct resource_lists res_lists;
1248 struct pci_func *temp_func;
1249 struct slot *p_slot;
1254 if (pciehp_unconfigure_device(func))
1257 device = func->device;
1259 hp_slot = func->device - ctrl->slot_device_offset;
1260 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1262 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
1264 if ((ctrl->add_support) &&
1265 !(func->bus_head || func->mem_head || func->p_mem_head || func->io_head)) {
1266 /* Here we check to see if we've saved any of the board's
1267 * resources already. If so, we'll skip the attempt to
1268 * determine what's being used.
1274 while ((temp_func = pciehp_slot_find(temp_func->bus, temp_func->device,
1276 if (temp_func->bus_head || temp_func->mem_head
1277 || temp_func->p_mem_head || temp_func->io_head) {
1284 rc = pciehp_save_used_resources(ctrl, func, DISABLE_CARD);
1286 /* Change status to shutdown */
1287 if (func->is_a_board)
1288 func->status = 0x01;
1289 func->configured = 0;
1291 /* Wait for exclusive access to hardware */
1292 down(&ctrl->crit_sect);
1294 /* Power off slot */
1295 rc = p_slot->hpc_ops->power_off_slot(p_slot);
1297 err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
1298 up(&ctrl->crit_sect);
1301 /* Wait for the command to complete */
1302 wait_for_ctrl_irq(ctrl);
1304 /* Turn off Green LED */
1305 p_slot->hpc_ops->green_led_off(p_slot);
1307 /* Wait for the command to complete */
1308 wait_for_ctrl_irq(ctrl);
1310 /* Done with exclusive hardware access */
1311 up(&ctrl->crit_sect);
1313 if (ctrl->add_support) {
1315 res_lists.io_head = ctrl->io_head;
1316 res_lists.mem_head = ctrl->mem_head;
1317 res_lists.p_mem_head = ctrl->p_mem_head;
1318 res_lists.bus_head = ctrl->bus_head;
1320 dbg("Returning resources to ctlr lists for (B/D/F) = (%#x/%#x/%#x)\n",
1321 func->bus, func->device, func->function);
1323 pciehp_return_board_resources(func, &res_lists);
1325 ctrl->io_head = res_lists.io_head;
1326 ctrl->mem_head = res_lists.mem_head;
1327 ctrl->p_mem_head = res_lists.p_mem_head;
1328 ctrl->bus_head = res_lists.bus_head;
1330 pciehp_resource_sort_and_combine(&(ctrl->mem_head));
1331 pciehp_resource_sort_and_combine(&(ctrl->p_mem_head));
1332 pciehp_resource_sort_and_combine(&(ctrl->io_head));
1333 pciehp_resource_sort_and_combine(&(ctrl->bus_head));
1335 if (is_bridge(func)) {
1336 dbg("PCI Bridge Hot-Remove s:b:d:f(%02x:%02x:%02x:%02x)\n",
1337 ctrl->seg, func->bus, func->device, func->function);
1338 bridge_slot_remove(func);
1340 dbg("PCI Function Hot-Remove s:b:d:f(%02x:%02x:%02x:%02x)\n",
1341 ctrl->seg, func->bus, func->device, func->function);
1344 func = pciehp_slot_find(ctrl->slot_bus, device, 0);
1347 /* Setup slot structure with entry for empty slot */
1348 func = pciehp_slot_create(ctrl->slot_bus);
1354 func->bus = ctrl->slot_bus;
1355 func->device = device;
1357 func->configured = 0;
1358 func->switch_save = 0x10;
1359 func->is_a_board = 0;
1365 static void pushbutton_helper_thread (unsigned long data)
1367 pushbutton_pending = data;
1368 up(&event_semaphore);
1372 /* this is the main worker thread */
1373 static int event_thread(void* data)
1375 struct controller *ctrl;
1380 strcpy(current->comm, "pciehpd_event");
1385 dbg("!!!!event_thread sleeping\n");
1386 down_interruptible (&event_semaphore);
1387 dbg("event_thread woken finished = %d\n", event_finished);
1388 if (event_finished || signal_pending(current))
1391 if (pushbutton_pending)
1392 pciehp_pushbutton_thread(pushbutton_pending);
1394 for (ctrl = pciehp_ctrl_list; ctrl; ctrl=ctrl->next)
1395 interrupt_event_handler(ctrl);
1397 dbg("event_thread signals exit\n");
1402 int pciehp_event_start_thread (void)
1406 /* Initialize our semaphores */
1407 init_MUTEX_LOCKED(&event_exit);
1410 init_MUTEX_LOCKED(&event_semaphore);
1411 pid = kernel_thread(event_thread, 0, 0);
1414 err ("Can't start up our event thread\n");
1417 dbg("Our event thread pid = %d\n", pid);
1422 void pciehp_event_stop_thread (void)
1425 dbg("event_thread finish command given\n");
1426 up(&event_semaphore);
1427 dbg("wait for event_thread to exit\n");
1432 static int update_slot_info (struct slot *slot)
1434 struct hotplug_slot_info *info;
1435 char buffer[SLOT_NAME_SIZE];
1438 info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL);
1442 make_slot_name (&buffer[0], SLOT_NAME_SIZE, slot);
1444 slot->hpc_ops->get_power_status(slot, &(info->power_status));
1445 slot->hpc_ops->get_attention_status(slot, &(info->attention_status));
1446 slot->hpc_ops->get_latch_status(slot, &(info->latch_status));
1447 slot->hpc_ops->get_adapter_status(slot, &(info->adapter_status));
1449 result = pci_hp_change_slot_info(buffer, info);
1454 static void interrupt_event_handler(struct controller *ctrl)
1458 struct pci_func *func;
1461 struct slot *p_slot;
1466 for (loop = 0; loop < 10; loop++) {
1467 if (ctrl->event_queue[loop].event_type != 0) {
1468 hp_slot = ctrl->event_queue[loop].hp_slot;
1470 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
1472 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1474 dbg("hp_slot %d, func %p, p_slot %p\n", hp_slot, func, p_slot);
1476 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) {
1477 dbg("button cancel\n");
1478 del_timer(&p_slot->task_event);
1480 switch (p_slot->state) {
1481 case BLINKINGOFF_STATE:
1482 /* Wait for exclusive access to hardware */
1483 down(&ctrl->crit_sect);
1485 p_slot->hpc_ops->green_led_on(p_slot);
1486 /* Wait for the command to complete */
1487 wait_for_ctrl_irq(ctrl);
1489 p_slot->hpc_ops->set_attention_status(p_slot, 0);
1491 /* Wait for the command to complete */
1492 wait_for_ctrl_irq(ctrl);
1494 /* Done with exclusive hardware access */
1495 up(&ctrl->crit_sect);
1497 case BLINKINGON_STATE:
1498 /* Wait for exclusive access to hardware */
1499 down(&ctrl->crit_sect);
1501 p_slot->hpc_ops->green_led_off(p_slot);
1502 /* Wait for the command to complete */
1503 wait_for_ctrl_irq(ctrl);
1505 p_slot->hpc_ops->set_attention_status(p_slot, 0);
1506 /* Wait for the command to complete */
1507 wait_for_ctrl_irq(ctrl);
1509 /* Done with exclusive hardware access */
1510 up(&ctrl->crit_sect);
1514 warn("Not a valid state\n");
1517 info(msg_button_cancel, p_slot->number);
1518 p_slot->state = STATIC_STATE;
1520 /* ***********Button Pressed (No action on 1st press...) */
1521 else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) {
1522 dbg("Button pressed\n");
1524 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1527 dbg("Slot is on\n");
1528 p_slot->state = BLINKINGOFF_STATE;
1529 info(msg_button_off, p_slot->number);
1532 dbg("Slot is off\n");
1533 p_slot->state = BLINKINGON_STATE;
1534 info(msg_button_on, p_slot->number);
1537 /* Wait for exclusive access to hardware */
1538 down(&ctrl->crit_sect);
1540 /* blink green LED and turn off amber */
1541 p_slot->hpc_ops->green_led_blink(p_slot);
1542 /* Wait for the command to complete */
1543 wait_for_ctrl_irq(ctrl);
1545 p_slot->hpc_ops->set_attention_status(p_slot, 0);
1547 /* Wait for the command to complete */
1548 wait_for_ctrl_irq(ctrl);
1550 /* Done with exclusive hardware access */
1551 up(&ctrl->crit_sect);
1553 init_timer(&p_slot->task_event);
1554 p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
1555 p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
1556 p_slot->task_event.data = (unsigned long) p_slot;
1558 dbg("add_timer p_slot = %p\n", (void *) p_slot);
1559 add_timer(&p_slot->task_event);
1561 /***********POWER FAULT********************/
1562 else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
1563 dbg("power fault\n");
1564 /* Wait for exclusive access to hardware */
1565 down(&ctrl->crit_sect);
1567 p_slot->hpc_ops->set_attention_status(p_slot, 1);
1568 wait_for_ctrl_irq(ctrl);
1570 p_slot->hpc_ops->green_led_off(p_slot);
1571 wait_for_ctrl_irq(ctrl);
1573 /* Done with exclusive hardware access */
1574 up(&ctrl->crit_sect);
1576 /* refresh notification */
1578 update_slot_info(p_slot);
1581 ctrl->event_queue[loop].event_type = 0;
1585 } /* End of FOR loop */
1593 * pciehp_pushbutton_thread
1595 * Scheduled procedure to handle blocking stuff for the pushbuttons
1596 * Handles all pending events and exits.
1599 void pciehp_pushbutton_thread (unsigned long slot)
1601 struct slot *p_slot = (struct slot *) slot;
1604 pushbutton_pending = 0;
1607 dbg("%s: Error! slot NULL\n", __FUNCTION__);
1611 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1613 p_slot->state = POWEROFF_STATE;
1614 dbg("In power_down_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
1616 pciehp_disable_slot(p_slot);
1617 p_slot->state = STATIC_STATE;
1619 p_slot->state = POWERON_STATE;
1620 dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device);
1622 if (pciehp_enable_slot(p_slot)) {
1623 /* Wait for exclusive access to hardware */
1624 down(&p_slot->ctrl->crit_sect);
1626 p_slot->hpc_ops->green_led_off(p_slot);
1628 /* Wait for the command to complete */
1629 wait_for_ctrl_irq (p_slot->ctrl);
1631 /* Done with exclusive hardware access */
1632 up(&p_slot->ctrl->crit_sect);
1634 p_slot->state = STATIC_STATE;
1641 int pciehp_enable_slot (struct slot *p_slot)
1645 struct pci_func *func;
1647 func = pciehp_slot_find(p_slot->bus, p_slot->device, 0);
1649 dbg("%s: Error! slot NULL\n", __FUNCTION__);
1653 /* Check to see if (latch closed, card present, power off) */
1654 down(&p_slot->ctrl->crit_sect);
1655 rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
1656 if (rc || !getstatus) {
1657 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
1658 up(&p_slot->ctrl->crit_sect);
1662 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1663 if (rc || getstatus) {
1664 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
1665 up(&p_slot->ctrl->crit_sect);
1669 rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1670 if (rc || getstatus) {
1671 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
1672 up(&p_slot->ctrl->crit_sect);
1675 up(&p_slot->ctrl->crit_sect);
1679 func = pciehp_slot_create(p_slot->bus);
1683 func->bus = p_slot->bus;
1684 func->device = p_slot->device;
1686 func->configured = 0;
1687 func->is_a_board = 1;
1689 /* We have to save the presence info for these slots */
1690 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
1691 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1692 func->switch_save = !getstatus? 0x10:0;
1694 rc = board_added(func, p_slot->ctrl);
1696 if (is_bridge(func))
1697 bridge_slot_remove(func);
1701 /* Setup slot structure with entry for empty slot */
1702 func = pciehp_slot_create(p_slot->bus);
1704 return (1); /* Out of memory */
1706 func->bus = p_slot->bus;
1707 func->device = p_slot->device;
1709 func->configured = 0;
1710 func->is_a_board = 1;
1712 /* We have to save the presence info for these slots */
1713 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
1714 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1715 func->switch_save = !getstatus? 0x10:0;
1719 update_slot_info(p_slot);
1725 int pciehp_disable_slot (struct slot *p_slot)
1727 u8 class_code, header_type, BCR;
1733 struct pci_bus *pci_bus = p_slot->ctrl->pci_dev->subordinate;
1734 struct pci_func *func;
1739 /* Check to see if (latch closed, card present, power on) */
1740 down(&p_slot->ctrl->crit_sect);
1742 ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
1743 if (ret || !getstatus) {
1744 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
1745 up(&p_slot->ctrl->crit_sect);
1749 ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1750 if (ret || getstatus) {
1751 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
1752 up(&p_slot->ctrl->crit_sect);
1756 ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1757 if (ret || !getstatus) {
1758 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
1759 up(&p_slot->ctrl->crit_sect);
1762 up(&p_slot->ctrl->crit_sect);
1764 func = pciehp_slot_find(p_slot->bus, p_slot->device, index++);
1766 /* Make sure there are no video controllers here
1767 * for all func of p_slot
1769 while (func && !rc) {
1770 pci_bus->number = func->bus;
1771 devfn = PCI_DEVFN(func->device, func->function);
1773 /* Check the Class Code */
1774 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
1778 if (class_code == PCI_BASE_CLASS_DISPLAY) {
1779 /* Display/Video adapter (not supported) */
1780 rc = REMOVE_NOT_SUPPORTED;
1782 /* See if it's a bridge */
1783 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
1787 /* If it's a bridge, check the VGA Enable bit */
1788 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
1789 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
1793 /* If the VGA Enable bit is set, remove isn't supported */
1794 if (BCR & PCI_BRIDGE_CTL_VGA) {
1795 rc = REMOVE_NOT_SUPPORTED;
1800 func = pciehp_slot_find(p_slot->bus, p_slot->device, index++);
1803 func = pciehp_slot_find(p_slot->bus, p_slot->device, 0);
1804 if ((func != NULL) && !rc) {
1805 rc = remove_board(func, p_slot->ctrl);
1810 update_slot_info(p_slot);
1817 * configure_new_device - Configures the PCI header information of one board.
1819 * @ctrl: pointer to controller structure
1820 * @func: pointer to function structure
1821 * @behind_bridge: 1 if this is a recursive call, 0 if not
1822 * @resources: pointer to set of resource lists
1824 * Returns 0 if success
1827 static u32 configure_new_device (struct controller * ctrl, struct pci_func * func,
1828 u8 behind_bridge, struct resource_lists * resources, u8 bridge_bus, u8 bridge_dev)
1830 u8 temp_byte, function, max_functions, stop_it;
1833 struct pci_func *new_slot;
1834 struct pci_bus lpci_bus, *pci_bus;
1839 dbg("%s\n", __FUNCTION__);
1841 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
1842 pci_bus = &lpci_bus;
1843 pci_bus->number = func->bus;
1845 /* Check for Multi-function device */
1846 rc = pci_bus_read_config_byte(pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte);
1848 dbg("%s: rc = %d\n", __FUNCTION__, rc);
1852 if (temp_byte & 0x80) /* Multi-function device */
1860 rc = configure_new_function(ctrl, new_slot, behind_bridge, resources, bridge_bus, bridge_dev);
1863 dbg("configure_new_function failed %d\n",rc);
1867 new_slot = pciehp_slot_find(new_slot->bus, new_slot->device, index++);
1870 pciehp_return_board_resources(new_slot, resources);
1880 /* The following loop skips to the next present function
1881 * and creates a board structure
1884 while ((function < max_functions) && (!stop_it)) {
1885 pci_bus_read_config_dword(pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
1887 if (ID == 0xFFFFFFFF) { /* There's nothing there. */
1889 } else { /* There's something there */
1890 /* Setup slot structure. */
1891 new_slot = pciehp_slot_create(func->bus);
1893 if (new_slot == NULL) {
1898 new_slot->bus = func->bus;
1899 new_slot->device = func->device;
1900 new_slot->function = function;
1901 new_slot->is_a_board = 1;
1902 new_slot->status = 0;
1908 } while (function < max_functions);
1909 dbg("returning from configure_new_device\n");
1916 * Configuration logic that involves the hotplug data structures and
1922 * configure_new_function - Configures the PCI header information of one device
1924 * @ctrl: pointer to controller structure
1925 * @func: pointer to function structure
1926 * @behind_bridge: 1 if this is a recursive call, 0 if not
1927 * @resources: pointer to set of resource lists
1929 * Calls itself recursively for bridged devices.
1930 * Returns 0 if success
1933 static int configure_new_function (struct controller * ctrl, struct pci_func * func,
1934 u8 behind_bridge, struct resource_lists *resources, u8 bridge_bus, u8 bridge_dev)
1946 struct pci_resource *mem_node;
1947 struct pci_resource *p_mem_node;
1948 struct pci_resource *io_node;
1949 struct pci_resource *bus_node;
1950 struct pci_resource *hold_mem_node;
1951 struct pci_resource *hold_p_mem_node;
1952 struct pci_resource *hold_IO_node;
1953 struct pci_resource *hold_bus_node;
1954 struct irq_mapping irqs;
1955 struct pci_func *new_slot;
1956 struct pci_bus lpci_bus, *pci_bus;
1957 struct resource_lists temp_resources;
1959 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
1960 pci_bus = &lpci_bus;
1961 pci_bus->number = func->bus;
1962 devfn = PCI_DEVFN(func->device, func->function);
1964 /* Check for Bridge */
1965 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &temp_byte);
1968 dbg("%s: bus %x dev %x func %x temp_byte = %x\n", __FUNCTION__,
1969 func->bus, func->device, func->function, temp_byte);
1971 if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */
1972 /* Set Primary bus */
1973 dbg("set Primary bus = 0x%x\n", func->bus);
1974 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
1978 /* Find range of busses to use */
1979 bus_node = get_max_resource(&resources->bus_head, 1L);
1981 /* If we don't have any busses to allocate, we can't continue */
1983 err("Got NO bus resource to use\n");
1986 dbg("Got ranges of buses to use: base:len=0x%x:%x\n", bus_node->base, bus_node->length);
1988 /* Set Secondary bus */
1989 dbg("set Secondary bus = 0x%x\n", temp_byte);
1990 dbg("func->bus %x\n", func->bus);
1992 temp_byte = (u8)bus_node->base;
1993 dbg("set Secondary bus = 0x%x\n", temp_byte);
1994 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, temp_byte);
1998 /* set subordinate bus */
1999 temp_byte = (u8)(bus_node->base + bus_node->length - 1);
2000 dbg("set subordinate bus = 0x%x\n", temp_byte);
2001 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
2005 /* Set HP parameters (Cache Line Size, Latency Timer) */
2006 rc = pciehprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_BRIDGE);
2010 /* Setup the IO, memory, and prefetchable windows */
2012 io_node = get_max_resource(&(resources->io_head), 0x1000L);
2014 dbg("io_node(base, len, next) (%x, %x, %p)\n", io_node->base, io_node->length, io_node->next);
2017 mem_node = get_max_resource(&(resources->mem_head), 0x100000L);
2019 dbg("mem_node(base, len, next) (%x, %x, %p)\n", mem_node->base, mem_node->length, mem_node->next);
2022 if (resources->p_mem_head)
2023 p_mem_node = get_max_resource(&(resources->p_mem_head), 0x100000L);
2026 * In some platform implementation, MEM and PMEM are not
2027 * distinguished, and hence ACPI _CRS has only MEM entries
2028 * for both MEM and PMEM.
2030 dbg("using MEM for PMEM\n");
2031 p_mem_node = get_max_resource(&(resources->mem_head), 0x100000L);
2034 dbg("p_mem_node(base, len, next) (%x, %x, %p)\n", p_mem_node->base, p_mem_node->length, p_mem_node->next);
2037 /* Set up the IRQ info */
2038 if (!resources->irqs) {
2039 irqs.barber_pole = 0;
2040 irqs.interrupt[0] = 0;
2041 irqs.interrupt[1] = 0;
2042 irqs.interrupt[2] = 0;
2043 irqs.interrupt[3] = 0;
2046 irqs.barber_pole = resources->irqs->barber_pole;
2047 irqs.interrupt[0] = resources->irqs->interrupt[0];
2048 irqs.interrupt[1] = resources->irqs->interrupt[1];
2049 irqs.interrupt[2] = resources->irqs->interrupt[2];
2050 irqs.interrupt[3] = resources->irqs->interrupt[3];
2051 irqs.valid_INT = resources->irqs->valid_INT;
2054 /* Set up resource lists that are now aligned on top and bottom
2055 * for anything behind the bridge.
2057 temp_resources.bus_head = bus_node;
2058 temp_resources.io_head = io_node;
2059 temp_resources.mem_head = mem_node;
2060 temp_resources.p_mem_head = p_mem_node;
2061 temp_resources.irqs = &irqs;
2063 /* Make copies of the nodes we are going to pass down so that
2064 * if there is a problem,we can just use these to free resources
2066 hold_bus_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
2067 hold_IO_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
2068 hold_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
2069 hold_p_mem_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
2071 if (!hold_bus_node || !hold_IO_node || !hold_mem_node || !hold_p_mem_node) {
2073 kfree(hold_bus_node);
2075 kfree(hold_IO_node);
2077 kfree(hold_mem_node);
2078 if (hold_p_mem_node)
2079 kfree(hold_p_mem_node);
2084 memcpy(hold_bus_node, bus_node, sizeof(struct pci_resource));
2086 bus_node->base += 1;
2087 bus_node->length -= 1;
2088 bus_node->next = NULL;
2090 /* If we have IO resources copy them and fill in the bridge's
2091 * IO range registers
2094 memcpy(hold_IO_node, io_node, sizeof(struct pci_resource));
2095 io_node->next = NULL;
2097 /* set IO base and Limit registers */
2098 RES_CHECK(io_node->base, 8);
2099 temp_byte = (u8)(io_node->base >> 8);
2100 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_BASE, temp_byte);
2102 RES_CHECK(io_node->base + io_node->length - 1, 8);
2103 temp_byte = (u8)((io_node->base + io_node->length - 1) >> 8);
2104 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2106 kfree(hold_IO_node);
2107 hold_IO_node = NULL;
2110 /* If we have memory resources copy them and fill in the bridge's
2111 * memory range registers. Otherwise, fill in the range
2112 * registers with values that disable them.
2115 memcpy(hold_mem_node, mem_node, sizeof(struct pci_resource));
2116 mem_node->next = NULL;
2118 /* set Mem base and Limit registers */
2119 RES_CHECK(mem_node->base, 16);
2120 temp_word = (u32)(mem_node->base >> 16);
2121 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
2123 RES_CHECK(mem_node->base + mem_node->length - 1, 16);
2124 temp_word = (u32)((mem_node->base + mem_node->length - 1) >> 16);
2125 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2128 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
2131 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2133 kfree(hold_mem_node);
2134 hold_mem_node = NULL;
2137 /* If we have prefetchable memory resources copy them and
2138 * fill in the bridge's memory range registers. Otherwise,
2139 * fill in the range registers with values that disable them.
2142 memcpy(hold_p_mem_node, p_mem_node, sizeof(struct pci_resource));
2143 p_mem_node->next = NULL;
2145 /* Set Pre Mem base and Limit registers */
2146 RES_CHECK(p_mem_node->base, 16);
2147 temp_word = (u32)(p_mem_node->base >> 16);
2148 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2150 RES_CHECK(p_mem_node->base + p_mem_node->length - 1, 16);
2151 temp_word = (u32)((p_mem_node->base + p_mem_node->length - 1) >> 16);
2152 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2155 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2158 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2160 kfree(hold_p_mem_node);
2161 hold_p_mem_node = NULL;
2164 /* Adjust this to compensate for extra adjustment in first loop */
2169 /* Here we actually find the devices and configure them */
2170 for (device = 0; (device <= 0x1F) && !rc; device++) {
2171 irqs.barber_pole = (irqs.barber_pole + 1) & 0x03;
2174 pci_bus->number = hold_bus_node->base;
2175 pci_bus_read_config_dword (pci_bus, PCI_DEVFN(device, 0), PCI_VENDOR_ID, &ID);
2176 pci_bus->number = func->bus;
2178 if (ID != 0xFFFFFFFF) { /* device Present */
2179 /* Setup slot structure. */
2180 new_slot = pciehp_slot_create(hold_bus_node->base);
2182 if (new_slot == NULL) {
2188 new_slot->bus = hold_bus_node->base;
2189 new_slot->device = device;
2190 new_slot->function = 0;
2191 new_slot->is_a_board = 1;
2192 new_slot->status = 0;
2194 rc = configure_new_device(ctrl, new_slot, 1, &temp_resources, func->bus, func->device);
2195 dbg("configure_new_device rc=0x%x\n",rc);
2196 } /* End of IF (device in slot?) */
2197 } /* End of FOR loop */
2200 pciehp_destroy_resource_list(&temp_resources);
2202 return_resource(&(resources->bus_head), hold_bus_node);
2203 return_resource(&(resources->io_head), hold_IO_node);
2204 return_resource(&(resources->mem_head), hold_mem_node);
2205 return_resource(&(resources->p_mem_head), hold_p_mem_node);
2209 /* Save the interrupt routing information */
2210 if (resources->irqs) {
2211 resources->irqs->interrupt[0] = irqs.interrupt[0];
2212 resources->irqs->interrupt[1] = irqs.interrupt[1];
2213 resources->irqs->interrupt[2] = irqs.interrupt[2];
2214 resources->irqs->interrupt[3] = irqs.interrupt[3];
2215 resources->irqs->valid_INT = irqs.valid_INT;
2216 } else if (!behind_bridge) {
2217 /* We need to hook up the interrupts here */
2218 for (cloop = 0; cloop < 4; cloop++) {
2219 if (irqs.valid_INT & (0x01 << cloop)) {
2220 rc = pciehp_set_irq(func->bus, func->device,
2221 0x0A + cloop, irqs.interrupt[cloop]);
2223 pciehp_destroy_resource_list (&temp_resources);
2224 return_resource(&(resources->bus_head), hold_bus_node);
2225 return_resource(&(resources->io_head), hold_IO_node);
2226 return_resource(&(resources->mem_head), hold_mem_node);
2227 return_resource(&(resources->p_mem_head), hold_p_mem_node);
2231 } /* end of for loop */
2234 /* Return unused bus resources
2235 * First use the temporary node to store information for the board
2237 if (hold_bus_node && bus_node && temp_resources.bus_head) {
2238 hold_bus_node->length = bus_node->base - hold_bus_node->base;
2240 hold_bus_node->next = func->bus_head;
2241 func->bus_head = hold_bus_node;
2243 temp_byte = (u8)(temp_resources.bus_head->base - 1);
2245 /* Set subordinate bus */
2246 dbg("re-set subordinate bus = 0x%x\n", temp_byte);
2248 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
2250 if (temp_resources.bus_head->length == 0) {
2251 kfree(temp_resources.bus_head);
2252 temp_resources.bus_head = NULL;
2254 dbg("return bus res of b:d(0x%x:%x) base:len(0x%x:%x)\n",
2255 func->bus, func->device, temp_resources.bus_head->base, temp_resources.bus_head->length);
2256 return_resource(&(resources->bus_head), temp_resources.bus_head);
2260 /* If we have IO space available and there is some left,
2261 * return the unused portion
2263 if (hold_IO_node && temp_resources.io_head) {
2264 io_node = do_pre_bridge_resource_split(&(temp_resources.io_head),
2265 &hold_IO_node, 0x1000);
2267 /* Check if we were able to split something off */
2269 hold_IO_node->base = io_node->base + io_node->length;
2271 RES_CHECK(hold_IO_node->base, 8);
2272 temp_byte = (u8)((hold_IO_node->base) >> 8);
2273 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_BASE, temp_byte);
2275 return_resource(&(resources->io_head), io_node);
2278 io_node = do_bridge_resource_split(&(temp_resources.io_head), 0x1000);
2280 /* Check if we were able to split something off */
2282 /* First use the temporary node to store information for the board */
2283 hold_IO_node->length = io_node->base - hold_IO_node->base;
2285 /* If we used any, add it to the board's list */
2286 if (hold_IO_node->length) {
2287 hold_IO_node->next = func->io_head;
2288 func->io_head = hold_IO_node;
2290 RES_CHECK(io_node->base - 1, 8);
2291 temp_byte = (u8)((io_node->base - 1) >> 8);
2292 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2294 return_resource(&(resources->io_head), io_node);
2296 /* It doesn't need any IO */
2298 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2300 return_resource(&(resources->io_head), io_node);
2301 kfree(hold_IO_node);
2304 /* It used most of the range */
2305 hold_IO_node->next = func->io_head;
2306 func->io_head = hold_IO_node;
2308 } else if (hold_IO_node) {
2309 /* It used the whole range */
2310 hold_IO_node->next = func->io_head;
2311 func->io_head = hold_IO_node;
2314 /* If we have memory space available and there is some left,
2315 * return the unused portion
2317 if (hold_mem_node && temp_resources.mem_head) {
2318 mem_node = do_pre_bridge_resource_split(&(temp_resources.mem_head), &hold_mem_node, 0x100000L);
2320 /* Check if we were able to split something off */
2322 hold_mem_node->base = mem_node->base + mem_node->length;
2324 RES_CHECK(hold_mem_node->base, 16);
2325 temp_word = (u32)((hold_mem_node->base) >> 16);
2326 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
2328 return_resource(&(resources->mem_head), mem_node);
2331 mem_node = do_bridge_resource_split(&(temp_resources.mem_head), 0x100000L);
2333 /* Check if we were able to split something off */
2335 /* First use the temporary node to store information for the board */
2336 hold_mem_node->length = mem_node->base - hold_mem_node->base;
2338 if (hold_mem_node->length) {
2339 hold_mem_node->next = func->mem_head;
2340 func->mem_head = hold_mem_node;
2342 /* Configure end address */
2343 RES_CHECK(mem_node->base - 1, 16);
2344 temp_word = (u32)((mem_node->base - 1) >> 16);
2345 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2347 /* Return unused resources to the pool */
2348 return_resource(&(resources->mem_head), mem_node);
2350 /* It doesn't need any Mem */
2352 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2354 return_resource(&(resources->mem_head), mem_node);
2355 kfree(hold_mem_node);
2358 /* It used most of the range */
2359 hold_mem_node->next = func->mem_head;
2360 func->mem_head = hold_mem_node;
2362 } else if (hold_mem_node) {
2363 /* It used the whole range */
2364 hold_mem_node->next = func->mem_head;
2365 func->mem_head = hold_mem_node;
2368 /* If we have prefetchable memory space available and there is some
2369 * left at the end, return the unused portion
2371 if (hold_p_mem_node && temp_resources.p_mem_head) {
2372 p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head),
2373 &hold_p_mem_node, 0x100000L);
2375 /* Check if we were able to split something off */
2377 hold_p_mem_node->base = p_mem_node->base + p_mem_node->length;
2379 RES_CHECK(hold_p_mem_node->base, 16);
2380 temp_word = (u32)((hold_p_mem_node->base) >> 16);
2381 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2383 return_resource(&(resources->p_mem_head), p_mem_node);
2386 p_mem_node = do_bridge_resource_split(&(temp_resources.p_mem_head), 0x100000L);
2388 /* Check if we were able to split something off */
2390 /* First use the temporary node to store information for the board */
2391 hold_p_mem_node->length = p_mem_node->base - hold_p_mem_node->base;
2393 /* If we used any, add it to the board's list */
2394 if (hold_p_mem_node->length) {
2395 hold_p_mem_node->next = func->p_mem_head;
2396 func->p_mem_head = hold_p_mem_node;
2398 RES_CHECK(p_mem_node->base - 1, 16);
2399 temp_word = (u32)((p_mem_node->base - 1) >> 16);
2400 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2402 return_resource(&(resources->p_mem_head), p_mem_node);
2404 /* It doesn't need any PMem */
2406 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2408 return_resource(&(resources->p_mem_head), p_mem_node);
2409 kfree(hold_p_mem_node);
2412 /* It used the most of the range */
2413 hold_p_mem_node->next = func->p_mem_head;
2414 func->p_mem_head = hold_p_mem_node;
2416 } else if (hold_p_mem_node) {
2417 /* It used the whole range */
2418 hold_p_mem_node->next = func->p_mem_head;
2419 func->p_mem_head = hold_p_mem_node;
2422 /* We should be configuring an IRQ and the bridge's base address
2423 * registers if it needs them. Although we have never seen such
2427 pciehprm_enable_card(ctrl, func, PCI_HEADER_TYPE_BRIDGE);
2429 dbg("PCI Bridge Hot-Added s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus,
2430 func->device, func->function);
2431 } else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
2432 /* Standard device */
2434 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
2436 if (class_code == PCI_BASE_CLASS_DISPLAY)
2437 return (DEVICE_TYPE_NOT_SUPPORTED);
2439 /* Figure out IO and memory needs */
2440 for (cloop = PCI_BASE_ADDRESS_0; cloop <= PCI_BASE_ADDRESS_5; cloop += 4) {
2441 temp_register = 0xFFFFFFFF;
2443 rc = pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register);
2444 rc = pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp_register);
2445 dbg("Bar[%x]=0x%x on bus:dev:func(0x%x:%x:%x)\n", cloop, temp_register, func->bus, func->device, func->function);
2451 if (temp_register & PCI_BASE_ADDRESS_SPACE_IO) {
2454 /* Set base = amount of IO space */
2455 base = temp_register & 0xFFFFFFFC;
2458 dbg("NEED IO length(0x%x)\n", base);
2459 io_node = get_io_resource(&(resources->io_head),(ulong)base);
2461 /* Allocate the resource to the board */
2463 dbg("Got IO base=0x%x(length=0x%x)\n", io_node->base, io_node->length);
2464 base = (u32)io_node->base;
2465 io_node->next = func->io_head;
2466 func->io_head = io_node;
2468 err("Got NO IO resource(length=0x%x)\n", base);
2471 } else { /* Map MEM */
2472 int prefetchable = 1;
2473 struct pci_resource **res_node = &func->p_mem_head;
2474 char *res_type_str = "PMEM";
2477 if (!(temp_register & PCI_BASE_ADDRESS_MEM_PREFETCH)) {
2479 res_node = &func->mem_head;
2483 base = temp_register & 0xFFFFFFF0;
2486 switch (temp_register & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
2487 case PCI_BASE_ADDRESS_MEM_TYPE_32:
2488 dbg("NEED 32 %s bar=0x%x(length=0x%x)\n", res_type_str, temp_register, base);
2490 if (prefetchable && resources->p_mem_head)
2491 mem_node=get_resource(&(resources->p_mem_head), (ulong)base);
2494 dbg("using MEM for PMEM\n");
2495 mem_node=get_resource(&(resources->mem_head), (ulong)base);
2498 /* Allocate the resource to the board */
2500 base = (u32)mem_node->base;
2501 mem_node->next = *res_node;
2502 *res_node = mem_node;
2503 dbg("Got 32 %s base=0x%x(length=0x%x)\n", res_type_str, mem_node->base, mem_node->length);
2505 err("Got NO 32 %s resource(length=0x%x)\n", res_type_str, base);
2509 case PCI_BASE_ADDRESS_MEM_TYPE_64:
2510 rc = pci_bus_read_config_dword(pci_bus, devfn, cloop+4, &temp_register2);
2511 dbg("NEED 64 %s bar=0x%x:%x(length=0x%x)\n", res_type_str, temp_register2, temp_register, base);
2513 if (prefetchable && resources->p_mem_head)
2514 mem_node = get_resource(&(resources->p_mem_head), (ulong)base);
2517 dbg("using MEM for PMEM\n");
2518 mem_node = get_resource(&(resources->mem_head), (ulong)base);
2521 /* Allocate the resource to the board */
2523 base64 = mem_node->base;
2524 mem_node->next = *res_node;
2525 *res_node = mem_node;
2526 dbg("Got 64 %s base=0x%x:%x(length=%x)\n", res_type_str, (u32)(base64 >> 32), (u32)base64, mem_node->length);
2528 err("Got NO 64 %s resource(length=0x%x)\n", res_type_str, base);
2533 dbg("reserved BAR type=0x%x\n", temp_register);
2540 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, (u32)base64);
2545 dbg("%s: high dword of base64(0x%x) set to 0\n", __FUNCTION__, (u32)base64);
2549 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, (u32)base64);
2551 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, base);
2553 } /* End of base register loop */
2555 /* Disable ROM base Address */
2557 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_ROM_ADDRESS, temp_word);
2559 /* Set HP parameters (Cache Line Size, Latency Timer) */
2560 rc = pciehprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_NORMAL);
2564 pciehprm_enable_card(ctrl, func, PCI_HEADER_TYPE_NORMAL);
2566 dbg("PCI function Hot-Added s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus, func->device, func->function);
2567 } /* End of Not-A-Bridge else */
2569 /* It's some strange type of PCI adapter (Cardbus?) */
2570 return(DEVICE_TYPE_NOT_SUPPORTED);
2573 func->configured = 1;
2575 dbg("%s: exit\n", __FUNCTION__);