diff mbox series

[net-next,v2,3/3] net: ethernet: fec: Allow the MDIO preamble to be disabled

Message ID 20200418000355.804617-4-andrew@lunn.ch
State Superseded
Delegated to: David Miller
Headers show
Series FEC MDIO speedups | expand

Commit Message

Andrew Lunn April 18, 2020, 12:03 a.m. UTC
An MDIO transaction normally starts with 32 1s as a preamble. However
not all devices requires such a preamble. Add a device tree property
which allows the preamble to be suppressed. This will half the size of
the MDIO transaction, allowing faster transactions.

Suggested-by: Chris Healy <Chris.Healy@zii.aero>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 Documentation/devicetree/bindings/net/mdio.yaml | 4 ++++
 drivers/net/ethernet/freescale/fec_main.c       | 9 ++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

Comments

Florian Fainelli April 18, 2020, 12:39 a.m. UTC | #1
Hi Andrew,

On 4/17/2020 5:03 PM, Andrew Lunn wrote:
> An MDIO transaction normally starts with 32 1s as a preamble. However
> not all devices requires such a preamble. Add a device tree property
> which allows the preamble to be suppressed. This will half the size of
> the MDIO transaction, allowing faster transactions.
> 
> Suggested-by: Chris Healy <Chris.Healy@zii.aero>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>   Documentation/devicetree/bindings/net/mdio.yaml | 4 ++++
>   drivers/net/ethernet/freescale/fec_main.c       | 9 ++++++++-
>   2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/mdio.yaml b/Documentation/devicetree/bindings/net/mdio.yaml
> index bcd457c54cd7..41ed4019f8ca 100644
> --- a/Documentation/devicetree/bindings/net/mdio.yaml
> +++ b/Documentation/devicetree/bindings/net/mdio.yaml
> @@ -43,6 +43,10 @@ properties:
>       description:
>         Desired MDIO bus clock frequency in Hz.
>   
> +  suppress-preamble:
> +        description: The 32 bit preamble should be suppressed.
> +        type: boolean

This is a property of the MDIO device node and the MDIO bus controller 
as well, so I would assume that it has to be treated a little it like 
the 'broken-turn-around' property and it would have to be a bitmask per 
MDIO device address that is set/clear depending on what the device 
support. If it is set for the device and your controller supports it, 
then you an suppress preamble.
Andrew Lunn April 18, 2020, 2:27 p.m. UTC | #2
> This is a property of the MDIO device node and the MDIO bus controller as
> well, so I would assume that it has to be treated a little it like the
> 'broken-turn-around' property and it would have to be a bitmask per MDIO
> device address that is set/clear depending on what the device support. If it
> is set for the device and your controller supports it, then you an suppress
> preamble.

Again, i don't see how this can work. You need all the devices on the
bus to support preamble suppression, otherwise you cannot use it. As
with a maximum clock frequency, we could add the complexity to check
as bus scan time that all devices have the necessary property, but i
don't think it brings anything.

    Andrew
Florian Fainelli April 18, 2020, 4:02 p.m. UTC | #3
On 4/18/2020 7:27 AM, Andrew Lunn wrote:
>> This is a property of the MDIO device node and the MDIO bus controller as
>> well, so I would assume that it has to be treated a little it like the
>> 'broken-turn-around' property and it would have to be a bitmask per MDIO
>> device address that is set/clear depending on what the device support. If it
>> is set for the device and your controller supports it, then you an suppress
>> preamble.
> 
> Again, i don't see how this can work. You need all the devices on the
> bus to support preamble suppression, otherwise you cannot use it. As
> with a maximum clock frequency, we could add the complexity to check
> as bus scan time that all devices have the necessary property, but i
> don't think it brings anything.

With your current patch I can define 'suppress-preamble' for the FEC 
MDIO node, and if there is at least one device on the bus that does not 
support preamble suppression, they are not going to work, so if nothing 
else you need to intersect between the device capability and the MDIO 
bus controller capability. Same comments as patch #2 about we could 
approach this.
Florian Fainelli April 18, 2020, 9:09 p.m. UTC | #4
On 4/17/2020 5:03 PM, Andrew Lunn wrote:
> An MDIO transaction normally starts with 32 1s as a preamble. However
> not all devices requires such a preamble. Add a device tree property
> which allows the preamble to be suppressed. This will half the size of
> the MDIO transaction, allowing faster transactions.
> 
> Suggested-by: Chris Healy <Chris.Healy@zii.aero>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/mdio.yaml b/Documentation/devicetree/bindings/net/mdio.yaml
index bcd457c54cd7..41ed4019f8ca 100644
--- a/Documentation/devicetree/bindings/net/mdio.yaml
+++ b/Documentation/devicetree/bindings/net/mdio.yaml
@@ -43,6 +43,10 @@  properties:
     description:
       Desired MDIO bus clock frequency in Hz.
 
+  suppress-preamble:
+        description: The 32 bit preamble should be suppressed.
+        type: boolean
+
 patternProperties:
   "^ethernet-phy@[0-9a-f]+$":
     type: object
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 28ef0abfa660..3404e085c657 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2064,6 +2064,7 @@  static int fec_enet_mii_init(struct platform_device *pdev)
 	static struct mii_bus *fec0_mii_bus;
 	struct net_device *ndev = platform_get_drvdata(pdev);
 	struct fec_enet_private *fep = netdev_priv(ndev);
+	bool suppress_preamble = false;
 	struct device_node *node;
 	int err = -ENXIO;
 	u32 mii_speed, holdtime;
@@ -2097,8 +2098,11 @@  static int fec_enet_mii_init(struct platform_device *pdev)
 
 	bus_freq = 2500000; /* 2.5MHz by default */
 	node = of_get_child_by_name(pdev->dev.of_node, "mdio");
-	if (node)
+	if (node) {
 		of_property_read_u32(node, "clock-frequency", &bus_freq);
+		suppress_preamble = of_property_read_bool(node,
+							  "suppress-preamble");
+	}
 
 	/*
 	 * Set MII speed (= clk_get_rate() / 2 * phy_speed)
@@ -2135,6 +2139,9 @@  static int fec_enet_mii_init(struct platform_device *pdev)
 
 	fep->phy_speed = mii_speed << 1 | holdtime << 8;
 
+	if (suppress_preamble)
+		fep->phy_speed |= BIT(7);
+
 	writel(fep->phy_speed, fep->hwp + FEC_MII_SPEED);
 
 	/* Clear any pending transaction complete indication */