mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Riesch <michael.riesch@wolfvision.net>
To: barebox@lists.infradead.org
Cc: Michael Riesch <michael.riesch@wolfvision.net>
Subject: [PATCH] net: designware: rockchip: improve support for multiple gmac instances
Date: Mon,  7 Mar 2022 08:16:27 +0100	[thread overview]
Message-ID: <20220307071627.346527-1-michael.riesch@wolfvision.net> (raw)

Do not rely on (board-specific) aliases to distinguish between multiple
(SoC-specific) GMAC instances. Instead, use the base address of the
controllers as is done in the Linux kernel.

Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
---
 drivers/net/designware_rockchip.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/net/designware_rockchip.c b/drivers/net/designware_rockchip.c
index da57ed171..dcf65c9ad 100644
--- a/drivers/net/designware_rockchip.c
+++ b/drivers/net/designware_rockchip.c
@@ -21,6 +21,7 @@ struct rk_gmac_ops {
 	void (*set_rmii_speed)(struct eqos *eqos, int speed);
 	void (*set_rgmii_speed)(struct eqos *eqos, int speed);
 	void (*integrated_phy_powerup)(struct eqos *eqos);
+	u32 regs[];
 };
 
 struct eqos_rk_gmac {
@@ -174,6 +175,11 @@ static const struct rk_gmac_ops rk3568_ops = {
 	.set_to_rmii = rk3568_set_to_rmii,
 	.set_rmii_speed = rk3568_set_gmac_speed,
 	.set_rgmii_speed = rk3568_set_gmac_speed,
+	.regs = {
+		0xfe2a0000, /* gmac0 */
+		0xfe010000, /* gmac1 */
+		0x0, /* sentinel */
+	},
 };
 
 static int rk_gmac_powerup(struct eqos *eqos)
@@ -228,7 +234,7 @@ static int eqos_init_rk_gmac(struct device_d *dev, struct eqos *eqos)
 {
 	struct device_node *np = dev->device_node;
 	struct eqos_rk_gmac *priv = to_rk_gmac(eqos);
-	int ret;
+	int i = 0, ret;
 	const char *strings;
 
 	priv->dev = dev;
@@ -247,7 +253,15 @@ static int eqos_init_rk_gmac(struct device_d *dev, struct eqos *eqos)
 
 	priv->ops = device_get_match_data(dev);
 
-	priv->bus_id = of_alias_get_id(np, "ethernet");
+	if (dev->num_resources > 0) {
+		while (priv->ops->regs[i]) {
+			if (priv->ops->regs[i] == dev->resource[0].start) {
+				priv->bus_id = i;
+				break;
+			}
+			i++;
+		}
+	}
 
 	priv->grf = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
 	if (IS_ERR(priv->grf)) {
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2022-03-07  7:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07  7:16 Michael Riesch [this message]
2022-03-07  7:56 ` Sascha Hauer

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=20220307071627.346527-1-michael.riesch@wolfvision.net \
    --to=michael.riesch@wolfvision.net \
    --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