netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver
@ 2025-04-08 15:53 Christian Marangi
  2025-04-08 15:53 ` [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver Christian Marangi
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Christian Marangi @ 2025-04-08 15:53 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Daniel Golle,
	Qingfang Deng, SkyLake Huang, Matthias Brugger,
	AngeloGioacchino Del Regno, Christian Marangi, Randy Dunlap,
	Simon Horman, Arnd Bergmann, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

When commit 462a3daad679 ("net: phy: mediatek: fix compile-test
dependencies") fixed the dependency, it should have also introduced
an or on COMPILE_TEST to permit this driver to be compile-tested even if
NVMEM_MTK_EFUSE wasn't selected. The driver makes use of NVMEM API that
are always compiled (return error) so the driver can actually be
compiled even without that config.

Fixes: 462a3daad679 ("net: phy: mediatek: fix compile-test dependencies")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/phy/mediatek/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/mediatek/Kconfig b/drivers/net/phy/mediatek/Kconfig
index 2a8ac5aed0f8..c80b4c5b7b66 100644
--- a/drivers/net/phy/mediatek/Kconfig
+++ b/drivers/net/phy/mediatek/Kconfig
@@ -16,7 +16,7 @@ config MEDIATEK_GE_PHY
 config MEDIATEK_GE_SOC_PHY
 	tristate "MediaTek SoC Ethernet PHYs"
 	depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
-	depends on NVMEM_MTK_EFUSE
+	depends on NVMEM_MTK_EFUSE || COMPILE_TEST
 	select MTK_NET_PHYLIB
 	help
 	  Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
-- 
2.48.1


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

* [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver
  2025-04-08 15:53 [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver Christian Marangi
@ 2025-04-08 15:53 ` Christian Marangi
  2025-04-08 17:08   ` Andrew Lunn
  2025-04-08 17:11   ` Russell King (Oracle)
  2025-04-08 15:58 ` [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver Daniel Golle
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 8+ messages in thread
From: Christian Marangi @ 2025-04-08 15:53 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Daniel Golle,
	Qingfang Deng, SkyLake Huang, Matthias Brugger,
	AngeloGioacchino Del Regno, Christian Marangi, Randy Dunlap,
	Simon Horman, Arnd Bergmann, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

Airoha AN7581 SoC ship with a Switch based on the MT753x Switch embedded
in other SoC like the MT7581 and the MT7988. Similar to these they
require configuring some pin to enable LED PHYs.

Add support for the PHY ID for the Airoha embedded Switch and define a
simple probe function to toggle these pins. Also fill the LED functions
and add dedicated function to define LED polarity.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/phy/mediatek/Kconfig      |  4 +-
 drivers/net/phy/mediatek/mtk-ge-soc.c | 62 +++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/mediatek/Kconfig b/drivers/net/phy/mediatek/Kconfig
index c80b4c5b7b66..0fb496757e04 100644
--- a/drivers/net/phy/mediatek/Kconfig
+++ b/drivers/net/phy/mediatek/Kconfig
@@ -15,8 +15,8 @@ config MEDIATEK_GE_PHY
 
 config MEDIATEK_GE_SOC_PHY
 	tristate "MediaTek SoC Ethernet PHYs"
-	depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
-	depends on NVMEM_MTK_EFUSE || COMPILE_TEST
+	depends on (ARM64 && (ARCH_MEDIATEK || ARCH_AIROHA)) || COMPILE_TEST
+	depends on (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || ARCH_AIROHA || COMPILE_TEST
 	select MTK_NET_PHYLIB
 	help
 	  Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
diff --git a/drivers/net/phy/mediatek/mtk-ge-soc.c b/drivers/net/phy/mediatek/mtk-ge-soc.c
index 175cf5239bba..fd0e447ffce7 100644
--- a/drivers/net/phy/mediatek/mtk-ge-soc.c
+++ b/drivers/net/phy/mediatek/mtk-ge-soc.c
@@ -11,8 +11,11 @@
 #include "../phylib.h"
 #include "mtk.h"
 
+#define MTK_PHY_MAX_LEDS			2
+
 #define MTK_GPHY_ID_MT7981			0x03a29461
 #define MTK_GPHY_ID_MT7988			0x03a29481
+#define MTK_GPHY_ID_AN7581			0x03a294c1
 
 #define MTK_EXT_PAGE_ACCESS			0x1f
 #define MTK_PHY_PAGE_STANDARD			0x0000
@@ -1406,6 +1409,53 @@ static int mt7981_phy_probe(struct phy_device *phydev)
 	return mt798x_phy_calibration(phydev);
 }
 
+static int an7581_phy_probe(struct phy_device *phydev)
+{
+	struct mtk_socphy_priv *priv;
+	struct pinctrl *pinctrl;
+
+	/* Toggle pinctrl to enable PHY LED */
+	pinctrl = devm_pinctrl_get_select(&phydev->mdio.dev, "gbe-led");
+	if (IS_ERR(pinctrl))
+		dev_err(&phydev->mdio.bus->dev,
+			"Failed to setup PHY LED pinctrl\n");
+
+	priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	phydev->priv = priv;
+
+	return 0;
+}
+
+static int an7581_phy_led_polarity_set(struct phy_device *phydev, int index,
+				       unsigned long modes)
+{
+	u32 mode;
+	u16 val;
+
+	if (index >= MTK_PHY_MAX_LEDS)
+		return -EINVAL;
+
+	for_each_set_bit(mode, &modes, __PHY_LED_MODES_NUM) {
+		switch (mode) {
+		case PHY_LED_ACTIVE_LOW:
+			val = MTK_PHY_LED_ON_POLARITY;
+			break;
+		case PHY_LED_ACTIVE_HIGH:
+			val = 0;
+			break;
+		default:
+			return -EINVAL;
+		}
+	}
+
+	return phy_modify_mmd(phydev, MDIO_MMD_VEND2, index ?
+			      MTK_PHY_LED1_ON_CTRL : MTK_PHY_LED0_ON_CTRL,
+			      MTK_PHY_LED_ON_POLARITY, val);
+}
+
 static struct phy_driver mtk_socphy_driver[] = {
 	{
 		PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981),
@@ -1441,6 +1491,17 @@ static struct phy_driver mtk_socphy_driver[] = {
 		.led_hw_control_set = mt798x_phy_led_hw_control_set,
 		.led_hw_control_get = mt798x_phy_led_hw_control_get,
 	},
+	{
+		PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581),
+		.name		= "Airoha AN7581 PHY",
+		.probe		= an7581_phy_probe,
+		.led_blink_set	= mt798x_phy_led_blink_set,
+		.led_brightness_set = mt798x_phy_led_brightness_set,
+		.led_hw_is_supported = mt798x_phy_led_hw_is_supported,
+		.led_hw_control_set = mt798x_phy_led_hw_control_set,
+		.led_hw_control_get = mt798x_phy_led_hw_control_get,
+		.led_polarity_set = an7581_phy_led_polarity_set,
+	},
 };
 
 module_phy_driver(mtk_socphy_driver);
@@ -1448,6 +1509,7 @@ module_phy_driver(mtk_socphy_driver);
 static const struct mdio_device_id __maybe_unused mtk_socphy_tbl[] = {
 	{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7981) },
 	{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7988) },
+	{ PHY_ID_MATCH_EXACT(MTK_GPHY_ID_AN7581) },
 	{ }
 };
 
-- 
2.48.1


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

* Re: [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver
  2025-04-08 15:53 [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver Christian Marangi
  2025-04-08 15:53 ` [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver Christian Marangi
@ 2025-04-08 15:58 ` Daniel Golle
  2025-04-08 17:04 ` Andrew Lunn
  2025-04-08 17:57 ` Russell King (Oracle)
  3 siblings, 0 replies; 8+ messages in thread
From: Daniel Golle @ 2025-04-08 15:58 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Qingfang Deng,
	SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
	Randy Dunlap, Simon Horman, Arnd Bergmann, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, Apr 08, 2025 at 05:53:13PM +0200, Christian Marangi wrote:
> When commit 462a3daad679 ("net: phy: mediatek: fix compile-test
> dependencies") fixed the dependency, it should have also introduced
> an or on COMPILE_TEST to permit this driver to be compile-tested even if
> NVMEM_MTK_EFUSE wasn't selected. The driver makes use of NVMEM API that
> are always compiled (return error) so the driver can actually be
> compiled even without that config.
> 
> Fixes: 462a3daad679 ("net: phy: mediatek: fix compile-test dependencies")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

Acked-by: Daniel Golle <daniel@makrotopia.org>

> ---
>  drivers/net/phy/mediatek/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/mediatek/Kconfig b/drivers/net/phy/mediatek/Kconfig
> index 2a8ac5aed0f8..c80b4c5b7b66 100644
> --- a/drivers/net/phy/mediatek/Kconfig
> +++ b/drivers/net/phy/mediatek/Kconfig
> @@ -16,7 +16,7 @@ config MEDIATEK_GE_PHY
>  config MEDIATEK_GE_SOC_PHY
>  	tristate "MediaTek SoC Ethernet PHYs"
>  	depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
> -	depends on NVMEM_MTK_EFUSE
> +	depends on NVMEM_MTK_EFUSE || COMPILE_TEST
>  	select MTK_NET_PHYLIB
>  	help
>  	  Supports MediaTek SoC built-in Gigabit Ethernet PHYs.
> -- 
> 2.48.1
> 

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

* Re: [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver
  2025-04-08 15:53 [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver Christian Marangi
  2025-04-08 15:53 ` [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver Christian Marangi
  2025-04-08 15:58 ` [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver Daniel Golle
@ 2025-04-08 17:04 ` Andrew Lunn
  2025-04-08 17:57 ` Russell King (Oracle)
  3 siblings, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2025-04-08 17:04 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Daniel Golle, Qingfang Deng,
	SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
	Randy Dunlap, Simon Horman, Arnd Bergmann, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, Apr 08, 2025 at 05:53:13PM +0200, Christian Marangi wrote:
> When commit 462a3daad679 ("net: phy: mediatek: fix compile-test
> dependencies") fixed the dependency, it should have also introduced
> an or on COMPILE_TEST to permit this driver to be compile-tested even if
> NVMEM_MTK_EFUSE wasn't selected. The driver makes use of NVMEM API that
> are always compiled (return error) so the driver can actually be
> compiled even without that config.
> 
> Fixes: 462a3daad679 ("net: phy: mediatek: fix compile-test dependencies")
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver
  2025-04-08 15:53 ` [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver Christian Marangi
@ 2025-04-08 17:08   ` Andrew Lunn
  2025-04-08 17:11   ` Russell King (Oracle)
  1 sibling, 0 replies; 8+ messages in thread
From: Andrew Lunn @ 2025-04-08 17:08 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Daniel Golle, Qingfang Deng,
	SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
	Randy Dunlap, Simon Horman, Arnd Bergmann, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, Apr 08, 2025 at 05:53:14PM +0200, Christian Marangi wrote:
> Airoha AN7581 SoC ship with a Switch based on the MT753x Switch embedded
> in other SoC like the MT7581 and the MT7988. Similar to these they
> require configuring some pin to enable LED PHYs.
> 
> Add support for the PHY ID for the Airoha embedded Switch and define a
> simple probe function to toggle these pins. Also fill the LED functions
> and add dedicated function to define LED polarity.
> 
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver
  2025-04-08 15:53 ` [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver Christian Marangi
  2025-04-08 17:08   ` Andrew Lunn
@ 2025-04-08 17:11   ` Russell King (Oracle)
  2025-04-08 17:17     ` Christian Marangi
  1 sibling, 1 reply; 8+ messages in thread
From: Russell King (Oracle) @ 2025-04-08 17:11 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Daniel Golle, Qingfang Deng,
	SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
	Randy Dunlap, Simon Horman, Arnd Bergmann, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, Apr 08, 2025 at 05:53:14PM +0200, Christian Marangi wrote:
>  config MEDIATEK_GE_SOC_PHY
>  	tristate "MediaTek SoC Ethernet PHYs"
> -	depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
> -	depends on NVMEM_MTK_EFUSE || COMPILE_TEST
> +	depends on (ARM64 && (ARCH_MEDIATEK || ARCH_AIROHA)) || COMPILE_TEST
> +	depends on (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || ARCH_AIROHA || COMPILE_TEST

So...
COMPILE_TEST	ARM64	ARCH_AIROHA	ARCH_MEDIATEK	NVMEM_MTK_EFUSE	result
N		N	x		x		x		N
N		Y	N		N		x		N
N		Y	N		Y		N		N
N		Y	N		Y		Y		Y
N		Y	Y		x		x		Y
Y		x	x		x		x		Y

Hence this simplifies to:

	depends on ARM64 || COMPILE_TEST
	depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \
		   COMPILE_TEST

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver
  2025-04-08 17:11   ` Russell King (Oracle)
@ 2025-04-08 17:17     ` Christian Marangi
  0 siblings, 0 replies; 8+ messages in thread
From: Christian Marangi @ 2025-04-08 17:17 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Daniel Golle, Qingfang Deng,
	SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
	Randy Dunlap, Simon Horman, Arnd Bergmann, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, Apr 08, 2025 at 06:11:43PM +0100, Russell King (Oracle) wrote:
> On Tue, Apr 08, 2025 at 05:53:14PM +0200, Christian Marangi wrote:
> >  config MEDIATEK_GE_SOC_PHY
> >  	tristate "MediaTek SoC Ethernet PHYs"
> > -	depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
> > -	depends on NVMEM_MTK_EFUSE || COMPILE_TEST
> > +	depends on (ARM64 && (ARCH_MEDIATEK || ARCH_AIROHA)) || COMPILE_TEST
> > +	depends on (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || ARCH_AIROHA || COMPILE_TEST
> 
> So...
> COMPILE_TEST	ARM64	ARCH_AIROHA	ARCH_MEDIATEK	NVMEM_MTK_EFUSE	result
> N		N	x		x		x		N
> N		Y	N		N		x		N
> N		Y	N		Y		N		N
> N		Y	N		Y		Y		Y
> N		Y	Y		x		x		Y
> Y		x	x		x		x		Y
> 
> Hence this simplifies to:
> 
> 	depends on ARM64 || COMPILE_TEST
> 	depends on ARCH_AIROHA || (ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || \
> 		   COMPILE_TEST
>

Right, I will update in v2.

Hope Andrew is OK with keeping the review tag.

-- 
	Ansuel

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

* Re: [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver
  2025-04-08 15:53 [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver Christian Marangi
                   ` (2 preceding siblings ...)
  2025-04-08 17:04 ` Andrew Lunn
@ 2025-04-08 17:57 ` Russell King (Oracle)
  3 siblings, 0 replies; 8+ messages in thread
From: Russell King (Oracle) @ 2025-04-08 17:57 UTC (permalink / raw)
  To: Christian Marangi
  Cc: Andrew Lunn, Heiner Kallweit, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Daniel Golle, Qingfang Deng,
	SkyLake Huang, Matthias Brugger, AngeloGioacchino Del Regno,
	Randy Dunlap, Simon Horman, Arnd Bergmann, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

On Tue, Apr 08, 2025 at 05:53:13PM +0200, Christian Marangi wrote:
>  config MEDIATEK_GE_SOC_PHY
>  	tristate "MediaTek SoC Ethernet PHYs"
>  	depends on (ARM64 && ARCH_MEDIATEK) || COMPILE_TEST
> -	depends on NVMEM_MTK_EFUSE
> +	depends on NVMEM_MTK_EFUSE || COMPILE_TEST

Isn't this equivalent to:

	depends on (ARM64 && ARCH_MEDIATEK && NVMEM_MTK_EFUSE) || COMPILE_TEST

?

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

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

end of thread, other threads:[~2025-04-08 17:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-08 15:53 [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver Christian Marangi
2025-04-08 15:53 ` [net-next PATCH 2/2] net: phy: mediatek: add Airoha PHY ID to SoC driver Christian Marangi
2025-04-08 17:08   ` Andrew Lunn
2025-04-08 17:11   ` Russell King (Oracle)
2025-04-08 17:17     ` Christian Marangi
2025-04-08 15:58 ` [net-next PATCH 1/2] net: phy: mediatek: permit to compile test GE SOC PHY driver Daniel Golle
2025-04-08 17:04 ` Andrew Lunn
2025-04-08 17:57 ` Russell King (Oracle)

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).