[net-next,v6,2/6] dsa: lan9303: move Turbo Mode bit init

Message ID 20230109211849.32530-3-jerry.ray@microchip.com
State New
Headers
Series dsa: lan9303: Move to PHYLINK |

Commit Message

Jerry Ray Jan. 9, 2023, 9:18 p.m. UTC
  In preparing to remove the .adjust_link api, I am moving the one-time
initialization of the device's Turbo Mode bit into a different execution
path. This code clears (disables) the Turbo Mode bit which is never used
by this driver. Turbo Mode is a non-standard mode that would allow the
100Mbps RMII interface to run at 200Mbps.

Signed-off-by: Jerry Ray <jerry.ray@microchip.com>
---
 drivers/net/dsa/lan9303-core.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
  

Comments

Vladimir Oltean Jan. 14, 2023, 8:49 p.m. UTC | #1
On Mon, Jan 09, 2023 at 03:18:45PM -0600, Jerry Ray wrote:
> In preparing to remove the .adjust_link api, I am moving the one-time
> initialization of the device's Turbo Mode bit into a different execution
> path. This code clears (disables) the Turbo Mode bit which is never used
> by this driver. Turbo Mode is a non-standard mode that would allow the
> 100Mbps RMII interface to run at 200Mbps.
> 
> Signed-off-by: Jerry Ray <jerry.ray@microchip.com>
> ---
>  drivers/net/dsa/lan9303-core.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> index 5a21fc96d479..50470fb09cb4 100644
> --- a/drivers/net/dsa/lan9303-core.c
> +++ b/drivers/net/dsa/lan9303-core.c
> @@ -886,6 +886,12 @@ static int lan9303_check_device(struct lan9303 *chip)
>  		return ret;
>  	}
>  
> +	/* Virtual Phy: Remove Turbo 200Mbit mode */
> +	lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &reg);
> +
> +	reg &= ~LAN9303_VIRT_SPECIAL_TURBO;
> +	regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg);
> +

Isn't a function whose name is lan9303_check_device() being abused for
this purpose (device initialization)?

>  	return 0;
>  }
>  
> @@ -1050,7 +1056,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, int phy, int regnum,
>  static void lan9303_adjust_link(struct dsa_switch *ds, int port,
>  				struct phy_device *phydev)
>  {
> -	struct lan9303 *chip = ds->priv;
>  	int ctl;
>  
>  	if (!phy_is_pseudo_fixed_link(phydev))
> @@ -1073,14 +1078,6 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port,
>  		ctl &= ~BMCR_FULLDPLX;
>  
>  	lan9303_phy_write(ds, port, MII_BMCR, ctl);
> -
> -	if (port == chip->phy_addr_base) {
> -		/* Virtual Phy: Remove Turbo 200Mbit mode */
> -		lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl);
> -
> -		ctl &= ~LAN9303_VIRT_SPECIAL_TURBO;
> -		regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl);
> -	}
>  }
>  
>  static int lan9303_port_enable(struct dsa_switch *ds, int port,
> -- 
> 2.17.1
>
  
Jerry Ray Jan. 16, 2023, 6:03 p.m. UTC | #2
> > In preparing to remove the .adjust_link api, I am moving the one-time
> > initialization of the device's Turbo Mode bit into a different execution
> > path. This code clears (disables) the Turbo Mode bit which is never used
> > by this driver. Turbo Mode is a non-standard mode that would allow the
> > 100Mbps RMII interface to run at 200Mbps.
> >
> > Signed-off-by: Jerry Ray <jerry.ray@microchip.com>
> > ---
> >  drivers/net/dsa/lan9303-core.c | 15 ++++++---------
> >  1 file changed, 6 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> > index 5a21fc96d479..50470fb09cb4 100644
> > --- a/drivers/net/dsa/lan9303-core.c
> > +++ b/drivers/net/dsa/lan9303-core.c
> > @@ -886,6 +886,12 @@ static int lan9303_check_device(struct lan9303 *chip)
> >               return ret;
> >       }
> >
> > +     /* Virtual Phy: Remove Turbo 200Mbit mode */
> > +     lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &reg);
> > +
> > +     reg &= ~LAN9303_VIRT_SPECIAL_TURBO;
> > +     regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg);
> > +
> 
> Isn't a function whose name is lan9303_check_device() being abused for
> this purpose (device initialization)?
> 
I will move this into lan9303_setup.

Regards,
Jerry.

> >       return 0;
> >  }
> >
> > @@ -1050,7 +1056,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, int phy, int regnum,
> >  static void lan9303_adjust_link(struct dsa_switch *ds, int port,
> >                               struct phy_device *phydev)
> >  {
> > -     struct lan9303 *chip = ds->priv;
> >       int ctl;
> >
> >       if (!phy_is_pseudo_fixed_link(phydev))
> > @@ -1073,14 +1078,6 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port,
> >               ctl &= ~BMCR_FULLDPLX;
> >
> >       lan9303_phy_write(ds, port, MII_BMCR, ctl);
> > -
> > -     if (port == chip->phy_addr_base) {
> > -             /* Virtual Phy: Remove Turbo 200Mbit mode */
> > -             lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl);
> > -
> > -             ctl &= ~LAN9303_VIRT_SPECIAL_TURBO;
> > -             regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl);
> > -     }
> >  }
> >
> >  static int lan9303_port_enable(struct dsa_switch *ds, int port,
> > --
> > 2.17.1
  
Jerry Ray Jan. 16, 2023, 6:06 p.m. UTC | #3
> > In preparing to remove the .adjust_link api, I am moving the one-time
> > initialization of the device's Turbo Mode bit into a different execution
> > path. This code clears (disables) the Turbo Mode bit which is never used
> > by this driver. Turbo Mode is a non-standard mode that would allow the
> > 100Mbps RMII interface to run at 200Mbps.
> >
> > Signed-off-by: Jerry Ray <jerry.ray@microchip.com>
> > ---
> >  drivers/net/dsa/lan9303-core.c | 15 ++++++---------
> >  1 file changed, 6 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
> > index 5a21fc96d479..50470fb09cb4 100644
> > --- a/drivers/net/dsa/lan9303-core.c
> > +++ b/drivers/net/dsa/lan9303-core.c
> > @@ -886,6 +886,12 @@ static int lan9303_check_device(struct lan9303 *chip)
> >               return ret;
> >       }
> >
> > +     /* Virtual Phy: Remove Turbo 200Mbit mode */
> > +     lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &reg);
> > +
> > +     reg &= ~LAN9303_VIRT_SPECIAL_TURBO;
> > +     regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg);
> > +
> 
> Isn't a function whose name is lan9303_check_device() being abused for
> this purpose (device initialization)?
> 
I will move this into lan9303_setup.

Regards,
Jerry.

> >       return 0;
> >  }
> >
> > @@ -1050,7 +1056,6 @@ static int lan9303_phy_write(struct dsa_switch *ds, int phy, int regnum,
> >  static void lan9303_adjust_link(struct dsa_switch *ds, int port,
> >                               struct phy_device *phydev)
> >  {
> > -     struct lan9303 *chip = ds->priv;
> >       int ctl;
> >
> >       if (!phy_is_pseudo_fixed_link(phydev))
> > @@ -1073,14 +1078,6 @@ static void lan9303_adjust_link(struct dsa_switch *ds, int port,
> >               ctl &= ~BMCR_FULLDPLX;
> >
> >       lan9303_phy_write(ds, port, MII_BMCR, ctl);
> > -
> > -     if (port == chip->phy_addr_base) {
> > -             /* Virtual Phy: Remove Turbo 200Mbit mode */
> > -             lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl);
> > -
> > -             ctl &= ~LAN9303_VIRT_SPECIAL_TURBO;
> > -             regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl);
> > -     }
> >  }
> >
> >  static int lan9303_port_enable(struct dsa_switch *ds, int port,
> > --
> > 2.17.1
  

Patch

diff --git a/drivers/net/dsa/lan9303-core.c b/drivers/net/dsa/lan9303-core.c
index 5a21fc96d479..50470fb09cb4 100644
--- a/drivers/net/dsa/lan9303-core.c
+++ b/drivers/net/dsa/lan9303-core.c
@@ -886,6 +886,12 @@  static int lan9303_check_device(struct lan9303 *chip)
 		return ret;
 	}
 
+	/* Virtual Phy: Remove Turbo 200Mbit mode */
+	lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &reg);
+
+	reg &= ~LAN9303_VIRT_SPECIAL_TURBO;
+	regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, reg);
+
 	return 0;
 }
 
@@ -1050,7 +1056,6 @@  static int lan9303_phy_write(struct dsa_switch *ds, int phy, int regnum,
 static void lan9303_adjust_link(struct dsa_switch *ds, int port,
 				struct phy_device *phydev)
 {
-	struct lan9303 *chip = ds->priv;
 	int ctl;
 
 	if (!phy_is_pseudo_fixed_link(phydev))
@@ -1073,14 +1078,6 @@  static void lan9303_adjust_link(struct dsa_switch *ds, int port,
 		ctl &= ~BMCR_FULLDPLX;
 
 	lan9303_phy_write(ds, port, MII_BMCR, ctl);
-
-	if (port == chip->phy_addr_base) {
-		/* Virtual Phy: Remove Turbo 200Mbit mode */
-		lan9303_read(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, &ctl);
-
-		ctl &= ~LAN9303_VIRT_SPECIAL_TURBO;
-		regmap_write(chip->regmap, LAN9303_VIRT_SPECIAL_CTRL, ctl);
-	}
 }
 
 static int lan9303_port_enable(struct dsa_switch *ds, int port,