RE: [PATCH 09/12] driver: net: fm: add DM ETH support

2020-04-28 Thread Camelia Alexandra Groza (OSS)
> -Original Message-
> From: U-Boot  On Behalf Of Madalin Bucur
> Sent: Thursday, April 23, 2020 16:25
> To: u-boot@lists.denx.de
> Cc: Ruchika Gupta ; joe.hershber...@ni.com;
> s...@chromium.org; Priyanka Jain (OSS) ;
> tr...@konsulko.com; Ioana Ciornei ; Madalin Bucur
> (OSS) 
> Subject: [PATCH 09/12] driver: net: fm: add DM ETH support
> 
> Probe the FMan MACs based on the device tree while
> retaining the legacy code/functionality.
> One notable change introduced here is that, for DM_ETH,
> the name of the interfaces is corrected to the fmX-macY
> format, that avoids the referral to the MAC block names
> which were incorrect for FMan v3 devices (i.e. DTSEC,
> TGEC) and had weird formatting (i.e. FM1@DTSEC6, FM1@TGEC1).
> The legacy code is left unchanged in this respect.
> 
> Signed-off-by: Madalin Bucur 



> @@ -37,10 +46,18 @@ static void dtsec_configure_serdes(struct fm_eth
> *priv)
>  #ifdef CONFIG_SYS_FMAN_V3
>   u32 value;
>   struct mii_dev bus;
> - bus.priv = priv->mac->phyregs;
>   bool sgmii_2500 = (priv->enet_if ==
>   PHY_INTERFACE_MODE_SGMII_2500) ? true : false;
> - int i = 0;
> + int i = 0, j;
> +
> +#ifndef CONFIG_DM_ETH
> + bus.priv = priv->mac->phyregs;
> +#else
> + bus.priv = priv->pcs_mdio;
> +#endif
> + bus.read = memac_mdio_read;
> + bus.write = memac_mdio_write;
> + bus.reset = memac_mdio_reset;

The read/write/reset callback changes should be added for the DM_ETH case only.

Camelia


RE: [PATCH 09/12] driver: net: fm: add DM ETH support

2020-04-28 Thread Madalin Bucur (OSS)
> -Original Message-
> From: Camelia Alexandra Groza (OSS) 
> Sent: Tuesday, April 28, 2020 4:06 PM
> To: Madalin Bucur (OSS) ; u-boot@lists.denx.de
> Cc: Ruchika Gupta ; joe.hershber...@ni.com;
> s...@chromium.org; Priyanka Jain (OSS) ;
> tr...@konsulko.com; Ioana Ciornei 
> Subject: RE: [PATCH 09/12] driver: net: fm: add DM ETH support
> 
> > -Original Message-
> > From: U-Boot  On Behalf Of Madalin Bucur
> > Sent: Thursday, April 23, 2020 16:25
> > To: u-boot@lists.denx.de
> > Cc: Ruchika Gupta ; joe.hershber...@ni.com;
> > s...@chromium.org; Priyanka Jain (OSS) ;
> > tr...@konsulko.com; Ioana Ciornei ; Madalin Bucur
> > (OSS) 
> > Subject: [PATCH 09/12] driver: net: fm: add DM ETH support
> >
> > Probe the FMan MACs based on the device tree while
> > retaining the legacy code/functionality.
> > One notable change introduced here is that, for DM_ETH,
> > the name of the interfaces is corrected to the fmX-macY
> > format, that avoids the referral to the MAC block names
> > which were incorrect for FMan v3 devices (i.e. DTSEC,
> > TGEC) and had weird formatting (i.e. FM1@DTSEC6, FM1@TGEC1).
> > The legacy code is left unchanged in this respect.
> >
> > Signed-off-by: Madalin Bucur 
> 
> 
> 
> > @@ -37,10 +46,18 @@ static void dtsec_configure_serdes(struct fm_eth
> > *priv)
> >  #ifdef CONFIG_SYS_FMAN_V3
> > u32 value;
> > struct mii_dev bus;
> > -   bus.priv = priv->mac->phyregs;
> > bool sgmii_2500 = (priv->enet_if ==
> > PHY_INTERFACE_MODE_SGMII_2500) ? true : false;
> > -   int i = 0;
> > +   int i = 0, j;
> > +
> > +#ifndef CONFIG_DM_ETH
> > +   bus.priv = priv->mac->phyregs;
> > +#else
> > +   bus.priv = priv->pcs_mdio;
> > +#endif
> > +   bus.read = memac_mdio_read;
> > +   bus.write = memac_mdio_write;
> > +   bus.reset = memac_mdio_reset;
> 
> The read/write/reset callback changes should be added for the DM_ETH case
> only.
> 
> Camelia

Indeed, thank you, let me send a v2.
I'll also have to drop patch 10/12, issue was addressed already.

Madalin


[PATCH 09/12] driver: net: fm: add DM ETH support

2020-04-23 Thread Madalin Bucur
Probe the FMan MACs based on the device tree while
retaining the legacy code/functionality.
One notable change introduced here is that, for DM_ETH,
the name of the interfaces is corrected to the fmX-macY
format, that avoids the referral to the MAC block names
which were incorrect for FMan v3 devices (i.e. DTSEC,
TGEC) and had weird formatting (i.e. FM1@DTSEC6, FM1@TGEC1).
The legacy code is left unchanged in this respect.

Signed-off-by: Madalin Bucur 
---
 arch/arm/cpu/armv8/fsl-layerscape/cpu.c   |   2 +
 board/freescale/ls1043ardb/ls1043ardb.c   |   2 +
 board/freescale/ls1046afrwy/ls1046afrwy.c |   2 +
 board/freescale/ls1046aqds/ls1046aqds.c   |   2 +
 board/freescale/ls1046ardb/ls1046ardb.c   |   2 +
 drivers/net/fm/eth.c  | 351 +-
 drivers/net/fm/fm.c   |  80 +++
 drivers/net/fm/fm.h   |  23 ++
 drivers/net/fm/init.c |   2 +
 drivers/net/fm/memac.c|   1 +
 include/fsl_mdio.h|   1 +
 11 files changed, 458 insertions(+), 10 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c 
b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
index b443894..e0f8a50 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/cpu.c
@@ -1156,8 +1156,10 @@ int arch_early_init_r(void)
fsl_rgmii_init();
 #endif
 #ifdef CONFIG_FMAN_ENET
+#ifndef CONFIG_DM_ETH
fman_enet_init();
 #endif
+#endif
 #ifdef CONFIG_SYS_DPAA_QBMAN
setup_qbman_portals();
 #endif
diff --git a/board/freescale/ls1043ardb/ls1043ardb.c 
b/board/freescale/ls1043ardb/ls1043ardb.c
index 9bc78d6..26a1929 100644
--- a/board/freescale/ls1043ardb/ls1043ardb.c
+++ b/board/freescale/ls1043ardb/ls1043ardb.c
@@ -285,8 +285,10 @@ int ft_board_setup(void *blob, bd_t *bd)
ft_cpu_setup(blob, bd);
 
 #ifdef CONFIG_SYS_DPAA_FMAN
+#ifndef CONFIG_DM_ETH
fdt_fixup_fman_ethernet(blob);
 #endif
+#endif
 
fdt_fixup_icid(blob);
 
diff --git a/board/freescale/ls1046afrwy/ls1046afrwy.c 
b/board/freescale/ls1046afrwy/ls1046afrwy.c
index 8c0abb6..71ace19 100644
--- a/board/freescale/ls1046afrwy/ls1046afrwy.c
+++ b/board/freescale/ls1046afrwy/ls1046afrwy.c
@@ -232,8 +232,10 @@ int ft_board_setup(void *blob, bd_t *bd)
ft_cpu_setup(blob, bd);
 
 #ifdef CONFIG_SYS_DPAA_FMAN
+#ifndef CONFIG_DM_ETH
fdt_fixup_fman_ethernet(blob);
 #endif
+#endif
 
fdt_fixup_icid(blob);
 
diff --git a/board/freescale/ls1046aqds/ls1046aqds.c 
b/board/freescale/ls1046aqds/ls1046aqds.c
index cabd7ee..e6648e9 100644
--- a/board/freescale/ls1046aqds/ls1046aqds.c
+++ b/board/freescale/ls1046aqds/ls1046aqds.c
@@ -462,7 +462,9 @@ int ft_board_setup(void *blob, bd_t *bd)
ft_cpu_setup(blob, bd);
 
 #ifdef CONFIG_SYS_DPAA_FMAN
+#ifndef CONFIG_DM_ETH
fdt_fixup_fman_ethernet(blob);
+#endif
fdt_fixup_board_enet(blob);
 #endif
 
diff --git a/board/freescale/ls1046ardb/ls1046ardb.c 
b/board/freescale/ls1046ardb/ls1046ardb.c
index cc6bd88..5308cb2 100644
--- a/board/freescale/ls1046ardb/ls1046ardb.c
+++ b/board/freescale/ls1046ardb/ls1046ardb.c
@@ -172,8 +172,10 @@ int ft_board_setup(void *blob, bd_t *bd)
ft_cpu_setup(blob, bd);
 
 #ifdef CONFIG_SYS_DPAA_FMAN
+#ifndef CONFIG_DM_ETH
fdt_fixup_fman_ethernet(blob);
 #endif
+#endif
 
fdt_fixup_icid(blob);
 
diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index 7d13736..5f1a023 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -1,10 +1,17 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright 2009-2012 Freescale Semiconductor, Inc.
+ * Copyright 2020 NXP
  * Dave Liu 
  */
 #include 
 #include 
+#ifdef CONFIG_DM_ETH
+#include 
+#include 
+#include 
+#include 
+#endif
 #include 
 #include 
 #include 
@@ -18,8 +25,10 @@
 
 #include "fm.h"
 
+#ifndef CONFIG_DM_ETH
 static struct eth_device *devlist[NUM_FM_PORTS];
 static int num_controllers;
+#endif
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) && !defined(BITBANGMII)
 
@@ -37,10 +46,18 @@ static void dtsec_configure_serdes(struct fm_eth *priv)
 #ifdef CONFIG_SYS_FMAN_V3
u32 value;
struct mii_dev bus;
-   bus.priv = priv->mac->phyregs;
bool sgmii_2500 = (priv->enet_if ==
PHY_INTERFACE_MODE_SGMII_2500) ? true : false;
-   int i = 0;
+   int i = 0, j;
+
+#ifndef CONFIG_DM_ETH
+   bus.priv = priv->mac->phyregs;
+#else
+   bus.priv = priv->pcs_mdio;
+#endif
+   bus.read = memac_mdio_read;
+   bus.write = memac_mdio_write;
+   bus.reset = memac_mdio_reset;
 
 qsgmii_loop:
/* SGMII IF mode + AN enable only for 1G SGMII, not for 2.5G */
@@ -51,6 +68,10 @@ qsgmii_loop:
else
value = PHY_SGMII_IF_MODE_SGMII | PHY_SGMII_IF_MODE_AN;
 
+   for (j = 0; j <= 3; j++)
+   debug("dump PCS reg %#x: %#x\n", j,
+ memac_mdio_read(, i, MDIO_DEVAD_NONE, j));
+