From: Dave Aldridge <fovsoft@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] macb: support DMA bus widths > 32 bits
Date: Thu, 18 Aug 2011 14:32:18 +0100 [thread overview]
Message-ID: <1313674339-1834-4-git-send-email-fovsoft@gmail.com> (raw)
In-Reply-To: <1313674339-1834-1-git-send-email-fovsoft@gmail.com>
Some GEM implementations may support DMA bus widths up to 128 bits.
We can get the maximum supported DMA bus width from the design
configuration register so use that to program the device up.
Signed-off-by: Dave Aldridge <fovsoft@gmail.com>
---
drivers/net/macb.c | 25 +++++++++++++++++++++++++
drivers/net/macb.h | 18 ++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index fd99cdb..41f1dce 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -574,6 +574,27 @@ static u32 macb_mdc_clk_div(struct macb_device *macb, int id)
return ncfgr;
}
+/*
+ * Get the DMA bus width field of the network configuration register that we
+ * should program. We find the width from decoding the design configuration
+ * register to find the maximum supported data bus width.
+ */
+static u32 macb_dbw(struct macb_device *macb)
+{
+ if (!macb->is_gem)
+ return 0;
+
+ switch (GEM_BFEXT(DBWDEF, gem_readl(macb, DCFG1))) {
+ case 4:
+ return GEM_BF(DBW, GEM_DBW128);
+ case 2:
+ return GEM_BF(DBW, GEM_DBW64);
+ case 1:
+ default:
+ return GEM_BF(DBW, GEM_DBW32);
+ }
+}
+
int macb_eth_initialize(int id, void *regs, unsigned int phy_addr)
{
struct macb_device *macb;
@@ -614,6 +635,10 @@ int macb_eth_initialize(int id, void *regs, unsigned int phy_addr)
/* Set MII management clock divider */
ncfgr = macb_mdc_clk_div(macb, id);
+
+ /* Set up the DMA bus width */
+ ncfgr |= macb_dbw(macb);
+
macb_writel(macb, NCFGR, ncfgr);
eth_register(netdev);
diff --git a/drivers/net/macb.h b/drivers/net/macb.h
index b08a057..c0759cf 100644
--- a/drivers/net/macb.h
+++ b/drivers/net/macb.h
@@ -80,6 +80,13 @@
#define GEM_HRT 0x0084
#define GEM_SA1B 0x0088
#define GEM_SA1T 0x008C
+#define GEM_DCFG1 0x0280
+#define GEM_DCFG2 0x0284
+#define GEM_DCFG3 0x0288
+#define GEM_DCFG4 0x028c
+#define GEM_DCFG5 0x0290
+#define GEM_DCFG6 0x0294
+#define GEM_DCFG7 0x0298
/* Bitfields in NCR */
#define MACB_LB_OFFSET 0
@@ -150,6 +157,13 @@
/* GEM specific NCFGR bitfields. */
#define GEM_CLK_OFFSET 18
#define GEM_CLK_SIZE 3
+#define GEM_DBW_OFFSET 21
+#define GEM_DBW_SIZE 2
+
+/* Constants for data bus width. */
+#define GEM_DBW32 0
+#define GEM_DBW64 1
+#define GEM_DBW128 2
/* Bitfields in NSR */
#define MACB_NSR_LINK_OFFSET 0
@@ -259,6 +273,10 @@
#define MACB_REV_OFFSET 0
#define MACB_REV_SIZE 16
+/* Bitfields in DCFG1. */
+#define GEM_DBWDEF_OFFSET 25
+#define GEM_DBWDEF_SIZE 3
+
/* Constants for CLK */
#define MACB_CLK_DIV8 0
#define MACB_CLK_DIV16 1
--
1.7.3.4
next 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 ` Dave Aldridge [this message]
2011-08-18 13:32 ` [U-Boot] [PATCH 4/4] macb: allow GEM to have configurable receive buffer size Dave Aldridge
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-4-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