diff mbox series

[1/2] net: tsec: only call tsec_get_interface as fallback to DT-specified PHY mode

Message ID 20210918124655.1086645-2-vladimir.oltean@nxp.com
State Accepted
Commit d883a5fb52b3fe1b6cb653faa60095df0c11a6bf
Delegated to: Ramon Fried
Headers show
Series TSEC Ethernet driver phy-mode changes | expand

Commit Message

Vladimir Oltean Sept. 18, 2021, 12:46 p.m. UTC
Currently the init_phy function may overwrite the priv->interface
property, since it calls tsec_get_interface which tries to determine it
dynamically based on default register values in ECNTRL.

Let's do that only if phy-connection-type happens to not be defined in
the device tree.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/tsec.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Bin Meng Sept. 19, 2021, 7:32 a.m. UTC | #1
On Sat, Sep 18, 2021 at 8:47 PM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> Currently the init_phy function may overwrite the priv->interface
> property, since it calls tsec_get_interface which tries to determine it
> dynamically based on default register values in ECNTRL.
>
> Let's do that only if phy-connection-type happens to not be defined in
> the device tree.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  drivers/net/tsec.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Ramon Fried Sept. 28, 2021, 1:30 p.m. UTC | #2
On Sun, Sep 19, 2021 at 10:32 AM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Sat, Sep 18, 2021 at 8:47 PM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
> >
> > Currently the init_phy function may overwrite the priv->interface
> > property, since it calls tsec_get_interface which tries to determine it
> > dynamically based on default register values in ECNTRL.
> >
> > Let's do that only if phy-connection-type happens to not be defined in
> > the device tree.
> >
> > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > ---
> >  drivers/net/tsec.c | 9 +++------
> >  1 file changed, 3 insertions(+), 6 deletions(-)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
> Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index ee820aae15ef..809cf7e432e6 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -701,8 +701,6 @@  static int init_phy(struct tsec_private *priv)
 	/* Assign a Physical address to the TBI */
 	out_be32(&regs->tbipa, priv->tbiaddr);
 
-	priv->interface = tsec_get_interface(priv);
-
 	if (priv->interface == PHY_INTERFACE_MODE_SGMII)
 		tsec_configure_serdes(priv);
 
@@ -888,10 +886,9 @@  int tsec_probe(struct udevice *dev)
 	phy_mode = dev_read_prop(dev, "phy-connection-type", NULL);
 	if (phy_mode)
 		pdata->phy_interface = phy_get_interface_by_name(phy_mode);
-	if (pdata->phy_interface == -1) {
-		printf("Invalid PHY interface '%s'\n", phy_mode);
-		return -EINVAL;
-	}
+	if (pdata->phy_interface == -1)
+		pdata->phy_interface = tsec_get_interface(priv);
+
 	priv->interface = pdata->phy_interface;
 
 	/* Check for speed limit, default is 1000Mbps */