From: Ong Boon Leong <hidden> Date: 2021-10-13 03:35:24
Hi,
1/2: TI DP83867 is chosen as Ethernet PHY card that paired with intel
mGbE controller (stmmac, dw-intel) and used for non-OF platform.
It is important for DP83867 default settings (RX & TX internal
delay and IO impedence) are initialied for non-OF platform in order
to get the basic TX and RX traffics to work.
2/2: To enable loopback operation enabled/disabled using BMCR register
that is available for TI DP83867 PHY.
These two patches have been tested on Intel Elkhart Lake board with TI
DP83867 AIC card and other derivative platforms from board vendors
Thanks
Boon Leong
Lay, Kuan Loon (2):
net: phy: dp83867: introduce critical chip default init for non-of
platform
net: phy: dp83867: add generic PHY loopback
drivers/net/phy/dp83867.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
--
2.25.1
From: Ong Boon Leong <hidden> Date: 2021-10-13 03:35:25
From: "Lay, Kuan Loon" <redacted>
PHY driver dp83867 has rich supports for OF-platform to fine-tune the PHY
chip during phy configuration. However, for non-OF platform, certain PHY
tunable parameters such as IO impedence and RX & TX internal delays are
critical and should be initialized to its default during PHY driver probe.
Signed-off-by: Lay, Kuan Loon <redacted>
Co-developed-by: Ong Boon Leong <redacted>
Tested-by: Clement <redacted>
Signed-off-by: Ong Boon Leong <redacted>
---
drivers/net/phy/dp83867.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
@@ -619,6 +619,24 @@ static int dp83867_of_init(struct phy_device *phydev)#elsestaticintdp83867_of_init(structphy_device*phydev){+structdp83867_private*dp83867=phydev->priv;+u16delay;++/* For non-OF device, the RX and TX ID values are either strapped+*ortakefromdefaultvalue.So,weinitRX&TXIDvalueshere+*sothattheRGMIIDCTLisconfiguredcorrectlylaterin+*dp83867_config_init();+*/+delay=phy_read_mmd(phydev,DP83867_DEVADDR,DP83867_RGMIIDCTL);+dp83867->rx_id_delay=delay&DP83867_RGMII_RX_CLK_DELAY_MAX;+dp83867->tx_id_delay=(delay>>DP83867_RGMII_TX_CLK_DELAY_SHIFT)&+DP83867_RGMII_TX_CLK_DELAY_MAX;++/* Per datasheet, IO impedance is default to 50-ohm, so we set the same+*hereorelsethedefault'0'meanshighestIOimpedencewhichiswrong.+*/+dp83867->io_impedance=DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN/2;+return0;}#endif /* CONFIG_OF_MDIO */
From: Andrew Lunn <andrew@lunn.ch> Date: 2021-10-19 18:51:22
On Wed, Oct 13, 2021 at 11:41:27AM +0800, Ong Boon Leong wrote:
quoted hunk
From: "Lay, Kuan Loon" <redacted>
PHY driver dp83867 has rich supports for OF-platform to fine-tune the PHY
chip during phy configuration. However, for non-OF platform, certain PHY
tunable parameters such as IO impedence and RX & TX internal delays are
critical and should be initialized to its default during PHY driver probe.
Signed-off-by: Lay, Kuan Loon <redacted>
Co-developed-by: Ong Boon Leong <redacted>
Tested-by: Clement <redacted>
Signed-off-by: Ong Boon Leong <redacted>
---
drivers/net/phy/dp83867.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
@@ -619,6 +619,24 @@ static int dp83867_of_init(struct phy_device *phydev)#elsestaticintdp83867_of_init(structphy_device*phydev){+structdp83867_private*dp83867=phydev->priv;+u16delay;
So this is in the stub for when OF is disabled. What about the case
that OF is enabled? I've used DT on x86, even Intel used it for
intel,ce4100 aka falconfalls. So rather than do this in the stub, i
would look at the value of dev->of_node. If it is NULL, do this. That
should always work, and it is how other drivers deal with none OF
cases.
+ /* Per datasheet, IO impedance is default to 50-ohm, so we set the same
+ * here or else the default '0' means highest IO impedence which is wrong.
+ */
+ dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN / 2;
+
I would prefer you add a new define
DP83867_IO_MUX_CFG_IO_IMPEDANCE_DEFAULT, which then avoids this very
odd looking 1/2 the minimum.
Andrew