Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
@ 2026-09-09 21:32 Caleb James DeLisle
  2026-09-09 23:02 ` Daniel Golle
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Caleb James DeLisle @ 2026-09-09 21:32 UTC (permalink / raw)
  To: netdev
  Cc: daniel, dqfext, SkyLake.Huang, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Caleb James DeLisle, Matheus Sampaio Queiroga

The EcoNet EN751221 multi-chip module implementation of the MT7530
requires some additional configuration of the PHYs on startup.
The reason for this is not known, but it is possible that it has
to do with the fact that the EN751221 MCM implementation of the
MT7530 runs at an abnormal PLL frequency (362.5Mhz).

Detect whether the MT7530 PHY is attached to the MDIO bus of an
EcoNet EN751221 switch and if so, apply the necessary register
updates.

Co-developed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
---
 drivers/net/phy/mediatek/mtk-ge.c | 61 +++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/drivers/net/phy/mediatek/mtk-ge.c b/drivers/net/phy/mediatek/mtk-ge.c
index 73d9b72f9d9e..42b06c40d703 100644
--- a/drivers/net/phy/mediatek/mtk-ge.c
+++ b/drivers/net/phy/mediatek/mtk-ge.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include <linux/of.h>
 #include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/phy.h>
@@ -62,8 +63,68 @@ static void mtk_gephy_config_init(struct phy_device *phydev)
 		       FIELD_PREP(MTK_MCC_NEARECHO_OFFSET_MASK, 0x3));
 }
 
+static bool mt7530_phy_is_en751221_companion(struct phy_device *phydev)
+{
+	struct device *parent = phydev->mdio.bus->parent;
+
+	return parent && parent->of_node &&
+	       of_device_is_compatible(parent->of_node, "econet,en751221");
+}
+
+/*
+ * The EcoNet reference implementation applies additional tuning to
+ * the PHYs of the multi-chip module MT7530.
+ */
+static int mt7530_phy_en751221_config_init(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = genphy_soft_reset(phydev);
+	if (ret)
+		return ret;
+
+	/* Clause 22 local data. */
+	ret = phy_write(phydev, MII_CTRL1000, 0x1e00);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_write_paged(phydev, MTK_PHY_PAGE_EXTENDED_1, 0x14, 0x3a04);
+	if (ret < 0)
+		return ret;
+
+	/* Clause 45 global/local data from mt7530GePhyCfgLoad(E3.0). */
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x0417, 0x7775);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00a6, 0x0350);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0012, 0xd210);
+	if (ret < 0)
+		return ret;
+
+	/* Vendor profile disables 100/1000BASE-T EEE advertisement. */
+	ret = phy_write_mmd(phydev, MDIO_MMD_AN, 0x003c, 0x0000);
+	if (ret < 0)
+		return ret;
+
+	phydev_info(phydev, "EN751221 companion MT7530 E3.0 PHY profile loaded\n");
+
+	return 0;
+}
+
 static int mt7530_phy_config_init(struct phy_device *phydev)
 {
+	int ret;
+
+	if (mt7530_phy_is_en751221_companion(phydev)) {
+		ret = mt7530_phy_en751221_config_init(phydev);
+		if (ret)
+			return ret;
+	}
+
 	mtk_gephy_config_init(phydev);
 
 	/* Increase post_update_timer */
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-09 21:32 [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM Caleb James DeLisle
@ 2026-09-09 23:02 ` Daniel Golle
  2026-09-09 23:26   ` Caleb James DeLisle
  2026-09-10  2:03 ` Andrew Lunn
  2026-09-11 10:39 ` [PATCH v2 " Caleb James DeLisle
  2 siblings, 1 reply; 11+ messages in thread
From: Daniel Golle @ 2026-09-09 23:02 UTC (permalink / raw)
  To: Caleb James DeLisle
  Cc: netdev, dqfext, SkyLake.Huang, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga

On Wed, Sep 09, 2026 at 09:32:50PM +0000, Caleb James DeLisle wrote:
> The EcoNet EN751221 multi-chip module implementation of the MT7530
> requires some additional configuration of the PHYs on startup.
> The reason for this is not known, but it is possible that it has
> to do with the fact that the EN751221 MCM implementation of the
> MT7530 runs at an abnormal PLL frequency (362.5Mhz).
> 
> Detect whether the MT7530 PHY is attached to the MDIO bus of an
> EcoNet EN751221 switch and if so, apply the necessary register
> updates.
> 
> Co-developed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
> Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
> Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
> ---
>  drivers/net/phy/mediatek/mtk-ge.c | 61 +++++++++++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
> 
> diff --git a/drivers/net/phy/mediatek/mtk-ge.c b/drivers/net/phy/mediatek/mtk-ge.c
> index 73d9b72f9d9e..42b06c40d703 100644
> --- a/drivers/net/phy/mediatek/mtk-ge.c
> +++ b/drivers/net/phy/mediatek/mtk-ge.c
> [...]
>  static int mt7530_phy_config_init(struct phy_device *phydev)
>  {
> +	int ret;
> +
> +	if (mt7530_phy_is_en751221_companion(phydev)) {

Please introduce a `.match_phy_device` operation for both, actual
MT7530 and EN751221, similar eg. to `ksz8051_match_phy_device` in
micrel.c.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-09 23:02 ` Daniel Golle
@ 2026-09-09 23:26   ` Caleb James DeLisle
  2026-09-10  1:55     ` Daniel Golle
  0 siblings, 1 reply; 11+ messages in thread
From: Caleb James DeLisle @ 2026-09-09 23:26 UTC (permalink / raw)
  To: Daniel Golle
  Cc: netdev, dqfext, SkyLake.Huang, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga


On 10/09/2026 01:02, Daniel Golle wrote:
> On Wed, Sep 09, 2026 at 09:32:50PM +0000, Caleb James DeLisle wrote:
>> The EcoNet EN751221 multi-chip module implementation of the MT7530
>> requires some additional configuration of the PHYs on startup.
>> The reason for this is not known, but it is possible that it has
>> to do with the fact that the EN751221 MCM implementation of the
>> MT7530 runs at an abnormal PLL frequency (362.5Mhz).
>>
>> Detect whether the MT7530 PHY is attached to the MDIO bus of an
>> EcoNet EN751221 switch and if so, apply the necessary register
>> updates.
>>
>> Co-developed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
>> Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
>> Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
>> ---
>>   drivers/net/phy/mediatek/mtk-ge.c | 61 +++++++++++++++++++++++++++++++
>>   1 file changed, 61 insertions(+)
>>
>> diff --git a/drivers/net/phy/mediatek/mtk-ge.c b/drivers/net/phy/mediatek/mtk-ge.c
>> index 73d9b72f9d9e..42b06c40d703 100644
>> --- a/drivers/net/phy/mediatek/mtk-ge.c
>> +++ b/drivers/net/phy/mediatek/mtk-ge.c
>> [...]
>>   static int mt7530_phy_config_init(struct phy_device *phydev)
>>   {
>> +	int ret;
>> +
>> +	if (mt7530_phy_is_en751221_companion(phydev)) {
> Please introduce a `.match_phy_device` operation for both, actual
> MT7530 and EN751221, similar eg. to `ksz8051_match_phy_device` in
> micrel.c.

Sounds good, since this will certainly collide with 
https://lore.kernel.org/netdev/20260827065930.2618729-2-cjd@cjdns.fr/ 
would you prefer them in the same patch, or as a patch set? If you'd 
like I can do this and the FE phy as a common patch set. Let me know 
what you prefer.

Thanks,

Caleb



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-09 23:26   ` Caleb James DeLisle
@ 2026-09-10  1:55     ` Daniel Golle
  2026-09-10  6:12       ` Caleb James DeLisle
  0 siblings, 1 reply; 11+ messages in thread
From: Daniel Golle @ 2026-09-10  1:55 UTC (permalink / raw)
  To: Caleb James DeLisle
  Cc: netdev, dqfext, SkyLake.Huang, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga

On Thu, Sep 10, 2026 at 01:26:14AM +0200, Caleb James DeLisle wrote:
> 
> On 10/09/2026 01:02, Daniel Golle wrote:
> > On Wed, Sep 09, 2026 at 09:32:50PM +0000, Caleb James DeLisle wrote:
> > > The EcoNet EN751221 multi-chip module implementation of the MT7530
> > > requires some additional configuration of the PHYs on startup.
> > > The reason for this is not known, but it is possible that it has
> > > to do with the fact that the EN751221 MCM implementation of the
> > > MT7530 runs at an abnormal PLL frequency (362.5Mhz).
> > > 
> > > Detect whether the MT7530 PHY is attached to the MDIO bus of an
> > > EcoNet EN751221 switch and if so, apply the necessary register
> > > updates.
> > > 
> > > Co-developed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
> > > Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
> > > Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
> > > ---
> > >   drivers/net/phy/mediatek/mtk-ge.c | 61 +++++++++++++++++++++++++++++++
> > >   1 file changed, 61 insertions(+)
> > > 
> > > diff --git a/drivers/net/phy/mediatek/mtk-ge.c b/drivers/net/phy/mediatek/mtk-ge.c
> > > index 73d9b72f9d9e..42b06c40d703 100644
> > > --- a/drivers/net/phy/mediatek/mtk-ge.c
> > > +++ b/drivers/net/phy/mediatek/mtk-ge.c
> > > [...]
> > >   static int mt7530_phy_config_init(struct phy_device *phydev)
> > >   {
> > > +	int ret;
> > > +
> > > +	if (mt7530_phy_is_en751221_companion(phydev)) {
> > Please introduce a `.match_phy_device` operation for both, actual
> > MT7530 and EN751221, similar eg. to `ksz8051_match_phy_device` in
> > micrel.c.
> 
> Sounds good, since this will certainly collide with
> https://lore.kernel.org/netdev/20260827065930.2618729-2-cjd@cjdns.fr/ would
> you prefer them in the same patch, or as a patch set? If you'd like I can do
> this and the FE phy as a common patch set. Let me know what you prefer.

I'd do it one driver at a time, starting with mtk-ge.c, already adding
the .match_phy_device logic so it would also avoid binding the MT7530
driver to an ECONET_FEPHY.

The econet-fe-soc.c driver is much larger and may require more rounds
to make all bots and humans happy, so I'd not have the independently
useful mtk-ge.c changes depend on that.

Dumping the PHY register space and comparing it with MT7530 could also
help to indentify any better way than relying on the parent DT
compatible which *is* a bit of a stretch (but could well be
unavoidable, of course).


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-09 21:32 [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM Caleb James DeLisle
  2026-09-09 23:02 ` Daniel Golle
@ 2026-09-10  2:03 ` Andrew Lunn
  2026-09-10  7:01   ` Caleb James DeLisle
  2026-09-11 10:39 ` [PATCH v2 " Caleb James DeLisle
  2 siblings, 1 reply; 11+ messages in thread
From: Andrew Lunn @ 2026-09-10  2:03 UTC (permalink / raw)
  To: Caleb James DeLisle
  Cc: netdev, daniel, dqfext, SkyLake.Huang, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga

> +	/* Clause 22 local data. */
> +	ret = phy_write(phydev, MII_CTRL1000, 0x1e00);

Please express this using

/* 1000BASE-T Control register */
#define ADVERTISE_1000FULL	0x0200  /* Advertise 1000BASE-T full duplex */
#define ADVERTISE_1000HALF	0x0100  /* Advertise 1000BASE-T half duplex */
#define CTL1000_PREFER_MASTER	0x0400  /* prefer to operate as master */
#define CTL1000_AS_MASTER	0x0800
#define CTL1000_ENABLE_MASTER	0x1000

Once we have symbolic names, it might be obvious what this is doing,
and if there is a better way to do it.


> +	/* Vendor profile disables 100/1000BASE-T EEE advertisement. */
> +	ret = phy_write_mmd(phydev, MDIO_MMD_AN, 0x003c, 0x0000);
> +	if (ret < 0)
> +		return ret;

Any idea why? Is EEE broken? If it is, phy_disable_eee().

    Andrew


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-10  1:55     ` Daniel Golle
@ 2026-09-10  6:12       ` Caleb James DeLisle
  2026-09-11 10:48         ` Caleb James DeLisle
  0 siblings, 1 reply; 11+ messages in thread
From: Caleb James DeLisle @ 2026-09-10  6:12 UTC (permalink / raw)
  To: Daniel Golle
  Cc: netdev, dqfext, SkyLake.Huang, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga


On 10/09/2026 03:55, Daniel Golle wrote:
> On Thu, Sep 10, 2026 at 01:26:14AM +0200, Caleb James DeLisle wrote:
>> On 10/09/2026 01:02, Daniel Golle wrote:
>>> On Wed, Sep 09, 2026 at 09:32:50PM +0000, Caleb James DeLisle wrote:
>>>> The EcoNet EN751221 multi-chip module implementation of the MT7530
>>>> requires some additional configuration of the PHYs on startup.
>>>> The reason for this is not known, but it is possible that it has
>>>> to do with the fact that the EN751221 MCM implementation of the
>>>> MT7530 runs at an abnormal PLL frequency (362.5Mhz).
>>>>
>>>> Detect whether the MT7530 PHY is attached to the MDIO bus of an
>>>> EcoNet EN751221 switch and if so, apply the necessary register
>>>> updates.
>>>>
>>>> Co-developed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
>>>> Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
>>>> Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
>>>> ---
>>>>    drivers/net/phy/mediatek/mtk-ge.c | 61 +++++++++++++++++++++++++++++++
>>>>    1 file changed, 61 insertions(+)
>>>>
>>>> diff --git a/drivers/net/phy/mediatek/mtk-ge.c b/drivers/net/phy/mediatek/mtk-ge.c
>>>> index 73d9b72f9d9e..42b06c40d703 100644
>>>> --- a/drivers/net/phy/mediatek/mtk-ge.c
>>>> +++ b/drivers/net/phy/mediatek/mtk-ge.c
>>>> [...]
>>>>    static int mt7530_phy_config_init(struct phy_device *phydev)
>>>>    {
>>>> +	int ret;
>>>> +
>>>> +	if (mt7530_phy_is_en751221_companion(phydev)) {
>>> Please introduce a `.match_phy_device` operation for both, actual
>>> MT7530 and EN751221, similar eg. to `ksz8051_match_phy_device` in
>>> micrel.c.
>> Sounds good, since this will certainly collide with
>> https://lore.kernel.org/netdev/20260827065930.2618729-2-cjd@cjdns.fr/ would
>> you prefer them in the same patch, or as a patch set? If you'd like I can do
>> this and the FE phy as a common patch set. Let me know what you prefer.
> I'd do it one driver at a time, starting with mtk-ge.c, already adding
> the .match_phy_device logic so it would also avoid binding the MT7530
> driver to an ECONET_FEPHY.
>
> The econet-fe-soc.c driver is much larger and may require more rounds
> to make all bots and humans happy, so I'd not have the independently
> useful mtk-ge.c changes depend on that.
Good point, so I can make mtk-ge so it won't interfere with "any future 
FE PHY with the same ID" with the understanding that this PHY is moving 
along at it's own pace.
>
> Dumping the PHY register space and comparing it with MT7530 could also
> help to indentify any better way than relying on the parent DT
> compatible which *is* a bit of a stretch (but could well be
> unavoidable, of course).

I'll give it a shot but I have low confidence in it because AFAIK this 
is actually a real MT7530 MCM just like MT7621 but it just happens to be 
clocked to a weird PLL frequency.


Thanks,

Caleb

>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-10  2:03 ` Andrew Lunn
@ 2026-09-10  7:01   ` Caleb James DeLisle
  0 siblings, 0 replies; 11+ messages in thread
From: Caleb James DeLisle @ 2026-09-10  7:01 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, daniel, dqfext, SkyLake.Huang, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga


On 10/09/2026 04:03, Andrew Lunn wrote:
>> +	/* Clause 22 local data. */
>> +	ret = phy_write(phydev, MII_CTRL1000, 0x1e00);
> Please express this using
>
> /* 1000BASE-T Control register */
> #define ADVERTISE_1000FULL	0x0200  /* Advertise 1000BASE-T full duplex */
> #define ADVERTISE_1000HALF	0x0100  /* Advertise 1000BASE-T half duplex */
> #define CTL1000_PREFER_MASTER	0x0400  /* prefer to operate as master */
> #define CTL1000_AS_MASTER	0x0800
> #define CTL1000_ENABLE_MASTER	0x1000
>
> Once we have symbolic names, it might be obvious what this is doing,
> and if there is a better way to do it.
>
>
>> +	/* Vendor profile disables 100/1000BASE-T EEE advertisement. */
>> +	ret = phy_write_mmd(phydev, MDIO_MMD_AN, 0x003c, 0x0000);
>> +	if (ret < 0)
>> +		return ret;
> Any idea why? Is EEE broken? If it is, phy_disable_eee().


I am so sorry, we had this entire conversation about the other PHY and I 
did not check carefully enough that this one is doing the same thing. I 
will test and submit the same solution we arrived at over there.


Thanks,

Caleb


>
>      Andrew


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-09 21:32 [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM Caleb James DeLisle
  2026-09-09 23:02 ` Daniel Golle
  2026-09-10  2:03 ` Andrew Lunn
@ 2026-09-11 10:39 ` Caleb James DeLisle
  2026-09-11 11:58   ` Andrew Lunn
  2 siblings, 1 reply; 11+ messages in thread
From: Caleb James DeLisle @ 2026-09-11 10:39 UTC (permalink / raw)
  To: netdev
  Cc: daniel, dqfext, SkyLake.Huang, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Caleb James DeLisle, Matheus Sampaio Queiroga

The EcoNet EN751221 multi-chip module implementation of the MT7530
requires some additional configuration of the PHYs on startup.
The reason for this is not known, but it is possible that it has
to do with the fact that the EN751221 MCM implementation of the
MT7530 runs at an abnormal PLL frequency (362.5Mhz).

Detect whether the MT7530 PHY is attached to the MDIO bus of an
EcoNet EN751221 switch and if so, apply the necessary register
updates. Additionally, never attempt to configure an MT7530
identified PHY which does not have gigabit support because the same
ID is used for another (FE) PHY.

Of note: MDIO_AN_EEE_ADV must be zero at startup or else link will
fail to connect. Setting MDIO_AN_EEE_ADV to 6 after link is brought
up will make EEE work when cable is next plugged in, but link fails
to downgrade to 100mb if gigabit is not possible, leaving a
"connected" (nonfunctional) gigabit link.

Co-developed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
Signed-off-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
Signed-off-by: Caleb James DeLisle <cjd@cjdns.fr>
---
 drivers/net/phy/mediatek/mtk-ge.c | 61 +++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/drivers/net/phy/mediatek/mtk-ge.c b/drivers/net/phy/mediatek/mtk-ge.c
index 73d9b72f9d9e..42b06c40d703 100644
--- a/drivers/net/phy/mediatek/mtk-ge.c
+++ b/drivers/net/phy/mediatek/mtk-ge.c
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include <linux/of.h>
 #include <linux/bitfield.h>
 #include <linux/module.h>
 #include <linux/phy.h>
@@ -62,8 +63,68 @@ static void mtk_gephy_config_init(struct phy_device *phydev)
 		       FIELD_PREP(MTK_MCC_NEARECHO_OFFSET_MASK, 0x3));
 }
 
+static bool mt7530_phy_is_en751221_companion(struct phy_device *phydev)
+{
+	struct device *parent = phydev->mdio.bus->parent;
+
+	return parent && parent->of_node &&
+	       of_device_is_compatible(parent->of_node, "econet,en751221");
+}
+
+/*
+ * The EcoNet reference implementation applies additional tuning to
+ * the PHYs of the multi-chip module MT7530.
+ */
+static int mt7530_phy_en751221_config_init(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = genphy_soft_reset(phydev);
+	if (ret)
+		return ret;
+
+	/* Clause 22 local data. */
+	ret = phy_write(phydev, MII_CTRL1000, 0x1e00);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_write_paged(phydev, MTK_PHY_PAGE_EXTENDED_1, 0x14, 0x3a04);
+	if (ret < 0)
+		return ret;
+
+	/* Clause 45 global/local data from mt7530GePhyCfgLoad(E3.0). */
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND2, 0x0417, 0x7775);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x00a6, 0x0350);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0x0012, 0xd210);
+	if (ret < 0)
+		return ret;
+
+	/* Vendor profile disables 100/1000BASE-T EEE advertisement. */
+	ret = phy_write_mmd(phydev, MDIO_MMD_AN, 0x003c, 0x0000);
+	if (ret < 0)
+		return ret;
+
+	phydev_info(phydev, "EN751221 companion MT7530 E3.0 PHY profile loaded\n");
+
+	return 0;
+}
+
 static int mt7530_phy_config_init(struct phy_device *phydev)
 {
+	int ret;
+
+	if (mt7530_phy_is_en751221_companion(phydev)) {
+		ret = mt7530_phy_en751221_config_init(phydev);
+		if (ret)
+			return ret;
+	}
+
 	mtk_gephy_config_init(phydev);
 
 	/* Increase post_update_timer */
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-10  6:12       ` Caleb James DeLisle
@ 2026-09-11 10:48         ` Caleb James DeLisle
  0 siblings, 0 replies; 11+ messages in thread
From: Caleb James DeLisle @ 2026-09-11 10:48 UTC (permalink / raw)
  To: Daniel Golle
  Cc: netdev, dqfext, SkyLake.Huang, andrew, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga

>>
>> Dumping the PHY register space and comparing it with MT7530 could also
>> help to indentify any better way than relying on the parent DT
>> compatible which *is* a bit of a stretch (but could well be
>> unavoidable, of course).
>
> I'll give it a shot but I have low confidence in it because AFAIK this 
> is actually a real MT7530 MCM just like MT7621 but it just happens to 
> be clocked to a weird PLL frequency.


I just sent a v2 and I didn't find a register that looks obviously like 
a chip sub-id so I left the check based on the DT. But since I have no 
documentation on any of this, here are the differences I found in case 
you or someone else may know something that I don't.


I dumped the pages (g0-g7,l0-l4,ext,misc,lpi,test,tr) and the 
MDIO_MMD_VEND(1|2) of non-0 non-active PHYs on MT7621 and EN7526G. The 
differences that seem potentially relevant are:


MT7621:
EXT   23 (0x17): 0x0800
MISC  20 (0x14): 0x0200
MISC  21 (0x15): 0xffff

EN7526G:
EXT   23 (0x17): 0x1800
MISC  20 (0x14): 0xffff
MISC  21 (0x15): 0x00fe


MMD is here: 
https://docs.google.com/spreadsheets/d/1kzdVxYqu4cTpe6ascNshn5PoCmxrbTkr3bAuWkqKkeg/edit?gid=835011309#gid=835011309 
with about 16 differences in total.


And regarding what's being changed by the patch, the registers, their 
MT7621 value, and the value set by the driver are as follows:

EXT 0x14 (MTK_PHY_AUX_CTRL_AND_STATUS) -> MT7621 = 0x3a55, EN751221 
sets 0x3a04

MDIO_MMD_VEND2 0x417 -> MT7521 = 0x7773, EN751221 sets 0x7775

MDIO_MMD_VEND1 0xa6 -> MT7621 = 0x03e0, EN751221 sets 0x0350

MDIO_MMD_VEND1 0x12 -> MT7621 = 0x7210, EN751221 sets 0xd210

The other difference of this implementation is both master/slave 
negotiation and EEE are unreliable. Maybe these give a hint as to what's 
different with this implementation - whether it's same silicon different 
frequency, different package, different FAB run, etc.


Thanks,

Caleb



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-11 10:39 ` [PATCH v2 " Caleb James DeLisle
@ 2026-09-11 11:58   ` Andrew Lunn
  2026-09-11 12:03     ` Caleb James DeLisle
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Lunn @ 2026-09-11 11:58 UTC (permalink / raw)
  To: Caleb James DeLisle
  Cc: netdev, daniel, dqfext, SkyLake.Huang, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga

> +	/* Clause 22 local data. */
> +	ret = phy_write(phydev, MII_CTRL1000, 0x1e00);

Didn't i ask for 0x1e00 to be replaced with standard macros?

> +	/* Vendor profile disables 100/1000BASE-T EEE advertisement. */
> +	ret = phy_write_mmd(phydev, MDIO_MMD_AN, 0x003c, 0x0000);
> +	if (ret < 0)
> +		return ret;

And didn't i ask if EEE is broken? We have infrastructure for that,
please use it.

Also, please start a new thread for every version of a patch
series. The CI tools don't always pick up replies to previous patch
versions, it thinks it is just ongoing discussion.

    Andrew

---
pw-bot: cr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM
  2026-09-11 11:58   ` Andrew Lunn
@ 2026-09-11 12:03     ` Caleb James DeLisle
  0 siblings, 0 replies; 11+ messages in thread
From: Caleb James DeLisle @ 2026-09-11 12:03 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, daniel, dqfext, SkyLake.Huang, hkallweit1, linux, davem,
	edumazet, kuba, pabeni, matthias.bgg, angelogioacchino.delregno,
	linux-kernel, linux-arm-kernel, linux-mediatek,
	Matheus Sampaio Queiroga


On 11/09/2026 13:58, Andrew Lunn wrote:
>> +	/* Clause 22 local data. */
>> +	ret = phy_write(phydev, MII_CTRL1000, 0x1e00);
> Didn't i ask for 0x1e00 to be replaced with standard macros?


Oh no I somehow re-sent the old patch. So sorry, I'll re-send in a minute.


Caleb



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-09-11 13:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 21:32 [PATCH net-next] net: phy: mediatek: support MT7530 PHYs on EN71221 MCM Caleb James DeLisle
2026-09-09 23:02 ` Daniel Golle
2026-09-09 23:26   ` Caleb James DeLisle
2026-09-10  1:55     ` Daniel Golle
2026-09-10  6:12       ` Caleb James DeLisle
2026-09-11 10:48         ` Caleb James DeLisle
2026-09-10  2:03 ` Andrew Lunn
2026-09-10  7:01   ` Caleb James DeLisle
2026-09-11 10:39 ` [PATCH v2 " Caleb James DeLisle
2026-09-11 11:58   ` Andrew Lunn
2026-09-11 12:03     ` Caleb James DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox