if_awg: Add awg_stop_dma and use it in awg_stop

No functional changes intended
This commit is contained in:
Emmanuel Vadot 2020-11-20 11:28:23 +00:00
parent 86c7bc68ed
commit a19071cea2

View File

@ -780,6 +780,31 @@ awg_init_dma(struct awg_softc *sc)
WR4(sc, EMAC_RX_CTL_1, val | RX_DMA_EN | RX_MD);
}
static void
awg_stop_dma(struct awg_softc *sc)
{
uint32_t val;
AWG_ASSERT_LOCKED(sc);
/* Stop transmit DMA and flush data in the TX FIFO */
val = RD4(sc, EMAC_TX_CTL_1);
val &= ~TX_DMA_EN;
val |= FLUSH_TX_FIFO;
WR4(sc, EMAC_TX_CTL_1, val);
/* Disable interrupts */
awg_disable_dma_intr(sc);
/* Disable transmit DMA */
val = RD4(sc, EMAC_TX_CTL_1);
WR4(sc, EMAC_TX_CTL_1, val & ~TX_DMA_EN);
/* Disable receive DMA */
val = RD4(sc, EMAC_RX_CTL_1);
WR4(sc, EMAC_RX_CTL_1, val & ~RX_DMA_EN);
}
static void
awg_init_locked(struct awg_softc *sc)
{
@ -830,25 +855,9 @@ awg_stop(struct awg_softc *sc)
callout_stop(&sc->stat_ch);
/* Stop transmit DMA and flush data in the TX FIFO */
val = RD4(sc, EMAC_TX_CTL_1);
val &= ~TX_DMA_EN;
val |= FLUSH_TX_FIFO;
WR4(sc, EMAC_TX_CTL_1, val);
awg_stop_dma(sc);
awg_enable_mac(sc, false);
/* Disable interrupts */
awg_disable_dma_intr(sc);
/* Disable transmit DMA */
val = RD4(sc, EMAC_TX_CTL_1);
WR4(sc, EMAC_TX_CTL_1, val & ~TX_DMA_EN);
/* Disable receive DMA */
val = RD4(sc, EMAC_RX_CTL_1);
WR4(sc, EMAC_RX_CTL_1, val & ~RX_DMA_EN);
sc->link = 0;
/* Finish handling transmitted buffers */