This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM4379: am437x sdk04.03 prueth driver support one pruss ethernet

Part Number: AM4379

Tool/software: Linux

Hi,

Ti,

I am using the rt-linux sdk04.03 of am437x.linux version is 4.9.65-rt.There are rgmii ethernet and one pruss ethernet on my board.The pruss ethernet connects to pruss1 mii1.

Now the prueth driver on the kernel is  only support two pruss ethernet,only when two pruss ethernet exist on the board,the driver will work fine.

So I modify the prueth.c like that, to support one pruss ethernet.

After do that, The eth1 is up,but can not get the ip.

the hardware is ok,because I use the kernel on sdk03.01,it can get the ip.

Now I want to know how to modify the prueth driver to support one ethernet?

Br,

vefone

  • Hi,
    There are a few things needed. Could you please supply the following results of these commands:
    ifconfig -a
    ethtool eth1
    ethanol -S eth1

    Could you also supply the portions of the DTS file used to describe the RGMII port and the PRU port?
    Could you also describe how you plan to use the two ports?
    Could you also describe the topology of both the ports used and how the connect with each link partner? Are both ports on separate subnets?

    Best Regards,
    Schuyler
  • Hi,

    Schuyler,

    here the test resluts:

    1)

    It seems that the eth1 can not recive anything.

    2) dts configuration

    rgmii:

    pruss eth:

    3) modify on prueth.c like that

    https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/791/0005_2D00_must_2D00_reset.7z

    I found that commented the below code, the eth1 will not get the ip.

    4) I hope the rgmii and pru eth can get ip,but the pru eth can not get ip now.

    5) the prueth,c driver not work fine if there is only one pru eth on the board,so I want to modify the prueth,c,supprting one pru ethernet port.

  • Hi,

    I had solved the problem.

    Here are the modify.

    From da41459dd7e965259221d677173ad685b3ce6d59 Mon Sep 17 00:00:00 2001
    From: vefone <lwf@tronlong.com>
    Date: Wed, 31 Oct 2018 11:43:45 +0800
    Subject: [PATCH 11/12] net: prueth: support single emac register, make sure
     two emac port of one pruss works independently
    
    Signed-off-by: vefone <lwf@tronlong.com>
    ---
     .../devicetree/bindings/net/ti-prueth.txt          |  3 +
     drivers/net/ethernet/ti/prueth.c                   | 73 +++++++++++++---------
     drivers/net/ethernet/ti/prueth.h                   |  1 +
     3 files changed, 47 insertions(+), 30 deletions(-)
    
    diff --git a/Documentation/devicetree/bindings/net/ti-prueth.txt b/Documentation/devicetree/bindings/net/ti-prueth.txt
    index 7a4e637..f32b7fe 100644
    --- a/Documentation/devicetree/bindings/net/ti-prueth.txt
    +++ b/Documentation/devicetree/bindings/net/ti-prueth.txt
    @@ -11,6 +11,7 @@ Required properties:
     - pruss            : Must point to a pruss device node
     - sram	           : pHandle to OCMC SRAM node
     - interrupt-parent : pHandle to the PRUSS INTC node
    +- dual_emac        : Must add it if we use two emac on one pruss
     
     Must contain children, one for each of the MAC ports.
     Required properties for children:
    @@ -34,6 +35,8 @@ Example (am572x-idk board):
     		sram = <&ocmcram1>;
     		interrupt-parent = <&pruss2_intc>;
     
    +               dual_emac;
    +
     		pruss2_emac0: ethernet-mii0 {
     			phy-handle = <&pruss2_eth0_phy>;
     			phy-mode = "mii";
    diff --git a/drivers/net/ethernet/ti/prueth.c b/drivers/net/ethernet/ti/prueth.c
    index 23d98f5..733923e 100644
    --- a/drivers/net/ethernet/ti/prueth.c
    +++ b/drivers/net/ethernet/ti/prueth.c
    @@ -2700,8 +2700,11 @@ static int emac_ndo_open(struct net_device *ndev)
     		prueth_init_mmap_configs(prueth);
     
     		emac_calculate_queue_offsets(prueth, eth_node, emac);
    -		emac_calculate_queue_offsets(prueth, other_eth_node,
    -					     other_emac);
    +
    +		if (prueth->dual_emac) {
    +			emac_calculate_queue_offsets(prueth, other_eth_node,
    +						other_emac);
    +		}
     
     		ret = prueth_hostinit(prueth);
     		if (ret) {
    @@ -3107,13 +3110,15 @@ static int emac_ndo_set_features(struct net_device *ndev,
     		return -EBUSY;
     	}
     
    -	other_port_id = (emac->port_id == PRUETH_PORT_MII0) ?
    -			PRUETH_PORT_MII1 : PRUETH_PORT_MII0;
    -	other_emac = prueth->emac[other_port_id];
    -	if (netif_running(other_emac->ndev) && change_request) {
    -		netdev_err(ndev,
    -			   "Can't change feature when other device runs\n");
    -		return -EBUSY;
    +	if (prueth->dual_emac) {
    +		other_port_id = (emac->port_id == PRUETH_PORT_MII0) ?
    +				PRUETH_PORT_MII1 : PRUETH_PORT_MII0;
    +		other_emac = prueth->emac[other_port_id];
    +		if (netif_running(other_emac->ndev) && change_request) {
    +			netdev_err(ndev,
    +				"Can't change feature when other device runs\n");
    +			return -EBUSY;
    +		}
     	}
     
     	if (features & NETIF_F_HW_HSR_RX_OFFLOAD) {
    @@ -4022,40 +4027,48 @@ static int prueth_probe(struct platform_device *pdev)
     		prueth->mem[PRUETH_MEM_OCMC].va,
     		prueth->mem[PRUETH_MEM_OCMC].size);
     
    +	if (of_property_read_bool(np, "dual_emac"))
    +		prueth->dual_emac = 1;
    +	else
    +		prueth->dual_emac = 0;
    +
    +	mutex_init(&prueth->mlock);
    +
     	/* setup netdev interfaces */
     	eth_node = of_get_child_by_name(np, "ethernet-mii0");
     	if (!eth_node) {
     		dev_err(dev, "no ethernet-mii0 node\n");
    -		ret = -ENODEV;
    -		goto free_pool;
     	}
    -	mutex_init(&prueth->mlock);
    -	ret = prueth_netdev_init(prueth, eth_node);
    -	if (ret) {
    -		if (ret != -EPROBE_DEFER) {
    -			dev_err(dev, "netdev init %s failed: %d\n",
    -				eth_node->name, ret);
    +	else
    +	{
    +		ret = prueth_netdev_init(prueth, eth_node);
    +		if (ret) {
    +			if (ret != -EPROBE_DEFER) {
    +				dev_err(dev, "netdev init %s failed: %d\n",
    +					eth_node->name, ret);
    +			}
    +			goto netdev_exit;
    +		} else {
    +			prueth->eth_node[PRUETH_PORT_MII0] = eth_node;
     		}
    -		goto netdev_exit;
    -	} else {
    -		prueth->eth_node[PRUETH_PORT_MII0] = eth_node;
     	}
     
     	eth_node = of_get_child_by_name(np, "ethernet-mii1");
     	if (!eth_node) {
     		dev_err(dev, "no ethernet-mii1 node\n");
    -		ret = -ENODEV;
    -		goto netdev_exit;
     	}
    -	ret = prueth_netdev_init(prueth, eth_node);
    -	if (ret) {
    -		if (ret != -EPROBE_DEFER) {
    -			dev_err(dev, "netdev init %s failed: %d\n",
    -				eth_node->name, ret);
    +	else
    +	{
    +		ret = prueth_netdev_init(prueth, eth_node);
    +		if (ret) {
    +			if (ret != -EPROBE_DEFER) {
    +				dev_err(dev, "netdev init %s failed: %d\n",
    +					eth_node->name, ret);
    +			}
    +			goto netdev_exit;
    +		} else {
    +			prueth->eth_node[PRUETH_PORT_MII1] = eth_node;
     		}
    -		goto netdev_exit;
    -	} else {
    -		prueth->eth_node[PRUETH_PORT_MII1] = eth_node;
     	}
     
     	prueth_init_mem(prueth);
    diff --git a/drivers/net/ethernet/ti/prueth.h b/drivers/net/ethernet/ti/prueth.h
    index 3c43e5e..c57c62a 100644
    --- a/drivers/net/ethernet/ti/prueth.h
    +++ b/drivers/net/ethernet/ti/prueth.h
    @@ -600,6 +600,7 @@ struct prueth {
     	struct kthread_work    nt_work;
     	u32		rem_cnt;
     	spinlock_t	nt_lock;
    +	u32		dual_emac;
     };
     
     #endif /* __NET_TI_PRUETH_H */
    -- 
    2.7.4