From: "Arınç ÜNAL" <arinc.unal@arinc9.com>
To: Sean Wang <sean.wang@mediatek.com>,
Landen Chao <Landen.Chao@mediatek.com>,
DENG Qingfang <dqfext@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Russell King <linux@armlinux.org.uk>
Cc: "Russell King" <rmk+kernel@armlinux.org.uk>,
"René van Dorst" <opensource@vdorst.com>,
"Alexander Couzens" <lynxis@fe80.eu>,
"Ilya Lipnitskiy" <ilya.lipnitskiy@gmail.com>,
"Richard van Schagen" <richard@routerhints.com>,
"Frank Wunderlich" <frank-w@public-files.de>,
erkin.bozoglu@xeront.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [RFC PATCH net] net: dsa: mt7530: move PLL setup out of port 6 pad configuration
Date: Mon, 6 Mar 2023 16:19:18 +0300 [thread overview]
Message-ID: <f8669264-0c96-0337-2293-4d215e313b93@arinc9.com> (raw)
In-Reply-To: <20230304125453.53476-1-arinc.unal@arinc9.com>
On 4.03.2023 15:54, arinc9.unal@gmail.com wrote:
> From: Arınç ÜNAL <arinc.unal@arinc9.com>
>
> Move the PLL setup of the MT7530 switch out of the pad configuration of
> port 6 to mt7530_setup, after reset.
>
> This fixes the improper initialisation of the switch when only port 5 is
> used as a CPU port.
>
> Add supported phy modes of port 5 on the PLL setup.
>
> Remove now incorrect comment regarding P5 as GMAC5.
>
> Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
> Fixes: 38f790a80560 ("net: dsa: mt7530: Add support for port 5")
> Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> ---
>
> I'm trying to mimic this change by Alexander [0] for the MT7530 switch.
> This is already the case for MT7530 and MT7531 on the MediaTek ethernet
> driver on U-Boot [1] [2].
>
> [0] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=42bc4fafe359ed6b73602b7a2dba0dd99588f8ce
> [1] https://github.com/u-boot/u-boot/blob/a94ab561e2f49a80d8579930e840b810ab1a1330/drivers/net/mtk_eth.c#L729
> [2] https://github.com/u-boot/u-boot/blob/a94ab561e2f49a80d8579930e840b810ab1a1330/drivers/net/mtk_eth.c#L903
>
> There are some parts I couldn't figure out myself with my limited C
> knowledge. I've pointed them out on the code. Vladimir, could you help?
>
> There is a lot of code which is only needed for port 6 or trgmii on port 6,
> but runs whether port 6 or trgmii is used or not. For now, the best I can
> do is to fix port 5 so it works without port 6 being used.
>
> The U-Boot driver seems to be much more organised so it could be taken as
> a reference to sort out this DSA driver further.
>
> Also, now that the pad setup for mt7530 is also moved somewhere else, can
> we completely get rid of @pad_setup?
>
> Arınç
>
> ---
> drivers/net/dsa/mt7530.c | 46 +++++++++++++++++++++++++++++-----------
> 1 file changed, 34 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 0e99de26d159..fb20ce4f443e 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -395,9 +395,8 @@ mt7530_fdb_write(struct mt7530_priv *priv, u16 vid,
>
> /* Setup TX circuit including relevant PAD and driving */
> static int
> -mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
> +mt7530_pad_clk_setup(struct mt7530_priv *priv, phy_interface_t interface)
> {
> - struct mt7530_priv *priv = ds->priv;
> u32 ncpo1, ssc_delta, trgint, i, xtal;
>
> xtal = mt7530_read(priv, MT7530_MHWTRAP) & HWTRAP_XTAL_MASK;
> @@ -409,9 +408,32 @@ mt7530_pad_clk_setup(struct dsa_switch *ds, phy_interface_t interface)
> return -EINVAL;
> }
>
> + /* Is setting trgint to 0 really needed for the !trgint check? */
> + trgint = 0;
> +
> + /* FIXME: run this switch if p5 is defined on the devicetree */
> + /* and change interface to the phy-mode of port 5 */
> + switch (interface) {
> + case PHY_INTERFACE_MODE_GMII:
> + /* PLL frequency: 125MHz */
> + ncpo1 = 0x0c80;
> + break;
> + case PHY_INTERFACE_MODE_MII:
> + break;
> + case PHY_INTERFACE_MODE_RGMII:
> + /* PLL frequency: 125MHz */
> + ncpo1 = 0x0c80;
> + break;
> + default:
> + dev_err(priv->dev, "xMII interface %d not supported\n",
> + interface);
> + return -EINVAL;
> + }
> +
> + /* FIXME: run this switch if p6 is defined on the devicetree */
> + /* and change interface to the phy-mode of port 6 */
> switch (interface) {
> case PHY_INTERFACE_MODE_RGMII:
> - trgint = 0;
> /* PLL frequency: 125MHz */
> ncpo1 = 0x0c80;
> break;
> @@ -2172,7 +2194,11 @@ mt7530_setup(struct dsa_switch *ds)
> SYS_CTRL_PHY_RST | SYS_CTRL_SW_RST |
> SYS_CTRL_REG_RST);
>
> - /* Enable Port 6 only; P5 as GMAC5 which currently is not supported */
> + /* Setup switch core pll */
> + /* FIXME: feed the phy-mode of port 5 and 6, if the ports are defined on the devicetree */
> + mt7530_pad_clk_setup(priv, interface);
Unlike mt7531_pll_setup, there are return codes on mt7530_pad_clk_setup
so we may need to check for the return code here.
Arınç
next prev parent reply other threads:[~2023-03-06 13:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-04 12:54 arinc9.unal
2023-03-04 13:04 ` Russell King (Oracle)
2023-03-06 13:18 ` Arınç ÜNAL
2023-03-06 13:19 ` Arınç ÜNAL [this message]
2023-03-06 15:45 ` Vladimir Oltean
2023-03-06 17:03 ` Arınç ÜNAL
2023-03-06 20:19 ` Vladimir Oltean
2023-03-07 11:26 ` Arınç ÜNAL
2023-03-07 11:37 ` Vladimir Oltean
2023-03-07 11:51 ` 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=f8669264-0c96-0337-2293-4d215e313b93@arinc9.com \
--to=arinc.unal@arinc9.com \
--cc=Landen.Chao@mediatek.com \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=davem@davemloft.net \
--cc=dqfext@gmail.com \
--cc=edumazet@google.com \
--cc=erkin.bozoglu@xeront.com \
--cc=f.fainelli@gmail.com \
--cc=frank-w@public-files.de \
--cc=ilya.lipnitskiy@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=lynxis@fe80.eu \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=opensource@vdorst.com \
--cc=pabeni@redhat.com \
--cc=richard@routerhints.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=sean.wang@mediatek.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®