u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Ramon Fried <rfried.dev@gmail.com>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: U-Boot Mailing List <u-boot@lists.denx.de>,
	Joe Hershberger <joe.hershberger@ni.com>,
	 Priyanka Jain <priyanka.jain@nxp.com>
Subject: Re: [PATCH 3/9] net: dsa: allow drivers to get the port OF node
Date: Tue, 28 Sep 2021 16:34:36 +0300	[thread overview]
Message-ID: <CAGi-RUK_FSoWgyojsMKYzxtnezn2z2A61QWL6dgvNKV6F9a-2w@mail.gmail.com> (raw)
In-Reply-To: <20210927234825.823582-4-vladimir.oltean@nxp.com>

On Tue, Sep 28, 2021 at 2:48 AM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> 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 <vladimir.oltean@nxp.com>
> ---
>  include/net/dsa.h | 12 ++++++++++++
>  net/dsa-uclass.c  | 20 ++++++++++++++++++++
>  2 files changed, 32 insertions(+)
>
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index ab2a9dfbea2d..d165427fcd4c 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -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.
> diff --git a/net/dsa-uclass.c b/net/dsa-uclass.c
> index a9b4484d6d24..61bb47d0102d 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)
>  {
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

  reply	other threads:[~2021-09-28 13:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 23:48 [PATCH 0/9] Support the SJA1105 DSA switch on the NXP LS1021A-TSN board Vladimir Oltean
2021-09-27 23:48 ` [PATCH 1/9] net: tsec: add support for promiscuous mode Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 2/9] include: import if_vlan.h from Linux Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 3/9] net: dsa: allow drivers to get the port OF node Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried [this message]
2021-09-27 23:48 ` [PATCH 4/9] net: introduce a helper to determine whether to use in-band autoneg Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-29  2:32   ` Bin Meng
2021-09-27 23:48 ` [PATCH 5/9] net: dsa: felix: configure the in-band autoneg property based on OF node info Vladimir Oltean
2021-09-28 13:34   ` Ramon Fried
2021-09-29 12:21     ` Vladimir Oltean
2021-09-27 23:48 ` [PATCH 6/9] net: add driver for NXP SJA1105 DSA L2 switch Vladimir Oltean
2021-09-28 13:35   ` Ramon Fried
2021-09-27 23:48 ` [PATCH 7/9] arm: dts: ls1021a-tsn: add sja1105 and eth2 bindings Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-27 23:48 ` [PATCH 8/9] configs: ls1021a-tsn: enable sja1105 switch driver Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:33   ` Bin Meng
2021-09-27 23:48 ` [PATCH 9/9] configs: ls1021a-tsn: enable the generation of random Ethernet MAC addresses Vladimir Oltean
2021-09-28 13:26   ` Ramon Fried
2021-09-29  2:33   ` Bin Meng

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=CAGi-RUK_FSoWgyojsMKYzxtnezn2z2A61QWL6dgvNKV6F9a-2w@mail.gmail.com \
    --to=rfried.dev@gmail.com \
    --cc=joe.hershberger@ni.com \
    --cc=priyanka.jain@nxp.com \
    --cc=u-boot@lists.denx.de \
    --cc=vladimir.oltean@nxp.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).