diff mbox series

[net-next,v2,1/1] net: phy: dp83867: introduce critical chip default init for non-of platform

Message ID 20211013065941.2124858-2-boon.leong.ong@intel.com (mailing list archive)
State Accepted
Commit 4dc08dcc9f6f58e881fd790d800e49abee8540e1
Delegated to: Netdev Maintainers
Headers show
Series net: phy: dp83867 non-OF and loopback support | expand

Checks

Context Check Description
netdev/cover_letter success Series has a cover letter
netdev/fixes_present success Fixes tag not required for -next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 25 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files

Commit Message

Ong Boon Leong Oct. 13, 2021, 6:59 a.m. UTC
From: "Lay, Kuan Loon" <kuan.loon.lay@intel.com>

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 impedance and RX & TX internal delays are
critical and should be initialized to its default during PHY driver probe.

Tested-by: Clement <clement@intel.com>
Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
Co-developed-by: Ong Boon Leong <boon.leong.ong@intel.com>
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
---
 drivers/net/phy/dp83867.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Kurt Kanzenbach Oct. 13, 2021, 7:34 a.m. UTC | #1
On Wed Oct 13 2021, Ong Boon Leong wrote:
> From: "Lay, Kuan Loon" <kuan.loon.lay@intel.com>
>
> 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 impedance and RX & TX internal delays are
> critical and should be initialized to its default during PHY driver probe.
>
> Tested-by: Clement <clement@intel.com>
> Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
> Co-developed-by: Ong Boon Leong <boon.leong.ong@intel.com>
> Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>

Thanks!

Tested-by: Kurt Kanzenbach <kurt@linutronix.de>
diff mbox series

Patch

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 6bbc81ad295f..914619f3f0e3 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -619,6 +619,25 @@  static int dp83867_of_init(struct phy_device *phydev)
 #else
 static int dp83867_of_init(struct phy_device *phydev)
 {
+	struct dp83867_private *dp83867 = phydev->priv;
+	u16 delay;
+
+	/* For non-OF device, the RX and TX ID values are either strapped
+	 * or take from default value. So, we init RX & TX ID values here
+	 * so that the RGMIIDCTL is configured correctly later in
+	 * 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 here or else the default '0' means highest IO impedance
+	 * which is wrong.
+	 */
+	dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN / 2;
+
 	return 0;
 }
 #endif /* CONFIG_OF_MDIO */