From patchwork Tue Jul 16 19:03:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramon Fried X-Patchwork-Id: 1132901 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FWZ02yKD"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45p8xQ6gzvz9sDB for ; Wed, 17 Jul 2019 05:05:46 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 91688C21EA7; Tue, 16 Jul 2019 19:05:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 724A1C21E6C; Tue, 16 Jul 2019 19:03:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 44F85C21EE0; Tue, 16 Jul 2019 19:03:47 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id 27D14C21E96 for ; Tue, 16 Jul 2019 19:03:31 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id n4so22153660wrs.3 for ; Tue, 16 Jul 2019 12:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PiJdf2nyJW3gQ3bVSiU2Ca6F+402JomIb31ft8rg27w=; b=FWZ02yKDNPfkzlEhk0OeMWRnO1t/zKVwVZf/d5dfECYJ26Hl+w4ZrGXGTIexL3pPwJ KDw6bW6EwoJ5WfL7+00C+MRUn3I072i7nRKezYs3I2rqfXfPfwipN6yJlxMGFZVrIv9+ 0DS9xy5wYh9buYDT8w6Y+85a5JIXXSJf2ATa7R3rogoBiDpXetEYOLbFF/EhsRCNsfy3 g726orEfFw5/d7JxERztU1RPPv+zYYoaSau/8ZcqCAFUvpwRLKVJp9qqaECP6yeJVcGv QPJEyvcWbfm9yHV4ZTO5jl73zBnM1A5CzRn3J+5mVa8Ik6MrmARmCWuXJ/r6EvxQEttd YILA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PiJdf2nyJW3gQ3bVSiU2Ca6F+402JomIb31ft8rg27w=; b=EAgfC20I8pKz19rrHKzJXU+te7LpIjFeakXb4MUO0GwoXwi6Tf70NpvMxvCDjnD/cG EOxT2MF8180dCCwyoWC9LadqGdZFdiimwzZP9qrdA71d8GwRlktyMCdx+l/j+UyDZ1B/ mVt0sT/0zvXftxnPsUwQmjZJCroawHUVsnSDHAUeJP5lmXhQ+wCnJBd3W819j5QNonzk 4Dpj3C2CG5Wga5zcQerWUFjD9BKDllkQRqrcwqxTNLpNFQfhb432QkEb0CUJn+9eiWmu 5GDspvunsZOwpuo5rfA31C7NoI7zCZM/mVnIqXhdXOAnubPX/nmAncZTLL7qjNhi227y tD9g== X-Gm-Message-State: APjAAAW0zrbShIEhMwXTRsN8u2KOXvtHSRbIyZrWVn92MbNcQqPLHeug N9Fx9Bg9dH4Bz6VGsj+l5JLAJaq2g60= X-Google-Smtp-Source: APXvYqxEWHCpSy0RIp3krG3tBPsLu63tf+XyRDdS0mkrbbDMGAQtLoJ40DdO0cF1Jo0Y24jgA6EzJQ== X-Received: by 2002:a5d:494d:: with SMTP id r13mr38923449wrs.152.1563303810704; Tue, 16 Jul 2019 12:03:30 -0700 (PDT) Received: from localhost.localdomain ([141.226.31.91]) by smtp.gmail.com with ESMTPSA id i66sm36508397wmi.11.2019.07.16.12.03.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 12:03:30 -0700 (PDT) From: Ramon Fried To: u-boot@lists.denx.de, joe.hershberger@ni.com Date: Tue, 16 Jul 2019 22:03:05 +0300 Message-Id: <20190716190305.20520-6-rfried.dev@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190716190305.20520-1-rfried.dev@gmail.com> References: <20190716190305.20520-1-rfried.dev@gmail.com> MIME-Version: 1.0 Subject: [U-Boot] [PATCH 6/6] net: macb: apply sane DMA configuration X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" DMA configuration was heavily dependent on the HW defaults, add function to properly set the required fields, including the new dma_burst_length. Signed-off-by: Ramon Fried Reviewed-by: Anup Patel Tested-by: Anup Patel Acked-by: Joe Hershberger --- v2: nothing. drivers/net/macb.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index dc6aa6deda..035109dc43 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -47,6 +47,7 @@ DECLARE_GLOBAL_DATA_PTR; #define MACB_RX_BUFFER_SIZE 4096 #define MACB_RX_RING_SIZE (MACB_RX_BUFFER_SIZE / 128) +#define RX_BUFFER_MULTIPLE 64 #define MACB_TX_RING_SIZE 16 #define MACB_TX_TIMEOUT 1000 #define MACB_AUTONEG_TIMEOUT 5000000 @@ -697,6 +698,31 @@ static int gmac_init_multi_queues(struct macb_device *macb) return 0; } +static void gmac_configure_dma(struct macb_device *macb) +{ + u32 buffer_size; + u32 dmacfg; + + buffer_size = 128 / RX_BUFFER_MULTIPLE; + dmacfg = gem_readl(macb, DMACFG) & ~GEM_BF(RXBS, -1L); + dmacfg |= GEM_BF(RXBS, buffer_size); + + if (macb->dma_burst_length) + dmacfg = GEM_BFINS(FBLDO, macb->dma_burst_length, dmacfg); + + dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L); + dmacfg &= ~GEM_BIT(ENDIA_PKT); + +#ifdef CONFIG_SYS_LITTLE_ENDIAN + dmacfg &= ~GEM_BIT(ENDIA_DESC); +#else + dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */ +#endif + + dmacfg &= ~GEM_BIT(ADDR64); + gem_writel(macb, DMACFG, dmacfg); +} + #ifdef CONFIG_DM_ETH static int _macb_init(struct udevice *dev, const char *name) #else @@ -750,6 +776,8 @@ static int _macb_init(struct macb_device *macb, const char *name) macb_writel(macb, TBQP, macb->tx_ring_dma); if (macb_is_gem(macb)) { + /* Initialize DMA properties */ + gmac_configure_dma(macb); /* Check the multi queue and initialize the queue for tx */ gmac_init_multi_queues(macb);