devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: ti cpsw ethernet: allow reading phy interface mode from DT
@ 2012-09-26 17:24 Daniel Mack
  2012-09-26 17:24 ` [PATCH 2/2] net: ti cpsw ethernet: set IFCTL_{A,B} bits for RMII mode Daniel Mack
       [not found] ` <1348680268-8194-1-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Mack @ 2012-09-26 17:24 UTC (permalink / raw)
  To: netdev
  Cc: devicetree-discuss, Daniel Mack, Mugunthan V N, Vaibhav Hiremath,
	David S. Miller

Allow users to specify the phy interface of the CPSW slaves. The new
node parameter is called "phy_if_mode" and is optional. The original
behaviour of the driver is preserved when not given.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: David S. Miller <davem@davemloft.net>
---
 Documentation/devicetree/bindings/net/cpsw.txt | 3 +++
 drivers/net/ethernet/ti/cpsw.c                 | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
index dcaabe9..d87f7d2 100644
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -25,6 +25,8 @@ Required properties:
 - slave_reg_ofs		: Specifies slave register offset
 - sliver_reg_ofs	: Specifies slave sliver register offset
 - phy_id		: Specifies slave phy id
+- phy_if_mode		: Specified slave phy interface mode (optional)
+			  (one of the PHY_INTERFACE_MODE_* as numerical value)
 - mac-address		: Specifies slave MAC address
 
 Optional properties:
@@ -62,6 +64,7 @@ Examples:
 			slave_reg_ofs = <0x208>;
 			sliver_reg_ofs = <0xd80>;
 			phy_id = "davinci_mdio.16:00";
+			phy_if_mode = <6>; /* PHY_INTERFACE_MODE_RGMII */
 			/* Filled in by U-Boot */
 			mac-address = [ 00 00 00 00 00 00 ];
 		};
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index aa78168..3d7594e 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -850,6 +850,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
 		}
 		slave_data->sliver_reg_ofs = prop;
 
+		if (!of_property_read_u32(slave_node, "phy_if_mode", &prop))
+			slave_data->phy_if = prop;
+
 		mac_addr = of_get_mac_address(slave_node);
 		if (mac_addr)
 			memcpy(slave_data->mac_addr, mac_addr, ETH_ALEN);
-- 
1.7.11.4

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

* [PATCH 2/2] net: ti cpsw ethernet: set IFCTL_{A,B} bits for RMII mode
  2012-09-26 17:24 [PATCH 1/2] net: ti cpsw ethernet: allow reading phy interface mode from DT Daniel Mack
@ 2012-09-26 17:24 ` Daniel Mack
  2012-09-26 18:50   ` N, Mugunthan V
       [not found] ` <1348680268-8194-1-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Mack @ 2012-09-26 17:24 UTC (permalink / raw)
  To: netdev
  Cc: devicetree-discuss, Daniel Mack, Mugunthan V N, Vaibhav Hiremath,
	David S. Miller

For RMII mode operation in 100Mbps, the CPSW needs to set the
IFCTL_A / IFCTL_B bits in the MACCONTROL register.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: David S. Miller <davem@davemloft.net>
---
 drivers/net/ethernet/ti/cpsw.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 3d7594e..d88dbfa 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -386,6 +386,12 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave,
 			mac_control |= BIT(7);	/* GIGABITEN	*/
 		if (phy->duplex)
 			mac_control |= BIT(0);	/* FULLDUPLEXEN	*/
+
+		/* set speed_in input in case RMII mode is used in >10Mbps */
+		if (phy->speed > 10 && slave->slave_num < 2 &&
+		    phy->interface == PHY_INTERFACE_MODE_RMII)
+			mac_control |= BIT(15 + slave->slave_num);
+
 		*link = true;
 	} else {
 		mac_control = 0;
-- 
1.7.11.4

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

* RE: [PATCH 2/2] net: ti cpsw ethernet: set IFCTL_{A,B} bits for RMII mode
  2012-09-26 17:24 ` [PATCH 2/2] net: ti cpsw ethernet: set IFCTL_{A,B} bits for RMII mode Daniel Mack
@ 2012-09-26 18:50   ` N, Mugunthan V
  2012-09-27 11:42     ` Daniel Mack
  0 siblings, 1 reply; 7+ messages in thread
From: N, Mugunthan V @ 2012-09-26 18:50 UTC (permalink / raw)
  To: Daniel Mack, netdev
  Cc: devicetree-discuss, Hiremath, Vaibhav, David S. Miller

> -----Original Message-----
> From: Daniel Mack [mailto:zonque@gmail.com]
> Sent: Wednesday, September 26, 2012 10:54 PM
> To: netdev@vger.kernel.org
> Cc: devicetree-discuss@lists.ozlabs.org; Daniel Mack; N, Mugunthan V;
> Hiremath, Vaibhav; David S. Miller
> Subject: [PATCH 2/2] net: ti cpsw ethernet: set IFCTL_{A,B} bits for
> RMII mode
> 
> For RMII mode operation in 100Mbps, the CPSW needs to set the
> IFCTL_A / IFCTL_B bits in the MACCONTROL register.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>
> Cc: Mugunthan V N <mugunthanvnm@ti.com>
> Cc: Vaibhav Hiremath <hvaibhav@ti.com>
> Cc: David S. Miller <davem@davemloft.net>
> ---
>  drivers/net/ethernet/ti/cpsw.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/ti/cpsw.c
> b/drivers/net/ethernet/ti/cpsw.c
> index 3d7594e..d88dbfa 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -386,6 +386,12 @@ static void _cpsw_adjust_link(struct cpsw_slave
> *slave,
>  			mac_control |= BIT(7);	/* GIGABITEN	*/
>  		if (phy->duplex)
>  			mac_control |= BIT(0);	/* FULLDUPLEXEN	*/
> +
> +		/* set speed_in input in case RMII mode is used in >10Mbps
> */
> +		if (phy->speed > 10 && slave->slave_num < 2 &&
> +		    phy->interface == PHY_INTERFACE_MODE_RMII)
> +			mac_control |= BIT(15 + slave->slave_num);

Mac control register is separate for both the slaves and has same bit definitions,
Bit 15 has to be set for 100Mbps link for RMII and RGMII Phy interface to control
the RMII/RGMII gasket and in GMII this bit is Un-used by CPSW.
For slave 1, Bit 16 is set with the above code which is not used control the
RMII/RGMII gasket control. So it is not required to pass the Phy mode from DT.
This patch has to be reworked to set Bit 15 with any Phy mode connected.

The original driver present was tested with GMII (Beagle Bone A5) and
RGMII (AM3358 EVM) phy , but CPSW works fine without setting this bit in
RGMII phymode so this issue was not caught in testing.

Regards
Mugunthan V N

> +
>  		*link = true;
>  	} else {
>  		mac_control = 0;
> --
> 1.7.11.4

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

* Re: [PATCH 2/2] net: ti cpsw ethernet: set IFCTL_{A,B} bits for RMII mode
  2012-09-26 18:50   ` N, Mugunthan V
@ 2012-09-27 11:42     ` Daniel Mack
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Mack @ 2012-09-27 11:42 UTC (permalink / raw)
  To: N, Mugunthan V
  Cc: netdev, devicetree-discuss, Hiremath, Vaibhav, David S. Miller

On 26.09.2012 20:50, N, Mugunthan V wrote:
>> For RMII mode operation in 100Mbps, the CPSW needs to set the
>> IFCTL_A / IFCTL_B bits in the MACCONTROL register.
>>
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>> Cc: Mugunthan V N <mugunthanvnm@ti.com>
>> Cc: Vaibhav Hiremath <hvaibhav@ti.com>
>> Cc: David S. Miller <davem@davemloft.net>
>> ---
>>  drivers/net/ethernet/ti/cpsw.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/ti/cpsw.c
>> b/drivers/net/ethernet/ti/cpsw.c
>> index 3d7594e..d88dbfa 100644
>> --- a/drivers/net/ethernet/ti/cpsw.c
>> +++ b/drivers/net/ethernet/ti/cpsw.c
>> @@ -386,6 +386,12 @@ static void _cpsw_adjust_link(struct cpsw_slave
>> *slave,
>>  			mac_control |= BIT(7);	/* GIGABITEN	*/
>>  		if (phy->duplex)
>>  			mac_control |= BIT(0);	/* FULLDUPLEXEN	*/
>> +
>> +		/* set speed_in input in case RMII mode is used in >10Mbps
>> */
>> +		if (phy->speed > 10 && slave->slave_num < 2 &&
>> +		    phy->interface == PHY_INTERFACE_MODE_RMII)
>> +			mac_control |= BIT(15 + slave->slave_num);
> 
> Mac control register is separate for both the slaves and has same bit definitions,
> Bit 15 has to be set for 100Mbps link for RMII and RGMII Phy interface to control
> the RMII/RGMII gasket and in GMII this bit is Un-used by CPSW.
> For slave 1, Bit 16 is set with the above code which is not used control the
> RMII/RGMII gasket control. So it is not required to pass the Phy mode from DT.
> This patch has to be reworked to set Bit 15 with any Phy mode connected.

Hmm, that's interesting. I read the datasheet differently, but I believe
you're right.

> The original driver present was tested with GMII (Beagle Bone A5) and
> RGMII (AM3358 EVM) phy , but CPSW works fine without setting this bit in
> RGMII phymode so this issue was not caught in testing.

Yes, it used to work fine for me too until the hardware was reworked
from RGMII to RMII :)

Thanks a lot for the review - I just tested that setting bit 15 for all
PHY interface modes works for me as well, so I'm fine with that
solution. Will repost a new patch.


Daniel

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

* Re: [PATCH 1/2] net: ti cpsw ethernet: allow reading phy interface mode from DT
       [not found] ` <1348680268-8194-1-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2012-10-01 21:11   ` David Miller
  2012-10-01 21:15     ` Daniel Mack
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2012-10-01 21:11 UTC (permalink / raw)
  To: zonque-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
	mugunthanvnm-l0cyMroinI0

From: Daniel Mack <zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Wed, 26 Sep 2012 19:24:27 +0200

> Allow users to specify the phy interface of the CPSW slaves. The new
> node parameter is called "phy_if_mode" and is optional. The original
> behaviour of the driver is preserved when not given.
> 
> Signed-off-by: Daniel Mack <zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Applied, thanks.

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

* Re: [PATCH 1/2] net: ti cpsw ethernet: allow reading phy interface mode from DT
  2012-10-01 21:11   ` [PATCH 1/2] net: ti cpsw ethernet: allow reading phy interface mode from DT David Miller
@ 2012-10-01 21:15     ` Daniel Mack
  2012-10-01 21:38       ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Mack @ 2012-10-01 21:15 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, devicetree-discuss, mugunthanvnm, hvaibhav

On 01.10.2012 23:11, David Miller wrote:
> From: Daniel Mack <zonque@gmail.com>
> Date: Wed, 26 Sep 2012 19:24:27 +0200
> 
>> Allow users to specify the phy interface of the CPSW slaves. The new
>> node parameter is called "phy_if_mode" and is optional. The original
>> behaviour of the driver is preserved when not given.
>>
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
> 
> Applied, thanks.
> 

Eh, no - sorry. My original understanding was that a bit in the cpsw
registers has to be set only when a certain physical phy mode is in use.
Hence we would have needed a way to pass that information in via DT. But
as Mugunthan pointed out, that bit must always be set, and the cpsw
slaves can stay agnostic to the actual phy mode.

So that patch isn't needed. Sorry for the confusion.


Daniel

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

* Re: [PATCH 1/2] net: ti cpsw ethernet: allow reading phy interface mode from DT
  2012-10-01 21:15     ` Daniel Mack
@ 2012-10-01 21:38       ` David Miller
  0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2012-10-01 21:38 UTC (permalink / raw)
  To: zonque; +Cc: netdev, devicetree-discuss, mugunthanvnm, hvaibhav

From: Daniel Mack <zonque@gmail.com>
Date: Mon, 01 Oct 2012 23:15:38 +0200

> On 01.10.2012 23:11, David Miller wrote:
>> From: Daniel Mack <zonque@gmail.com>
>> Date: Wed, 26 Sep 2012 19:24:27 +0200
>> 
>>> Allow users to specify the phy interface of the CPSW slaves. The new
>>> node parameter is called "phy_if_mode" and is optional. The original
>>> behaviour of the driver is preserved when not given.
>>>
>>> Signed-off-by: Daniel Mack <zonque@gmail.com>
>> 
>> Applied, thanks.
>> 
> 
> Eh, no - sorry. My original understanding was that a bit in the cpsw
> registers has to be set only when a certain physical phy mode is in use.
> Hence we would have needed a way to pass that information in via DT. But
> as Mugunthan pointed out, that bit must always be set, and the cpsw
> slaves can stay agnostic to the actual phy mode.
> 
> So that patch isn't needed. Sorry for the confusion.

Ok I'll revert.

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

end of thread, other threads:[~2012-10-01 21:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-26 17:24 [PATCH 1/2] net: ti cpsw ethernet: allow reading phy interface mode from DT Daniel Mack
2012-09-26 17:24 ` [PATCH 2/2] net: ti cpsw ethernet: set IFCTL_{A,B} bits for RMII mode Daniel Mack
2012-09-26 18:50   ` N, Mugunthan V
2012-09-27 11:42     ` Daniel Mack
     [not found] ` <1348680268-8194-1-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-10-01 21:11   ` [PATCH 1/2] net: ti cpsw ethernet: allow reading phy interface mode from DT David Miller
2012-10-01 21:15     ` Daniel Mack
2012-10-01 21:38       ` 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).