From: "SkyLake Huang (黃啟澤)" <SkyLake.Huang@mediatek.com>
To: "olteanv@gmail.com" <olteanv@gmail.com>,
"andrew@lunn.ch" <andrew@lunn.ch>,
"arinc.unal@arinc9.com" <arinc.unal@arinc9.com>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
"f.fainelli@gmail.com" <f.fainelli@gmail.com>,
"opensource@vdorst.com" <opensource@vdorst.com>,
Sean Wang <Sean.Wang@mediatek.com>,
"kuba@kernel.org" <kuba@kernel.org>,
"edumazet@google.com" <edumazet@google.com>,
"pabeni@redhat.com" <pabeni@redhat.com>,
"dqfext@gmail.com" <dqfext@gmail.com>,
"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"daniel@makrotopia.org" <daniel@makrotopia.org>,
"hkallweit1@gmail.com" <hkallweit1@gmail.com>,
"angelogioacchino.delregno@collabora.com"
<angelogioacchino.delregno@collabora.com>
Cc: "bartel.eerdekens@constell8.be" <bartel.eerdekens@constell8.be>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"florian.fainelli@broadcom.com" <florian.fainelli@broadcom.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"mithat.guner@xeront.com" <mithat.guner@xeront.com>,
"erkin.bozoglu@xeront.com" <erkin.bozoglu@xeront.com>
Subject: Re: [PATCH net v2 1/2] net: dsa: mt7530: fix enabling EEE on MT7531 switch on all boards
Date: Wed, 27 Mar 2024 09:51:11 +0000 [thread overview]
Message-ID: <70bc9c503c8ce1ee821a22e0739344229646dbe2.camel@mediatek.com> (raw)
In-Reply-To: <20240321-for-net-mt7530-fix-eee-for-mt7531-mt7988-v2-1-9af9d5041bfe@arinc9.com>
On Thu, 2024-03-21 at 19:29 +0300, Arınç ÜNAL via B4 Relay wrote:
>
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> From: Arınç ÜNAL <arinc.unal@arinc9.com>
>
> The commit 40b5d2f15c09 ("net: dsa: mt7530: Add support for EEE
> features")
> brought EEE support but did not enable EEE on MT7531 switch MACs. EEE
> is
> enabled on MT7531 switch MACs either by pulling the LAN2LED0 pin low
> on the
> board (bootstrapping), or unsetting the EEE_DIS bit on the trap
> register.
>
> There are existing boards that were not designed to pull the pin low.
> Therefore, unset the EEE_DIS bit on the trap register.
>
> Unlike MT7530, the modifiable trap register won't be populated
> identical to
> the trap status register after reset. Therefore, read from the trap
> status
> register, modify the bits, then write to the modifiable trap
> register.
>
> My testing on MT7531 shows a certain amount of traffic loss when EEE
> is
> enabled. That said, I haven't come across a board that enables EEE.
> So
> enable EEE on the switch MACs but disable EEE advertisement on the
> switch
> PHYs. This way, we don't change the behaviour of the majority of the
> boards
> that have this switch.
>
> With this change, EEE can now be enabled using ethtool.
>
> The disable EEE bit on the trap pertains to the LAN2LED0 pin which is
> usually used to control an LED. Once the bit is unset, the pin will
> be low.
> That will make the active low LED turn on.
>
> The pin is controlled by the switch PHY. It seems that the PHY
> controls the
> pin in the way that it inverts the pin state. That means depending on
> the
> wiring of the LED connected to LAN2LED0 on the board, the LED may be
> on
> without an active link.
>
> Fixes: 40b5d2f15c09 ("net: dsa: mt7530: Add support for EEE
> features")
> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
> Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> ---
> drivers/net/dsa/mt7530.c | 14 ++++++++++++++
> drivers/net/dsa/mt7530.h | 1 +
> 2 files changed, 15 insertions(+)
>
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 678b51f9cea6..6aa99b590329 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -2458,6 +2458,20 @@ mt7531_setup(struct dsa_switch *ds)
> /* Reset the switch through internal reset */
> mt7530_write(priv, MT7530_SYS_CTRL, SYS_CTRL_SW_RST |
> SYS_CTRL_REG_RST);
>
> +/* Allow modifying the trap and enable Energy-Efficient Ethernet
> (EEE).
> + */
> +val = mt7530_read(priv, MT7531_HWTRAP);
> +val |= CHG_STRAP;
> +val &= ~EEE_DIS;
> +mt7530_write(priv, MT7530_MHWTRAP, val);
You may try to set bit 6 of CL45 register dev=0x1f,
reg=0x403(PLL_GROUP_CTL_REG), which is an internal EEE switch called
RG_SYSPLL_DMY2.
Read it out first with "switch command", if you have it:
root@OpenWrt:/# switch phy cl45 r 0 0x1f 0x403
Phy read dev_num=0x1f, reg=0x403, value=0x1091
And then set bit 6:
root@OpenWrt:/# $ switch phy cl45 w 0 0x1f 0x403 0x10d1
root@OpenWrt:/# ethtool --set-eee lan1 eee on tx-lpi on tx-timer 0x1e
advertise 0x28
root@OpenWrt:/# switch phy cl45 r 0 0x7 0x3c
Phy read dev_num=0x7, reg=0x3c, value=0x6
Then you should be able to enable EEE via ethtool without clearing
EEE_DIS bit of MT7530_HWTRAP.
If above CL45 command is good for you, I think this can be moved to
mtk_gephy_config_init() @ mediatek-ge.c, which will lead to cleaner
implementation.
> +
> +/* Disable EEE advertisement on the switch PHYs. */
> +for (i = MT753X_CTRL_PHY_ADDR;
> + i < MT753X_CTRL_PHY_ADDR + MT7530_NUM_PHYS; i++) {
> +mt7531_ind_c45_phy_write(priv, i, MDIO_MMD_AN, MDIO_AN_EEE_ADV,
> + 0);
> +}
Sorry, I still can't figure out why this is needed since we disable
MDIO_AN_EEE_ADV in mediatek-ge.c after reading previous threads. Would
you please provide something else (like dmesg log?) to show that
settings in mtk_gephy_config_init() may fail?
> +
> if (!priv->p5_sgmii) {
> mt7531_pll_setup(priv);
> } else {
> diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h
> index a71166e0a7fc..509ed5362236 100644
> --- a/drivers/net/dsa/mt7530.h
> +++ b/drivers/net/dsa/mt7530.h
> @@ -457,6 +457,7 @@ enum mt7531_clk_skew {
> #define XTAL_FSEL_MBIT(7)
> #define PHY_ENBIT(6)
> #define CHG_STRAPBIT(8)
> +#define EEE_DISBIT(4)
>
> /* Register for hw trap modification */
> #define MT7530_MHWTRAP0x7804
>
> --
> 2.40.1
>
>
next prev parent reply other threads:[~2024-03-27 9:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-21 16:29 [PATCH net v2 0/2] Fix EEE support for MT7531 and MT7988 SoC switch Arınç ÜNAL via B4 Relay
2024-03-21 16:29 ` [PATCH net v2 1/2] net: dsa: mt7530: fix enabling EEE on MT7531 switch on all boards Arınç ÜNAL via B4 Relay
2024-03-27 9:51 ` SkyLake Huang (黃啟澤) [this message]
2024-03-28 13:57 ` Arınç ÜNAL
2024-03-21 16:29 ` [PATCH net v2 2/2] net: dsa: mt7530: fix disabling EEE on failure on MT7531 and MT7988 Arınç ÜNAL via B4 Relay
2024-03-26 9:02 ` Paolo Abeni
2024-03-26 9:19 ` Arınç ÜNAL
2024-03-27 8:46 ` arinc.unal
2024-03-27 15:58 ` Russell King (Oracle)
2024-03-27 15:59 ` Russell King (Oracle)
2024-03-28 14:46 ` Arınç ÜNAL
2024-03-27 15:50 ` Russell King (Oracle)
2024-03-28 14:31 ` Arınç ÜNAL
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=70bc9c503c8ce1ee821a22e0739344229646dbe2.camel@mediatek.com \
--to=skylake.huang@mediatek.com \
--cc=Sean.Wang@mediatek.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=arinc.unal@arinc9.com \
--cc=bartel.eerdekens@constell8.be \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=edumazet@google.com \
--cc=erkin.bozoglu@xeront.com \
--cc=f.fainelli@gmail.com \
--cc=florian.fainelli@broadcom.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=matthias.bgg@gmail.com \
--cc=mithat.guner@xeront.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=opensource@vdorst.com \
--cc=pabeni@redhat.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
all inboxes | Powered by JetHome®