aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2016-04-26 05:03:20 -0400
committerTejun Heo <tj@kernel.org>2016-05-12 10:53:11 -0400
commitee81d6cc8e8aa667aabce72f39a4b806419e1d55 (patch)
treefbabeb4686a91513a892f28b6d1880d41e77e936
parent9e8b855e9841eeb9c13e79d50f70dc000b0dfbfd (diff)
ata: sata_dwc_460ex: use readl/writel_relaxed()
Rename the register access macros and use standard _relaxed() ops instead of __raw variants with explicit byte swapping. The original driver used the ppc-specific in/out_le32(). When it was adapted to other systems, these were added to the driver under ifdefs. However, those names are not defined as macros on ppc, so it ended up replacing them there as well with altered semantics. This patch restores the original semantics on ppc and makes the accesses no less strict on other systems. Also fixes too many sparse warnings to count. Tested-by: Christian Lamparter <chunkeey@googlemail.com> Signed-off-by: Mans Rullgard <mans@mansr.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--drivers/ata/sata_dwc_460ex.c91
1 files changed, 43 insertions, 48 deletions
diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 10b6a59fe499..b7828c702112 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -51,13 +51,8 @@
51#define DRV_NAME "sata-dwc" 51#define DRV_NAME "sata-dwc"
52#define DRV_VERSION "1.3" 52#define DRV_VERSION "1.3"
53 53
54#ifndef out_le32 54#define sata_dwc_writel(a, v) writel_relaxed(v, a)
55#define out_le32(a, v) __raw_writel(__cpu_to_le32(v), (void __iomem *)(a)) 55#define sata_dwc_readl(a) readl_relaxed(a)
56#endif
57
58#ifndef in_le32
59#define in_le32(a) __le32_to_cpu(__raw_readl((void __iomem *)(a)))
60#endif
61 56
62#ifndef NO_IRQ 57#ifndef NO_IRQ
63#define NO_IRQ 0 58#define NO_IRQ 0
@@ -425,7 +420,7 @@ static int sata_dwc_scr_read(struct ata_link *link, unsigned int scr, u32 *val)
425 return -EINVAL; 420 return -EINVAL;
426 } 421 }
427 422
428 *val = in_le32(link->ap->ioaddr.scr_addr + (scr * 4)); 423 *val = sata_dwc_readl(link->ap->ioaddr.scr_addr + (scr * 4));
429 dev_dbg(link->ap->dev, "%s: id=%d reg=%d val=val=0x%08x\n", 424 dev_dbg(link->ap->dev, "%s: id=%d reg=%d val=val=0x%08x\n",
430 __func__, link->ap->print_id, scr, *val); 425 __func__, link->ap->print_id, scr, *val);
431 426
@@ -441,7 +436,7 @@ static int sata_dwc_scr_write(struct ata_link *link, unsigned int scr, u32 val)
441 __func__, scr); 436 __func__, scr);
442 return -EINVAL; 437 return -EINVAL;
443 } 438 }
444 out_le32(link->ap->ioaddr.scr_addr + (scr * 4), val); 439 sata_dwc_writel(link->ap->ioaddr.scr_addr + (scr * 4), val);
445 440
446 return 0; 441 return 0;
447} 442}
@@ -455,8 +450,8 @@ static void clear_serror(struct ata_port *ap)
455 450
456static void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32 bit) 451static void clear_interrupt_bit(struct sata_dwc_device *hsdev, u32 bit)
457{ 452{
458 out_le32(&hsdev->sata_dwc_regs->intpr, 453 sata_dwc_writel(&hsdev->sata_dwc_regs->intpr,
459 in_le32(&hsdev->sata_dwc_regs->intpr)); 454 sata_dwc_readl(&hsdev->sata_dwc_regs->intpr));
460} 455}
461 456
462static u32 qcmd_tag_to_mask(u8 tag) 457static u32 qcmd_tag_to_mask(u8 tag)
@@ -532,7 +527,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
532 spin_lock_irqsave(&host->lock, flags); 527 spin_lock_irqsave(&host->lock, flags);
533 528
534 /* Read the interrupt register */ 529 /* Read the interrupt register */
535 intpr = in_le32(&hsdev->sata_dwc_regs->intpr); 530 intpr = sata_dwc_readl(&hsdev->sata_dwc_regs->intpr);
536 531
537 ap = host->ports[port]; 532 ap = host->ports[port];
538 hsdevp = HSDEVP_FROM_AP(ap); 533 hsdevp = HSDEVP_FROM_AP(ap);
@@ -551,7 +546,7 @@ static irqreturn_t sata_dwc_isr(int irq, void *dev_instance)
551 if (intpr & SATA_DWC_INTPR_NEWFP) { 546 if (intpr & SATA_DWC_INTPR_NEWFP) {
552 clear_interrupt_bit(hsdev, SATA_DWC_INTPR_NEWFP); 547 clear_interrupt_bit(hsdev, SATA_DWC_INTPR_NEWFP);
553 548
554 tag = (u8)(in_le32(&hsdev->sata_dwc_regs->fptagr)); 549 tag = (u8)(sata_dwc_readl(&hsdev->sata_dwc_regs->fptagr));
555 dev_dbg(ap->dev, "%s: NEWFP tag=%d\n", __func__, tag); 550 dev_dbg(ap->dev, "%s: NEWFP tag=%d\n", __func__, tag);
556 if (hsdevp->cmd_issued[tag] != SATA_DWC_CMD_ISSUED_PEND) 551 if (hsdevp->cmd_issued[tag] != SATA_DWC_CMD_ISSUED_PEND)
557 dev_warn(ap->dev, "CMD tag=%d not pending?\n", tag); 552 dev_warn(ap->dev, "CMD tag=%d not pending?\n", tag);
@@ -736,13 +731,13 @@ static void sata_dwc_clear_dmacr(struct sata_dwc_device_port *hsdevp, u8 tag)
736 struct sata_dwc_device *hsdev = HSDEV_FROM_HSDEVP(hsdevp); 731 struct sata_dwc_device *hsdev = HSDEV_FROM_HSDEVP(hsdevp);
737 732
738 if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_RX) { 733 if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_RX) {
739 out_le32(&(hsdev->sata_dwc_regs->dmacr), 734 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
740 SATA_DWC_DMACR_RX_CLEAR( 735 SATA_DWC_DMACR_RX_CLEAR(
741 in_le32(&(hsdev->sata_dwc_regs->dmacr)))); 736 sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr)));
742 } else if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX) { 737 } else if (hsdevp->dma_pending[tag] == SATA_DWC_DMA_PENDING_TX) {
743 out_le32(&(hsdev->sata_dwc_regs->dmacr), 738 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
744 SATA_DWC_DMACR_TX_CLEAR( 739 SATA_DWC_DMACR_TX_CLEAR(
745 in_le32(&(hsdev->sata_dwc_regs->dmacr)))); 740 sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr)));
746 } else { 741 } else {
747 /* 742 /*
748 * This should not happen, it indicates the driver is out of 743 * This should not happen, it indicates the driver is out of
@@ -751,9 +746,9 @@ static void sata_dwc_clear_dmacr(struct sata_dwc_device_port *hsdevp, u8 tag)
751 dev_err(hsdev->dev, 746 dev_err(hsdev->dev,
752 "%s DMA protocol RX and TX DMA not pending tag=0x%02x pending=%d dmacr: 0x%08x\n", 747 "%s DMA protocol RX and TX DMA not pending tag=0x%02x pending=%d dmacr: 0x%08x\n",
753 __func__, tag, hsdevp->dma_pending[tag], 748 __func__, tag, hsdevp->dma_pending[tag],
754 in_le32(&hsdev->sata_dwc_regs->dmacr)); 749 sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr));
755 out_le32(&(hsdev->sata_dwc_regs->dmacr), 750 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
756 SATA_DWC_DMACR_TXRXCH_CLEAR); 751 SATA_DWC_DMACR_TXRXCH_CLEAR);
757 } 752 }
758} 753}
759 754
@@ -778,7 +773,7 @@ static void sata_dwc_dma_xfer_complete(struct ata_port *ap, u32 check_status)
778 __func__, qc->tag, qc->tf.command, 773 __func__, qc->tag, qc->tf.command,
779 get_dma_dir_descript(qc->dma_dir), 774 get_dma_dir_descript(qc->dma_dir),
780 get_prot_descript(qc->tf.protocol), 775 get_prot_descript(qc->tf.protocol),
781 in_le32(&(hsdev->sata_dwc_regs->dmacr))); 776 sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr));
782 } 777 }
783#endif 778#endif
784 779
@@ -787,7 +782,7 @@ static void sata_dwc_dma_xfer_complete(struct ata_port *ap, u32 check_status)
787 dev_err(ap->dev, 782 dev_err(ap->dev,
788 "%s DMA protocol RX and TX DMA not pending dmacr: 0x%08x\n", 783 "%s DMA protocol RX and TX DMA not pending dmacr: 0x%08x\n",
789 __func__, 784 __func__,
790 in_le32(&(hsdev->sata_dwc_regs->dmacr))); 785 sata_dwc_readl(&hsdev->sata_dwc_regs->dmacr));
791 } 786 }
792 787
793 hsdevp->dma_pending[tag] = SATA_DWC_DMA_PENDING_NONE; 788 hsdevp->dma_pending[tag] = SATA_DWC_DMA_PENDING_NONE;
@@ -828,20 +823,20 @@ static int sata_dwc_qc_complete(struct ata_port *ap, struct ata_queued_cmd *qc,
828static void sata_dwc_enable_interrupts(struct sata_dwc_device *hsdev) 823static void sata_dwc_enable_interrupts(struct sata_dwc_device *hsdev)
829{ 824{
830 /* Enable selective interrupts by setting the interrupt maskregister*/ 825 /* Enable selective interrupts by setting the interrupt maskregister*/
831 out_le32(&hsdev->sata_dwc_regs->intmr, 826 sata_dwc_writel(&hsdev->sata_dwc_regs->intmr,
832 SATA_DWC_INTMR_ERRM | 827 SATA_DWC_INTMR_ERRM |
833 SATA_DWC_INTMR_NEWFPM | 828 SATA_DWC_INTMR_NEWFPM |
834 SATA_DWC_INTMR_PMABRTM | 829 SATA_DWC_INTMR_PMABRTM |
835 SATA_DWC_INTMR_DMATM); 830 SATA_DWC_INTMR_DMATM);
836 /* 831 /*
837 * Unmask the error bits that should trigger an error interrupt by 832 * Unmask the error bits that should trigger an error interrupt by
838 * setting the error mask register. 833 * setting the error mask register.
839 */ 834 */
840 out_le32(&hsdev->sata_dwc_regs->errmr, SATA_DWC_SERROR_ERR_BITS); 835 sata_dwc_writel(&hsdev->sata_dwc_regs->errmr, SATA_DWC_SERROR_ERR_BITS);
841 836
842 dev_dbg(hsdev->dev, "%s: INTMR = 0x%08x, ERRMR = 0x%08x\n", 837 dev_dbg(hsdev->dev, "%s: INTMR = 0x%08x, ERRMR = 0x%08x\n",
843 __func__, in_le32(&hsdev->sata_dwc_regs->intmr), 838 __func__, sata_dwc_readl(&hsdev->sata_dwc_regs->intmr),
844 in_le32(&hsdev->sata_dwc_regs->errmr)); 839 sata_dwc_readl(&hsdev->sata_dwc_regs->errmr));
845} 840}
846 841
847static void sata_dwc_setup_port(struct ata_ioports *port, void __iomem *base) 842static void sata_dwc_setup_port(struct ata_ioports *port, void __iomem *base)
@@ -938,14 +933,14 @@ static int sata_dwc_port_start(struct ata_port *ap)
938 if (ap->port_no == 0) { 933 if (ap->port_no == 0) {
939 dev_dbg(ap->dev, "%s: clearing TXCHEN, RXCHEN in DMAC\n", 934 dev_dbg(ap->dev, "%s: clearing TXCHEN, RXCHEN in DMAC\n",
940 __func__); 935 __func__);
941 out_le32(&hsdev->sata_dwc_regs->dmacr, 936 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
942 SATA_DWC_DMACR_TXRXCH_CLEAR); 937 SATA_DWC_DMACR_TXRXCH_CLEAR);
943 938
944 dev_dbg(ap->dev, "%s: setting burst size in DBTSR\n", 939 dev_dbg(ap->dev, "%s: setting burst size in DBTSR\n",
945 __func__); 940 __func__);
946 out_le32(&hsdev->sata_dwc_regs->dbtsr, 941 sata_dwc_writel(&hsdev->sata_dwc_regs->dbtsr,
947 (SATA_DWC_DBTSR_MWR(AHB_DMA_BRST_DFLT) | 942 (SATA_DWC_DBTSR_MWR(AHB_DMA_BRST_DFLT) |
948 SATA_DWC_DBTSR_MRD(AHB_DMA_BRST_DFLT))); 943 SATA_DWC_DBTSR_MRD(AHB_DMA_BRST_DFLT)));
949 } 944 }
950 945
951 /* Clear any error bits before libata starts issuing commands */ 946 /* Clear any error bits before libata starts issuing commands */
@@ -1060,11 +1055,11 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag)
1060 } 1055 }
1061 1056
1062 if (dir == DMA_TO_DEVICE) 1057 if (dir == DMA_TO_DEVICE)
1063 out_le32(&hsdev->sata_dwc_regs->dmacr, 1058 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
1064 SATA_DWC_DMACR_TXCHEN); 1059 SATA_DWC_DMACR_TXCHEN);
1065 else 1060 else
1066 out_le32(&hsdev->sata_dwc_regs->dmacr, 1061 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
1067 SATA_DWC_DMACR_RXCHEN); 1062 SATA_DWC_DMACR_RXCHEN);
1068 1063
1069 /* Enable AHB DMA transfer on the specified channel */ 1064 /* Enable AHB DMA transfer on the specified channel */
1070 dmaengine_submit(desc); 1065 dmaengine_submit(desc);
@@ -1148,13 +1143,13 @@ static int sata_dwc_hardreset(struct ata_link *link, unsigned int *class,
1148 sata_dwc_enable_interrupts(hsdev); 1143 sata_dwc_enable_interrupts(hsdev);
1149 1144
1150 /* Reconfigure the DMA control register */ 1145 /* Reconfigure the DMA control register */
1151 out_le32(&hsdev->sata_dwc_regs->dmacr, 1146 sata_dwc_writel(&hsdev->sata_dwc_regs->dmacr,
1152 SATA_DWC_DMACR_TXRXCH_CLEAR); 1147 SATA_DWC_DMACR_TXRXCH_CLEAR);
1153 1148
1154 /* Reconfigure the DMA Burst Transaction Size register */ 1149 /* Reconfigure the DMA Burst Transaction Size register */
1155 out_le32(&hsdev->sata_dwc_regs->dbtsr, 1150 sata_dwc_writel(&hsdev->sata_dwc_regs->dbtsr,
1156 SATA_DWC_DBTSR_MWR(AHB_DMA_BRST_DFLT) | 1151 SATA_DWC_DBTSR_MWR(AHB_DMA_BRST_DFLT) |
1157 SATA_DWC_DBTSR_MRD(AHB_DMA_BRST_DFLT)); 1152 SATA_DWC_DBTSR_MRD(AHB_DMA_BRST_DFLT));
1158 1153
1159 return ret; 1154 return ret;
1160} 1155}
@@ -1254,8 +1249,8 @@ static int sata_dwc_probe(struct platform_device *ofdev)
1254 sata_dwc_setup_port(&host->ports[0]->ioaddr, base); 1249 sata_dwc_setup_port(&host->ports[0]->ioaddr, base);
1255 1250
1256 /* Read the ID and Version Registers */ 1251 /* Read the ID and Version Registers */
1257 idr = in_le32(&hsdev->sata_dwc_regs->idr); 1252 idr = sata_dwc_readl(&hsdev->sata_dwc_regs->idr);
1258 versionr = in_le32(&hsdev->sata_dwc_regs->versionr); 1253 versionr = sata_dwc_readl(&hsdev->sata_dwc_regs->versionr);
1259 dev_notice(&ofdev->dev, "id %d, controller version %c.%c%c\n", 1254 dev_notice(&ofdev->dev, "id %d, controller version %c.%c%c\n",
1260 idr, ver[0], ver[1], ver[2]); 1255 idr, ver[0], ver[1], ver[2]);
1261 1256