From: Dave Aldridge <fovsoft@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4] macb: allow GEM to have configurable receive buffer size
Date: Thu, 18 Aug 2011 14:32:19 +0100 [thread overview]
Message-ID: <1313674339-1834-5-git-send-email-fovsoft@gmail.com> (raw)
In-Reply-To: <1313674339-1834-1-git-send-email-fovsoft@gmail.com>
GEM has configurable receive buffer sizes so requires this to be
programmed up.
Signed-off-by: Dave Aldridge <fovsoft@gmail.com>
---
drivers/net/macb.c | 19 +++++++++++++++++++
drivers/net/macb.h | 5 +++++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 41f1dce..4d21f14 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -436,6 +436,23 @@ static int macb_phy_init(struct macb_device *macb)
}
}
+/*
+ * Configure the receive DMA engine to use the correct receive buffer size.
+ * This is a configurable parameter for GEM.
+ */
+static void macb_configure_dma(struct macb_device *macb)
+{
+ u32 dmacfg;
+ u32 rx_ring_buf_size = CONFIG_SYS_MACB_RX_BUFFER_SIZE /
+ CONFIG_SYS_MACB_RX_RING_SIZE;
+
+ if (macb->is_gem) {
+ dmacfg = gem_readl(macb, DMACFG) & ~GEM_BF(RXBS, -1L);
+ dmacfg |= GEM_BF(RXBS, rx_ring_buf_size / 64);
+ gem_writel(macb, DMACFG, dmacfg);
+ }
+}
+
static int macb_init(struct eth_device *netdev, bd_t *bd)
{
struct macb_device *macb = to_macb(netdev);
@@ -465,6 +482,8 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)
}
macb->rx_tail = macb->tx_head = macb->tx_tail = 0;
+ macb_configure_dma(macb);
+
macb_writel(macb, RBQP, macb->rx_ring_dma);
macb_writel(macb, TBQP, macb->tx_ring_dma);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index c0759cf..e0fbd46 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -76,6 +76,7 @@
/* GEM register offsets. */
#define GEM_NCFGR 0x0004
#define GEM_USRIO 0x000c
+#define GEM_DMACFG 0x0010
#define GEM_HRB 0x0080
#define GEM_HRT 0x0084
#define GEM_SA1B 0x0088
@@ -165,6 +166,10 @@
#define GEM_DBW64 1
#define GEM_DBW128 2
+/* Bitfields in DMACFG. */
+#define GEM_RXBS_OFFSET 16
+#define GEM_RXBS_SIZE 8
+
/* Bitfields in NSR */
#define MACB_NSR_LINK_OFFSET 0
#define MACB_NSR_LINK_SIZE 1
--
1.7.3.4
prev parent reply other threads:[~2011-08-18 13:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-18 13:32 [U-Boot] [PATCH 0/4] Add Cadence GEM support to macb Ethernet driver Dave Aldridge
2011-08-18 13:32 ` [U-Boot] [PATCH 1/4] macb: initial support for Cadence GEM Dave Aldridge
2011-08-18 14:03 ` Andreas Bießmann
2011-08-18 15:26 ` Dave Aldridge
2011-10-06 21:50 ` Wolfgang Denk
2011-08-18 13:32 ` [U-Boot] [PATCH 2/4] macb: support higher rate GEM MDIO clock divisors Dave Aldridge
2011-08-18 13:32 ` [U-Boot] [PATCH 3/4] macb: support DMA bus widths > 32 bits Dave Aldridge
2011-08-18 13:32 ` Dave Aldridge [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1313674339-1834-5-git-send-email-fovsoft@gmail.com \
--to=fovsoft@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox