linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
@ 2016-11-12 23:32 Alexandru Gagniuc
  2016-11-14 21:18 ` David Miller
  0 siblings, 1 reply; 11+ messages in thread
From: Alexandru Gagniuc @ 2016-11-12 23:32 UTC (permalink / raw)
  To: f.fainelli; +Cc: gokhan, netdev, linux-kernel, Alexandru Gagniuc

With RGMII, we need a 1.5 to 2ns skew between clock and data lines. The
VSC8601 can handle this internally. While the VSC8601 can set more
fine-grained delays, the standard skew settings work out of the box.
The same heuristic is used to determine when this skew should be enabled
as in vsc824x_config_init().

Tested on custom board with AM3352 SOC and VSC801 PHY.

Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
---
 drivers/net/phy/vitesse.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 2e37eb3..7923831 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -62,6 +62,10 @@
 /* Vitesse Extended Page Access Register */
 #define MII_VSC82X4_EXT_PAGE_ACCESS	0x1f
 
+/* Vitesse VSC8601 Extended PHY Control Register 1 */
+#define MII_VSC8601_EPHY_CTL		0x17
+#define MII_VSC8601_EPHY_CTL_RGMII_SKEW	(1 << 8)
+
 #define PHY_ID_VSC8234			0x000fc620
 #define PHY_ID_VSC8244			0x000fc6c0
 #define PHY_ID_VSC8514			0x00070670
@@ -111,6 +115,31 @@ static int vsc824x_config_init(struct phy_device *phydev)
 	return err;
 }
 
+static int vsc8601_add_skew(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = phy_read(phydev, MII_VSC8601_EPHY_CTL);
+	if (ret < 0)
+		return ret;
+
+	ret |= MII_VSC8601_EPHY_CTL_RGMII_SKEW;
+	return phy_write(phydev, MII_VSC8601_EPHY_CTL, ret);
+}
+
+static int vsc8601_config_init(struct phy_device *phydev)
+{
+	int ret = 0;
+
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
+		ret = vsc8601_add_skew(phydev);
+
+	if (ret < 0)
+		return ret;
+
+	return genphy_config_init(phydev);
+}
+
 static int vsc824x_ack_interrupt(struct phy_device *phydev)
 {
 	int err = 0;
@@ -275,7 +304,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.phy_id_mask    = 0x000ffff0,
 	.features       = PHY_GBIT_FEATURES,
 	.flags          = PHY_HAS_INTERRUPT,
-	.config_init    = &genphy_config_init,
+	.config_init    = &vsc8601_config_init,
 	.config_aneg    = &genphy_config_aneg,
 	.read_status    = &genphy_read_status,
 	.ack_interrupt  = &vsc824x_ack_interrupt,
-- 
2.7.4

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

* Re: [PATCH] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-12 23:32 [PATCH] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed Alexandru Gagniuc
@ 2016-11-14 21:18 ` David Miller
  2016-11-14 21:25   ` Florian Fainelli
  0 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2016-11-14 21:18 UTC (permalink / raw)
  To: alex.g; +Cc: f.fainelli, gokhan, netdev, linux-kernel

From: Alexandru Gagniuc <alex.g@adaptrum.com>
Date: Sat, 12 Nov 2016 15:32:13 -0800

> +	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
> +		ret = vsc8601_add_skew(phydev);

I think you should use phy_interface_is_rgmii() here.

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

* Re: [PATCH] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-14 21:18 ` David Miller
@ 2016-11-14 21:25   ` Florian Fainelli
  2016-11-14 21:54     ` Alex
  0 siblings, 1 reply; 11+ messages in thread
From: Florian Fainelli @ 2016-11-14 21:25 UTC (permalink / raw)
  To: David Miller, alex.g; +Cc: gokhan, netdev, linux-kernel

On 11/14/2016 01:18 PM, David Miller wrote:
> From: Alexandru Gagniuc <alex.g@adaptrum.com>
> Date: Sat, 12 Nov 2016 15:32:13 -0800
> 
>> +	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
>> +		ret = vsc8601_add_skew(phydev);
> 
> I think you should use phy_interface_is_rgmii() here.
> 

This would include all RGMII modes, here I think the intent is to check
for PHY_INTERFACE_MODE_RGMII_ID and PHY_INTERFACE_MODE_RGMII_TXID (or
RXID),  Alexandru, what direction does the skew settings apply to?
-- 
Florian

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

* Re: [PATCH] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-14 21:25   ` Florian Fainelli
@ 2016-11-14 21:54     ` Alex
  2016-11-16  3:12       ` David Miller
  0 siblings, 1 reply; 11+ messages in thread
From: Alex @ 2016-11-14 21:54 UTC (permalink / raw)
  To: Florian Fainelli, David Miller; +Cc: gokhan, netdev, linux-kernel



On 11/14/2016 01:25 PM, Florian Fainelli wrote:
> On 11/14/2016 01:18 PM, David Miller wrote:
>> From: Alexandru Gagniuc <alex.g@adaptrum.com>
>> Date: Sat, 12 Nov 2016 15:32:13 -0800
>>
>>> +	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
>>> +		ret = vsc8601_add_skew(phydev);
>>
>> I think you should use phy_interface_is_rgmii() here.
>>
>
> This would include all RGMII modes, here I think the intent is to check
> for PHY_INTERFACE_MODE_RGMII_ID and PHY_INTERFACE_MODE_RGMII_TXID (or
> RXID),

That is correct.

>  Alexandru, what direction does the skew settings apply to?

It applies a skew in both TX and RX directions.

Alex

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

* Re: [PATCH] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-14 21:54     ` Alex
@ 2016-11-16  3:12       ` David Miller
  2016-11-16  9:02         ` [PATCH v2] " Alexandru Gagniuc
  0 siblings, 1 reply; 11+ messages in thread
From: David Miller @ 2016-11-16  3:12 UTC (permalink / raw)
  To: alex.g; +Cc: f.fainelli, gokhan, netdev, linux-kernel

From: Alex <alex.g@adaptrum.com>
Date: Mon, 14 Nov 2016 13:54:57 -0800

> 
> 
> On 11/14/2016 01:25 PM, Florian Fainelli wrote:
>> On 11/14/2016 01:18 PM, David Miller wrote:
>>> From: Alexandru Gagniuc <alex.g@adaptrum.com>
>>> Date: Sat, 12 Nov 2016 15:32:13 -0800
>>>
>>>> +	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
>>>> +		ret = vsc8601_add_skew(phydev);
>>>
>>> I think you should use phy_interface_is_rgmii() here.
>>>
>>
>> This would include all RGMII modes, here I think the intent is to
>> check
>> for PHY_INTERFACE_MODE_RGMII_ID and PHY_INTERFACE_MODE_RGMII_TXID (or
>> RXID),
> 
> That is correct.
> 
>>  Alexandru, what direction does the skew settings apply to?
> 
> It applies a skew in both TX and RX directions.

Please repost your patch, making the intent clear either in the
commit message or a code comment.

Thanks.

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

* [PATCH v2] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-16  3:12       ` David Miller
@ 2016-11-16  9:02         ` Alexandru Gagniuc
  2016-11-16 13:50           ` Andrew Lunn
  2016-11-16 22:54           ` David Miller
  0 siblings, 2 replies; 11+ messages in thread
From: Alexandru Gagniuc @ 2016-11-16  9:02 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, linux-kernel, davem, Alexandru Gagniuc

With RGMII, we need a 1.5 to 2ns skew between clock and data lines. The
VSC8601 can handle this internally. While the VSC8601 can set more
fine-grained delays, the standard skew settings work out of the box.
The same heuristic is used to determine when this skew should be enabled
as in vsc824x_config_init().

Tested on custom board with AM3352 SOC and VSC801 PHY.

Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
---
Changes since v1:
 * Added comment detailing applicability to different RGMII interfaces.

 drivers/net/phy/vitesse.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
index 2e37eb3..24b4a09 100644
--- a/drivers/net/phy/vitesse.c
+++ b/drivers/net/phy/vitesse.c
@@ -62,6 +62,10 @@
 /* Vitesse Extended Page Access Register */
 #define MII_VSC82X4_EXT_PAGE_ACCESS	0x1f
 
+/* Vitesse VSC8601 Extended PHY Control Register 1 */
+#define MII_VSC8601_EPHY_CTL		0x17
+#define MII_VSC8601_EPHY_CTL_RGMII_SKEW	(1 << 8)
+
 #define PHY_ID_VSC8234			0x000fc620
 #define PHY_ID_VSC8244			0x000fc6c0
 #define PHY_ID_VSC8514			0x00070670
@@ -111,6 +115,34 @@ static int vsc824x_config_init(struct phy_device *phydev)
 	return err;
 }
 
+/* This adds a skew for both TX and RX clocks, so the skew should only be
+ * applied to "rgmii-id" interfaces. It may not work as expected
+ * on "rgmii-txid", "rgmii-rxid" or "rgmii" interfaces. */
+static int vsc8601_add_skew(struct phy_device *phydev)
+{
+	int ret;
+
+	ret = phy_read(phydev, MII_VSC8601_EPHY_CTL);
+	if (ret < 0)
+		return ret;
+
+	ret |= MII_VSC8601_EPHY_CTL_RGMII_SKEW;
+	return phy_write(phydev, MII_VSC8601_EPHY_CTL, ret);
+}
+
+static int vsc8601_config_init(struct phy_device *phydev)
+{
+	int ret = 0;
+
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
+		ret = vsc8601_add_skew(phydev);
+
+	if (ret < 0)
+		return ret;
+
+	return genphy_config_init(phydev);
+}
+
 static int vsc824x_ack_interrupt(struct phy_device *phydev)
 {
 	int err = 0;
@@ -275,7 +307,7 @@ static struct phy_driver vsc82xx_driver[] = {
 	.phy_id_mask    = 0x000ffff0,
 	.features       = PHY_GBIT_FEATURES,
 	.flags          = PHY_HAS_INTERRUPT,
-	.config_init    = &genphy_config_init,
+	.config_init    = &vsc8601_config_init,
 	.config_aneg    = &genphy_config_aneg,
 	.read_status    = &genphy_read_status,
 	.ack_interrupt  = &vsc824x_ack_interrupt,
-- 
2.7.4

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

* Re: [PATCH v2] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-16  9:02         ` [PATCH v2] " Alexandru Gagniuc
@ 2016-11-16 13:50           ` Andrew Lunn
  2016-11-16 16:44             ` Alex
  2016-11-16 22:54           ` David Miller
  1 sibling, 1 reply; 11+ messages in thread
From: Andrew Lunn @ 2016-11-16 13:50 UTC (permalink / raw)
  To: Alexandru Gagniuc; +Cc: f.fainelli, netdev, linux-kernel, davem

On Wed, Nov 16, 2016 at 01:02:33AM -0800, Alexandru Gagniuc wrote:
> With RGMII, we need a 1.5 to 2ns skew between clock and data lines. The
> VSC8601 can handle this internally. While the VSC8601 can set more
> fine-grained delays, the standard skew settings work out of the box.
> The same heuristic is used to determine when this skew should be enabled
> as in vsc824x_config_init().
> 
> Tested on custom board with AM3352 SOC and VSC801 PHY.
> 
> Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
> ---
> Changes since v1:
>  * Added comment detailing applicability to different RGMII interfaces.
> 
>  drivers/net/phy/vitesse.c | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c
> index 2e37eb3..24b4a09 100644
> --- a/drivers/net/phy/vitesse.c
> +++ b/drivers/net/phy/vitesse.c
> @@ -62,6 +62,10 @@
>  /* Vitesse Extended Page Access Register */
>  #define MII_VSC82X4_EXT_PAGE_ACCESS	0x1f
>  
> +/* Vitesse VSC8601 Extended PHY Control Register 1 */
> +#define MII_VSC8601_EPHY_CTL		0x17
> +#define MII_VSC8601_EPHY_CTL_RGMII_SKEW	(1 << 8)
> +
>  #define PHY_ID_VSC8234			0x000fc620
>  #define PHY_ID_VSC8244			0x000fc6c0
>  #define PHY_ID_VSC8514			0x00070670
> @@ -111,6 +115,34 @@ static int vsc824x_config_init(struct phy_device *phydev)
>  	return err;
>  }
>  
> +/* This adds a skew for both TX and RX clocks, so the skew should only be
> + * applied to "rgmii-id" interfaces. It may not work as expected
> + * on "rgmii-txid", "rgmii-rxid" or "rgmii" interfaces. */

Hi Alexandru

You should be able to make "rgmii" work as expected. If that is the
phy mode, disable the skew.

    Andrew

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

* Re: [PATCH v2] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-16 13:50           ` Andrew Lunn
@ 2016-11-16 16:44             ` Alex
  2016-11-16 16:54               ` Andrew Lunn
  0 siblings, 1 reply; 11+ messages in thread
From: Alex @ 2016-11-16 16:44 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: f.fainelli, netdev, linux-kernel, davem, Gokhan Cosgul



On 11/16/2016 05:50 AM, Andrew Lunn wrote:
> On Wed, Nov 16, 2016 at 01:02:33AM -0800, Alexandru Gagniuc wrote:
>> With RGMII, we need a 1.5 to 2ns skew between clock and data lines. The
>> VSC8601 can handle this internally. While the VSC8601 can set more
>> fine-grained delays, the standard skew settings work out of the box.
>> The same heuristic is used to determine when this skew should be enabled
>> as in vsc824x_config_init().
>>
>> +/* This adds a skew for both TX and RX clocks, so the skew should only be
>> + * applied to "rgmii-id" interfaces. It may not work as expected
>> + * on "rgmii-txid", "rgmii-rxid" or "rgmii" interfaces. */
>
> Hi Alexandru
>
> You should be able to make "rgmii" work as expected. If that is the
> phy mode, disable the skew.

And that's exactly the implemented behavior. See vsc8601_config_init() 
below.

Alex

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

* Re: [PATCH v2] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-16 16:44             ` Alex
@ 2016-11-16 16:54               ` Andrew Lunn
  2016-11-16 17:10                 ` Alex
  0 siblings, 1 reply; 11+ messages in thread
From: Andrew Lunn @ 2016-11-16 16:54 UTC (permalink / raw)
  To: Alex; +Cc: f.fainelli, netdev, linux-kernel, davem, Gokhan Cosgul

On Wed, Nov 16, 2016 at 08:44:30AM -0800, Alex wrote:
> 
> 
> On 11/16/2016 05:50 AM, Andrew Lunn wrote:
> >On Wed, Nov 16, 2016 at 01:02:33AM -0800, Alexandru Gagniuc wrote:
> >>With RGMII, we need a 1.5 to 2ns skew between clock and data lines. The
> >>VSC8601 can handle this internally. While the VSC8601 can set more
> >>fine-grained delays, the standard skew settings work out of the box.
> >>The same heuristic is used to determine when this skew should be enabled
> >>as in vsc824x_config_init().
> >>
> >>+/* This adds a skew for both TX and RX clocks, so the skew should only be
> >>+ * applied to "rgmii-id" interfaces. It may not work as expected
> >>+ * on "rgmii-txid", "rgmii-rxid" or "rgmii" interfaces. */
> >
> >Hi Alexandru
> >
> >You should be able to make "rgmii" work as expected. If that is the
> >phy mode, disable the skew.
> 
> And that's exactly the implemented behavior. See
> vsc8601_config_init() below.

I don't think so. vsc8601_config_init() will not cause the skew to be
cleared if the phy-mode is "rgmii" and something else like the
bootloader could of set the skew. So saying that "rgmii" might not
work as expected is true. But with a minor change, you can make it
work as expected.

	Andrew

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

* Re: [PATCH v2] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-16 16:54               ` Andrew Lunn
@ 2016-11-16 17:10                 ` Alex
  0 siblings, 0 replies; 11+ messages in thread
From: Alex @ 2016-11-16 17:10 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: f.fainelli, netdev, linux-kernel, davem, Gokhan Cosgul



On 11/16/2016 08:54 AM, Andrew Lunn wrote:
> On Wed, Nov 16, 2016 at 08:44:30AM -0800, Alex wrote:
>>
>>
>> On 11/16/2016 05:50 AM, Andrew Lunn wrote:
>>> On Wed, Nov 16, 2016 at 01:02:33AM -0800, Alexandru Gagniuc wrote:
>>>> With RGMII, we need a 1.5 to 2ns skew between clock and data lines. The
>>>> VSC8601 can handle this internally. While the VSC8601 can set more
>>>> fine-grained delays, the standard skew settings work out of the box.
>>>> The same heuristic is used to determine when this skew should be enabled
>>>> as in vsc824x_config_init().
>>>>
>>>> +/* This adds a skew for both TX and RX clocks, so the skew should only be
>>>> + * applied to "rgmii-id" interfaces. It may not work as expected
>>>> + * on "rgmii-txid", "rgmii-rxid" or "rgmii" interfaces. */
>>>
>>> Hi Alexandru
>>>
>>> You should be able to make "rgmii" work as expected. If that is the
>>> phy mode, disable the skew.
>>
>> And that's exactly the implemented behavior. See
>> vsc8601_config_init() below.
>
> I don't think so. vsc8601_config_init() will not cause the skew to be
> cleared if the phy-mode is "rgmii" and something else like the
> bootloader could of set the skew. So saying that "rgmii" might not
> work as expected is true. But with a minor change, you can make it
> work as expected.

That's not within the scope of this change. The scope is to make 
rgmii-id work. Any additional changes would be untested.

Alex

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

* Re: [PATCH v2] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed
  2016-11-16  9:02         ` [PATCH v2] " Alexandru Gagniuc
  2016-11-16 13:50           ` Andrew Lunn
@ 2016-11-16 22:54           ` David Miller
  1 sibling, 0 replies; 11+ messages in thread
From: David Miller @ 2016-11-16 22:54 UTC (permalink / raw)
  To: alex.g; +Cc: f.fainelli, netdev, linux-kernel

From: Alexandru Gagniuc <alex.g@adaptrum.com>
Date: Wed, 16 Nov 2016 01:02:33 -0800

> With RGMII, we need a 1.5 to 2ns skew between clock and data lines. The
> VSC8601 can handle this internally. While the VSC8601 can set more
> fine-grained delays, the standard skew settings work out of the box.
> The same heuristic is used to determine when this skew should be enabled
> as in vsc824x_config_init().
> 
> Tested on custom board with AM3352 SOC and VSC801 PHY.
> 
> Signed-off-by: Alexandru Gagniuc <alex.g@adaptrum.com>
> ---
> Changes since v1:
>  * Added comment detailing applicability to different RGMII interfaces.

Applied.

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

end of thread, other threads:[~2016-11-16 22:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-12 23:32 [PATCH] net/phy/vitesse: Configure RGMII skew on VSC8601, if needed Alexandru Gagniuc
2016-11-14 21:18 ` David Miller
2016-11-14 21:25   ` Florian Fainelli
2016-11-14 21:54     ` Alex
2016-11-16  3:12       ` David Miller
2016-11-16  9:02         ` [PATCH v2] " Alexandru Gagniuc
2016-11-16 13:50           ` Andrew Lunn
2016-11-16 16:44             ` Alex
2016-11-16 16:54               ` Andrew Lunn
2016-11-16 17:10                 ` Alex
2016-11-16 22:54           ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).