Re: [PATCH v4 01/21] net: ti: am65-cpsw-nuss: Define bind method for CPSW driver

Wadim Egorov
2025-11-21T12:56:52Z

Hi,

On 7/31/25 10:59 AM, Chintan Vankar wrote:
> 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.

I just noticed a new error message with this patch.

On the phycore-am64x we can see that the 2nd cpsw port is getting probed
but fails. This is not really an Issue because we are not making use of
the 2nd port. But the error message does not look nice.

Why is this even probed? The soc-level device tree disables the ports
per default. And we do not activate it in our device tree.

U-Boot 2025.10-rc1-00085-git (Nov 21 2025 - 14:48:38 +0200)

SoC: AM64X SR2.0 HS-FS
Model: PHYTEC phyBOARD-Electra-AM64x RDK
DRAM: 2 GiB
I/TC: Reserved shared memory is enabled
I/TC: Dynamic shared memory is enabled
I/TC: Normal World virtualization support is disabled
I/TC: Asynchronous notifications are disabled
Core: 89 devices, 35 uclasses, devicetree: separate
MMC: mmc@fa10000: 0, mmc@fa00000: 1
Loading Environment from MMC... Reading from MMC(1)... OK
In: serial@2800000
Out: serial@2800000
Err: serial@2800000
Net: eth0: ethernet@8000000port@1am65_cpsw_nuss_port
ethernet@8000000port@2: Invalid PHY mode, port 2

Hit any key to stop autoboot: 0
=>

Regards,
Wadim

>
> 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),
> };