From: Renaud Barbier <renaud.barbier@ge.com>
To: barebox@lists.infradead.org
Subject: [PATCH] gianfar: prevent resource conflict
Date: Thu, 30 May 2013 16:15:35 +0100 [thread overview]
Message-ID: <1369926935-24159-1-git-send-email-renaud.barbier@ge.com> (raw)
On eTSEC Ethernet devices, there are three memory regions to map.
These regions map registers to control the TSEC interfaces, PHY
access and TBI interface.
Depending on the port number and TSEC version, some of these resources
may be shared within an instance of the driver or between instances
of the driver.
Since dev_request_mem_region returns NULL to avoid resource conflicts if
a region is already mapped the TSEC driver fails to initialise when
these regions are shared. This patch works around this and makes
all three memory regions available to each instance.
Below is a description of TSEC Ethernet port mapping for port 1 to 3.
These ports are present in CPUs susch as the mpc8544 and P2020.
Each port has three set of registers:
* region 0 maps the TSEC registers.
* region 1 maps the PHY access registers always through port 1.
* region 2 maps the TBI interface registers.
The tables below shows how registers are mapped.
For instance, for TSEC version 1:
- port 2/register set 1 i.e p2/reg1 is the same region as
port 1/register set 1 i.e p1/reg1. That is they share port 1
register set 1 as the same region.
As well is p3/reg1, p1/reg0 and p1/reg2 uses p1/reg1.
- port 2/register set 0 i.e p2/reg0 is not the same region as
port 3/register set 0 i.e p3/reg0.
That is p2/r0 and p3/r0 are two different regions.
However, port 2/register 2 is the same as port 2/register 0.
TSEC version 1:
ports/registers reg0 reg1 reg2
p1 p1/r1 p1/r1 p1/r1
p2 p2/r0 p1/r1 p2/r0
p3 p3/r0 p1/r1 p3/r0
TSEC version2:
ports/registers reg0 reg1 reg2
p1 p1/r0 p1/r1 p1/r1
p2 p2/r0 p1/r1 p2/r2
p3 p3/r0 p1/r1 p3/r2
Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
---
drivers/net/gianfar.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 96055bd..79113a8 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -28,6 +28,8 @@
#define RX_BUF_CNT PKTBUFSRX
#define BUF_ALIGN 8
+static void __iomem *phyregs;
+
/*
* Initialize required registers to appropriate values, zeroing
* those we don't care about (unless zero is bad, in which case,
@@ -481,8 +483,23 @@ static int gfar_probe(struct device_d *dev)
edev = &priv->edev;
priv->regs = dev_request_mem_region(dev, 0);
- priv->phyregs = dev_request_mem_region(dev, 1);
+ if (priv->regs == NULL)
+ priv->regs = phyregs;
+
+ if (phyregs == NULL) {
+ phyregs = dev_request_mem_region(dev, 1);
+ if (phyregs == NULL)
+ phyregs = priv->regs;
+ }
+ priv->phyregs = phyregs;
+
priv->phyregs_sgmii = dev_request_mem_region(dev, 2);
+ if (priv->phyregs_sgmii == NULL) {
+ if (IS_ENABLED(CONFIG_TSECV2))
+ priv->phyregs_sgmii = priv->phyregs;
+ else
+ priv->phyregs_sgmii = priv->regs;
+ }
priv->phyaddr = gfar_info->phyaddr;
priv->tbicr = gfar_info->tbicr;
--
1.7.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2013-05-30 15:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 15:15 Renaud Barbier [this message]
2013-06-01 9:20 ` Sascha Hauer
2013-06-03 9:31 ` Renaud Barbier
2013-06-04 17:01 ` Renaud Barbier
2013-06-05 7:12 ` Sascha Hauer
2013-06-05 9:05 ` Renaud Barbier
2013-06-25 13:09 ` [PATCH v2 0/2] " Renaud Barbier
2013-06-25 13:09 ` [PATCH 1/2] ppc: gianfar MDIO buses Renaud Barbier
2013-06-26 6:44 ` Sascha Hauer
2013-06-25 13:10 ` [PATCH 2/2] P2020RDB: update build configuration Renaud Barbier
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=1369926935-24159-1-git-send-email-renaud.barbier@ge.com \
--to=renaud.barbier@ge.com \
--cc=barebox@lists.infradead.org \
/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