diff options
Diffstat (limited to 'drivers/ata/sata_promise.c')
-rw-r--r-- | drivers/ata/sata_promise.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c index e09c609d4961..4fb47cad8229 100644 --- a/drivers/ata/sata_promise.c +++ b/drivers/ata/sata_promise.c | |||
@@ -50,6 +50,8 @@ | |||
50 | 50 | ||
51 | 51 | ||
52 | enum { | 52 | enum { |
53 | PDC_MMIO_BAR = 3, | ||
54 | |||
53 | /* register offsets */ | 55 | /* register offsets */ |
54 | PDC_FEATURE = 0x04, /* Feature/Error reg (per port) */ | 56 | PDC_FEATURE = 0x04, /* Feature/Error reg (per port) */ |
55 | PDC_SECTOR_COUNT = 0x08, /* Sector count reg (per port) */ | 57 | PDC_SECTOR_COUNT = 0x08, /* Sector count reg (per port) */ |
@@ -167,7 +169,7 @@ static const struct ata_port_operations pdc_sata_ops = { | |||
167 | .thaw = pdc_thaw, | 169 | .thaw = pdc_thaw, |
168 | .error_handler = pdc_error_handler, | 170 | .error_handler = pdc_error_handler, |
169 | .post_internal_cmd = pdc_post_internal_cmd, | 171 | .post_internal_cmd = pdc_post_internal_cmd, |
170 | .data_xfer = ata_mmio_data_xfer, | 172 | .data_xfer = ata_data_xfer, |
171 | .irq_handler = pdc_interrupt, | 173 | .irq_handler = pdc_interrupt, |
172 | .irq_clear = pdc_irq_clear, | 174 | .irq_clear = pdc_irq_clear, |
173 | 175 | ||
@@ -192,7 +194,7 @@ static const struct ata_port_operations pdc_old_sata_ops = { | |||
192 | .thaw = pdc_thaw, | 194 | .thaw = pdc_thaw, |
193 | .error_handler = pdc_error_handler, | 195 | .error_handler = pdc_error_handler, |
194 | .post_internal_cmd = pdc_post_internal_cmd, | 196 | .post_internal_cmd = pdc_post_internal_cmd, |
195 | .data_xfer = ata_mmio_data_xfer, | 197 | .data_xfer = ata_data_xfer, |
196 | .irq_handler = pdc_interrupt, | 198 | .irq_handler = pdc_interrupt, |
197 | .irq_clear = pdc_irq_clear, | 199 | .irq_clear = pdc_irq_clear, |
198 | 200 | ||
@@ -214,7 +216,7 @@ static const struct ata_port_operations pdc_pata_ops = { | |||
214 | 216 | ||
215 | .qc_prep = pdc_qc_prep, | 217 | .qc_prep = pdc_qc_prep, |
216 | .qc_issue = pdc_qc_issue_prot, | 218 | .qc_issue = pdc_qc_issue_prot, |
217 | .data_xfer = ata_mmio_data_xfer, | 219 | .data_xfer = ata_data_xfer, |
218 | .eng_timeout = pdc_eng_timeout, | 220 | .eng_timeout = pdc_eng_timeout, |
219 | .irq_handler = pdc_interrupt, | 221 | .irq_handler = pdc_interrupt, |
220 | .irq_clear = pdc_irq_clear, | 222 | .irq_clear = pdc_irq_clear, |
@@ -348,7 +350,7 @@ static int pdc_port_start(struct ata_port *ap) | |||
348 | 350 | ||
349 | static void pdc_reset_port(struct ata_port *ap) | 351 | static void pdc_reset_port(struct ata_port *ap) |
350 | { | 352 | { |
351 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_CTLSTAT; | 353 | void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_CTLSTAT; |
352 | unsigned int i; | 354 | unsigned int i; |
353 | u32 tmp; | 355 | u32 tmp; |
354 | 356 | ||
@@ -394,7 +396,7 @@ static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg) | |||
394 | { | 396 | { |
395 | if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) | 397 | if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) |
396 | return 0xffffffffU; | 398 | return 0xffffffffU; |
397 | return readl((void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); | 399 | return readl(ap->ioaddr.scr_addr + (sc_reg * 4)); |
398 | } | 400 | } |
399 | 401 | ||
400 | 402 | ||
@@ -403,7 +405,7 @@ static void pdc_sata_scr_write (struct ata_port *ap, unsigned int sc_reg, | |||
403 | { | 405 | { |
404 | if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) | 406 | if (sc_reg > SCR_CONTROL || ap->cbl != ATA_CBL_SATA) |
405 | return; | 407 | return; |
406 | writel(val, (void __iomem *) ap->ioaddr.scr_addr + (sc_reg * 4)); | 408 | writel(val, ap->ioaddr.scr_addr + (sc_reg * 4)); |
407 | } | 409 | } |
408 | 410 | ||
409 | static void pdc_atapi_pkt(struct ata_queued_cmd *qc) | 411 | static void pdc_atapi_pkt(struct ata_queued_cmd *qc) |
@@ -627,7 +629,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap, | |||
627 | { | 629 | { |
628 | unsigned int handled = 0; | 630 | unsigned int handled = 0; |
629 | u32 tmp; | 631 | u32 tmp; |
630 | void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; | 632 | void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; |
631 | 633 | ||
632 | tmp = readl(mmio); | 634 | tmp = readl(mmio); |
633 | if (tmp & PDC_ERR_MASK) { | 635 | if (tmp & PDC_ERR_MASK) { |
@@ -656,7 +658,7 @@ static inline unsigned int pdc_host_intr( struct ata_port *ap, | |||
656 | static void pdc_irq_clear(struct ata_port *ap) | 658 | static void pdc_irq_clear(struct ata_port *ap) |
657 | { | 659 | { |
658 | struct ata_host *host = ap->host; | 660 | struct ata_host *host = ap->host; |
659 | void __iomem *mmio = host->mmio_base; | 661 | void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; |
660 | 662 | ||
661 | readl(mmio + PDC_INT_SEQMASK); | 663 | readl(mmio + PDC_INT_SEQMASK); |
662 | } | 664 | } |
@@ -672,12 +674,12 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance) | |||
672 | 674 | ||
673 | VPRINTK("ENTER\n"); | 675 | VPRINTK("ENTER\n"); |
674 | 676 | ||
675 | if (!host || !host->mmio_base) { | 677 | if (!host || !host->iomap[PDC_MMIO_BAR]) { |
676 | VPRINTK("QUICK EXIT\n"); | 678 | VPRINTK("QUICK EXIT\n"); |
677 | return IRQ_NONE; | 679 | return IRQ_NONE; |
678 | } | 680 | } |
679 | 681 | ||
680 | mmio_base = host->mmio_base; | 682 | mmio_base = host->iomap[PDC_MMIO_BAR]; |
681 | 683 | ||
682 | /* reading should also clear interrupts */ | 684 | /* reading should also clear interrupts */ |
683 | mask = readl(mmio_base + PDC_INT_SEQMASK); | 685 | mask = readl(mmio_base + PDC_INT_SEQMASK); |
@@ -722,18 +724,19 @@ static inline void pdc_packet_start(struct ata_queued_cmd *qc) | |||
722 | { | 724 | { |
723 | struct ata_port *ap = qc->ap; | 725 | struct ata_port *ap = qc->ap; |
724 | struct pdc_port_priv *pp = ap->private_data; | 726 | struct pdc_port_priv *pp = ap->private_data; |
727 | void __iomem *mmio = ap->host->iomap[PDC_MMIO_BAR]; | ||
725 | unsigned int port_no = ap->port_no; | 728 | unsigned int port_no = ap->port_no; |
726 | u8 seq = (u8) (port_no + 1); | 729 | u8 seq = (u8) (port_no + 1); |
727 | 730 | ||
728 | VPRINTK("ENTER, ap %p\n", ap); | 731 | VPRINTK("ENTER, ap %p\n", ap); |
729 | 732 | ||
730 | writel(0x00000001, ap->host->mmio_base + (seq * 4)); | 733 | writel(0x00000001, mmio + (seq * 4)); |
731 | readl(ap->host->mmio_base + (seq * 4)); /* flush */ | 734 | readl(mmio + (seq * 4)); /* flush */ |
732 | 735 | ||
733 | pp->pkt[2] = seq; | 736 | pp->pkt[2] = seq; |
734 | wmb(); /* flush PRD, pkt writes */ | 737 | wmb(); /* flush PRD, pkt writes */ |
735 | writel(pp->pkt_dma, (void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); | 738 | writel(pp->pkt_dma, ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); |
736 | readl((void __iomem *) ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ | 739 | readl(ap->ioaddr.cmd_addr + PDC_PKT_SUBMIT); /* flush */ |
737 | } | 740 | } |
738 | 741 | ||
739 | static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) | 742 | static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc) |
@@ -808,7 +811,7 @@ static int pdc_old_check_atapi_dma(struct ata_queued_cmd *qc) | |||
808 | return pdc_check_atapi_dma(qc); | 811 | return pdc_check_atapi_dma(qc); |
809 | } | 812 | } |
810 | 813 | ||
811 | static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base) | 814 | static void pdc_ata_setup_port(struct ata_ioports *port, void __iomem *base) |
812 | { | 815 | { |
813 | port->cmd_addr = base; | 816 | port->cmd_addr = base; |
814 | port->data_addr = base; | 817 | port->data_addr = base; |
@@ -828,7 +831,7 @@ static void pdc_ata_setup_port(struct ata_ioports *port, unsigned long base) | |||
828 | 831 | ||
829 | static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) | 832 | static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe) |
830 | { | 833 | { |
831 | void __iomem *mmio = pe->mmio_base; | 834 | void __iomem *mmio = pe->iomap[PDC_MMIO_BAR]; |
832 | struct pdc_host_priv *hp = pe->private_data; | 835 | struct pdc_host_priv *hp = pe->private_data; |
833 | int hotplug_offset; | 836 | int hotplug_offset; |
834 | u32 tmp; | 837 | u32 tmp; |
@@ -884,8 +887,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
884 | static int printed_version; | 887 | static int printed_version; |
885 | struct ata_probe_ent *probe_ent; | 888 | struct ata_probe_ent *probe_ent; |
886 | struct pdc_host_priv *hp; | 889 | struct pdc_host_priv *hp; |
887 | unsigned long base; | 890 | void __iomem *base; |
888 | void __iomem *mmio_base; | ||
889 | unsigned int board_idx = (unsigned int) ent->driver_data; | 891 | unsigned int board_idx = (unsigned int) ent->driver_data; |
890 | int rc; | 892 | int rc; |
891 | u8 tmp; | 893 | u8 tmp; |
@@ -897,11 +899,11 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
897 | if (rc) | 899 | if (rc) |
898 | return rc; | 900 | return rc; |
899 | 901 | ||
900 | rc = pci_request_regions(pdev, DRV_NAME); | 902 | rc = pcim_iomap_regions(pdev, 1 << PDC_MMIO_BAR, DRV_NAME); |
901 | if (rc) { | 903 | if (rc == -EBUSY) |
902 | pcim_pin_device(pdev); | 904 | pcim_pin_device(pdev); |
905 | if (rc) | ||
903 | return rc; | 906 | return rc; |
904 | } | ||
905 | 907 | ||
906 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); | 908 | rc = pci_set_dma_mask(pdev, ATA_DMA_MASK); |
907 | if (rc) | 909 | if (rc) |
@@ -917,11 +919,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
917 | probe_ent->dev = pci_dev_to_dev(pdev); | 919 | probe_ent->dev = pci_dev_to_dev(pdev); |
918 | INIT_LIST_HEAD(&probe_ent->node); | 920 | INIT_LIST_HEAD(&probe_ent->node); |
919 | 921 | ||
920 | mmio_base = pcim_iomap(pdev, 3, 0); | ||
921 | if (mmio_base == NULL) | ||
922 | return -ENOMEM; | ||
923 | base = (unsigned long) mmio_base; | ||
924 | |||
925 | hp = devm_kzalloc(&pdev->dev, sizeof(*hp), GFP_KERNEL); | 922 | hp = devm_kzalloc(&pdev->dev, sizeof(*hp), GFP_KERNEL); |
926 | if (hp == NULL) | 923 | if (hp == NULL) |
927 | return -ENOMEM; | 924 | return -ENOMEM; |
@@ -937,7 +934,9 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
937 | 934 | ||
938 | probe_ent->irq = pdev->irq; | 935 | probe_ent->irq = pdev->irq; |
939 | probe_ent->irq_flags = IRQF_SHARED; | 936 | probe_ent->irq_flags = IRQF_SHARED; |
940 | probe_ent->mmio_base = mmio_base; | 937 | probe_ent->iomap = pcim_iomap_table(pdev); |
938 | |||
939 | base = probe_ent->iomap[PDC_MMIO_BAR]; | ||
941 | 940 | ||
942 | pdc_ata_setup_port(&probe_ent->port[0], base + 0x200); | 941 | pdc_ata_setup_port(&probe_ent->port[0], base + 0x200); |
943 | pdc_ata_setup_port(&probe_ent->port[1], base + 0x280); | 942 | pdc_ata_setup_port(&probe_ent->port[1], base + 0x280); |
@@ -964,7 +963,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e | |||
964 | /* Fall through */ | 963 | /* Fall through */ |
965 | case board_2037x: | 964 | case board_2037x: |
966 | /* TX2plus boards also have a PATA port */ | 965 | /* TX2plus boards also have a PATA port */ |
967 | tmp = readb(mmio_base + PDC_FLASH_CTL+1); | 966 | tmp = readb(base + PDC_FLASH_CTL+1); |
968 | if (!(tmp & 0x80)) { | 967 | if (!(tmp & 0x80)) { |
969 | probe_ent->n_ports = 3; | 968 | probe_ent->n_ports = 3; |
970 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300); | 969 | pdc_ata_setup_port(&probe_ent->port[2], base + 0x300); |