public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alexandru Marginean <alexm.osslist@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 1/6] net: introduce DSA class for Ethernet switches
Date: Tue, 17 Dec 2019 08:18:42 +0100	[thread overview]
Message-ID: <a80dd243-90a9-e5d5-62ba-802fcde237d9@gmail.com> (raw)
In-Reply-To: <CA+h21hpVyL129XR4P3NePQkKyvkihNW+QHHCNdq0whxLRujRgw@mail.gmail.com>

On 12/15/2019 2:08 PM, Vladimir Oltean wrote:
> On Tue, 3 Dec 2019 at 17:32, Alex Marginean <alexandru.marginean@nxp.com> wrote:
>> +/**
>> + * This function deals with additional devices around the switch as these should
>> + * have been bound to drivers by now.
>> + * TODO: pick up references to other switch devices here, if we're cascaded.
>> + */
>> +static int dm_dsa_pre_probe(struct udevice *dev)
>> +{
>> +       struct dsa_perdev_platdata *platdata = dev_get_platdata(dev);
>> +       int i;
>> +
>> +       if (!platdata)
>> +               return -EINVAL;
>> +
>> +       if (ofnode_valid(platdata->master_node))
>> +               uclass_find_device_by_ofnode(UCLASS_ETH, platdata->master_node,
>> +                                            &platdata->master_dev);
>> +
>> +       for (i = 0; i < platdata->num_ports; i++) {
>> +               struct dsa_port_platdata *port = &platdata->port[i];
>> +
>> +               if (port->dev) {
>> +                       port->dev->priv = port;
>> +                       port->phy = dm_eth_phy_connect(port->dev);
> 
> Fixed-link interfaces don't work with DM_MDIO. That is somewhat
> natural as there is no MDIO bus for a fixed-link. However the legacy
> phy_connect function can be made rather easily to work with
> fixed-link, since it has the necessary code for dealing with it
> already. I am not, however, sure how it ever worked in the absence of
> an MDIO bus.
> 
> commit 1b7e23cc7e6d0dc3fe7ae9c55390b40717ff3c3a
> Author: Vladimir Oltean <olteanv@gmail.com>
> Date:   Sat Dec 14 23:25:40 2019 +0200
> 
>      phy: make phy_connect_fixed work with a null mdio bus
> 
>      It is utterly pointless to require an MDIO bus pointer for a fixed PHY
>      device. The fixed.c implementation does not require it, only
>      phy_device_create. Fix that.
> 
>      Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 80a7664e4978..8ea5c9005291 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -658,7 +658,7 @@ static struct phy_device *phy_device_create(struct
> mii_dev *bus, int addr,
>          dev = malloc(sizeof(*dev));
>          if (!dev) {
>                  printf("Failed to allocate PHY device for %s:%d\n",
> -                      bus->name, addr);
> +                      bus ? bus->name : "(null bus)", addr);
>                  return NULL;
>          }
> 
> @@ -686,7 +686,7 @@ static struct phy_device *phy_device_create(struct
> mii_dev *bus, int addr,
>                  return NULL;
>          }
> 
> -       if (addr >= 0 && addr < PHY_MAX_ADDR)
> +       if (addr >= 0 && addr < PHY_MAX_ADDR && phy_id != PHY_FIXED_ID)
>                  bus->phymap[addr] = dev;
> 
>          return dev;
> 
> With the patch above in place, fixed-link can also be made to work
> with some logic similar to what can be seen below:
> 
>      if (ofnode_valid(ofnode_find_subnode(port->dev->node, "fixed-link")))
>          port->phy = phy_connect(NULL, 0, port->dev, phy_mode); //
> phy_mode needs to be pre-parsed somewhere else as well
>      else
>          port->phy = dm_eth_phy_connect(port->dev);
> 
> How would you see fixed-link interfaces being treated? My question so
> far is in the context of front-panel ports but I am interested in your
> view of the CPU port situation as well.

I was thinking turning dm_eth_phy_connect into a more generic helper 
that also deals with fixed links, which it does not yet.  That would 
move the "fixed-link" if out of the driver code.  Ideally the driver 
should be able to call a single helper and, if the device has a DT node, 
it would get back a PHY handle to either a proper PHY or to a fixed link 
(from phy_connect_fixed).

Alex

> 
>> +               }
>> +       }
>> +
>> +       return 0;
>> +}
> 
> Thanks,
> -Vladimir
> 

  reply	other threads:[~2019-12-17  7:18 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03 14:56 [PATCH v3 0/6] Introduce DSA Ethernet switch class and Felix driver Alex Marginean
2019-12-03 14:56 ` [PATCH v3 1/6] net: introduce DSA class for Ethernet switches Alex Marginean
2019-12-15 12:44   ` Vladimir Oltean
2019-12-17  7:11     ` Alexandru Marginean
2019-12-15 13:08   ` Vladimir Oltean
2019-12-17  7:18     ` Alexandru Marginean [this message]
2019-12-17  9:41       ` Vladimir Oltean
2019-12-17 10:36         ` Alexandru Marginean
2019-12-17 10:47           ` Vladimir Oltean
2020-02-09 13:10   ` Vladimir Oltean
2019-12-03 14:56 ` [PATCH v3 2/6] drivers: net: add a DSA sandbox driver Alex Marginean
2019-12-03 14:56 ` [PATCH v3 3/6] test: dm: add a simple unit test for DSA class Alex Marginean
2019-12-04  4:14   ` Priyanka Jain
2019-12-03 14:56 ` [PATCH v3 4/6] drivers: net: add Felix DSA switch driver Alex Marginean
2019-12-15 12:53   ` Vladimir Oltean
2019-12-15 12:53     ` Vladimir Oltean
2019-12-15 14:16     ` Vladimir Oltean
2019-12-17  7:29       ` Alexandru Marginean
2019-12-17  7:28     ` Alexandru Marginean
2019-12-03 14:56 ` [PATCH v3 5/6] arm: dts: ls1028a: adds Ethernet switch node and its dependencies Alex Marginean
2019-12-03 14:56 ` [PATCH v3 6/6] configs: ls1028a: enable the Ethernet switch driver in defconfig Alex Marginean
2020-03-13 14:33   ` Vladimir Oltean
2020-03-17  9:49     ` Alexandru Marginean
2020-02-08 13:19 ` [PATCH v3 0/6] Introduce DSA Ethernet switch class and Felix driver Vladimir Oltean
2020-03-17  9:58   ` Alexandru Marginean

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=a80dd243-90a9-e5d5-62ba-802fcde237d9@gmail.com \
    --to=alexm.osslist@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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