From 7dd27606d9b7f28a7367e4b9444bed7d573f4b6c Mon Sep 17 00:00:00 2001
From: Camelia Groza <camelia.groza@nxp.com>
Date: Fri, 23 Mar 2018 16:33:19 +0200
Subject: [PATCH] sdk_fman: fix probing of 10G ports on T102x

Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
 .../sdk_fman/src/wrapper/lnxwrp_fm_port.c          | 24 +++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

--- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm_port.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm_port.c
@@ -388,7 +388,14 @@ static t_LnxWrpFmPortDev *ReadFmPortDevT
 			settings.param.specificParams.nonRxParams.qmChannel =
 			p_LnxWrpFmPortDev->txCh;
 	} else if (of_device_is_compatible(port_node, "fsl,fman-port-10g-tx")) {
+#ifndef CONFIG_FMAN_ARM
+		/* On T102x, the 10G TX port IDs start from 0x28 */
+		if (IS_T1023_T1024)
+			tmp_prop -= 0x28;
+		else
+#endif
 		tmp_prop -= 0x30;
+
 		if (unlikely(tmp_prop>= FM_MAX_NUM_OF_10G_TX_PORTS)) {
 			REPORT_ERROR(MAJOR, E_INVALID_VALUE,
 					("of_get_property(%s, cell-index) failed",
@@ -399,7 +406,7 @@ static t_LnxWrpFmPortDev *ReadFmPortDevT
 			FM_MAX_NUM_OF_1G_TX_PORTS];
 #ifndef CONFIG_FMAN_ARM
 		if (IS_T1023_T1024)
-			p_LnxWrpFmPortDev = &p_LnxWrpFmDev->txPorts[*uint32_prop];
+			p_LnxWrpFmPortDev = &p_LnxWrpFmDev->txPorts[tmp_prop];
 #endif
 
 		p_LnxWrpFmPortDev->id = tmp_prop;
@@ -437,7 +444,14 @@ static t_LnxWrpFmPortDev *ReadFmPortDevT
 		if (p_LnxWrpFmDev->pcdActive)
 			p_LnxWrpFmPortDev->defPcd = p_LnxWrpFmDev->defPcd;
 	} else if (of_device_is_compatible(port_node, "fsl,fman-port-10g-rx")) {
+#ifndef CONFIG_FMAN_ARM
+		/* On T102x, the 10G RX port IDs start from 0x08 */
+		if (IS_T1023_T1024)
+			tmp_prop -= 0x8;
+		else
+#endif
 		tmp_prop -= 0x10;
+
 		if (unlikely(tmp_prop >= FM_MAX_NUM_OF_10G_RX_PORTS)) {
 			REPORT_ERROR(MAJOR, E_INVALID_VALUE,
 					("of_get_property(%s, cell-index) failed",
@@ -449,7 +463,7 @@ static t_LnxWrpFmPortDev *ReadFmPortDevT
 
 #ifndef CONFIG_FMAN_ARM
 		if (IS_T1023_T1024)
-			p_LnxWrpFmPortDev = &p_LnxWrpFmDev->rxPorts[*uint32_prop];
+			p_LnxWrpFmPortDev = &p_LnxWrpFmDev->rxPorts[tmp_prop];
 #endif
 
 		p_LnxWrpFmPortDev->id = tmp_prop;
@@ -637,7 +651,7 @@ static t_Error CheckNConfigFmPortAdvArgs
     uint32_prop = (uint32_t *)of_get_property(port_node, "ar-tables-sizes",
 	&lenp);
     if (uint32_prop) {
-    
+
     	if (WARN_ON(lenp != sizeof(uint32_t)*8))
             RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
     	if (WARN_ON(p_LnxWrpFmPortDev->settings.param.portType !=
@@ -671,7 +685,7 @@ static t_Error CheckNConfigFmPortAdvArgs
         if (uint32_prop) {
         	if (WARN_ON(lenp != sizeof(uint32_t)*3))
                 RETURN_ERROR(MINOR, E_INVALID_VALUE, NO_MSG);
-         
+
             p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_ip_prot_filtering  =
 		(uint16_t)be32_to_cpu(uint32_prop[0]);
             p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_tcp_port_filtering =
@@ -679,7 +693,7 @@ static t_Error CheckNConfigFmPortAdvArgs
             p_LnxWrpFmPortDev->dsar_table_sizes.max_num_of_udp_port_filtering =
 		(uint16_t)be32_to_cpu(uint32_prop[2]);
         }
-        
+
         if ((err = FM_PORT_ConfigDsarSupport(p_LnxWrpFmPortDev->h_Dev,
 		(t_FmPortDsarTablesSizes*)&p_LnxWrpFmPortDev->dsar_table_sizes)) != E_OK)
 		RETURN_ERROR(MINOR, err, NO_MSG);