All of lore.kernel.org
 help / color / mirror / Atom feed
From: Parvathi Pudi <parvathi@couthit.com>
To: Bastien Curutchet <bastien.curutchet@bootlin.com>
Cc: pratheesh <pratheesh@ti.com>,
	Vignesh Raghavendra <vigneshr@ti.com>, praneeth <praneeth@ti.com>,
	edumazet <edumazet@google.com>, glaroque <glaroque@baylibre.com>,
	pmohan <pmohan@couthit.com>, diogo ivo <diogo.ivo@siemens.com>,
	robh <robh@kernel.org>,
	javier carrasco cruz <javier.carrasco.cruz@gmail.com>,
	saikrishnag <saikrishnag@marvell.com>,
	m-karicheri2 <m-karicheri2@ti.com>,
	jacob e keller <jacob.e.keller@intel.com>, kuba <kuba@kernel.org>,
	pabeni <pabeni@redhat.com>,
	richardcochran <richardcochran@gmail.com>,
	devicetree <devicetree@vger.kernel.org>,
	conor+dt <conor+dt@kernel.org>, mohan <mohan@couthit.com>,
	s hauer <s.hauer@pengutronix.de>,
	Prajith Jayarajan <prajith@ti.com>, rogerq <rogerq@kernel.org>,
	basharath <basharath@couthit.com>, ssantosh <ssantosh@kernel.org>,
	Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	rogerq <rogerq@ti.com>, srk <srk@ti.com>,
	kory maincent <kory.maincent@bootlin.com>,
	m-malladi <m-malladi@ti.com>, netdev <netdev@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	danishanwar <danishanwar@ti.com>, afd <afd@ti.com>,
	andrew+netdev <andrew+netdev@lunn.ch>,
	parvathi <parvathi@couthit.com>, horms <horms@kernel.org>,
	krishna <krishna@couthit.com>, krzk+dt <krzk+dt@kernel.org>,
	davem <davem@davemloft.net>
Subject: Re: [PATCH net-next v12 2/5] net: ti: prueth: Adds ICSSM Ethernet driver
Date: Mon, 11 Aug 2025 15:44:48 +0530 (IST)	[thread overview]
Message-ID: <202602590.150020.1754907288322.JavaMail.zimbra@couthit.local> (raw)
In-Reply-To: <f979f4ef-53b6-418b-b1d2-1bc733feba9b@bootlin.com>

Hi,
 
> On 7/24/25 9:23 AM, Parvathi Pudi wrote:
>> From: Roger Quadros <rogerq@ti.com>
>> 
>> Updates Kernel configuration to enable PRUETH driver and its dependencies
>> along with makefile changes to add the new PRUETH driver.
>> 
>> Changes includes init and deinit of ICSSM PRU Ethernet driver including
>> net dev registration and firmware loading for DUAL-MAC mode running on
>> PRU-ICSS2 instance.
>> 
>> Changes also includes link handling, PRU booting, default firmware loading
>> and PRU stopping using existing remoteproc driver APIs.
>> 
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> Signed-off-by: Andrew F. Davis <afd@ti.com>
>> Signed-off-by: Basharath Hussain Khaja <basharath@couthit.com>
>> Signed-off-by: Parvathi Pudi <parvathi@couthit.com>
>> ---
>>   drivers/net/ethernet/ti/Kconfig              |  12 +
>>   drivers/net/ethernet/ti/Makefile             |   3 +
>>   drivers/net/ethernet/ti/icssm/icssm_prueth.c | 610 +++++++++++++++++++
>>   drivers/net/ethernet/ti/icssm/icssm_prueth.h | 100 +++
>>   4 files changed, 725 insertions(+)
>>   create mode 100644 drivers/net/ethernet/ti/icssm/icssm_prueth.c
>>   create mode 100644 drivers/net/ethernet/ti/icssm/icssm_prueth.h
>> 
>> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
>> index a07c910c497a..ab20f22524cb 100644
>> --- a/drivers/net/ethernet/ti/Kconfig
>> +++ b/drivers/net/ethernet/ti/Kconfig
>> @@ -229,4 +229,16 @@ config TI_ICSS_IEP
>>   	  To compile this driver as a module, choose M here. The module
>>   	  will be called icss_iep.
>>   
>> +config TI_PRUETH
>> +	tristate "TI PRU Ethernet EMAC driver"
>> +	depends on PRU_REMOTEPROC
>> +	depends on NET_SWITCHDEV
>> +	select TI_ICSS_IEP
>> +	imply PTP_1588_CLOCK
>> +	help
>> +	  Some TI SoCs has Programmable Realtime Units (PRUs) cores which can
>> +	  support Single or Dual Ethernet ports with help of firmware code running
>> +	  on PRU cores. This driver supports remoteproc based communication to
>> +	  PRU firmware to expose ethernet interface to Linux.
>> +
>>   endif # NET_VENDOR_TI
>> diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
>> index cbcf44806924..93c0a4d0e33a 100644
>> --- a/drivers/net/ethernet/ti/Makefile
>> +++ b/drivers/net/ethernet/ti/Makefile
>> @@ -3,6 +3,9 @@
>>   # Makefile for the TI network device drivers.
>>   #
>>   
>> +obj-$(CONFIG_TI_PRUETH) += icssm-prueth.o
>> +icssm-prueth-y := icssm/icssm_prueth.o
>> +
>>   obj-$(CONFIG_TI_CPSW) += cpsw-common.o
>>   obj-$(CONFIG_TI_DAVINCI_EMAC) += cpsw-common.o
>>   obj-$(CONFIG_TI_CPSW_SWITCHDEV) += cpsw-common.o
>> diff --git a/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> new file mode 100644
>> index 000000000000..375fd636684d
>> --- /dev/null
>> +++ b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> @@ -0,0 +1,610 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +/* Texas Instruments ICSSM Ethernet Driver
>> + *
>> + * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
>> + *
>> + */
>> +
>> +#include <linux/etherdevice.h>
>> +#include <linux/genalloc.h>
>> +#include <linux/if_bridge.h>
>> +#include <linux/if_hsr.h>
>> +#include <linux/if_vlan.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/kernel.h>
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/module.h>
>> +#include <linux/net_tstamp.h>
>> +#include <linux/of.h>
>> +#include <linux/of_irq.h>
>> +#include <linux/of_mdio.h>
>> +#include <linux/of_net.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/phy.h>
>> +#include <linux/remoteproc/pruss.h>
>> +#include <linux/ptp_classify.h>
>> +#include <linux/regmap.h>
>> +#include <linux/remoteproc.h>
>> +#include <net/pkt_cls.h>
>> +
>> +#include "icssm_prueth.h"
>> +
>> +/* called back by PHY layer if there is change in link state of hw port*/
>> +static void icssm_emac_adjust_link(struct net_device *ndev)
>> +{
>> +	struct prueth_emac *emac = netdev_priv(ndev);
>> +	struct phy_device *phydev = emac->phydev;
>> +	bool new_state = false;
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&emac->lock, flags);
>> +
>> +	if (phydev->link) {
>> +		/* check the mode of operation */
>> +		if (phydev->duplex != emac->duplex) {
>> +			new_state = true;
>> +			emac->duplex = phydev->duplex;
>> +		}
>> +		if (phydev->speed != emac->speed) {
>> +			new_state = true;
>> +			emac->speed = phydev->speed;
>> +		}
>> +		if (!emac->link) {
>> +			new_state = true;
>> +			emac->link = 1;
>> +		}
>> +	} else if (emac->link) {
>> +		new_state = true;
>> +		emac->link = 0;
>> +	}
>> +
>> +	if (new_state)
>> +		phy_print_status(phydev);
>> +
>> +	if (emac->link) {
>> +	       /* reactivate the transmit queue if it is stopped */
>> +		if (netif_running(ndev) && netif_queue_stopped(ndev))
>> +			netif_wake_queue(ndev);
>> +	} else {
>> +		if (!netif_queue_stopped(ndev))
>> +			netif_stop_queue(ndev);
>> +	}
>> +
>> +	spin_unlock_irqrestore(&emac->lock, flags);
>> +}
>> +
>> +static int icssm_emac_set_boot_pru(struct prueth_emac *emac,
>> +				   struct net_device *ndev)
>> +{
>> +	const struct prueth_firmware *pru_firmwares;
>> +	struct prueth *prueth = emac->prueth;
>> +	const char *fw_name;
>> +	int ret;
>> +
>> +	pru_firmwares = &prueth->fw_data->fw_pru[emac->port_id - 1];
>> +	fw_name = pru_firmwares->fw_name[prueth->eth_type];
>> +	if (!fw_name) {
>> +		netdev_err(ndev, "eth_type %d not supported\n",
>> +			   prueth->eth_type);
>> +		return -ENODEV;
>> +	}
>> +
>> +	ret = rproc_set_firmware(emac->pru, fw_name);
>> +	if (ret) {
>> +		netdev_err(ndev, "failed to set PRU0 firmware %s: %d\n",
>> +			   fw_name, ret);
>> +		return ret;
>> +	}
>> +
>> +	ret = rproc_boot(emac->pru);
>> +	if (ret) {
>> +		netdev_err(ndev, "failed to boot PRU0: %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +/**
>> + * icssm_emac_ndo_open - EMAC device open
>> + * @ndev: network adapter device
>> + *
>> + * Called when system wants to start the interface.
>> + *
>> + * Return: 0 for a successful open, or appropriate error code
>> + */
>> +static int icssm_emac_ndo_open(struct net_device *ndev)
>> +{
>> +	struct prueth_emac *emac = netdev_priv(ndev);
>> +	int ret;
>> +
>> +	ret = icssm_emac_set_boot_pru(emac, ndev);
>> +	if (ret)
>> +		return ret;
>> +
>> +	/* start PHY */
>> +	phy_start(emac->phydev);
>> +
>> +	return 0;
>> +}
>> +
>> +/**
>> + * icssm_emac_ndo_stop - EMAC device stop
>> + * @ndev: network adapter device
>> + *
>> + * Called when system wants to stop or down the interface.
>> + *
>> + * Return: Always 0 (Success)
>> + */
>> +static int icssm_emac_ndo_stop(struct net_device *ndev)
>> +{
>> +	struct prueth_emac *emac = netdev_priv(ndev);
>> +
>> +	/* stop PHY */
>> +	phy_stop(emac->phydev);
>> +
>> +	rproc_shutdown(emac->pru);
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct net_device_ops emac_netdev_ops = {
>> +	.ndo_open = icssm_emac_ndo_open,
>> +	.ndo_stop = icssm_emac_ndo_stop,
>> +};
>> +
>> +/* get emac_port corresponding to eth_node name */
>> +static int icssm_prueth_node_port(struct device_node *eth_node)
>> +{
>> +	u32 port_id;
>> +	int ret;
>> +
>> +	ret = of_property_read_u32(eth_node, "reg", &port_id);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if (port_id == 0)
>> +		return PRUETH_PORT_MII0;
>> +	else if (port_id == 1)
>> +		return PRUETH_PORT_MII1;
>> +	else
>> +		return PRUETH_PORT_INVALID;
>> +}
>> +
>> +/* get MAC instance corresponding to eth_node name */
>> +static int icssm_prueth_node_mac(struct device_node *eth_node)
>> +{
>> +	u32 port_id;
>> +	int ret;
>> +
>> +	ret = of_property_read_u32(eth_node, "reg", &port_id);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if (port_id == 0)
>> +		return PRUETH_MAC0;
>> +	else if (port_id == 1)
>> +		return PRUETH_MAC1;
>> +	else
>> +		return PRUETH_MAC_INVALID;
>> +}
>> +
>> +static int icssm_prueth_netdev_init(struct prueth *prueth,
>> +				    struct device_node *eth_node)
>> +{
>> +	struct prueth_emac *emac;
>> +	struct net_device *ndev;
>> +	enum prueth_port port;
>> +	enum prueth_mac mac;
>> +	int ret;
>> +
>> +	port = icssm_prueth_node_port(eth_node);
>> +	if (port == PRUETH_PORT_INVALID)
>> +		return -EINVAL;
>> +
>> +	mac = icssm_prueth_node_mac(eth_node);
>> +	if (mac == PRUETH_MAC_INVALID)
>> +		return -EINVAL;
>> +
>> +	ndev = devm_alloc_etherdev(prueth->dev, sizeof(*emac));
>> +	if (!ndev)
>> +		return -ENOMEM;
>> +
>> +	SET_NETDEV_DEV(ndev, prueth->dev);
>> +	emac = netdev_priv(ndev);
>> +	prueth->emac[mac] = emac;
>> +	emac->prueth = prueth;
>> +	emac->ndev = ndev;
>> +	emac->port_id = port;
>> +
>> +	/* by default eth_type is EMAC */
>> +	switch (port) {
>> +	case PRUETH_PORT_MII0:
>> +		emac->pru = prueth->pru0;
>> +		break;
>> +	case PRUETH_PORT_MII1:
>> +		emac->pru = prueth->pru1;
>> +		break;
>> +	default:
>> +		return -EINVAL;
>> +	}
>> +	/* get mac address from DT and set private and netdev addr */
>> +	ret = of_get_ethdev_address(eth_node, ndev);
>> +	if (!is_valid_ether_addr(ndev->dev_addr)) {
>> +		eth_hw_addr_random(ndev);
>> +		dev_warn(prueth->dev, "port %d: using random MAC addr: %pM\n",
>> +			 port, ndev->dev_addr);
>> +	}
>> +	ether_addr_copy(emac->mac_addr, ndev->dev_addr);
>> +
>> +	/* connect PHY */
>> +	emac->phydev = of_phy_get_and_connect(ndev, eth_node,
>> +					      icssm_emac_adjust_link);
>> +	if (!emac->phydev) {
>> +		dev_dbg(prueth->dev, "PHY connection failed\n");
>> +		ret = -EPROBE_DEFER;
>> +		goto free;
>> +	}
>> +
>> +	/* remove unsupported modes */
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
>> +
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
>> +
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_Pause_BIT);
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_Asym_Pause_BIT);
>> +
>> +	ndev->netdev_ops = &emac_netdev_ops;
>> +
> 
> I think ndev->dev.of_node should be set to eth_node here.
> 
> If ndev->dev.of_node isn't set, of_find_net_device_by_node() won't find
> the iccsm_prueth ports and their of_node won't be available in sysfs
> (which, in my case, leads to issues during the probe of a switch
> connected to them)
> 

We will add the below line in icssm_prueth_netdev_init() function to
resolve the issue.

ndev->dev.of_node = eth_node;

We will add it in the next version.


Thanks and Regards,
Parvathi.






WARNING: multiple messages have this Message-ID (diff)
From: Parvathi Pudi <parvathi@couthit.com>
To: Bastien Curutchet <bastien.curutchet@bootlin.com>
Cc: parvathi <parvathi@couthit.com>, danishanwar <danishanwar@ti.com>,
	 rogerq <rogerq@kernel.org>,
	andrew+netdev <andrew+netdev@lunn.ch>,
	 davem <davem@davemloft.net>, edumazet <edumazet@google.com>,
	 kuba <kuba@kernel.org>, pabeni <pabeni@redhat.com>,
	 robh <robh@kernel.org>, krzk+dt <krzk+dt@kernel.org>,
	 conor+dt <conor+dt@kernel.org>, ssantosh <ssantosh@kernel.org>,
	 richardcochran <richardcochran@gmail.com>,
	 s hauer <s.hauer@pengutronix.de>,
	m-karicheri2 <m-karicheri2@ti.com>,
	 glaroque <glaroque@baylibre.com>, afd <afd@ti.com>,
	 saikrishnag <saikrishnag@marvell.com>,
	m-malladi <m-malladi@ti.com>,
	 jacob e keller <jacob.e.keller@intel.com>,
	 kory maincent <kory.maincent@bootlin.com>,
	 diogo ivo <diogo.ivo@siemens.com>,
	 javier carrasco cruz <javier.carrasco.cruz@gmail.com>,
	 horms <horms@kernel.org>, s-anna <s-anna@ti.com>,
	 basharath <basharath@couthit.com>,
	 linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	 netdev <netdev@vger.kernel.org>,
	 devicetree <devicetree@vger.kernel.org>,
	 linux-kernel <linux-kernel@vger.kernel.org>,
	 Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	 pratheesh <pratheesh@ti.com>, Prajith Jayarajan <prajith@ti.com>,
	 Vignesh Raghavendra <vigneshr@ti.com>,
	praneeth <praneeth@ti.com>,  srk <srk@ti.com>,
	rogerq <rogerq@ti.com>,  krishna <krishna@couthit.com>,
	pmohan <pmohan@couthit.com>,  mohan <mohan@couthit.com>
Subject: Re: [PATCH net-next v12 2/5] net: ti: prueth: Adds ICSSM Ethernet driver
Date: Mon, 11 Aug 2025 15:44:48 +0530 (IST)	[thread overview]
Message-ID: <202602590.150020.1754907288322.JavaMail.zimbra@couthit.local> (raw)
In-Reply-To: <f979f4ef-53b6-418b-b1d2-1bc733feba9b@bootlin.com>

Hi,
 
> On 7/24/25 9:23 AM, Parvathi Pudi wrote:
>> From: Roger Quadros <rogerq@ti.com>
>> 
>> Updates Kernel configuration to enable PRUETH driver and its dependencies
>> along with makefile changes to add the new PRUETH driver.
>> 
>> Changes includes init and deinit of ICSSM PRU Ethernet driver including
>> net dev registration and firmware loading for DUAL-MAC mode running on
>> PRU-ICSS2 instance.
>> 
>> Changes also includes link handling, PRU booting, default firmware loading
>> and PRU stopping using existing remoteproc driver APIs.
>> 
>> Signed-off-by: Roger Quadros <rogerq@ti.com>
>> Signed-off-by: Andrew F. Davis <afd@ti.com>
>> Signed-off-by: Basharath Hussain Khaja <basharath@couthit.com>
>> Signed-off-by: Parvathi Pudi <parvathi@couthit.com>
>> ---
>>   drivers/net/ethernet/ti/Kconfig              |  12 +
>>   drivers/net/ethernet/ti/Makefile             |   3 +
>>   drivers/net/ethernet/ti/icssm/icssm_prueth.c | 610 +++++++++++++++++++
>>   drivers/net/ethernet/ti/icssm/icssm_prueth.h | 100 +++
>>   4 files changed, 725 insertions(+)
>>   create mode 100644 drivers/net/ethernet/ti/icssm/icssm_prueth.c
>>   create mode 100644 drivers/net/ethernet/ti/icssm/icssm_prueth.h
>> 
>> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
>> index a07c910c497a..ab20f22524cb 100644
>> --- a/drivers/net/ethernet/ti/Kconfig
>> +++ b/drivers/net/ethernet/ti/Kconfig
>> @@ -229,4 +229,16 @@ config TI_ICSS_IEP
>>   	  To compile this driver as a module, choose M here. The module
>>   	  will be called icss_iep.
>>   
>> +config TI_PRUETH
>> +	tristate "TI PRU Ethernet EMAC driver"
>> +	depends on PRU_REMOTEPROC
>> +	depends on NET_SWITCHDEV
>> +	select TI_ICSS_IEP
>> +	imply PTP_1588_CLOCK
>> +	help
>> +	  Some TI SoCs has Programmable Realtime Units (PRUs) cores which can
>> +	  support Single or Dual Ethernet ports with help of firmware code running
>> +	  on PRU cores. This driver supports remoteproc based communication to
>> +	  PRU firmware to expose ethernet interface to Linux.
>> +
>>   endif # NET_VENDOR_TI
>> diff --git a/drivers/net/ethernet/ti/Makefile b/drivers/net/ethernet/ti/Makefile
>> index cbcf44806924..93c0a4d0e33a 100644
>> --- a/drivers/net/ethernet/ti/Makefile
>> +++ b/drivers/net/ethernet/ti/Makefile
>> @@ -3,6 +3,9 @@
>>   # Makefile for the TI network device drivers.
>>   #
>>   
>> +obj-$(CONFIG_TI_PRUETH) += icssm-prueth.o
>> +icssm-prueth-y := icssm/icssm_prueth.o
>> +
>>   obj-$(CONFIG_TI_CPSW) += cpsw-common.o
>>   obj-$(CONFIG_TI_DAVINCI_EMAC) += cpsw-common.o
>>   obj-$(CONFIG_TI_CPSW_SWITCHDEV) += cpsw-common.o
>> diff --git a/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> new file mode 100644
>> index 000000000000..375fd636684d
>> --- /dev/null
>> +++ b/drivers/net/ethernet/ti/icssm/icssm_prueth.c
>> @@ -0,0 +1,610 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +
>> +/* Texas Instruments ICSSM Ethernet Driver
>> + *
>> + * Copyright (C) 2018-2022 Texas Instruments Incorporated - https://www.ti.com/
>> + *
>> + */
>> +
>> +#include <linux/etherdevice.h>
>> +#include <linux/genalloc.h>
>> +#include <linux/if_bridge.h>
>> +#include <linux/if_hsr.h>
>> +#include <linux/if_vlan.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/kernel.h>
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/module.h>
>> +#include <linux/net_tstamp.h>
>> +#include <linux/of.h>
>> +#include <linux/of_irq.h>
>> +#include <linux/of_mdio.h>
>> +#include <linux/of_net.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/phy.h>
>> +#include <linux/remoteproc/pruss.h>
>> +#include <linux/ptp_classify.h>
>> +#include <linux/regmap.h>
>> +#include <linux/remoteproc.h>
>> +#include <net/pkt_cls.h>
>> +
>> +#include "icssm_prueth.h"
>> +
>> +/* called back by PHY layer if there is change in link state of hw port*/
>> +static void icssm_emac_adjust_link(struct net_device *ndev)
>> +{
>> +	struct prueth_emac *emac = netdev_priv(ndev);
>> +	struct phy_device *phydev = emac->phydev;
>> +	bool new_state = false;
>> +	unsigned long flags;
>> +
>> +	spin_lock_irqsave(&emac->lock, flags);
>> +
>> +	if (phydev->link) {
>> +		/* check the mode of operation */
>> +		if (phydev->duplex != emac->duplex) {
>> +			new_state = true;
>> +			emac->duplex = phydev->duplex;
>> +		}
>> +		if (phydev->speed != emac->speed) {
>> +			new_state = true;
>> +			emac->speed = phydev->speed;
>> +		}
>> +		if (!emac->link) {
>> +			new_state = true;
>> +			emac->link = 1;
>> +		}
>> +	} else if (emac->link) {
>> +		new_state = true;
>> +		emac->link = 0;
>> +	}
>> +
>> +	if (new_state)
>> +		phy_print_status(phydev);
>> +
>> +	if (emac->link) {
>> +	       /* reactivate the transmit queue if it is stopped */
>> +		if (netif_running(ndev) && netif_queue_stopped(ndev))
>> +			netif_wake_queue(ndev);
>> +	} else {
>> +		if (!netif_queue_stopped(ndev))
>> +			netif_stop_queue(ndev);
>> +	}
>> +
>> +	spin_unlock_irqrestore(&emac->lock, flags);
>> +}
>> +
>> +static int icssm_emac_set_boot_pru(struct prueth_emac *emac,
>> +				   struct net_device *ndev)
>> +{
>> +	const struct prueth_firmware *pru_firmwares;
>> +	struct prueth *prueth = emac->prueth;
>> +	const char *fw_name;
>> +	int ret;
>> +
>> +	pru_firmwares = &prueth->fw_data->fw_pru[emac->port_id - 1];
>> +	fw_name = pru_firmwares->fw_name[prueth->eth_type];
>> +	if (!fw_name) {
>> +		netdev_err(ndev, "eth_type %d not supported\n",
>> +			   prueth->eth_type);
>> +		return -ENODEV;
>> +	}
>> +
>> +	ret = rproc_set_firmware(emac->pru, fw_name);
>> +	if (ret) {
>> +		netdev_err(ndev, "failed to set PRU0 firmware %s: %d\n",
>> +			   fw_name, ret);
>> +		return ret;
>> +	}
>> +
>> +	ret = rproc_boot(emac->pru);
>> +	if (ret) {
>> +		netdev_err(ndev, "failed to boot PRU0: %d\n", ret);
>> +		return ret;
>> +	}
>> +
>> +	return ret;
>> +}
>> +
>> +/**
>> + * icssm_emac_ndo_open - EMAC device open
>> + * @ndev: network adapter device
>> + *
>> + * Called when system wants to start the interface.
>> + *
>> + * Return: 0 for a successful open, or appropriate error code
>> + */
>> +static int icssm_emac_ndo_open(struct net_device *ndev)
>> +{
>> +	struct prueth_emac *emac = netdev_priv(ndev);
>> +	int ret;
>> +
>> +	ret = icssm_emac_set_boot_pru(emac, ndev);
>> +	if (ret)
>> +		return ret;
>> +
>> +	/* start PHY */
>> +	phy_start(emac->phydev);
>> +
>> +	return 0;
>> +}
>> +
>> +/**
>> + * icssm_emac_ndo_stop - EMAC device stop
>> + * @ndev: network adapter device
>> + *
>> + * Called when system wants to stop or down the interface.
>> + *
>> + * Return: Always 0 (Success)
>> + */
>> +static int icssm_emac_ndo_stop(struct net_device *ndev)
>> +{
>> +	struct prueth_emac *emac = netdev_priv(ndev);
>> +
>> +	/* stop PHY */
>> +	phy_stop(emac->phydev);
>> +
>> +	rproc_shutdown(emac->pru);
>> +
>> +	return 0;
>> +}
>> +
>> +static const struct net_device_ops emac_netdev_ops = {
>> +	.ndo_open = icssm_emac_ndo_open,
>> +	.ndo_stop = icssm_emac_ndo_stop,
>> +};
>> +
>> +/* get emac_port corresponding to eth_node name */
>> +static int icssm_prueth_node_port(struct device_node *eth_node)
>> +{
>> +	u32 port_id;
>> +	int ret;
>> +
>> +	ret = of_property_read_u32(eth_node, "reg", &port_id);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if (port_id == 0)
>> +		return PRUETH_PORT_MII0;
>> +	else if (port_id == 1)
>> +		return PRUETH_PORT_MII1;
>> +	else
>> +		return PRUETH_PORT_INVALID;
>> +}
>> +
>> +/* get MAC instance corresponding to eth_node name */
>> +static int icssm_prueth_node_mac(struct device_node *eth_node)
>> +{
>> +	u32 port_id;
>> +	int ret;
>> +
>> +	ret = of_property_read_u32(eth_node, "reg", &port_id);
>> +	if (ret)
>> +		return ret;
>> +
>> +	if (port_id == 0)
>> +		return PRUETH_MAC0;
>> +	else if (port_id == 1)
>> +		return PRUETH_MAC1;
>> +	else
>> +		return PRUETH_MAC_INVALID;
>> +}
>> +
>> +static int icssm_prueth_netdev_init(struct prueth *prueth,
>> +				    struct device_node *eth_node)
>> +{
>> +	struct prueth_emac *emac;
>> +	struct net_device *ndev;
>> +	enum prueth_port port;
>> +	enum prueth_mac mac;
>> +	int ret;
>> +
>> +	port = icssm_prueth_node_port(eth_node);
>> +	if (port == PRUETH_PORT_INVALID)
>> +		return -EINVAL;
>> +
>> +	mac = icssm_prueth_node_mac(eth_node);
>> +	if (mac == PRUETH_MAC_INVALID)
>> +		return -EINVAL;
>> +
>> +	ndev = devm_alloc_etherdev(prueth->dev, sizeof(*emac));
>> +	if (!ndev)
>> +		return -ENOMEM;
>> +
>> +	SET_NETDEV_DEV(ndev, prueth->dev);
>> +	emac = netdev_priv(ndev);
>> +	prueth->emac[mac] = emac;
>> +	emac->prueth = prueth;
>> +	emac->ndev = ndev;
>> +	emac->port_id = port;
>> +
>> +	/* by default eth_type is EMAC */
>> +	switch (port) {
>> +	case PRUETH_PORT_MII0:
>> +		emac->pru = prueth->pru0;
>> +		break;
>> +	case PRUETH_PORT_MII1:
>> +		emac->pru = prueth->pru1;
>> +		break;
>> +	default:
>> +		return -EINVAL;
>> +	}
>> +	/* get mac address from DT and set private and netdev addr */
>> +	ret = of_get_ethdev_address(eth_node, ndev);
>> +	if (!is_valid_ether_addr(ndev->dev_addr)) {
>> +		eth_hw_addr_random(ndev);
>> +		dev_warn(prueth->dev, "port %d: using random MAC addr: %pM\n",
>> +			 port, ndev->dev_addr);
>> +	}
>> +	ether_addr_copy(emac->mac_addr, ndev->dev_addr);
>> +
>> +	/* connect PHY */
>> +	emac->phydev = of_phy_get_and_connect(ndev, eth_node,
>> +					      icssm_emac_adjust_link);
>> +	if (!emac->phydev) {
>> +		dev_dbg(prueth->dev, "PHY connection failed\n");
>> +		ret = -EPROBE_DEFER;
>> +		goto free;
>> +	}
>> +
>> +	/* remove unsupported modes */
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_10baseT_Full_BIT);
>> +
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
>> +
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_Pause_BIT);
>> +	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_Asym_Pause_BIT);
>> +
>> +	ndev->netdev_ops = &emac_netdev_ops;
>> +
> 
> I think ndev->dev.of_node should be set to eth_node here.
> 
> If ndev->dev.of_node isn't set, of_find_net_device_by_node() won't find
> the iccsm_prueth ports and their of_node won't be available in sysfs
> (which, in my case, leads to issues during the probe of a switch
> connected to them)
> 

We will add the below line in icssm_prueth_netdev_init() function to
resolve the issue.

ndev->dev.of_node = eth_node;

We will add it in the next version.


Thanks and Regards,
Parvathi.





  reply	other threads:[~2025-08-11 10:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-24  7:23 [PATCH net-next v12 0/5] PRU-ICSSM Ethernet Driver Parvathi Pudi
2025-07-24  7:23 ` [PATCH net-next v12 1/5] dt-bindings: net: ti: Adds DUAL-EMAC mode support on PRU-ICSS2 for AM57xx, AM43xx and AM33xx SOCs Parvathi Pudi
2025-07-24  7:23 ` [PATCH net-next v12 2/5] net: ti: prueth: Adds ICSSM Ethernet driver Parvathi Pudi
2025-07-25 17:55   ` ALOK TIWARI
2025-07-31 14:15     ` Parvathi Pudi
2025-07-31 14:15       ` Parvathi Pudi
2025-08-06 13:40   ` Bastien Curutchet
2025-08-11 10:14     ` Parvathi Pudi [this message]
2025-08-11 10:14       ` Parvathi Pudi
2025-07-24  7:23 ` [PATCH net-next v12 3/5] net: ti: prueth: Adds PRUETH HW and SW configuration Parvathi Pudi
2025-07-25 17:43   ` ALOK TIWARI
2025-07-31 14:11     ` Parvathi Pudi
2025-07-31 14:11       ` Parvathi Pudi
2025-07-24  9:10 ` [PATCH net-next v12 4/5] net: ti: prueth: Adds link detection, RX and TX support Parvathi Pudi
2025-07-24  9:10 ` [PATCH net-next v12 5/5] net: ti: prueth: Adds IEP support for PRUETH on AM33x, AM43x and AM57x SOCs Parvathi Pudi
2025-07-25 14:04   ` ALOK TIWARI
2025-07-31 14:08     ` Parvathi Pudi
2025-07-31 14:08       ` Parvathi Pudi

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=202602590.150020.1754907288322.JavaMail.zimbra@couthit.local \
    --to=parvathi@couthit.com \
    --cc=afd@ti.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=basharath@couthit.com \
    --cc=bastien.curutchet@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=diogo.ivo@siemens.com \
    --cc=edumazet@google.com \
    --cc=glaroque@baylibre.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=javier.carrasco.cruz@gmail.com \
    --cc=kory.maincent@bootlin.com \
    --cc=krishna@couthit.com \
    --cc=krzk+dt@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=m-malladi@ti.com \
    --cc=mohan@couthit.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pmohan@couthit.com \
    --cc=prajith@ti.com \
    --cc=praneeth@ti.com \
    --cc=pratheesh@ti.com \
    --cc=richardcochran@gmail.com \
    --cc=robh@kernel.org \
    --cc=rogerq@kernel.org \
    --cc=rogerq@ti.com \
    --cc=s.hauer@pengutronix.de \
    --cc=saikrishnag@marvell.com \
    --cc=srk@ti.com \
    --cc=ssantosh@kernel.org \
    --cc=vadim.fedorenko@linux.dev \
    --cc=vigneshr@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.