Skip to content
Snippets Groups Projects
Commit 0783b165 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by Ramon Fried
Browse files

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: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarRamon Fried <rfried.dev@gmail.com>
parent 8a5c0570
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
#ifndef __DSA_H__
#define __DSA_H__
#include <dm/ofnode.h>
#include <phy.h>
#include <net.h>
......@@ -145,6 +146,17 @@ int dsa_set_tagging(struct udevice *dev, ushort headroom, ushort tailroom);
*/
struct udevice *dsa_get_master(struct udevice *dev);
/**
* dsa_port_get_ofnode() - Return a reference to the given port's OF node
*
* Can be called at driver probe time or later.
*
* @dev: DSA switch udevice pointer
* @port: Port index
* @return OF node reference if OK, NULL on error
*/
ofnode dsa_port_get_ofnode(struct udevice *dev, int port);
/**
* dsa_port_get_pdata() - Helper that returns the platdata of an active
* (non-CPU) DSA port device.
......
......@@ -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)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment