aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/ibmphp_pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug/ibmphp_pci.c')
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index c60f5f3e838d..639ea3a75e14 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * IBM Hot Plug Controller Driver 2 * IBM Hot Plug Controller Driver
3 * 3 *
4 * Written By: Irene Zubarev, IBM Corporation 4 * Written By: Irene Zubarev, IBM Corporation
5 * 5 *
6 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com) 6 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
7 * Copyright (C) 2001,2002 IBM Corp. 7 * Copyright (C) 2001,2002 IBM Corp.
8 * 8 *
@@ -42,7 +42,7 @@ static u8 find_sec_number (u8 primary_busno, u8 slotno);
42 42
43/* 43/*
44 * NOTE..... If BIOS doesn't provide default routing, we assign: 44 * NOTE..... If BIOS doesn't provide default routing, we assign:
45 * 9 for SCSI, 10 for LAN adapters, and 11 for everything else. 45 * 9 for SCSI, 10 for LAN adapters, and 11 for everything else.
46 * If adapter is bridged, then we assign 11 to it and devices behind it. 46 * If adapter is bridged, then we assign 11 to it and devices behind it.
47 * We also assign the same irq numbers for multi function devices. 47 * We also assign the same irq numbers for multi function devices.
48 * These are PIC mode, so shouldn't matter n.e.ways (hopefully) 48 * These are PIC mode, so shouldn't matter n.e.ways (hopefully)
@@ -71,11 +71,11 @@ static void assign_alt_irq (struct pci_func * cur_func, u8 class_code)
71 * Configures the device to be added (will allocate needed resources if it 71 * Configures the device to be added (will allocate needed resources if it
72 * can), the device can be a bridge or a regular pci device, can also be 72 * can), the device can be a bridge or a regular pci device, can also be
73 * multi-functional 73 * multi-functional
74 * 74 *
75 * Input: function to be added 75 * Input: function to be added
76 * 76 *
77 * TO DO: The error case with Multifunction device or multi function bridge, 77 * TO DO: The error case with Multifunction device or multi function bridge,
78 * if there is an error, will need to go through all previous functions and 78 * if there is an error, will need to go through all previous functions and
79 * unconfigure....or can add some code into unconfigure_card.... 79 * unconfigure....or can add some code into unconfigure_card....
80 */ 80 */
81int ibmphp_configure_card (struct pci_func *func, u8 slotno) 81int ibmphp_configure_card (struct pci_func *func, u8 slotno)
@@ -98,7 +98,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
98 cur_func = func; 98 cur_func = func;
99 99
100 /* We only get bus and device from IRQ routing table. So at this point, 100 /* We only get bus and device from IRQ routing table. So at this point,
101 * func->busno is correct, and func->device contains only device (at the 5 101 * func->busno is correct, and func->device contains only device (at the 5
102 * highest bits) 102 * highest bits)
103 */ 103 */
104 104
@@ -151,7 +151,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
151 cur_func->device, cur_func->busno); 151 cur_func->device, cur_func->busno);
152 cleanup_count = 6; 152 cleanup_count = 6;
153 goto error; 153 goto error;
154 } 154 }
155 cur_func->next = NULL; 155 cur_func->next = NULL;
156 function = 0x8; 156 function = 0x8;
157 break; 157 break;
@@ -339,7 +339,7 @@ error:
339} 339}
340 340
341/* 341/*
342 * This function configures the pci BARs of a single device. 342 * This function configures the pci BARs of a single device.
343 * Input: pointer to the pci_func 343 * Input: pointer to the pci_func
344 * Output: configured PCI, 0, or error 344 * Output: configured PCI, 0, or error
345 */ 345 */
@@ -371,17 +371,17 @@ static int configure_device (struct pci_func *func)
371 371
372 for (count = 0; address[count]; count++) { /* for 6 BARs */ 372 for (count = 0; address[count]; count++) { /* for 6 BARs */
373 373
374 /* not sure if i need this. per scott, said maybe need smth like this 374 /* not sure if i need this. per scott, said maybe need * something like this
375 if devices don't adhere 100% to the spec, so don't want to write 375 if devices don't adhere 100% to the spec, so don't want to write
376 to the reserved bits 376 to the reserved bits
377 377
378 pcibios_read_config_byte(cur_func->busno, cur_func->device, 378 pcibios_read_config_byte(cur_func->busno, cur_func->device,
379 PCI_BASE_ADDRESS_0 + 4 * count, &tmp); 379 PCI_BASE_ADDRESS_0 + 4 * count, &tmp);
380 if (tmp & 0x01) // IO 380 if (tmp & 0x01) // IO
381 pcibios_write_config_dword(cur_func->busno, cur_func->device, 381 pcibios_write_config_dword(cur_func->busno, cur_func->device,
382 PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFD); 382 PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFD);
383 else // Memory 383 else // Memory
384 pcibios_write_config_dword(cur_func->busno, cur_func->device, 384 pcibios_write_config_dword(cur_func->busno, cur_func->device,
385 PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF); 385 PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF);
386 */ 386 */
387 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); 387 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF);
@@ -421,8 +421,8 @@ static int configure_device (struct pci_func *func)
421 return -EIO; 421 return -EIO;
422 } 422 }
423 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); 423 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start);
424 424
425 /* _______________This is for debugging purposes only_____________________ */ 425 /* _______________This is for debugging purposes only_____________________ */
426 debug ("b4 writing, the IO address is %x\n", func->io[count]->start); 426 debug ("b4 writing, the IO address is %x\n", func->io[count]->start);
427 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); 427 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]);
428 debug ("after writing.... the start address is %x\n", bar[count]); 428 debug ("after writing.... the start address is %x\n", bar[count]);
@@ -484,7 +484,7 @@ static int configure_device (struct pci_func *func)
484 484
485 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); 485 pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start);
486 486
487 /*_______________This is for debugging purposes only______________________________*/ 487 /*_______________This is for debugging purposes only______________________________*/
488 debug ("b4 writing, start address is %x\n", func->pfmem[count]->start); 488 debug ("b4 writing, start address is %x\n", func->pfmem[count]->start);
489 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); 489 pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]);
490 debug ("after writing, start address is %x\n", bar[count]); 490 debug ("after writing, start address is %x\n", bar[count]);
@@ -559,7 +559,7 @@ static int configure_device (struct pci_func *func)
559/****************************************************************************** 559/******************************************************************************
560 * This routine configures a PCI-2-PCI bridge and the functions behind it 560 * This routine configures a PCI-2-PCI bridge and the functions behind it
561 * Parameters: pci_func 561 * Parameters: pci_func
562 * Returns: 562 * Returns:
563 ******************************************************************************/ 563 ******************************************************************************/
564static int configure_bridge (struct pci_func **func_passed, u8 slotno) 564static int configure_bridge (struct pci_func **func_passed, u8 slotno)
565{ 565{
@@ -622,7 +622,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
622 debug ("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno); 622 debug ("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno);
623 623
624 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number); 624 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number);
625 625
626 /* __________________For debugging purposes only __________________________________ 626 /* __________________For debugging purposes only __________________________________
627 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); 627 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number);
628 debug ("sec_number after write/read is %x\n", sec_number); 628 debug ("sec_number after write/read is %x\n", sec_number);
@@ -644,7 +644,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
644 644
645 645
646 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 646 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
647 !!!!!!!!!!!!!!!NEED TO ADD!!! FAST BACK-TO-BACK ENABLE!!!!!!!!!!!!!!!!!!!! 647 !!!!!!!!!!!!!!!NEED TO ADD!!! FAST BACK-TO-BACK ENABLE!!!!!!!!!!!!!!!!!!!!
648 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ 648 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
649 649
650 650
@@ -670,7 +670,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
670 debug ("len[count] in IO = %x\n", len[count]); 670 debug ("len[count] in IO = %x\n", len[count]);
671 671
672 bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL); 672 bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
673 673
674 if (!bus_io[count]) { 674 if (!bus_io[count]) {
675 err ("out of system memory\n"); 675 err ("out of system memory\n");
676 retval = -ENOMEM; 676 retval = -ENOMEM;
@@ -735,7 +735,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
735 ibmphp_add_pfmem_from_mem (bus_pfmem[count]); 735 ibmphp_add_pfmem_from_mem (bus_pfmem[count]);
736 func->pfmem[count] = bus_pfmem[count]; 736 func->pfmem[count] = bus_pfmem[count];
737 } else { 737 } else {
738 err ("cannot allocate requested pfmem for bus %x, device %x, len %x\n", 738 err ("cannot allocate requested pfmem for bus %x, device %x, len %x\n",
739 func->busno, func->device, len[count]); 739 func->busno, func->device, len[count]);
740 kfree (mem_tmp); 740 kfree (mem_tmp);
741 kfree (bus_pfmem[count]); 741 kfree (bus_pfmem[count]);
@@ -805,7 +805,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
805 debug ("amount_needed->mem = %x\n", amount_needed->mem); 805 debug ("amount_needed->mem = %x\n", amount_needed->mem);
806 debug ("amount_needed->pfmem = %x\n", amount_needed->pfmem); 806 debug ("amount_needed->pfmem = %x\n", amount_needed->pfmem);
807 807
808 if (amount_needed->not_correct) { 808 if (amount_needed->not_correct) {
809 debug ("amount_needed is not correct\n"); 809 debug ("amount_needed is not correct\n");
810 for (count = 0; address[count]; count++) { 810 for (count = 0; address[count]; count++) {
811 /* for 2 BARs */ 811 /* for 2 BARs */
@@ -830,7 +830,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
830 } else { 830 } else {
831 debug ("it wants %x IO behind the bridge\n", amount_needed->io); 831 debug ("it wants %x IO behind the bridge\n", amount_needed->io);
832 io = kzalloc(sizeof(*io), GFP_KERNEL); 832 io = kzalloc(sizeof(*io), GFP_KERNEL);
833 833
834 if (!io) { 834 if (!io) {
835 err ("out of system memory\n"); 835 err ("out of system memory\n");
836 retval = -ENOMEM; 836 retval = -ENOMEM;
@@ -959,7 +959,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
959 959
960 if (bus->noIORanges) { 960 if (bus->noIORanges) {
961 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8); 961 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8);
962 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8); 962 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8);
963 963
964 /* _______________This is for debugging purposes only ____________________ 964 /* _______________This is for debugging purposes only ____________________
965 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp); 965 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp);
@@ -980,7 +980,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
980 if (bus->noMemRanges) { 980 if (bus->noMemRanges) {
981 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16); 981 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16);
982 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16); 982 pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16);
983 983
984 /* ____________________This is for debugging purposes only ________________________ 984 /* ____________________This is for debugging purposes only ________________________
985 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp); 985 pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp);
986 debug ("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); 986 debug ("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16);
@@ -1017,7 +1017,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
1017 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); 1017 pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq);
1018 if ((irq > 0x00) && (irq < 0x05)) 1018 if ((irq > 0x00) && (irq < 0x05))
1019 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); 1019 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]);
1020 /* 1020 /*
1021 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl); 1021 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl);
1022 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY); 1022 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY);
1023 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); 1023 pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR);
@@ -1071,7 +1071,7 @@ error:
1071 * This function adds up the amount of resources needed behind the PPB bridge 1071 * This function adds up the amount of resources needed behind the PPB bridge
1072 * and passes it to the configure_bridge function 1072 * and passes it to the configure_bridge function
1073 * Input: bridge function 1073 * Input: bridge function
1074 * Ouput: amount of resources needed 1074 * Output: amount of resources needed
1075 *****************************************************************************/ 1075 *****************************************************************************/
1076static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) 1076static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
1077{ 1077{
@@ -1204,9 +1204,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
1204 return amount; 1204 return amount;
1205} 1205}
1206 1206
1207/* The following 3 unconfigure_boot_ routines deal with the case when we had the card 1207/* The following 3 unconfigure_boot_ routines deal with the case when we had the card
1208 * upon bootup in the system, since we don't allocate func to such case, we need to read 1208 * upon bootup in the system, since we don't allocate func to such case, we need to read
1209 * the start addresses from pci config space and then find the corresponding entries in 1209 * the start addresses from pci config space and then find the corresponding entries in
1210 * our resource lists. The functions return either 0, -ENODEV, or -1 (general failure) 1210 * our resource lists. The functions return either 0, -ENODEV, or -1 (general failure)
1211 * Change: we also call these functions even if we configured the card ourselves (i.e., not 1211 * Change: we also call these functions even if we configured the card ourselves (i.e., not
1212 * the bootup case), since it should work same way 1212 * the bootup case), since it should work same way
@@ -1561,8 +1561,8 @@ static int unconfigure_boot_card (struct slot *slot_cur)
1561 * unconfiguring the device 1561 * unconfiguring the device
1562 * TO DO: will probably need to add some code in case there was some resource, 1562 * TO DO: will probably need to add some code in case there was some resource,
1563 * to remove it... this is from when we have errors in the configure_card... 1563 * to remove it... this is from when we have errors in the configure_card...
1564 * !!!!!!!!!!!!!!!!!!!!!!!!!FOR BUSES!!!!!!!!!!!! 1564 * !!!!!!!!!!!!!!!!!!!!!!!!!FOR BUSES!!!!!!!!!!!!
1565 * Returns: 0, -1, -ENODEV 1565 * Returns: 0, -1, -ENODEV
1566 */ 1566 */
1567int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end) 1567int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end)
1568{ 1568{
@@ -1634,7 +1634,7 @@ int ibmphp_unconfigure_card (struct slot **slot_cur, int the_end)
1634 * Input: bus and the amount of resources needed (we know we can assign those, 1634 * Input: bus and the amount of resources needed (we know we can assign those,
1635 * since they've been checked already 1635 * since they've been checked already
1636 * Output: bus added to the correct spot 1636 * Output: bus added to the correct spot
1637 * 0, -1, error 1637 * 0, -1, error
1638 */ 1638 */
1639static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct resource_node *mem, struct resource_node *pfmem, u8 parent_busno) 1639static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct resource_node *mem, struct resource_node *pfmem, u8 parent_busno)
1640{ 1640{
@@ -1650,7 +1650,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1650 err ("strange, cannot find bus which is supposed to be at the system... something is terribly wrong...\n"); 1650 err ("strange, cannot find bus which is supposed to be at the system... something is terribly wrong...\n");
1651 return -ENODEV; 1651 return -ENODEV;
1652 } 1652 }
1653 1653
1654 list_add (&bus->bus_list, &cur_bus->bus_list); 1654 list_add (&bus->bus_list, &cur_bus->bus_list);
1655 } 1655 }
1656 if (io) { 1656 if (io) {
@@ -1679,7 +1679,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
1679 } 1679 }
1680 if (pfmem) { 1680 if (pfmem) {
1681 pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL); 1681 pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL);
1682 if (!pfmem_range) { 1682 if (!pfmem_range) {
1683 err ("out of system memory\n"); 1683 err ("out of system memory\n");
1684 return -ENOMEM; 1684 return -ENOMEM;
1685 } 1685 }
@@ -1726,4 +1726,3 @@ static u8 find_sec_number (u8 primary_busno, u8 slotno)
1726 return busno; 1726 return busno;
1727 return 0xff; 1727 return 0xff;
1728} 1728}
1729