aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/setup-pci.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:31 -0500
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-02-02 13:56:31 -0500
commitc413b9b94d9a8e7548cc4b2e04b7df0439ce76fd (patch)
tree5d23110a0d1f87ad0c88fb1746194e532808eaab /drivers/ide/setup-pci.c
parent1ebf74936b1fccb5b65940f99ccddd74ec4d1fef (diff)
ide: add struct ide_port_info instances to legacy host drivers
* Remove 'struct pci_dev *dev' argument from ide_hwif_setup_dma(). * Un-static ide_hwif_setup_dma() and add CONFIG_BLK_DEV_IDEDMA_PCI=n version. * Add 'const struct ide_port_info *d' argument to ide_device_add[_all](). * Factor out generic ports init from ide_pci_setup_ports() to ide_init_port(), move it to ide-probe.c and call it in in ide_device_add_all() instead of ide_pci_setup_ports(). * Move ->mate setup to ide_device_add_all() from ide_port_init(). * Add IDE_HFLAG_NO_AUTOTUNE host flag for host drivers that don't enable ->autotune currently. * Setup hwif->chipset in ide_init_port() but iff pi->chipset is set (to not override setup done by ide_hwif_configure()). * Add ETRAX host handling to ide_device_add_all(). * cmd640.c: set IDE_HFLAG_ABUSE_* also for CONFIG_BLK_DEV_CMD640_ENHANCED=n. * pmac.c: make pmac_ide_setup_dma() return an error value and move DMA masks setup to pmac_ide_setup_device(). * Add 'struct ide_port_info' instances to legacy host drivers, pass them to ide_device_add() calls and then remove open-coded ports initialization. Reviewed-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r--drivers/ide/setup-pci.c81
1 files changed, 8 insertions, 73 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 53d9979edc72..634e3f6a9608 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -401,20 +401,20 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev,
401 return hwif; 401 return hwif;
402} 402}
403 403
404#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
404/** 405/**
405 * ide_hwif_setup_dma - configure DMA interface 406 * ide_hwif_setup_dma - configure DMA interface
406 * @dev: PCI device
407 * @d: IDE port info
408 * @hwif: IDE interface 407 * @hwif: IDE interface
408 * @d: IDE port info
409 * 409 *
410 * Set up the DMA base for the interface. Enable the master bits as 410 * Set up the DMA base for the interface. Enable the master bits as
411 * necessary and attempt to bring the device DMA into a ready to use 411 * necessary and attempt to bring the device DMA into a ready to use
412 * state 412 * state
413 */ 413 */
414 414
415static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *hwif) 415void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)
416{ 416{
417#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 417 struct pci_dev *dev = to_pci_dev(hwif->dev);
418 u16 pcicmd; 418 u16 pcicmd;
419 419
420 pci_read_config_word(dev, PCI_COMMAND, &pcicmd); 420 pci_read_config_word(dev, PCI_COMMAND, &pcicmd);
@@ -446,8 +446,8 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info *
446 "(BIOS)\n", hwif->name, d->name); 446 "(BIOS)\n", hwif->name, d->name);
447 } 447 }
448 } 448 }
449#endif /* CONFIG_BLK_DEV_IDEDMA_PCI*/
450} 449}
450#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
451 451
452/** 452/**
453 * ide_setup_pci_controller - set up IDE PCI 453 * ide_setup_pci_controller - set up IDE PCI
@@ -509,7 +509,7 @@ out:
509void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) 509void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx)
510{ 510{
511 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; 511 int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port;
512 ide_hwif_t *hwif, *mate = NULL; 512 ide_hwif_t *hwif;
513 u8 tmp; 513 u8 tmp;
514 514
515 /* 515 /*
@@ -531,71 +531,6 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int
531 531
532 *(idx + port) = hwif->index; 532 *(idx + port) = hwif->index;
533 } 533 }
534
535 for (port = 0; port < channels; ++port) {
536 if (*(idx + port) == 0xff)
537 continue;
538
539 hwif = &ide_hwifs[*(idx + port)];
540
541 if (mate) {
542 hwif->mate = mate;
543 mate->mate = hwif;
544 }
545
546 hwif->channel = port;
547
548 if (d->init_iops)
549 d->init_iops(hwif);
550
551 if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0)
552 ide_hwif_setup_dma(dev, d, hwif);
553
554 if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) ||
555 (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS))
556 hwif->irq = port ? 15 : 14;
557
558 hwif->host_flags = d->host_flags;
559 hwif->pio_mask = d->pio_mask;
560
561 if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate)
562 hwif->mate->serialized = hwif->serialized = 1;
563
564 if (d->host_flags & IDE_HFLAG_IO_32BIT) {
565 hwif->drives[0].io_32bit = 1;
566 hwif->drives[1].io_32bit = 1;
567 }
568
569 if (d->host_flags & IDE_HFLAG_UNMASK_IRQS) {
570 hwif->drives[0].unmask = 1;
571 hwif->drives[1].unmask = 1;
572 }
573
574 hwif->swdma_mask = d->swdma_mask;
575 hwif->mwdma_mask = d->mwdma_mask;
576 hwif->ultra_mask = d->udma_mask;
577
578 if ((d->host_flags && IDE_HFLAG_NO_DMA) == 0 &&
579 hwif->dma_base == 0) {
580 hwif->swdma_mask = 0;
581 hwif->mwdma_mask = 0;
582 hwif->ultra_mask = 0;
583 }
584
585 hwif->drives[0].autotune = 1;
586 hwif->drives[1].autotune = 1;
587
588 if (d->host_flags & IDE_HFLAG_RQSIZE_256)
589 hwif->rqsize = 256;
590
591 if (d->init_hwif)
592 /* Call chipset-specific routine
593 * for each enabled hwif
594 */
595 d->init_hwif(hwif);
596
597 mate = hwif;
598 }
599} 534}
600 535
601EXPORT_SYMBOL_GPL(ide_pci_setup_ports); 536EXPORT_SYMBOL_GPL(ide_pci_setup_ports);
@@ -676,7 +611,7 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d)
676 ret = do_ide_setup_pci_device(dev, d, &idx[0], 1); 611 ret = do_ide_setup_pci_device(dev, d, &idx[0], 1);
677 612
678 if (ret >= 0) 613 if (ret >= 0)
679 ide_device_add(idx); 614 ide_device_add(idx, d);
680 615
681 return ret; 616 return ret;
682} 617}
@@ -700,7 +635,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
700 goto out; 635 goto out;
701 } 636 }
702 637
703 ide_device_add(idx); 638 ide_device_add(idx, d);
704out: 639out:
705 return ret; 640 return ret;
706} 641}