aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudiu Manoil <claudiu.manoil@freescale.com>2014-10-07 03:44:34 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-09 01:40:37 -0400
commita4feee89ce4590c7a4aead49ca5a4853dc6ea5dc (patch)
tree781f0632c4405085d75e4f73394927dab39bb964
parent83bfc3c4765c35ef0dfff8a3d6dedab88f3f50ea (diff)
gianfar: Replace spin_event_timeout() with arch independent
Use arch independent code to replace the powerpc dependent spin_event_timeout() from gfar_halt_nodisable(). Added GRS/GTS read accessors to clean-up the implementation of gfar_halt_nodisable(). Signed-off-by: Claudiu Manoil <claudiu.manoil@freescale.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c32
-rw-r--r--drivers/net/ethernet/freescale/gianfar.h15
2 files changed, 34 insertions, 13 deletions
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 961198a2bfa8..356a9982d014 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1762,26 +1762,32 @@ static void gfar_halt_nodisable(struct gfar_private *priv)
1762{ 1762{
1763 struct gfar __iomem *regs = priv->gfargrp[0].regs; 1763 struct gfar __iomem *regs = priv->gfargrp[0].regs;
1764 u32 tempval; 1764 u32 tempval;
1765 unsigned int timeout;
1766 int stopped;
1765 1767
1766 gfar_ints_disable(priv); 1768 gfar_ints_disable(priv);
1767 1769
1770 if (gfar_is_dma_stopped(priv))
1771 return;
1772
1768 /* Stop the DMA, and wait for it to stop */ 1773 /* Stop the DMA, and wait for it to stop */
1769 tempval = gfar_read(&regs->dmactrl); 1774 tempval = gfar_read(&regs->dmactrl);
1770 if ((tempval & (DMACTRL_GRS | DMACTRL_GTS)) != 1775 tempval |= (DMACTRL_GRS | DMACTRL_GTS);
1771 (DMACTRL_GRS | DMACTRL_GTS)) { 1776 gfar_write(&regs->dmactrl, tempval);
1772 int ret;
1773
1774 tempval |= (DMACTRL_GRS | DMACTRL_GTS);
1775 gfar_write(&regs->dmactrl, tempval);
1776 1777
1777 do { 1778retry:
1778 ret = spin_event_timeout(((gfar_read(&regs->ievent) & 1779 timeout = 1000;
1779 (IEVENT_GRSC | IEVENT_GTSC)) == 1780 while (!(stopped = gfar_is_dma_stopped(priv)) && timeout) {
1780 (IEVENT_GRSC | IEVENT_GTSC)), 1000000, 0); 1781 cpu_relax();
1781 if (!ret && !(gfar_read(&regs->ievent) & IEVENT_GRSC)) 1782 timeout--;
1782 ret = __gfar_is_rx_idle(priv);
1783 } while (!ret);
1784 } 1783 }
1784
1785 if (!timeout)
1786 stopped = gfar_is_dma_stopped(priv);
1787
1788 if (!stopped && !gfar_is_rx_dma_stopped(priv) &&
1789 !__gfar_is_rx_idle(priv))
1790 goto retry;
1785} 1791}
1786 1792
1787/* Halt the receive and transmit queues */ 1793/* Halt the receive and transmit queues */
diff --git a/drivers/net/ethernet/freescale/gianfar.h b/drivers/net/ethernet/freescale/gianfar.h
index 84632c569f2c..0b3772217a9a 100644
--- a/drivers/net/ethernet/freescale/gianfar.h
+++ b/drivers/net/ethernet/freescale/gianfar.h
@@ -1226,6 +1226,21 @@ static inline void gfar_write_isrg(struct gfar_private *priv)
1226 } 1226 }
1227} 1227}
1228 1228
1229static inline int gfar_is_dma_stopped(struct gfar_private *priv)
1230{
1231 struct gfar __iomem *regs = priv->gfargrp[0].regs;
1232
1233 return ((gfar_read(&regs->ievent) & (IEVENT_GRSC | IEVENT_GTSC)) ==
1234 (IEVENT_GRSC | IEVENT_GTSC));
1235}
1236
1237static inline int gfar_is_rx_dma_stopped(struct gfar_private *priv)
1238{
1239 struct gfar __iomem *regs = priv->gfargrp[0].regs;
1240
1241 return gfar_read(&regs->ievent) & IEVENT_GRSC;
1242}
1243
1229irqreturn_t gfar_receive(int irq, void *dev_id); 1244irqreturn_t gfar_receive(int irq, void *dev_id);
1230int startup_gfar(struct net_device *dev); 1245int startup_gfar(struct net_device *dev);
1231void stop_gfar(struct net_device *dev); 1246void stop_gfar(struct net_device *dev);