aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/sata_inic162x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ata/sata_inic162x.c')
-rw-r--r--drivers/ata/sata_inic162x.c86
1 files changed, 34 insertions, 52 deletions
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index 1e21688bfcf2..f099a1d83a00 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -488,11 +488,11 @@ static void inic_error_handler(struct ata_port *ap)
488static void inic_post_internal_cmd(struct ata_queued_cmd *qc) 488static void inic_post_internal_cmd(struct ata_queued_cmd *qc)
489{ 489{
490 /* make DMA engine forget about the failed command */ 490 /* make DMA engine forget about the failed command */
491 if (qc->err_mask) 491 if (qc->flags & ATA_QCFLAG_FAILED)
492 inic_reset_port(inic_port_base(qc->ap)); 492 inic_reset_port(inic_port_base(qc->ap));
493} 493}
494 494
495static void inic_dev_config(struct ata_port *ap, struct ata_device *dev) 495static void inic_dev_config(struct ata_device *dev)
496{ 496{
497 /* inic can only handle upto LBA28 max sectors */ 497 /* inic can only handle upto LBA28 max sectors */
498 if (dev->max_sectors > ATA_MAX_SECTORS) 498 if (dev->max_sectors > ATA_MAX_SECTORS)
@@ -559,7 +559,6 @@ static struct ata_port_operations inic_port_ops = {
559 .bmdma_stop = inic_bmdma_stop, 559 .bmdma_stop = inic_bmdma_stop,
560 .bmdma_status = inic_bmdma_status, 560 .bmdma_status = inic_bmdma_status,
561 561
562 .irq_handler = inic_interrupt,
563 .irq_clear = inic_irq_clear, 562 .irq_clear = inic_irq_clear,
564 .irq_on = ata_irq_on, 563 .irq_on = ata_irq_on,
565 .irq_ack = ata_irq_ack, 564 .irq_ack = ata_irq_ack,
@@ -580,7 +579,6 @@ static struct ata_port_operations inic_port_ops = {
580}; 579};
581 580
582static struct ata_port_info inic_port_info = { 581static struct ata_port_info inic_port_info = {
583 .sht = &inic_sht,
584 /* For some reason, ATA_PROT_ATAPI is broken on this 582 /* For some reason, ATA_PROT_ATAPI is broken on this
585 * controller, and no, PIO_POLLING does't fix it. It somehow 583 * controller, and no, PIO_POLLING does't fix it. It somehow
586 * manages to report the wrong ireason and ignoring ireason 584 * manages to report the wrong ireason and ignoring ireason
@@ -642,7 +640,9 @@ static int inic_pci_device_resume(struct pci_dev *pdev)
642 void __iomem *mmio_base = host->iomap[MMIO_BAR]; 640 void __iomem *mmio_base = host->iomap[MMIO_BAR];
643 int rc; 641 int rc;
644 642
645 ata_pci_device_do_resume(pdev); 643 rc = ata_pci_device_do_resume(pdev);
644 if (rc)
645 return rc;
646 646
647 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { 647 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
648 rc = init_controller(mmio_base, hpriv->cached_hctl); 648 rc = init_controller(mmio_base, hpriv->cached_hctl);
@@ -659,8 +659,8 @@ static int inic_pci_device_resume(struct pci_dev *pdev)
659static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 659static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
660{ 660{
661 static int printed_version; 661 static int printed_version;
662 struct ata_port_info *pinfo = &inic_port_info; 662 const struct ata_port_info *ppi[] = { &inic_port_info, NULL };
663 struct ata_probe_ent *probe_ent; 663 struct ata_host *host;
664 struct inic_host_priv *hpriv; 664 struct inic_host_priv *hpriv;
665 void __iomem * const *iomap; 665 void __iomem * const *iomap;
666 int i, rc; 666 int i, rc;
@@ -668,6 +668,15 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
668 if (!printed_version++) 668 if (!printed_version++)
669 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n"); 669 dev_printk(KERN_DEBUG, &pdev->dev, "version " DRV_VERSION "\n");
670 670
671 /* alloc host */
672 host = ata_host_alloc_pinfo(&pdev->dev, ppi, NR_PORTS);
673 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
674 if (!host || !hpriv)
675 return -ENOMEM;
676
677 host->private_data = hpriv;
678
679 /* acquire resources and fill host */
671 rc = pcim_enable_device(pdev); 680 rc = pcim_enable_device(pdev);
672 if (rc) 681 if (rc)
673 return rc; 682 return rc;
@@ -675,7 +684,22 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
675 rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME); 684 rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME);
676 if (rc) 685 if (rc)
677 return rc; 686 return rc;
678 iomap = pcim_iomap_table(pdev); 687 host->iomap = iomap = pcim_iomap_table(pdev);
688
689 for (i = 0; i < NR_PORTS; i++) {
690 struct ata_ioports *port = &host->ports[i]->ioaddr;
691 void __iomem *port_base = iomap[MMIO_BAR] + i * PORT_SIZE;
692
693 port->cmd_addr = iomap[2 * i];
694 port->altstatus_addr =
695 port->ctl_addr = (void __iomem *)
696 ((unsigned long)iomap[2 * i + 1] | ATA_PCI_CTL_OFS);
697 port->scr_addr = port_base + PORT_SCR;
698
699 ata_std_ports(port);
700 }
701
702 hpriv->cached_hctl = readw(iomap[MMIO_BAR] + HOST_CTL);
679 703
680 /* Set dma_mask. This devices doesn't support 64bit addressing. */ 704 /* Set dma_mask. This devices doesn't support 64bit addressing. */
681 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 705 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
@@ -692,43 +716,6 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
692 return rc; 716 return rc;
693 } 717 }
694 718
695 probe_ent = devm_kzalloc(&pdev->dev, sizeof(*probe_ent), GFP_KERNEL);
696 hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
697 if (!probe_ent || !hpriv)
698 return -ENOMEM;
699
700 probe_ent->dev = &pdev->dev;
701 INIT_LIST_HEAD(&probe_ent->node);
702
703 probe_ent->sht = pinfo->sht;
704 probe_ent->port_flags = pinfo->flags;
705 probe_ent->pio_mask = pinfo->pio_mask;
706 probe_ent->mwdma_mask = pinfo->mwdma_mask;
707 probe_ent->udma_mask = pinfo->udma_mask;
708 probe_ent->port_ops = pinfo->port_ops;
709 probe_ent->n_ports = NR_PORTS;
710
711 probe_ent->irq = pdev->irq;
712 probe_ent->irq_flags = IRQF_SHARED;
713
714 probe_ent->iomap = iomap;
715
716 for (i = 0; i < NR_PORTS; i++) {
717 struct ata_ioports *port = &probe_ent->port[i];
718 void __iomem *port_base = iomap[MMIO_BAR] + i * PORT_SIZE;
719
720 port->cmd_addr = iomap[2 * i];
721 port->altstatus_addr =
722 port->ctl_addr = (void __iomem *)
723 ((unsigned long)iomap[2 * i + 1] | ATA_PCI_CTL_OFS);
724 port->scr_addr = port_base + PORT_SCR;
725
726 ata_std_ports(port);
727 }
728
729 probe_ent->private_data = hpriv;
730 hpriv->cached_hctl = readw(iomap[MMIO_BAR] + HOST_CTL);
731
732 rc = init_controller(iomap[MMIO_BAR], hpriv->cached_hctl); 719 rc = init_controller(iomap[MMIO_BAR], hpriv->cached_hctl);
733 if (rc) { 720 if (rc) {
734 dev_printk(KERN_ERR, &pdev->dev, 721 dev_printk(KERN_ERR, &pdev->dev,
@@ -737,13 +724,8 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
737 } 724 }
738 725
739 pci_set_master(pdev); 726 pci_set_master(pdev);
740 727 return ata_host_activate(host, pdev->irq, inic_interrupt, IRQF_SHARED,
741 if (!ata_device_add(probe_ent)) 728 &inic_sht);
742 return -ENODEV;
743
744 devm_kfree(&pdev->dev, probe_ent);
745
746 return 0;
747} 729}
748 730
749static const struct pci_device_id inic_pci_tbl[] = { 731static const struct pci_device_id inic_pci_tbl[] = {