public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Pengcheng Xu <i@jsteward.moe>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: macb: add support for fixed-link
Date: Sat, 29 Feb 2020 16:30:23 +0100	[thread overview]
Message-ID: <20200229153023.GC6305@lunn.ch> (raw)
In-Reply-To: <CADuippAvUXHH2Mjuxyz+9JFf-SR5j8itmRi5YvUJowmbVXR9Og@mail.gmail.com>

On Sat, Feb 29, 2020 at 03:19:15PM +0800, Pengcheng Xu wrote:
> Sorry for forgetting to CC the mailing lists.  Adding them now.
> 
> 2020年2月29日(土) 15:09 Pengcheng Xu <i@jsteward.moe>:
> >
> > The Cadence macb driver did not support fixed-link PHYs.  This patch
> > adds support for fixed-link PHYs to the driver.
> >
> > The driver only checks if there's a valid PHY over MDIO, which is either
> > present as a device tree node, or (if absent) searched on the MDIO bus.
> > This patch detects if there is a `fixed-link` PHY instead of a regular
> > MDIO-attached PHY.  The device tree node of the MAC is checked for a
> > fixed-link PHY via `of_phy_is_fixed_link`, and, if so, the normal MDIO
> > register routine is skipped, and `of_phy_register_fixed_link` is
> > performed instead.
> >
> > The changes were borrowed from
> > drivers/net/ethernet/altera/altera_tse_main.c and tested to work on a
> > Xilinx Zynq UltraScale+ device.
> >
> > Signed-off-by: Pengcheng Xu <i@jsteward.moe>
> > ---
> >  drivers/net/ethernet/cadence/macb_main.c | 15 ++++++++++++---
> >  1 file changed, 12 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> > index 2c28da1737fe..fb359ce90ae4 100644
> > --- a/drivers/net/ethernet/cadence/macb_main.c
> > +++ b/drivers/net/ethernet/cadence/macb_main.c
> > @@ -744,6 +744,7 @@ static int macb_mdiobus_register(struct macb *bp)
> >
> >  static int macb_mii_init(struct macb *bp)
> >  {
> > +       struct device_node *np = bp->pdev->dev.of_node;
> >         int err = -ENXIO;
> >
> >         /* Enable management port */
> > @@ -765,9 +766,17 @@ static int macb_mii_init(struct macb *bp)
> >
> >         dev_set_drvdata(&bp->dev->dev, bp->mii_bus);
> >
> > -       err = macb_mdiobus_register(bp);
> > -       if (err)
> > -               goto err_out_free_mdiobus;
> > +       if (of_phy_is_fixed_link(np)) {
> > +               err = of_phy_register_fixed_link(np);
> > +               if (err) {
> > +                       netdev_err(bp->dev, "cannot register fixed-link PHY\n");
> > +                       goto err_out_free_mdiobus;
> > +               }
> > +       } else {
> > +               err = macb_mdiobus_register(bp);
> > +               if (err)
> > +                       goto err_out_free_mdiobus;
> > +       }
> >
> >         err = macb_mii_probe(bp->dev);
> >         if (err)

Hi Pengcheng

Fixed link and an mdio bus are not mutually exclusive. When the MAC is
connected to an Ethernet switch, you often see a fixed link, and the
ethernet switch on the MDIO bus. As an example,

arch/arm/boot/dts/vf610-zii-cfu1.dts

&fec1 {
        phy-mode = "rmii";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_fec1>;
        status = "okay";

        fixed-link {
                speed = <100>;
                full-duplex;
        };

        mdio1: mdio {
                #address-cells = <1>;
                #size-cells = <0>;
                status = "okay";

                switch0: switch0@0 {
                        compatible = "marvell,mv88e6085";
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_switch>;
                        reg = <0>;
                        eeprom-length = <512>;
                        interrupt-parent = <&gpio3>;
                        interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
                        reset-gpios = <&gpio3 11 GPIO_ACTIVE_LOW>;

...

So if you find a fixed-phy, you should register it. And if you find an
mdio bus, you should also register it.

     Andrew

      reply	other threads:[~2020-02-29 15:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200229070902.1294280-1-i@jsteward.moe>
2020-02-29  7:19 ` [PATCH] net: macb: add support for fixed-link Pengcheng Xu
2020-02-29 15:30   ` Andrew Lunn [this message]

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=20200229153023.GC6305@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=i@jsteward.moe \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.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