diff mbox series

[net-next,v2,2/2] net: phy: micrel: lan8814 cable improvement errata

Message ID 20240229195220.2673049-3-horatiu.vultur@microchip.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: phy: micrel: lan8814 erratas | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 940 this patch: 940
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 956 this patch: 956
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 956 this patch: 956
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 37 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-03-01--15-00 (tests: 884)

Commit Message

Horatiu Vultur Feb. 29, 2024, 7:52 p.m. UTC
When the length of the cable is more than 100m and the lan8814 is
configured to run in 1000Base-T Slave then the register of the device
needs to be optimized.

Workaround this by setting the measure time to a value of 0xb. This
value can be set regardless of the configuration.

This issue is described in 'LAN8814 Silicon Errata and Data Sheet
Clarification' and according to that, this will not be corrected in a
future silicon revision.

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
---
 drivers/net/phy/micrel.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Arun Ramadoss March 1, 2024, 3:27 a.m. UTC | #1
Hi Horatiu,

On Thu, 2024-02-29 at 20:52 +0100, Horatiu Vultur wrote:
> When the length of the cable is more than 100m and the lan8814 is
> configured to run in 1000Base-T Slave then the register of the device
> needs to be optimized.
> 
> Workaround this by setting the measure time to a value of 0xb. This
> value can be set regardless of the configuration.
> 
> This issue is described in 'LAN8814 Silicon Errata and Data Sheet
> Clarification' and according to that, this will not be corrected in a
> future silicon revision.
> 
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---
>  drivers/net/phy/micrel.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 88cc03982bb78..788fdd54fd22d 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -117,6 +117,10 @@
>  #define LAN8814_EEE_STATE			0x38
>  #define LAN8814_EEE_STATE_MASK2P5P		BIT(10)
>  
> +#define LAN8814_PD_CONTROLS			0x9d
> +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_MASK_	GENMASK(3, 0)
> +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_VAL_	0xb

nitpick: TIME_VAL macro is very generic if it can end with specific
like TIME_VAL_100M or something similar will gives more readability.

> +
>
Horatiu Vultur March 1, 2024, 7:27 a.m. UTC | #2
The 03/01/2024 03:27, Arun Ramadoss - I17769 wrote:
> Hi Horatiu,

Hi Arun,

> 
> On Thu, 2024-02-29 at 20:52 +0100, Horatiu Vultur wrote:
> > When the length of the cable is more than 100m and the lan8814 is
> > configured to run in 1000Base-T Slave then the register of the device
> > needs to be optimized.
> > 
> > Workaround this by setting the measure time to a value of 0xb. This
> > value can be set regardless of the configuration.
> > 
> > This issue is described in 'LAN8814 Silicon Errata and Data Sheet
> > Clarification' and according to that, this will not be corrected in a
> > future silicon revision.
> > 
> > Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> > ---
> >  drivers/net/phy/micrel.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> > index 88cc03982bb78..788fdd54fd22d 100644
> > --- a/drivers/net/phy/micrel.c
> > +++ b/drivers/net/phy/micrel.c
> > @@ -117,6 +117,10 @@
> >  #define LAN8814_EEE_STATE			0x38
> >  #define LAN8814_EEE_STATE_MASK2P5P		BIT(10)
> >  
> > +#define LAN8814_PD_CONTROLS			0x9d
> > +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_MASK_	GENMASK(3, 0)
> > +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_VAL_	0xb
> 
> nitpick: TIME_VAL macro is very generic if it can end with specific
> like TIME_VAL_100M or something similar will gives more readability.

Actually I prefer to keep it like this the name if it is possible..
Because the VAL_ represents the value and MASK_ represents the mask
value. Therefore the actual bits name of the register is
LAN8814_PD_CONTROLS_PD_MEAS_TIME.

I am trying to have a naming convetion about how to define names in this
file:
<TARGET>_<REG_NAME>_<REG_BITS_NAME>

In this way it way it is easier to find in the datasheet to what it
refers to.

> 
> > +
> >
Wojciech Drewek March 1, 2024, 8:18 a.m. UTC | #3
On 29.02.2024 20:52, Horatiu Vultur wrote:
> When the length of the cable is more than 100m and the lan8814 is
> configured to run in 1000Base-T Slave then the register of the device
> needs to be optimized.
> 
> Workaround this by setting the measure time to a value of 0xb. This
> value can be set regardless of the configuration.
> 
> This issue is described in 'LAN8814 Silicon Errata and Data Sheet
> Clarification' and according to that, this will not be corrected in a
> future silicon revision.
> 
> Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
> ---

Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>

>  drivers/net/phy/micrel.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 88cc03982bb78..788fdd54fd22d 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -117,6 +117,10 @@
>  #define LAN8814_EEE_STATE			0x38
>  #define LAN8814_EEE_STATE_MASK2P5P		BIT(10)
>  
> +#define LAN8814_PD_CONTROLS			0x9d
> +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_MASK_	GENMASK(3, 0)
> +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_VAL_	0xb
> +
>  /* Represents 1ppm adjustment in 2^32 format with
>   * each nsec contains 4 clock cycles.
>   * The value is calculated as following: (1/1000000)/((2^-32)/4)
> @@ -3304,6 +3308,20 @@ static void lan8814_clear_2psp_bit(struct phy_device *phydev)
>  	lanphy_write_page_reg(phydev, 2, LAN8814_EEE_STATE, val);
>  }
>  
> +static void lan8814_update_meas_time(struct phy_device *phydev)
> +{
> +	u16 val;
> +
> +	/* By setting the measure time to a value of 0xb this will allow cables
> +	 * longer than 100m to be used. This configuration can be used
> +	 * regardless of the mode of operation of the PHY
> +	 */
> +	val = lanphy_read_page_reg(phydev, 1, LAN8814_PD_CONTROLS);
> +	val &= ~LAN8814_PD_CONTROLS_PD_MEAS_TIME_MASK_;
> +	val |= LAN8814_PD_CONTROLS_PD_MEAS_TIME_VAL_;
> +	lanphy_write_page_reg(phydev, 1, LAN8814_PD_CONTROLS, val);
> +}
> +
>  static int lan8814_probe(struct phy_device *phydev)
>  {
>  	const struct kszphy_type *type = phydev->drv->driver_data;
> @@ -3342,6 +3360,7 @@ static int lan8814_probe(struct phy_device *phydev)
>  
>  	/* Errata workarounds */
>  	lan8814_clear_2psp_bit(phydev);
> +	lan8814_update_meas_time(phydev);
>  
>  	return 0;
>  }
Jakub Kicinski March 3, 2024, 3:40 a.m. UTC | #4
On Fri, 1 Mar 2024 08:27:57 +0100 Horatiu Vultur - M31836 wrote:
> > > +#define LAN8814_PD_CONTROLS			0x9d
> > > +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_MASK_	GENMASK(3, 0)
> > > +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_VAL_	0xb  
> > 
> > nitpick: TIME_VAL macro is very generic if it can end with specific
> > like TIME_VAL_100M or something similar will gives more readability.  
> 
> Actually I prefer to keep it like this the name if it is possible..
> Because the VAL_ represents the value and MASK_ represents the mask
> value. Therefore the actual bits name of the register is
> LAN8814_PD_CONTROLS_PD_MEAS_TIME.
> 
> I am trying to have a naming convetion about how to define names in this
> file:
> <TARGET>_<REG_NAME>_<REG_BITS_NAME>

Why the trailing underscores, tho?
Horatiu Vultur March 4, 2024, 8:48 a.m. UTC | #5
The 03/02/2024 19:40, Jakub Kicinski wrote:
> 
> On Fri, 1 Mar 2024 08:27:57 +0100 Horatiu Vultur - M31836 wrote:
> > > > +#define LAN8814_PD_CONTROLS                      0x9d
> > > > +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_MASK_   GENMASK(3, 0)
> > > > +#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_VAL_    0xb
> > >
> > > nitpick: TIME_VAL macro is very generic if it can end with specific
> > > like TIME_VAL_100M or something similar will gives more readability.
> >
> > Actually I prefer to keep it like this the name if it is possible..
> > Because the VAL_ represents the value and MASK_ represents the mask
> > value. Therefore the actual bits name of the register is
> > LAN8814_PD_CONTROLS_PD_MEAS_TIME.
> >
> > I am trying to have a naming convetion about how to define names in this
> > file:
> > <TARGET>_<REG_NAME>_<REG_BITS_NAME>
> 
> Why the trailing underscores, tho?

That is not really needed. I will update this in the next version.

>
diff mbox series

Patch

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 88cc03982bb78..788fdd54fd22d 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -117,6 +117,10 @@ 
 #define LAN8814_EEE_STATE			0x38
 #define LAN8814_EEE_STATE_MASK2P5P		BIT(10)
 
+#define LAN8814_PD_CONTROLS			0x9d
+#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_MASK_	GENMASK(3, 0)
+#define LAN8814_PD_CONTROLS_PD_MEAS_TIME_VAL_	0xb
+
 /* Represents 1ppm adjustment in 2^32 format with
  * each nsec contains 4 clock cycles.
  * The value is calculated as following: (1/1000000)/((2^-32)/4)
@@ -3304,6 +3308,20 @@  static void lan8814_clear_2psp_bit(struct phy_device *phydev)
 	lanphy_write_page_reg(phydev, 2, LAN8814_EEE_STATE, val);
 }
 
+static void lan8814_update_meas_time(struct phy_device *phydev)
+{
+	u16 val;
+
+	/* By setting the measure time to a value of 0xb this will allow cables
+	 * longer than 100m to be used. This configuration can be used
+	 * regardless of the mode of operation of the PHY
+	 */
+	val = lanphy_read_page_reg(phydev, 1, LAN8814_PD_CONTROLS);
+	val &= ~LAN8814_PD_CONTROLS_PD_MEAS_TIME_MASK_;
+	val |= LAN8814_PD_CONTROLS_PD_MEAS_TIME_VAL_;
+	lanphy_write_page_reg(phydev, 1, LAN8814_PD_CONTROLS, val);
+}
+
 static int lan8814_probe(struct phy_device *phydev)
 {
 	const struct kszphy_type *type = phydev->drv->driver_data;
@@ -3342,6 +3360,7 @@  static int lan8814_probe(struct phy_device *phydev)
 
 	/* Errata workarounds */
 	lan8814_clear_2psp_bit(phydev);
+	lan8814_update_meas_time(phydev);
 
 	return 0;
 }