public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: u-boot@lists.denx.de
Cc: joe.hershberger@ni.com, rfried.dev@gmail.com, marex@denx.de,
	cstevens@beaconembedded.com, aford@beaconembedded.com,
	Adam Ford <aford173@gmail.com>
Subject: [PATCH 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid
Date: Sun, 20 Feb 2022 15:45:20 -0600	[thread overview]
Message-ID: <20220220214522.862224-1-aford173@gmail.com> (raw)

Some boards like the Beacon RZ/G2 SOM use either flags for
tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid.

In Linux the APSR_RDM flag is set when either rx-internal-delay-ps
is set or the mode is rgmii-rxid, and the APSR_TDM is set when
tx-internal-delay-ps is found or rgmii-txid is set, and both
are set if rgmii-id is set.

The ravb driver in U-Boot driver was missing rgmii-rxid support,
so add that support in a similar fashion to what is done in Linux.

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 1d1118c341..9e09e998e3 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -52,6 +52,7 @@
 #define CSR_OPS			0x0000000F
 #define CSR_OPS_CONFIG		BIT(1)
 
+#define APSR_RDM		BIT(13)
 #define APSR_TDM		BIT(14)
 
 #define TCCR_TSRQ0		BIT(0)
@@ -376,6 +377,8 @@ static int ravb_dmac_init(struct udevice *dev)
 	struct ravb_priv *eth = dev_get_priv(dev);
 	struct eth_pdata *pdata = dev_get_plat(dev);
 	int ret = 0;
+	int mode = 0;
+	unsigned int delay;
 
 	/* Set CONFIG mode */
 	ret = ravb_reset(dev);
@@ -402,9 +405,25 @@ static int ravb_dmac_init(struct udevice *dev)
 	    (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995))
 		return 0;
 
-	if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) ||
-	    (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID))
-		writel(APSR_TDM, eth->iobase + RAVB_REG_APSR);
+	if (!dev_read_u32(dev, "tx-internal-delay-ps", &delay)) {
+		if (delay)
+			mode |= APSR_TDM;
+	}
+
+	if (!dev_read_u32(dev, "rx-internal-delay-ps", &delay)) {
+		if (delay)
+			mode |= APSR_RDM;
+	}
+
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+	    pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID)
+		mode |= APSR_RDM;
+
+	if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID ||
+	    pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)
+		mode |= APSR_TDM;
+
+	writel(mode, eth->iobase + RAVB_REG_APSR);
 
 	return 0;
 }
-- 
2.32.0


             reply	other threads:[~2022-02-20 21:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-20 21:45 Adam Ford [this message]
2022-02-20 21:45 ` [PATCH 2/2] arm: rmobile: rzg2_beacon: Enable proper Ethernet PHY Adam Ford
2022-02-20 23:58 ` [PATCH 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Marek Vasut
2022-02-21  1:45   ` Adam Ford
2022-02-25  4:25     ` Marek Vasut

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=20220220214522.862224-1-aford173@gmail.com \
    --to=aford173@gmail.com \
    --cc=aford@beaconembedded.com \
    --cc=cstevens@beaconembedded.com \
    --cc=joe.hershberger@ni.com \
    --cc=marex@denx.de \
    --cc=rfried.dev@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