From af6e9e0779ac113bec6fab4aa4808475c897a8fe Mon Sep 17 00:00:00 2001 From: Irene Zubarev Date: Mon, 9 Sep 2002 00:38:14 -0700 Subject: [PATCH] IBM PCI Hotplug driver update - fix polling logic - add ability to write [chassis/rxe]#slot# instead of just slot# --- drivers/hotplug/ibmphp.h | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'drivers/hotplug/ibmphp.h') diff --git a/drivers/hotplug/ibmphp.h b/drivers/hotplug/ibmphp.h index ca8e5044c622..a45b1c7e821b 100644 --- a/drivers/hotplug/ibmphp.h +++ b/drivers/hotplug/ibmphp.h @@ -39,7 +39,8 @@ extern int ibmphp_debug; #else #define MY_NAME THIS_MODULE->name #endif -#define debug(fmt, arg...) do { if (ibmphp_debug) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) +#define debug(fmt, arg...) do { if (ibmphp_debug == 1) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) +#define debug_pci(fmt, arg...) do { if (ibmphp_debug) printk(KERN_DEBUG "%s: " fmt , MY_NAME , ## arg); } while (0) #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg) #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg) #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg) @@ -121,6 +122,7 @@ struct scal_detail { u8 port1_port_connect; u8 port2_node_connect; u8 port2_port_connect; + u8 chassis_num; // struct list_head scal_detail_list; }; @@ -139,9 +141,27 @@ struct rio_detail { u8 port1_port_connect; u8 first_slot_num; u8 status; -// struct list_head rio_detail_list; + u8 wpindex; + u8 chassis_num; + struct list_head rio_detail_list; }; +struct opt_rio { + u8 rio_type; + u8 chassis_num; + u8 first_slot_num; + u8 middle_num; + struct list_head opt_rio_list; +}; + +struct opt_rio_lo { + u8 rio_type; + u8 chassis_num; + u8 first_slot_num; + u8 middle_num; + u8 pack_count; + struct list_head opt_rio_lo_list; +}; /**************************************************************** * HPC DESCRIPTOR NODE * @@ -153,7 +173,6 @@ struct ebda_hpc_list { short phys_addr; // struct list_head ebda_hpc_list; }; - /***************************************************************** * IN HPC DATA STRUCTURE, THE ASSOCIATED SLOT AND BUS * * STRUCTURE * @@ -195,6 +214,9 @@ struct wpeg_i2c_ctlr_access { u8 i2c_addr; }; +#define HPC_DEVICE_ID 0x0246 +#define HPC_SUBSYSTEM_ID 0x0247 +#define HPC_PCI_OFFSET 0x40 /************************************************************************* * RSTC DESCRIPTOR NODE * *************************************************************************/ @@ -215,8 +237,9 @@ struct ebda_pci_rsrc { u8 rsrc_type; u8 bus_num; u8 dev_fun; - ulong start_addr; - ulong end_addr; + u32 start_addr; + u32 end_addr; + u8 marked; /* for NVRAM */ struct list_head ebda_pci_rsrc_list; }; @@ -248,7 +271,7 @@ struct bus_info { ***********************************************************/ extern struct list_head ibmphp_ebda_pci_rsrc_head; extern struct list_head ibmphp_slot_head; - +extern struct list_head ibmphp_res_head; /*********************************************************** * FUNCTION PROTOTYPES * ***********************************************************/ @@ -263,6 +286,7 @@ extern void ibmphp_free_ebda_pci_rsrc_queue (void); extern struct bus_info *ibmphp_find_same_bus_num (u32); extern int ibmphp_get_bus_index (u8); extern u16 ibmphp_get_total_controllers (void); +extern int ibmphp_register_pci (void); /* passed parameters */ #define MEM 0 @@ -739,6 +763,7 @@ 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) -- cgit v1.2.3 From ef7f120ab49379a4745574dddf480c845ea2c7ab Mon Sep 17 00:00:00 2001 From: Irene Zubarev Date: Mon, 9 Sep 2002 00:40:30 -0700 Subject: [PATCH] IBM PCI Hotplug driver update for PCI based controllers --- drivers/hotplug/ibmphp.h | 1 + drivers/hotplug/ibmphp_core.c | 5 +++ drivers/hotplug/ibmphp_ebda.c | 71 +++++++++++++++++++++++++++++++++++++++---- drivers/hotplug/ibmphp_hpc.c | 26 ++++++++++++++++ 4 files changed, 97 insertions(+), 6 deletions(-) (limited to 'drivers/hotplug/ibmphp.h') diff --git a/drivers/hotplug/ibmphp.h b/drivers/hotplug/ibmphp.h index a45b1c7e821b..3828441ce748 100644 --- a/drivers/hotplug/ibmphp.h +++ b/drivers/hotplug/ibmphp.h @@ -737,6 +737,7 @@ struct slot { struct controller { struct ebda_hpc_slot *slots; struct ebda_hpc_bus *buses; + struct pci_dev *ctrl_dev; /* in case where controller is PCI */ u8 starting_slot_num; /* starting and ending slot #'s this ctrl controls*/ u8 ending_slot_num; u8 revision; diff --git a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c index 72907414443f..713943370a76 100644 --- a/drivers/hotplug/ibmphp_core.c +++ b/drivers/hotplug/ibmphp_core.c @@ -1636,6 +1636,11 @@ static int __init ibmphp_init (void) max_slots = get_max_slots (); + if ((rc = ibmphp_register_pci ())) { + ibmphp_unload (); + return rc; + } + if (init_ops ()) { ibmphp_unload (); return -ENODEV; diff --git a/drivers/hotplug/ibmphp_ebda.c b/drivers/hotplug/ibmphp_ebda.c index 3fba419e7d07..86a88433da5f 100644 --- a/drivers/hotplug/ibmphp_ebda.c +++ b/drivers/hotplug/ibmphp_ebda.c @@ -131,6 +131,7 @@ static void free_ebda_hpc (struct controller *controller) controller->slots = NULL; kfree (controller->buses); controller->buses = NULL; + controller->ctrl_dev = NULL; kfree (controller); } @@ -798,6 +799,8 @@ static char *create_file_name (struct slot * slot_cur) return NULL; } +static struct pci_driver ibmphp_driver; + /* * map info (ctlr-id, slot count, slot#.. bus count, bus#, ctlr type...) of * each hpc from physical address to a list of hot plug controllers based on @@ -929,6 +932,7 @@ static int __init ebda_rsrc_controller (void) hpc_ptr->u.pci_ctlr.dev_fun = readb (io_mem + addr + 1); hpc_ptr->irq = readb (io_mem + addr + 2); addr += 3; + debug ("ctrl bus = %x, ctlr devfun = %x, irq = %x\n", hpc_ptr->u.pci_ctlr.bus, hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq); break; case 0: @@ -954,12 +958,6 @@ static int __init ebda_rsrc_controller (void) return -ENODEV; } - /* following 3 line: Now our driver only supports I2c/ISA ctlrType */ - if ((hpc_ptr->ctlr_type != 2) && (hpc_ptr->ctlr_type != 4) && (hpc_ptr->ctlr_type != 0)) { - err ("Please run this driver on IBM xSeries440 or xSeries 235\n "); - return -ENODEV; - } - //reorganize chassis' linked list combine_wpg_for_chassis (); combine_wpg_for_expansion (); @@ -1213,11 +1211,16 @@ void ibmphp_free_ebda_hpc_queue (void) struct controller *controller = NULL; struct list_head *list; struct list_head *next; + int pci_flag = 0; list_for_each_safe (list, next, &ebda_hpc_head) { controller = list_entry (list, struct controller, ebda_hpc_list); if (controller->ctlr_type == 0) release_region (controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1)); + else if ((controller->ctlr_type == 1) && (!pci_flag)) { + ++pci_flag; + pci_unregister_driver (&ibmphp_driver); + } free_ebda_hpc (controller); } } @@ -1234,3 +1237,59 @@ void ibmphp_free_ebda_pci_rsrc_queue (void) resource = NULL; } } + +static struct pci_device_id id_table[] __devinitdata = { + { + vendor: PCI_VENDOR_ID_IBM, + device: HPC_DEVICE_ID, + subvendor: PCI_VENDOR_ID_IBM, + subdevice: HPC_SUBSYSTEM_ID, + class: ((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00), + }, {} +}; + +MODULE_DEVICE_TABLE(pci, id_table); + +static int ibmphp_probe (struct pci_dev *, const struct pci_device_id *); +static struct pci_driver ibmphp_driver = { + name: "ibmphp", + id_table: id_table, + probe: ibmphp_probe, +}; + +int ibmphp_register_pci (void) +{ + struct controller *ctrl; + struct list_head *tmp; + int rc = 0; + + list_for_each (tmp, &ebda_hpc_head) { + ctrl = list_entry (tmp, struct controller, ebda_hpc_list); + if (ctrl->ctlr_type == 1) { + rc = pci_module_init (&ibmphp_driver); + break; + } + } + return rc; +} +static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids) +{ + struct controller *ctrl; + struct list_head *tmp; + + debug ("inside ibmphp_probe \n"); + + list_for_each (tmp, &ebda_hpc_head) { + ctrl = list_entry (tmp, struct controller, ebda_hpc_list); + if (ctrl->ctlr_type == 1) { + if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { + ctrl->ctrl_dev = dev; + debug ("found device!!! \n"); + debug ("dev->device = %x, dev->subsystem_device = %x\n", dev->device, dev->subsystem_device); + return 0; + } + } + } + return -ENODEV; +} + diff --git a/drivers/hotplug/ibmphp_hpc.c b/drivers/hotplug/ibmphp_hpc.c index de70037b449a..ae959809e8a8 100644 --- a/drivers/hotplug/ibmphp_hpc.c +++ b/drivers/hotplug/ibmphp_hpc.c @@ -379,6 +379,26 @@ static void isa_ctrl_write (struct controller *ctlr_ptr, u8 offset, u8 data) outb (data, port_address); } +static u8 pci_ctrl_read (struct controller *ctrl, u8 offset) +{ + u8 data = 0x00; + debug ("inside pci_ctrl_read\n"); + if (ctrl->ctrl_dev) + pci_read_config_byte (ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, &data); + return data; +} + +static u8 pci_ctrl_write (struct controller *ctrl, u8 offset, u8 data) +{ + u8 rc = -ENODEV; + debug ("inside pci_ctrl_write\n"); + if (ctrl->ctrl_dev) { + pci_write_config_byte (ctrl->ctrl_dev, HPC_PCI_OFFSET + offset, data); + rc = 0; + } + return rc; +} + static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset) { u8 rc; @@ -386,6 +406,9 @@ static u8 ctrl_read (struct controller *ctlr, void *base, u8 offset) case 0: rc = isa_ctrl_read (ctlr, offset); break; + case 1: + rc = pci_ctrl_read (ctlr, offset); + break; case 2: case 4: rc = i2c_ctrl_read (ctlr, base, offset); @@ -403,6 +426,9 @@ static u8 ctrl_write (struct controller *ctlr, void *base, u8 offset, u8 data) case 0: isa_ctrl_write(ctlr, offset, data); break; + case 1: + rc = pci_ctrl_write (ctlr, offset, data); + break; case 2: case 4: rc = i2c_ctrl_write(ctlr, base, offset, data); -- cgit v1.2.3 From 441a1393ee4ad8413044415fd3a50833cafc7258 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 9 Sep 2002 01:00:49 -0700 Subject: IBM PCI Hotplug driver: changed calls to pci_*_nodev() to pci_bus_*() --- drivers/hotplug/ibmphp.h | 3 +- drivers/hotplug/ibmphp_core.c | 67 +++++++------ drivers/hotplug/ibmphp_pci.c | 215 +++++++++++++++++++++++------------------- drivers/hotplug/ibmphp_res.c | 33 ++++--- 4 files changed, 175 insertions(+), 143 deletions(-) (limited to 'drivers/hotplug/ibmphp.h') diff --git a/drivers/hotplug/ibmphp.h b/drivers/hotplug/ibmphp.h index 3828441ce748..fc899b307834 100644 --- a/drivers/hotplug/ibmphp.h +++ b/drivers/hotplug/ibmphp.h @@ -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) diff --git a/drivers/hotplug/ibmphp_core.c b/drivers/hotplug/ibmphp_core.c index 713943370a76..5113d30f93f1 100644 --- a/drivers/hotplug/ibmphp_core.c +++ b/drivers/hotplug/ibmphp_core.c @@ -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; diff --git a/drivers/hotplug/ibmphp_pci.c b/drivers/hotplug/ibmphp_pci.c index 363fb3ecc021..cfc9ecffd650 100644 --- a/drivers/hotplug/ibmphp_pci.c +++ b/drivers/hotplug/ibmphp_pci.c @@ -104,11 +104,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) /* For every function on the card */ for (function = 0x00; function < 0x08; function++) { + unsigned int devfn = PCI_DEVFN(device, function); + ibmphp_pci_bus->number = cur_func->busno; + cur_func->function = function; - debug ("inside the loop, cur_func->busno = %x, cur_func->device = %x, cur_func->funcion = %x\n", cur_func->busno, device, function); + debug ("inside the loop, cur_func->busno = %x, cur_func->device = %x, cur_func->funcion = %x\n", + cur_func->busno, cur_func->device, cur_func->function); - pci_read_config_word_nodev (ibmphp_pci_root_ops, cur_func->busno, device, function, PCI_VENDOR_ID, &vendor_id); + pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); debug ("vendor_id is %x\n", vendor_id); if (vendor_id != PCI_VENDOR_ID_NOTVALID) { @@ -122,8 +126,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) * |_=> 0 = single function device, 1 = multi-function device */ - pci_read_config_byte_nodev (ibmphp_pci_root_ops, cur_func->busno, device, function, PCI_HEADER_TYPE, &hdr_type); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, cur_func->busno, device, function, PCI_CLASS_REVISION, &class); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); class_code = class >> 24; debug ("hrd_type = %x, class = %x, class_code %x \n", hdr_type, class, class_code); @@ -195,7 +199,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) goto error; } - pci_read_config_byte_nodev (ibmphp_pci_root_ops, cur_func->busno, device, function, PCI_SECONDARY_BUS, &sec_number); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); flag = FALSE; for (i = 0; i < 32; i++) { if (func->devices[i]) { @@ -267,8 +271,9 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) cleanup_count = 2; goto error; } - debug ("cur_func->busno = %x, device = %x, function = %x\n", cur_func->busno, device, function); - pci_read_config_byte_nodev (ibmphp_pci_root_ops, cur_func->busno, device, function, PCI_SECONDARY_BUS, &sec_number); + debug ("cur_func->busno = %x, device = %x, function = %x\n", + cur_func->busno, device, function); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); debug ("after configuring bridge..., sec_number = %x\n", sec_number); flag = FALSE; for (i = 0; i < 32; i++) { @@ -361,13 +366,12 @@ static int configure_device (struct pci_func *func) struct resource_node *mem[6]; struct resource_node *mem_tmp; struct resource_node *pfmem[6]; - u8 device; - u8 function; + unsigned int devfn; debug ("%s - inside\n", __FUNCTION__); - device = func->device; - function = func->function; + devfn = PCI_DEVFN(func->device, func->function); + ibmphp_pci_bus->number = func->busno; for (count = 0; address[count]; count++) { /* for 6 BARs */ @@ -384,8 +388,8 @@ static int configure_device (struct pci_func *func) pcibios_write_config_dword(cur_func->busno, cur_func->device, PCI_BASE_ADDRESS_0 + 4 * count, 0xFFFFFFFF); */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], 0xFFFFFFFF); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], &bar[count]); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); if (!bar[count]) /* This BAR is not implemented */ continue; @@ -421,11 +425,11 @@ static int configure_device (struct pci_func *func) kfree (io[count]); return -EIO; } - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], func->io[count]->start); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); /* _______________This is for debugging purposes only_____________________ */ debug ("b4 writing, the IO address is %x\n", func->io[count]->start); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], &bar[count]); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); debug ("after writing.... the start address is %x\n", bar[count]); /* _________________________________________________________________________*/ @@ -484,11 +488,11 @@ static int configure_device (struct pci_func *func) } } - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], func->pfmem[count]->start); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); - /*_______________This if for debugging purposes only______________________________*/ + /*_______________This is for debugging purposes only______________________________*/ debug ("b4 writing, start addres is %x\n", func->pfmem[count]->start); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], &bar[count]); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); debug ("after writing, start address is %x\n", bar[count]); /*_________________________________________________________________________________*/ @@ -496,7 +500,7 @@ static int configure_device (struct pci_func *func) debug ("inside the mem 64 case, count %d\n", count); count += 1; /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], 0x00000000); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); } } else { /* regular memory */ @@ -526,10 +530,10 @@ static int configure_device (struct pci_func *func) kfree (mem[count]); return -EIO; } - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], func->mem[count]->start); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); /* _______________________This is for debugging purposes only _______________________*/ debug ("b4 writing, start address is %x\n", func->mem[count]->start); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], &bar[count]); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); debug ("after writing, the address is %x\n", bar[count]); /* __________________________________________________________________________________*/ @@ -538,22 +542,22 @@ static int configure_device (struct pci_func *func) debug ("inside mem 64 case, reg. mem, count %d\n", count); count += 1; /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], 0x00000000); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); } } } /* end of mem */ } /* end of for */ func->bus = 0; /* To indicate that this is not a PPB */ - pci_read_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_INTERRUPT_PIN, &irq); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); if ((irq > 0x00) && (irq < 0x05)) - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_INTERRUPT_LINE, func->irq[irq - 1]); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_CACHE_LINE_SIZE, CACHE); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_LATENCY_TIMER, LATENCY); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_ROM_ADDRESS, 0x00L); - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_COMMAND, DEVICEENABLE); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_ROM_ADDRESS, 0x00L); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); return 0; } @@ -593,24 +597,23 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) 0 }; struct pci_func *func = *func_passed; - u8 function; - u8 device; + unsigned int devfn; u8 irq; int retval; debug ("%s - enter\n", __FUNCTION__); - function = func->function; - device = func->device; + devfn = PCI_DEVFN(func->function, func->device); + ibmphp_pci_bus->number = func->busno; /* Configuring necessary info for the bridge so that we could see the devices * behind it */ - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PRIMARY_BUS, func->busno); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, func->busno); /* _____________________For debugging purposes only __________________________ - pci_read_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PRIMARY_BUS, &pri_number); + pci_bus_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); debug ("primary # written into the bridge is %x\n", pri_number); ___________________________________________________________________________*/ @@ -624,23 +627,23 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) debug ("after find_sec_number, the number we got is %x\n", sec_number); debug ("AFTER FIND_SEC_NUMBER, func->busno IS %x\n", func->busno); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_SECONDARY_BUS, sec_number); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, sec_number); /* __________________For debugging purposes only __________________________________ - pci_read_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_SECONDARY_BUS, &sec_number); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); debug ("sec_number after write/read is %x\n", sec_number); ________________________________________________________________________________*/ - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_SUBORDINATE_BUS, sec_number); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, sec_number); /* __________________For debugging purposes only ____________________________________ - pci_read_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_SUBORDINATE_BUS, &sec_number); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sec_number); debug ("subordinate number after write/read is %x\n", sec_number); __________________________________________________________________________________*/ - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_CACHE_LINE_SIZE, CACHE); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_LATENCY_TIMER, LATENCY); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_SEC_LATENCY_TIMER, LATENCY); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_CACHE_LINE_SIZE, CACHE); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_LATENCY_TIMER, LATENCY); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_SEC_LATENCY_TIMER, LATENCY); debug ("func->busno is %x\n", func->busno); debug ("sec_number after writing is %x\n", sec_number); @@ -653,8 +656,8 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) /* First we need to allocate mem/io for the bridge itself in case it needs it */ for (count = 0; address[count]; count++) { /* for 2 BARs */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], 0xFFFFFFFF); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], &bar[count]); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); if (!bar[count]) { /* This BAR is not implemented */ @@ -694,7 +697,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) return -EIO; } - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], func->io[count]->start); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->io[count]->start); } else { /* This is Memory */ @@ -747,13 +750,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) } } - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], func->pfmem[count]->start); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->pfmem[count]->start); if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ count += 1; /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], 0x00000000); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); } } else { @@ -784,13 +787,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) return -EIO; } - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], func->mem[count]->start); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], func->mem[count]->start); if (bar[count] & PCI_BASE_ADDRESS_MEM_TYPE_64) { /* takes up another dword */ count += 1; /* on the 2nd dword, write all 0s, since we can't handle them n.e.ways */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, address[count], 0x00000000); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0x00000000); } } @@ -802,6 +805,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) if (amount_needed == NULL) return -ENOMEM; + ibmphp_pci_bus->number = func->busno; debug ("after coming back from scan_behind_bridge\n"); debug ("amount_needed->not_correct = %x\n", amount_needed->not_correct); debug ("amount_needed->io = %x\n", amount_needed->io); @@ -952,8 +956,8 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) retval = rc; goto error; } - pci_read_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_BASE, &io_base); - pci_read_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_MEMORY_BASE, &pfmem_base); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &io_base); + pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &pfmem_base); if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { debug ("io 32\n"); @@ -965,73 +969,73 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) } if (bus->noIORanges) { - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00 | bus->rangeIO->start >> 8); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00 | bus->rangeIO->end >> 8); /* _______________This is for debugging purposes only ____________________ - pci_read_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_BASE, &temp); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, &temp); debug ("io_base = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); - pci_read_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_LIMIT, &temp); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, &temp); debug ("io_limit = %x\n", (temp & PCI_IO_RANGE_TYPE_MASK) << 8); ________________________________________________________________________*/ if (need_io_upper) { /* since can't support n.e.ways */ - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_BASE_UPPER16, 0x0000); - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_LIMIT_UPPER16, 0x0000); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_IO_BASE_UPPER16, 0x0000); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_IO_LIMIT_UPPER16, 0x0000); } } else { - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_BASE, 0x00); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_IO_LIMIT, 0x00); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_BASE, 0x00); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_IO_LIMIT, 0x00); } if (bus->noMemRanges) { - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16); - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0x0000 | bus->rangeMem->start >> 16); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000 | bus->rangeMem->end >> 16); /* ____________________This is for debugging purposes only ________________________ - pci_read_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_MEMORY_BASE, &temp); + pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, &temp); debug ("mem_base = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); - pci_read_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_MEMORY_LIMIT, &temp); + pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, &temp); debug ("mem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); __________________________________________________________________________________*/ } else { - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_MEMORY_BASE, 0xffff); - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_MEMORY_LIMIT, 0x0000); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_BASE, 0xffff); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_MEMORY_LIMIT, 0x0000); } if (bus->noPFMemRanges) { - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_MEMORY_BASE, 0x0000 | bus->rangePFMem->start >> 16); - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_MEMORY_LIMIT, 0x0000 | bus->rangePFMem->end >> 16); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0x0000 | bus->rangePFMem->start >> 16); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000 | bus->rangePFMem->end >> 16); /* __________________________This is for debugging purposes only _______________________ - pci_read_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_MEMORY_BASE, &temp); + pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, &temp); debug ("pfmem_base = %x", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); - pci_read_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_MEMORY_LIMIT, &temp); + pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &temp); debug ("pfmem_limit = %x\n", (temp & PCI_MEMORY_RANGE_TYPE_MASK) << 16); ______________________________________________________________________________________*/ if (need_pfmem_upper) { /* since can't support n.e.ways */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_BASE_UPPER32, 0x00000000); - pci_write_config_dword_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_LIMIT_UPPER32, 0x00000000); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_BASE_UPPER32, 0x00000000); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, PCI_PREF_LIMIT_UPPER32, 0x00000000); } } else { - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_MEMORY_BASE, 0xffff); - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_PREF_MEMORY_LIMIT, 0x0000); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_BASE, 0xffff); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, 0x0000); } debug ("b4 writing control information\n"); - pci_read_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_INTERRUPT_PIN, &irq); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_PIN, &irq); if ((irq > 0x00) && (irq < 0x05)) - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_INTERRUPT_LINE, func->irq[irq - 1]); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_INTERRUPT_LINE, func->irq[irq - 1]); /* - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_BRIDGE_CONTROL, ctrl); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY); - pci_write_config_byte_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, ctrl); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_PARITY); + pci_bus_write_config_byte (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); */ - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_COMMAND, DEVICEENABLE); - pci_write_config_word_nodev (ibmphp_pci_root_ops, func->busno, device, function, PCI_BRIDGE_CONTROL, 0x07); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_COMMAND, DEVICEENABLE); + pci_bus_write_config_word (ibmphp_pci_bus, devfn, PCI_BRIDGE_CONTROL, 0x07); for (i = 0; i < 32; i++) { if (amount_needed->devices[i]) { debug ("device where devices[i] is 1 = %x\n", i); @@ -1087,6 +1091,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) u16 vendor_id; u8 hdr_type; u8 device, function; + unsigned int devfn; int howmany = 0; /*this is to see if there are any devices behind the bridge */ u32 bar[6], class; @@ -1106,20 +1111,23 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) return NULL; memset (amount, 0, sizeof (struct res_needed)); + ibmphp_pci_bus->number = busno; + debug ("the bus_no behind the bridge is %x\n", busno); debug ("scanning devices behind the bridge...\n"); for (device = 0; device < 32; device++) { amount->devices[device] = 0; for (function = 0; function < 8; function++) { + devfn = PCI_DEVFN(device, function); - pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_VENDOR_ID, &vendor_id); + pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); if (vendor_id != PCI_VENDOR_ID_NOTVALID) { /* found correct device!!! */ howmany++; - pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_HEADER_TYPE, &hdr_type); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_CLASS_REVISION, &class); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); debug ("hdr_type behind the bridge is %x\n", hdr_type); if (hdr_type & PCI_HEADER_TYPE_BRIDGE) { @@ -1146,14 +1154,14 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) for (count = 0; address[count]; count++) { /* for 6 BARs */ /* - pci_read_config_byte_nodev(ibmphp_pci_root_ops, busno, device, function, address[count], &tmp); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, address[count], &tmp); if (tmp & 0x01) // IO - pci_write_config_dword_nodev(ibmphp_pci_root_ops, busno, device, function, address[count], 0xFFFFFFFD); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFD); else // MEMORY - pci_write_config_dword_nodev(ibmphp_pci_root_ops, busno, device, function, address[count], 0xFFFFFFFF); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, address[count], 0xFFFFFFFF); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, address[count], &bar[count]); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &bar[count]); debug ("what is bar[count]? %x, count = %d\n", bar[count], count); @@ -1237,6 +1245,7 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) u32 temp_end; u32 size; u32 tmp_address; + unsigned int devfn; debug ("%s - enter\n", __FUNCTION__); @@ -1246,14 +1255,16 @@ static int unconfigure_boot_device (u8 busno, u8 device, u8 function) return -EINVAL; } + devfn = PCI_DEVFN(device, function); + ibmphp_pci_bus->number = busno; for (count = 0; address[count]; count++) { /* for 6 BARs */ - pci_read_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, address[count], &start_address); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &start_address); /* We can do this here, b/c by that time the device driver of the card has been stopped */ - pci_write_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, address[count], 0xFFFFFFFF); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, address[count], &size); - pci_write_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, address[count], start_address); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], 0xFFFFFFFF); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &size); + pci_bus_write_config_dword (ibmphp_pci_bus, devfn, address[count], start_address); debug ("start_address is %x\n", start_address); debug ("busno, device, function %x %x %x\n", busno, device, function); @@ -1350,13 +1361,16 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) PCI_BASE_ADDRESS_1, 0 }; + unsigned int devfn; + devfn = PCI_DEVFN(device, function); + ibmphp_pci_bus->number = busno; bus_no = (int) busno; debug ("busno is %x\n", busno); - pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_PRIMARY_BUS, &pri_number); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_PRIMARY_BUS, &pri_number); debug ("%s - busno = %x, primary_number = %x\n", __FUNCTION__, busno, pri_number); - pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_SECONDARY_BUS, &sec_number); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); debug ("sec_number is %x\n", sec_number); sec_no = (int) sec_number; pri_no = (int) pri_number; @@ -1365,10 +1379,10 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) return -EINVAL; } - pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_SECONDARY_BUS, &sec_number); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number); sec_no = (int) sec_no; - pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_SUBORDINATE_BUS, &sub_number); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SUBORDINATE_BUS, &sub_number); sub_no = (int) sub_number; debug ("sub_no is %d, sec_no is %d\n", sub_no, sec_no); if (sec_no != sub_number) { @@ -1388,7 +1402,7 @@ static int unconfigure_boot_bridge (u8 busno, u8 device, u8 function) for (count = 0; address[count]; count++) { /* for 2 BARs */ - pci_read_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, address[count], &start_address); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, address[count], &start_address); if (!start_address) { /* This BAR is not implemented */ @@ -1461,6 +1475,7 @@ static int unconfigure_boot_card (struct slot *slot_cur) u8 busno; u8 function; int rc; + unsigned int devfn; u8 valid_device = 0x00; /* To see if we are ever able to find valid device and read it */ debug ("%s - enter\n", __FUNCTION__); @@ -1471,8 +1486,10 @@ static int unconfigure_boot_card (struct slot *slot_cur) debug ("b4 for loop, device is %x\n", device); /* For every function on the card */ for (function = 0x0; function < 0x08; function++) { + devfn = PCI_DEVFN(device, function); + ibmphp_pci_bus->number = busno; - pci_read_config_word_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_VENDOR_ID, &vendor_id); + pci_bus_read_config_word (ibmphp_pci_bus, devfn, PCI_VENDOR_ID, &vendor_id); if (vendor_id != PCI_VENDOR_ID_NOTVALID) { /* found correct device!!! */ @@ -1485,8 +1502,8 @@ static int unconfigure_boot_card (struct slot *slot_cur) * |_=> 0 = single function device, 1 = multi-function device */ - pci_read_config_byte_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_HEADER_TYPE, &hdr_type); - pci_read_config_dword_nodev (ibmphp_pci_root_ops, busno, device, function, PCI_CLASS_REVISION, &class); + pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_HEADER_TYPE, &hdr_type); + pci_bus_read_config_dword (ibmphp_pci_bus, devfn, PCI_CLASS_REVISION, &class); debug ("hdr_type %x, class %x\n", hdr_type, class); class >>= 8; /* to take revision out, class = class.subclass.prog i/f */ diff --git a/drivers/hotplug/ibmphp_res.c b/drivers/hotplug/ibmphp_res.c index 305bbc178f0b..762ad60c71a7 100644 --- a/drivers/hotplug/ibmphp_res.c +++ b/drivers/hotplug/ibmphp_res.c @@ -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 -- cgit v1.2.3