mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: designware: rockchip: improve support for multiple gmac instances
@ 2022-03-07  7:16 Michael Riesch
  2022-03-07  7:56 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Riesch @ 2022-03-07  7:16 UTC (permalink / raw)
  To: barebox; +Cc: Michael Riesch

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-07  7:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07  7:16 [PATCH] net: designware: rockchip: improve support for multiple gmac instances Michael Riesch
2022-03-07  7:56 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox