From: Andrew Lunn <andrew@lunn.ch>
To: "Alvin Šipraga" <ALSI@bang-olufsen.dk>
Cc: "Alvin Šipraga" <alvin@pqrs.dk>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Vivien Didelot" <vivien.didelot@gmail.com>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Heiner Kallweit" <hkallweit1@gmail.com>,
"Russell King" <linux@armlinux.org.uk>,
"Michael Rasmussen" <MIR@bang-olufsen.dk>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH net-next 4/5] net: dsa: realtek-smi: add rtl8365mb subdriver for RTL8365MB-VC
Date: Mon, 23 Aug 2021 03:14:05 +0200 [thread overview]
Message-ID: <YSL2XcUmb7PO5H0y@lunn.ch> (raw)
In-Reply-To: <283675c4-90cf-6e5c-8178-5e3eba7592ba@bang-olufsen.dk>
> Just to clarify, this means I should set the physical port number in the
> reg field of the device tree? i.e.:
>
> port@4 {
> reg = <6>; /* <--- instead of <4>? */
> label = "cpu";
> ethernet = <&fec1>;
> phy-mode = "rgmii-id";
> fixed-link {
> speed = <1000>;
> full-duplex;
> pause;
> };
> };
Yes, this is fine.
> >> +static int rtl8365mb_port_enable(struct dsa_switch *ds, int port,
> >> + struct phy_device *phy)
> >> +{
> >> + struct realtek_smi *smi = ds->priv;
> >> + int val;
> >> +
> >> + if (dsa_is_user_port(ds, port)) {
> >> + /* Power up the internal PHY and restart autonegotiation */
> >> + val = rtl8365mb_phy_read(smi, port, MII_BMCR);
> >> + if (val < 0)
> >> + return val;
> >> +
> >> + val &= ~BMCR_PDOWN;
> >> + val |= BMCR_ANRESTART;
> >> +
> >> + return rtl8365mb_phy_write(smi, port, MII_BMCR, val);
> >> + }
> >
> > There should not be any need to do this. phylib should do it. In
> > generally, you should not need to touch any PHY registers, you just
> > need to allow access to the PHY registers.
>
> Will phylib also the opposite when the interface is administratively put
> down (e.g. ip link set dev swp2 down)? The switch doesn't seem to have
> any other handle for stopping the flow of packets from a port except to
> power down the internal PHY, hence why I put this in for port_disable.
> For port_enable I just did the opposite but I can see why it's not
> necessary.
When the MAC and PHY are attached phy_attach_direct() gets called,
which calls phy_resume(phydev); The generic implementation clears the
BMCR_PDOWN bit.
phy_detach() will suspend the PHY, which sets the BMCR_PDOWN bit.
But there are two different schemes for doing this. Some MAC drivers
connect the PHY during probe. Others do it at open. DSA does it at
probe. So this is generic feature is not going to work for you. You
might want to put some printk() in phy_suspend and phy_resume to check
that.
So, setting/clearing the PDOWN bit does seems reasonable. But please
document in the functions why you are doing this. Also, don't restart
autoneg. That really should be up to phylib, and it should be
triggered by phylink_start() which should be called directly after
port_enable().
Andrew
next prev parent reply other threads:[~2021-08-23 1:14 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-22 19:31 [RFC PATCH net-next 0/5] net: dsa: add support for RTL8365MB-VC Alvin Šipraga
2021-08-22 19:31 ` [RFC PATCH net-next 1/5] net: dsa: realtek-smi: fix mdio_free bug on module unload Alvin Šipraga
2021-08-22 21:40 ` Andrew Lunn
2021-08-22 22:33 ` Alvin Šipraga
2021-08-22 23:16 ` Andrew Lunn
2021-08-27 22:06 ` Linus Walleij
2021-08-28 10:50 ` Alvin Šipraga
2021-08-22 21:54 ` Vladimir Oltean
2021-08-22 22:42 ` Alvin Šipraga
2021-08-22 23:10 ` Vladimir Oltean
2021-08-22 19:31 ` [RFC PATCH net-next 2/5] dt-bindings: net: dsa: realtek-smi: document new compatible rtl8365mb Alvin Šipraga
2021-08-22 21:44 ` Andrew Lunn
2021-08-23 10:15 ` Florian Fainelli
2021-08-24 16:51 ` Rob Herring
2021-08-27 22:08 ` Linus Walleij
2021-08-22 19:31 ` [RFC PATCH net-next 3/5] net: dsa: tag_rtl8_4: add realtek 8 byte protocol 4 tag Alvin Šipraga
2021-08-22 22:02 ` Andrew Lunn
2021-08-22 22:50 ` Alvin Šipraga
2021-08-22 23:14 ` Andrew Lunn
2021-08-22 23:27 ` Alvin Šipraga
2021-08-22 22:13 ` Vladimir Oltean
2021-08-22 23:11 ` Alvin Šipraga
2021-08-22 23:25 ` Vladimir Oltean
2021-08-22 23:37 ` Alvin Šipraga
2021-08-22 23:45 ` Vladimir Oltean
2021-08-23 0:28 ` Alvin Šipraga
2021-08-23 0:31 ` Vladimir Oltean
2021-08-22 19:31 ` [RFC PATCH net-next 4/5] net: dsa: realtek-smi: add rtl8365mb subdriver for RTL8365MB-VC Alvin Šipraga
2021-08-22 22:48 ` Vladimir Oltean
2021-08-22 23:56 ` Alvin Šipraga
2021-08-23 0:19 ` Vladimir Oltean
2021-08-23 1:22 ` Alvin Šipraga
2021-08-23 2:12 ` Vladimir Oltean
2021-08-23 10:06 ` Alvin Šipraga
2021-08-23 10:31 ` Vladimir Oltean
2021-08-23 10:54 ` Alvin Šipraga
2021-08-23 13:13 ` Andrew Lunn
2021-08-23 13:20 ` Alvin Šipraga
2021-08-27 22:24 ` Linus Walleij
2021-08-22 23:04 ` Andrew Lunn
2021-08-22 23:25 ` Alvin Šipraga
2021-08-23 1:14 ` Andrew Lunn [this message]
2021-08-23 10:08 ` Alvin Šipraga
2021-08-23 4:37 ` DENG Qingfang
2021-08-23 10:11 ` Alvin Šipraga
2021-08-22 19:31 ` [RFC PATCH net-next 5/5] net: phy: realtek: add support for RTL8365MB-VC internal PHYs Alvin Šipraga
2021-08-23 10:13 ` Florian Fainelli
2021-08-27 22:27 ` Linus Walleij
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=YSL2XcUmb7PO5H0y@lunn.ch \
--to=andrew@lunn.ch \
--cc=ALSI@bang-olufsen.dk \
--cc=MIR@bang-olufsen.dk \
--cc=alvin@pqrs.dk \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=robh+dt@kernel.org \
--cc=vivien.didelot@gmail.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).