Commit a4feee89 authored by Claudiu Manoil's avatar Claudiu Manoil Committed by David S. Miller

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: default avatarClaudiu Manoil <claudiu.manoil@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 83bfc3c4
...@@ -1762,26 +1762,32 @@ static void gfar_halt_nodisable(struct gfar_private *priv) ...@@ -1762,26 +1762,32 @@ static void gfar_halt_nodisable(struct gfar_private *priv)
{ {
struct gfar __iomem *regs = priv->gfargrp[0].regs; struct gfar __iomem *regs = priv->gfargrp[0].regs;
u32 tempval; u32 tempval;
unsigned int timeout;
int stopped;
gfar_ints_disable(priv); gfar_ints_disable(priv);
if (gfar_is_dma_stopped(priv))
return;
/* Stop the DMA, and wait for it to stop */ /* Stop the DMA, and wait for it to stop */
tempval = gfar_read(&regs->dmactrl); tempval = gfar_read(&regs->dmactrl);
if ((tempval & (DMACTRL_GRS | DMACTRL_GTS)) != tempval |= (DMACTRL_GRS | DMACTRL_GTS);
(DMACTRL_GRS | DMACTRL_GTS)) { gfar_write(&regs->dmactrl, tempval);
int ret;
tempval |= (DMACTRL_GRS | DMACTRL_GTS);
gfar_write(&regs->dmactrl, tempval);
do { retry:
ret = spin_event_timeout(((gfar_read(&regs->ievent) & timeout = 1000;
(IEVENT_GRSC | IEVENT_GTSC)) == while (!(stopped = gfar_is_dma_stopped(priv)) && timeout) {
(IEVENT_GRSC | IEVENT_GTSC)), 1000000, 0); cpu_relax();
if (!ret && !(gfar_read(&regs->ievent) & IEVENT_GRSC)) timeout--;
ret = __gfar_is_rx_idle(priv);
} while (!ret);
} }
if (!timeout)
stopped = gfar_is_dma_stopped(priv);
if (!stopped && !gfar_is_rx_dma_stopped(priv) &&
!__gfar_is_rx_idle(priv))
goto retry;
} }
/* Halt the receive and transmit queues */ /* Halt the receive and transmit queues */
......
...@@ -1226,6 +1226,21 @@ static inline void gfar_write_isrg(struct gfar_private *priv) ...@@ -1226,6 +1226,21 @@ static inline void gfar_write_isrg(struct gfar_private *priv)
} }
} }
static inline int gfar_is_dma_stopped(struct gfar_private *priv)
{
struct gfar __iomem *regs = priv->gfargrp[0].regs;
return ((gfar_read(&regs->ievent) & (IEVENT_GRSC | IEVENT_GTSC)) ==
(IEVENT_GRSC | IEVENT_GTSC));
}
static inline int gfar_is_rx_dma_stopped(struct gfar_private *priv)
{
struct gfar __iomem *regs = priv->gfargrp[0].regs;
return gfar_read(&regs->ievent) & IEVENT_GRSC;
}
irqreturn_t gfar_receive(int irq, void *dev_id); irqreturn_t gfar_receive(int irq, void *dev_id);
int startup_gfar(struct net_device *dev); int startup_gfar(struct net_device *dev);
void stop_gfar(struct net_device *dev); void stop_gfar(struct net_device *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment