diff options
author | Mans Rullgard <mans@mansr.com> | 2016-04-26 05:03:12 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2016-05-10 12:29:19 -0400 |
commit | 2d20da00c324b9a4dd1c4ab9429a6376e7f4b735 (patch) | |
tree | f3d9edf8f016f136ce8e1631e1b696ec89c57db5 /drivers/ata | |
parent | 0f48debdb90601ec37cdcb81f796ca120aae60f4 (diff) |
ata: sata_dwc_460ex: get rid of global data
This moves all global data into the driver private struct, thus
permitting multiple devices of this type to be used.
The core_scr_read/write() functions are replaced with equivalent
calls to the existing sata_dwc_scr_read/write().
Tested-by: Christian Lamparter <chunkeey@googlemail.com>
Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'drivers/ata')
-rw-r--r-- | drivers/ata/sata_dwc_460ex.c | 79 |
1 files changed, 29 insertions, 50 deletions
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c index 4b8eded09c06..24837d6fbe80 100644 --- a/drivers/ata/sata_dwc_460ex.c +++ b/drivers/ata/sata_dwc_460ex.c | |||
@@ -146,6 +146,8 @@ struct sata_dwc_device { | |||
146 | struct ata_host *host; | 146 | struct ata_host *host; |
147 | u8 __iomem *reg_base; | 147 | u8 __iomem *reg_base; |
148 | struct sata_dwc_regs *sata_dwc_regs; /* DW Synopsys SATA specific */ | 148 | struct sata_dwc_regs *sata_dwc_regs; /* DW Synopsys SATA specific */ |
149 | u32 sactive_issued; | ||
150 | u32 sactive_queued; | ||
149 | struct phy *phy; | 151 | struct phy *phy; |
150 | #ifdef CONFIG_SATA_DWC_OLD_DMA | 152 | #ifdef CONFIG_SATA_DWC_OLD_DMA |
151 | struct dw_dma_chip *dma; | 153 | struct dw_dma_chip *dma; |
@@ -190,14 +192,6 @@ enum { | |||
190 | SATA_DWC_DMA_PENDING_RX = 2, | 192 | SATA_DWC_DMA_PENDING_RX = 2, |
191 | }; | 193 | }; |
192 | 194 | ||
193 | struct sata_dwc_host_priv { | ||
194 | void __iomem *scr_addr_sstatus; | ||
195 | u32 sata_dwc_sactive_issued ; | ||
196 | u32 sata_dwc_sactive_queued ; | ||
197 | }; | ||
198 | |||
199 | static struct sata_dwc_host_priv host_pvt; | ||
200 | |||
201 | /* | 195 | /* |
202 | * Prototypes | 196 | * Prototypes |
203 | */ | 197 | */ |
@@ -457,21 +451,11 @@ static int sata_dwc_scr_write(struct ata_link *link, unsigned int scr, u32 val) | |||
457 | return 0; | 451 | return 0; |
458 | } | 452 | } |
459 | 453 | ||
460 | static u32 core_scr_read(unsigned int scr) | 454 | static void clear_serror(struct ata_port *ap) |
461 | { | ||
462 | return in_le32(host_pvt.scr_addr_sstatus + (scr * 4)); | ||
463 | } | ||
464 | |||
465 | static void core_scr_write(unsigned int scr, u32 val) | ||
466 | { | ||
467 | out_le32(host_pvt.scr_addr_sstatus + (scr * 4), val); | ||
468 | } | ||
469 | |||
470 | static void clear_serror(void) | ||
471 | { | 455 | { |
472 | u32 val; | 456 | u32 val; |
473 | val = core_scr_read(SCR_ERROR); | 457 | sata_dwc_scr_read(&ap->link, SCR_ERROR, &val); |
474 | core_scr_write(SCR_ERROR, val); | 458 | sata_dwc_scr_write(&ap->link, SCR_ERROR, val); |
475 | } | 459 | } |
476 | 460 | ||
477 | static void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32 bit) | 461 | static void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32 bit) |
@@ -498,7 +482,7 @@ static void sata_dwc_error_intr(struct ata_port *ap, | |||
498 | 482 | ||
499 | ata_ehi_clear_desc(ehi); | 483 | ata_ehi_clear_desc(ehi); |
500 | 484 | ||
501 | serror = core_scr_read(SCR_ERROR); | 485 | sata_dwc_scr_read(&ap->link, SCR_ERROR, &serror); |
502 | status = ap->ops->sff_check_status(ap); | 486 | status = ap->ops->sff_check_status(ap); |
503 | 487 | ||
504 | tag = ap->link.active_tag; | 488 | tag = ap->link.active_tag; |
@@ -509,7 +493,7 @@ static void sata_dwc_error_intr(struct ata_port *ap, | |||
509 | hsdevp->dma_pending[tag], hsdevp->cmd_issued[tag]); | 493 | hsdevp->dma_pending[tag], hsdevp->cmd_issued[tag]); |
510 | 494 | ||
511 | /* Clear error register and interrupt bit */ | 495 | /* Clear error register and interrupt bit */ |
512 | clear_serror(); | 496 | clear_serror(ap); |
513 | clear_interrupt_bit(hsdev, SATA_DWC_INTPR_ERR); | 497 | clear_interrupt_bit(hsdev, SATA_DWC_INTPR_ERR); |
514 | 498 | ||
515 | /* This is the only error happening now. TODO check for exact error */ | 499 | /* This is the only error happening now. TODO check for exact error */ |
@@ -548,7 +532,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) | |||
548 | int handled, num_processed, port = 0; | 532 | int handled, num_processed, port = 0; |
549 | uint intpr, sactive, sactive2, tag_mask; | 533 | uint intpr, sactive, sactive2, tag_mask; |
550 | struct sata_dwc_device_port *hsdevp; | 534 | struct sata_dwc_device_port *hsdevp; |
551 | host_pvt.sata_dwc_sactive_issued = 0; | 535 | hsdev->sactive_issued = 0; |
552 | 536 | ||
553 | spin_lock_irqsave(&host->lock, flags); | 537 | spin_lock_irqsave(&host->lock, flags); |
554 | 538 | ||
@@ -577,7 +561,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) | |||
577 | if (hsdevp->cmd_issued[tag] != SATA_DWC_CMD_ISSUED_PEND) | 561 | if (hsdevp->cmd_issued[tag] != SATA_DWC_CMD_ISSUED_PEND) |
578 | dev_warn(ap->dev, "CMD tag=%d not pending?\n", tag); | 562 | dev_warn(ap->dev, "CMD tag=%d not pending?\n", tag); |
579 | 563 | ||
580 | host_pvt.sata_dwc_sactive_issued |= qcmd_tag_to_mask(tag); | 564 | hsdev->sactive_issued |= qcmd_tag_to_mask(tag); |
581 | 565 | ||
582 | qc = ata_qc_from_tag(ap, tag); | 566 | qc = ata_qc_from_tag(ap, tag); |
583 | /* | 567 | /* |
@@ -591,11 +575,11 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance) | |||
591 | handled = 1; | 575 | handled = 1; |
592 | goto DONE; | 576 | goto DONE; |
593 | } | 577 | } |
594 | sactive = core_scr_read(SCR_ACTIVE); | 578 | sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive); |
595 | tag_mask = (host_pvt.sata_dwc_sactive_issued | sactive) ^ sactive; | 579 | tag_mask = (hsdev->sactive_issued | sactive) ^ sactive; |
596 | 580 | ||
597 | /* If no sactive issued and tag_mask is zero then this is not NCQ */ | 581 | /* If no sactive issued and tag_mask is zero then this is not NCQ */ |
598 | if (host_pvt.sata_dwc_sactive_issued == 0 && tag_mask == 0) { | 582 | if (hsdev->sactive_issued == 0 && tag_mask == 0) { |
599 | if (ap->link.active_tag == ATA_TAG_POISON) | 583 | if (ap->link.active_tag == ATA_TAG_POISON) |
600 | tag = 0; | 584 | tag = 0; |
601 | else | 585 | else |
@@ -665,22 +649,19 @@ DRVSTILLBUSY: | |||
665 | */ | 649 | */ |
666 | 650 | ||
667 | /* process completed commands */ | 651 | /* process completed commands */ |
668 | sactive = core_scr_read(SCR_ACTIVE); | 652 | sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive); |
669 | tag_mask = (host_pvt.sata_dwc_sactive_issued | sactive) ^ sactive; | 653 | tag_mask = (hsdev->sactive_issued | sactive) ^ sactive; |
670 | 654 | ||
671 | if (sactive != 0 || (host_pvt.sata_dwc_sactive_issued) > 1 || \ | 655 | if (sactive != 0 || hsdev->sactive_issued > 1 || tag_mask > 1) { |
672 | tag_mask > 1) { | ||
673 | dev_dbg(ap->dev, | 656 | dev_dbg(ap->dev, |
674 | "%s NCQ:sactive=0x%08x sactive_issued=0x%08x tag_mask=0x%08x\n", | 657 | "%s NCQ:sactive=0x%08x sactive_issued=0x%08x tag_mask=0x%08x\n", |
675 | __func__, sactive, host_pvt.sata_dwc_sactive_issued, | 658 | __func__, sactive, hsdev->sactive_issued, tag_mask); |
676 | tag_mask); | ||
677 | } | 659 | } |
678 | 660 | ||
679 | if ((tag_mask | (host_pvt.sata_dwc_sactive_issued)) != \ | 661 | if ((tag_mask | hsdev->sactive_issued) != hsdev->sactive_issued) { |
680 | (host_pvt.sata_dwc_sactive_issued)) { | ||
681 | dev_warn(ap->dev, | 662 | dev_warn(ap->dev, |
682 | "Bad tag mask? sactive=0x%08x (host_pvt.sata_dwc_sactive_issued)=0x%08x tag_mask=0x%08x\n", | 663 | "Bad tag mask? sactive=0x%08x sactive_issued=0x%08x tag_mask=0x%08x\n", |
683 | sactive, host_pvt.sata_dwc_sactive_issued, tag_mask); | 664 | sactive, hsdev->sactive_issued, tag_mask); |
684 | } | 665 | } |
685 | 666 | ||
686 | /* read just to clear ... not bad if currently still busy */ | 667 | /* read just to clear ... not bad if currently still busy */ |
@@ -742,7 +723,7 @@ STILLBUSY: | |||
742 | * we were processing --we read status as part of processing a completed | 723 | * we were processing --we read status as part of processing a completed |
743 | * command). | 724 | * command). |
744 | */ | 725 | */ |
745 | sactive2 = core_scr_read(SCR_ACTIVE); | 726 | sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive2); |
746 | if (sactive2 != sactive) { | 727 | if (sactive2 != sactive) { |
747 | dev_dbg(ap->dev, | 728 | dev_dbg(ap->dev, |
748 | "More completed - sactive=0x%x sactive2=0x%x\n", | 729 | "More completed - sactive=0x%x sactive2=0x%x\n", |
@@ -828,8 +809,9 @@ static int sata_dwc_qc_complete(struct ata_port *ap, struct ata_queued_cmd *qc, | |||
828 | u8 status = 0; | 809 | u8 status = 0; |
829 | u32 mask = 0x0; | 810 | u32 mask = 0x0; |
830 | u8 tag = qc->tag; | 811 | u8 tag = qc->tag; |
812 | struct sata_dwc_device *hsdev = HSDEV_FROM_AP(ap); | ||
831 | struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); | 813 | struct sata_dwc_device_port *hsdevp = HSDEVP_FROM_AP(ap); |
832 | host_pvt.sata_dwc_sactive_queued = 0; | 814 | hsdev->sactive_queued = 0; |
833 | dev_dbg(ap->dev, "%s checkstatus? %x\n", __func__, check_status); | 815 | dev_dbg(ap->dev, "%s checkstatus? %x\n", __func__, check_status); |
834 | 816 | ||
835 | if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX) | 817 | if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX) |
@@ -842,10 +824,8 @@ static int sata_dwc_qc_complete(struct ata_port *ap, struct ata_queued_cmd *qc, | |||
842 | 824 | ||
843 | /* clear active bit */ | 825 | /* clear active bit */ |
844 | mask = (~(qcmd_tag_to_mask(tag))); | 826 | mask = (~(qcmd_tag_to_mask(tag))); |
845 | host_pvt.sata_dwc_sactive_queued = (host_pvt.sata_dwc_sactive_queued) \ | 827 | hsdev->sactive_queued = hsdev->sactive_queued & mask; |
846 | & mask; | 828 | hsdev->sactive_issued = hsdev->sactive_issued & mask; |
847 | host_pvt.sata_dwc_sactive_issued = (host_pvt.sata_dwc_sactive_issued) \ | ||
848 | & mask; | ||
849 | ata_qc_complete(qc); | 829 | ata_qc_complete(qc); |
850 | return 0; | 830 | return 0; |
851 | } | 831 | } |
@@ -974,7 +954,7 @@ static int sata_dwc_port_start(struct ata_port *ap) | |||
974 | } | 954 | } |
975 | 955 | ||
976 | /* Clear any error bits before libata starts issuing commands */ | 956 | /* Clear any error bits before libata starts issuing commands */ |
977 | clear_serror(); | 957 | clear_serror(ap); |
978 | ap->private_data = hsdevp; | 958 | ap->private_data = hsdevp; |
979 | dev_dbg(ap->dev, "%s: done\n", __func__); | 959 | dev_dbg(ap->dev, "%s: done\n", __func__); |
980 | return 0; | 960 | return 0; |
@@ -1025,7 +1005,7 @@ static void sata_dwc_exec_command_by_tag(struct ata_port *ap, | |||
1025 | * managed SError register for the disk needs to be done before the | 1005 | * managed SError register for the disk needs to be done before the |
1026 | * task file is loaded. | 1006 | * task file is loaded. |
1027 | */ | 1007 | */ |
1028 | clear_serror(); | 1008 | clear_serror(ap); |
1029 | ata_sff_exec_command(ap, tf); | 1009 | ata_sff_exec_command(ap, tf); |
1030 | } | 1010 | } |
1031 | 1011 | ||
@@ -1078,7 +1058,7 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag) | |||
1078 | sata_dwc_tf_dump(ap, &qc->tf); | 1058 | sata_dwc_tf_dump(ap, &qc->tf); |
1079 | 1059 | ||
1080 | if (start_dma) { | 1060 | if (start_dma) { |
1081 | reg = core_scr_read(SCR_ERROR); | 1061 | sata_dwc_scr_read(&ap->link, SCR_ERROR, ®); |
1082 | if (reg & SATA_DWC_SERROR_ERR_BITS) { | 1062 | if (reg & SATA_DWC_SERROR_ERR_BITS) { |
1083 | dev_err(ap->dev, "%s: ****** SError=0x%08x ******\n", | 1063 | dev_err(ap->dev, "%s: ****** SError=0x%08x ******\n", |
1084 | __func__, reg); | 1064 | __func__, reg); |
@@ -1140,9 +1120,9 @@ static unsigned int sata_dwc_qc_issue(struct ata_queued_cmd *qc) | |||
1140 | } | 1120 | } |
1141 | 1121 | ||
1142 | if (ata_is_ncq(qc->tf.protocol)) { | 1122 | if (ata_is_ncq(qc->tf.protocol)) { |
1143 | sactive = core_scr_read(SCR_ACTIVE); | 1123 | sata_dwc_scr_read(&ap->link, SCR_ACTIVE, &sactive); |
1144 | sactive |= (0x00000001 << tag); | 1124 | sactive |= (0x00000001 << tag); |
1145 | core_scr_write(SCR_ACTIVE, sactive); | 1125 | sata_dwc_scr_write(&ap->link, SCR_ACTIVE, sactive); |
1146 | 1126 | ||
1147 | dev_dbg(qc->ap->dev, | 1127 | dev_dbg(qc->ap->dev, |
1148 | "%s: tag=%d ap->link.sactive = 0x%08x sactive=0x%08x\n", | 1128 | "%s: tag=%d ap->link.sactive = 0x%08x sactive=0x%08x\n", |
@@ -1298,7 +1278,6 @@ static int sata_dwc_probe(struct platform_device *ofdev) | |||
1298 | /* Setup port */ | 1278 | /* Setup port */ |
1299 | host->ports[0]->ioaddr.cmd_addr = base; | 1279 | host->ports[0]->ioaddr.cmd_addr = base; |
1300 | host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET; | 1280 | host->ports[0]->ioaddr.scr_addr = base + SATA_DWC_SCR_OFFSET; |
1301 | host_pvt.scr_addr_sstatus = base + SATA_DWC_SCR_OFFSET; | ||
1302 | sata_dwc_setup_port(&host->ports[0]->ioaddr, (unsigned long)base); | 1281 | sata_dwc_setup_port(&host->ports[0]->ioaddr, (unsigned long)base); |
1303 | 1282 | ||
1304 | /* Read the ID and Version Registers */ | 1283 | /* Read the ID and Version Registers */ |