diff options
-rw-r--r-- | drivers/ide/pci/scc_pata.c | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index 085c1b58a99c..1a560dc1eac1 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
@@ -523,6 +523,43 @@ static int setup_mmio_scc (struct pci_dev *dev, const char *name) | |||
523 | return -ENOMEM; | 523 | return -ENOMEM; |
524 | } | 524 | } |
525 | 525 | ||
526 | static int scc_ide_setup_pci_device(struct pci_dev *dev, | ||
527 | const struct ide_port_info *d) | ||
528 | { | ||
529 | struct scc_ports *ports = pci_get_drvdata(dev); | ||
530 | ide_hwif_t *hwif = NULL; | ||
531 | hw_regs_t hw; | ||
532 | u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; | ||
533 | int i; | ||
534 | |||
535 | for (i = 0; i < MAX_HWIFS; i++) { | ||
536 | hwif = &ide_hwifs[i]; | ||
537 | if (hwif->chipset == ide_unknown) | ||
538 | break; /* pick an unused entry */ | ||
539 | } | ||
540 | if (i == MAX_HWIFS) { | ||
541 | printk(KERN_ERR "%s: too many IDE interfaces, " | ||
542 | "no room in table\n", SCC_PATA_NAME); | ||
543 | return -ENOMEM; | ||
544 | } | ||
545 | |||
546 | memset(&hw, 0, sizeof(hw)); | ||
547 | for (i = IDE_DATA_OFFSET; i <= IDE_CONTROL_OFFSET; i++) | ||
548 | hw.io_ports[i] = ports->dma + 0x20 + i * 4; | ||
549 | hw.irq = dev->irq; | ||
550 | hw.dev = &dev->dev; | ||
551 | hw.chipset = ide_pci; | ||
552 | ide_init_port_hw(hwif, &hw); | ||
553 | hwif->dev = &dev->dev; | ||
554 | hwif->cds = d; | ||
555 | |||
556 | idx[0] = hwif->index; | ||
557 | |||
558 | ide_device_add(idx, d); | ||
559 | |||
560 | return 0; | ||
561 | } | ||
562 | |||
526 | /** | 563 | /** |
527 | * init_setup_scc - set up an SCC PATA Controller | 564 | * init_setup_scc - set up an SCC PATA Controller |
528 | * @dev: PCI device | 565 | * @dev: PCI device |
@@ -545,10 +582,13 @@ static int __devinit init_setup_scc(struct pci_dev *dev, | |||
545 | struct scc_ports *ports; | 582 | struct scc_ports *ports; |
546 | int rc; | 583 | int rc; |
547 | 584 | ||
585 | rc = pci_enable_device(dev); | ||
586 | if (rc) | ||
587 | goto end; | ||
588 | |||
548 | rc = setup_mmio_scc(dev, d->name); | 589 | rc = setup_mmio_scc(dev, d->name); |
549 | if (rc < 0) { | 590 | if (rc < 0) |
550 | return rc; | 591 | goto end; |
551 | } | ||
552 | 592 | ||
553 | ports = pci_get_drvdata(dev); | 593 | ports = pci_get_drvdata(dev); |
554 | ctl_base = ports->ctl; | 594 | ctl_base = ports->ctl; |
@@ -583,7 +623,10 @@ static int __devinit init_setup_scc(struct pci_dev *dev, | |||
583 | out_be32((void*)mode_port, MODE_JCUSFEN); | 623 | out_be32((void*)mode_port, MODE_JCUSFEN); |
584 | out_be32((void*)intmask_port, INTMASK_MSK); | 624 | out_be32((void*)intmask_port, INTMASK_MSK); |
585 | 625 | ||
586 | return ide_setup_pci_device(dev, d); | 626 | rc = scc_ide_setup_pci_device(dev, d); |
627 | |||
628 | end: | ||
629 | return rc; | ||
587 | } | 630 | } |
588 | 631 | ||
589 | /** | 632 | /** |
@@ -610,17 +653,6 @@ static void __devinit init_mmio_iops_scc(ide_hwif_t *hwif) | |||
610 | hwif->OUTSW = scc_ide_outsw; | 653 | hwif->OUTSW = scc_ide_outsw; |
611 | hwif->OUTSL = scc_ide_outsl; | 654 | hwif->OUTSL = scc_ide_outsl; |
612 | 655 | ||
613 | hwif->io_ports[IDE_DATA_OFFSET] = dma_base + 0x20; | ||
614 | hwif->io_ports[IDE_ERROR_OFFSET] = dma_base + 0x24; | ||
615 | hwif->io_ports[IDE_NSECTOR_OFFSET] = dma_base + 0x28; | ||
616 | hwif->io_ports[IDE_SECTOR_OFFSET] = dma_base + 0x2c; | ||
617 | hwif->io_ports[IDE_LCYL_OFFSET] = dma_base + 0x30; | ||
618 | hwif->io_ports[IDE_HCYL_OFFSET] = dma_base + 0x34; | ||
619 | hwif->io_ports[IDE_SELECT_OFFSET] = dma_base + 0x38; | ||
620 | hwif->io_ports[IDE_STATUS_OFFSET] = dma_base + 0x3c; | ||
621 | hwif->io_ports[IDE_CONTROL_OFFSET] = dma_base + 0x40; | ||
622 | |||
623 | hwif->irq = dev->irq; | ||
624 | hwif->dma_base = dma_base; | 656 | hwif->dma_base = dma_base; |
625 | hwif->config_data = ports->ctl; | 657 | hwif->config_data = ports->ctl; |
626 | hwif->mmio = 1; | 658 | hwif->mmio = 1; |