Commit 441a1393 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

IBM PCI Hotplug driver: changed calls to pci_*_nodev() to pci_bus_*()

parent 82475a64
......@@ -693,7 +693,7 @@ extern void ibmphp_hpc_stop_poll_thread (void);
#define PCIX66 0x05
#define PCI66 0x04
extern struct pci_ops *ibmphp_pci_root_ops;
extern struct pci_bus *ibmphp_pci_bus;
/* Variables */
......@@ -764,7 +764,6 @@ extern int ibmphp_disable_slot (struct hotplug_slot *); /* This function is call
extern int ibmphp_update_slot_info (struct slot *); /* This function is called from HPC, so we need it to not be be static */
extern int ibmphp_configure_card (struct pci_func *, u8);
extern int ibmphp_unconfigure_card (struct slot **, int);
extern void ibmphp_increase_count (void);
extern struct hotplug_slot_ops ibmphp_hotplug_slot_ops;
static inline void long_delay (int delay)
......
......@@ -56,7 +56,7 @@ MODULE_LICENSE ("GPL");
MODULE_DESCRIPTION (DRIVER_DESC);
static int *ops[MAX_OPS + 1];
struct pci_ops *ibmphp_pci_root_ops;
struct pci_bus *ibmphp_pci_bus;
static int max_slots;
static int irqs[16]; /* PIC mode IRQ's we're using so far (in case MPS tables don't provide default info for empty slots */
......@@ -769,18 +769,6 @@ static struct pci_bus *find_bus (u8 busno)
return NULL;
}
/******************************************************************
* This function is here because we can no longer use pci_root_ops
******************************************************************/
static struct pci_ops *get_root_pci_ops (void)
{
struct pci_bus * bus;
if ((bus = find_bus (0)))
return bus->ops;
return NULL;
}
/*************************************************************
* This routine frees up memory used by struct slot, including
* the pointers to pci_func, bus, hotplug_slot, controller,
......@@ -975,8 +963,8 @@ static int configure_visit_pci_dev (struct pci_dev_wrapped *wrapped_dev, struct
}
if (temp_func->dev) {
pci_proc_attach_device (temp_func->dev);
pci_announce_device_to_drivers (temp_func->dev);
// pci_proc_attach_device (temp_func->dev);
// pci_announce_device_to_drivers (temp_func->dev);
}
return 0;
......@@ -995,22 +983,39 @@ static struct pci_visit configure_functions = {
static u8 bus_structure_fixup (u8 busno)
{
struct pci_bus bus_t;
struct pci_dev dev_t;
struct pci_bus *bus;
struct pci_dev *dev;
u16 l;
if (!find_bus (busno) || !(ibmphp_find_same_bus_num (busno)))
return 1;
bus_t.number = busno;
bus_t.ops = ibmphp_pci_root_ops;
dev_t.bus = &bus_t;
for (dev_t.devfn=0; dev_t.devfn<256; dev_t.devfn += 8) {
if (!pci_read_config_word (&dev_t, PCI_VENDOR_ID, &l) && l != 0x0000 && l != 0xffff) {
bus = kmalloc (sizeof (*bus), GFP_KERNEL);
if (!bus) {
err ("%s - out of memory\n", __FUNCTION__);
return 1;
}
dev = kmalloc (sizeof (*dev), GFP_KERNEL);
if (!dev) {
kfree (bus);
err ("%s - out of memory\n", __FUNCTION__);
return 1;
}
bus->number = busno;
bus->ops = ibmphp_pci_bus->ops;
dev->bus = bus;
for (dev->devfn = 0; dev->devfn < 256; dev->devfn += 8) {
if (!pci_read_config_word (dev, PCI_VENDOR_ID, &l) && l != 0x0000 && l != 0xffff) {
debug ("%s - Inside bus_struture_fixup() \n", __FUNCTION__);
pci_scan_bus (busno, ibmphp_pci_root_ops, NULL);
pci_scan_bus (busno, ibmphp_pci_bus->ops, NULL);
break;
}
}
kfree (dev);
kfree (bus);
return 0;
}
......@@ -1602,6 +1607,7 @@ static void ibmphp_unload (void)
static int __init ibmphp_init (void)
{
struct pci_bus *bus;
int i = 0;
int rc = 0;
......@@ -1609,11 +1615,18 @@ static int __init ibmphp_init (void)
info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
ibmphp_pci_root_ops = get_root_pci_ops ();
if (ibmphp_pci_root_ops == NULL) {
err ("cannot read bus operations... will not be able to read the cards. Please check your system\n");
return -ENODEV;
ibmphp_pci_bus = kmalloc (sizeof (*ibmphp_pci_bus), GFP_KERNEL);
if (!ibmphp_pci_bus) {
err ("out of memory\n");
return -ENOMEM;
}
bus = find_bus (0);
if (!bus) {
err ("Can't find the root pci bus, can not continue\n");
return -ENODEV;
}
memcpy (ibmphp_pci_bus, bus, sizeof (*ibmphp_pci_bus));
ibmphp_debug = debug;
......
This diff is collapsed.
......@@ -1932,7 +1932,7 @@ int static range_exists_already (struct range_node * range, struct bus_node * bu
*/
static int __init update_bridge_ranges (struct bus_node **bus)
{
u8 sec_busno, device, function, busno, hdr_type, start_io_address, end_io_address;
u8 sec_busno, device, function, hdr_type, start_io_address, end_io_address;
u16 vendor_id, upper_io_start, upper_io_end, start_mem_address, end_mem_address;
u32 start_address, end_address, upper_start, upper_end;
struct bus_node *bus_sec;
......@@ -1941,21 +1941,24 @@ static int __init update_bridge_ranges (struct bus_node **bus)
struct resource_node *mem;
struct resource_node *pfmem;
struct range_node *range;
unsigned int devfn;
bus_cur = *bus;
if (!bus_cur)
return -ENODEV;
busno = bus_cur->busno;
ibmphp_pci_bus->number = bus_cur->busno;
debug ("inside %s \n", __FUNCTION__);
debug ("bus_cur->busno = %x\n", bus_cur->busno);
for (device = 0; device < 32; device++) {
for (function = 0x00; function < 0x08; function++) {
pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_VENDOR_ID, &vendor_id);
devfn = PCI_DEVFN(device, function);
pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id);
if (vendor_id != PCI_VENDOR_ID_NOTVALID) {
/* found correct device!!! */
pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_HEADER_TYPE, &hdr_type);
pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type);
switch (hdr_type) {
case PCI_HEADER_TYPE_NORMAL:
......@@ -1974,7 +1977,7 @@ static int __init update_bridge_ranges (struct bus_node **bus)
temp++;
}
*/
pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_SECONDARY_BUS, &sec_busno);
pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_busno);
bus_sec = find_bus_wprev (sec_busno, NULL, 0);
/* this bus structure doesn't exist yet, PPB was configured during previous loading of ibmphp */
if (!bus_sec) {
......@@ -1982,10 +1985,10 @@ static int __init update_bridge_ranges (struct bus_node **bus)
/* the rest will be populated during NVRAM call */
return 0;
}
pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_IO_BASE, &start_io_address);
pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_IO_LIMIT, &end_io_address);
pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_IO_BASE_UPPER16, &upper_io_start);
pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_IO_LIMIT_UPPER16, &upper_io_end);
pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &start_io_address);
pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &end_io_address);
pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, &upper_io_start);
pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, &upper_io_end);
start_address = (start_io_address & PCI_IO_RANGE_MASK) << 8;
start_address |= (upper_io_start << 16);
end_address = (end_io_address & PCI_IO_RANGE_MASK) << 8;
......@@ -2035,8 +2038,8 @@ static int __init update_bridge_ranges (struct bus_node **bus)
}
}
pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_MEMORY_BASE, &start_mem_address);
pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_MEMORY_LIMIT, &end_mem_address);
pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &start_mem_address);
pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &end_mem_address);
start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16;
end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16;
......@@ -2086,10 +2089,10 @@ static int __init update_bridge_ranges (struct bus_node **bus)
ibmphp_add_resource (mem);
}
}
pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_PREF_MEMORY_BASE, &start_mem_address);
pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_PREF_MEMORY_LIMIT, &end_mem_address);
pci_read_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_PREF_BASE_UPPER32, &upper_start);
pci_read_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_PREF_LIMIT_UPPER32, &upper_end);
pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &start_mem_address);
pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &end_mem_address);
pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, &upper_start);
pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, &upper_end);
start_address = 0x00000000 | (start_mem_address & PCI_MEMORY_RANGE_MASK) << 16;
end_address = 0x00000000 | (end_mem_address & PCI_MEMORY_RANGE_MASK) << 16;
#if BITS_PER_LONG == 64
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment