diff options
Diffstat (limited to 'drivers/ide/pci/pdc202xx_new.c')
-rw-r--r-- | drivers/ide/pci/pdc202xx_new.c | 78 |
1 files changed, 46 insertions, 32 deletions
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index 070df8ab3b21..998615fa285f 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <asm/pci-bridge.h> | 31 | #include <asm/pci-bridge.h> |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #define DRV_NAME "pdc202xx_new" | ||
35 | |||
34 | #undef DEBUG | 36 | #undef DEBUG |
35 | 37 | ||
36 | #ifdef DEBUG | 38 | #ifdef DEBUG |
@@ -324,8 +326,9 @@ static void __devinit apple_kiwi_init(struct pci_dev *pdev) | |||
324 | } | 326 | } |
325 | #endif /* CONFIG_PPC_PMAC */ | 327 | #endif /* CONFIG_PPC_PMAC */ |
326 | 328 | ||
327 | static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const char *name) | 329 | static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev) |
328 | { | 330 | { |
331 | const char *name = DRV_NAME; | ||
329 | unsigned long dma_base = pci_resource_start(dev, 4); | 332 | unsigned long dma_base = pci_resource_start(dev, 4); |
330 | unsigned long sec_dma_base = dma_base + 0x08; | 333 | unsigned long sec_dma_base = dma_base + 0x08; |
331 | long pll_input, pll_output, ratio; | 334 | long pll_input, pll_output, ratio; |
@@ -358,12 +361,13 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha | |||
358 | * registers setting. | 361 | * registers setting. |
359 | */ | 362 | */ |
360 | pll_input = detect_pll_input_clock(dma_base); | 363 | pll_input = detect_pll_input_clock(dma_base); |
361 | printk("%s: PLL input clock is %ld kHz\n", name, pll_input / 1000); | 364 | printk(KERN_INFO "%s %s: PLL input clock is %ld kHz\n", |
365 | name, pci_name(dev), pll_input / 1000); | ||
362 | 366 | ||
363 | /* Sanity check */ | 367 | /* Sanity check */ |
364 | if (unlikely(pll_input < 5000000L || pll_input > 70000000L)) { | 368 | if (unlikely(pll_input < 5000000L || pll_input > 70000000L)) { |
365 | printk(KERN_ERR "%s: Bad PLL input clock %ld Hz, giving up!\n", | 369 | printk(KERN_ERR "%s %s: Bad PLL input clock %ld Hz, giving up!" |
366 | name, pll_input); | 370 | "\n", name, pci_name(dev), pll_input); |
367 | goto out; | 371 | goto out; |
368 | } | 372 | } |
369 | 373 | ||
@@ -399,7 +403,8 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha | |||
399 | r = 0x00; | 403 | r = 0x00; |
400 | } else { | 404 | } else { |
401 | /* Invalid ratio */ | 405 | /* Invalid ratio */ |
402 | printk(KERN_ERR "%s: Bad ratio %ld, giving up!\n", name, ratio); | 406 | printk(KERN_ERR "%s %s: Bad ratio %ld, giving up!\n", |
407 | name, pci_name(dev), ratio); | ||
403 | goto out; | 408 | goto out; |
404 | } | 409 | } |
405 | 410 | ||
@@ -409,7 +414,8 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha | |||
409 | 414 | ||
410 | if (unlikely(f < 0 || f > 127)) { | 415 | if (unlikely(f < 0 || f > 127)) { |
411 | /* Invalid F */ | 416 | /* Invalid F */ |
412 | printk(KERN_ERR "%s: F[%d] invalid!\n", name, f); | 417 | printk(KERN_ERR "%s %s: F[%d] invalid!\n", |
418 | name, pci_name(dev), f); | ||
413 | goto out; | 419 | goto out; |
414 | } | 420 | } |
415 | 421 | ||
@@ -455,8 +461,8 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) | |||
455 | 461 | ||
456 | if (dev2->irq != dev->irq) { | 462 | if (dev2->irq != dev->irq) { |
457 | dev2->irq = dev->irq; | 463 | dev2->irq = dev->irq; |
458 | printk(KERN_INFO "PDC20270: PCI config space " | 464 | printk(KERN_INFO DRV_NAME " %s: PCI config space " |
459 | "interrupt fixed\n"); | 465 | "interrupt fixed\n", pci_name(dev)); |
460 | } | 466 | } |
461 | 467 | ||
462 | return dev2; | 468 | return dev2; |
@@ -473,9 +479,9 @@ static const struct ide_port_ops pdcnew_port_ops = { | |||
473 | .cable_detect = pdcnew_cable_detect, | 479 | .cable_detect = pdcnew_cable_detect, |
474 | }; | 480 | }; |
475 | 481 | ||
476 | #define DECLARE_PDCNEW_DEV(name_str, udma) \ | 482 | #define DECLARE_PDCNEW_DEV(udma) \ |
477 | { \ | 483 | { \ |
478 | .name = name_str, \ | 484 | .name = DRV_NAME, \ |
479 | .init_chipset = init_chipset_pdcnew, \ | 485 | .init_chipset = init_chipset_pdcnew, \ |
480 | .port_ops = &pdcnew_port_ops, \ | 486 | .port_ops = &pdcnew_port_ops, \ |
481 | .host_flags = IDE_HFLAG_POST_SET_MODE | \ | 487 | .host_flags = IDE_HFLAG_POST_SET_MODE | \ |
@@ -487,13 +493,8 @@ static const struct ide_port_ops pdcnew_port_ops = { | |||
487 | } | 493 | } |
488 | 494 | ||
489 | static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { | 495 | static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { |
490 | /* 0 */ DECLARE_PDCNEW_DEV("PDC20268", ATA_UDMA5), | 496 | /* 0: PDC202{68,70} */ DECLARE_PDCNEW_DEV(ATA_UDMA5), |
491 | /* 1 */ DECLARE_PDCNEW_DEV("PDC20269", ATA_UDMA6), | 497 | /* 1: PDC202{69,71,75,76,77} */ DECLARE_PDCNEW_DEV(ATA_UDMA6), |
492 | /* 2 */ DECLARE_PDCNEW_DEV("PDC20270", ATA_UDMA5), | ||
493 | /* 3 */ DECLARE_PDCNEW_DEV("PDC20271", ATA_UDMA6), | ||
494 | /* 4 */ DECLARE_PDCNEW_DEV("PDC20275", ATA_UDMA6), | ||
495 | /* 5 */ DECLARE_PDCNEW_DEV("PDC20276", ATA_UDMA6), | ||
496 | /* 6 */ DECLARE_PDCNEW_DEV("PDC20277", ATA_UDMA6), | ||
497 | }; | 498 | }; |
498 | 499 | ||
499 | /** | 500 | /** |
@@ -507,13 +508,10 @@ static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { | |||
507 | 508 | ||
508 | static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id) | 509 | static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id) |
509 | { | 510 | { |
510 | const struct ide_port_info *d; | 511 | const struct ide_port_info *d = &pdcnew_chipsets[id->driver_data]; |
511 | struct pci_dev *bridge = dev->bus->self; | 512 | struct pci_dev *bridge = dev->bus->self; |
512 | u8 idx = id->driver_data; | ||
513 | |||
514 | d = &pdcnew_chipsets[idx]; | ||
515 | 513 | ||
516 | if (idx == 2 && bridge && | 514 | if (dev->device == PCI_DEVICE_ID_PROMISE_20270 && bridge && |
517 | bridge->vendor == PCI_VENDOR_ID_DEC && | 515 | bridge->vendor == PCI_VENDOR_ID_DEC && |
518 | bridge->device == PCI_DEVICE_ID_DEC_21150) { | 516 | bridge->device == PCI_DEVICE_ID_DEC_21150) { |
519 | struct pci_dev *dev2; | 517 | struct pci_dev *dev2; |
@@ -524,33 +522,42 @@ static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_de | |||
524 | dev2 = pdc20270_get_dev2(dev); | 522 | dev2 = pdc20270_get_dev2(dev); |
525 | 523 | ||
526 | if (dev2) { | 524 | if (dev2) { |
527 | int ret = ide_setup_pci_devices(dev, dev2, d); | 525 | int ret = ide_pci_init_two(dev, dev2, d, NULL); |
528 | if (ret < 0) | 526 | if (ret < 0) |
529 | pci_dev_put(dev2); | 527 | pci_dev_put(dev2); |
530 | return ret; | 528 | return ret; |
531 | } | 529 | } |
532 | } | 530 | } |
533 | 531 | ||
534 | if (idx == 5 && bridge && | 532 | if (dev->device == PCI_DEVICE_ID_PROMISE_20276 && bridge && |
535 | bridge->vendor == PCI_VENDOR_ID_INTEL && | 533 | bridge->vendor == PCI_VENDOR_ID_INTEL && |
536 | (bridge->device == PCI_DEVICE_ID_INTEL_I960 || | 534 | (bridge->device == PCI_DEVICE_ID_INTEL_I960 || |
537 | bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) { | 535 | bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) { |
538 | printk(KERN_INFO "PDC20276: attached to I2O RAID controller, " | 536 | printk(KERN_INFO DRV_NAME " %s: attached to I2O RAID controller," |
539 | "skipping\n"); | 537 | " skipping\n", pci_name(dev)); |
540 | return -ENODEV; | 538 | return -ENODEV; |
541 | } | 539 | } |
542 | 540 | ||
543 | return ide_setup_pci_device(dev, d); | 541 | return ide_pci_init_one(dev, d, NULL); |
542 | } | ||
543 | |||
544 | static void __devexit pdc202new_remove(struct pci_dev *dev) | ||
545 | { | ||
546 | struct ide_host *host = pci_get_drvdata(dev); | ||
547 | struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL; | ||
548 | |||
549 | ide_pci_remove(dev); | ||
550 | pci_dev_put(dev2); | ||
544 | } | 551 | } |
545 | 552 | ||
546 | static const struct pci_device_id pdc202new_pci_tbl[] = { | 553 | static const struct pci_device_id pdc202new_pci_tbl[] = { |
547 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20268), 0 }, | 554 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20268), 0 }, |
548 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20269), 1 }, | 555 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20269), 1 }, |
549 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20270), 2 }, | 556 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20270), 0 }, |
550 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20271), 3 }, | 557 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20271), 1 }, |
551 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20275), 4 }, | 558 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20275), 1 }, |
552 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20276), 5 }, | 559 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20276), 1 }, |
553 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20277), 6 }, | 560 | { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20277), 1 }, |
554 | { 0, }, | 561 | { 0, }, |
555 | }; | 562 | }; |
556 | MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl); | 563 | MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl); |
@@ -559,6 +566,7 @@ static struct pci_driver driver = { | |||
559 | .name = "Promise_IDE", | 566 | .name = "Promise_IDE", |
560 | .id_table = pdc202new_pci_tbl, | 567 | .id_table = pdc202new_pci_tbl, |
561 | .probe = pdc202new_init_one, | 568 | .probe = pdc202new_init_one, |
569 | .remove = pdc202new_remove, | ||
562 | }; | 570 | }; |
563 | 571 | ||
564 | static int __init pdc202new_ide_init(void) | 572 | static int __init pdc202new_ide_init(void) |
@@ -566,7 +574,13 @@ static int __init pdc202new_ide_init(void) | |||
566 | return ide_pci_register_driver(&driver); | 574 | return ide_pci_register_driver(&driver); |
567 | } | 575 | } |
568 | 576 | ||
577 | static void __exit pdc202new_ide_exit(void) | ||
578 | { | ||
579 | pci_unregister_driver(&driver); | ||
580 | } | ||
581 | |||
569 | module_init(pdc202new_ide_init); | 582 | module_init(pdc202new_ide_init); |
583 | module_exit(pdc202new_ide_exit); | ||
570 | 584 | ||
571 | MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); | 585 | MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); |
572 | MODULE_DESCRIPTION("PCI driver module for Promise PDC20268 and higher"); | 586 | MODULE_DESCRIPTION("PCI driver module for Promise PDC20268 and higher"); |