From 15847e1f56b7f9423095cd96fd9d524a41bee814 Mon Sep 17 00:00:00 2001
From: Ziyang Huang <hzyitc@outlook.com>
Date: Sun, 8 Sep 2024 15:24:07 +0800
Subject: [PATCH] hsl_phy: split MP_PHY config

Compiling the MP_PHY driver for ipq50xx is disabled in the Makefile in
favor of a native driver being upstreamed. As such, conditionally disable 
unneeded flags and code associated to initializing the MP GE PHY that 
would otherwise conflict with the native driver.

Signed-off-by: Ziyang Huang <hzyitc@outlook.com>
Signed-off-by: George Moussalem <george.moussalem@outlook.com>
---
 config                         | 1 +
 make/linux_opt.mk              | 5 +++++
 src/adpt/mp/adpt_mp_portctrl.c | 4 ++++
 src/hsl/phy/Makefile           | 8 +-------
 src/hsl/phy/hsl_phy.c          | 4 ++--
 5 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/config b/config
index 99d99dff..1f74e4f8 100644
--- a/config
+++ b/config
@@ -299,6 +299,7 @@ else ifeq (DESS, $(CHIP_TYPE))
 else ifeq (MP, $(CHIP_TYPE))
 	IN_QCA803X_PHY=TRUE
 	IN_QCA808X_PHY=TRUE
+	IN_MP_PHY=TRUE
 	IN_SFP_PHY=TRUE
 	IN_SFP=TRUE
 else ifeq (APPE, $(CHIP_TYPE))
diff --git a/make/linux_opt.mk b/make/linux_opt.mk
index 6936b754..66b08ef5 100644
--- a/make/linux_opt.mk
+++ b/make/linux_opt.mk
@@ -183,6 +183,11 @@ endif
 ifeq (TRUE, $(IN_QCA808X_PHY))
   MODULE_CFLAG += -DIN_QCA808X_PHY
 endif
+
+ifeq (TRUE, $(IN_MP_PHY))
+  MODULE_CFLAG += -DIN_MP_PHY
+endif
+
 ifeq (TRUE, $(IN_SFP_PHY))
   MODULE_CFLAG += -DIN_SFP_PHY
 endif
diff --git a/src/adpt/mp/adpt_mp_portctrl.c b/src/adpt/mp/adpt_mp_portctrl.c
index 2c983fff..db60fc72 100644
--- a/src/adpt/mp/adpt_mp_portctrl.c
+++ b/src/adpt/mp/adpt_mp_portctrl.c
@@ -92,12 +92,15 @@ static sw_error_t
 adpt_mp_port_reset_set(a_uint32_t dev_id, a_uint32_t port_id)
 {
 	sw_error_t rv = 0;
+#ifdef IN_MP_PHY
 	a_uint32_t phy_addr;
 	hsl_phy_ops_t *phy_drv;
+#endif
 
 	ADPT_DEV_ID_CHECK(dev_id);
 
 	if (port_id == SSDK_PHYSICAL_PORT1) {
+#ifdef IN_MP_PHY
 		/*internal gephy reset*/
 		SW_RTN_ON_NULL (phy_drv = hsl_phy_api_ops_get(dev_id,
 				port_id));
@@ -107,6 +110,7 @@ adpt_mp_port_reset_set(a_uint32_t dev_id, a_uint32_t port_id)
 		SW_RTN_ON_ERROR (rv);
 		rv = phy_drv->phy_function_reset(dev_id, phy_addr, PHY_FIFO_RESET);
 		SW_RTN_ON_ERROR (rv);
+#endif
 	} else if (port_id == SSDK_PHYSICAL_PORT2) {
 		rv = adpt_mp_uniphy_adapter_port_reset(dev_id, port_id);
 	} else {
diff --git a/src/hsl/phy/Makefile b/src/hsl/phy/Makefile
index 68d0679f..0eae9377 100755
--- a/src/hsl/phy/Makefile
+++ b/src/hsl/phy/Makefile
@@ -23,7 +23,7 @@ ifeq (ISIS, $(CHIP_TYPE))
   SRC_LIST = f1_phy.c
 endif
 
-ifeq (MP, $(CHIP_TYPE))
+ifeq (TRUE, $(IN_MP_PHY))
   SRC_LIST = mpge_phy.c
 ifeq (TRUE, $(IN_LED))
   SRC_LIST += mpge_led.c
@@ -40,12 +40,6 @@ endif
 
 ifeq (ALL_CHIP, $(CHIP_TYPE))
      SRC_LIST = f1_phy.c f2_phy.c malibu_phy.c
-ifneq (,$(filter MP, $(SUPPORT_CHIP)))
-     SRC_LIST += mpge_phy.c
-ifeq (TRUE, $(IN_LED))
-     SRC_LIST += mpge_led.c
-endif
-endif
 endif
 
 ifeq (NONHK_CHIP, $(CHIP_TYPE))
diff --git a/src/hsl/phy/hsl_phy.c b/src/hsl/phy/hsl_phy.c
index f2cf90e2..efab2343 100644
--- a/src/hsl/phy/hsl_phy.c
+++ b/src/hsl/phy/hsl_phy.c
@@ -28,7 +28,7 @@
 #if defined(ATHENA) ||defined(SHIVA) ||defined(HORUS)
 #include <f2_phy.h>
 #endif
-#ifdef MP
+#ifdef IN_MP_PHY
 #include "mpge_phy.h"
 #endif
 #ifdef IN_MALIBU_PHY
@@ -94,7 +94,7 @@ phy_driver_instance_t ssdk_phy_driver[] =
 	#else
 	{SFP_PHY_CHIP, {0}, NULL, NULL, NULL},
 	#endif
-	#ifdef MP
+	#ifdef IN_MP_PHY
 	{MPGE_PHY_CHIP, {0}, NULL, mpge_phy_init, NULL},
 	#else
 	{MPGE_PHY_CHIP, {0}, NULL, NULL, NULL},
-- 
2.40.1

