driver: net: fsl-mc: Add support of multiple phys for dpmac
cover driver: net: fsl-mc: Add support of multiple phys for dpmac
This patch set adds support of multiple phys for one dpmac
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. To handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up.
also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Pankaj Bansal (6):
driver: net: fsl-mc: modify the label name
driver: net: fsl-mc: remove unused strcture elements
driver: net: fsl-mc: fix error handing in init_phy
driver: net: fsl-mc: Modify the dpmac link detection method
driver: net: fsl-mc: initialize dpmac irrespective of phy
driver: net: fsl-mc: Add support of multiple phys for dpmac
board/freescale/ls1088a/eth_ls1088aqds.c | 18 +-- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +-- board/freescale/ls2080aqds/eth.c | 26 +-- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +-- drivers/net/fsl-mc/mc.c | 6 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 180 +++++++++++++-------- drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 49 ++++-- include/fsl-mc/ldpaa_wriop.h | 22 +-- 9 files changed, 209 insertions(+), 138 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/6 driver: net: fsl-mc: modify the label name
The goto label name is misspelled it should be DPMAC not DPAMC
--- drivers/net/ldpaa_eth/ldpaa_eth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +4 -4
@@ -413,7 +413,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err) {printf ("%s: Could not initialize\n" , priv->phydev->dev->name); - goto err_dpamc_bind; + goto err_dpmac_bind; } }#else
@@ -441,13 +441,13 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (!priv->phydev->link) {printf ("%s: No link.\n" , priv->phydev->dev->name); err =-1 ; - goto err_dpamc_bind; + goto err_dpmac_bind; }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);if (err) - goto err_dpamc_bind; + goto err_dpmac_bind;/* DPNI initialization */ err =ldpaa_dpni_setup (priv);
@@ -540,7 +540,7 @@ err_dpni_bind: err_dpbp_setup:dpni_close (dflt_mc_io,MC_CMD_NO_FLAGS , dflt_dpni->dpni_handle); err_dpni_setup: -err_dpamc_bind: +err_dpmac_bind:dpmac_close (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle); dpmac_destroy(dflt_mc_io, dflt_dprc_handle,
Signature · 1 line
2.17.1
PATCH 1/6 driver: net: fsl-mc: modify the label name
Quoted 3 lines · Pankaj Bansal
The goto label name is misspelled it should be DPMAC not DPAMC
Signed-off-by Pankaj Bansal <[email protected]>
PATCH v3 2/6 driver: net: fsl-mc: remove unused strcture elements
In reply to Pankaj BansalThe phydev structure is present in both ldpaa_eth_priv and wriop_dpmac_info. the phydev in wriop_dpmac_info is not being used
As the phydev is created based on phy_addr and bus members of wriop_dpmac_info, it is appropriate to keep phydev in wriop_dpmac_info.
Also phy_regs is not being used, therefore remove it
--- drivers/net/ldpaa_eth/ldpaa_eth.c | 57 +++++++++++++++------------ drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 2 + include/fsl-mc/ldpaa_wriop.h | 1 - 4 files changed, 34 insertions(+), 27 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +32 -25
@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)return -1 ; } - priv->phydev = phydev; +wriop_set_phy_dev (priv->dpmac_id, phydev);return phy_config (phydev); }
@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct mii_dev *bus;phy_interface_t enet_if;struct dpni_queue d_queue; +struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;
@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_dpmac_setup;#ifdef CONFIG_PHYLIB -if (priv->phydev) { - err =phy_startup (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , - priv->phydev->dev->name); + phydev->dev->name); goto err_dpmac_bind; } }#else - priv->phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_1000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_1000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ;#endif bus =wriop_get_mdio (priv->dpmac_id); enet_if =wriop_get_enet_if (priv->dpmac_id);if ((bus ==NULL ) && (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - priv->phydev = (struct phy_device *) + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_10000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_10000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ; } -if (!priv->phydev->link) { -printf ("%s: No link.\n" , priv->phydev->dev->name); +if (!phydev->link) { +printf ("%s: No link.\n" , phydev->dev->name); err =-1 ; goto err_dpmac_bind; }
@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = priv->phydev->speed; + dpmac_link_state.rate = phydev->speed; -if (priv->phydev->autoneg ==AUTONEG_DISABLE ) +if (phydev->autoneg ==AUTONEG_DISABLE ) dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ;else dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; -if (priv->phydev->duplex ==DUPLEX_HALF ) +if (phydev->duplex ==DUPLEX_HALF ) dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - dpmac_link_state.up = priv->phydev->link; + dpmac_link_state.up = phydev->link; err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);
@@ -530,7 +534,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return priv->phydev->link; +return phydev->link; err_qdid: err_get_queue:
@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id);#endif +struct phy_device *phydev =NULL ;if ((net_dev->state ==ETH_STATE_PASSIVE ) || (net_dev->state ==ETH_STATE_INIT ))
@@ -588,11 +593,13 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)printf ("dpni_disable() failed\n" );#ifdef CONFIG_PHYLIB -if (priv->phydev && bus !=NULL ) -phy_shutdown (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev && bus !=NULL ) +phy_shutdown (phydev);else { -free (priv->phydev); - priv->phydev =NULL ; +free (phydev); + phydev =NULL ; +wriop_set_phy_dev (priv->dpmac_id, phydev); }#endif
drivers/net/ldpaa_eth/ldpaa_eth.h +0 -1
@@ -127,7 +127,6 @@ struct ldpaa_eth_priv {uint16_t tx_flow_id;enum ldpaa_eth_type type;/* 1G or 10G ethernet */ -struct phy_device *phydev; };struct dprc_endpoint dpmac_endpoint;
drivers/net/ldpaa_eth/ldpaa_wriop.c +2 -0
@@ -26,6 +26,7 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; dpmac_info[dpmac_id].phy_addr =-1 ; + dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl);
@@ -42,6 +43,7 @@ void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t enet_if) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; + dpmac_info[dpmac_id].phydev =NULL ; }
include/fsl-mc/ldpaa_wriop.h +0 -1
@@ -41,7 +41,6 @@ struct wriop_dpmac_info {u8 id;u8 board_mux;int phy_addr; -void *phy_regs;phy_interface_t enet_if;struct phy_device *phydev;struct mii_dev *bus;
Signature · 1 line
2.17.1
PATCH v3 2/6 driver: net: fsl-mc: remove unused strcture elements
Quoted 9 lines · Pankaj Bansal
The phydev structure is present in both
ldpaa_eth_privandwriop_dpmac_info. the phydev inwriop_dpmac_infois not being usedAs the phydev is created based on
phy_addrand bus members ofwriop_dpmac_info, it is appropriate to keep phydev inwriop_dpmac_info.Also
phy_regsis not being used, therefore remove itSigned-off-by Pankaj Bansal <[email protected]>
One nit below, but...
If we don't need another version of this series, I'll fix it up when it's applied.
Quoted 125 lines
--- drivers/net/ldpaa_eth/ldpaa_eth.c | 57 +++++++++++++++------------ drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 2 + include/fsl-mc/ldpaa_wriop.h | 1 - 4 files changed, 34 insertions(+), 27 deletions(-)drivers/net/ldpaa_eth/ldpaa_eth.c +26
-21@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)return -1 ; } - priv->phydev = phydev; +wriop_set_phy_dev (priv->dpmac_id, phydev);return phy_config (phydev); }@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct mii_dev *bus;phy_interface_t enet_if;struct dpni_queue d_queue; +struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_dpmac_setup;#ifdef CONFIG_PHYLIB -if (priv->phydev) { - err =phy_startup (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , - priv->phydev->dev->name); + phydev->dev->name); goto err_dpmac_bind; } }#else - priv->phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_1000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_1000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ;#endif bus =wriop_get_mdio (priv->dpmac_id); enet_if =wriop_get_enet_if (priv->dpmac_id);if ((bus ==NULL ) && (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - priv->phydev = (struct phy_device *) + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_10000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_10000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ; } -if (!priv->phydev->link) { -printf ("%s: No link.\n" , priv->phydev->dev->name); +if (!phydev->link) { +printf ("%s: No link.\n" , phydev->dev->name); err =-1 ; goto err_dpmac_bind; }@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = priv->phydev->speed; + dpmac_link_state.rate = phydev->speed; -if (priv->phydev->autoneg ==AUTONEG_DISABLE ) +if (phydev->autoneg ==AUTONEG_DISABLE ) dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ;else dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; -if (priv->phydev->duplex ==DUPLEX_HALF ) +if (phydev->duplex ==DUPLEX_HALF ) dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - dpmac_link_state.up = priv->phydev->link; + dpmac_link_state.up = phydev->link; err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);@@ -530,7 +534,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return priv->phydev->link; +return phydev->link; err_qdid: err_get_queue:@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id);#endif +struct phy_device *phydev =NULL ;if ((net_dev->state ==ETH_STATE_PASSIVE ) || (net_dev->state ==ETH_STATE_INIT ))
drivers/net/ldpaa_eth/ldpaa_eth.c static void ldpaa_eth_stop(struct eth_device *net_dev) · line 597
Quoted 7 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-2@@ -588,11 +593,13 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)printf ("dpni_disable() failed\n" );#ifdef CONFIG_PHYLIB -if (priv->phydev && bus !=NULL ) -phy_shutdown (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev && bus !=NULL )
I'm surprised checkpatch.pl doesn't complain about this "!= NULL". Either way, remove it and just use "phydev && bus"
Quoted 61 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +4
-2+phy_shutdown (phydev); else { -free (priv->phydev); - priv->phydev =NULL ; +free (phydev); + phydev =NULL ; +wriop_set_phy_dev (priv->dpmac_id, phydev); }#endif drivers/net/ldpaa_eth/ldpaa_eth.h +0
-1@@ -127,7 +127,6 @@ struct ldpaa_eth_priv {uint16_t tx_flow_id;enum ldpaa_eth_type type;/* 1G or 10G ethernet */ -struct phy_device *phydev; };struct dprc_endpoint dpmac_endpoint;drivers/net/ldpaa_eth/ldpaa_wriop.c +2
-0@@ -26,6 +26,7 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; dpmac_info[dpmac_id].phy_addr =-1 ; + dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl);@@ -42,6 +43,7 @@ void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t enet_if) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; + dpmac_info[dpmac_id].phydev =NULL ; }include/fsl-mc/ldpaa_wriop.h +0
-2@@ -41,7 +41,6 @@ struct wriop_dpmac_info {u8 id;u8 board_mux;int phy_addr; -void *phy_regs;phy_interface_t enet_if;struct phy_device *phydev;struct mii_dev *bus; --2.17.1
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 3/6 driver: net: fsl-mc: fix error handing in init_phy
In reply to Pankaj Bansalif an error occurs during init_phy, we should free the phydev structure which has been allocated by phy_connect.
--- drivers/net/ldpaa_eth/ldpaa_eth.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +10 -1
@@ -23,6 +23,7 @@ static int init_phy(struct eth_device *dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;struct phy_device *phydev =NULL ;struct mii_dev *bus; +int ret; bus =wriop_get_mdio (priv->dpmac_id);if (bus ==NULL )
@@ -37,7 +38,15 @@ static int init_phy(struct eth_device *dev)wriop_set_phy_dev (priv->dpmac_id, phydev); - return phy_config(phydev); + ret =phy_config (phydev); + +if (ret) { +free (phydev); + phydev =NULL ; +wriop_set_phy_dev (priv->dpmac_id, phydev); + } + + return ret; }#endif
Signature · 1 line
2.17.1
PATCH 3/6 driver: net: fsl-mc: fix error handing in init_phy
Quoted 21 lines · Pankaj Bansal
if an error occurs during
init_phy, we should free the phydev structure which has been allocated byphy_connect.Signed-off-by Pankaj Bansal <[email protected]>--- drivers/net/ldpaa_eth/ldpaa_eth.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)drivers/net/ldpaa_eth/ldpaa_eth.c +1
-0@@ -23,6 +23,7 @@ static int init_phy(struct eth_device *dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;struct phy_device *phydev =NULL ;struct mii_dev *bus; +int ret; bus =wriop_get_mdio (priv->dpmac_id);if (bus ==NULL )
drivers/net/ldpaa_eth/ldpaa_eth.c static int init_phy(struct eth_device *dev) · line 45
Quoted 9 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +5
-1@@ -37,7 +38,15 @@ static int init_phy(struct eth_device *dev)wriop_set_phy_dev (priv->dpmac_id, phydev); -return phy_config (phydev); + ret =phy_config (phydev); + +if (ret) { +free (phydev); + phydev =NULL ;
This seems odd. It's a local variable... why not just pass NULL into wriop_set_phy_dev()? That seems clearer.
Quoted 14 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +4
-1+ wriop_set_phy_dev(priv->dpmac_id, phydev); + } + +return ret; }#endif --2.17.1
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 4/6 driver: net: fsl-mc: Modify the dpmac link detection method
In reply to Pankaj Bansalwhen there is no phy present for a dpmac, a dummy phy device is created. when we move to multiple phy method, we need to create as many dummy phy devices.
Change this method so that we don't need to create dummy phy devices. We always report linkup if no phy is present.
--- drivers/net/ldpaa_eth/ldpaa_eth.c | 121 +++++++++++++--------------- 1 file changed, 58 insertions(+), 63 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +58 -63
@@ -386,6 +386,60 @@ error:return err; } +static int ldpaa_get_dpmac_state (struct ldpaa_eth_priv *priv, +struct dpmac_link_state *state) +{ +struct phy_device *phydev =NULL ; +phy_interface_t enet_if; +int err; + +/* let's start off with maximum capabilities +*/ + enet_if =wriop_get_enet_if (priv->dpmac_id); +switch (enet_if) { +case PHY_INTERFACE_MODE_XGMII : + state->rate =SPEED_10000 ; +break ; +default : + state->rate =SPEED_1000 ; +break ; + } + state->up =1 ; + +#ifdef CONFIG_PHYLIB + state->options |=DPMAC_LINK_OPT_AUTONEG ; + + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev); +if (err) { +printf ("%s: Could not initialize\n" , phydev->dev->name); + state->up =0 ; + } +if (phydev->link ==1 ) { + state->rate = state->rate < phydev->speed ? + state->rate : phydev->speed; +if (!phydev->duplex) + state->options |=DPMAC_LINK_OPT_HALF_DUPLEX ; +if (!phydev->autoneg) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + }else { + state->up =0 ; + } + } +#endif +if (!phydev) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + +if (state->up ==0 ) { + state->rate =0 ; + state->options =0 ; +return -1 ; + } + +return 0 ; +} +static int ldpaa_eth_open (struct eth_device *net_dev,bd_t *bd) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
@@ -394,10 +448,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct dpni_link_state link_state;#endif int err =0 ; -struct mii_dev *bus; -phy_interface_t enet_if;struct dpni_queue d_queue; -struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;
@@ -417,45 +468,9 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err <0 ) goto err_dpmac_setup; -#ifdef CONFIG_PHYLIB - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) { - err =phy_startup (phydev); -if (err) { -printf ("%s: Could not initialize\n" , - phydev->dev->name); - goto err_dpmac_bind; - } - } -#else - phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_1000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; -#endif - - bus =wriop_get_mdio (priv->dpmac_id); - enet_if =wriop_get_enet_if (priv->dpmac_id); -if ((bus ==NULL ) && - (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - phydev = (struct phy_device *) -malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_10000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; - } - -if (!phydev->link) { -printf ("%s: No link.\n" , phydev->dev->name); - err =-1 ; + err =ldpaa_get_dpmac_state (priv, &dpmac_link_state); +if (err <0 ) goto err_dpmac_bind; - }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);
@@ -489,18 +504,6 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = phydev->speed; - -if (phydev->autoneg ==AUTONEG_DISABLE ) - dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ; -else - dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; - -if (phydev->duplex ==DUPLEX_HALF ) - dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - - dpmac_link_state.up = phydev->link; - err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);if (err <0 ) {
@@ -543,7 +546,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return phydev->link; +return dpmac_link_state.up; err_qdid: err_get_queue:
@@ -566,9 +569,6 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;int err =0 ; -#ifdef CONFIG_PHYLIB -struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id); -#endif struct phy_device *phydev =NULL ; if ((net_dev->state == ETH_STATE_PASSIVE) ||
@@ -603,13 +603,8 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev && bus !=NULL ) +if (phydev)phy_shutdown (phydev); -else { -free (phydev); - phydev =NULL ; -wriop_set_phy_dev (priv->dpmac_id, phydev); - }#endif /* Free DPBP handle and reset. */
Signature · 1 line
2.17.1
PATCH 4/6 driver: net: fsl-mc: Modify the dpmac link detection method
Quoted 41 lines · Pankaj Bansal
when there is no phy present for a dpmac, a dummy phy device is created. when we move to multiple phy method, we need to create as many dummy phy devices.
Change this method so that we don't need to create dummy phy devices. We always report linkup if no phy is present.
Signed-off-by Pankaj Bansal <[email protected]>--- drivers/net/ldpaa_eth/ldpaa_eth.c | 121 +++++++++++++--------------- 1 file changed, 58 insertions(+), 63 deletions(-)drivers/net/ldpaa_eth/ldpaa_eth.c +21
-0@@ -386,6 +386,60 @@ error:return err; } +static int ldpaa_get_dpmac_state (struct ldpaa_eth_priv *priv, +struct dpmac_link_state *state) +{ +struct phy_device *phydev =NULL ; +phy_interface_t enet_if; +int err; + +/* let's start off with maximum capabilities +*/ + enet_if =wriop_get_enet_if (priv->dpmac_id); +switch (enet_if) { +case PHY_INTERFACE_MODE_XGMII : + state->rate =SPEED_10000 ; +break ; +default : + state->rate =SPEED_1000 ; +break ; + } + state->up =1 ; + +#ifdef CONFIG_PHYLIB
drivers/net/ldpaa_eth/ldpaa_eth.c error: · line 419
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +10
-0+ state->options |=DPMAC_LINK_OPT_AUTONEG ; + + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev); +if (err) { +printf ("%s: Could not initialize\n" , phydev->dev->name); + state->up =0 ; + } +if (phydev->link ==1 ) {
Just "phydev->link"
drivers/net/ldpaa_eth/ldpaa_eth.c error: · line 421
Quoted 2 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-0+ state->rate = state->rate < phydev->speed ? + state->rate : phydev->speed;
MIN(state->rate, phydev->speed);
Quoted 6 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +6
-0+if (!phydev->duplex) + state->options |=DPMAC_LINK_OPT_HALF_DUPLEX ; +if (!phydev->autoneg) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + }else { + state->up =0 ;
drivers/net/ldpaa_eth/ldpaa_eth.c error: · line 437
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +10
-0+ } + } +#endif +if (!phydev) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + +if (state->up ==0 ) { + state->rate =0 ; + state->options =0 ; +return -1 ;
return -ENODEV;
Quoted 127 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +9
-64+ } + +return 0 ; +} +static int ldpaa_eth_open (struct eth_device *net_dev,bd_t *bd) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;@@ -394,10 +448,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct dpni_link_state link_state;#endif int err =0 ; -struct mii_dev *bus; -phy_interface_t enet_if;struct dpni_queue d_queue; -struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;@@ -417,45 +468,9 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err <0 ) goto err_dpmac_setup; -#ifdef CONFIG_PHYLIB - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) { - err =phy_startup (phydev); -if (err) { -printf ("%s: Could not initialize\n" , - phydev->dev->name); - goto err_dpmac_bind; - } - } -#else - phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_1000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; -#endif - - bus =wriop_get_mdio (priv->dpmac_id); - enet_if =wriop_get_enet_if (priv->dpmac_id); -if ((bus ==NULL ) && - (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - phydev = (struct phy_device *) -malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_10000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; - } - -if (!phydev->link) { -printf ("%s: No link.\n" , phydev->dev->name); - err =-1 ; + err =ldpaa_get_dpmac_state (priv, &dpmac_link_state); +if (err <0 ) goto err_dpmac_bind; - }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);@@ -489,18 +504,6 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = phydev->speed; - -if (phydev->autoneg ==AUTONEG_DISABLE ) - dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ; -else - dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; - -if (phydev->duplex ==DUPLEX_HALF ) - dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - - dpmac_link_state.up = phydev->link; - err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);if (err <0 ) {@@ -543,7 +546,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return phydev->link; +return dpmac_link_state.up; err_qdid: err_get_queue:@@ -566,9 +569,6 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;int err =0 ; -#ifdef CONFIG_PHYLIB -struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id); -#endif struct phy_device *phydev =NULL ; if ((net_dev->state == ETH_STATE_PASSIVE) ||@@ -603,13 +603,8 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev && bus !=NULL ) +if (phydev)phy_shutdown (phydev); -else { -free (phydev); - phydev =NULL ; -wriop_set_phy_dev (priv->dpmac_id, phydev); - }#endif /* Free DPBP handle and reset. */ --2.17.1
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH 5/6 driver: net: fsl-mc: initialize dpmac irrespective of phy
In reply to Pankaj BansalThe dpmac initalization should not depend on phy.
As the phy is not necessary to be present for dpmac to function. Therefore, remove dpmac initialization dependency from phy.
--- drivers/net/fsl-mc/mc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/fsl-mc/mc.c +2 -4
@@ -327,8 +327,7 @@ static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type)for (i =WRIOP1_DPMAC1 ; i <NUM_WRIOP_PORTS ; i++) {/* port not enabled */ -if ((wriop_is_enabled_dpmac (i) !=1 ) || - (wriop_get_phy_address (i) ==-1 )) +if (wriop_is_enabled_dpmac (i) !=1 )continue ; sprintf(ethname, "DPMAC%d@%s", i,
@@ -845,8 +844,7 @@ int fsl_mc_ldpaa_init(bd_t *bis)int i;for (i =WRIOP1_DPMAC1 ; i <NUM_WRIOP_PORTS ; i++) -if ((wriop_is_enabled_dpmac (i) ==1 ) && - (wriop_get_phy_address (i) !=-1 )) +if (wriop_is_enabled_dpmac (i) ==1 )ldpaa_eth_init (i,wriop_get_enet_if (i));return 0 ; }
Signature · 1 line
2.17.1
PATCH 5/6 driver: net: fsl-mc: initialize dpmac irrespective of phy
Quoted 5 lines · Pankaj Bansal
The dpmac initalization should not depend on phy.
As the phy is not necessary to be present for dpmac to function. Therefore, remove dpmac initialization dependency from phy.Signed-off-by Pankaj Bansal <[email protected]>
PATCH 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalTill now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
--- board/freescale/ls1088a/eth_ls1088aqds.c | 18 ++--- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +++--- board/freescale/ls2080aqds/eth.c | 26 +++---- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 71 ++++++++++++++------ drivers/net/ldpaa_eth/ldpaa_wriop.c | 51 ++++++++++---- include/fsl-mc/ldpaa_wriop.h | 21 +++--- 7 files changed, 147 insertions(+), 85 deletions(-)
board/freescale/ls1088a/eth_ls1088aqds.c +9 -9
@@ -487,16 +487,16 @@ void ls1088a_handle_phy_interface_sgmii(int dpmac_id)case 0x3A :switch (dpmac_id) {case 1 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[1 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[1 ]);break ;case 2 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[0 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[0 ]);break ;case 3 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[3 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[3 ]);break ;case 7 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[2 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[2 ]);break ;default :printf ("WRIOP: Wrong DPMAC%d set to SGMII" , dpmac_id);
@@ -532,13 +532,13 @@ void ls1088a_handle_phy_interface_qsgmii(int dpmac_id)case 4 :case 5 :case 6 : -wriop_set_phy_address (dpmac_id, dpmac_id +9 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +9 );break ;case 7 :case 8 :case 9 :case 10 : -wriop_set_phy_address (dpmac_id, dpmac_id +1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +1 );break ; }
@@ -567,7 +567,7 @@ void ls1088a_handle_phy_interface_xsgmii(int i)case 0x15 :case 0x1D :case 0x1E : -wriop_set_phy_address (i, i +26 ); +wriop_set_phy_address (i,0 , i +26 );ls1088a_qds_enable_SFP_TX (SFP_TX );break ;default :
@@ -590,13 +590,13 @@ static void ls1088a_handle_phy_interface_rgmii(int dpmac_id)switch (dpmac_id) {case 4 : -wriop_set_phy_address (dpmac_id,RGMII_PHY1_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY1_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII1 ; bus =mii_dev_for_muxval (EMI1_RGMII1 );wriop_set_mdio (dpmac_id, bus);break ;case 5 : -wriop_set_phy_address (dpmac_id,RGMII_PHY2_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY2_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII2 ; bus =mii_dev_for_muxval (EMI1_RGMII2 );wriop_set_mdio (dpmac_id, bus);
board/freescale/ls1088a/eth_ls1088ardb.c +11 -10
@@ -55,16 +55,17 @@ int board_eth_init(bd_t *bis)* a MAC has no PHY address, we give a PHY address to XFI * MAC error. */ -wriop_set_phy_address (WRIOP1_DPMAC1 ,0x0a ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,QSGMII1_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,QSGMII1_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,QSGMII1_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,QSGMII1_PORT4_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,QSGMII2_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,QSGMII2_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC9 ,QSGMII2_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC10 ,QSGMII2_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,0x0a ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,QSGMII1_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,QSGMII1_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,QSGMII1_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,QSGMII1_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,QSGMII2_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,QSGMII2_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC9 ,0 ,QSGMII2_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC10 ,0 , +QSGMII2_PORT4_PHY_ADDR );break ;default :
board/freescale/ls2080aqds/eth.c +13 -13
@@ -623,7 +623,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );
@@ -631,7 +631,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)break ;case 2 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT2 ; bus =mii_dev_for_muxval (EMI1_SLOT2 );
@@ -641,18 +641,18 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)if (slot ==EMI_NONE )return ;if (serdes1_prtcl ==0x39 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=6 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=7 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT3 ;
@@ -691,7 +691,7 @@ serdes2:break ;case 4 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -9 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT4 ; bus =mii_dev_for_muxval (EMI1_SLOT4 );
@@ -701,14 +701,14 @@ serdes2:if (slot ==EMI_NONE )return ;if (serdes2_prtcl ==0x47 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -10 ]);if (dpmac_id >=14 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT5 ;
@@ -717,7 +717,7 @@ serdes2:break ;case 6 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -13 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT6 ; bus =mii_dev_for_muxval (EMI1_SLOT6 );
@@ -775,7 +775,7 @@ void ls2080a_handle_phy_interface_qsgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a QSGMII riser card? */ -wriop_set_phy_address (dpmac_id, dpmac_id -1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id -1 ); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );wriop_set_mdio (dpmac_id, bus);
@@ -819,7 +819,7 @@ void ls2080a_handle_phy_interface_xsgmii(int i)* the XAUI card is used for the XFI MAC, which will cause * error. */ -wriop_set_phy_address (i, i +4 ); +wriop_set_phy_address (i,0 , i +4 );ls2080a_qds_enable_SFP_TX (SFP_TX );break ;
board/freescale/ls2080ardb/eth_ls2080rdb.c +12 -12
@@ -50,21 +50,21 @@ int board_eth_init(bd_t *bis)switch (srds_s1) {case 0x2A : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,AQ_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,AQ_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,AQ_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,AQ_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,AQ_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,AQ_PHY_ADDR4 );break ;case 0x4B : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 );break ;default :
drivers/net/ldpaa_eth/ldpaa_eth.c +52 -19
127 lines not on this page · raw message
drivers/net/ldpaa_eth/ldpaa_wriop.c +39 -12
109 lines not on this page · raw message
include/fsl-mc/ldpaa_wriop.h +11 -10
@@ -6,7 +6,11 @@#ifndef __LDPAA_WRIOP_H#define __LDPAA_WRIOP_H -#include <phy.h> +#include <phy.h> + +#define DEFAULT_WRIOP_MDIO1_NAME "FSL_MDIO0" +#define DEFAULT_WRIOP_MDIO2_NAME "FSL_MDIO1" +#define WRIOP_MAX_PHY_NUM 2enum wriop_port { WRIOP1_DPMAC1 = 1,
@@ -40,27 +44,24 @@ struct wriop_dpmac_info {u8 enabled;u8 id;u8 board_mux; -int phy_addr; +int phy_addr[WRIOP_MAX_PHY_NUM ];phy_interface_t enet_if; -struct phy_device *phydev; +struct phy_device *phydev[WRIOP_MAX_PHY_NUM ];struct mii_dev *bus; };extern struct wriop_dpmac_info dpmac_info[NUM_WRIOP_PORTS ]; -#define DEFAULT_WRIOP_MDIO1_NAME "FSL_MDIO0" -#define DEFAULT_WRIOP_MDIO2_NAME "FSL_MDIO1" -void wriop_init_dpmac (int ,int ,int );void wriop_disable_dpmac (int );void wriop_enable_dpmac (int );u8 wriop_is_enabled_dpmac (int dpmac_id);void wriop_set_mdio (int ,struct mii_dev *);struct mii_dev *wriop_get_mdio (int ); -void wriop_set_phy_address (int ,int ); -int wriop_get_phy_address (int ); -void wriop_set_phy_dev (int ,struct phy_device *); -struct phy_device *wriop_get_phy_dev (int ); +void wriop_set_phy_address (int ,int ,int ); +int wriop_get_phy_address (int ,int ); +void wriop_set_phy_dev (int ,int ,struct phy_device *); +struct phy_device *wriop_get_phy_dev (int ,int );phy_interface_t wriop_get_enet_if (int );void wriop_dpmac_disable (int );
Signature · 1 line
2.17.1
PATCH 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
Quoted 271 lines · Pankaj Bansal
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Signed-off-by Pankaj Bansal <[email protected]>--- board/freescale/ls1088a/eth_ls1088aqds.c | 18 ++--- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +++--- board/freescale/ls2080aqds/eth.c | 26 +++---- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 71 ++++++++++++++------ drivers/net/ldpaa_eth/ldpaa_wriop.c | 51 ++++++++++---- include/fsl-mc/ldpaa_wriop.h | 21 +++--- 7 files changed, 147 insertions(+), 85 deletions(-)board/freescale/ls1088a/eth_ls1088aqds.c +9
-9@@ -487,16 +487,16 @@ void ls1088a_handle_phy_interface_sgmii(int dpmac_id)case 0x3A :switch (dpmac_id) {case 1 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[1 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[1 ]);break ;case 2 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[0 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[0 ]);break ;case 3 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[3 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[3 ]);break ;case 7 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[2 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[2 ]);break ;default :printf ("WRIOP: Wrong DPMAC%d set to SGMII" , dpmac_id);@@ -532,13 +532,13 @@ void ls1088a_handle_phy_interface_qsgmii(int dpmac_id)case 4 :case 5 :case 6 : -wriop_set_phy_address (dpmac_id, dpmac_id +9 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +9 );break ;case 7 :case 8 :case 9 :case 10 : -wriop_set_phy_address (dpmac_id, dpmac_id +1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +1 );break ; }@@ -567,7 +567,7 @@ void ls1088a_handle_phy_interface_xsgmii(int i)case 0x15 :case 0x1D :case 0x1E : -wriop_set_phy_address (i, i +26 ); +wriop_set_phy_address (i,0 , i +26 );ls1088a_qds_enable_SFP_TX (SFP_TX );break ;default :@@ -590,13 +590,13 @@ static void ls1088a_handle_phy_interface_rgmii(int dpmac_id)switch (dpmac_id) {case 4 : -wriop_set_phy_address (dpmac_id,RGMII_PHY1_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY1_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII1 ; bus =mii_dev_for_muxval (EMI1_RGMII1 );wriop_set_mdio (dpmac_id, bus);break ;case 5 : -wriop_set_phy_address (dpmac_id,RGMII_PHY2_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY2_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII2 ; bus =mii_dev_for_muxval (EMI1_RGMII2 );wriop_set_mdio (dpmac_id, bus);board/freescale/ls1088a/eth_ls1088ardb.c +11
-10@@ -55,16 +55,17 @@ int board_eth_init(bd_t *bis)* a MAC has no PHY address, we give a PHY address to XFI * MAC error. */ -wriop_set_phy_address (WRIOP1_DPMAC1 ,0x0a ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,QSGMII1_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,QSGMII1_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,QSGMII1_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,QSGMII1_PORT4_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,QSGMII2_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,QSGMII2_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC9 ,QSGMII2_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC10 ,QSGMII2_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,0x0a ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,QSGMII1_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,QSGMII1_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,QSGMII1_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,QSGMII1_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,QSGMII2_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,QSGMII2_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC9 ,0 ,QSGMII2_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC10 ,0 , +QSGMII2_PORT4_PHY_ADDR );break ;default :board/freescale/ls2080aqds/eth.c +13
-13@@ -623,7 +623,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );@@ -631,7 +631,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)break ;case 2 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT2 ; bus =mii_dev_for_muxval (EMI1_SLOT2 );@@ -641,18 +641,18 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)if (slot ==EMI_NONE )return ;if (serdes1_prtcl ==0x39 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=6 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=7 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT3 ;@@ -691,7 +691,7 @@ serdes2:break ;case 4 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -9 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT4 ; bus =mii_dev_for_muxval (EMI1_SLOT4 );@@ -701,14 +701,14 @@ serdes2:if (slot ==EMI_NONE )return ;if (serdes2_prtcl ==0x47 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -10 ]);if (dpmac_id >=14 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT5 ;@@ -717,7 +717,7 @@ serdes2:break ;case 6 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -13 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT6 ; bus =mii_dev_for_muxval (EMI1_SLOT6 );@@ -775,7 +775,7 @@ void ls2080a_handle_phy_interface_qsgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a QSGMII riser card? */ -wriop_set_phy_address (dpmac_id, dpmac_id -1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id -1 ); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );wriop_set_mdio (dpmac_id, bus);@@ -819,7 +819,7 @@ void ls2080a_handle_phy_interface_xsgmii(int i)* the XAUI card is used for the XFI MAC, which will cause * error. */ -wriop_set_phy_address (i, i +4 ); +wriop_set_phy_address (i,0 , i +4 );ls2080a_qds_enable_SFP_TX (SFP_TX );break ;board/freescale/ls2080ardb/eth_ls2080rdb.c +12
-12@@ -50,21 +50,21 @@ int board_eth_init(bd_t *bis)switch (srds_s1) {case 0x2A : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,AQ_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,AQ_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,AQ_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,AQ_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,AQ_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,AQ_PHY_ADDR4 );break ;case 0x4B : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 );break ;default :drivers/net/ldpaa_eth/ldpaa_eth.c +3
-1@@ -23,27 +23,43 @@ static int init_phy(struct eth_device *dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;struct phy_device *phydev =NULL ;struct mii_dev *bus; -int ret; +struct wriop_dpmac_info *dpmac_info =NULL ; +int phy_addr, phy_num; +int ret =0 ;
drivers/net/ldpaa_eth/ldpaa_eth.c static int init_phy(struct eth_device *dev) · line 34
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +1
-5bus =wriop_get_mdio (priv->dpmac_id);if (bus ==NULL )return 0 ; - phydev =phy_connect (bus,wriop_get_phy_address (priv->dpmac_id), - dev,wriop_get_enet_if (priv->dpmac_id)); -if (!phydev) { -printf ("Failed to connect\n" ); -return -1 ; +for (phy_num =0 ; phy_num <ARRAY_SIZE (dpmac_info->phydev); phy_num++) {
Why not use WRIOP_MAX_PHY_NUM here directly?
drivers/net/ldpaa_eth/ldpaa_eth.c static int init_phy(struct eth_device *dev) · line 36
Quoted 2 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-0+ phy_addr =wriop_get_phy_address (priv->dpmac_id, phy_num); +if (phy_addr !=-1 ) {
If you instead say:
if (phy_addr == -1)
continue;
Then you don't have to have the whole next chunk indented in a deeper block.
drivers/net/ldpaa_eth/ldpaa_eth.c static int init_phy(struct eth_device *dev) · line 41
Quoted 5 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +5
-0+ phydev =phy_connect (bus, phy_addr, dev, +wriop_get_enet_if (priv->dpmac_id)); +if (!phydev) { +printf ("Failed to connect\n" ); + ret =-1 ;
ret = -ENODEV; since this would be NULL if phy_find_by_mask() can't find the phy.
Quoted 9 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +7
-0+break ; + } +wriop_set_phy_dev (priv->dpmac_id, phy_num, phydev); + ret =phy_config (phydev); +if (ret) +break ; + } }
drivers/net/ldpaa_eth/ldpaa_eth.c static int init_phy(struct eth_device *dev) · line 53
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-7-wriop_set_phy_dev (priv->dpmac_id, phydev); - - ret =phy_config (phydev); -if (ret) { -free (phydev); - phydev =NULL ; -wriop_set_phy_dev (priv->dpmac_id, phydev); + for (phy_num = 0; + phy_num < ARRAY_SIZE(dpmac_info->phydev);
Throughout it would be better to use WRIOP_MAX_PHY_NUM.
Quoted 24 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +11
-0+ phy_num++) { + phydev =wriop_get_phy_dev (priv->dpmac_id, phy_num); +if (phydev) { +free (phydev); + phydev =NULL ; +wriop_set_phy_dev (priv->dpmac_id, phy_num, + phydev); + } + } }return ret;@@ -390,7 +406,9 @@ static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, struct dpmac_link_state *state) {struct phy_device *phydev =NULL ; +struct wriop_dpmac_info *dpmac_info =NULL ;phy_interface_t enet_if; +int phy_num, phys_detected;int err;/* let's start off with maximum capabilities @@ -406,15 +424,23 @@ static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, }
drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, · line 432
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +3
-2state->up =1 ; + phys_detected =0 ;#ifdef CONFIG_PHYLIB state->options |=DPMAC_LINK_OPT_AUTONEG ; - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) { +/* start the phy devices one by one and update the dpmac state +*/
Please use single-line comment format.
Quoted 15 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +7
-0+for (phy_num =0 ; phy_num <ARRAY_SIZE (dpmac_info->phydev); phy_num++) { + phydev =wriop_get_phy_dev (priv->dpmac_id, phy_num); +if (!phydev) +continue ; + + phys_detected++; err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , phydev->dev->name); state->up =0 ; +break ; }if (phydev->link ==1 ) { state->rate = state->rate < phydev->speed ?
drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, · line 454
Quoted 5 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-0@@ -424,11 +450,14 @@ static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv,if (!phydev->autoneg) state->options &= ~DPMAC_LINK_OPT_AUTONEG ; }else { +/* break out of loop even if one phy is down +*/
Please use single-line comment format.
Quoted 20 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +4
-1state->up =0 ; + break; } }#endif -if (!phydev) +if (phys_detected ==0 ) state->options &= ~DPMAC_LINK_OPT_AUTONEG ;if (state->up ==0 ) {@@ -570,6 +599,8 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;int err =0 ;struct phy_device *phydev =NULL ; +struct wriop_dpmac_info *dpmac_info =NULL ; +int phy_num;if ((net_dev->state ==ETH_STATE_PASSIVE ) || (net_dev->state ==ETH_STATE_INIT ))
drivers/net/ldpaa_eth/ldpaa_eth.c static void ldpaa_eth_stop(struct eth_device *net_dev) · line 636
Quoted 7 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +1
-3@@ -602,9 +633,11 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)printf ("dpni_disable() failed\n" );#ifdef CONFIG_PHYLIB - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) -phy_shutdown (phydev); +for (phy_num =0 ; phy_num <ARRAY_SIZE (dpmac_info->phydev); phy_num++) {
Use WRIOP_MAX_PHY_NUM
Quoted 25 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +4
-0+ phydev =wriop_get_phy_dev (priv->dpmac_id, phy_num); +if (phydev) + phy_shutdown(phydev); + }#endif /* Free DPBP handle and reset. */ drivers/net/ldpaa_eth/ldpaa_wriop.c +1
-2@@ -22,11 +22,10 @@ __weak phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtc)void wriop_init_dpmac (int sd,int dpmac_id,int lane_prtcl) {phy_interface_t enet_if; +int phy_num; dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; - dpmac_info[dpmac_id].phy_addr =-1 ; - dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl);
drivers/net/ldpaa_eth/ldpaa_wriop.c void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) · line 36
Quoted 3 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +0
-0@@ -35,15 +34,35 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].enet_if = enet_if; }
This should jut call wriop_init_dpmac_enet_if(). You can just set dpmac_info[dpmac_id].enabled = 0 after calling wriop_init_dpmac_enet_if().
Quoted 13 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +10
-0+for (phy_num =0 ; + phy_num <ARRAY_SIZE (dpmac_info[dpmac_id].phydev); + phy_num++) { + dpmac_info[dpmac_id].phydev[phy_num] =NULL ; + } +for (phy_num =0 ; + phy_num <ARRAY_SIZE (dpmac_info[dpmac_id].phy_addr); + phy_num++) { + dpmac_info[dpmac_id].phy_addr[phy_num] =-1 ; + } }void wriop_init_dpmac_enet_if (int dpmac_id,phy_interface_t enet_if)
drivers/net/ldpaa_eth/ldpaa_wriop.c void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) · line 57
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +4
-2{ +int phy_num; + dpmac_info[dpmac_id].enabled =1 ; dpmac_info[dpmac_id].id = dpmac_id; - dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; - dpmac_info[dpmac_id].phydev =NULL ; + for (phy_num = 0; + phy_num < ARRAY_SIZE(dpmac_info[dpmac_id].phydev);
Use WRIOP_MAX_PHY_NUM
drivers/net/ldpaa_eth/ldpaa_wriop.c void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) · line 45
Quoted 7 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +7
-0+ phy_num++) { + dpmac_info[dpmac_id].phydev[phy_num] =NULL ; + } +for (phy_num =0 ; + phy_num <ARRAY_SIZE (dpmac_info[dpmac_id].phy_addr); + phy_num++) { + dpmac_info[dpmac_id].phy_addr[phy_num] =-1 ;
Move this to the other loop.
Quoted 6 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +1
-0+ } }@@ -113,44 +132,52 @@ struct mii_dev *wriop_get_mdio(int dpmac_id)return dpmac_info[i].bus;
drivers/net/ldpaa_eth/ldpaa_wriop.c struct mii_dev *wriop_get_mdio(int dpmac_id) · line 141
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +2
-1} -void wriop_set_phy_address (int dpmac_id,int address) +void wriop_set_phy_address (int dpmac_id,int phy_num,int address) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 )return ; +if (phy_num <0 || phy_num >=ARRAY_SIZE (dpmac_info[dpmac_id].phy_addr))
Use WRIOP_MAX_PHY_NUM
drivers/net/ldpaa_eth/ldpaa_wriop.c struct mii_dev *wriop_get_mdio(int dpmac_id) · line 152
Quoted 13 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +3
-2+return ; - dpmac_info[i].phy_addr = address; + dpmac_info[i].phy_addr[phy_num] = address; } -int wriop_get_phy_address (int dpmac_id) +int wriop_get_phy_address (int dpmac_id,int phy_num) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 )return -1 ;
This should probably return -ENODEV;
drivers/net/ldpaa_eth/ldpaa_wriop.c struct mii_dev *wriop_get_mdio(int dpmac_id) · line 153
Quoted 1 line
drivers/net/ldpaa_eth/ldpaa_wriop.c +1
-0+if (phy_num <0 || phy_num >=ARRAY_SIZE (dpmac_info[dpmac_id].phy_addr))
Use WRIOP_MAX_PHY_NUM
drivers/net/ldpaa_eth/ldpaa_wriop.c struct mii_dev *wriop_get_mdio(int dpmac_id) · line 154
Quoted 1 line
drivers/net/ldpaa_eth/ldpaa_wriop.c +1
-0+return -1 ;
Use return -EINVAL;
drivers/net/ldpaa_eth/ldpaa_wriop.c struct mii_dev *wriop_get_mdio(int dpmac_id) · line 159
Quoted 7 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +2
-2-return dpmac_info[i].phy_addr; +return dpmac_info[i].phy_addr[phy_num]; } -void wriop_set_phy_dev (int dpmac_id,struct phy_device *phydev) +void wriop_set_phy_dev (int dpmac_id,int phy_num,struct phy_device *phydev)
Please make this return an int and use the same errors as above.
Quoted 65 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +7
-3{int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 )return ; +if (phy_num <0 || phy_num >=ARRAY_SIZE (dpmac_info[dpmac_id].phydev)) +return ; - dpmac_info[i].phydev = phydev; + dpmac_info[i].phydev[phy_num] = phydev; } -struct phy_device *wriop_get_phy_dev (int dpmac_id) +struct phy_device *wriop_get_phy_dev (int dpmac_id,int phy_num) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 )return NULL ; +if (phy_num <0 || phy_num >=ARRAY_SIZE (dpmac_info[dpmac_id].phydev)) +return NULL ; -return dpmac_info[i].phydev; +return dpmac_info[i].phydev[phy_num]; }phy_interface_t wriop_get_enet_if (int dpmac_id)include/fsl-mc/ldpaa_wriop.h +7
-6@@ -6,7 +6,11 @@#ifndef __LDPAA_WRIOP_H#define __LDPAA_WRIOP_H -#include <phy.h> +#include <phy.h> + +#define DEFAULT_WRIOP_MDIO1_NAME "FSL_MDIO0" +#define DEFAULT_WRIOP_MDIO2_NAME "FSL_MDIO1" +#define WRIOP_MAX_PHY_NUM 2enum wriop_port { WRIOP1_DPMAC1 = 1,@@ -40,27 +44,24 @@ struct wriop_dpmac_info {u8 enabled;u8 id;u8 board_mux; -int phy_addr; +int phy_addr[WRIOP_MAX_PHY_NUM ];phy_interface_t enet_if; -struct phy_device *phydev; +struct phy_device *phydev[WRIOP_MAX_PHY_NUM ];struct mii_dev *bus; };extern struct wriop_dpmac_info dpmac_info[NUM_WRIOP_PORTS ]; -#define DEFAULT_WRIOP_MDIO1_NAME "FSL_MDIO0" -#define DEFAULT_WRIOP_MDIO2_NAME "FSL_MDIO1" -void wriop_init_dpmac (int ,int ,int );void wriop_disable_dpmac (int );void wriop_enable_dpmac (int );u8 wriop_is_enabled_dpmac (int dpmac_id);
include/fsl-mc/ldpaa_wriop.h struct wriop_dpmac_info { · line 64
Quoted 10 lines
include/fsl-mc/ldpaa_wriop.h +4
-4void wriop_set_mdio (int ,struct mii_dev *);struct mii_dev *wriop_get_mdio (int ); -void wriop_set_phy_address (int ,int ); -int wriop_get_phy_address (int ); -void wriop_set_phy_dev (int ,struct phy_device *); -struct phy_device *wriop_get_phy_dev (int ); +void wriop_set_phy_address (int ,int ,int ); +int wriop_get_phy_address (int ,int ); +void wriop_set_phy_dev (int ,int ,struct phy_device *); +struct phy_device *wriop_get_phy_dev (int ,int );
Please include the variable names in the headers too. No need to be obfuscated. Function comments would be even better.
Quoted 10 lines
include/fsl-mc/ldpaa_wriop.h +0
-1phy_interface_t wriop_get_enet_if (int );void wriop_dpmac_disable (int ); --2.17.1
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
cover driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalQuoted 34 lines
-----Original Message-----
From: Pankaj Bansal
Sent: Friday, July 13, 2018 8:11 PM
To: u-boot at lists.denx.de
Cc: Prabhakar Kushwaha <[email protected]>; Priyanka Jain <[email protected]>; Varun Sethi <[email protected]>; York Sun <[email protected]>; joe.hershberger at ni.com; Pankaj Bansal <[email protected]>
Subject: [PATCH 0/6] driver: net: fsl-mc: Add support of multiple phys for dpmacThis patch set adds support of multiple phys for one dpmac
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. To handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up.
also the link capabilities are limited by the weakest phy device.i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Pankaj Bansal (6):
driver: net: fsl-mc: modify the label name
driver: net: fsl-mc: remove unused strcture elements
driver: net: fsl-mc: fix error handing ininit_phy
driver: net: fsl-mc: Modify the dpmac link detection method
driver: net: fsl-mc: initialize dpmac irrespective of phy
driver: net: fsl-mc: Add support of multiple phys for dpmac
Quoted 10 lines
board/freescale/ls1088a/eth_ls1088aqds.c | 18 +-- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +-- board/freescale/ls2080aqds/eth.c | 26 +-- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +-- drivers/net/fsl-mc/mc.c | 6 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 180 +++++++++++++-------- drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 49 ++++-- include/fsl-mc/ldpaa_wriop.h | 22 +-- 9 files changed, 209 insertions(+), 138 deletions(-)
Patch set looks good.
cover driver: net: fsl-mc: Add support of multiple phys for dpmac
Hi Joe,
Can you please review these changes ?
Regards,
Pankaj Bansal
Quoted 60 lines
-----Original Message-----
From: Prabhakar Kushwaha
Sent: Thursday, July 19, 2018 9:06 AM
To: Pankaj Bansal <[email protected]>; u-boot at lists.denx.de
Cc: Priyanka Jain <[email protected]>; Varun Sethi <[email protected]>; York Sun <[email protected]>; joe.hershberger at ni.com
Subject: RE: [PATCH 0/6] driver: net: fsl-mc: Add support of multiple phys for dpmacQuoted 33 lines
-----Original Message-----
From: Pankaj Bansal
Sent: Friday, July 13, 2018 8:11 PM
To: u-boot at lists.denx.de
Cc: Prabhakar Kushwaha <[email protected]>; Priyanka Jain <[email protected]>; Varun Sethi <[email protected]>; York Sun <[email protected]>; joe.hershberger at ni.com; Pankaj Bansal <[email protected]>
Subject: [PATCH 0/6] driver: net: fsl-mc: Add support of multiple phys for dpmacThis patch set adds support of multiple phys for one dpmac
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. To handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Pankaj Bansal (6):
driver: net: fsl-mc: modify the label name
driver: net: fsl-mc: remove unused strcture elements
driver: net: fsl-mc: fix error handing ininit_phy
driver: net: fsl-mc: Modify the dpmac link detection method
driver: net: fsl-mc: initialize dpmac irrespective of phy
driver: net: fsl-mc: Add support of multiple phys for dpmacQuoted 10 lines
board/freescale/ls1088a/eth_ls1088aqds.c | 18 +-- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +-- board/freescale/ls2080aqds/eth.c | 26 +-- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +-- drivers/net/fsl-mc/mc.c | 6 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 180 +++++++++++++-------- drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 49 ++++-- include/fsl-mc/ldpaa_wriop.h | 22 +-- 9 files changed, 209 insertions(+), 138 deletions(-)Patch set looks good.
Reviewed-by Prabhakar Kushwaha <[email protected]>
v2 cover driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalThis patch set adds support of multiple phys for one dpmac
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. To handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up.
also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Pankaj Bansal (6):
driver: net: fsl-mc: modify the label name
driver: net: fsl-mc: remove unused strcture elements
driver: net: fsl-mc: fix error handing in init_phy
driver: net: fsl-mc: Modify the dpmac link detection method
driver: net: fsl-mc: initialize dpmac irrespective of phy
driver: net: fsl-mc: Add support of multiple phys for dpmac
board/freescale/ls1088a/eth_ls1088aqds.c | 18 +-- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +-- board/freescale/ls2080aqds/eth.c | 26 ++-- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +-- drivers/net/fsl-mc/mc.c | 6 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 171 +++++++++++++-------- drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 59 ++++--- include/fsl-mc/ldpaa_wriop.h | 46 +++--- 9 files changed, 211 insertions(+), 161 deletions(-)
Signature · 1 line
2.17.1
PATCH v2 1/6 driver: net: fsl-mc: modify the label name
The goto label name is misspelled it should be DPMAC not DPAMC
---
Notes:
V2:
- No change
drivers/net/ldpaa_eth/ldpaa_eth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +4 -4
@@ -413,7 +413,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err) {printf ("%s: Could not initialize\n" , priv->phydev->dev->name); - goto err_dpamc_bind; + goto err_dpmac_bind; } }#else
@@ -441,13 +441,13 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (!priv->phydev->link) {printf ("%s: No link.\n" , priv->phydev->dev->name); err =-1 ; - goto err_dpamc_bind; + goto err_dpmac_bind; }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);if (err) - goto err_dpamc_bind; + goto err_dpmac_bind;/* DPNI initialization */ err =ldpaa_dpni_setup (priv);
@@ -540,7 +540,7 @@ err_dpni_bind: err_dpbp_setup:dpni_close (dflt_mc_io,MC_CMD_NO_FLAGS , dflt_dpni->dpni_handle); err_dpni_setup: -err_dpamc_bind: +err_dpmac_bind:dpmac_close (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle); dpmac_destroy(dflt_mc_io, dflt_dprc_handle,
Signature · 1 line
2.17.1
PATCH v2 1/6 driver: net: fsl-mc: modify the label name
Quoted 3 lines · Pankaj Bansal
The goto label name is misspelled it should be DPMAC not DPAMC
Signed-off-by Pankaj Bansal <[email protected]>
PATCH v2 2/6 driver: net: fsl-mc: remove unused strcture elements
In reply to Pankaj BansalThe phydev structure is present in both ldpaa_eth_priv and wriop_dpmac_info. the phydev in wriop_dpmac_info is not being used
As the phydev is created based on phy_addr and bus members of wriop_dpmac_info, it is appropriate to keep phydev in wriop_dpmac_info.
Also phy_regs is not being used, therefore remove it
---
Notes:
V2:
- change (phydev && bus != NULL) to (phydev && bus)
- after free phydev just pass NULL into wriop_set_phy_dev()
drivers/net/ldpaa_eth/ldpaa_eth.c | 56 +++++++++++++++------------ drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 2 + include/fsl-mc/ldpaa_wriop.h | 1 - 4 files changed, 33 insertions(+), 27 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +31 -25
@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)return -1 ; } - priv->phydev = phydev; +wriop_set_phy_dev (priv->dpmac_id, phydev);return phy_config (phydev); }
@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct mii_dev *bus;phy_interface_t enet_if;struct dpni_queue d_queue; +struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;
@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_dpmac_setup;#ifdef CONFIG_PHYLIB -if (priv->phydev) { - err =phy_startup (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , - priv->phydev->dev->name); + phydev->dev->name); goto err_dpmac_bind; } }#else - priv->phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_1000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_1000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ;#endif bus =wriop_get_mdio (priv->dpmac_id); enet_if =wriop_get_enet_if (priv->dpmac_id);if ((bus ==NULL ) && (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - priv->phydev = (struct phy_device *) + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_10000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_10000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ; } -if (!priv->phydev->link) { -printf ("%s: No link.\n" , priv->phydev->dev->name); +if (!phydev->link) { +printf ("%s: No link.\n" , phydev->dev->name); err =-1 ; goto err_dpmac_bind; }
@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = priv->phydev->speed; + dpmac_link_state.rate = phydev->speed; -if (priv->phydev->autoneg ==AUTONEG_DISABLE ) +if (phydev->autoneg ==AUTONEG_DISABLE ) dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ;else dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; -if (priv->phydev->duplex ==DUPLEX_HALF ) +if (phydev->duplex ==DUPLEX_HALF ) dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - dpmac_link_state.up = priv->phydev->link; + dpmac_link_state.up = phydev->link; err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);
@@ -530,7 +534,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return priv->phydev->link; +return phydev->link; err_qdid: err_get_queue:
@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id);#endif +struct phy_device *phydev =NULL ;if ((net_dev->state ==ETH_STATE_PASSIVE ) || (net_dev->state ==ETH_STATE_INIT ))
@@ -588,11 +593,12 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)printf ("dpni_disable() failed\n" );#ifdef CONFIG_PHYLIB -if (priv->phydev && bus !=NULL ) -phy_shutdown (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev && bus) +phy_shutdown (phydev);else { -free (priv->phydev); - priv->phydev =NULL ; +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); }#endif
drivers/net/ldpaa_eth/ldpaa_eth.h +0 -1
@@ -127,7 +127,6 @@ struct ldpaa_eth_priv {uint16_t tx_flow_id;enum ldpaa_eth_type type;/* 1G or 10G ethernet */ -struct phy_device *phydev; };struct dprc_endpoint dpmac_endpoint;
drivers/net/ldpaa_eth/ldpaa_wriop.c +2 -0
@@ -26,6 +26,7 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; dpmac_info[dpmac_id].phy_addr =-1 ; + dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl);
@@ -42,6 +43,7 @@ void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t enet_if) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; + dpmac_info[dpmac_id].phydev =NULL ; }
include/fsl-mc/ldpaa_wriop.h +0 -1
@@ -41,7 +41,6 @@ struct wriop_dpmac_info {u8 id;u8 board_mux;int phy_addr; -void *phy_regs;phy_interface_t enet_if;struct phy_device *phydev;struct mii_dev *bus;
Signature · 1 line
2.17.1
PATCH v2 2/6 driver: net: fsl-mc: remove unused strcture elements
Quoted 9 lines · Pankaj Bansal
The phydev structure is present in both
ldpaa_eth_privandwriop_dpmac_info. the phydev inwriop_dpmac_infois not being usedAs the phydev is created based on
phy_addrand bus members ofwriop_dpmac_info, it is appropriate to keep phydev inwriop_dpmac_info.Also
phy_regsis not being used, therefore remove itSigned-off-by Pankaj Bansal <[email protected]>
PATCH v2 3/6 driver: net: fsl-mc: fix error handing in init_phy
In reply to Pankaj Bansalif an error occurs during init_phy, we should free the phydev structure which has been allocated by phy_connect.
---
Notes:
V2:
- after free phydev just pass NULL into wriop_set_phy_dev()
drivers/net/ldpaa_eth/ldpaa_eth.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +9 -1
@@ -23,6 +23,7 @@ static int init_phy(struct eth_device *dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;struct phy_device *phydev =NULL ;struct mii_dev *bus; +int ret; bus =wriop_get_mdio (priv->dpmac_id);if (bus ==NULL )
@@ -37,7 +38,14 @@ static int init_phy(struct eth_device *dev)wriop_set_phy_dev (priv->dpmac_id, phydev); - return phy_config(phydev); + ret =phy_config (phydev); + +if (ret) { +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); + } + + return ret; }#endif
Signature · 1 line
2.17.1
PATCH v2 3/6 driver: net: fsl-mc: fix error handing in init_phy
Quoted 4 lines · Pankaj Bansal
if an error occurs during
init_phy, we should free the phydev structure which has been allocated byphy_connect.Signed-off-by Pankaj Bansal <[email protected]>
PATCH v2 4/6 driver: net: fsl-mc: Modify the dpmac link detection method
In reply to Pankaj Bansalwhen there is no phy present for a dpmac, a dummy phy device is created. when we move to multiple phy method, we need to create as many dummy phy devices.
Change this method so that we don't need to create dummy phy devices. We always report linkup if no phy is present.
---
Notes:
V2:
- Change (phydev->link == 1) to (phydev->link)
- Use min macro instead of ternary operator
- return -ENOLINK instead of -1 from ldpaa_get_dpmac_state
- Change (state->up == 0) to (!state->up)
drivers/net/ldpaa_eth/ldpaa_eth.c | 119 +++++++++++++--------------- 1 file changed, 57 insertions(+), 62 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +57 -62
@@ -385,6 +385,59 @@ error:return err; } +static int ldpaa_get_dpmac_state (struct ldpaa_eth_priv *priv, +struct dpmac_link_state *state) +{ +struct phy_device *phydev =NULL ; +phy_interface_t enet_if; +int err; + +/* let's start off with maximum capabilities +*/ + enet_if =wriop_get_enet_if (priv->dpmac_id); +switch (enet_if) { +case PHY_INTERFACE_MODE_XGMII : + state->rate =SPEED_10000 ; +break ; +default : + state->rate =SPEED_1000 ; +break ; + } + state->up =1 ; + +#ifdef CONFIG_PHYLIB + state->options |=DPMAC_LINK_OPT_AUTONEG ; + + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev); +if (err) { +printf ("%s: Could not initialize\n" , phydev->dev->name); + state->up =0 ; + } +if (phydev->link) { + state->rate =min (state->rate, (uint32_t )phydev->speed); +if (!phydev->duplex) + state->options |=DPMAC_LINK_OPT_HALF_DUPLEX ; +if (!phydev->autoneg) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + }else { + state->up =0 ; + } + } +#endif +if (!phydev) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + +if (!state->up) { + state->rate =0 ; + state->options =0 ; +return -ENOLINK ; + } + +return 0 ; +} +static int ldpaa_eth_open (struct eth_device *net_dev,bd_t *bd) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
@@ -393,10 +446,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct dpni_link_state link_state;#endif int err =0 ; -struct mii_dev *bus; -phy_interface_t enet_if;struct dpni_queue d_queue; -struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;
@@ -416,45 +466,9 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err <0 ) goto err_dpmac_setup; -#ifdef CONFIG_PHYLIB - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) { - err =phy_startup (phydev); -if (err) { -printf ("%s: Could not initialize\n" , - phydev->dev->name); - goto err_dpmac_bind; - } - } -#else - phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_1000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; -#endif - - bus =wriop_get_mdio (priv->dpmac_id); - enet_if =wriop_get_enet_if (priv->dpmac_id); -if ((bus ==NULL ) && - (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - phydev = (struct phy_device *) -malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_10000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; - } - -if (!phydev->link) { -printf ("%s: No link.\n" , phydev->dev->name); - err =-1 ; + err =ldpaa_get_dpmac_state (priv, &dpmac_link_state); +if (err <0 ) goto err_dpmac_bind; - }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);
@@ -488,18 +502,6 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = phydev->speed; - -if (phydev->autoneg ==AUTONEG_DISABLE ) - dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ; -else - dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; - -if (phydev->duplex ==DUPLEX_HALF ) - dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - - dpmac_link_state.up = phydev->link; - err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);if (err <0 ) {
@@ -542,7 +544,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return phydev->link; +return dpmac_link_state.up; err_qdid: err_get_queue:
@@ -565,9 +567,6 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;int err =0 ; -#ifdef CONFIG_PHYLIB -struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id); -#endif struct phy_device *phydev =NULL ; if ((net_dev->state == ETH_STATE_PASSIVE) ||
@@ -602,12 +601,8 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev && bus) +if (phydev)phy_shutdown (phydev); -else { -free (phydev); -wriop_set_phy_dev (priv->dpmac_id,NULL ); - }#endif /* Free DPBP handle and reset. */
Signature · 1 line
2.17.1
PATCH v2 4/6 driver: net: fsl-mc: Modify the dpmac link detection method
Quoted 8 lines · Pankaj Bansal
when there is no phy present for a dpmac, a dummy phy device is created. when we move to multiple phy method, we need to create as many dummy phy devices.
Change this method so that we don't need to create dummy phy devices. We always report linkup if no phy is present.
Signed-off-by Pankaj Bansal <[email protected]>
PATCH v2 5/6 driver: net: fsl-mc: initialize dpmac irrespective of phy
In reply to Pankaj BansalThe dpmac initalization should not depend on phy.
As the phy is not necessary to be present for dpmac to function. Therefore, remove dpmac initialization dependency from phy.
---
Notes:
V2:
- No Change
drivers/net/fsl-mc/mc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/fsl-mc/mc.c +2 -4
@@ -327,8 +327,7 @@ static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type)for (i =WRIOP1_DPMAC1 ; i <NUM_WRIOP_PORTS ; i++) {/* port not enabled */ -if ((wriop_is_enabled_dpmac (i) !=1 ) || - (wriop_get_phy_address (i) ==-1 )) +if (wriop_is_enabled_dpmac (i) !=1 )continue ; sprintf(ethname, "DPMAC%d@%s", i,
@@ -845,8 +844,7 @@ int fsl_mc_ldpaa_init(bd_t *bis)int i;for (i =WRIOP1_DPMAC1 ; i <NUM_WRIOP_PORTS ; i++) -if ((wriop_is_enabled_dpmac (i) ==1 ) && - (wriop_get_phy_address (i) !=-1 )) +if (wriop_is_enabled_dpmac (i) ==1 )ldpaa_eth_init (i,wriop_get_enet_if (i));return 0 ; }
Signature · 1 line
2.17.1
PATCH v2 5/6 driver: net: fsl-mc: initialize dpmac irrespective of phy
Quoted 5 lines · Pankaj Bansal
The dpmac initalization should not depend on phy.
As the phy is not necessary to be present for dpmac to function. Therefore, remove dpmac initialization dependency from phy.Signed-off-by Pankaj Bansal <[email protected]>
PATCH v2 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalTill now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
---
Notes:
V2:
- use single-line comment format.
- use WRIOP_MAX_PHY_NUM.
- use -ENODEV or -EINVAL instead of -1 wherever appropriate
- include the variable names in the headers too.
- Change the return type of some functions from void to int so that a meaningful error message can be returned
board/freescale/ls1088a/eth_ls1088aqds.c | 18 +++--- board/freescale/ls1088a/eth_ls1088ardb.c | 21 ++++--- board/freescale/ls2080aqds/eth.c | 26 ++++---- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 66 ++++++++++++++------ drivers/net/ldpaa_eth/ldpaa_wriop.c | 61 +++++++++++------- include/fsl-mc/ldpaa_wriop.h | 45 ++++++------- 7 files changed, 152 insertions(+), 109 deletions(-)
board/freescale/ls1088a/eth_ls1088aqds.c +9 -9
@@ -487,16 +487,16 @@ void ls1088a_handle_phy_interface_sgmii(int dpmac_id)case 0x3A :switch (dpmac_id) {case 1 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[1 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[1 ]);break ;case 2 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[0 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[0 ]);break ;case 3 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[3 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[3 ]);break ;case 7 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[2 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[2 ]);break ;default :printf ("WRIOP: Wrong DPMAC%d set to SGMII" , dpmac_id);
@@ -532,13 +532,13 @@ void ls1088a_handle_phy_interface_qsgmii(int dpmac_id)case 4 :case 5 :case 6 : -wriop_set_phy_address (dpmac_id, dpmac_id +9 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +9 );break ;case 7 :case 8 :case 9 :case 10 : -wriop_set_phy_address (dpmac_id, dpmac_id +1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +1 );break ; }
@@ -567,7 +567,7 @@ void ls1088a_handle_phy_interface_xsgmii(int i)case 0x15 :case 0x1D :case 0x1E : -wriop_set_phy_address (i, i +26 ); +wriop_set_phy_address (i,0 , i +26 );ls1088a_qds_enable_SFP_TX (SFP_TX );break ;default :
@@ -590,13 +590,13 @@ static void ls1088a_handle_phy_interface_rgmii(int dpmac_id)switch (dpmac_id) {case 4 : -wriop_set_phy_address (dpmac_id,RGMII_PHY1_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY1_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII1 ; bus =mii_dev_for_muxval (EMI1_RGMII1 );wriop_set_mdio (dpmac_id, bus);break ;case 5 : -wriop_set_phy_address (dpmac_id,RGMII_PHY2_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY2_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII2 ; bus =mii_dev_for_muxval (EMI1_RGMII2 );wriop_set_mdio (dpmac_id, bus);
board/freescale/ls1088a/eth_ls1088ardb.c +11 -10
@@ -55,16 +55,17 @@ int board_eth_init(bd_t *bis)* a MAC has no PHY address, we give a PHY address to XFI * MAC error. */ -wriop_set_phy_address (WRIOP1_DPMAC1 ,0x0a ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,QSGMII1_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,QSGMII1_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,QSGMII1_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,QSGMII1_PORT4_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,QSGMII2_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,QSGMII2_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC9 ,QSGMII2_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC10 ,QSGMII2_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,0x0a ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,QSGMII1_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,QSGMII1_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,QSGMII1_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,QSGMII1_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,QSGMII2_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,QSGMII2_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC9 ,0 ,QSGMII2_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC10 ,0 , +QSGMII2_PORT4_PHY_ADDR );break ;default :
board/freescale/ls2080aqds/eth.c +13 -13
@@ -623,7 +623,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );
@@ -631,7 +631,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)break ;case 2 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT2 ; bus =mii_dev_for_muxval (EMI1_SLOT2 );
@@ -641,18 +641,18 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)if (slot ==EMI_NONE )return ;if (serdes1_prtcl ==0x39 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=6 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=7 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT3 ;
@@ -691,7 +691,7 @@ serdes2:break ;case 4 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -9 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT4 ; bus =mii_dev_for_muxval (EMI1_SLOT4 );
@@ -701,14 +701,14 @@ serdes2:if (slot ==EMI_NONE )return ;if (serdes2_prtcl ==0x47 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -10 ]);if (dpmac_id >=14 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT5 ;
@@ -717,7 +717,7 @@ serdes2:break ;case 6 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -13 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT6 ; bus =mii_dev_for_muxval (EMI1_SLOT6 );
@@ -775,7 +775,7 @@ void ls2080a_handle_phy_interface_qsgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a QSGMII riser card? */ -wriop_set_phy_address (dpmac_id, dpmac_id -1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id -1 ); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );wriop_set_mdio (dpmac_id, bus);
@@ -819,7 +819,7 @@ void ls2080a_handle_phy_interface_xsgmii(int i)* the XAUI card is used for the XFI MAC, which will cause * error. */ -wriop_set_phy_address (i, i +4 ); +wriop_set_phy_address (i,0 , i +4 );ls2080a_qds_enable_SFP_TX (SFP_TX );break ;
board/freescale/ls2080ardb/eth_ls2080rdb.c +12 -12
@@ -50,21 +50,21 @@ int board_eth_init(bd_t *bis)switch (srds_s1) {case 0x2A : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,AQ_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,AQ_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,AQ_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,AQ_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,AQ_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,AQ_PHY_ADDR4 );break ;case 0x4B : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 );break ;default :
drivers/net/ldpaa_eth/ldpaa_eth.c +46 -20
123 lines not on this page · raw message
drivers/net/ldpaa_eth/ldpaa_wriop.c +38 -23
153 lines not on this page · raw message
include/fsl-mc/ldpaa_wriop.h +23 -22
63 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
Hi Joe,
I have incorporated all your review comments except one:
"This should jut call wriop_init_dpmac_enet_if(). You can just set dpmac_info[dpmac_id].enabled = 0 after calling wriop_init_dpmac_enet_if()."
Actually in wriop_init_dpmac, we assign -1 to phy_addr array and NULL to phydev array irrespective of enet_if.
If we call wriop_init_dpmac_enet_if from wriop_init_dpmac then this would be done only for dpmacs for which enet_if is not PHY_INTERFACE_MODE_NONE.
Regards,
Pankaj Bansal
Quoted 729 lines
-----Original Message-----
From: Pankaj Bansal
Sent: Monday, July 30, 2018 6:45 PM
To: u-boot at lists.denx.de; joe.hershberger at ni.com
Cc: Prabhakar Kushwaha <[email protected]>; Priyanka Jain <[email protected]>; Varun Sethi <[email protected]>; York Sun <[email protected]>; Pankaj Bansal <[email protected]>
Subject: [PATCH v2 6/6] driver: net: fsl-mc: Add support of multiple phys for dpmacTill now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Signed-off-by Pankaj Bansal <[email protected]>---
Notes:
V2:
- use single-line comment format.
- useWRIOP_MAX_PHY_NUM.
- use-ENODEVor-EINVALinstead of -1 wherever appropriate
- include the variable names in the headers too.
- Change the return type of some functions from void to int so that a meaningful error message can be returnedboard/freescale/ls1088a/eth_ls1088aqds.c | 18 +++--- board/freescale/ls1088a/eth_ls1088ardb.c | 21 ++++--- board/freescale/ls2080aqds/eth.c | 26 ++++---- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 66 ++++++++++++++------ drivers/net/ldpaa_eth/ldpaa_wriop.c | 61 +++++++++++------- include/fsl-mc/ldpaa_wriop.h | 45 ++++++------- 7 files changed, 152 insertions(+), 109 deletions(-)board/freescale/ls1088a/eth_ls1088aqds.c +3
-3@@ -487,16 +487,16 @@ void ls1088a_handle_phy_interface_sgmii(int dpmac_id)case 0x3A :switch (dpmac_id) {case 1 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[1]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[1 ]);break ;case 2 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[0]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[0 ]);break ;case 3 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[3]); + wriop_set_phy_address(dpmac_id, 0,riser_phy_addr[3]);
board/freescale/ls1088a/eth_ls1088aqds.c +0
-1break ;case 7 : - wriop_set_phy_address(dpmac_id,riser_phy_addr[2]);
board/freescale/ls1088a/eth_ls1088aqds.c +1
-0+ wriop_set_phy_address(dpmac_id, 0,riser_phy_addr[2]);
board/freescale/ls1088a/eth_ls1088aqds.c +0
-0break ;default : printf("WRIOP: Wrong DPMAC%d set to SGMII",
dpmac_id); @@ -532,13 +532,13 @@ voidls1088a_handle_phy_interface_qsgmii(int dpmac_id)board/freescale/ls1088a/eth_ls1088aqds.c +1
-1case 4 :case 5 :case 6 : -wriop_set_phy_address (dpmac_id, dpmac_id +9 ); + wriop_set_phy_address(dpmac_id, 0, dpmac_id +9);
board/freescale/ls1088a/eth_ls1088aqds.c +1
-1break ;case 7 :case 8 :case 9 :case 10 : -wriop_set_phy_address (dpmac_id, dpmac_id +1 ); + wriop_set_phy_address(dpmac_id, 0, dpmac_id +1);
board/freescale/ls1088a/eth_ls1088aqds.c +3
-3break ; }@@ -567,7 +567,7 @@ void ls1088a_handle_phy_interface_xsgmii(int i)case 0x15 :case 0x1D :case 0x1E : -wriop_set_phy_address (i, i +26 ); +wriop_set_phy_address (i,0 , i +26 );ls1088a_qds_enable_SFP_TX (SFP_TX );break ;default :@@ -590,13 +590,13 @@ static void ls1088a_handle_phy_interface_rgmii(int dpmac_id) switch (dpmac_id) {case 4 : -wriop_set_phy_address (dpmac_id,RGMII_PHY1_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY1_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII1 ; bus =mii_dev_for_muxval (EMI1_RGMII1 );wriop_set_mdio (dpmac_id, bus);break ;case 5 : -wriop_set_phy_address (dpmac_id,RGMII_PHY2_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY2_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII2 ; bus =mii_dev_for_muxval (EMI1_RGMII2 );board/freescale/ls1088a/eth_ls1088aqds.c +0
-0wriop_set_mdio (dpmac_id, bus);board/freescale/ls1088a/eth_ls1088ardb.c +0
-8@@ -55,16 +55,17 @@ int board_eth_init(bd_t *bis)* a MAC has no PHY address, we give a PHY address to XFI * MAC error. */ -wriop_set_phy_address (WRIOP1_DPMAC1 ,0x0a ); -wriop_set_phy_address (WRIOP1_DPMAC2 , AQ_PHY_ADDR1); -wriop_set_phy_address (WRIOP1_DPMAC3 , QSGMII1_PORT1_PHY_ADDR); -wriop_set_phy_address (WRIOP1_DPMAC4 , QSGMII1_PORT2_PHY_ADDR); -wriop_set_phy_address (WRIOP1_DPMAC5 , QSGMII1_PORT3_PHY_ADDR); -wriop_set_phy_address (WRIOP1_DPMAC6 , QSGMII1_PORT4_PHY_ADDR); -wriop_set_phy_address (WRIOP1_DPMAC7 , QSGMII2_PORT1_PHY_ADDR); - wriop_set_phy_address(WRIOP1_DPMAC8,
QSGMII2_PORT2_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +0
-1- wriop_set_phy_address(WRIOP1_DPMAC9,
QSGMII2_PORT3_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +0
-1- wriop_set_phy_address(WRIOP1_DPMAC10,
QSGMII2_PORT4_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +2
-0+wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,0x0a ); + wriop_set_phy_address(WRIOP1_DPMAC2, 0,
AQ_PHY_ADDR1);board/freescale/ls1088a/eth_ls1088ardb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC3, 0,
QSGMII1_PORT1_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC4, 0,
QSGMII1_PORT2_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC5, 0,
QSGMII1_PORT3_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC6, 0,
QSGMII1_PORT4_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC7, 0,
QSGMII2_PORT1_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC8, 0,
QSGMII2_PORT2_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC9, 0,
QSGMII2_PORT3_PHY_ADDR);board/freescale/ls1088a/eth_ls1088ardb.c +2
-0+wriop_set_phy_address (WRIOP1_DPMAC10 ,0 , +QSGMII2_PORT4_PHY_ADDR );break ;default :board/freescale/ls2080aqds/eth.c +1
-1@@ -623,7 +623,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ;bus =
mii_dev_for_muxval(EMI1_SLOT1); @@ -
631,7 +631,7 @@ voidls2080a_handle_phy_interface_sgmii(int dpmac_id)board/freescale/ls2080aqds/eth.c +1
-1break ;case 2 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT2 ; bus = mii_dev_for_muxval(EMI1_SLOT2); @@ -641,18 +641,18 @@ void
ls2080a_handle_phy_interface_sgmii(int dpmac_id)board/freescale/ls2080aqds/eth.c +1
-1if (slot ==EMI_NONE )return ; if (serdes1_prtcl == 0x39) { - wriop_set_phy_address(dpmac_id, + wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[dpmac_id - 2]); if (dpmac_id >= 6 && hwconfig_f("xqsgmii",
env_hwconfig))board/freescale/ls2080aqds/eth.c +1
-1- wriop_set_phy_address(dpmac_id, + wriop_set_phy_address(dpmac_id,0,
riser_phy_addr[dpmac_id -
3]);board/freescale/ls2080aqds/eth.c +1
-1} else { -wriop_set_phy_address (dpmac_id , + wriop_set_phy_address(dpmac_id, 0, riser_phy_addr[dpmac_id - 2]); if (dpmac_id >= 7 && hwconfig_f("xqsgmii",
env_hwconfig))board/freescale/ls2080aqds/eth.c +1
-1- wriop_set_phy_address(dpmac_id, + wriop_set_phy_address(dpmac_id,0,
riser_phy_addr[dpmac_id -
3]);board/freescale/ls2080aqds/eth.c +1
-1} dpmac_info[dpmac_id].board_mux =EMI1_SLOT3 ;@@ -691,7 +691,7 @@ serdes2:break ;case 4 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -9 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT4 ; bus = mii_dev_for_muxval(EMI1_SLOT4); @@ -701,14 +701,14 @@ serdes2:
board/freescale/ls2080aqds/eth.c +1
-1if (slot ==EMI_NONE )return ;if (serdes2_prtcl ==0x47 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -10 ]); if (dpmac_id >= 14 &&hwconfig_f("xqsgmii",
env_hwconfig))board/freescale/ls2080aqds/eth.c +1
-1- wriop_set_phy_address(dpmac_id, + wriop_set_phy_address(dpmac_id,0,
riser_phy_addr[dpmac_id -
11]);board/freescale/ls2080aqds/eth.c +2
-2}else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT5 ;@@ -717,7 +717,7 @@ serdes2:break ;case 6 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -13 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT6 ; bus = mii_dev_for_muxval(EMI1_SLOT6); @@ -775,7 +775,7 @@ void
ls2080a_handle_phy_interface_qsgmii(int dpmac_id)board/freescale/ls2080aqds/eth.c +1
-1switch (++slot) {case 1 :/* Slot housing a QSGMII riser card? */ -wriop_set_phy_address (dpmac_id, dpmac_id -1 ); + wriop_set_phy_address(dpmac_id, 0, dpmac_id -1);
board/freescale/ls2080aqds/eth.c +1
-1dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );wriop_set_mdio (dpmac_id, bus);@@ -819,7 +819,7 @@ void ls2080a_handle_phy_interface_xsgmii(int i)* the XAUI card is used for the XFI MAC, which will cause * error. */ -wriop_set_phy_address (i, i +4 ); +wriop_set_phy_address (i,0 , i +4 );ls2080a_qds_enable_SFP_TX (SFP_TX );break ;board/freescale/ls2080ardb/eth_ls2080rdb.c +3
-8@@ -50,21 +50,21 @@ int board_eth_init(bd_t *bis)switch (srds_s1) {case 0x2A : -wriop_set_phy_address (WRIOP1_DPMAC1 , CORTINA_PHY_ADDR1); -wriop_set_phy_address (WRIOP1_DPMAC2 , CORTINA_PHY_ADDR2); -wriop_set_phy_address (WRIOP1_DPMAC3 , CORTINA_PHY_ADDR3); -wriop_set_phy_address (WRIOP1_DPMAC4 , CORTINA_PHY_ADDR4); -wriop_set_phy_address (WRIOP1_DPMAC5 , AQ_PHY_ADDR1); -wriop_set_phy_address (WRIOP1_DPMAC6 , AQ_PHY_ADDR2); -wriop_set_phy_address (WRIOP1_DPMAC7 , AQ_PHY_ADDR3); -wriop_set_phy_address (WRIOP1_DPMAC8 , AQ_PHY_ADDR4); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); + wriop_set_phy_address(WRIOP1_DPMAC3, 0,
CORTINA_PHY_ADDR3);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC4, 0,
CORTINA_PHY_ADDR4);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC5, 0,
AQ_PHY_ADDR1);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC6, 0,
AQ_PHY_ADDR2);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC7, 0,
AQ_PHY_ADDR3);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC8, 0,
AQ_PHY_ADDR4);board/freescale/ls2080ardb/eth_ls2080rdb.c +0
-1break ;case 0x4B : - wriop_set_phy_address(WRIOP1_DPMAC1,
CORTINA_PHY_ADDR1);board/freescale/ls2080ardb/eth_ls2080rdb.c +0
-1- wriop_set_phy_address(WRIOP1_DPMAC2,
CORTINA_PHY_ADDR2);board/freescale/ls2080ardb/eth_ls2080rdb.c +0
-1- wriop_set_phy_address(WRIOP1_DPMAC3,
CORTINA_PHY_ADDR3);board/freescale/ls2080ardb/eth_ls2080rdb.c +0
-1- wriop_set_phy_address(WRIOP1_DPMAC4,
CORTINA_PHY_ADDR4);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC1, 0,
CORTINA_PHY_ADDR1);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC2, 0,
CORTINA_PHY_ADDR2);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC3, 0,
CORTINA_PHY_ADDR3);board/freescale/ls2080ardb/eth_ls2080rdb.c +1
-0+ wriop_set_phy_address(WRIOP1_DPMAC4, 0,
CORTINA_PHY_ADDR4);board/freescale/ls2080ardb/eth_ls2080rdb.c +0
-0break ;default :drivers/net/ldpaa_eth/ldpaa_eth.c +19
-12@@ -23,26 +23,40 @@ static int init_phy(struct eth_device *dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;struct phy_device *phydev =NULL ;struct mii_dev *bus; -int ret; +int phy_addr, phy_num; +int ret =0 ; bus =wriop_get_mdio (priv->dpmac_id);if (bus ==NULL )return 0 ; - phydev =phy_connect (bus,wriop_get_phy_address (priv- >dpmac_id), - dev,wriop_get_enet_if (priv->dpmac_id)); -if (!phydev) { -printf ("Failed to connect\n" ); -return -1 ; - } - -wriop_set_phy_dev (priv->dpmac_id, phydev); +for (phy_num =0 ; phy_num <WRIOP_MAX_PHY_NUM ; phy_num++) { + phy_addr =wriop_get_phy_address (priv->dpmac_id, phy_num); +if (phy_addr <0 ) +continue ; - ret =phy_config (phydev); + phydev =phy_connect (bus, phy_addr, dev, +wriop_get_enet_if (priv->dpmac_id)); +if (!phydev) { +printf ("Failed to connect\n" ); + ret = -ENODEV ; +break ; + } +wriop_set_phy_dev (priv->dpmac_id, phy_num, phydev); + ret =phy_config (phydev); +if (ret) +break ; + }if (ret) { -free (phydev); -wriop_set_phy_dev (priv->dpmac_id,NULL ); + for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM;phy_num++) {
drivers/net/ldpaa_eth/ldpaa_eth.c +1
-0+ phydev = wriop_get_phy_dev(priv->dpmac_id,
phy_num);drivers/net/ldpaa_eth/ldpaa_eth.c +5
-0+if (!phydev) +continue ; + +free (phydev); + wriop_set_phy_dev(priv->dpmac_id, phy_num,NULL);
drivers/net/ldpaa_eth/ldpaa_eth.c +12
-4+ } }return ret;@@ -390,10 +404,10 @@ static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, {struct phy_device *phydev =NULL ;phy_interface_t enet_if; +int phy_num, phys_detected;int err; -/* let's start off with maximum capabilities -*/ +/* let's start off with maximum capabilities */ enet_if =wriop_get_enet_if (priv->dpmac_id);switch (enet_if) {case PHY_INTERFACE_MODE_XGMII :@@ -405,15 +419,22 @@ static int ldpaa_get_dpmac_state(struct ldpaa_eth_priv *priv, } state->up =1 ; + phys_detected =0 ;#ifdef CONFIG_PHYLIB state->options |=DPMAC_LINK_OPT_AUTONEG ; - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) { +/* start the phy devices one by one and update the dpmac state */ +for (phy_num =0 ; phy_num <WRIOP_MAX_PHY_NUM ; phy_num++) { + phydev =wriop_get_phy_dev (priv->dpmac_id, phy_num); +if (!phydev) +continue ; + + phys_detected++; err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , phydev->dev- >name); state->up =0 ; +break ;drivers/net/ldpaa_eth/ldpaa_eth.c +0
-0}if (phydev->link) { state->rate = min(state->rate, (uint32_t)phydev-Quoted 1 line
speed); @@ -422,11 +443,13 @@ static int
ldpaa_get_dpmac_state(struct
ldpaa_eth_priv*priv,drivers/net/ldpaa_eth/ldpaa_eth.c +0
-0if (!phydev->autoneg) state->options &=~DPMAC_LINK_OPT_AUTONEG;
drivers/net/ldpaa_eth/ldpaa_eth.c +4
-1} else { +/* break out of loop even if one phy is down */ state->up =0 ; +break ; } }#endif -if (!phydev) +if (!phys_detected) state->options &= ~DPMAC_LINK_OPT_AUTONEG ;if (!state->up) {@@ -568,6 +591,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev- >priv;int err =0 ;struct phy_device *phydev =NULL ; +int phy_num;drivers/net/ldpaa_eth/ldpaa_eth.c +0
-0if ((net_dev->state ==ETH_STATE_PASSIVE ) || (net_dev->state == ETH_STATE_INIT)) @@ -600,9 +624,11 @@static void
ldpaa_eth_stop(struct eth_device *net_dev)drivers/net/ldpaa_eth/ldpaa_eth.c +1
-3printf ("dpni_disable() failed\n" );#ifdef CONFIG_PHYLIB - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) -phy_shutdown (phydev); + for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM;phy_num++) {
drivers/net/ldpaa_eth/ldpaa_eth.c +4
-0+ phydev =wriop_get_phy_dev (priv->dpmac_id, phy_num); +if (phydev) + phy_shutdown(phydev); + }#endif /* Free DPBP handle and reset. */ drivers/net/ldpaa_eth/ldpaa_wriop.c +0
-0@@ -22,11 +22,10 @@ __weak phy_interface_t wriop_dpmac_enet_if(int
dpmac_id, intlane_prtc) voidwriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl){drivers/net/ldpaa_eth/ldpaa_wriop.c +3
-2phy_interface_t enet_if; +int phy_num; dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; - dpmac_info[dpmac_id].phy_addr =-1 ; - dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if = wriop_dpmac_enet_if(dpmac_id, lane_prtcl); @@ -35,15 +34,23 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].enet_if = enet_if; } + for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM;phy_num++) {
drivers/net/ldpaa_eth/ldpaa_wriop.c +6
-2+ dpmac_info[dpmac_id].phydev[phy_num] =NULL ; + dpmac_info[dpmac_id].phy_addr[phy_num] =-1 ; + } }void wriop_init_dpmac_enet_if (int dpmac_id,phy_interface_t enet_if) { +int phy_num; + dpmac_info[dpmac_id].enabled =1 ; dpmac_info[dpmac_id].id = dpmac_id; - dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; - dpmac_info[dpmac_id].phydev =NULL ; + for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM;phy_num++) {
drivers/net/ldpaa_eth/ldpaa_wriop.c +31
-19+ dpmac_info[dpmac_id].phydev[phy_num] =NULL ; + dpmac_info[dpmac_id].phy_addr[phy_num] =-1 ; + } }@@ -60,45 +67,45 @@ static int wriop_dpmac_to_index(int dpmac_id)return -1 ; } -void wriop_disable_dpmac (int dpmac_id) +int wriop_disable_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; dpmac_info[i].enabled =0 ;wriop_dpmac_disable (dpmac_id); } -void wriop_enable_dpmac (int dpmac_id) +int wriop_enable_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; dpmac_info[i].enabled =1 ;wriop_dpmac_enable (dpmac_id); } -u8 wriop_is_enabled_dpmac (int dpmac_id) +int wriop_is_enabled_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return -1 ; +return -ENODEV ;return dpmac_info[i].enabled; } -void wriop_set_mdio (int dpmac_id,struct mii_dev *bus) +int wriop_set_mdio (int dpmac_id,struct mii_dev *bus) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; dpmac_info[i].bus = bus; }@@ -113,44 +120,52 @@ struct mii_dev *wriop_get_mdio(int dpmac_id)return dpmac_info[i].bus; } -void wriop_set_phy_address (int dpmac_id,int address) +int wriop_set_phy_address (int dpmac_id,int phy_num,int address) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; - dpmac_info[i].phy_addr = address; + dpmac_info[i].phy_addr[phy_num] = address; } -int wriop_get_phy_address (int dpmac_id) +int wriop_get_phy_address (int dpmac_id,int phy_num) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return -1 ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; -return dpmac_info[i].phy_addr; +return dpmac_info[i].phy_addr[phy_num]; } -void wriop_set_phy_dev (int dpmac_id,struct phy_device *phydev) +int wriop_set_phy_dev (int dpmac_id,int phy_num,struct phy_device +*phydev) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; - dpmac_info[i].phydev = phydev; + dpmac_info[i].phydev[phy_num] = phydev; } -struct phy_device *wriop_get_phy_dev (int dpmac_id) +struct phy_device *wriop_get_phy_dev (int dpmac_id,int phy_num) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 )return NULL ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return NULL ; -return dpmac_info[i].phydev; +return dpmac_info[i].phydev[phy_num]; } phy_interface_t wriop_get_enet_if(int dpmac_id) diff --git a/include/fsl-
mc/ldpaa_wriop.hb/include/fsl-mc/ldpaa_wriop.hindex8971c6c55b..b55c39cbb2100644include/fsl-mc/ldpaa_wriop.h +7
-10@@ -6,7 +6,11 @@#ifndef __LDPAA_WRIOP_H#define __LDPAA_WRIOP_H -#include <phy.h> +#include <phy.h> + +#define DEFAULT_WRIOP_MDIO1_NAME "FSL_MDIO0" +#define DEFAULT_WRIOP_MDIO2_NAME "FSL_MDIO1" +#define WRIOP_MAX_PHY_NUM 2enum wriop_port { WRIOP1_DPMAC1 = 1,@@ -40,33 +44,30 @@ struct wriop_dpmac_info {u8 enabled;u8 id;u8 board_mux; -int phy_addr; +int phy_addr[WRIOP_MAX_PHY_NUM ];phy_interface_t enet_if; -struct phy_device *phydev; +struct phy_device *phydev[WRIOP_MAX_PHY_NUM ];struct mii_dev *bus; };extern struct wriop_dpmac_info dpmac_info[NUM_WRIOP_PORTS ]; -#define DEFAULT_WRIOP_MDIO1_NAME "FSL_MDIO0" -#define DEFAULT_WRIOP_MDIO2_NAME "FSL_MDIO1" - -void wriop_init_dpmac (int ,int ,int ); -void wriop_disable_dpmac (int ); -void wriop_enable_dpmac (int ); -u8 wriop_is_enabled_dpmac(int dpmac_id); -void wriop_set_mdio(int,struct
mii_dev*); -structmii_dev*wriop_get_mdio(int); -voidwriop_set_phy_address(int, int); -intwriop_get_phy_address(int); -voidwriop_set_phy_dev(int, struct phy_device *); -structphy_device*wriop_get_phy_dev(int); -phy_interface_twriop_get_enet_if(int);include/fsl-mc/ldpaa_wriop.h +6
-0+void wriop_init_dpmac (int sd,int dpmac_id,int lane_prtcl);void +wriop_init_dpmac_enet_if (int dpmac_id,phy_interface_t enet_if);int +wriop_disable_dpmac (int dpmac_id);int wriop_enable_dpmac (int +dpmac_id);int wriop_is_enabled_dpmac (int dpmac_id);int +wriop_set_mdio (int dpmac_id,struct mii_dev *bus);struct mii_dev +*wriop_get_mdio(int dpmac_id); int wriop_set_phy_address(int
dpmac_id,include/fsl-mc/ldpaa_wriop.h +3
-0+int phy_num, int address); int wriop_get_phy_address(int dpmac_id, int +phy_num);int wriop_set_phy_dev (int dpmac_id,int phy_num,struct +phy_device *phydev); struct phy_device *wriop_get_phy_dev(int
dpmac_id,include/fsl-mc/ldpaa_wriop.h +1
-3+int phy_num); phy_interface_t wriop_get_enet_if(int dpmac_id); -void wriop_dpmac_disable (int ); -void wriop_dpmac_enable (int ); -phy_interface_t wriop_dpmac_enet_if (int ,int ); -void
wriop_init_dpmac_qsgmii(int, int);include/fsl-mc/ldpaa_wriop.h +3
-2+void wriop_dpmac_disable (int dpmac_id);void wriop_dpmac_enable (int +dpmac_id);phy_interface_t wriop_dpmac_enet_if (int dpmac_id,int +lane_prtcl);void wriop_init_dpmac_qsgmii (int sd,int lane_prtcl);void wriop_init_rgmii (void ); -void wriop_init_dpmac_enet_if (int ,phy_interface_t );#endif /* __LDPAA_WRIOP_H */ --2.17.1
PATCH v2 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalQuoted 8 lines · Pankaj Bansal
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
Quoted 5 lines
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Signed-off-by Pankaj Bansal <[email protected]>
PATCH v2 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalQuoted 34 lines · Pankaj Bansal
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Signed-off-by Pankaj Bansal <[email protected]>---
Notes:
V2:
- use single-line comment format.
- useWRIOP_MAX_PHY_NUM.
- use-ENODEVor-EINVALinstead of -1 wherever appropriate
- include the variable names in the headers too.
- Change the return type of some functions from void to int so that a meaningful error message can be returnedboard/freescale/ls1088a/eth_ls1088aqds.c | 18 +++--- board/freescale/ls1088a/eth_ls1088ardb.c | 21 ++++--- board/freescale/ls2080aqds/eth.c | 26 ++++---- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 66 ++++++++++++++------ drivers/net/ldpaa_eth/ldpaa_wriop.c | 61 +++++++++++------- include/fsl-mc/ldpaa_wriop.h | 45 ++++++------- 7 files changed, 152 insertions(+), 109 deletions(-)
[ ... ]
Quoted 48 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +11
-5@@ -22,11 +22,10 @@ __weak phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtc)void wriop_init_dpmac (int sd,int dpmac_id,int lane_prtcl) {phy_interface_t enet_if; +int phy_num; dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; - dpmac_info[dpmac_id].phy_addr =-1 ; - dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl);@@ -35,15 +34,23 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].enet_if = enet_if; } +for (phy_num =0 ; phy_num <WRIOP_MAX_PHY_NUM ; phy_num++) { + dpmac_info[dpmac_id].phydev[phy_num] =NULL ; + dpmac_info[dpmac_id].phy_addr[phy_num] =-1 ; + } }void wriop_init_dpmac_enet_if (int dpmac_id,phy_interface_t enet_if) { +int phy_num; + dpmac_info[dpmac_id].enabled =1 ; dpmac_info[dpmac_id].id = dpmac_id; - dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; - dpmac_info[dpmac_id].phydev =NULL ; +for (phy_num =0 ; phy_num <WRIOP_MAX_PHY_NUM ; phy_num++) { + dpmac_info[dpmac_id].phydev[phy_num] =NULL ; + dpmac_info[dpmac_id].phy_addr[phy_num] =-1 ; + } }@@ -60,45 +67,45 @@ static int wriop_dpmac_to_index(int dpmac_id)return -1 ; } -void wriop_disable_dpmac (int dpmac_id)
drivers/net/ldpaa_eth/ldpaa_wriop.c static int wriop_dpmac_to_index(int dpmac_id) · line 78
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +2
-1+int wriop_disable_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; dpmac_info[i].enabled =0 ;wriop_dpmac_disable (dpmac_id);
These functions all warn since you don't return 0 at the end of them. Now I'll have to back this series out of the release and wait for an update. Patches need to build without warnings.
Quoted 103 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +25
-17} -void wriop_enable_dpmac (int dpmac_id) +int wriop_enable_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; dpmac_info[i].enabled =1 ;wriop_dpmac_enable (dpmac_id); } -u8 wriop_is_enabled_dpmac (int dpmac_id) +int wriop_is_enabled_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return -1 ; +return -ENODEV ;return dpmac_info[i].enabled; } -void wriop_set_mdio (int dpmac_id,struct mii_dev *bus) +int wriop_set_mdio (int dpmac_id,struct mii_dev *bus) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; dpmac_info[i].bus = bus; }@@ -113,44 +120,52 @@ struct mii_dev *wriop_get_mdio(int dpmac_id)return dpmac_info[i].bus; } -void wriop_set_phy_address (int dpmac_id,int address) +int wriop_set_phy_address (int dpmac_id,int phy_num,int address) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; - dpmac_info[i].phy_addr = address; + dpmac_info[i].phy_addr[phy_num] = address; } -int wriop_get_phy_address (int dpmac_id) +int wriop_get_phy_address (int dpmac_id,int phy_num) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return -1 ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; -return dpmac_info[i].phy_addr; +return dpmac_info[i].phy_addr[phy_num]; } -void wriop_set_phy_dev (int dpmac_id,struct phy_device *phydev) +int wriop_set_phy_dev (int dpmac_id,int phy_num,struct phy_device *phydev) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; - dpmac_info[i].phydev = phydev; + dpmac_info[i].phydev[phy_num] = phydev; } -struct phy_device *wriop_get_phy_dev (int dpmac_id) +struct phy_device *wriop_get_phy_dev (int dpmac_id,int phy_num) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 )return NULL ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return NULL ; -return dpmac_info[i].phydev; +return dpmac_info[i].phydev[phy_num]; }phy_interface_t wriop_get_enet_if (int dpmac_id)
[ ... ]
PATCH v2 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
Quoted 111 lines
-----Original Message-----
From: Joe Hershberger [mailto:joe.hershberger at ni.com]
Sent: Wednesday, October 10, 2018 3:02 AM
To: Pankaj Bansal <[email protected]>
Cc: u-boot <[email protected]>; Joseph Hershberger <[email protected]>; Priyanka Jain <[email protected]>; Varun Sethi <[email protected]>
Subject: Re: [U-Boot] [PATCH v2 6/6] driver: net: fsl-mc: Add support of multiple phys for dpmacQuoted 34 lines · Pankaj Bansal
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Signed-off-by Pankaj Bansal <[email protected]>---
Notes:
V2:
- use single-line comment format.
- useWRIOP_MAX_PHY_NUM.
- use-ENODEVor-EINVALinstead of -1 wherever appropriate
- include the variable names in the headers too.
- Change the return type of some functions from void to int so that a meaningful error message can be returnedboard/freescale/ls1088a/eth_ls1088aqds.c | 18 +++--- board/freescale/ls1088a/eth_ls1088ardb.c | 21 ++++--- board/freescale/ls2080aqds/eth.c | 26 ++++---- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 66 ++++++++++++++------ drivers/net/ldpaa_eth/ldpaa_wriop.c | 61 +++++++++++------- include/fsl-mc/ldpaa_wriop.h | 45 ++++++------- 7 files changed, 152 insertions(+), 109 deletions(-)[ ... ]
drivers/net/ldpaa_eth/ldpaa_wriop.c __weak phy_interface_t
Quoted 6 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +0
-0@@ -22,11 +22,10 @@ __weak phy_interface_twriop_dpmac_enet_if(int
Quoted 7 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +1
-0dpmac_id, int lane_prtc) void wriop_init_dpmac(int sd, int dpmac_id,int lane_prtcl) {phy_interface_t enet_if; +int phy_num; dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ;drivers/net/ldpaa_eth/ldpaa_wriop.c __weak phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtc)
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +2
-2- dpmac_info[dpmac_id].phy_addr =-1 ; - dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if = wriop_dpmac_enet_if(dpmac_id, lane_prtcl); @@ -35,15 +34,23 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].enet_if = enet_if; } + for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM;phy_num++) {
Quoted 7 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +3
-0+ dpmac_info[dpmac_id].phydev[phy_num] =NULL ; + dpmac_info[dpmac_id].phy_addr[phy_num] =-1 ; + } }void wriop_init_dpmac_enet_if (int dpmac_id,phy_interface_t enet_if){
drivers/net/ldpaa_eth/ldpaa_wriop.c void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl)
Quoted 8 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +3
-2+int phy_num; + dpmac_info[dpmac_id].enabled =1 ; dpmac_info[dpmac_id].id = dpmac_id; - dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; - dpmac_info[dpmac_id].phydev =NULL ; + for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM;phy_num++) {
Quoted 19 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +5
-2+ dpmac_info[dpmac_id].phydev[phy_num] =NULL ; + dpmac_info[dpmac_id].phy_addr[phy_num] =-1 ; + } }@@ -60,45 +67,45 @@ static int wriop_dpmac_to_index(int dpmac_id)return -1 ; } -void wriop_disable_dpmac (int dpmac_id) +int wriop_disable_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ;
Quoted 6 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c static int wriop_dpmac_to_index(int dpmac_id) · line 78
Quoted 2 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +0
-0dpmac_info[i].enabled =0 ;wriop_dpmac_disable (dpmac_id);These functions all warn since you don't return 0 at the end of them. Now I'll have to back this series out of the release and wait for an update. Patches need to build without warnings.
My apologies for this oversight on my part.
I have sent V3 of these patches with the return 0 at the end of all functions, whose return type changed. I have also tested these patches for build warning after compiling for "ls2080aqds"
Quoted 108 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c struct mii_dev *wriop_get_mdio(int
Quoted 41 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +6
-6} -void wriop_enable_dpmac (int dpmac_id) +int wriop_enable_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; dpmac_info[i].enabled =1 ;wriop_dpmac_enable (dpmac_id); } -u8 wriop_is_enabled_dpmac (int dpmac_id) +int wriop_is_enabled_dpmac (int dpmac_id) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return -1 ; +return -ENODEV ;return dpmac_info[i].enabled; } -void wriop_set_mdio (int dpmac_id,struct mii_dev *bus) +int wriop_set_mdio (int dpmac_id,struct mii_dev *bus) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; dpmac_info[i].bus = bus; }@@ -113,44 +120,52 @@ struct mii_dev *wriop_get_mdio(int
dpmac_id)Quoted 64 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +20
-11return dpmac_info[i].bus; } -void wriop_set_phy_address (int dpmac_id,int address) +int wriop_set_phy_address (int dpmac_id,int phy_num,int address) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; - dpmac_info[i].phy_addr = address; + dpmac_info[i].phy_addr[phy_num] = address; } -int wriop_get_phy_address (int dpmac_id) +int wriop_get_phy_address (int dpmac_id,int phy_num) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return -1 ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; -return dpmac_info[i].phy_addr; +return dpmac_info[i].phy_addr[phy_num]; } -void wriop_set_phy_dev (int dpmac_id,struct phy_device *phydev) +int wriop_set_phy_dev (int dpmac_id,int phy_num,struct phy_device +*phydev) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 ) -return ; +return -ENODEV ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return -EINVAL ; - dpmac_info[i].phydev = phydev; + dpmac_info[i].phydev[phy_num] = phydev; } -struct phy_device *wriop_get_phy_dev (int dpmac_id) +struct phy_device *wriop_get_phy_dev (int dpmac_id,int phy_num) {int i =wriop_dpmac_to_index (dpmac_id);if (i ==-1 )return NULL ; +if (phy_num <0 || phy_num >=WRIOP_MAX_PHY_NUM ) +return NULL ; -return dpmac_info[i].phydev; +return dpmac_info[i].phydev[phy_num]; }phy_interface_t wriop_get_enet_if (int dpmac_id)[ ... ]
v3 cover driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalThis patch set adds support of multiple phys for one dpmac
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. To handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Pankaj Bansal (6):
driver: net: fsl-mc: modify the label name
driver: net: fsl-mc: remove unused strcture elements
driver: net: fsl-mc: fix error handing in init_phy
driver: net: fsl-mc: Modify the dpmac link detection method
driver: net: fsl-mc: initialize dpmac irrespective of phy
driver: net: fsl-mc: Add support of multiple phys for dpmac
board/freescale/ls1088a/eth_ls1088aqds.c | 18 +-- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +-- board/freescale/ls2080aqds/eth.c | 26 ++-- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +-- drivers/net/fsl-mc/mc.c | 6 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 171 +++++++++++++-------- drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 71 ++++++--- include/fsl-mc/ldpaa_wriop.h | 46 +++--- 9 files changed, 223 insertions(+), 161 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/6 driver: net: fsl-mc: modify the label name
The goto label name is misspelled it should be DPMAC not DPAMC
---
Notes:
V3:
- No change
V2:
- No change
drivers/net/ldpaa_eth/ldpaa_eth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +4 -4
@@ -413,7 +413,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err) {printf ("%s: Could not initialize\n" , priv->phydev->dev->name); - goto err_dpamc_bind; + goto err_dpmac_bind; } }#else
@@ -441,13 +441,13 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (!priv->phydev->link) {printf ("%s: No link.\n" , priv->phydev->dev->name); err =-1 ; - goto err_dpamc_bind; + goto err_dpmac_bind; }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);if (err) - goto err_dpamc_bind; + goto err_dpmac_bind;/* DPNI initialization */ err =ldpaa_dpni_setup (priv);
@@ -540,7 +540,7 @@ err_dpni_bind: err_dpbp_setup:dpni_close (dflt_mc_io,MC_CMD_NO_FLAGS , dflt_dpni->dpni_handle); err_dpni_setup: -err_dpamc_bind: +err_dpmac_bind:dpmac_close (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle); dpmac_destroy(dflt_mc_io, dflt_dprc_handle,
Signature · 1 line
2.17.1
PATCH v3 2/6 driver: net: fsl-mc: remove unused strcture elements
In reply to Pankaj BansalThe phydev structure is present in both ldpaa_eth_priv and wriop_dpmac_info. the phydev in wriop_dpmac_info is not being used
As the phydev is created based on phy_addr and bus members of wriop_dpmac_info, it is appropriate to keep phydev in wriop_dpmac_info.
Also phy_regs is not being used, therefore remove it
---
Notes:
V3:
- No change
V2:
- change (phydev && bus != NULL) to (phydev && bus)
- after free phydev just pass NULL into wriop_set_phy_dev()
drivers/net/ldpaa_eth/ldpaa_eth.c | 56 +++++++++++++++------------ drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 2 + include/fsl-mc/ldpaa_wriop.h | 1 - 4 files changed, 33 insertions(+), 27 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +31 -25
@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)return -1 ; } - priv->phydev = phydev; +wriop_set_phy_dev (priv->dpmac_id, phydev);return phy_config (phydev); }
@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct mii_dev *bus;phy_interface_t enet_if;struct dpni_queue d_queue; +struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;
@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_dpmac_setup;#ifdef CONFIG_PHYLIB -if (priv->phydev) { - err =phy_startup (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , - priv->phydev->dev->name); + phydev->dev->name); goto err_dpmac_bind; } }#else - priv->phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_1000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_1000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ;#endif bus =wriop_get_mdio (priv->dpmac_id); enet_if =wriop_get_enet_if (priv->dpmac_id);if ((bus ==NULL ) && (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - priv->phydev = (struct phy_device *) + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_10000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_10000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ; } -if (!priv->phydev->link) { -printf ("%s: No link.\n" , priv->phydev->dev->name); +if (!phydev->link) { +printf ("%s: No link.\n" , phydev->dev->name); err =-1 ; goto err_dpmac_bind; }
@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = priv->phydev->speed; + dpmac_link_state.rate = phydev->speed; -if (priv->phydev->autoneg ==AUTONEG_DISABLE ) +if (phydev->autoneg ==AUTONEG_DISABLE ) dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ;else dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; -if (priv->phydev->duplex ==DUPLEX_HALF ) +if (phydev->duplex ==DUPLEX_HALF ) dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - dpmac_link_state.up = priv->phydev->link; + dpmac_link_state.up = phydev->link; err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);
@@ -530,7 +534,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return priv->phydev->link; +return phydev->link; err_qdid: err_get_queue:
@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id);#endif +struct phy_device *phydev =NULL ;if ((net_dev->state ==ETH_STATE_PASSIVE ) || (net_dev->state ==ETH_STATE_INIT ))
@@ -588,11 +593,12 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)printf ("dpni_disable() failed\n" );#ifdef CONFIG_PHYLIB -if (priv->phydev && bus !=NULL ) -phy_shutdown (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev && bus) +phy_shutdown (phydev);else { -free (priv->phydev); - priv->phydev =NULL ; +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); }#endif
drivers/net/ldpaa_eth/ldpaa_eth.h +0 -1
@@ -127,7 +127,6 @@ struct ldpaa_eth_priv {uint16_t tx_flow_id;enum ldpaa_eth_type type;/* 1G or 10G ethernet */ -struct phy_device *phydev; };struct dprc_endpoint dpmac_endpoint;
drivers/net/ldpaa_eth/ldpaa_wriop.c +2 -0
@@ -26,6 +26,7 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; dpmac_info[dpmac_id].phy_addr =-1 ; + dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl);
@@ -42,6 +43,7 @@ void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t enet_if) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; + dpmac_info[dpmac_id].phydev =NULL ; }
include/fsl-mc/ldpaa_wriop.h +0 -1
@@ -41,7 +41,6 @@ struct wriop_dpmac_info {u8 id;u8 board_mux;int phy_addr; -void *phy_regs;phy_interface_t enet_if;struct phy_device *phydev;struct mii_dev *bus;
Signature · 1 line
2.17.1
PATCH v3 2/6 driver: net: fsl-mc: remove unused strcture elements
Quoted 9 lines · Pankaj Bansal
The phydev structure is present in both
ldpaa_eth_privandwriop_dpmac_info. the phydev inwriop_dpmac_infois not being usedAs the phydev is created based on
phy_addrand bus members ofwriop_dpmac_info, it is appropriate to keep phydev inwriop_dpmac_info.Also
phy_regsis not being used, therefore remove it
Quoted 7 lines
Signed-off-by Pankaj Bansal <[email protected]>Acked-by Joe Hershberger <[email protected]>---
Notes:
V3:
- No change
Please be sure you are running scripts/checkpatch.pl on your patches. v2 had a number of issues I had to fix up. I'm pretty sure this was one of them.
You would do yourself a favor to use tools/patman/patman.
Quoted 195 lines
V2:
- change (phydev && bus != NULL) to (phydev && bus)
- after free phydev just pass NULL intowriop_set_phy_dev()drivers/net/ldpaa_eth/ldpaa_eth.c | 56 +++++++++++++++------------ drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 2 + include/fsl-mc/ldpaa_wriop.h | 1 - 4 files changed, 33 insertions(+), 27 deletions(-)drivers/net/ldpaa_eth/ldpaa_eth.c +31
-25@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)return -1 ; } - priv->phydev = phydev; +wriop_set_phy_dev (priv->dpmac_id, phydev);return phy_config (phydev); }@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct mii_dev *bus;phy_interface_t enet_if;struct dpni_queue d_queue; +struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_dpmac_setup;#ifdef CONFIG_PHYLIB -if (priv->phydev) { - err =phy_startup (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , - priv->phydev->dev->name); + phydev->dev->name); goto err_dpmac_bind; } }#else - priv->phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_1000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_1000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ;#endif bus =wriop_get_mdio (priv->dpmac_id); enet_if =wriop_get_enet_if (priv->dpmac_id);if ((bus ==NULL ) && (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - priv->phydev = (struct phy_device *) + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_10000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_10000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ; } -if (!priv->phydev->link) { -printf ("%s: No link.\n" , priv->phydev->dev->name); +if (!phydev->link) { +printf ("%s: No link.\n" , phydev->dev->name); err =-1 ; goto err_dpmac_bind; }@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = priv->phydev->speed; + dpmac_link_state.rate = phydev->speed; -if (priv->phydev->autoneg ==AUTONEG_DISABLE ) +if (phydev->autoneg ==AUTONEG_DISABLE ) dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ;else dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; -if (priv->phydev->duplex ==DUPLEX_HALF ) +if (phydev->duplex ==DUPLEX_HALF ) dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - dpmac_link_state.up = priv->phydev->link; + dpmac_link_state.up = phydev->link; err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);@@ -530,7 +534,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return priv->phydev->link; +return phydev->link; err_qdid: err_get_queue:@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id);#endif +struct phy_device *phydev =NULL ;if ((net_dev->state ==ETH_STATE_PASSIVE ) || (net_dev->state ==ETH_STATE_INIT ))@@ -588,11 +593,12 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)printf ("dpni_disable() failed\n" );#ifdef CONFIG_PHYLIB -if (priv->phydev && bus !=NULL ) -phy_shutdown (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev && bus) +phy_shutdown (phydev);else { -free (priv->phydev); - priv->phydev =NULL ; +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); }#endif drivers/net/ldpaa_eth/ldpaa_eth.h +0
-1@@ -127,7 +127,6 @@ struct ldpaa_eth_priv {uint16_t tx_flow_id;enum ldpaa_eth_type type;/* 1G or 10G ethernet */ -struct phy_device *phydev; };struct dprc_endpoint dpmac_endpoint;drivers/net/ldpaa_eth/ldpaa_wriop.c +2
-0@@ -26,6 +26,7 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; dpmac_info[dpmac_id].phy_addr =-1 ; + dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl);@@ -42,6 +43,7 @@ void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t enet_if) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; + dpmac_info[dpmac_id].phydev =NULL ; }include/fsl-mc/ldpaa_wriop.h +0
-2@@ -41,7 +41,6 @@ struct wriop_dpmac_info {u8 id;u8 board_mux;int phy_addr; -void *phy_regs;phy_interface_t enet_if;struct phy_device *phydev;struct mii_dev *bus; --2.17.1
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v3 2/6 driver: net: fsl-mc: remove unused strcture elements
Hi Joe,
Quoted 25 lines
-----Original Message-----
From: Joe Hershberger [mailto:joe.hershberger at ni.com]
Sent: Wednesday, October 10, 2018 9:29 AM
To: Pankaj Bansal <[email protected]>
Cc: Joseph Hershberger <[email protected]>; u-boot <u- boot at lists.denx.de>
Subject: Re: [U-Boot] [PATCH v3 2/6] driver: net: fsl-mc: remove unused strcture elementsQuoted 6 lines · Pankaj Bansal
The phydev structure is present in both
ldpaa_eth_privandwriop_dpmac_info. the phydev inwriop_dpmac_infois not being usedAs the phydev is created based on
phy_addrand bus members ofwriop_dpmac_info, it is appropriate to keep phydev in
wriop_dpmac_info.Quoted 7 lines
Also
phy_regsis not being used, therefore remove itSigned-off-by Pankaj Bansal <[email protected]>Acked-by Joe Hershberger <[email protected]>---
Quoted 7 lines
Quoted 3 lines
Notes:
V3:
- No changePlease be sure you are running
scripts/checkpatch.plon your patches. v2 had a number of issues I had to fix up. I'm pretty sure this was one of them.
I had run checkpatch script on all the versions of patches I sent.
I use this command "./scripts/checkpatch.pl 0001-something.patch"
This "no return at the end of function" issue was not reported by checkpatch script.
Can you please tell me which issues in V2 are you referring to?
Because when I ran checkpatch.pl, it gave me no errors or warnings but 7 checks regarding alignment in board/freescale/ls2080aqds/eth.c. I did not do any changes for that because that code was not part of my patch and I think that was done
so that line doesn't exceed 80 characters.
Quoted 2 lines
You would do yourself a favor to use
tools/patman/patman.
This is a good advice. I will use patman from now onwards to prepare and send patches.
Quoted 216 lines
drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_eth_open(struct eth_device
Quoted 26 lines
V2:
- change (phydev && bus != NULL) to (phydev && bus)
- after free phydev just pass NULL intowriop_set_phy_dev()drivers/net/ldpaa_eth/ldpaa_eth.c | 56 +++++++++++++++------------ drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 2 + include/fsl-mc/ldpaa_wriop.h | 1 - 4 files changed, 33 insertions(+), 27 deletions(-)drivers/net/ldpaa_eth/ldpaa_eth.c +1
-1@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)return -1 ; } - priv->phydev = phydev; +wriop_set_phy_dev (priv->dpmac_id, phydev);return phy_config (phydev); }@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device
*net_dev,bd_t*bd)drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_eth_open(struct eth_device
Quoted 8 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +1
-0struct mii_dev *bus;phy_interface_t enet_if;struct dpni_queue d_queue; +struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device
*net_dev,bd_t*bd)Quoted 7 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-2goto err_dpmac_setup;#ifdef CONFIG_PHYLIB -if (priv->phydev) { - err =phy_startup (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) {drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-2+ err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , - priv->phydev->dev->name); + phydev->dev->name); goto err_dpmac_bind; } }#else - priv->phydev = (struct phy_device *)malloc(sizeof(struct
phy_device));drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_eth_open(struct eth_device
Quoted 40 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +14
-11-memset (priv->phydev,0 ,sizeof (struct phy_device )); + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_1000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_1000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ;#endif bus =wriop_get_mdio (priv->dpmac_id); enet_if =wriop_get_enet_if (priv->dpmac_id);if ((bus ==NULL ) && (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - priv->phydev = (struct phy_device *) + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_10000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_10000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ; } -if (!priv->phydev->link) { -printf ("%s: No link.\n" , priv->phydev->dev->name); +if (!phydev->link) { +printf ("%s: No link.\n" , phydev->dev->name); err =-1 ; goto err_dpmac_bind; }@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device
*net_dev,bd_t*bd)Quoted 22 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +4
-4return err; } - dpmac_link_state.rate = priv->phydev->speed; + dpmac_link_state.rate = phydev->speed; -if (priv->phydev->autoneg ==AUTONEG_DISABLE ) +if (phydev->autoneg ==AUTONEG_DISABLE ) dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ;else dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; -if (priv->phydev->duplex ==DUPLEX_HALF ) +if (phydev->duplex ==DUPLEX_HALF ) dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - dpmac_link_state.up = priv->phydev->link; + dpmac_link_state.up = phydev->link; err = dpmac_set_link_state(dflt_mc_io, MC_CMD_NO_FLAGS,priv->dpmac_handle,Quoted 1 line
&dpmac_link_state); @@ -530,7 +534,7 @@ static int
ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)drivers/net/ldpaa_eth/ldpaa_wriop.c void wriop_init_dpmac(int sd, int dpmac_id, int
Quoted 51 lines
goto err_qdid; }drivers/net/ldpaa_eth/ldpaa_eth.c +2
-1-return priv->phydev->link; +return phydev->link; err_qdid: err_get_queue:@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) #ifdef CONFIG_PHYLIBstruct mii_dev *bus =wriop_get_mdio (priv->dpmac_id);#endif +struct phy_device *phydev =NULL ; if ((net_dev->state == ETH_STATE_PASSIVE) || (net_dev->state == ETH_STATE_INIT)) @@ -588,11 +593,12 @@static void ldpaa_eth_stop (struct eth_device *net_dev)printf("dpni_disable() failed\n");#ifdef
CONFIG_PHYLIBdrivers/net/ldpaa_eth/ldpaa_eth.c +5
-4-if (priv->phydev && bus !=NULL ) -phy_shutdown (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev && bus) +phy_shutdown (phydev);else { -free (priv->phydev); - priv->phydev =NULL ; +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); }#endif drivers/net/ldpaa_eth/ldpaa_eth.h +0
-1@@ -127,7 +127,6 @@ struct ldpaa_eth_priv {uint16_t tx_flow_id;enum ldpaa_eth_type type;/* 1G or 10G ethernet */ -struct phy_device *phydev; };struct dprc_endpoint dpmac_endpoint;drivers/net/ldpaa_eth/ldpaa_wriop.c +0
-0@@ -26,6 +26,7 @@ void wriop_init_dpmac(int sd, int dpmac_id, int
lane_prtcl)drivers/net/ldpaa_eth/ldpaa_wriop.c void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl)
Quoted 8 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +2
-0dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; dpmac_info[dpmac_id].phy_addr =-1 ; + dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if = wriop_dpmac_enet_if(dpmac_id, lane_prtcl); @@ -42,6 +43,7 @@ void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t
enet_if)Quoted 22 lines
dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].phy_addr = -1; dpmac_info[dpmac_id].enet_if = enet_if;drivers/net/ldpaa_eth/ldpaa_wriop.c +1
-0+ dpmac_info[dpmac_id].phydev =NULL ; }(quoted diff) +0
-0
b/include/fsl-mc/ldpaa_wriop.hindex07e5130264..8971c6c55b100644include/fsl-mc/ldpaa_wriop.h +0
-2@@ -41,7 +41,6 @@ struct wriop_dpmac_info {u8 id;u8 board_mux;int phy_addr; -void *phy_regs;phy_interface_t enet_if;struct phy_device *phydev;struct mii_dev *bus; --2.17.1
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.dehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flis
Quoted 1 line
ts.denx.de%2Flistinfo%2Fu-
boot&data=02%7C01%7Cpankaj.bansal%40nxp.
Quoted 1 line
com%7Cbced1ce32f8e455148d408d62e64c7f5%7C686ea1d3bc2b4c6fa92c
d99c5c301Quoted 1 line
635%7C0%7C0%7C636747407731429023&sdata=4cwaAt8C4V91TNo iNFGcoznoGEn
Quoted 1 line
POsCGDmh9maFv%2FOA%3D&reserved=0
PATCH v3 2/6 driver: net: fsl-mc: remove unused strcture elements
Quoted 36 lines · Pankaj Bansal
Hi Joe,
Quoted 25 lines
-----Original Message-----
From: Joe Hershberger [mailto:joe.hershberger at ni.com]
Sent: Wednesday, October 10, 2018 9:29 AM
To: Pankaj Bansal <[email protected]>
Cc: Joseph Hershberger <[email protected]>; u-boot <u- boot at lists.denx.de>
Subject: Re: [U-Boot] [PATCH v3 2/6] driver: net: fsl-mc: remove unused strcture elementsQuoted 6 lines · Pankaj Bansal
The phydev structure is present in both
ldpaa_eth_privandwriop_dpmac_info. the phydev inwriop_dpmac_infois not being usedAs the phydev is created based on
phy_addrand bus members ofwriop_dpmac_info, it is appropriate to keep phydev in
wriop_dpmac_info.Quoted 7 lines
Also
phy_regsis not being used, therefore remove itSigned-off-by Pankaj Bansal <[email protected]>Acked-by Joe Hershberger <[email protected]>---
Quoted 7 lines
Quoted 3 lines
Notes:
V3:
- No changePlease be sure you are running
scripts/checkpatch.plon your patches. v2 had a number of issues I had to fix up. I'm pretty sure this was one of them.
Quoted 8 lines
I had run checkpatch script on all the versions of patches I sent.
I use this command "./scripts/checkpatch.pl0001-something.patch"
This "no return at the end of function" issue was not reported by checkpatch script.Can you please tell me which issues in V2 are you referring to?
Because when I ran checkpatch.pl, it gave me no errors or warnings but 7 checks regarding alignment inboard/freescale/ls2080aqds/eth.c. I did not do any changes for that because that code was not part of my patch and I think that was done
so that line doesn't exceed 80 characters.
This patch specifically had a complaint "CHECK: braces {} should be used on all arms of this statement" that I fixed up.
This issue doesn't last long, since the code in question is fixed in "driver: net: fsl-mc: Modify the dpmac link detection method", but we prefer not to have patches that have issues. patman will tell you about it.
I've applied v3 and it looks like "Freescale AArch64" is still warning ( https://travis-ci.org/jhershbe/u-boot/jobs/439762814 ) ...
---------
aarch64: + ls2080a_emu+drivers/net/ldpaa_eth/ldpaa_eth.c: In function 'ldpaa_get_dpmac_state':+drivers/net/ldpaa_eth/ldpaa_eth.c:408:6: error: unused variable 'err' [-Werror=unused-variable]
+ int err;
+ ^~~+drivers/net/ldpaa_eth/ldpaa_eth.c:407:6: error: unused variable 'phy_num' [-Werror=unused-variable]
+ int phy_num, phys_detected;
+ ^~~~~~~+drivers/net/ldpaa_eth/ldpaa_eth.c:405:21: error: unused variable 'phydev' [-Werror=unused-variable]
+ struct phy_device *phydev = NULL;
+ ^~~~~~+drivers/net/ldpaa_eth/ldpaa_eth.c: In function 'ldpaa_eth_stop':+drivers/net/ldpaa_eth/ldpaa_eth.c:594:6: error: unused variable 'phy_num' [-Werror=unused-variable]
+ int phy_num;+drivers/net/ldpaa_eth/ldpaa_eth.c:593:21: error: unused variable 'phydev' [-Werror=unused-variable]
+cc1: all warnings being treated as errors
+make[3]: *** [drivers/net/ldpaa_eth/ldpaa_eth.o] Error 1 +make[2]: *** [drivers/net/ldpaa_eth] Error 2
+make[1]: *** [drivers/net] Error 2
+make: *** [sub-make] Error 2
---------
Both "driver: net: fsl-mc: Modify the dpmac link detection method" and "driver: net: fsl-mc: Add support of multiple phys for dpmac" introduce unused variable warnings on ls2080a_emu.
-Joe
Quoted 226 lines
Quoted 3 lines
You would do yourself a favor to use
tools/patman/patman.This is a good advice. I will use patman from now onwards to prepare and send patches.
Quoted 207 lines
drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_eth_open(struct eth_device
Quoted 26 lines
V2:
- change (phydev && bus != NULL) to (phydev && bus)
- after free phydev just pass NULL intowriop_set_phy_dev()drivers/net/ldpaa_eth/ldpaa_eth.c | 56 +++++++++++++++------------ drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 2 + include/fsl-mc/ldpaa_wriop.h | 1 - 4 files changed, 33 insertions(+), 27 deletions(-)drivers/net/ldpaa_eth/ldpaa_eth.c +1
-1@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)return -1 ; } - priv->phydev = phydev; +wriop_set_phy_dev (priv->dpmac_id, phydev);return phy_config (phydev); }@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device
*net_dev,bd_t*bd)drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_eth_open(struct eth_device
Quoted 8 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +1
-0struct mii_dev *bus;phy_interface_t enet_if;struct dpni_queue d_queue; +struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device
*net_dev,bd_t*bd)Quoted 7 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-2goto err_dpmac_setup;#ifdef CONFIG_PHYLIB -if (priv->phydev) { - err =phy_startup (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) {drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)
Quoted 10 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +2
-2+ err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , - priv->phydev->dev->name); + phydev->dev->name); goto err_dpmac_bind; } }#else - priv->phydev = (struct phy_device *)malloc(sizeof(struct
phy_device));drivers/net/ldpaa_eth/ldpaa_eth.c static int ldpaa_eth_open(struct eth_device
Quoted 40 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +14
-11-memset (priv->phydev,0 ,sizeof (struct phy_device )); + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_1000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_1000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ;#endif bus =wriop_get_mdio (priv->dpmac_id); enet_if =wriop_get_enet_if (priv->dpmac_id);if ((bus ==NULL ) && (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - priv->phydev = (struct phy_device *) + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_10000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_10000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ; } -if (!priv->phydev->link) { -printf ("%s: No link.\n" , priv->phydev->dev->name); +if (!phydev->link) { +printf ("%s: No link.\n" , phydev->dev->name); err =-1 ; goto err_dpmac_bind; }@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device
*net_dev,bd_t*bd)Quoted 22 lines
drivers/net/ldpaa_eth/ldpaa_eth.c +4
-4return err; } - dpmac_link_state.rate = priv->phydev->speed; + dpmac_link_state.rate = phydev->speed; -if (priv->phydev->autoneg ==AUTONEG_DISABLE ) +if (phydev->autoneg ==AUTONEG_DISABLE ) dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ;else dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; -if (priv->phydev->duplex ==DUPLEX_HALF ) +if (phydev->duplex ==DUPLEX_HALF ) dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - dpmac_link_state.up = priv->phydev->link; + dpmac_link_state.up = phydev->link; err = dpmac_set_link_state(dflt_mc_io, MC_CMD_NO_FLAGS,priv->dpmac_handle,Quoted 1 line
&dpmac_link_state); @@ -530,7 +534,7 @@ static int
ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)drivers/net/ldpaa_eth/ldpaa_wriop.c void wriop_init_dpmac(int sd, int dpmac_id, int
Quoted 51 lines
goto err_qdid; }drivers/net/ldpaa_eth/ldpaa_eth.c +2
-1-return priv->phydev->link; +return phydev->link; err_qdid: err_get_queue:@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) #ifdef CONFIG_PHYLIBstruct mii_dev *bus =wriop_get_mdio (priv->dpmac_id);#endif +struct phy_device *phydev =NULL ; if ((net_dev->state == ETH_STATE_PASSIVE) || (net_dev->state == ETH_STATE_INIT)) @@ -588,11 +593,12 @@static void ldpaa_eth_stop (struct eth_device *net_dev)printf("dpni_disable() failed\n");#ifdef
CONFIG_PHYLIBdrivers/net/ldpaa_eth/ldpaa_eth.c +5
-4-if (priv->phydev && bus !=NULL ) -phy_shutdown (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev && bus) +phy_shutdown (phydev);else { -free (priv->phydev); - priv->phydev =NULL ; +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); }#endif drivers/net/ldpaa_eth/ldpaa_eth.h +0
-1@@ -127,7 +127,6 @@ struct ldpaa_eth_priv {uint16_t tx_flow_id;enum ldpaa_eth_type type;/* 1G or 10G ethernet */ -struct phy_device *phydev; };struct dprc_endpoint dpmac_endpoint;drivers/net/ldpaa_eth/ldpaa_wriop.c +0
-0@@ -26,6 +26,7 @@ void wriop_init_dpmac(int sd, int dpmac_id, int
lane_prtcl)drivers/net/ldpaa_eth/ldpaa_wriop.c void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl)
Quoted 8 lines
drivers/net/ldpaa_eth/ldpaa_wriop.c +2
-0dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; dpmac_info[dpmac_id].phy_addr =-1 ; + dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if = wriop_dpmac_enet_if(dpmac_id, lane_prtcl); @@ -42,6 +43,7 @@ void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t
enet_if)Quoted 22 lines
dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].phy_addr = -1; dpmac_info[dpmac_id].enet_if = enet_if;drivers/net/ldpaa_eth/ldpaa_wriop.c +1
-0+ dpmac_info[dpmac_id].phydev =NULL ; }(quoted diff) +0
-0
b/include/fsl-mc/ldpaa_wriop.hindex07e5130264..8971c6c55b100644include/fsl-mc/ldpaa_wriop.h +0
-2@@ -41,7 +41,6 @@ struct wriop_dpmac_info {u8 id;u8 board_mux;int phy_addr; -void *phy_regs;phy_interface_t enet_if;struct phy_device *phydev;struct mii_dev *bus; --2.17.1
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.dehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flis
Quoted 9 lines
Quoted 1 line
ts.denx.de%2Flistinfo%2Fu-
boot&data=02%7C01%7Cpankaj.bansal%40nxp.
Quoted 1 line
com%7Cbced1ce32f8e455148d408d62e64c7f5%7C686ea1d3bc2b4c6fa92c
d99c5c301Quoted 1 line
635%7C0%7C0%7C636747407731429023&sdata=4cwaAt8C4V91TNo iNFGcoznoGEn
Quoted 1 line
POsCGDmh9maFv%2FOA%3D&reserved=0
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot
PATCH v3 3/6 driver: net: fsl-mc: fix error handing in init_phy
In reply to Pankaj Bansalif an error occurs during init_phy, we should free the phydev structure which has been allocated by phy_connect.
---
Notes:
V3:
- No change
V2:
- after free phydev just pass NULL into wriop_set_phy_dev()
drivers/net/ldpaa_eth/ldpaa_eth.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +9 -1
@@ -23,6 +23,7 @@ static int init_phy(struct eth_device *dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;struct phy_device *phydev =NULL ;struct mii_dev *bus; +int ret; bus =wriop_get_mdio (priv->dpmac_id);if (bus ==NULL )
@@ -37,7 +38,14 @@ static int init_phy(struct eth_device *dev)wriop_set_phy_dev (priv->dpmac_id, phydev); - return phy_config(phydev); + ret =phy_config (phydev); + +if (ret) { +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); + } + + return ret; }#endif
Signature · 1 line
2.17.1
PATCH v3 4/6 driver: net: fsl-mc: Modify the dpmac link detection method
In reply to Pankaj Bansalwhen there is no phy present for a dpmac, a dummy phy device is created. when we move to multiple phy method, we need to create as many dummy phy devices.
Change this method so that we don't need to create dummy phy devices. We always report linkup if no phy is present.
---
Notes:
V3:
- No change
V2:
- Change (phydev->link == 1) to (phydev->link)
- Use min macro instead of ternary operator
- return -ENOLINK instead of -1 from ldpaa_get_dpmac_state
- Change (state->up == 0) to (!state->up)
drivers/net/ldpaa_eth/ldpaa_eth.c | 119 +++++++++++++--------------- 1 file changed, 57 insertions(+), 62 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +57 -62
@@ -385,6 +385,59 @@ error:return err; } +static int ldpaa_get_dpmac_state (struct ldpaa_eth_priv *priv, +struct dpmac_link_state *state) +{ +struct phy_device *phydev =NULL ; +phy_interface_t enet_if; +int err; + +/* let's start off with maximum capabilities +*/ + enet_if =wriop_get_enet_if (priv->dpmac_id); +switch (enet_if) { +case PHY_INTERFACE_MODE_XGMII : + state->rate =SPEED_10000 ; +break ; +default : + state->rate =SPEED_1000 ; +break ; + } + state->up =1 ; + +#ifdef CONFIG_PHYLIB + state->options |=DPMAC_LINK_OPT_AUTONEG ; + + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev); +if (err) { +printf ("%s: Could not initialize\n" , phydev->dev->name); + state->up =0 ; + } +if (phydev->link) { + state->rate =min (state->rate, (uint32_t )phydev->speed); +if (!phydev->duplex) + state->options |=DPMAC_LINK_OPT_HALF_DUPLEX ; +if (!phydev->autoneg) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + }else { + state->up =0 ; + } + } +#endif +if (!phydev) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + +if (!state->up) { + state->rate =0 ; + state->options =0 ; +return -ENOLINK ; + } + +return 0 ; +} +static int ldpaa_eth_open (struct eth_device *net_dev,bd_t *bd) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
@@ -393,10 +446,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct dpni_link_state link_state;#endif int err =0 ; -struct mii_dev *bus; -phy_interface_t enet_if;struct dpni_queue d_queue; -struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;
@@ -416,45 +466,9 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err <0 ) goto err_dpmac_setup; -#ifdef CONFIG_PHYLIB - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) { - err =phy_startup (phydev); -if (err) { -printf ("%s: Could not initialize\n" , - phydev->dev->name); - goto err_dpmac_bind; - } - } -#else - phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_1000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; -#endif - - bus =wriop_get_mdio (priv->dpmac_id); - enet_if =wriop_get_enet_if (priv->dpmac_id); -if ((bus ==NULL ) && - (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - phydev = (struct phy_device *) -malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_10000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; - } - -if (!phydev->link) { -printf ("%s: No link.\n" , phydev->dev->name); - err =-1 ; + err =ldpaa_get_dpmac_state (priv, &dpmac_link_state); +if (err <0 ) goto err_dpmac_bind; - }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);
@@ -488,18 +502,6 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = phydev->speed; - -if (phydev->autoneg ==AUTONEG_DISABLE ) - dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ; -else - dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; - -if (phydev->duplex ==DUPLEX_HALF ) - dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - - dpmac_link_state.up = phydev->link; - err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);if (err <0 ) {
@@ -542,7 +544,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return phydev->link; +return dpmac_link_state.up; err_qdid: err_get_queue:
@@ -565,9 +567,6 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;int err =0 ; -#ifdef CONFIG_PHYLIB -struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id); -#endif struct phy_device *phydev =NULL ; if ((net_dev->state == ETH_STATE_PASSIVE) ||
@@ -602,12 +601,8 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev && bus) +if (phydev)phy_shutdown (phydev); -else { -free (phydev); -wriop_set_phy_dev (priv->dpmac_id,NULL ); - }#endif /* Free DPBP handle and reset. */
Signature · 1 line
2.17.1
PATCH v3 5/6 driver: net: fsl-mc: initialize dpmac irrespective of phy
In reply to Pankaj BansalThe dpmac initalization should not depend on phy.
As the phy is not necessary to be present for dpmac to function. Therefore, remove dpmac initialization dependency from phy.
---
Notes:
V3:
- No change
V2:
- No Change
drivers/net/fsl-mc/mc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/fsl-mc/mc.c +2 -4
@@ -363,8 +363,7 @@ static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type)for (i =WRIOP1_DPMAC1 ; i <NUM_WRIOP_PORTS ; i++) {/* port not enabled */ -if ((wriop_is_enabled_dpmac (i) !=1 ) || - (wriop_get_phy_address (i) ==-1 )) +if (wriop_is_enabled_dpmac (i) !=1 )continue ; snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s", i,
@@ -886,8 +885,7 @@ int fsl_mc_ldpaa_init(bd_t *bis)int i;for (i =WRIOP1_DPMAC1 ; i <NUM_WRIOP_PORTS ; i++) -if ((wriop_is_enabled_dpmac (i) ==1 ) && - (wriop_get_phy_address (i) !=-1 )) +if (wriop_is_enabled_dpmac (i) ==1 )ldpaa_eth_init (i,wriop_get_enet_if (i));return 0 ; }
Signature · 1 line
2.17.1
PATCH v3 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalTill now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
---
Notes:
V3:
- return 0 from end of functions whose return type has been changed from void to int
V2:
- use single-line comment format.
- use WRIOP_MAX_PHY_NUM.
- use -ENODEV or -EINVAL instead of -1 wherever appropriate
- include the variable names in the headers too.
- Change the return type of some functions from void to int so that a meaningful error message can be returned
board/freescale/ls1088a/eth_ls1088aqds.c | 18 ++--- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +++--- board/freescale/ls2080aqds/eth.c | 26 +++---- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 66 ++++++++++++------ drivers/net/ldpaa_eth/ldpaa_wriop.c | 73 ++++++++++++++------ include/fsl-mc/ldpaa_wriop.h | 45 ++++++------ 7 files changed, 164 insertions(+), 109 deletions(-)
board/freescale/ls1088a/eth_ls1088aqds.c +9 -9
@@ -487,16 +487,16 @@ void ls1088a_handle_phy_interface_sgmii(int dpmac_id)case 0x3A :switch (dpmac_id) {case 1 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[1 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[1 ]);break ;case 2 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[0 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[0 ]);break ;case 3 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[3 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[3 ]);break ;case 7 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[2 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[2 ]);break ;default :printf ("WRIOP: Wrong DPMAC%d set to SGMII" , dpmac_id);
@@ -532,13 +532,13 @@ void ls1088a_handle_phy_interface_qsgmii(int dpmac_id)case 4 :case 5 :case 6 : -wriop_set_phy_address (dpmac_id, dpmac_id +9 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +9 );break ;case 7 :case 8 :case 9 :case 10 : -wriop_set_phy_address (dpmac_id, dpmac_id +1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +1 );break ; }
@@ -567,7 +567,7 @@ void ls1088a_handle_phy_interface_xsgmii(int i)case 0x15 :case 0x1D :case 0x1E : -wriop_set_phy_address (i, i +26 ); +wriop_set_phy_address (i,0 , i +26 );ls1088a_qds_enable_SFP_TX (SFP_TX );break ;default :
@@ -590,13 +590,13 @@ static void ls1088a_handle_phy_interface_rgmii(int dpmac_id)switch (dpmac_id) {case 4 : -wriop_set_phy_address (dpmac_id,RGMII_PHY1_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY1_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII1 ; bus =mii_dev_for_muxval (EMI1_RGMII1 );wriop_set_mdio (dpmac_id, bus);break ;case 5 : -wriop_set_phy_address (dpmac_id,RGMII_PHY2_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY2_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII2 ; bus =mii_dev_for_muxval (EMI1_RGMII2 );wriop_set_mdio (dpmac_id, bus);
board/freescale/ls1088a/eth_ls1088ardb.c +11 -10
@@ -55,16 +55,17 @@ int board_eth_init(bd_t *bis)* a MAC has no PHY address, we give a PHY address to XFI * MAC error. */ -wriop_set_phy_address (WRIOP1_DPMAC1 ,0x0a ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,QSGMII1_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,QSGMII1_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,QSGMII1_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,QSGMII1_PORT4_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,QSGMII2_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,QSGMII2_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC9 ,QSGMII2_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC10 ,QSGMII2_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,0x0a ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,QSGMII1_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,QSGMII1_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,QSGMII1_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,QSGMII1_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,QSGMII2_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,QSGMII2_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC9 ,0 ,QSGMII2_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC10 ,0 , +QSGMII2_PORT4_PHY_ADDR );break ;default :
board/freescale/ls2080aqds/eth.c +13 -13
@@ -623,7 +623,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );
@@ -631,7 +631,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)break ;case 2 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT2 ; bus =mii_dev_for_muxval (EMI1_SLOT2 );
@@ -641,18 +641,18 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)if (slot ==EMI_NONE )return ;if (serdes1_prtcl ==0x39 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=6 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=7 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT3 ;
@@ -691,7 +691,7 @@ serdes2:break ;case 4 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -9 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT4 ; bus =mii_dev_for_muxval (EMI1_SLOT4 );
@@ -701,14 +701,14 @@ serdes2:if (slot ==EMI_NONE )return ;if (serdes2_prtcl ==0x47 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -10 ]);if (dpmac_id >=14 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT5 ;
@@ -717,7 +717,7 @@ serdes2:break ;case 6 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -13 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT6 ; bus =mii_dev_for_muxval (EMI1_SLOT6 );
@@ -775,7 +775,7 @@ void ls2080a_handle_phy_interface_qsgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a QSGMII riser card? */ -wriop_set_phy_address (dpmac_id, dpmac_id -1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id -1 ); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );wriop_set_mdio (dpmac_id, bus);
@@ -819,7 +819,7 @@ void ls2080a_handle_phy_interface_xsgmii(int i)* the XAUI card is used for the XFI MAC, which will cause * error. */ -wriop_set_phy_address (i, i +4 ); +wriop_set_phy_address (i,0 , i +4 );ls2080a_qds_enable_SFP_TX (SFP_TX );break ;
board/freescale/ls2080ardb/eth_ls2080rdb.c +12 -12
@@ -50,21 +50,21 @@ int board_eth_init(bd_t *bis)switch (srds_s1) {case 0x2A : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,AQ_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,AQ_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,AQ_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,AQ_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,AQ_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,AQ_PHY_ADDR4 );break ;case 0x4B : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 );break ;default :
drivers/net/ldpaa_eth/ldpaa_eth.c +46 -20
123 lines not on this page · raw message
drivers/net/ldpaa_eth/ldpaa_wriop.c +50 -23
167 lines not on this page · raw message
include/fsl-mc/ldpaa_wriop.h +23 -22
63 lines not on this page · raw message
Signature · 1 line
2.17.1
v3 cover driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalThis patch set adds support of multiple phys for one dpmac
Till now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. To handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
Pankaj Bansal (6):
driver: net: fsl-mc: modify the label name
driver: net: fsl-mc: remove unused strcture elements
driver: net: fsl-mc: fix error handing in init_phy
driver: net: fsl-mc: Modify the dpmac link detection method
driver: net: fsl-mc: initialize dpmac irrespective of phy
driver: net: fsl-mc: Add support of multiple phys for dpmac
board/freescale/ls1088a/eth_ls1088aqds.c | 18 +-- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +-- board/freescale/ls2080aqds/eth.c | 26 ++-- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +-- drivers/net/fsl-mc/mc.c | 6 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 171 +++++++++++++-------- drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 69 ++++++--- include/fsl-mc/ldpaa_wriop.h | 46 +++--- 9 files changed, 221 insertions(+), 161 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/6 driver: net: fsl-mc: modify the label name
The goto label name is misspelled it should be DPMAC not DPAMC
---
Notes:
V3:
- No change
V2:
- No change
drivers/net/ldpaa_eth/ldpaa_eth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +4 -4
@@ -413,7 +413,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err) {printf ("%s: Could not initialize\n" , priv->phydev->dev->name); - goto err_dpamc_bind; + goto err_dpmac_bind; } }#else
@@ -441,13 +441,13 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (!priv->phydev->link) {printf ("%s: No link.\n" , priv->phydev->dev->name); err =-1 ; - goto err_dpamc_bind; + goto err_dpmac_bind; }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);if (err) - goto err_dpamc_bind; + goto err_dpmac_bind;/* DPNI initialization */ err =ldpaa_dpni_setup (priv);
@@ -540,7 +540,7 @@ err_dpni_bind: err_dpbp_setup:dpni_close (dflt_mc_io,MC_CMD_NO_FLAGS , dflt_dpni->dpni_handle); err_dpni_setup: -err_dpamc_bind: +err_dpmac_bind:dpmac_close (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle); dpmac_destroy(dflt_mc_io, dflt_dprc_handle,
Signature · 1 line
2.17.1
[U-Boot] driver: net: fsl-mc: modify the label name
Hi Pankaj,
https://patchwork.ozlabs.org/patch/981665/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 2/6 driver: net: fsl-mc: remove unused strcture elements
In reply to Pankaj BansalThe phydev structure is present in both ldpaa_eth_priv and wriop_dpmac_info. the phydev in wriop_dpmac_info is not being used
As the phydev is created based on phy_addr and bus members of wriop_dpmac_info, it is appropriate to keep phydev in wriop_dpmac_info.
Also phy_regs is not being used, therefore remove it
---
Notes:
V3:
- No change
V2:
- change (phydev && bus != NULL) to (phydev && bus)
- after free phydev just pass NULL into wriop_set_phy_dev()
drivers/net/ldpaa_eth/ldpaa_eth.c | 56 +++++++++++++++------------ drivers/net/ldpaa_eth/ldpaa_eth.h | 1 - drivers/net/ldpaa_eth/ldpaa_wriop.c | 2 + include/fsl-mc/ldpaa_wriop.h | 1 - 4 files changed, 33 insertions(+), 27 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +31 -25
@@ -35,7 +35,7 @@ static int init_phy(struct eth_device *dev)return -1 ; } - priv->phydev = phydev; +wriop_set_phy_dev (priv->dpmac_id, phydev);return phy_config (phydev); }
@@ -388,6 +388,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct mii_dev *bus;phy_interface_t enet_if;struct dpni_queue d_queue; +struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;
@@ -408,38 +409,41 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_dpmac_setup;#ifdef CONFIG_PHYLIB -if (priv->phydev) { - err =phy_startup (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev);if (err) {printf ("%s: Could not initialize\n" , - priv->phydev->dev->name); + phydev->dev->name); goto err_dpmac_bind; } }#else - priv->phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_1000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_1000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ;#endif bus =wriop_get_mdio (priv->dpmac_id); enet_if =wriop_get_enet_if (priv->dpmac_id);if ((bus ==NULL ) && (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - priv->phydev = (struct phy_device *) + phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (priv->phydev,0 ,sizeof (struct phy_device )); +memset (phydev,0 ,sizeof (struct phy_device )); +wriop_set_phy_dev (priv->dpmac_id, phydev); - priv->phydev->speed =SPEED_10000 ; - priv->phydev->link =1 ; - priv->phydev->duplex =DUPLEX_FULL ; + phydev->speed =SPEED_10000 ; + phydev->link =1 ; + phydev->duplex =DUPLEX_FULL ; } -if (!priv->phydev->link) { -printf ("%s: No link.\n" , priv->phydev->dev->name); +if (!phydev->link) { +printf ("%s: No link.\n" , phydev->dev->name); err =-1 ; goto err_dpmac_bind; }
@@ -476,17 +480,17 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = priv->phydev->speed; + dpmac_link_state.rate = phydev->speed; -if (priv->phydev->autoneg ==AUTONEG_DISABLE ) +if (phydev->autoneg ==AUTONEG_DISABLE ) dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ;else dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; -if (priv->phydev->duplex ==DUPLEX_HALF ) +if (phydev->duplex ==DUPLEX_HALF ) dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - dpmac_link_state.up = priv->phydev->link; + dpmac_link_state.up = phydev->link; err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);
@@ -530,7 +534,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return priv->phydev->link; +return phydev->link; err_qdid: err_get_queue:
@@ -556,6 +560,7 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id);#endif +struct phy_device *phydev =NULL ;if ((net_dev->state ==ETH_STATE_PASSIVE ) || (net_dev->state ==ETH_STATE_INIT ))
@@ -588,11 +593,12 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)printf ("dpni_disable() failed\n" );#ifdef CONFIG_PHYLIB -if (priv->phydev && bus !=NULL ) -phy_shutdown (priv->phydev); + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev && bus) +phy_shutdown (phydev);else { -free (priv->phydev); - priv->phydev =NULL ; +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); }#endif
drivers/net/ldpaa_eth/ldpaa_eth.h +0 -1
@@ -127,7 +127,6 @@ struct ldpaa_eth_priv {uint16_t tx_flow_id;enum ldpaa_eth_type type;/* 1G or 10G ethernet */ -struct phy_device *phydev; };struct dprc_endpoint dpmac_endpoint;
drivers/net/ldpaa_eth/ldpaa_wriop.c +2 -0
@@ -26,6 +26,7 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].enabled =0 ; dpmac_info[dpmac_id].id =0 ; dpmac_info[dpmac_id].phy_addr =-1 ; + dpmac_info[dpmac_id].phydev =NULL ; dpmac_info[dpmac_id].enet_if =PHY_INTERFACE_MODE_NONE ; enet_if =wriop_dpmac_enet_if (dpmac_id, lane_prtcl);
@@ -42,6 +43,7 @@ void wriop_init_dpmac_enet_if(int dpmac_id, phy_interface_t enet_if) dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].phy_addr =-1 ; dpmac_info[dpmac_id].enet_if = enet_if; + dpmac_info[dpmac_id].phydev =NULL ; }
include/fsl-mc/ldpaa_wriop.h +0 -1
@@ -41,7 +41,6 @@ struct wriop_dpmac_info {u8 id;u8 board_mux;int phy_addr; -void *phy_regs;phy_interface_t enet_if;struct phy_device *phydev;struct mii_dev *bus;
Signature · 1 line
2.17.1
[U-Boot] driver: net: fsl-mc: remove unused strcture elements
Hi Pankaj,
https://patchwork.ozlabs.org/patch/981668/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 3/6 driver: net: fsl-mc: fix error handing in init_phy
In reply to Pankaj Bansalif an error occurs during init_phy, we should free the phydev structure which has been allocated by phy_connect.
---
Notes:
V3:
- No change
V2:
- after free phydev just pass NULL into wriop_set_phy_dev()
drivers/net/ldpaa_eth/ldpaa_eth.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +9 -1
@@ -23,6 +23,7 @@ static int init_phy(struct eth_device *dev)struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)dev->priv;struct phy_device *phydev =NULL ;struct mii_dev *bus; +int ret; bus =wriop_get_mdio (priv->dpmac_id);if (bus ==NULL )
@@ -37,7 +38,14 @@ static int init_phy(struct eth_device *dev)wriop_set_phy_dev (priv->dpmac_id, phydev); - return phy_config(phydev); + ret =phy_config (phydev); + +if (ret) { +free (phydev); +wriop_set_phy_dev (priv->dpmac_id,NULL ); + } + + return ret; }#endif
Signature · 1 line
2.17.1
[U-Boot] driver: net: fsl-mc: fix error handing in init_phy
Hi Pankaj,
https://patchwork.ozlabs.org/patch/981669/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 4/6 driver: net: fsl-mc: Modify the dpmac link detection method
In reply to Pankaj Bansalwhen there is no phy present for a dpmac, a dummy phy device is created. when we move to multiple phy method, we need to create as many dummy phy devices.
Change this method so that we don't need to create dummy phy devices. We always report linkup if no phy is present.
---
Notes:
V3:
- No change
V2:
- Change (phydev->link == 1) to (phydev->link)
- Use min macro instead of ternary operator
- return -ENOLINK instead of -1 from ldpaa_get_dpmac_state
- Change (state->up == 0) to (!state->up)
drivers/net/ldpaa_eth/ldpaa_eth.c | 119 +++++++++++++--------------- 1 file changed, 57 insertions(+), 62 deletions(-)
drivers/net/ldpaa_eth/ldpaa_eth.c +57 -62
@@ -385,6 +385,59 @@ error:return err; } +static int ldpaa_get_dpmac_state (struct ldpaa_eth_priv *priv, +struct dpmac_link_state *state) +{ +struct phy_device *phydev =NULL ; +phy_interface_t enet_if; +int err; + +/* let's start off with maximum capabilities +*/ + enet_if =wriop_get_enet_if (priv->dpmac_id); +switch (enet_if) { +case PHY_INTERFACE_MODE_XGMII : + state->rate =SPEED_10000 ; +break ; +default : + state->rate =SPEED_1000 ; +break ; + } + state->up =1 ; + +#ifdef CONFIG_PHYLIB + state->options |=DPMAC_LINK_OPT_AUTONEG ; + + phydev =wriop_get_phy_dev (priv->dpmac_id); +if (phydev) { + err =phy_startup (phydev); +if (err) { +printf ("%s: Could not initialize\n" , phydev->dev->name); + state->up =0 ; + } +if (phydev->link) { + state->rate =min (state->rate, (uint32_t )phydev->speed); +if (!phydev->duplex) + state->options |=DPMAC_LINK_OPT_HALF_DUPLEX ; +if (!phydev->autoneg) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + }else { + state->up =0 ; + } + } +#endif +if (!phydev) + state->options &= ~DPMAC_LINK_OPT_AUTONEG ; + +if (!state->up) { + state->rate =0 ; + state->options =0 ; +return -ENOLINK ; + } + +return 0 ; +} +static int ldpaa_eth_open (struct eth_device *net_dev,bd_t *bd) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;
@@ -393,10 +446,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)struct dpni_link_state link_state;#endif int err =0 ; -struct mii_dev *bus; -phy_interface_t enet_if;struct dpni_queue d_queue; -struct phy_device *phydev =NULL ;if (net_dev->state ==ETH_STATE_ACTIVE )return 0 ;
@@ -416,45 +466,9 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)if (err <0 ) goto err_dpmac_setup; -#ifdef CONFIG_PHYLIB - phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev) { - err =phy_startup (phydev); -if (err) { -printf ("%s: Could not initialize\n" , - phydev->dev->name); - goto err_dpmac_bind; - } - } -#else - phydev = (struct phy_device *)malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_1000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; -#endif - - bus =wriop_get_mdio (priv->dpmac_id); - enet_if =wriop_get_enet_if (priv->dpmac_id); -if ((bus ==NULL ) && - (enet_if ==PHY_INTERFACE_MODE_XGMII )) { - phydev = (struct phy_device *) -malloc (sizeof (struct phy_device )); -memset (phydev,0 ,sizeof (struct phy_device )); -wriop_set_phy_dev (priv->dpmac_id, phydev); - - phydev->speed =SPEED_10000 ; - phydev->link =1 ; - phydev->duplex =DUPLEX_FULL ; - } - -if (!phydev->link) { -printf ("%s: No link.\n" , phydev->dev->name); - err =-1 ; + err =ldpaa_get_dpmac_state (priv, &dpmac_link_state); +if (err <0 ) goto err_dpmac_bind; - }/* DPMAC binding DPNI */ err =ldpaa_dpmac_bind (priv);
@@ -488,18 +502,6 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd)return err; } - dpmac_link_state.rate = phydev->speed; - -if (phydev->autoneg ==AUTONEG_DISABLE ) - dpmac_link_state.options &= ~DPMAC_LINK_OPT_AUTONEG ; -else - dpmac_link_state.options |=DPMAC_LINK_OPT_AUTONEG ; - -if (phydev->duplex ==DUPLEX_HALF ) - dpmac_link_state.options |=DPMAC_LINK_OPT_HALF_DUPLEX ; - - dpmac_link_state.up = phydev->link; - err =dpmac_set_link_state (dflt_mc_io,MC_CMD_NO_FLAGS , priv->dpmac_handle, &dpmac_link_state);if (err <0 ) {
@@ -542,7 +544,7 @@ static int ldpaa_eth_open(struct eth_device *net_dev, bd_t *bd) goto err_qdid; } -return phydev->link; +return dpmac_link_state.up; err_qdid: err_get_queue:
@@ -565,9 +567,6 @@ static void ldpaa_eth_stop(struct eth_device *net_dev) {struct ldpaa_eth_priv *priv = (struct ldpaa_eth_priv *)net_dev->priv;int err =0 ; -#ifdef CONFIG_PHYLIB -struct mii_dev *bus =wriop_get_mdio (priv->dpmac_id); -#endif struct phy_device *phydev =NULL ; if ((net_dev->state == ETH_STATE_PASSIVE) ||
@@ -602,12 +601,8 @@ static void ldpaa_eth_stop(struct eth_device *net_dev)#ifdef CONFIG_PHYLIB phydev =wriop_get_phy_dev (priv->dpmac_id); -if (phydev && bus) +if (phydev)phy_shutdown (phydev); -else { -free (phydev); -wriop_set_phy_dev (priv->dpmac_id,NULL ); - }#endif /* Free DPBP handle and reset. */
Signature · 1 line
2.17.1
[U-Boot] driver: net: fsl-mc: Modify the dpmac link detection method
Hi Pankaj,
https://patchwork.ozlabs.org/patch/981670/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 5/6 driver: net: fsl-mc: initialize dpmac irrespective of phy
In reply to Pankaj BansalThe dpmac initalization should not depend on phy.
As the phy is not necessary to be present for dpmac to function. Therefore, remove dpmac initialization dependency from phy.
---
Notes:
V3:
- No change
V2:
- No Change
drivers/net/fsl-mc/mc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/fsl-mc/mc.c +2 -4
@@ -363,8 +363,7 @@ static int mc_fixup_mac_addrs(void *blob, enum mc_fixup_type type)for (i =WRIOP1_DPMAC1 ; i <NUM_WRIOP_PORTS ; i++) {/* port not enabled */ -if ((wriop_is_enabled_dpmac (i) !=1 ) || - (wriop_get_phy_address (i) ==-1 )) +if (wriop_is_enabled_dpmac (i) !=1 )continue ; snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s", i,
@@ -886,8 +885,7 @@ int fsl_mc_ldpaa_init(bd_t *bis)int i;for (i =WRIOP1_DPMAC1 ; i <NUM_WRIOP_PORTS ; i++) -if ((wriop_is_enabled_dpmac (i) ==1 ) && - (wriop_get_phy_address (i) !=-1 )) +if (wriop_is_enabled_dpmac (i) ==1 )ldpaa_eth_init (i,wriop_get_enet_if (i));return 0 ; }
Signature · 1 line
2.17.1
[U-Boot] driver: net: fsl-mc: initialize dpmac irrespective of phy
Hi Pankaj,
https://patchwork.ozlabs.org/patch/981672/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe
PATCH v3 6/6 driver: net: fsl-mc: Add support of multiple phys for dpmac
In reply to Pankaj BansalTill now we have had cases where we had one phy device per dpmac. Now, with the upcoming products (LX2160AQDS), we have cases, where there are sometimes two phy devices for one dpmac. One phy for TX lanes and one phy for RX lanes. to handle such cases, add the support for multiple phys in ethernet driver. The ethernet link is up if all the phy devices connected to one dpmac report link up. also the link capabilities are limited by the weakest phy device.
i.e. say if there are two phys for one dpmac. one operates at 10G without autoneg and other operate at 1G with autoneg. Then the ethernet interface will operate at 1G without autoneg.
---
Notes:
V3:
- return 0 from end of functions whose return type has been changed from void to int
V2:
- use single-line comment format.
- use WRIOP_MAX_PHY_NUM.
- use -ENODEV or -EINVAL instead of -1 wherever appropriate
- include the variable names in the headers too.
- Change the return type of some functions from void to int so that a meaningful error message can be returned
board/freescale/ls1088a/eth_ls1088aqds.c | 18 ++--- board/freescale/ls1088a/eth_ls1088ardb.c | 21 +++--- board/freescale/ls2080aqds/eth.c | 26 +++---- board/freescale/ls2080ardb/eth_ls2080rdb.c | 24 +++---- drivers/net/ldpaa_eth/ldpaa_eth.c | 66 ++++++++++++------ drivers/net/ldpaa_eth/ldpaa_wriop.c | 71 +++++++++++++------- include/fsl-mc/ldpaa_wriop.h | 45 +++++++------ 7 files changed, 162 insertions(+), 109 deletions(-)
board/freescale/ls1088a/eth_ls1088aqds.c +9 -9
@@ -487,16 +487,16 @@ void ls1088a_handle_phy_interface_sgmii(int dpmac_id)case 0x3A :switch (dpmac_id) {case 1 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[1 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[1 ]);break ;case 2 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[0 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[0 ]);break ;case 3 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[3 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[3 ]);break ;case 7 : -wriop_set_phy_address (dpmac_id, riser_phy_addr[2 ]); +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[2 ]);break ;default :printf ("WRIOP: Wrong DPMAC%d set to SGMII" , dpmac_id);
@@ -532,13 +532,13 @@ void ls1088a_handle_phy_interface_qsgmii(int dpmac_id)case 4 :case 5 :case 6 : -wriop_set_phy_address (dpmac_id, dpmac_id +9 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +9 );break ;case 7 :case 8 :case 9 :case 10 : -wriop_set_phy_address (dpmac_id, dpmac_id +1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id +1 );break ; }
@@ -567,7 +567,7 @@ void ls1088a_handle_phy_interface_xsgmii(int i)case 0x15 :case 0x1D :case 0x1E : -wriop_set_phy_address (i, i +26 ); +wriop_set_phy_address (i,0 , i +26 );ls1088a_qds_enable_SFP_TX (SFP_TX );break ;default :
@@ -590,13 +590,13 @@ static void ls1088a_handle_phy_interface_rgmii(int dpmac_id)switch (dpmac_id) {case 4 : -wriop_set_phy_address (dpmac_id,RGMII_PHY1_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY1_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII1 ; bus =mii_dev_for_muxval (EMI1_RGMII1 );wriop_set_mdio (dpmac_id, bus);break ;case 5 : -wriop_set_phy_address (dpmac_id,RGMII_PHY2_ADDR ); +wriop_set_phy_address (dpmac_id,0 ,RGMII_PHY2_ADDR ); dpmac_info[dpmac_id].board_mux =EMI1_RGMII2 ; bus =mii_dev_for_muxval (EMI1_RGMII2 );wriop_set_mdio (dpmac_id, bus);
board/freescale/ls1088a/eth_ls1088ardb.c +11 -10
@@ -55,16 +55,17 @@ int board_eth_init(bd_t *bis)* a MAC has no PHY address, we give a PHY address to XFI * MAC error. */ -wriop_set_phy_address (WRIOP1_DPMAC1 ,0x0a ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,QSGMII1_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,QSGMII1_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,QSGMII1_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,QSGMII1_PORT4_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,QSGMII2_PORT1_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,QSGMII2_PORT2_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC9 ,QSGMII2_PORT3_PHY_ADDR ); -wriop_set_phy_address (WRIOP1_DPMAC10 ,QSGMII2_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,0x0a ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,QSGMII1_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,QSGMII1_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,QSGMII1_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,QSGMII1_PORT4_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,QSGMII2_PORT1_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,QSGMII2_PORT2_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC9 ,0 ,QSGMII2_PORT3_PHY_ADDR ); +wriop_set_phy_address (WRIOP1_DPMAC10 ,0 , +QSGMII2_PORT4_PHY_ADDR );break ;default :
board/freescale/ls2080aqds/eth.c +13 -13
@@ -623,7 +623,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );
@@ -631,7 +631,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)break ;case 2 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -1 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT2 ; bus =mii_dev_for_muxval (EMI1_SLOT2 );
@@ -641,18 +641,18 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)if (slot ==EMI_NONE )return ;if (serdes1_prtcl ==0x39 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=6 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -2 ]);if (dpmac_id >=7 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -3 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT3 ;
@@ -691,7 +691,7 @@ serdes2:break ;case 4 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -9 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT4 ; bus =mii_dev_for_muxval (EMI1_SLOT4 );
@@ -701,14 +701,14 @@ serdes2:if (slot ==EMI_NONE )return ;if (serdes2_prtcl ==0x47 ) { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -10 ]);if (dpmac_id >=14 &&hwconfig_f ("xqsgmii" , env_hwconfig)) -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); }else { -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -11 ]); } dpmac_info[dpmac_id].board_mux =EMI1_SLOT5 ;
@@ -717,7 +717,7 @@ serdes2:break ;case 6 :/* Slot housing a SGMII riser card? */ -wriop_set_phy_address (dpmac_id, +wriop_set_phy_address (dpmac_id,0 , riser_phy_addr[dpmac_id -13 ]); dpmac_info[dpmac_id].board_mux =EMI1_SLOT6 ; bus =mii_dev_for_muxval (EMI1_SLOT6 );
@@ -775,7 +775,7 @@ void ls2080a_handle_phy_interface_qsgmii(int dpmac_id)switch (++slot) {case 1 :/* Slot housing a QSGMII riser card? */ -wriop_set_phy_address (dpmac_id, dpmac_id -1 ); +wriop_set_phy_address (dpmac_id,0 , dpmac_id -1 ); dpmac_info[dpmac_id].board_mux =EMI1_SLOT1 ; bus =mii_dev_for_muxval (EMI1_SLOT1 );wriop_set_mdio (dpmac_id, bus);
@@ -819,7 +819,7 @@ void ls2080a_handle_phy_interface_xsgmii(int i)* the XAUI card is used for the XFI MAC, which will cause * error. */ -wriop_set_phy_address (i, i +4 ); +wriop_set_phy_address (i,0 , i +4 );ls2080a_qds_enable_SFP_TX (SFP_TX );break ;
board/freescale/ls2080ardb/eth_ls2080rdb.c +12 -12
@@ -50,21 +50,21 @@ int board_eth_init(bd_t *bis)switch (srds_s1) {case 0x2A : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); -wriop_set_phy_address (WRIOP1_DPMAC5 ,AQ_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC6 ,AQ_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC7 ,AQ_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC8 ,AQ_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC5 ,0 ,AQ_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC6 ,0 ,AQ_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC7 ,0 ,AQ_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC8 ,0 ,AQ_PHY_ADDR4 );break ;case 0x4B : -wriop_set_phy_address (WRIOP1_DPMAC1 ,CORTINA_PHY_ADDR1 ); -wriop_set_phy_address (WRIOP1_DPMAC2 ,CORTINA_PHY_ADDR2 ); -wriop_set_phy_address (WRIOP1_DPMAC3 ,CORTINA_PHY_ADDR3 ); -wriop_set_phy_address (WRIOP1_DPMAC4 ,CORTINA_PHY_ADDR4 ); +wriop_set_phy_address (WRIOP1_DPMAC1 ,0 ,CORTINA_PHY_ADDR1 ); +wriop_set_phy_address (WRIOP1_DPMAC2 ,0 ,CORTINA_PHY_ADDR2 ); +wriop_set_phy_address (WRIOP1_DPMAC3 ,0 ,CORTINA_PHY_ADDR3 ); +wriop_set_phy_address (WRIOP1_DPMAC4 ,0 ,CORTINA_PHY_ADDR4 );break ;default :
drivers/net/ldpaa_eth/ldpaa_eth.c +46 -20
123 lines not on this page · raw message
drivers/net/ldpaa_eth/ldpaa_wriop.c +48 -23
165 lines not on this page · raw message
include/fsl-mc/ldpaa_wriop.h +23 -22
63 lines not on this page · raw message
Signature · 1 line
2.17.1
Hi Pankaj,
https://patchwork.ozlabs.org/patch/981671/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git
Thanks!
-Joe