From 0783b16509a1e6d9821084ec64f5be1cc091c7f9 Mon Sep 17 00:00:00 2001 From: Vladimir Oltean Date: Wed, 29 Sep 2021 18:04:38 +0300 Subject: net: dsa: allow drivers to get the port OF node In the current DSA switch driver API, only the udevice of the switch (belonging to UCLASS_DSA) is exposed, as well as an "int port" argument. So drivers do not have access to the udevice of individual ports (belonging to UCLASS_ETH), one of the reasons being that not all ports have an associated UCLASS_ETH udevice. However, all DSA ports have an OF node, and in some cases the driver needs a handle to it, for all ports including the CPU port. Example: the following Linux per-port device tree property: managed = "in-band-status"; states whether a port should operate with clause 37 in-band autoneg enabled or not. This patch exposes a function which can be called by individual drivers as needed. Signed-off-by: Vladimir Oltean Reviewed-by: Ramon Fried --- net/dsa-uclass.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'net/dsa-uclass.c') diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c index bf762cd2a8..7a465b1099 100644 --- a/net/dsa-uclass.c +++ b/net/dsa-uclass.c @@ -44,6 +44,26 @@ int dsa_set_tagging(struct udevice *dev, ushort headroom, ushort tailroom) return 0; } +ofnode dsa_port_get_ofnode(struct udevice *dev, int port) +{ + struct dsa_pdata *pdata = dev_get_uclass_plat(dev); + struct dsa_port_pdata *port_pdata; + struct udevice *pdev; + + if (port == pdata->cpu_port) + return pdata->cpu_port_node; + + for (device_find_first_child(dev, &pdev); + pdev; + device_find_next_child(&pdev)) { + port_pdata = dev_get_parent_plat(pdev); + if (port_pdata->index == port) + return dev_ofnode(pdev); + } + + return ofnode_null(); +} + /* returns the DSA master Ethernet device */ struct udevice *dsa_get_master(struct udevice *dev) { -- cgit v1.2.3 From c7ae46efdcf42317e3e57d0f14e844c551691ab9 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 1 Nov 2021 14:15:10 +0800 Subject: net: dsa: Use true instead of 1 in the set_promisc() call set_promisc() call accepts the parameter of a bool type. Make it clear by using true instead of 1. Signed-off-by: Bin Meng Reviewed-by: Vladimir Oltean Reviewed-by: Ramon Fried --- net/dsa-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'net/dsa-uclass.c') diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c index 7a465b1099..606b1539a7 100644 --- a/net/dsa-uclass.c +++ b/net/dsa-uclass.c @@ -270,7 +270,7 @@ static void dsa_port_set_hwaddr(struct udevice *pdev, struct udevice *master) struct eth_ops *eth_ops = eth_get_ops(master); if (eth_ops->set_promisc) - eth_ops->set_promisc(master, 1); + eth_ops->set_promisc(master, true); return; } -- cgit v1.2.3