Re: [PATCH 14/16] net: phy: adin: make sure down-speed auto-neg is enabled

2019-08-05 Thread Ardelean, Alexandru
On Tue, 2019-08-06 at 07:52 +0200, Heiner Kallweit wrote:
> [External]
> 
> On 05.08.2019 18:54, Alexandru Ardelean wrote:
> > Down-speed auto-negotiation may not always be enabled, in which case the
> > PHY won't down-shift to 100 or 10 during auto-negotiation.
> > 
> > Signed-off-by: Alexandru Ardelean 
> > ---
> >  drivers/net/phy/adin.c | 27 +++
> >  1 file changed, 27 insertions(+)
> > 
> > diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
> > index 86848444bd98..a1f3456a8504 100644
> > --- a/drivers/net/phy/adin.c
> > +++ b/drivers/net/phy/adin.c
> > @@ -32,6 +32,13 @@
> >  #define   ADIN1300_NRG_PD_TX_ENBIT(2)
> >  #define   ADIN1300_NRG_PD_STATUS   BIT(1)
> >  
> > +#define ADIN1300_PHY_CTRL2 0x0016
> > +#define   ADIN1300_DOWNSPEED_AN_100_EN BIT(11)
> > +#define   ADIN1300_DOWNSPEED_AN_10_EN  BIT(10)
> > +#define   ADIN1300_GROUP_MDIO_EN   BIT(6)
> > +#define   ADIN1300_DOWNSPEEDS_EN   \
> > +   (ADIN1300_DOWNSPEED_AN_100_EN | ADIN1300_DOWNSPEED_AN_10_EN)
> > +
> >  #define ADIN1300_INT_MASK_REG  0x0018
> >  #define   ADIN1300_INT_MDIO_SYNC_ENBIT(9)
> >  #define   ADIN1300_INT_ANEG_STAT_CHNG_EN   BIT(8)
> > @@ -425,6 +432,22 @@ static int adin_config_mdix(struct phy_device *phydev)
> > return phy_write(phydev, ADIN1300_PHY_CTRL1, reg);
> >  }
> >  
> > +static int adin_config_downspeeds(struct phy_device *phydev)
> > +{
> > +   int reg;
> > +
> > +   reg = phy_read(phydev, ADIN1300_PHY_CTRL2);
> > +   if (reg < 0)
> > +   return reg;
> > +
> > +   if ((reg & ADIN1300_DOWNSPEEDS_EN) == ADIN1300_DOWNSPEEDS_EN)
> > +   return 0;
> > +
> > +   reg |= ADIN1300_DOWNSPEEDS_EN;
> > +
> > +   return phy_write(phydev, ADIN1300_PHY_CTRL2, reg);
> 
> Using phy_set_bits() would be easier.

ack;
missed this;

thanks

> 
> > +}
> > +
> >  static int adin_config_aneg(struct phy_device *phydev)
> >  {
> > int ret;
> > @@ -433,6 +456,10 @@ static int adin_config_aneg(struct phy_device *phydev)
> > if (ret)
> > return ret;
> >  
> > +   ret = adin_config_downspeeds(phydev);
> > +   if (ret < 0)
> > +   return ret;
> > +
> > return genphy_config_aneg(phydev);
> >  }
> >  
> > 


Re: [PATCH 14/16] net: phy: adin: make sure down-speed auto-neg is enabled

2019-08-05 Thread Ardelean, Alexandru
On Mon, 2019-08-05 at 17:22 +0200, Andrew Lunn wrote:
> [External]
> 
> On Mon, Aug 05, 2019 at 07:54:51PM +0300, Alexandru Ardelean wrote:
> > Down-speed auto-negotiation may not always be enabled, in which case the
> > PHY won't down-shift to 100 or 10 during auto-negotiation.
> 
> Please look at how the marvell driver enables and configures this
> feature. Ideally we want all PHY drivers to use the same configuration
> API for features like this.

ack

> 
> Andrew


Re: [PATCH 14/16] net: phy: adin: make sure down-speed auto-neg is enabled

2019-08-05 Thread Heiner Kallweit
On 05.08.2019 18:54, Alexandru Ardelean wrote:
> Down-speed auto-negotiation may not always be enabled, in which case the
> PHY won't down-shift to 100 or 10 during auto-negotiation.
> 
> Signed-off-by: Alexandru Ardelean 
> ---
>  drivers/net/phy/adin.c | 27 +++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
> index 86848444bd98..a1f3456a8504 100644
> --- a/drivers/net/phy/adin.c
> +++ b/drivers/net/phy/adin.c
> @@ -32,6 +32,13 @@
>  #define   ADIN1300_NRG_PD_TX_EN  BIT(2)
>  #define   ADIN1300_NRG_PD_STATUS BIT(1)
>  
> +#define ADIN1300_PHY_CTRL2   0x0016
> +#define   ADIN1300_DOWNSPEED_AN_100_EN   BIT(11)
> +#define   ADIN1300_DOWNSPEED_AN_10_ENBIT(10)
> +#define   ADIN1300_GROUP_MDIO_EN BIT(6)
> +#define   ADIN1300_DOWNSPEEDS_EN \
> + (ADIN1300_DOWNSPEED_AN_100_EN | ADIN1300_DOWNSPEED_AN_10_EN)
> +
>  #define ADIN1300_INT_MASK_REG0x0018
>  #define   ADIN1300_INT_MDIO_SYNC_EN  BIT(9)
>  #define   ADIN1300_INT_ANEG_STAT_CHNG_EN BIT(8)
> @@ -425,6 +432,22 @@ static int adin_config_mdix(struct phy_device *phydev)
>   return phy_write(phydev, ADIN1300_PHY_CTRL1, reg);
>  }
>  
> +static int adin_config_downspeeds(struct phy_device *phydev)
> +{
> + int reg;
> +
> + reg = phy_read(phydev, ADIN1300_PHY_CTRL2);
> + if (reg < 0)
> + return reg;
> +
> + if ((reg & ADIN1300_DOWNSPEEDS_EN) == ADIN1300_DOWNSPEEDS_EN)
> + return 0;
> +
> + reg |= ADIN1300_DOWNSPEEDS_EN;
> +
> + return phy_write(phydev, ADIN1300_PHY_CTRL2, reg);

Using phy_set_bits() would be easier.

> +}
> +
>  static int adin_config_aneg(struct phy_device *phydev)
>  {
>   int ret;
> @@ -433,6 +456,10 @@ static int adin_config_aneg(struct phy_device *phydev)
>   if (ret)
>   return ret;
>  
> + ret = adin_config_downspeeds(phydev);
> + if (ret < 0)
> + return ret;
> +
>   return genphy_config_aneg(phydev);
>  }
>  
> 



Re: [PATCH 14/16] net: phy: adin: make sure down-speed auto-neg is enabled

2019-08-05 Thread Andrew Lunn
On Mon, Aug 05, 2019 at 07:54:51PM +0300, Alexandru Ardelean wrote:
> Down-speed auto-negotiation may not always be enabled, in which case the
> PHY won't down-shift to 100 or 10 during auto-negotiation.

Please look at how the marvell driver enables and configures this
feature. Ideally we want all PHY drivers to use the same configuration
API for features like this.

Andrew


[PATCH 14/16] net: phy: adin: make sure down-speed auto-neg is enabled

2019-08-05 Thread Alexandru Ardelean
Down-speed auto-negotiation may not always be enabled, in which case the
PHY won't down-shift to 100 or 10 during auto-negotiation.

Signed-off-by: Alexandru Ardelean 
---
 drivers/net/phy/adin.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
index 86848444bd98..a1f3456a8504 100644
--- a/drivers/net/phy/adin.c
+++ b/drivers/net/phy/adin.c
@@ -32,6 +32,13 @@
 #define   ADIN1300_NRG_PD_TX_ENBIT(2)
 #define   ADIN1300_NRG_PD_STATUS   BIT(1)
 
+#define ADIN1300_PHY_CTRL2 0x0016
+#define   ADIN1300_DOWNSPEED_AN_100_EN BIT(11)
+#define   ADIN1300_DOWNSPEED_AN_10_EN  BIT(10)
+#define   ADIN1300_GROUP_MDIO_EN   BIT(6)
+#define   ADIN1300_DOWNSPEEDS_EN   \
+   (ADIN1300_DOWNSPEED_AN_100_EN | ADIN1300_DOWNSPEED_AN_10_EN)
+
 #define ADIN1300_INT_MASK_REG  0x0018
 #define   ADIN1300_INT_MDIO_SYNC_ENBIT(9)
 #define   ADIN1300_INT_ANEG_STAT_CHNG_EN   BIT(8)
@@ -425,6 +432,22 @@ static int adin_config_mdix(struct phy_device *phydev)
return phy_write(phydev, ADIN1300_PHY_CTRL1, reg);
 }
 
+static int adin_config_downspeeds(struct phy_device *phydev)
+{
+   int reg;
+
+   reg = phy_read(phydev, ADIN1300_PHY_CTRL2);
+   if (reg < 0)
+   return reg;
+
+   if ((reg & ADIN1300_DOWNSPEEDS_EN) == ADIN1300_DOWNSPEEDS_EN)
+   return 0;
+
+   reg |= ADIN1300_DOWNSPEEDS_EN;
+
+   return phy_write(phydev, ADIN1300_PHY_CTRL2, reg);
+}
+
 static int adin_config_aneg(struct phy_device *phydev)
 {
int ret;
@@ -433,6 +456,10 @@ static int adin_config_aneg(struct phy_device *phydev)
if (ret)
return ret;
 
+   ret = adin_config_downspeeds(phydev);
+   if (ret < 0)
+   return ret;
+
return genphy_config_aneg(phydev);
 }
 
-- 
2.20.1