public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Chintan Vankar <c-vankar@ti.com>
To: Richard Genoud <richard.genoud@bootlin.com>,
	Sam Protsenko <semen.protsenko@linaro.org>,
	Santhosh Kumar K <s-k6@ti.com>,
	"Jonathan Humphreys" <j-humphreys@ti.com>,
	Mattijs Korpershoek <mkorpershoek@kernel.org>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Bhavya Kapoor <b-kapoor@ti.com>,
	Parth Pancholi <parth.pancholi@toradex.com>,
	Andreas Dannenberg <dannenberg@ti.com>,
	Moteen Shah <m-shah@ti.com>, "Beleswar Padhi" <b-padhi@ti.com>,
	Anshul Dalal <anshuld@ti.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>,
	Neha Malcom Francis <n-francis@ti.com>,
	"Prasanth Babu Mantena" <p-mantena@ti.com>,
	Wadim Egorov <w.egorov@phytec.de>,
	"Simon Glass" <sjg@chromium.org>,
	Alexander Sverdlin <alexander.sverdlin@siemens.com>,
	Siddharth Vadapalli <s-vadapalli@ti.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Chintan Vankar <c-vankar@ti.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Jayesh Choudhary <j-choudhary@ti.com>,
	Vaishnav Achath <vaishnav.a@ti.com>, Bryan Brattlof <bb@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Tom Rini <trini@konsulko.com>
Cc: <u-boot@lists.denx.de>
Subject: [PATCH v4 01/21] net: ti: am65-cpsw-nuss: Define bind method for CPSW driver
Date: Thu, 31 Jul 2025 13:29:36 +0530	[thread overview]
Message-ID: <20250731075956.605474-2-c-vankar@ti.com> (raw)
In-Reply-To: <20250731075956.605474-1-c-vankar@ti.com>

CPSW driver is defined as UCLASS_MISC driver which needs to be probed
explicitly. Define bind method for CPSW driver to scan and bind
ethernet-ports with UCLASS_ETH driver which will eventually probe CPSW
driver and avoid probing CPSW driver explicitly.

Signed-off-by: Chintan Vankar <c-vankar@ti.com>
---

Link to v3:
https://lore.kernel.org/u-boot/20250225114903.2080616-2-c-vankar@ti.com/

Changes from v3 to v4:
- Moved initialization part from "am65_cpsw_probe_nuss()" to
  "am65_cpsw_nuss_bind()" method.

 drivers/net/ti/am65-cpsw-nuss.c | 40 +++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c
index 9b69f36d04d..754076d807c 100644
--- a/drivers/net/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ti/am65-cpsw-nuss.c
@@ -705,7 +705,6 @@ static int am65_cpsw_probe_nuss(struct udevice *dev)
 	struct am65_cpsw_common *cpsw_common = dev_get_priv(dev);
 	ofnode ports_np, node;
 	int ret, i;
-	struct udevice *port_dev;
 
 	cpsw_common->dev = dev;
 	cpsw_common->ss_base = dev_read_addr(dev);
@@ -732,6 +731,7 @@ static int am65_cpsw_probe_nuss(struct udevice *dev)
 	ports_np = dev_read_subnode(dev, "ethernet-ports");
 	if (!ofnode_valid(ports_np)) {
 		ret = -ENOENT;
+		dev_err(dev, "Invalid device tree node %d\n", ret);
 		goto out;
 	}
 
@@ -763,12 +763,6 @@ static int am65_cpsw_probe_nuss(struct udevice *dev)
 			continue;
 
 		cpsw_common->ports[port_id].disabled = disabled;
-		if (disabled)
-			continue;
-
-		ret = device_bind_driver_to_node(dev, "am65_cpsw_nuss_port", ofnode_get_name(node), node, &port_dev);
-		if (ret)
-			dev_err(dev, "Failed to bind to %s node\n", ofnode_get_name(node));
 	}
 
 	for (i = 0; i < AM65_CPSW_CPSWNU_MAX_PORTS; i++) {
@@ -798,6 +792,37 @@ out:
 	return ret;
 }
 
+static int am65_cpsw_nuss_bind(struct udevice *dev)
+{
+	struct uclass_driver *drv;
+	struct udevice *port_dev;
+	ofnode ports_np, node;
+	int ret;
+
+	drv = lists_uclass_lookup(UCLASS_ETH);
+	if (!drv) {
+		puts("Cannot find eth driver");
+		return -ENOENT;
+	}
+
+	ports_np = dev_read_subnode(dev, "ethernet-ports");
+	if (!ofnode_valid(ports_np))
+		return -ENOENT;
+
+	ofnode_for_each_subnode(node, ports_np) {
+		const char *node_name;
+
+		node_name = ofnode_get_name(node);
+
+		ret = device_bind_driver_to_node(dev, "am65_cpsw_nuss_port", node_name, node,
+						 &port_dev);
+		if (ret)
+			dev_err(dev, "Failed to bind to %s node\n", node_name);
+	}
+
+	return ret;
+}
+
 static const struct udevice_id am65_cpsw_nuss_ids[] = {
 	{ .compatible = "ti,am654-cpsw-nuss" },
 	{ .compatible = "ti,j721e-cpsw-nuss" },
@@ -809,6 +834,7 @@ U_BOOT_DRIVER(am65_cpsw_nuss) = {
 	.name	= "am65_cpsw_nuss",
 	.id	= UCLASS_MISC,
 	.of_match = am65_cpsw_nuss_ids,
+	.bind	= am65_cpsw_nuss_bind,
 	.probe	= am65_cpsw_probe_nuss,
 	.priv_auto = sizeof(struct am65_cpsw_common),
 };
-- 
2.34.1


  reply	other threads:[~2025-07-31  8:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-31  7:59 [PATCH v4 00/21] Add support for Ethernet boot Chintan Vankar
2025-07-31  7:59 ` Chintan Vankar [this message]
2025-11-21 12:55   ` [PATCH v4 01/21] net: ti: am65-cpsw-nuss: Define bind method for CPSW driver Wadim Egorov
2025-11-21 13:24     ` Siddharth Vadapalli
2025-07-31  7:59 ` [PATCH v4 02/21] arch: mach-k3: common: Remove explicit probing of " Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 03/21] Revert "mach-k3: am642_init: Probe AM65 CPSW NUSS for R5/A53 SPL" Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 04/21] Revert "arm: mach-k3: am62x: am625_init: Probe AM65 CPSW NUSS" Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 05/21] arm: mach-k3: j721s2: Update SoC auto-gen data to enable Ethernet boot Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 06/21] arm: mach-k3: j721s2_spl: Alias Ethernet boot to CPGMAC Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 07/21] net: ti: Kconfig: Enable SPL_SYSCON config for CPSW Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 08/21] configs: am68_sk_r5_ethboot: Add configs for enabling Ethernet boot in R5SPL Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 09/21] configs: am68_sk_a72_ethboot: Enable configs required for Ethernet boot Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 10/21] arm: mach-k3: am62p: Update SoC auto-gen data to enable " Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 11/21] board: ti: am62px: evm: Enable cache for AM62p Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 12/21] configs: am62px_evm_r5_ethboot: Add configs to enable Ethernet boot in R5SPL Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 13/21] configs: am62px_evm_a53_ethboot: Enable configs required for Ethboot Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 14/21] arm: mach-k3: j722s: Update SoC autogenerated data to enable Ethernet boot Chintan Vankar
2025-11-21 16:08   ` Michael Walle
2025-07-31  7:59 ` [PATCH v4 15/21] board: ti: j722s: evm: Enable cache for J722s Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 16/21] configs: j722s_evm_r5_ethboot: Add configs to enable Ethernet boot in R5SPL Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 17/21] configs: j722s_evm_a53_ethboot: Enable configs required for Ethernet boot Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 18/21] arm: mach-k3: j784s4: Update SoC auto-gen data to enable " Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 19/21] arm: mach-k3: j784s4_spl: Alias Ethernet boot to CPGMAC Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 20/21] configs: am69_sk_r5_ethboot: Add configs to enable Ethernet boot in R5SPL Chintan Vankar
2025-07-31  7:59 ` [PATCH v4 21/21] configs: am69_sk_a72_ethboot: Add configs to enable Ethernet boot Chintan Vankar
2025-08-20 18:41 ` [PATCH v4 00/21] Add support for " Tom Rini

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=20250731075956.605474-2-c-vankar@ti.com \
    --to=c-vankar@ti.com \
    --cc=alexander.sverdlin@siemens.com \
    --cc=anshuld@ti.com \
    --cc=b-kapoor@ti.com \
    --cc=b-padhi@ti.com \
    --cc=bb@ti.com \
    --cc=dannenberg@ti.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=j-choudhary@ti.com \
    --cc=j-humphreys@ti.com \
    --cc=joe.hershberger@ni.com \
    --cc=kishon@ti.com \
    --cc=m-shah@ti.com \
    --cc=mkorpershoek@kernel.org \
    --cc=n-francis@ti.com \
    --cc=p-mantena@ti.com \
    --cc=parth.pancholi@toradex.com \
    --cc=rfried.dev@gmail.com \
    --cc=richard.genoud@bootlin.com \
    --cc=s-k6@ti.com \
    --cc=s-vadapalli@ti.com \
    --cc=semen.protsenko@linaro.org \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=vaishnav.a@ti.com \
    --cc=vigneshr@ti.com \
    --cc=w.egorov@phytec.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