public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Chris Packham <judge.packham@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] net: mv88e61xx: add configuration for RGMII delay
Date: Mon, 25 Jun 2018 22:34:56 +1200	[thread overview]
Message-ID: <20180625103457.8674-1-judge.packham@gmail.com> (raw)

Some hardware designs connect a CPU MAC directly to the RGMII interface
of a mv88e61xx device. On such devices a delay on the RX/TX lines is
required, this can either be achieved by adding extra length to the
traces on the PCB or by implementing the delay in silicon. This is
an implementation of the latter.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
---

 drivers/net/phy/Kconfig     |  4 ++++
 drivers/net/phy/mv88e61xx.c | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index f5821dfed96d..98cd57eea977 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -59,6 +59,10 @@ config MV88E61XX_PHY_PORTS
 config MV88E61XX_FIXED_PORTS
 	hex "Bitmask of PHYless serdes Ports"
 
+config MV88E61XX_RGMII_DELAY
+	bool "Add delay to RGMII outputs"
+	default n
+
 endif # MV88E61XX_SWITCH
 
 config PHYLIB_10G
diff --git a/drivers/net/phy/mv88e61xx.c b/drivers/net/phy/mv88e61xx.c
index ea54a1531053..d258ba1ef0f3 100644
--- a/drivers/net/phy/mv88e61xx.c
+++ b/drivers/net/phy/mv88e61xx.c
@@ -69,6 +69,7 @@
 #define PORT_REG_CTRL			0x04
 #define PORT_REG_VLAN_MAP		0x06
 #define PORT_REG_VLAN_ID		0x07
+#define PORT_REG_RGMII_TIMING		0x1A
 
 /* Phy registers */
 #define PHY_REG_CTRL1			0x10
@@ -122,6 +123,9 @@
 #define PORT_REG_VLAN_MAP_TABLE_SHIFT	0
 #define PORT_REG_VLAN_MAP_TABLE_WIDTH	11
 
+#define PORT_REG_RGMII_TIMING_RX_DELAY	BIT(10)
+#define PORT_REG_RGMII_TIMING_TX_DELAY	BIT(9)
+
 #define SERDES_REG_CTRL_1_FORCE_LINK	BIT(10)
 
 #define PHY_REG_CTRL1_ENERGY_DET_SHIFT	8
@@ -705,6 +709,24 @@ unforce:
 	return res;
 }
 
+static int mv88e61xx_rgmii_timing_cfg(struct phy_device *phydev)
+{
+#ifdef CONFIG_MV88E61XX_RGMII_DELAY
+	int val;
+
+	val = mv88e61xx_port_read(phydev, 6, PORT_REG_RGMII_TIMING);
+	if (val < 0)
+		return val;
+
+	val |= PORT_REG_RGMII_TIMING_RX_DELAY |
+	       PORT_REG_RGMII_TIMING_TX_DELAY;
+
+	return mv88e61xx_port_write(phydev, 6, PORT_REG_RGMII_TIMING, val);
+#else
+	return 0;
+#endif
+}
+
 static int mv88e61xx_fixed_port_setup(struct phy_device *phydev, u8 port)
 {
 	int val;
@@ -774,6 +796,10 @@ static int mv88e61xx_set_cpu_port(struct phy_device *phydev)
 				return val;
 		}
 	} else {
+		val = mv88e61xx_rgmii_timing_cfg(phydev);
+		if (val < 0)
+			return val;
+
 		val = mv88e61xx_fixed_port_setup(phydev,
 						 CONFIG_MV88E61XX_CPU_PORT);
 		if (val < 0)
-- 
2.18.0

             reply	other threads:[~2018-06-25 10:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25 10:34 Chris Packham [this message]
2018-06-25 10:34 ` [U-Boot] [PATCH 2/2] ARM: kirkwood: add SBx81LIFXCAT board Chris Packham
2018-06-25 18:09 ` [U-Boot] [PATCH 1/2] net: mv88e61xx: add configuration for RGMII delay Joe Hershberger
2018-06-26 10:34   ` Chris Packham
2018-06-26 14:25     ` Joe Hershberger
2018-06-27  7:38       ` Chris Packham

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=20180625103457.8674-1-judge.packham@gmail.com \
    --to=judge.packham@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