From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Helmut Grohne <helmut.grohne@intenta.de>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Florian Fainelli <f.fainelli@gmail.com>
Subject: Re: [PATCH] net: macb: reject unsupported rgmii delays
Date: Thu, 18 Jun 2020 11:01:43 +0100 [thread overview]
Message-ID: <20200618100143.GZ1551@shell.armlinux.org.uk> (raw)
In-Reply-To: <20200618090526.GA10165@laureti-dev>
On Thu, Jun 18, 2020 at 11:05:26AM +0200, Helmut Grohne wrote:
> On Thu, Jun 18, 2020 at 10:45:54AM +0200, Russell King - ARM Linux admin wrote:
> > Why do we need that complexity? If we decide that we can allow
> > phy-mode = "rgmii" and introduce new properties to control the
> > delay, then we just need:
> >
> > rgmii-tx-delay-ps = <nnn>;
> > rgmii-rx-delay-ps = <nnn>;
> >
> > specified in the MAC node (to be applied only at the MAC end) or
> > specified in the PHY node (to be applied only at the PHY end.)
> > In the normal case, this would be the standard delay value, but
> > in exceptional cases where supported, the delays can be arbitary.
> > We know there are PHYs out there which allow other delays.
> >
> > This means each end is responsible for parsing these properties in
> > its own node and applying them - or raising an error if they can't
> > be supported.
>
> Thank you. That makes a lot more sense while keeping the (imo) important
> properties of my proposal:
> * It is backwards compatible. These properties override delays
> specified inside phy-mode. Otherwise the vague phy-mode meaning is
> retained.
> * The ambiguity is resolved. It is always clear where delays should be
> configure and the properties properly account for possible PCB
> traces.
>
> It also resolves my original problem. If support for these properties is
> added to macb_main.c, it would simply check that both delays are 0 as
> internal delays are not supported by the hardware. When I would have
> attempted to configure an rx delay, it would have nicely errored out.
I think we'd want a helper or two to do the parsing and return the
delays, something like:
#define PHY_RGMII_DELAY_PS_NONE 0
#define PHY_RGMII_DELAY_PS_STD 1500
/* @np here should be the MAC node */
int of_mac_get_delays(struct device_node *np,
phy_interface_mode interface,
u32 *tx_delay_ps, u32 *rx_delay_ps)
{
*tx_delay_ps = PHY_RGMII_DELAY_PS_NONE;
*rx_delay_ps = PHY_RGMII_DELAY_PS_NONE;
if (!np)
return 0;
if (interface == PHY_INTERFACE_MODE_RGMII) {
of_property_read_u32(np, "rgmii-tx-delay-ps", tx_delay_ps);
of_property_read_u32(np, "rgmii-rx-delay-ps", rx_delay_ps);
}
return 0;
}
/* @np here should be the PHY node */
int of_phy_get_delays(struct device_node *np,
phy_interface_mode interface,
u32 *tx_delay_ps, u32 *rx_delay_ps)
{
switch (interface) {
case PHY_INTERFACE_MODE_RGMII_ID:
*tx_delay_ps = PHY_RGMII_DELAY_PS_STD;
*rx_delay_ps = PHY_RGMII_DELAY_PS_STD;
return 0;
case PHY_INTERFACE_MODE_RGMII_RXID:
*tx_delay_ps = PHY_RGMII_DELAY_PS_NONE;
*rx_delay_ps = PHY_RGMII_DELAY_PS_STD;
return 0;
case PHY_INTERFACE_MODE_RGMII_TXID:
*tx_delay_ps = PHY_RGMII_DELAY_PS_STD;
*rx_delay_ps = PHY_RGMII_DELAY_PS_NONE;
return 0;
default:
return of_mac_get_delays(np, interface,
tx_delay_ps, rx_delay_ps);
}
}
as a first cut - validation left up to the user of these. At least
we then have an easy interface for PHY drivers to use, for example:
static int m88e1121_config_aneg_rgmii_delays(struct phy_device *phydev)
{
u32 tx_delay_ps, rx_delay_ps;
int err;
err = of_phy_get_delays(phydev->mdio.dev.of_node,
phydev->interface, &tx_delay_ps,
&rx_delay_ps);
if (err)
return err;
mscr = 0;
if (tx_delay_ps == PHY_RGMII_DELAY_PS_STD)
mscr |= MII_88E1121_PHY_MSCR_TX_DELAY;
else if (tx_delay_ps != PHY_RGMII_DELAY_PS_NONE)
/* ... log an error to kernel log */
return -EINVAL;
if (rx_delay_ps == PHY_RGMII_DELAY_PS_STD)
mscr |= MII_88E1121_PHY_MSCR_RX_DELAY;
else if (rx_delay_ps != PHY_RGMII_DELAY_PS_NONE)
/* ... log an error to kernel log */
return -EINVAL;
return phy_modify_paged(phydev, MII_MARVELL_MSCR_PAGE,
MII_88E1121_PHY_MSCR_REG,
MII_88E1121_PHY_MSCR_DELAY_MASK, mscr);
}
> How can we achieve wider consensus on this and put it into the dt
> specification? Should there be drivers supporting these first?
Provide an illustration of the idea in code form for consideration? ;)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2020-06-18 10:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-16 7:49 [PATCH] net: macb: reject unsupported rgmii delays Helmut Grohne
2020-06-17 9:24 ` Nicolas Ferre
2020-06-17 9:57 ` Vladimir Oltean
2020-06-17 11:15 ` Helmut Grohne
2020-06-17 10:55 ` Russell King - ARM Linux admin
2020-06-17 11:21 ` Helmut Grohne
2020-06-17 11:40 ` Russell King - ARM Linux admin
2020-06-17 11:52 ` Helmut Grohne
2020-06-17 12:08 ` Russell King - ARM Linux admin
2020-06-18 8:14 ` Helmut Grohne
2020-06-18 8:45 ` Russell King - ARM Linux admin
2020-06-18 9:05 ` Helmut Grohne
2020-06-18 10:01 ` Russell King - ARM Linux admin [this message]
2020-06-18 18:26 ` Florian Fainelli
2020-06-18 18:06 ` Florian Fainelli
2020-06-18 18:49 ` Russell King - ARM Linux admin
2020-06-18 19:02 ` Florian Fainelli
2020-06-18 19:10 ` Russell King - ARM Linux admin
2020-06-17 11:32 ` Vladimir Oltean
2020-06-17 11:34 ` Russell King - ARM Linux admin
2020-06-17 11:38 ` Vladimir Oltean
2020-06-17 11:57 ` Russell King - ARM Linux admin
2020-06-18 18:25 ` Florian Fainelli
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=20200618100143.GZ1551@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=helmut.grohne@intenta.de \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.