1 /* 2 * IBM Hot Plug Controller Driver 3 * 4 * Written By: Tong Yu, IBM Corporation 5 * 6 * Copyright (C) 2001,2003 Greg Kroah-Hartman ([email protected]) 7 * Copyright (C) 2001-2003 IBM Corp. 8 * 9 * All rights reserved. 10 * 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. 15 * 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 20 * details. 21 * 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. 25 * 26 * Send feedback to <[email protected]> 27 * 28 */ 29 30 #include <linux/module.h> 31 #include <linux/errno.h> 32 #include <linux/mm.h> 33 #include <linux/slab.h> 34 #include <linux/pci.h> 35 #include <linux/list.h> 36 #include <linux/init.h> 37 #include "ibmphp.h" 38 39 /* 40 * POST builds data blocks(in this data block definition, a char-1 41 * byte, short(or word)-2 byte, long(dword)-4 byte) in the Extended 42 * BIOS Data Area which describe the configuration of the hot-plug 43 * controllers and resources used by the PCI Hot-Plug devices. 44 * 45 * This file walks EBDA, maps data block from physical addr, 46 * reconstruct linked lists about all system resource(MEM, PFM, IO) 47 * already assigned by POST, as well as linked lists about hot plug 48 * controllers (ctlr#, slot#, bus&slot features...) 49 */ 50 51 /* Global lists */ 52 LIST_HEAD (ibmphp_ebda_pci_rsrc_head); 53 LIST_HEAD (ibmphp_slot_head); 54 55 /* Local variables */ 56 static struct ebda_hpc_list *hpc_list_ptr; 57 static struct ebda_rsrc_list *rsrc_list_ptr; 58 static struct rio_table_hdr *rio_table_ptr = NULL; 59 static LIST_HEAD (ebda_hpc_head); 60 static LIST_HEAD (bus_info_head); 61 static LIST_HEAD (rio_vg_head); 62 static LIST_HEAD (rio_lo_head); 63 static LIST_HEAD (opt_vg_head); 64 static LIST_HEAD (opt_lo_head); 65 static void __iomem *io_mem; 66 67 /* Local functions */ 68 static int ebda_rsrc_controller (void); 69 static int ebda_rsrc_rsrc (void); 70 static int ebda_rio_table (void); 71 72 static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void) 73 { 74 return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL); 75 } 76 77 static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count) 78 { 79 struct controller *controller; 80 struct ebda_hpc_slot *slots; 81 struct ebda_hpc_bus *buses; 82 83 controller = kzalloc(sizeof(struct controller), GFP_KERNEL); 84 if (!controller) 85 goto error; 86 87 slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL); 88 if (!slots) 89 goto error_contr; 90 controller->slots = slots; 91 92 buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL); 93 if (!buses) 94 goto error_slots; 95 controller->buses = buses; 96 97 return controller; 98 error_slots: 99 kfree(controller->slots); 100 error_contr: 101 kfree(controller); 102 error: 103 return NULL; 104 } 105 106 static void free_ebda_hpc (struct controller *controller) 107 { 108 kfree (controller->slots); 109 kfree (controller->buses); 110 kfree (controller); 111 } 112 113 static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void) 114 { 115 return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL); 116 } 117 118 static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void) 119 { 120 return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL); 121 } 122 123 static void __init print_bus_info (void) 124 { 125 struct bus_info *ptr; 126 127 list_for_each_entry(ptr, &bus_info_head, bus_info_list) { 128 debug ("%s - slot_min = %x\n", __func__, ptr->slot_min); 129 debug ("%s - slot_max = %x\n", __func__, ptr->slot_max); 130 debug ("%s - slot_count = %x\n", __func__, ptr->slot_count); 131 debug ("%s - bus# = %x\n", __func__, ptr->busno); 132 debug ("%s - current_speed = %x\n", __func__, ptr->current_speed); 133 debug ("%s - controller_id = %x\n", __func__, ptr->controller_id); 134 135 debug ("%s - slots_at_33_conv = %x\n", __func__, ptr->slots_at_33_conv); 136 debug ("%s - slots_at_66_conv = %x\n", __func__, ptr->slots_at_66_conv); 137 debug ("%s - slots_at_66_pcix = %x\n", __func__, ptr->slots_at_66_pcix); 138 debug ("%s - slots_at_100_pcix = %x\n", __func__, ptr->slots_at_100_pcix); 139 debug ("%s - slots_at_133_pcix = %x\n", __func__, ptr->slots_at_133_pcix); 140 141 } 142 } 143 144 static void print_lo_info (void) 145 { 146 struct rio_detail *ptr; 147 debug ("print_lo_info ----\n"); 148 list_for_each_entry(ptr, &rio_lo_head, rio_detail_list) { 149 debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); 150 debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); 151 debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); 152 debug ("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num); 153 debug ("%s - wpindex = %x\n", __func__, ptr->wpindex); 154 debug ("%s - chassis_num = %x\n", __func__, ptr->chassis_num); 155 156 } 157 } 158 159 static void print_vg_info (void) 160 { 161 struct rio_detail *ptr; 162 debug ("%s ---\n", __func__); 163 list_for_each_entry(ptr, &rio_vg_head, rio_detail_list) { 164 debug ("%s - rio_node_id = %x\n", __func__, ptr->rio_node_id); 165 debug ("%s - rio_type = %x\n", __func__, ptr->rio_type); 166 debug ("%s - owner_id = %x\n", __func__, ptr->owner_id); 167 debug ("%s - first_slot_num = %x\n", __func__, ptr->first_slot_num); 168 debug ("%s - wpindex = %x\n", __func__, ptr->wpindex); 169 debug ("%s - chassis_num = %x\n", __func__, ptr->chassis_num); 170 171 } 172 } 173 174 static void __init print_ebda_pci_rsrc (void) 175 { 176 struct ebda_pci_rsrc *ptr; 177 178 list_for_each_entry(ptr, &ibmphp_ebda_pci_rsrc_head, ebda_pci_rsrc_list) { 179 debug ("%s - rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", 180 __func__, ptr->rsrc_type ,ptr->bus_num, ptr->dev_fun,ptr->start_addr, ptr->end_addr); 181 } 182 } 183 184 static void __init print_ibm_slot (void) 185 { 186 struct slot *ptr; 187 188 list_for_each_entry(ptr, &ibmphp_slot_head, ibm_slot_list) { 189 debug ("%s - slot_number: %x\n", __func__, ptr->number); 190 } 191 } 192 193 static void __init print_opt_vg (void) 194 { 195 struct opt_rio *ptr; 196 debug ("%s ---\n", __func__); 197 list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { 198 debug ("%s - rio_type %x\n", __func__, ptr->rio_type); 199 debug ("%s - chassis_num: %x\n", __func__, ptr->chassis_num); 200 debug ("%s - first_slot_num: %x\n", __func__, ptr->first_slot_num); 201 debug ("%s - middle_num: %x\n", __func__, ptr->middle_num); 202 } 203 } 204 205 static void __init print_ebda_hpc (void) 206 { 207 struct controller *hpc_ptr; 208 u16 index; 209 210 list_for_each_entry(hpc_ptr, &ebda_hpc_head, ebda_hpc_list) { 211 for (index = 0; index < hpc_ptr->slot_count; index++) { 212 debug ("%s - physical slot#: %x\n", __func__, hpc_ptr->slots[index].slot_num); 213 debug ("%s - pci bus# of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_bus_num); 214 debug ("%s - index into ctlr addr: %x\n", __func__, hpc_ptr->slots[index].ctl_index); 215 debug ("%s - cap of the slot: %x\n", __func__, hpc_ptr->slots[index].slot_cap); 216 } 217 218 for (index = 0; index < hpc_ptr->bus_count; index++) { 219 debug ("%s - bus# of each bus controlled by this ctlr: %x\n", __func__, hpc_ptr->buses[index].bus_num); 220 } 221 222 debug ("%s - type of hpc: %x\n", __func__, hpc_ptr->ctlr_type); 223 switch (hpc_ptr->ctlr_type) { 224 case 1: 225 debug ("%s - bus: %x\n", __func__, hpc_ptr->u.pci_ctlr.bus); 226 debug ("%s - dev_fun: %x\n", __func__, hpc_ptr->u.pci_ctlr.dev_fun); 227 debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); 228 break; 229 230 case 0: 231 debug ("%s - io_start: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_start); 232 debug ("%s - io_end: %x\n", __func__, hpc_ptr->u.isa_ctlr.io_end); 233 debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); 234 break; 235 236 case 2: 237 case 4: 238 debug ("%s - wpegbbar: %lx\n", __func__, hpc_ptr->u.wpeg_ctlr.wpegbbar); 239 debug ("%s - i2c_addr: %x\n", __func__, hpc_ptr->u.wpeg_ctlr.i2c_addr); 240 debug ("%s - irq: %x\n", __func__, hpc_ptr->irq); 241 break; 242 } 243 } 244 } 245 246 int __init ibmphp_access_ebda (void) 247 { 248 u8 format, num_ctlrs, rio_complete, hs_complete; 249 u16 ebda_seg, num_entries, next_offset, offset, blk_id, sub_addr, re, rc_id, re_id, base; 250 int rc = 0; 251 252 253 rio_complete = 0; 254 hs_complete = 0; 255 256 io_mem = ioremap ((0x40 << 4) + 0x0e, 2); 257 if (!io_mem ) 258 return -ENOMEM; 259 ebda_seg = readw (io_mem); 260 iounmap (io_mem); 261 debug ("returned ebda segment: %x\n", ebda_seg); 262 263 io_mem = ioremap(ebda_seg<<4, 1024); 264 if (!io_mem ) 265 return -ENOMEM; 266 next_offset = 0x180; 267 268 for (;;) { 269 offset = next_offset; 270 next_offset = readw (io_mem + offset); /* offset of next blk */ 271 272 offset += 2; 273 if (next_offset == 0) /* 0 indicate it's last blk */ 274 break; 275 blk_id = readw (io_mem + offset); /* this blk id */ 276 277 offset += 2; 278 /* check if it is hot swap block or rio block */ 279 if (blk_id != 0x4853 && blk_id != 0x4752) 280 continue; 281 /* found hs table */ 282 if (blk_id == 0x4853) { 283 debug ("now enter hot swap block---\n"); 284 debug ("hot blk id: %x\n", blk_id); 285 format = readb (io_mem + offset); 286 287 offset += 1; 288 if (format != 4) 289 goto error_nodev; 290 debug ("hot blk format: %x\n", format); 291 /* hot swap sub blk */ 292 base = offset; 293 294 sub_addr = base; 295 re = readw (io_mem + sub_addr); /* next sub blk */ 296 297 sub_addr += 2; 298 rc_id = readw (io_mem + sub_addr); /* sub blk id */ 299 300 sub_addr += 2; 301 if (rc_id != 0x5243) 302 goto error_nodev; 303 /* rc sub blk signature */ 304 num_ctlrs = readb (io_mem + sub_addr); 305 306 sub_addr += 1; 307 hpc_list_ptr = alloc_ebda_hpc_list (); 308 if (!hpc_list_ptr) { 309 rc = -ENOMEM; 310 goto out; 311 } 312 hpc_list_ptr->format = format; 313 hpc_list_ptr->num_ctlrs = num_ctlrs; 314 hpc_list_ptr->phys_addr = sub_addr; /* offset of RSRC_CONTROLLER blk */ 315 debug ("info about hpc descriptor---\n"); 316 debug ("hot blk format: %x\n", format); 317 debug ("num of controller: %x\n", num_ctlrs); 318 debug ("offset of hpc data structure enteries: %x\n ", sub_addr); 319 320 sub_addr = base + re; /* re sub blk */ 321 /* FIXME: rc is never used/checked */ 322 rc = readw (io_mem + sub_addr); /* next sub blk */ 323 324 sub_addr += 2; 325 re_id = readw (io_mem + sub_addr); /* sub blk id */ 326 327 sub_addr += 2; 328 if (re_id != 0x5245) 329 goto error_nodev; 330 331 /* signature of re */ 332 num_entries = readw (io_mem + sub_addr); 333 334 sub_addr += 2; /* offset of RSRC_ENTRIES blk */ 335 rsrc_list_ptr = alloc_ebda_rsrc_list (); 336 if (!rsrc_list_ptr ) { 337 rc = -ENOMEM; 338 goto out; 339 } 340 rsrc_list_ptr->format = format; 341 rsrc_list_ptr->num_entries = num_entries; 342 rsrc_list_ptr->phys_addr = sub_addr; 343 344 debug ("info about rsrc descriptor---\n"); 345 debug ("format: %x\n", format); 346 debug ("num of rsrc: %x\n", num_entries); 347 debug ("offset of rsrc data structure enteries: %x\n ", sub_addr); 348 349 hs_complete = 1; 350 } else { 351 /* found rio table, blk_id == 0x4752 */ 352 debug ("now enter io table ---\n"); 353 debug ("rio blk id: %x\n", blk_id); 354 355 rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL); 356 if (!rio_table_ptr) 357 return -ENOMEM; 358 rio_table_ptr->ver_num = readb (io_mem + offset); 359 rio_table_ptr->scal_count = readb (io_mem + offset + 1); 360 rio_table_ptr->riodev_count = readb (io_mem + offset + 2); 361 rio_table_ptr->offset = offset +3 ; 362 363 debug("info about rio table hdr ---\n"); 364 debug("ver_num: %x\nscal_count: %x\nriodev_count: %x\noffset of rio table: %x\n ", 365 rio_table_ptr->ver_num, rio_table_ptr->scal_count, 366 rio_table_ptr->riodev_count, rio_table_ptr->offset); 367 368 rio_complete = 1; 369 } 370 } 371 372 if (!hs_complete && !rio_complete) 373 goto error_nodev; 374 375 if (rio_table_ptr) { 376 if (rio_complete && rio_table_ptr->ver_num == 3) { 377 rc = ebda_rio_table (); 378 if (rc) 379 goto out; 380 } 381 } 382 rc = ebda_rsrc_controller (); 383 if (rc) 384 goto out; 385 386 rc = ebda_rsrc_rsrc (); 387 goto out; 388 error_nodev: 389 rc = -ENODEV; 390 out: 391 iounmap (io_mem); 392 return rc; 393 } 394 395 /* 396 * map info of scalability details and rio details from physical address 397 */ 398 static int __init ebda_rio_table (void) 399 { 400 u16 offset; 401 u8 i; 402 struct rio_detail *rio_detail_ptr; 403 404 offset = rio_table_ptr->offset; 405 offset += 12 * rio_table_ptr->scal_count; 406 407 // we do concern about rio details 408 for (i = 0; i < rio_table_ptr->riodev_count; i++) { 409 rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL); 410 if (!rio_detail_ptr) 411 return -ENOMEM; 412 rio_detail_ptr->rio_node_id = readb (io_mem + offset); 413 rio_detail_ptr->bbar = readl (io_mem + offset + 1); 414 rio_detail_ptr->rio_type = readb (io_mem + offset + 5); 415 rio_detail_ptr->owner_id = readb (io_mem + offset + 6); 416 rio_detail_ptr->port0_node_connect = readb (io_mem + offset + 7); 417 rio_detail_ptr->port0_port_connect = readb (io_mem + offset + 8); 418 rio_detail_ptr->port1_node_connect = readb (io_mem + offset + 9); 419 rio_detail_ptr->port1_port_connect = readb (io_mem + offset + 10); 420 rio_detail_ptr->first_slot_num = readb (io_mem + offset + 11); 421 rio_detail_ptr->status = readb (io_mem + offset + 12); 422 rio_detail_ptr->wpindex = readb (io_mem + offset + 13); 423 rio_detail_ptr->chassis_num = readb (io_mem + offset + 14); 424 // debug ("rio_node_id: %x\nbbar: %x\nrio_type: %x\nowner_id: %x\nport0_node: %x\nport0_port: %x\nport1_node: %x\nport1_port: %x\nfirst_slot_num: %x\nstatus: %x\n", rio_detail_ptr->rio_node_id, rio_detail_ptr->bbar, rio_detail_ptr->rio_type, rio_detail_ptr->owner_id, rio_detail_ptr->port0_node_connect, rio_detail_ptr->port0_port_connect, rio_detail_ptr->port1_node_connect, rio_detail_ptr->port1_port_connect, rio_detail_ptr->first_slot_num, rio_detail_ptr->status); 425 //create linked list of chassis 426 if (rio_detail_ptr->rio_type == 4 || rio_detail_ptr->rio_type == 5) 427 list_add (&rio_detail_ptr->rio_detail_list, &rio_vg_head); 428 //create linked list of expansion box 429 else if (rio_detail_ptr->rio_type == 6 || rio_detail_ptr->rio_type == 7) 430 list_add (&rio_detail_ptr->rio_detail_list, &rio_lo_head); 431 else 432 // not in my concern 433 kfree (rio_detail_ptr); 434 offset += 15; 435 } 436 print_lo_info (); 437 print_vg_info (); 438 return 0; 439 } 440 441 /* 442 * reorganizing linked list of chassis 443 */ 444 static struct opt_rio *search_opt_vg (u8 chassis_num) 445 { 446 struct opt_rio *ptr; 447 list_for_each_entry(ptr, &opt_vg_head, opt_rio_list) { 448 if (ptr->chassis_num == chassis_num) 449 return ptr; 450 } 451 return NULL; 452 } 453 454 static int __init combine_wpg_for_chassis (void) 455 { 456 struct opt_rio *opt_rio_ptr = NULL; 457 struct rio_detail *rio_detail_ptr = NULL; 458 459 list_for_each_entry(rio_detail_ptr, &rio_vg_head, rio_detail_list) { 460 opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num); 461 if (!opt_rio_ptr) { 462 opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL); 463 if (!opt_rio_ptr) 464 return -ENOMEM; 465 opt_rio_ptr->rio_type = rio_detail_ptr->rio_type; 466 opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num; 467 opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num; 468 opt_rio_ptr->middle_num = rio_detail_ptr->first_slot_num; 469 list_add (&opt_rio_ptr->opt_rio_list, &opt_vg_head); 470 } else { 471 opt_rio_ptr->first_slot_num = min (opt_rio_ptr->first_slot_num, rio_detail_ptr->first_slot_num); 472 opt_rio_ptr->middle_num = max (opt_rio_ptr->middle_num, rio_detail_ptr->first_slot_num); 473 } 474 } 475 print_opt_vg (); 476 return 0; 477 } 478 479 /* 480 * reorganizing linked list of expansion box 481 */ 482 static struct opt_rio_lo *search_opt_lo (u8 chassis_num) 483 { 484 struct opt_rio_lo *ptr; 485 list_for_each_entry(ptr, &opt_lo_head, opt_rio_lo_list) { 486 if (ptr->chassis_num == chassis_num) 487 return ptr; 488 } 489 return NULL; 490 } 491 492 static int combine_wpg_for_expansion (void) 493 { 494 struct opt_rio_lo *opt_rio_lo_ptr = NULL; 495 struct rio_detail *rio_detail_ptr = NULL; 496 497 list_for_each_entry(rio_detail_ptr, &rio_lo_head, rio_detail_list) { 498 opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num); 499 if (!opt_rio_lo_ptr) { 500 opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL); 501 if (!opt_rio_lo_ptr) 502 return -ENOMEM; 503 opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type; 504 opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num; 505 opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num; 506 opt_rio_lo_ptr->middle_num = rio_detail_ptr->first_slot_num; 507 opt_rio_lo_ptr->pack_count = 1; 508 509 list_add (&opt_rio_lo_ptr->opt_rio_lo_list, &opt_lo_head); 510 } else { 511 opt_rio_lo_ptr->first_slot_num = min (opt_rio_lo_ptr->first_slot_num, rio_detail_ptr->first_slot_num); 512 opt_rio_lo_ptr->middle_num = max (opt_rio_lo_ptr->middle_num, rio_detail_ptr->first_slot_num); 513 opt_rio_lo_ptr->pack_count = 2; 514 } 515 } 516 return 0; 517 } 518 519 520 /* Since we don't know the max slot number per each chassis, hence go 521 * through the list of all chassis to find out the range 522 * Arguments: slot_num, 1st slot number of the chassis we think we are on, 523 * var (0 = chassis, 1 = expansion box) 524 */ 525 static int first_slot_num (u8 slot_num, u8 first_slot, u8 var) 526 { 527 struct opt_rio *opt_vg_ptr = NULL; 528 struct opt_rio_lo *opt_lo_ptr = NULL; 529 int rc = 0; 530 531 if (!var) { 532 list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) { 533 if ((first_slot < opt_vg_ptr->first_slot_num) && (slot_num >= opt_vg_ptr->first_slot_num)) { 534 rc = -ENODEV; 535 break; 536 } 537 } 538 } else { 539 list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) { 540 if ((first_slot < opt_lo_ptr->first_slot_num) && (slot_num >= opt_lo_ptr->first_slot_num)) { 541 rc = -ENODEV; 542 break; 543 } 544 } 545 } 546 return rc; 547 } 548 549 static struct opt_rio_lo * find_rxe_num (u8 slot_num) 550 { 551 struct opt_rio_lo *opt_lo_ptr; 552 553 list_for_each_entry(opt_lo_ptr, &opt_lo_head, opt_rio_lo_list) { 554 //check to see if this slot_num belongs to expansion box 555 if ((slot_num >= opt_lo_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_lo_ptr->first_slot_num, 1))) 556 return opt_lo_ptr; 557 } 558 return NULL; 559 } 560 561 static struct opt_rio * find_chassis_num (u8 slot_num) 562 { 563 struct opt_rio *opt_vg_ptr; 564 565 list_for_each_entry(opt_vg_ptr, &opt_vg_head, opt_rio_list) { 566 //check to see if this slot_num belongs to chassis 567 if ((slot_num >= opt_vg_ptr->first_slot_num) && (!first_slot_num (slot_num, opt_vg_ptr->first_slot_num, 0))) 568 return opt_vg_ptr; 569 } 570 return NULL; 571 } 572 573 /* This routine will find out how many slots are in the chassis, so that 574 * the slot numbers for rxe100 would start from 1, and not from 7, or 6 etc 575 */ 576 static u8 calculate_first_slot (u8 slot_num) 577 { 578 u8 first_slot = 1; 579 struct slot * slot_cur; 580 581 list_for_each_entry(slot_cur, &ibmphp_slot_head, ibm_slot_list) { 582 if (slot_cur->ctrl) { 583 if ((slot_cur->ctrl->ctlr_type != 4) && (slot_cur->ctrl->ending_slot_num > first_slot) && (slot_num > slot_cur->ctrl->ending_slot_num)) 584 first_slot = slot_cur->ctrl->ending_slot_num; 585 } 586 } 587 return first_slot + 1; 588 589 } 590 static char *create_file_name (struct slot * slot_cur) 591 { 592 struct opt_rio *opt_vg_ptr = NULL; 593 struct opt_rio_lo *opt_lo_ptr = NULL; 594 static char str[30]; 595 int which = 0; /* rxe = 1, chassis = 0 */ 596 u8 number = 1; /* either chassis or rxe # */ 597 u8 first_slot = 1; 598 u8 slot_num; 599 u8 flag = 0; 600 601 if (!slot_cur) { 602 err ("Structure passed is empty\n"); 603 return NULL; 604 } 605 606 slot_num = slot_cur->number; 607 608 memset (str, 0, sizeof(str)); 609 610 if (rio_table_ptr) { 611 if (rio_table_ptr->ver_num == 3) { 612 opt_vg_ptr = find_chassis_num (slot_num); 613 opt_lo_ptr = find_rxe_num (slot_num); 614 } 615 } 616 if (opt_vg_ptr) { 617 if (opt_lo_ptr) { 618 if ((slot_num - opt_vg_ptr->first_slot_num) > (slot_num - opt_lo_ptr->first_slot_num)) { 619 number = opt_lo_ptr->chassis_num; 620 first_slot = opt_lo_ptr->first_slot_num; 621 which = 1; /* it is RXE */ 622 } else { 623 first_slot = opt_vg_ptr->first_slot_num; 624 number = opt_vg_ptr->chassis_num; 625 which = 0; 626 } 627 } else { 628 first_slot = opt_vg_ptr->first_slot_num; 629 number = opt_vg_ptr->chassis_num; 630 which = 0; 631 } 632 ++flag; 633 } else if (opt_lo_ptr) { 634 number = opt_lo_ptr->chassis_num; 635 first_slot = opt_lo_ptr->first_slot_num; 636 which = 1; 637 ++flag; 638 } else if (rio_table_ptr) { 639 if (rio_table_ptr->ver_num == 3) { 640 /* if both NULL and we DO have correct RIO table in BIOS */ 641 return NULL; 642 } 643 } 644 if (!flag) { 645 if (slot_cur->ctrl->ctlr_type == 4) { 646 first_slot = calculate_first_slot (slot_num); 647 which = 1; 648 } else { 649 which = 0; 650 } 651 } 652 653 sprintf(str, "%s%dslot%d", 654 which == 0 ? "chassis" : "rxe", 655 number, slot_num - first_slot + 1); 656 return str; 657 } 658 659 static int fillslotinfo(struct hotplug_slot *hotplug_slot) 660 { 661 struct slot *slot; 662 int rc = 0; 663 664 if (!hotplug_slot || !hotplug_slot->private) 665 return -EINVAL; 666 667 slot = hotplug_slot->private; 668 rc = ibmphp_hpc_readslot(slot, READ_ALLSTAT, NULL); 669 if (rc) 670 return rc; 671 672 // power - enabled:1 not:0 673 hotplug_slot->info->power_status = SLOT_POWER(slot->status); 674 675 // attention - off:0, on:1, blinking:2 676 hotplug_slot->info->attention_status = SLOT_ATTN(slot->status, slot->ext_status); 677 678 // latch - open:1 closed:0 679 hotplug_slot->info->latch_status = SLOT_LATCH(slot->status); 680 681 // pci board - present:1 not:0 682 if (SLOT_PRESENT (slot->status)) 683 hotplug_slot->info->adapter_status = 1; 684 else 685 hotplug_slot->info->adapter_status = 0; 686 /* 687 if (slot->bus_on->supported_bus_mode 688 && (slot->bus_on->supported_speed == BUS_SPEED_66)) 689 hotplug_slot->info->max_bus_speed_status = BUS_SPEED_66PCIX; 690 else 691 hotplug_slot->info->max_bus_speed_status = slot->bus_on->supported_speed; 692 */ 693 694 return rc; 695 } 696 697 static void release_slot(struct hotplug_slot *hotplug_slot) 698 { 699 struct slot *slot; 700 701 if (!hotplug_slot || !hotplug_slot->private) 702 return; 703 704 slot = hotplug_slot->private; 705 kfree(slot->hotplug_slot->info); 706 kfree(slot->hotplug_slot->name); 707 kfree(slot->hotplug_slot); 708 slot->ctrl = NULL; 709 slot->bus_on = NULL; 710 711 /* we don't want to actually remove the resources, since free_resources will do just that */ 712 ibmphp_unconfigure_card(&slot, -1); 713 714 kfree (slot); 715 } 716 717 static struct pci_driver ibmphp_driver; 718 719 /* 720 * map info (ctlr-id, slot count, slot#.. bus count, bus#, ctlr type...) of 721 * each hpc from physical address to a list of hot plug controllers based on 722 * hpc descriptors. 723 */ 724 static int __init ebda_rsrc_controller (void) 725 { 726 u16 addr, addr_slot, addr_bus; 727 u8 ctlr_id, temp, bus_index; 728 u16 ctlr, slot, bus; 729 u16 slot_num, bus_num, index; 730 struct hotplug_slot *hp_slot_ptr; 731 struct controller *hpc_ptr; 732 struct ebda_hpc_bus *bus_ptr; 733 struct ebda_hpc_slot *slot_ptr; 734 struct bus_info *bus_info_ptr1, *bus_info_ptr2; 735 int rc; 736 struct slot *tmp_slot; 737 738 addr = hpc_list_ptr->phys_addr; 739 for (ctlr = 0; ctlr < hpc_list_ptr->num_ctlrs; ctlr++) { 740 bus_index = 1; 741 ctlr_id = readb (io_mem + addr); 742 addr += 1; 743 slot_num = readb (io_mem + addr); 744 745 addr += 1; 746 addr_slot = addr; /* offset of slot structure */ 747 addr += (slot_num * 4); 748 749 bus_num = readb (io_mem + addr); 750 751 addr += 1; 752 addr_bus = addr; /* offset of bus */ 753 addr += (bus_num * 9); /* offset of ctlr_type */ 754 temp = readb (io_mem + addr); 755 756 addr += 1; 757 /* init hpc structure */ 758 hpc_ptr = alloc_ebda_hpc (slot_num, bus_num); 759 if (!hpc_ptr ) { 760 rc = -ENOMEM; 761 goto error_no_hpc; 762 } 763 hpc_ptr->ctlr_id = ctlr_id; 764 hpc_ptr->ctlr_relative_id = ctlr; 765 hpc_ptr->slot_count = slot_num; 766 hpc_ptr->bus_count = bus_num; 767 debug ("now enter ctlr data struture ---\n"); 768 debug ("ctlr id: %x\n", ctlr_id); 769 debug ("ctlr_relative_id: %x\n", hpc_ptr->ctlr_relative_id); 770 debug ("count of slots controlled by this ctlr: %x\n", slot_num); 771 debug ("count of buses controlled by this ctlr: %x\n", bus_num); 772 773 /* init slot structure, fetch slot, bus, cap... */ 774 slot_ptr = hpc_ptr->slots; 775 for (slot = 0; slot < slot_num; slot++) { 776 slot_ptr->slot_num = readb (io_mem + addr_slot); 777 slot_ptr->slot_bus_num = readb (io_mem + addr_slot + slot_num); 778 slot_ptr->ctl_index = readb (io_mem + addr_slot + 2*slot_num); 779 slot_ptr->slot_cap = readb (io_mem + addr_slot + 3*slot_num); 780 781 // create bus_info lined list --- if only one slot per bus: slot_min = slot_max 782 783 bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num); 784 if (!bus_info_ptr2) { 785 bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL); 786 if (!bus_info_ptr1) { 787 rc = -ENOMEM; 788 goto error_no_hp_slot; 789 } 790 bus_info_ptr1->slot_min = slot_ptr->slot_num; 791 bus_info_ptr1->slot_max = slot_ptr->slot_num; 792 bus_info_ptr1->slot_count += 1; 793 bus_info_ptr1->busno = slot_ptr->slot_bus_num; 794 bus_info_ptr1->index = bus_index++; 795 bus_info_ptr1->current_speed = 0xff; 796 bus_info_ptr1->current_bus_mode = 0xff; 797 798 bus_info_ptr1->controller_id = hpc_ptr->ctlr_id; 799 800 list_add_tail (&bus_info_ptr1->bus_info_list, &bus_info_head); 801 802 } else { 803 bus_info_ptr2->slot_min = min (bus_info_ptr2->slot_min, slot_ptr->slot_num); 804 bus_info_ptr2->slot_max = max (bus_info_ptr2->slot_max, slot_ptr->slot_num); 805 bus_info_ptr2->slot_count += 1; 806 807 } 808 809 // end of creating the bus_info linked list 810 811 slot_ptr++; 812 addr_slot += 1; 813 } 814 815 /* init bus structure */ 816 bus_ptr = hpc_ptr->buses; 817 for (bus = 0; bus < bus_num; bus++) { 818 bus_ptr->bus_num = readb (io_mem + addr_bus + bus); 819 bus_ptr->slots_at_33_conv = readb (io_mem + addr_bus + bus_num + 8 * bus); 820 bus_ptr->slots_at_66_conv = readb (io_mem + addr_bus + bus_num + 8 * bus + 1); 821 822 bus_ptr->slots_at_66_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 2); 823 824 bus_ptr->slots_at_100_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 3); 825 826 bus_ptr->slots_at_133_pcix = readb (io_mem + addr_bus + bus_num + 8 * bus + 4); 827 828 bus_info_ptr2 = ibmphp_find_same_bus_num (bus_ptr->bus_num); 829 if (bus_info_ptr2) { 830 bus_info_ptr2->slots_at_33_conv = bus_ptr->slots_at_33_conv; 831 bus_info_ptr2->slots_at_66_conv = bus_ptr->slots_at_66_conv; 832 bus_info_ptr2->slots_at_66_pcix = bus_ptr->slots_at_66_pcix; 833 bus_info_ptr2->slots_at_100_pcix = bus_ptr->slots_at_100_pcix; 834 bus_info_ptr2->slots_at_133_pcix = bus_ptr->slots_at_133_pcix; 835 } 836 bus_ptr++; 837 } 838 839 hpc_ptr->ctlr_type = temp; 840 841 switch (hpc_ptr->ctlr_type) { 842 case 1: 843 hpc_ptr->u.pci_ctlr.bus = readb (io_mem + addr); 844 hpc_ptr->u.pci_ctlr.dev_fun = readb (io_mem + addr + 1); 845 hpc_ptr->irq = readb (io_mem + addr + 2); 846 addr += 3; 847 debug ("ctrl bus = %x, ctlr devfun = %x, irq = %x\n", 848 hpc_ptr->u.pci_ctlr.bus, 849 hpc_ptr->u.pci_ctlr.dev_fun, hpc_ptr->irq); 850 break; 851 852 case 0: 853 hpc_ptr->u.isa_ctlr.io_start = readw (io_mem + addr); 854 hpc_ptr->u.isa_ctlr.io_end = readw (io_mem + addr + 2); 855 if (!request_region (hpc_ptr->u.isa_ctlr.io_start, 856 (hpc_ptr->u.isa_ctlr.io_end - hpc_ptr->u.isa_ctlr.io_start + 1), 857 "ibmphp")) { 858 rc = -ENODEV; 859 goto error_no_hp_slot; 860 } 861 hpc_ptr->irq = readb (io_mem + addr + 4); 862 addr += 5; 863 break; 864 865 case 2: 866 case 4: 867 hpc_ptr->u.wpeg_ctlr.wpegbbar = readl (io_mem + addr); 868 hpc_ptr->u.wpeg_ctlr.i2c_addr = readb (io_mem + addr + 4); 869 hpc_ptr->irq = readb (io_mem + addr + 5); 870 addr += 6; 871 break; 872 default: 873 rc = -ENODEV; 874 goto error_no_hp_slot; 875 } 876 877 //reorganize chassis' linked list 878 combine_wpg_for_chassis (); 879 combine_wpg_for_expansion (); 880 hpc_ptr->revision = 0xff; 881 hpc_ptr->options = 0xff; 882 hpc_ptr->starting_slot_num = hpc_ptr->slots[0].slot_num; 883 hpc_ptr->ending_slot_num = hpc_ptr->slots[slot_num-1].slot_num; 884 885 // register slots with hpc core as well as create linked list of ibm slot 886 for (index = 0; index < hpc_ptr->slot_count; index++) { 887 888 hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL); 889 if (!hp_slot_ptr) { 890 rc = -ENOMEM; 891 goto error_no_hp_slot; 892 } 893 894 hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL); 895 if (!hp_slot_ptr->info) { 896 rc = -ENOMEM; 897 goto error_no_hp_info; 898 } 899 900 hp_slot_ptr->name = kmalloc(30, GFP_KERNEL); 901 if (!hp_slot_ptr->name) { 902 rc = -ENOMEM; 903 goto error_no_hp_name; 904 } 905 906 tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL); 907 if (!tmp_slot) { 908 rc = -ENOMEM; 909 goto error_no_slot; 910 } 911 912 tmp_slot->flag = 1; 913 914 tmp_slot->capabilities = hpc_ptr->slots[index].slot_cap; 915 if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_133_MAX) == EBDA_SLOT_133_MAX) 916 tmp_slot->supported_speed = 3; 917 else if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_100_MAX) == EBDA_SLOT_100_MAX) 918 tmp_slot->supported_speed = 2; 919 else if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_66_MAX) == EBDA_SLOT_66_MAX) 920 tmp_slot->supported_speed = 1; 921 922 if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_PCIX_CAP) == EBDA_SLOT_PCIX_CAP) 923 tmp_slot->supported_bus_mode = 1; 924 else 925 tmp_slot->supported_bus_mode = 0; 926 927 928 tmp_slot->bus = hpc_ptr->slots[index].slot_bus_num; 929 930 bus_info_ptr1 = ibmphp_find_same_bus_num (hpc_ptr->slots[index].slot_bus_num); 931 if (!bus_info_ptr1) { 932 kfree(tmp_slot); 933 rc = -ENODEV; 934 goto error; 935 } 936 tmp_slot->bus_on = bus_info_ptr1; 937 bus_info_ptr1 = NULL; 938 tmp_slot->ctrl = hpc_ptr; 939 940 tmp_slot->ctlr_index = hpc_ptr->slots[index].ctl_index; 941 tmp_slot->number = hpc_ptr->slots[index].slot_num; 942 tmp_slot->hotplug_slot = hp_slot_ptr; 943 944 hp_slot_ptr->private = tmp_slot; 945 hp_slot_ptr->release = release_slot; 946 947 rc = fillslotinfo(hp_slot_ptr); 948 if (rc) 949 goto error; 950 951 rc = ibmphp_init_devno ((struct slot **) &hp_slot_ptr->private); 952 if (rc) 953 goto error; 954 hp_slot_ptr->ops = &ibmphp_hotplug_slot_ops; 955 956 // end of registering ibm slot with hotplug core 957 958 list_add (& ((struct slot *)(hp_slot_ptr->private))->ibm_slot_list, &ibmphp_slot_head); 959 } 960 961 print_bus_info (); 962 list_add (&hpc_ptr->ebda_hpc_list, &ebda_hpc_head ); 963 964 } /* each hpc */ 965 966 list_for_each_entry(tmp_slot, &ibmphp_slot_head, ibm_slot_list) { 967 snprintf (tmp_slot->hotplug_slot->name, 30, "%s", create_file_name (tmp_slot)); 968 pci_hp_register(tmp_slot->hotplug_slot, 969 pci_find_bus(0, tmp_slot->bus), tmp_slot->device); 970 } 971 972 print_ebda_hpc (); 973 print_ibm_slot (); 974 return 0; 975 976 error: 977 kfree (hp_slot_ptr->private); 978 error_no_slot: 979 kfree (hp_slot_ptr->name); 980 error_no_hp_name: 981 kfree (hp_slot_ptr->info); 982 error_no_hp_info: 983 kfree (hp_slot_ptr); 984 error_no_hp_slot: 985 free_ebda_hpc (hpc_ptr); 986 error_no_hpc: 987 iounmap (io_mem); 988 return rc; 989 } 990 991 /* 992 * map info (bus, devfun, start addr, end addr..) of i/o, memory, 993 * pfm from the physical addr to a list of resource. 994 */ 995 static int __init ebda_rsrc_rsrc (void) 996 { 997 u16 addr; 998 short rsrc; 999 u8 type, rsrc_type; 1000 struct ebda_pci_rsrc *rsrc_ptr; 1001 1002 addr = rsrc_list_ptr->phys_addr; 1003 debug ("now entering rsrc land\n"); 1004 debug ("offset of rsrc: %x\n", rsrc_list_ptr->phys_addr); 1005 1006 for (rsrc = 0; rsrc < rsrc_list_ptr->num_entries; rsrc++) { 1007 type = readb (io_mem + addr); 1008 1009 addr += 1; 1010 rsrc_type = type & EBDA_RSRC_TYPE_MASK; 1011 1012 if (rsrc_type == EBDA_IO_RSRC_TYPE) { 1013 rsrc_ptr = alloc_ebda_pci_rsrc (); 1014 if (!rsrc_ptr) { 1015 iounmap (io_mem); 1016 return -ENOMEM; 1017 } 1018 rsrc_ptr->rsrc_type = type; 1019 1020 rsrc_ptr->bus_num = readb (io_mem + addr); 1021 rsrc_ptr->dev_fun = readb (io_mem + addr + 1); 1022 rsrc_ptr->start_addr = readw (io_mem + addr + 2); 1023 rsrc_ptr->end_addr = readw (io_mem + addr + 4); 1024 addr += 6; 1025 1026 debug ("rsrc from io type ----\n"); 1027 debug ("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", 1028 rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr); 1029 1030 list_add (&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head); 1031 } 1032 1033 if (rsrc_type == EBDA_MEM_RSRC_TYPE || rsrc_type == EBDA_PFM_RSRC_TYPE) { 1034 rsrc_ptr = alloc_ebda_pci_rsrc (); 1035 if (!rsrc_ptr ) { 1036 iounmap (io_mem); 1037 return -ENOMEM; 1038 } 1039 rsrc_ptr->rsrc_type = type; 1040 1041 rsrc_ptr->bus_num = readb (io_mem + addr); 1042 rsrc_ptr->dev_fun = readb (io_mem + addr + 1); 1043 rsrc_ptr->start_addr = readl (io_mem + addr + 2); 1044 rsrc_ptr->end_addr = readl (io_mem + addr + 6); 1045 addr += 10; 1046 1047 debug ("rsrc from mem or pfm ---\n"); 1048 debug ("rsrc type: %x bus#: %x dev_func: %x start addr: %x end addr: %x\n", 1049 rsrc_ptr->rsrc_type, rsrc_ptr->bus_num, rsrc_ptr->dev_fun, rsrc_ptr->start_addr, rsrc_ptr->end_addr); 1050 1051 list_add (&rsrc_ptr->ebda_pci_rsrc_list, &ibmphp_ebda_pci_rsrc_head); 1052 } 1053 } 1054 kfree (rsrc_list_ptr); 1055 rsrc_list_ptr = NULL; 1056 print_ebda_pci_rsrc (); 1057 return 0; 1058 } 1059 1060 u16 ibmphp_get_total_controllers (void) 1061 { 1062 return hpc_list_ptr->num_ctlrs; 1063 } 1064 1065 struct slot *ibmphp_get_slot_from_physical_num (u8 physical_num) 1066 { 1067 struct slot *slot; 1068 1069 list_for_each_entry(slot, &ibmphp_slot_head, ibm_slot_list) { 1070 if (slot->number == physical_num) 1071 return slot; 1072 } 1073 return NULL; 1074 } 1075 1076 /* To find: 1077 * - the smallest slot number 1078 * - the largest slot number 1079 * - the total number of the slots based on each bus 1080 * (if only one slot per bus slot_min = slot_max ) 1081 */ 1082 struct bus_info *ibmphp_find_same_bus_num (u32 num) 1083 { 1084 struct bus_info *ptr; 1085 1086 list_for_each_entry(ptr, &bus_info_head, bus_info_list) { 1087 if (ptr->busno == num) 1088 return ptr; 1089 } 1090 return NULL; 1091 } 1092 1093 /* Finding relative bus number, in order to map corresponding 1094 * bus register 1095 */ 1096 int ibmphp_get_bus_index (u8 num) 1097 { 1098 struct bus_info *ptr; 1099 1100 list_for_each_entry(ptr, &bus_info_head, bus_info_list) { 1101 if (ptr->busno == num) 1102 return ptr->index; 1103 } 1104 return -ENODEV; 1105 } 1106 1107 void ibmphp_free_bus_info_queue (void) 1108 { 1109 struct bus_info *bus_info; 1110 struct list_head *list; 1111 struct list_head *next; 1112 1113 list_for_each_safe (list, next, &bus_info_head ) { 1114 bus_info = list_entry (list, struct bus_info, bus_info_list); 1115 kfree (bus_info); 1116 } 1117 } 1118 1119 void ibmphp_free_ebda_hpc_queue (void) 1120 { 1121 struct controller *controller = NULL; 1122 struct list_head *list; 1123 struct list_head *next; 1124 int pci_flag = 0; 1125 1126 list_for_each_safe (list, next, &ebda_hpc_head) { 1127 controller = list_entry (list, struct controller, ebda_hpc_list); 1128 if (controller->ctlr_type == 0) 1129 release_region (controller->u.isa_ctlr.io_start, (controller->u.isa_ctlr.io_end - controller->u.isa_ctlr.io_start + 1)); 1130 else if ((controller->ctlr_type == 1) && (!pci_flag)) { 1131 ++pci_flag; 1132 pci_unregister_driver (&ibmphp_driver); 1133 } 1134 free_ebda_hpc (controller); 1135 } 1136 } 1137 1138 void ibmphp_free_ebda_pci_rsrc_queue (void) 1139 { 1140 struct ebda_pci_rsrc *resource; 1141 struct list_head *list; 1142 struct list_head *next; 1143 1144 list_for_each_safe (list, next, &ibmphp_ebda_pci_rsrc_head) { 1145 resource = list_entry (list, struct ebda_pci_rsrc, ebda_pci_rsrc_list); 1146 kfree (resource); 1147 resource = NULL; 1148 } 1149 } 1150 1151 static struct pci_device_id id_table[] = { 1152 { 1153 .vendor = PCI_VENDOR_ID_IBM, 1154 .device = HPC_DEVICE_ID, 1155 .subvendor = PCI_VENDOR_ID_IBM, 1156 .subdevice = HPC_SUBSYSTEM_ID, 1157 .class = ((PCI_CLASS_SYSTEM_PCI_HOTPLUG << 8) | 0x00), 1158 }, {} 1159 }; 1160 1161 MODULE_DEVICE_TABLE(pci, id_table); 1162 1163 static int ibmphp_probe (struct pci_dev *, const struct pci_device_id *); 1164 static struct pci_driver ibmphp_driver = { 1165 .name = "ibmphp", 1166 .id_table = id_table, 1167 .probe = ibmphp_probe, 1168 }; 1169 1170 int ibmphp_register_pci (void) 1171 { 1172 struct controller *ctrl; 1173 int rc = 0; 1174 1175 list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) { 1176 if (ctrl->ctlr_type == 1) { 1177 rc = pci_register_driver(&ibmphp_driver); 1178 break; 1179 } 1180 } 1181 return rc; 1182 } 1183 static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids) 1184 { 1185 struct controller *ctrl; 1186 1187 debug ("inside ibmphp_probe\n"); 1188 1189 list_for_each_entry(ctrl, &ebda_hpc_head, ebda_hpc_list) { 1190 if (ctrl->ctlr_type == 1) { 1191 if ((dev->devfn == ctrl->u.pci_ctlr.dev_fun) && (dev->bus->number == ctrl->u.pci_ctlr.bus)) { 1192 ctrl->ctrl_dev = dev; 1193 debug ("found device!!!\n"); 1194 debug ("dev->device = %x, dev->subsystem_device = %x\n", dev->device, dev->subsystem_device); 1195 return 0; 1196 } 1197 } 1198 } 1199 return -ENODEV; 1200 } 1201 1202