From a3cd6eb3259282a68b608fc923121460c0d3d2f7 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Fri, 17 Jan 2025 10:35:41 +0100
Subject: [PATCH 6/9] net: airoha: add initial fixup for GDM3/4 port support

GDM3 and GDM4 require different configuration for max long frame
definition, needs the QDMA to strip CRC on RX and require the SPORT to
be enabled to correctly be identified.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/ethernet/airoha/airoha_eth.c  | 12 ++++++++++--
 drivers/net/ethernet/airoha/airoha_regs.h |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/airoha/airoha_eth.c
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
@@ -514,8 +514,10 @@ static int airoha_fe_init(struct airoha_
 		      FIELD_PREP(IP_ASSEMBLE_PORT_MASK, 0) |
 		      FIELD_PREP(IP_ASSEMBLE_NBQ_MASK, 22));
 
-	airoha_fe_set(eth, REG_GDM_FWD_CFG(3), GDM_PAD_EN_MASK);
-	airoha_fe_set(eth, REG_GDM_FWD_CFG(4), GDM_PAD_EN_MASK);
+	airoha_fe_set(eth, REG_GDM_FWD_CFG(3),
+		      GDM_PAD_EN_MASK | GDM_STRIP_CRC_MASK);
+	airoha_fe_set(eth, REG_GDM_FWD_CFG(4),
+		      GDM_PAD_EN_MASK | GDM_STRIP_CRC_MASK);
 
 	airoha_fe_crsn_qsel_init(eth);
 
@@ -1625,7 +1627,8 @@ static int airoha_dev_open(struct net_de
 	if (err)
 		return err;
 
-	if (netdev_uses_dsa(dev))
+	/* It seems GDM3 and GDM4 needs SPORT enabled to correctly work */
+	if (netdev_uses_dsa(dev) || port->id > 2)
 		airoha_fe_set(qdma->eth, REG_GDM_INGRESS_CFG(port->id),
 			      GDM_STAG_EN_MASK);
 	else
