All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: phy: dp83867 non-OF and loopback support
@ 2021-10-13  3:41 Ong Boon Leong
  2021-10-13  3:41 ` [PATCH net-next 1/2] net: phy: dp83867: introduce critical chip default init for non-of platform Ong Boon Leong
  2021-10-13  3:41 ` [PATCH net-next 2/2] net: phy: dp83867: add generic PHY loopback Ong Boon Leong
  0 siblings, 2 replies; 6+ messages in thread
From: Ong Boon Leong @ 2021-10-13  3:41 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	Jakub Kicinski
  Cc: netdev, linux-kernel

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net-next 1/2] net: phy: dp83867: introduce critical chip default init for non-of platform
  2021-10-13  3:41 [PATCH net-next 0/2] net: phy: dp83867 non-OF and loopback support Ong Boon Leong
@ 2021-10-13  3:41 ` Ong Boon Leong
  2021-10-19 18:51   ` Andrew Lunn
  2021-10-13  3:41 ` [PATCH net-next 2/2] net: phy: dp83867: add generic PHY loopback Ong Boon Leong
  1 sibling, 1 reply; 6+ messages in thread
From: Ong Boon Leong @ 2021-10-13  3:41 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	Jakub Kicinski
  Cc: netdev, linux-kernel

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

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 6bbc81ad295f..bb4369b75179 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -619,6 +619,24 @@ 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 impedence which is wrong.
+	 */
+	dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN / 2;
+
 	return 0;
 }
 #endif /* CONFIG_OF_MDIO */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net-next 2/2] net: phy: dp83867: add generic PHY loopback
  2021-10-13  3:41 [PATCH net-next 0/2] net: phy: dp83867 non-OF and loopback support Ong Boon Leong
  2021-10-13  3:41 ` [PATCH net-next 1/2] net: phy: dp83867: introduce critical chip default init for non-of platform Ong Boon Leong
@ 2021-10-13  3:41 ` Ong Boon Leong
  2021-10-13  3:48   ` Wong Vee Khee
  1 sibling, 1 reply; 6+ messages in thread
From: Ong Boon Leong @ 2021-10-13  3:41 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	Jakub Kicinski
  Cc: netdev, linux-kernel

From: "Lay, Kuan Loon" <kuan.loon.lay@intel.com>

TI DP83867 supports loopback enabled using BMCR, so we add
genphy_loopback to the phy driver.

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

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index bb4369b75179..af47c62d6e04 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -878,6 +878,7 @@ static struct phy_driver dp83867_driver[] = {
 
 		.suspend	= genphy_suspend,
 		.resume		= genphy_resume,
+		.set_loopback	= genphy_loopback,
 	},
 };
 module_phy_driver(dp83867_driver);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 2/2] net: phy: dp83867: add generic PHY loopback
  2021-10-13  3:41 ` [PATCH net-next 2/2] net: phy: dp83867: add generic PHY loopback Ong Boon Leong
@ 2021-10-13  3:48   ` Wong Vee Khee
  2021-10-13  6:18     ` Ong, Boon Leong
  0 siblings, 1 reply; 6+ messages in thread
From: Wong Vee Khee @ 2021-10-13  3:48 UTC (permalink / raw)
  To: Ong Boon Leong
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	Jakub Kicinski, netdev, linux-kernel

On Wed, Oct 13, 2021 at 11:41:28AM +0800, Ong Boon Leong wrote:
> From: "Lay, Kuan Loon" <kuan.loon.lay@intel.com>
> 
> TI DP83867 supports loopback enabled using BMCR, so we add
> genphy_loopback to the phy driver.
> 
> Tested-by: Clement <clement@intel.com>
> Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
> Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
> ---
>  drivers/net/phy/dp83867.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
> index bb4369b75179..af47c62d6e04 100644
> --- a/drivers/net/phy/dp83867.c
> +++ b/drivers/net/phy/dp83867.c
> @@ -878,6 +878,7 @@ static struct phy_driver dp83867_driver[] = {
>  
>  		.suspend	= genphy_suspend,
>  		.resume		= genphy_resume,
> +		.set_loopback	= genphy_loopback,

Isn't this already handled in phy_loopback() in 
drivers/net/phy/phy_device.c?

>  	},
>  };
>  module_phy_driver(dp83867_driver);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH net-next 2/2] net: phy: dp83867: add generic PHY loopback
  2021-10-13  3:48   ` Wong Vee Khee
@ 2021-10-13  6:18     ` Ong, Boon Leong
  0 siblings, 0 replies; 6+ messages in thread
From: Ong, Boon Leong @ 2021-10-13  6:18 UTC (permalink / raw)
  To: Wong Vee Khee
  Cc: Andrew Lunn, Heiner Kallweit, Russell King, David S . Miller,
	Jakub Kicinski, netdev, linux-kernel

>> diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
>> index bb4369b75179..af47c62d6e04 100644
>> --- a/drivers/net/phy/dp83867.c
>> +++ b/drivers/net/phy/dp83867.c
>> @@ -878,6 +878,7 @@ static struct phy_driver dp83867_driver[] = {
>>
>>  		.suspend	= genphy_suspend,
>>  		.resume		= genphy_resume,
>> +		.set_loopback	= genphy_loopback,
>
>Isn't this already handled in phy_loopback() in
>drivers/net/phy/phy_device.c?
>
That is right. Thanks.  

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net-next 1/2] net: phy: dp83867: introduce critical chip default init for non-of platform
  2021-10-13  3:41 ` [PATCH net-next 1/2] net: phy: dp83867: introduce critical chip default init for non-of platform Ong Boon Leong
@ 2021-10-19 18:51   ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2021-10-19 18:51 UTC (permalink / raw)
  To: Ong Boon Leong
  Cc: Heiner Kallweit, Russell King, David S . Miller, Jakub Kicinski,
	netdev, linux-kernel

On Wed, Oct 13, 2021 at 11:41:27AM +0800, 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 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 <kuan.loon.lay@intel.com>
> Co-developed-by: Ong Boon Leong <boon.leong.ong@intel.com>
> Tested-by: Clement <clement@intel.com>
> Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
> ---
>  drivers/net/phy/dp83867.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
> index 6bbc81ad295f..bb4369b75179 100644
> --- a/drivers/net/phy/dp83867.c
> +++ b/drivers/net/phy/dp83867.c
> @@ -619,6 +619,24 @@ 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;

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-19 18:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13  3:41 [PATCH net-next 0/2] net: phy: dp83867 non-OF and loopback support Ong Boon Leong
2021-10-13  3:41 ` [PATCH net-next 1/2] net: phy: dp83867: introduce critical chip default init for non-of platform Ong Boon Leong
2021-10-19 18:51   ` Andrew Lunn
2021-10-13  3:41 ` [PATCH net-next 2/2] net: phy: dp83867: add generic PHY loopback Ong Boon Leong
2021-10-13  3:48   ` Wong Vee Khee
2021-10-13  6:18     ` Ong, Boon Leong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.