From: Dimitri Fedrau <dima.fedrau@gmail.com>
To: Stefan Eichenberger <eichest@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: phy: marvell-88q2xxx: add driver for the Marvell 88Q2220 PHY
Date: Mon, 18 Dec 2023 10:09:32 +0100 [thread overview]
Message-ID: <20231218090932.GA4319@debian> (raw)
In-Reply-To: <ZX78ucHcNyEatXLD@eichest-laptop>
Am Sun, Dec 17, 2023 at 02:50:49PM +0100 schrieb Stefan Eichenberger:
> Hi Dimitri,
>
Hi Stefan,
> On Sun, Dec 17, 2023 at 12:15:38PM +0100, Dimitri Fedrau wrote:
> > Am Sun, Dec 17, 2023 at 10:22:54AM +0100 schrieb Andrew Lunn:
> > > > > > + /* Set IEEE power down */
> > > > > > + ret = phy_write_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1, 0x840);
> > > > >
> > > > > 0x800 is MDIO_CTRL1_LPOWER. What is the other? It seems like a speed
> > > > > selection bit?
> > > > >
> > > > The other is MDIO_PMA_CTRL1_SPEED1000. Will fix this in V2.
> > >
> > > It seems odd to set a speed, and power it down. But i guess you have
> > > blindly copied the reference code, so have no idea why?
> > >
> > I agree, absolutely no idea. I already asked the Marvell support for
> > any document describing the init sequence, but they couldn't help me.
> > So I have to stick to the reference code. At least I copied the comments
> > that were part of the init sequence, trying to give some meaning to it.
>
> I also tried to make the 88Q2221 work but didn't find the time yet to
> write a clean version yet. My last minimal patch looks as attached
> bellow.
>
I probably will also get a 88Q2221 PHY, but it could take some time.
When looking at the reference code the only difference for the 88Q2220
and 88Q2221 seems to be an additional init sequence with 28 register writes.
Remaining code seems to be identical. Am I right ? If yes we can use the
same code base here. Besides that it seems that both PHYs share the same
PHY id and are only distinguished by the "Secondary ID Register".
> I think the main thing to make the PHY work is to call this
> sequence to set the master/slave detection threshold:
>
> /* Set detection threshold slave master */
> phy_write_mmd(phydev, MDIO_MMD_AN, 0x8032, 0x2020);
> phy_write_mmd(phydev, MDIO_MMD_AN, 0x8031, 0x0a28);
> phy_write_mmd(phydev, MDIO_MMD_AN, 0x8031, 0x0c28);
>
> Without this sequence the PHY does not work. I was also wondering as
> Andrew wrote why we write twice to the same register. My assumption is
> that 0x8032 is some kind of selector for a subregister while 0x8031 will
> set a 32 bit value. Unforunately, I also didn't get that information
> from Marvell and it is just a wild guess. Please also note that calling
> the sequence in the probe function (as I do it in the example below) is
> definitely wrong, it was just a quick and dirty test I did because I
> wanted to know if it is enough to call it only once.
>
You are maybe right about your guess. Without the init sequence at all I
was able to get the PHY work with a fixed setting (100Mbit/Master).
Maybe it was due to bootstrapping the pins of the PHY. But still I'm not
getting the point. What are we going to do ? Do we want to strip down or
generalize the init sequence ? There is probably a reason for such an
annoying large undocumented series of register writes.
> Are you able to test everyting with the upstream kernel? I'm asking
> because I have to backport a lot of stuff to a downstream kernel 5.15
> from NXP to test the 88Q2221.
>
I'm testing with the upstream kernel, no problems so far. Didn't have to
backport anything or test on another kernel. First version of my driver
was also on NXPs 5.15 kernel. Gladly you already upstreamed some T1
specific code which helped me a lot to reduce code size.
> Further, are you able to verify that autonegotion works? Somehow for me
> this never really worked even when using the example sequence from
> Marvell.
>
Autonegotiation works fine, didn't have any problems. I'm using the
88Q2220M rev B0. I test it with a Media Converter, the NETLion1000 C2T and
with another 88Q2220M PHY. What do you use for testing ?
> Best regards,
> Stefan
>
Best regards,
Dimitri
> diff --git a/drivers/net/phy/marvell-88q2xxx.c b/drivers/net/phy/marvell-88q2xxx.c
> index 94a8c99b58da..15e82e8ff8f4 100644
> --- a/drivers/net/phy/marvell-88q2xxx.c
> +++ b/drivers/net/phy/marvell-88q2xxx.c
> @@ -208,17 +214,26 @@ static int mv88q2xxxx_get_sqi(struct phy_device *phydev)
>
> ret = ret >> 12;
> } else {
> - /* Read from vendor specific registers, they are not documented
> - * but can be found in the Software Initialization Guide. Only
> - * revisions >= A0 are supported.
> - */
> - ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, 0xFC5D, 0x00FF, 0x00AC);
> - if (ret < 0)
> - return ret;
> + if (phydev->drv->phy_id == MARVELL_PHY_ID_88Q2221) {
> + /* Read from vendor specific register, they can be
> + * found in the sample source code of the Q222X API
> + */
> + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, 0xfcd9);
> + if (ret < 0)
> + return ret;
> + } else {
> + /* Read from vendor specific registers, they are not documented
> + * but can be found in the Software Initialization Guide. Only
> + * revisions >= A0 are supported.
> + */
> + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS, 0xFC5D, 0x00FF, 0x00AC);
> + if (ret < 0)
> + return ret;
>
> - ret = phy_read_mmd(phydev, MDIO_MMD_PCS, 0xfc88);
> - if (ret < 0)
> - return ret;
> + ret = phy_read_mmd(phydev, MDIO_MMD_PCS, 0xfc88);
> + if (ret < 0)
> + return ret;
> + }
> }
>
> return ret & 0x0F;
> @@ -229,6 +244,16 @@ static int mv88q2xxxx_get_sqi_max(struct phy_device *phydev)
> return 15;
> }
>
> +static int mv88q2221_probe(struct phy_device *phydev)
> +{
> + /* Set detection threshold slave master */
> + phy_write_mmd(phydev, MDIO_MMD_AN, 0x8032, 0x2020);
> + phy_write_mmd(phydev, MDIO_MMD_AN, 0x8031, 0x0a28);
> + phy_write_mmd(phydev, MDIO_MMD_AN, 0x8031, 0x0c28);
> +
> + return 0;
> +}
> +
> static struct phy_driver mv88q2xxx_driver[] = {
> {
> .phy_id = MARVELL_PHY_ID_88Q2110,
> @@ -243,12 +268,27 @@ static struct phy_driver mv88q2xxx_driver[] = {
> .get_sqi = mv88q2xxxx_get_sqi,
> .get_sqi_max = mv88q2xxxx_get_sqi_max,
> },
> + {
> + .phy_id = MARVELL_PHY_ID_88Q2221,
> + .phy_id_mask = MARVELL_PHY_ID_MASK,
> + .name = "mv88q2221",
> + .get_features = mv88q2xxx_get_features,
> + .config_aneg = mv88q2xxx_config_aneg,
> + .config_init = mv88q2xxx_config_init,
> + .read_status = mv88q2xxx_read_status,
> + .soft_reset = mv88q2xxx_soft_reset,
> + .set_loopback = genphy_c45_loopback,
> + .get_sqi = mv88q2xxxx_get_sqi,
> + .get_sqi_max = mv88q2xxxx_get_sqi_max,
> + .probe = mv88q2221_probe,
> + },
> };
>
> module_phy_driver(mv88q2xxx_driver);
>
> static struct mdio_device_id __maybe_unused mv88q2xxx_tbl[] = {
> { MARVELL_PHY_ID_88Q2110, MARVELL_PHY_ID_MASK },
> + { MARVELL_PHY_ID_88Q2221, MARVELL_PHY_ID_MASK },
> { /*sentinel*/ }
> };
> MODULE_DEVICE_TABLE(mdio, mv88q2xxx_tbl);
next prev parent reply other threads:[~2023-12-18 9:09 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 21:31 [PATCH] net: phy: marvell-88q2xxx: add driver for the Marvell 88Q2220 PHY Dimitri Fedrau
2023-12-16 16:46 ` Andrew Lunn
2023-12-16 22:11 ` Dimitri Fedrau
2023-12-17 9:22 ` Andrew Lunn
2023-12-17 11:15 ` Dimitri Fedrau
2023-12-17 13:50 ` Stefan Eichenberger
2023-12-18 9:09 ` Dimitri Fedrau [this message]
2023-12-18 11:19 ` Stefan Eichenberger
2023-12-19 8:11 ` Dimitri Fedrau
2023-12-19 9:19 ` Stefan Eichenberger
2023-12-19 9:35 ` Dimitri Fedrau
2023-12-21 7:28 ` [PATCH v3 0/4] " Dimitri Fedrau
2023-12-21 7:28 ` [PATCH v3 1/4] net: phy: Add BaseT1 auto-negotiation constants Dimitri Fedrau
2023-12-21 9:45 ` Andrew Lunn
2023-12-21 7:28 ` [PATCH v3 2/4] net: phy: Support 100/1000BT1 linkmode advertisements Dimitri Fedrau
2023-12-21 9:45 ` Andrew Lunn
2023-12-21 7:28 ` [PATCH v3 3/4] net: phy: c45: detect 100/1000BASE-T1 " Dimitri Fedrau
2023-12-21 9:46 ` Andrew Lunn
2023-12-21 7:28 ` [PATCH v3 4/4] net: phy: marvell-88q2xxx: add driver for the Marvell 88Q2220 PHY Dimitri Fedrau
2023-12-21 9:53 ` Andrew Lunn
2023-12-21 11:40 ` Dimitri Fedrau
2023-12-21 13:47 ` Stefan Eichenberger
2023-12-21 14:16 ` Dimitri Fedrau
2023-12-21 14:25 ` Andrew Lunn
2023-12-21 14:45 ` Dimitri Fedrau
2024-01-02 11:36 ` Russell King (Oracle)
2023-12-21 9:44 ` [PATCH v3 0/4] " Andrew Lunn
2023-12-21 11:45 ` Dimitri Fedrau
2023-12-19 15:57 ` [PATCH] " Andrew Lunn
2024-01-05 12:42 ` Dimitri Fedrau
2024-01-05 14:00 ` Andrew Lunn
2024-01-05 15:43 ` Dimitri Fedrau
2024-01-05 16:06 ` Andrew Lunn
2024-01-05 22:20 ` Dimitri Fedrau
2023-12-16 22:41 ` [PATCH v2] " Dimitri Fedrau
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=20231218090932.GA4319@debian \
--to=dima.fedrau@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eichest@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).