diff options
author | Thomas Chou <thomas@wytron.com.tw> | 2015-11-08 10:57:05 +0800 |
---|---|---|
committer | Thomas Chou <thomas@wytron.com.tw> | 2015-11-12 08:26:59 +0800 |
commit | acd71c320f917fbd3a2c4978117a2b586e245f42 (patch) | |
tree | 7d594c8fd385b4dd68eced75374df0a38b3dbd41 /drivers | |
parent | de99a17c9a8df4c0b4c4f57b5bb266835cbb9fab (diff) | |
download | u-boot-imx-acd71c320f917fbd3a2c4978117a2b586e245f42.zip u-boot-imx-acd71c320f917fbd3a2c4978117a2b586e245f42.tar.gz u-boot-imx-acd71c320f917fbd3a2c4978117a2b586e245f42.tar.bz2 |
net: altera_tse: factor out stop mac func
Factor out the stop mac function to prepare msgdma support.
Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/altera_tse.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index b2002f4..fe8c524 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -223,16 +223,33 @@ static int altera_tse_free_pkt(struct udevice *dev, uchar *packet, return 0; } +static void altera_tse_stop_mac(struct altera_tse_priv *priv) +{ + struct alt_tse_mac *mac_dev = priv->mac_dev; + u32 status; + ulong ctime; + + /* reset the mac */ + writel(ALTERA_TSE_CMD_SW_RESET_MSK, &mac_dev->command_config); + ctime = get_timer(0); + while (1) { + status = readl(&mac_dev->command_config); + if (!(status & ALTERA_TSE_CMD_SW_RESET_MSK)) + break; + if (get_timer(ctime) > ALT_TSE_SW_RESET_TIMEOUT) { + debug("Reset mac timeout\n"); + break; + } + } +} + static void altera_tse_stop(struct udevice *dev) { struct altera_tse_priv *priv = dev_get_priv(dev); - struct alt_tse_mac *mac_dev = priv->mac_dev; struct alt_sgdma_registers *rx_sgdma = priv->sgdma_rx; struct alt_sgdma_registers *tx_sgdma = priv->sgdma_tx; struct alt_sgdma_descriptor *rx_desc = priv->rx_desc; - u32 status; int ret; - ulong ctime; /* clear rx desc & wait for sgdma to complete */ rx_desc->descriptor_control = 0; @@ -248,18 +265,7 @@ static void altera_tse_stop(struct udevice *dev) writel(ALT_SGDMA_CONTROL_SOFTWARERESET_MSK, &tx_sgdma->control); - /* reset the mac */ - writel(ALTERA_TSE_CMD_SW_RESET_MSK, &mac_dev->command_config); - ctime = get_timer(0); - while (1) { - status = readl(&mac_dev->command_config); - if (!(status & ALTERA_TSE_CMD_SW_RESET_MSK)) - break; - if (get_timer(ctime) > ALT_TSE_SW_RESET_TIMEOUT) { - debug("Reset mac timeout\n"); - break; - } - } + altera_tse_stop_mac(priv); } static int tse_mdio_read(struct mii_dev *bus, int addr, int devad, int reg) |