diff mbox series

[v2,1/2] net: phy: adin: disable diag clock & disable standby mode in config_aneg

Message ID 20201022074551.11520-1-alexandru.ardelean@analog.com
State New
Headers show
Series [v2,1/2] net: phy: adin: disable diag clock & disable standby mode in config_aneg | expand

Commit Message

Alexandru Ardelean Oct. 22, 2020, 7:45 a.m. UTC
When the PHY powers up, the diagnostics clock isn't enabled (bit 2 in
register PHY_CTRL_1 (0x0012)).
Also, the PHY is not in standby mode, so bit 13 in PHY_CTRL_3 (0x0017) is
always set at power up.

The standby mode and the diagnostics clock are both meant to be for the
cable diagnostics feature of the PHY (in phylib this would be equivalent to
the cable-test support), and for the frame-generator feature of the PHY.

In standby mode, the PHY doesn't negotiate links or manage links.

To use the cable diagnostics/test (or frame-generator), the PHY must be
first set in standby mode, so that the link operation doesn't interfere.
Then, the diagnostics clock must be enabled.

For the cable-test feature, when the operation finishes, the PHY goes into
PHY_UP state, and the config_aneg hook is called.

For the ADIN PHY, we need to make sure that during autonegotiation
configuration/setup the PHY is removed from standby mode and the
diagnostics clock is disabled, so that normal operation is resumed.

This change does that by moving the set of the ADIN1300_LINKING_EN bit (2)
in the config_aneg (to disable standby mode).
Previously, this was set in the downshift setup, because the downshift
retry value and the ADIN1300_LINKING_EN are in the same register.

And the ADIN1300_DIAG_CLK_EN bit (13) is cleared, to disable the
diagnostics clock.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---

Changelog v1 -> v2:
* updated title; updated description to better describe the diagnostics
  clock & standby mode, and what they mean for the PHY


 drivers/net/phy/adin.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski Oct. 23, 2020, 12:02 a.m. UTC | #1
On Thu, 22 Oct 2020 10:45:51 +0300 Alexandru Ardelean wrote:
> The ADIN1300/ADIN1200 support cable diagnostics using TDR.
> 
> The cable fault detection is automatically run on all four pairs looking at
> all combinations of pair faults by first putting the PHY in standby (clear
> the LINK_EN bit, PHY_CTRL_3 register, Address 0x0017) and then enabling the
> diagnostic clock (set the DIAG_CLK_EN bit, PHY_CTRL_1 register, Address
> 0x0012).
> 
> Cable diagnostics can then be run (set the CDIAG_RUN bit in the
> CDIAG_RUN register, Address 0xBA1B). The results are reported for each pair
> in the cable diagnostics results registers, CDIAG_DTLD_RSLTS_0,
> CDIAG_DTLD_RSLTS_1, CDIAG_DTLD_RSLTS_2, and CDIAG_DTLD_RSLTS_3, Address
> 0xBA1D to Address 0xBA20).
> 
> The distance to the first fault for each pair is reported in the cable
> fault distance registers, CDIAG_FLT_DIST_0, CDIAG_FLT_DIST_1,
> CDIAG_FLT_DIST_2, and CDIAG_FLT_DIST_3, Address 0xBA21 to Address 0xBA24).
> 
> This change implements support for this using phylib's cable-test support.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

# Form letter - net-next is closed

We have already sent a pull request for 5.10 and therefore net-next 
is closed for new drivers, features, and code refactoring.

Please repost when net-next reopens after 5.10-rc1 is cut.

(http://vger.kernel.org/~davem/net-next.html will not be up to date 
 this time around, sorry about that).

RFC patches sent for review only are obviously welcome at any time.
Alexandru Ardelean Oct. 23, 2020, 1:25 p.m. UTC | #2
On Fri, Oct 23, 2020 at 3:02 AM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 22 Oct 2020 10:45:51 +0300 Alexandru Ardelean wrote:
> > The ADIN1300/ADIN1200 support cable diagnostics using TDR.
> >
> > The cable fault detection is automatically run on all four pairs looking at
> > all combinations of pair faults by first putting the PHY in standby (clear
> > the LINK_EN bit, PHY_CTRL_3 register, Address 0x0017) and then enabling the
> > diagnostic clock (set the DIAG_CLK_EN bit, PHY_CTRL_1 register, Address
> > 0x0012).
> >
> > Cable diagnostics can then be run (set the CDIAG_RUN bit in the
> > CDIAG_RUN register, Address 0xBA1B). The results are reported for each pair
> > in the cable diagnostics results registers, CDIAG_DTLD_RSLTS_0,
> > CDIAG_DTLD_RSLTS_1, CDIAG_DTLD_RSLTS_2, and CDIAG_DTLD_RSLTS_3, Address
> > 0xBA1D to Address 0xBA20).
> >
> > The distance to the first fault for each pair is reported in the cable
> > fault distance registers, CDIAG_FLT_DIST_0, CDIAG_FLT_DIST_1,
> > CDIAG_FLT_DIST_2, and CDIAG_FLT_DIST_3, Address 0xBA21 to Address 0xBA24).
> >
> > This change implements support for this using phylib's cable-test support.
> >
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
>
> # Form letter - net-next is closed
>
> We have already sent a pull request for 5.10 and therefore net-next
> is closed for new drivers, features, and code refactoring.
>
> Please repost when net-next reopens after 5.10-rc1 is cut.
>

Ack.
No hurry from my side.

Thanks
Alex

> (http://vger.kernel.org/~davem/net-next.html will not be up to date
>  this time around, sorry about that).
>
> RFC patches sent for review only are obviously welcome at any time.
Andrew Lunn Oct. 23, 2020, 10:43 p.m. UTC | #3
On Thu, Oct 22, 2020 at 10:45:50AM +0300, Alexandru Ardelean wrote:
> When the PHY powers up, the diagnostics clock isn't enabled (bit 2 in
> register PHY_CTRL_1 (0x0012)).
> Also, the PHY is not in standby mode, so bit 13 in PHY_CTRL_3 (0x0017) is
> always set at power up.
> 
> The standby mode and the diagnostics clock are both meant to be for the
> cable diagnostics feature of the PHY (in phylib this would be equivalent to
> the cable-test support), and for the frame-generator feature of the PHY.
> 
> In standby mode, the PHY doesn't negotiate links or manage links.
> 
> To use the cable diagnostics/test (or frame-generator), the PHY must be
> first set in standby mode, so that the link operation doesn't interfere.
> Then, the diagnostics clock must be enabled.
> 
> For the cable-test feature, when the operation finishes, the PHY goes into
> PHY_UP state, and the config_aneg hook is called.
> 
> For the ADIN PHY, we need to make sure that during autonegotiation
> configuration/setup the PHY is removed from standby mode and the
> diagnostics clock is disabled, so that normal operation is resumed.
> 
> This change does that by moving the set of the ADIN1300_LINKING_EN bit (2)
> in the config_aneg (to disable standby mode).
> Previously, this was set in the downshift setup, because the downshift
> retry value and the ADIN1300_LINKING_EN are in the same register.
> 
> And the ADIN1300_DIAG_CLK_EN bit (13) is cleared, to disable the
> diagnostics clock.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Alexandru Ardelean Oct. 31, 2020, 12:16 p.m. UTC | #4
On Sat, Oct 24, 2020 at 1:43 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Thu, Oct 22, 2020 at 10:45:50AM +0300, Alexandru Ardelean wrote:
> > When the PHY powers up, the diagnostics clock isn't enabled (bit 2 in
> > register PHY_CTRL_1 (0x0012)).
> > Also, the PHY is not in standby mode, so bit 13 in PHY_CTRL_3 (0x0017) is
> > always set at power up.
> >
> > The standby mode and the diagnostics clock are both meant to be for the
> > cable diagnostics feature of the PHY (in phylib this would be equivalent to
> > the cable-test support), and for the frame-generator feature of the PHY.
> >
> > In standby mode, the PHY doesn't negotiate links or manage links.
> >
> > To use the cable diagnostics/test (or frame-generator), the PHY must be
> > first set in standby mode, so that the link operation doesn't interfere.
> > Then, the diagnostics clock must be enabled.
> >
> > For the cable-test feature, when the operation finishes, the PHY goes into
> > PHY_UP state, and the config_aneg hook is called.
> >
> > For the ADIN PHY, we need to make sure that during autonegotiation
> > configuration/setup the PHY is removed from standby mode and the
> > diagnostics clock is disabled, so that normal operation is resumed.
> >
> > This change does that by moving the set of the ADIN1300_LINKING_EN bit (2)
> > in the config_aneg (to disable standby mode).
> > Previously, this was set in the downshift setup, because the downshift
> > retry value and the ADIN1300_LINKING_EN are in the same register.
> >
> > And the ADIN1300_DIAG_CLK_EN bit (13) is cleared, to disable the
> > diagnostics clock.
> >
> > Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>

So, then re-send for this or just this patch ping?
Naturally, this is for net-next.
I don't mind doing either way.

Thanks
Alex

>
>     Andrew
Andrew Lunn Oct. 31, 2020, 2:36 p.m. UTC | #5
> So, then re-send for this or just this patch ping?

> Naturally, this is for net-next.

> I don't mind doing either way.


Please resend, with all the acked-by, reviewed-by added, now that
net-next is open.

	 Andrew
diff mbox series

Patch

diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
index 5bc3926c52f0..619d36685b5d 100644
--- a/drivers/net/phy/adin.c
+++ b/drivers/net/phy/adin.c
@@ -23,6 +23,7 @@ 
 #define ADIN1300_PHY_CTRL1			0x0012
 #define   ADIN1300_AUTO_MDI_EN			BIT(10)
 #define   ADIN1300_MAN_MDIX_EN			BIT(9)
+#define   ADIN1300_DIAG_CLK_EN			BIT(2)
 
 #define ADIN1300_RX_ERR_CNT			0x0014
 
@@ -326,10 +327,9 @@  static int adin_set_downshift(struct phy_device *phydev, u8 cnt)
 		return -E2BIG;
 
 	val = FIELD_PREP(ADIN1300_DOWNSPEED_RETRIES_MSK, cnt);
-	val |= ADIN1300_LINKING_EN;
 
 	rc = phy_modify(phydev, ADIN1300_PHY_CTRL3,
-			ADIN1300_LINKING_EN | ADIN1300_DOWNSPEED_RETRIES_MSK,
+			ADIN1300_DOWNSPEED_RETRIES_MSK,
 			val);
 	if (rc < 0)
 		return rc;
@@ -560,6 +560,14 @@  static int adin_config_aneg(struct phy_device *phydev)
 {
 	int ret;
 
+	ret = phy_clear_bits(phydev, ADIN1300_PHY_CTRL1, ADIN1300_DIAG_CLK_EN);
+	if (ret < 0)
+		return ret;
+
+	ret = phy_set_bits(phydev, ADIN1300_PHY_CTRL3, ADIN1300_LINKING_EN);
+	if (ret < 0)
+		return ret;
+
 	ret = adin_config_mdix(phydev);
 	if (ret)
 		return ret;