diff options
Diffstat (limited to 'drivers/ide/setup-pci.c')
-rw-r--r-- | drivers/ide/setup-pci.c | 77 |
1 files changed, 15 insertions, 62 deletions
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 05db429a7da8..634e3f6a9608 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -339,7 +339,8 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
339 | * ide_hwif_configure - configure an IDE interface | 339 | * ide_hwif_configure - configure an IDE interface |
340 | * @dev: PCI device holding interface | 340 | * @dev: PCI device holding interface |
341 | * @d: IDE port info | 341 | * @d: IDE port info |
342 | * @mate: Paired interface if any | 342 | * @port: port number |
343 | * @irq: PCI IRQ | ||
343 | * | 344 | * |
344 | * Perform the initial set up for the hardware interface structure. This | 345 | * Perform the initial set up for the hardware interface structure. This |
345 | * is done per interface port rather than per PCI device. There may be | 346 | * is done per interface port rather than per PCI device. There may be |
@@ -348,7 +349,9 @@ static int ide_pci_check_iomem(struct pci_dev *dev, const struct ide_port_info * | |||
348 | * Returns the new hardware interface structure, or NULL on a failure | 349 | * Returns the new hardware interface structure, or NULL on a failure |
349 | */ | 350 | */ |
350 | 351 | ||
351 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *mate, int port, int irq) | 352 | static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, |
353 | const struct ide_port_info *d, | ||
354 | unsigned int port, int irq) | ||
352 | { | 355 | { |
353 | unsigned long ctl = 0, base = 0; | 356 | unsigned long ctl = 0, base = 0; |
354 | ide_hwif_t *hwif; | 357 | ide_hwif_t *hwif; |
@@ -394,29 +397,24 @@ static ide_hwif_t *ide_hwif_configure(struct pci_dev *dev, const struct ide_port | |||
394 | 397 | ||
395 | hwif->dev = &dev->dev; | 398 | hwif->dev = &dev->dev; |
396 | hwif->cds = d; | 399 | hwif->cds = d; |
397 | hwif->channel = port; | ||
398 | 400 | ||
399 | if (mate) { | ||
400 | hwif->mate = mate; | ||
401 | mate->mate = hwif; | ||
402 | } | ||
403 | return hwif; | 401 | return hwif; |
404 | } | 402 | } |
405 | 403 | ||
404 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | ||
406 | /** | 405 | /** |
407 | * ide_hwif_setup_dma - configure DMA interface | 406 | * ide_hwif_setup_dma - configure DMA interface |
408 | * @dev: PCI device | ||
409 | * @d: IDE port info | ||
410 | * @hwif: IDE interface | 407 | * @hwif: IDE interface |
408 | * @d: IDE port info | ||
411 | * | 409 | * |
412 | * 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 |
413 | * 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 |
414 | * state | 412 | * state |
415 | */ | 413 | */ |
416 | 414 | ||
417 | static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info *d, ide_hwif_t *hwif) | 415 | void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) |
418 | { | 416 | { |
419 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 417 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
420 | u16 pcicmd; | 418 | u16 pcicmd; |
421 | 419 | ||
422 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); | 420 | pci_read_config_word(dev, PCI_COMMAND, &pcicmd); |
@@ -448,8 +446,8 @@ static void ide_hwif_setup_dma(struct pci_dev *dev, const struct ide_port_info * | |||
448 | "(BIOS)\n", hwif->name, d->name); | 446 | "(BIOS)\n", hwif->name, d->name); |
449 | } | 447 | } |
450 | } | 448 | } |
451 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI*/ | ||
452 | } | 449 | } |
450 | #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ | ||
453 | 451 | ||
454 | /** | 452 | /** |
455 | * ide_setup_pci_controller - set up IDE PCI | 453 | * ide_setup_pci_controller - set up IDE PCI |
@@ -511,7 +509,7 @@ out: | |||
511 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) | 509 | void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int pciirq, u8 *idx) |
512 | { | 510 | { |
513 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; | 511 | int channels = (d->host_flags & IDE_HFLAG_SINGLE) ? 1 : 2, port; |
514 | ide_hwif_t *hwif, *mate = NULL; | 512 | ide_hwif_t *hwif; |
515 | u8 tmp; | 513 | u8 tmp; |
516 | 514 | ||
517 | /* | 515 | /* |
@@ -527,56 +525,11 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d, int | |||
527 | continue; /* port not enabled */ | 525 | continue; /* port not enabled */ |
528 | } | 526 | } |
529 | 527 | ||
530 | if ((hwif = ide_hwif_configure(dev, d, mate, port, pciirq)) == NULL) | 528 | hwif = ide_hwif_configure(dev, d, port, pciirq); |
529 | if (hwif == NULL) | ||
531 | continue; | 530 | continue; |
532 | 531 | ||
533 | *(idx + port) = hwif->index; | 532 | *(idx + port) = hwif->index; |
534 | |||
535 | if (d->init_iops) | ||
536 | d->init_iops(hwif); | ||
537 | |||
538 | if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) | ||
539 | ide_hwif_setup_dma(dev, d, hwif); | ||
540 | |||
541 | if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || | ||
542 | (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) | ||
543 | hwif->irq = port ? 15 : 14; | ||
544 | |||
545 | hwif->host_flags = d->host_flags; | ||
546 | hwif->pio_mask = d->pio_mask; | ||
547 | |||
548 | if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) | ||
549 | hwif->mate->serialized = hwif->serialized = 1; | ||
550 | |||
551 | if (d->host_flags & IDE_HFLAG_IO_32BIT) { | ||
552 | hwif->drives[0].io_32bit = 1; | ||
553 | hwif->drives[1].io_32bit = 1; | ||
554 | } | ||
555 | |||
556 | if (d->host_flags & IDE_HFLAG_UNMASK_IRQS) { | ||
557 | hwif->drives[0].unmask = 1; | ||
558 | hwif->drives[1].unmask = 1; | ||
559 | } | ||
560 | |||
561 | if (hwif->dma_base) { | ||
562 | hwif->swdma_mask = d->swdma_mask; | ||
563 | hwif->mwdma_mask = d->mwdma_mask; | ||
564 | hwif->ultra_mask = d->udma_mask; | ||
565 | } | ||
566 | |||
567 | hwif->drives[0].autotune = 1; | ||
568 | hwif->drives[1].autotune = 1; | ||
569 | |||
570 | if (d->host_flags & IDE_HFLAG_RQSIZE_256) | ||
571 | hwif->rqsize = 256; | ||
572 | |||
573 | if (d->init_hwif) | ||
574 | /* Call chipset-specific routine | ||
575 | * for each enabled hwif | ||
576 | */ | ||
577 | d->init_hwif(hwif); | ||
578 | |||
579 | mate = hwif; | ||
580 | } | 533 | } |
581 | } | 534 | } |
582 | 535 | ||
@@ -658,7 +611,7 @@ int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) | |||
658 | ret = do_ide_setup_pci_device(dev, d, &idx[0], 1); | 611 | ret = do_ide_setup_pci_device(dev, d, &idx[0], 1); |
659 | 612 | ||
660 | if (ret >= 0) | 613 | if (ret >= 0) |
661 | ide_device_add(idx); | 614 | ide_device_add(idx, d); |
662 | 615 | ||
663 | return ret; | 616 | return ret; |
664 | } | 617 | } |
@@ -682,7 +635,7 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, | |||
682 | goto out; | 635 | goto out; |
683 | } | 636 | } |
684 | 637 | ||
685 | ide_device_add(idx); | 638 | ide_device_add(idx, d); |
686 | out: | 639 | out: |
687 | return ret; | 640 | return ret; |
688 | } | 641 | } |