[PATCH v1 1/3] net: ath79: add ag71xx Ethernet driver
Sascha Hauer
s.hauer at pengutronix.de
Mon Sep 11 23:32:08 PDT 2017
On Fri, Aug 18, 2017 at 04:02:59PM +0200, Oleksij Rempel wrote:
> From: Yegor Yefremov <yegorslists at googlemail.com>
>
> Signed-off-by: Yegor Yefremov <yegorslists at googlemail.com>
> Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
> ---
> arch/mips/mach-ath79/include/mach/ar71xx_regs.h | 12 +
> drivers/net/Kconfig | 7 +
> drivers/net/Makefile | 1 +
> drivers/net/ag71xx.c | 530 ++++++++++++++++++++++++
> 4 files changed, 550 insertions(+)
> create mode 100644 drivers/net/ag71xx.c
>
> +static int ag71xx_ether_send(struct eth_device *edev, void *packet, int length)
> +{
> + struct ag71xx *priv = edev->priv;
> + struct device_d *dev = priv->dev;
> + ag7240_desc_t *f = &priv->fifo_tx[priv->next_tx];
> + int i;
> +
> + /* flush */
> + dma_sync_single_for_device((unsigned long)packet, length, DMA_TO_DEVICE);
> +
> + f->pkt_start_addr = virt_to_phys(packet);
> + f->res1 = 0;
> + f->pkt_size = length;
> + f->is_empty = 0;
> + ag71xx_wr(priv, AG71XX_REG_TX_DESC, virt_to_phys(f));
> + ag71xx_wr(priv, AG71XX_REG_TX_CTRL, TX_CTRL_TXE);
> +
> + /* flush again?! */
> + dma_sync_single_for_cpu((unsigned long)packet, length, DMA_TO_DEVICE);
> +
> + for (i = 0; i < MAX_WAIT; i++) {
> + udelay(100);
> + if (f->is_empty) {
> + break;
> + }
> + }
> +
Use a is_timeout() loop. With this you won't have a minimum delay of
100us and also not a granularity of 100us.
> + if (i == MAX_WAIT) {
> + dev_err(dev, "Tx Timed out\n");
> + }
> +
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list