This patch adds support for enabling or disabling the port mirroring
(at CFG4 register) feature of the DP83867 TI's PHY device.
One use case is when bootstrap configuration enables this feature (because
of e.g. LED wiring) so then one needs to disable it in software
(u-boot/Linux).
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
Changes for v2:
- use "net-phy-lane-swap" and "net-phy-lane-no-swap" generic PHY properties.
instead of TI specific one
---
drivers/net/phy/dp83867.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
The DP83867 when not properly bootstrapped - especially with LED_0 pin -
can enter N/A MODE4 for "port mirroring" feature.
To provide normal operation of the PHY, one needs not only to explicitly
disable the port mirroring feature, but as well stop some IC internal
testing (which disables RGMII communication).
To do that the STRAP_STS1 (0x006E) register must be read and RESERVED bit
11 examined. When it is set, the another RESERVED bit (11) at PHYCR
(0x0010) register must be clear to disable testing mode and enable RGMII
communication.
Thorough explanation of the problem can be found at following e2e thread:
"DP83867IR: Problem with RESERVED bits in PHY Control Register (PHYCR) -
Linux driver"
https://e2e.ti.com/support/interface/ethernet/f/903/p/571313/2096954#2096954
Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
drivers/net/phy/dp83867.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
@@ -191,7 +196,7 @@ static int dp83867_of_init(struct phy_device *phydev)staticintdp83867_config_init(structphy_device*phydev){structdp83867_private*dp83867;-intret,val;+intret,val,bs;u16delay;if(!phydev->priv){
@@ -214,6 +219,22 @@ static int dp83867_config_init(struct phy_device *phydev)returnval;val&=~DP83867_PHYCR_FIFO_DEPTH_MASK;val|=(dp83867->fifo_depth<<DP83867_PHYCR_FIFO_DEPTH_SHIFT);++/* The code below checks if "port mirroring" N/A MODE4 has been+*enabledduringpoweronbootstrap.+*+*SuchN/AmodeenabledbymistakecanputPHYICinsome+*internaltestingmodeanddisableRGMIItransmission.+*+*InthisparticularcaseoneneedstocheckSTRAP_STS1+*register'sbit11(markedasRESERVED).+*/++bs=phy_read_mmd_indirect(phydev,DP83867_STRAP_STS1,+DP83867_DEVADDR);+if(bs&DP83867_STRAP_STS1_RESERVED)+val&=~DP83867_PHYCR_RESERVED_MASK;+ret=phy_write(phydev,MII_DP83867_PHYCTRL,val);if(ret)returnret;
From: Andrew Lunn <andrew@lunn.ch> Date: 2017-02-04 17:33:19
On Sat, Feb 04, 2017 at 05:02:11PM +0100, Lukasz Majewski wrote:
This patch adds support for enabling or disabling the port mirroring
(at CFG4 register) feature of the DP83867 TI's PHY device.
As we discussed before, "port mirroring" is bad naming. Yes, we should
use it, because that is what the datasheet calls this feature. But the
commit message should also contain a description of what this means,
and reference that the linux name for this concept is lane swapping.
+enum {
Maybe give the 0 value a name. DP83867_PORT_MIRROING_KEEP?
That extra enum value can then make this more obvious:
if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP)
dp83867_config_port_mirroring(phydev);
On the first reading of the patch, i though you were setting mirroring
on/off under all conditions, but in fact you don't. This makes it
clearer.
Thanks
Andrew
That extra enum value can then make this more obvious:
if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP)
dp83867_config_port_mirroring(phydev);
On the first reading of the patch, i though you were setting mirroring
on/off under all conditions, but in fact you don't. This makes it
clearer.
Ok. I see your point.
Thanks
Andrew
Thanks for review :-)
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de