From: "Marek Behún" <marek.behun@nic.cz>
To: Russell King <rmk+kernel@armlinux.org.uk>
Cc: "Andrew Lunn" <andrew@lunn.ch>,
"Maxime Chevallier" <maxime.chevallier@bootlin.com>,
"Baruch Siach" <baruch@tkos.co.il>,
"Chris Healy" <cphealy@gmail.com>,
"Florian Fainelli" <f.fainelli@gmail.com>,
netdev@vger.kernel.org, "Marek Behún" <marek.behun@nic.cz>
Subject: [PATCH RFC russell-king 3/4] net: phy: marvell10g: change MACTYPE according to phydev->interface
Date: Tue, 11 Aug 2020 00:06:44 +0200 [thread overview]
Message-ID: <20200810220645.19326-4-marek.behun@nic.cz> (raw)
In-Reply-To: <20200810220645.19326-1-marek.behun@nic.cz>
RollBall SFPs contain Marvell 88X3310 PHY, but they have configuration
pins strapped so that MACTYPE is configured in XFI with Rate Matching
mode.
When these SFPs are inserted into a device which only supports lower
speeds on host interface, we need to configure the MACTYPE to a mode
in which the H unit changes SerDes speed according to speed on the
copper interface. I chose to use the
10GBASE-R/5GBASE-R/2500BASE-X/SGMII with AN mode.
Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
drivers/net/phy/marvell10g.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/marvell10g.c b/drivers/net/phy/marvell10g.c
index 29575442b25b2..13a588fa69e77 100644
--- a/drivers/net/phy/marvell10g.c
+++ b/drivers/net/phy/marvell10g.c
@@ -81,6 +81,7 @@ enum {
MV_V2_PORT_CTRL_SWRST = BIT(15),
MV_V2_PORT_CTRL_PWRDOWN = BIT(11),
MV_V2_PORT_MAC_TYPE_MASK = 0x7,
+ MV_V2_PORT_MAC_TYPE_10GBR_SGMII_AN = 0x4,
MV_V2_PORT_MAC_TYPE_RATE_MATCH = 0x6,
/* Temperature control/read registers (88X3310 only) */
MV_V2_TEMP_CTRL = 0xf08a,
@@ -258,17 +259,40 @@ static int mv3310_power_down(struct phy_device *phydev)
static int mv3310_power_up(struct phy_device *phydev)
{
struct mv3310_priv *priv = dev_get_drvdata(&phydev->mdio.dev);
+ u16 val, mask;
int ret;
ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL,
MV_V2_PORT_CTRL_PWRDOWN);
- if (phydev->drv->phy_id != MARVELL_PHY_ID_88X3310 ||
- priv->firmware_ver < 0x00030000)
+ if (ret < 0)
return ret;
- return phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL,
- MV_V2_PORT_CTRL_SWRST);
+ /* TODO: add support for changing MACTYPE on 88E2110 via register 1.C0A4.2:0 */
+ if (phydev->drv->phy_id != MARVELL_PHY_ID_88X3310)
+ return 0;
+
+ val = mask = MV_V2_PORT_CTRL_SWRST;
+
+ switch (phydev->interface) {
+ case PHY_INTERFACE_MODE_SGMII:
+ case PHY_INTERFACE_MODE_2500BASEX:
+ val |= MV_V2_PORT_MAC_TYPE_10GBR_SGMII_AN;
+ mask |= MV_V2_PORT_MAC_TYPE_MASK;
+ break;
+
+ default:
+ /* Otherwise we assume that the MACTYPE is set correctly by strapping pins.
+ * Feel free to add support for changing MACTYPE for other modes
+ * (XAUI/RXAUI/USXGMII).
+ */
+
+ /* reset is not needed for firmware version < 0.3.0.0 when not changing MACTYPE */
+ if (priv->firmware_ver < 0x00030000)
+ return 0;
+ }
+
+ return phy_modify_mmd(phydev, MDIO_MMD_VEND2, MV_V2_PORT_CTRL, mask, val);
}
static int mv3310_reset(struct phy_device *phydev, u32 unit)
--
2.26.2
next prev parent reply other threads:[~2020-08-10 22:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 22:06 [PATCH RFC russell-king 0/4] Support for RollBall 10G copper SFP modules Marek Behún
2020-08-10 22:06 ` [PATCH RFC russell-king 1/4] net: phy: add I2C mdio bus for RollBall compatible SFPs Marek Behún
2020-08-10 22:06 ` [PATCH RFC russell-king 2/4] net: phy: sfp: add support for multigig RollBall modules Marek Behún
2020-08-11 15:15 ` Russell King - ARM Linux admin
2020-08-12 13:33 ` Marek Behún
2020-08-12 14:33 ` Russell King - ARM Linux admin
2020-08-12 14:42 ` Marek Behún
2020-08-10 22:06 ` Marek Behún [this message]
2020-08-11 15:21 ` [PATCH RFC russell-king 3/4] net: phy: marvell10g: change MACTYPE according to phydev->interface Russell King - ARM Linux admin
2020-08-12 14:44 ` Marek Behún
2020-08-12 15:00 ` Russell King - ARM Linux admin
2020-08-12 15:37 ` Marek Behún
2020-08-12 15:48 ` Russell King - ARM Linux admin
2020-08-12 15:59 ` Marek Behún
2020-08-12 16:13 ` Marek Behún
2020-08-12 16:22 ` Russell King - ARM Linux admin
2020-08-12 16:28 ` Marek Behún
2020-08-12 16:30 ` Russell King - ARM Linux admin
2020-08-12 16:01 ` Russell King - ARM Linux admin
2020-08-12 16:15 ` Marek Behún
2020-08-12 15:44 ` Andrew Lunn
2020-08-12 15:54 ` Russell King - ARM Linux admin
2020-08-18 17:28 ` Marek Behún
2020-08-10 22:06 ` [PATCH RFC russell-king 4/4] net: phylink: don't fail attaching phy on 1000base-x/2500base-x mode Marek Behún
2020-08-11 15:08 ` [PATCH RFC russell-king 0/4] Support for RollBall 10G copper SFP modules Russell King - ARM Linux admin
2020-08-12 12:31 ` Marek Behún
2020-08-12 12:31 ` Marek Behún
2020-08-12 14:20 ` Marek Behún
2020-08-17 13:49 ` Russell King - ARM Linux admin
2020-08-18 13:43 ` Marek Behún
2020-08-18 15:08 ` Russell King - ARM Linux admin
2020-08-18 15:30 ` Marek Behún
2020-08-18 15:36 ` Russell King - ARM Linux admin
2020-08-18 15:47 ` Marek Behún
2020-08-18 16:34 ` Russell King - ARM Linux admin
2020-08-19 15:49 ` Marek Behún
2020-08-19 15:54 ` Marek Behún
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=20200810220645.19326-4-marek.behun@nic.cz \
--to=marek.behun@nic.cz \
--cc=andrew@lunn.ch \
--cc=baruch@tkos.co.il \
--cc=cphealy@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
/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).