Blob Blame History Raw
From: Andrew Lunn <andrew@lunn.ch>
Date: Mon, 20 Apr 2020 00:04:02 +0200
Subject: net: ethernet: fec: Allow the MDIO preamble to be disabled
Git-commit: 3c01eb62d1bd85a5dd1d22d74339728666ae2c45
Patch-mainline: v5.8-rc1
References: jsc#SLE-16106

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. But it should only
be used when all devices on the bus support suppressed preamble.

Suggested-by: Chris Healy <Chris.Healy@zii.aero>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 Documentation/devicetree/bindings/net/mdio.yaml |    6 ++++++
 drivers/net/ethernet/freescale/fec_main.c       |    9 ++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

--- a/Documentation/devicetree/bindings/net/mdio.yaml
+++ b/Documentation/devicetree/bindings/net/mdio.yaml
@@ -45,6 +45,12 @@ properties:
       defined 2.5MHz should only be used when all devices on the bus support
       the given clock speed.
 
+  suppress-preamble:
+    description:
+      The 32 bit preamble should be suppressed. In order for this to
+      work, all devices on the bus must support suppressed preamble.
+    type: boolean
+
 patternProperties:
   "^ethernet-phy@[0-9a-f]+$":
     type: object
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -2065,6 +2065,7 @@ static int fec_enet_mii_init(struct plat
 	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;
@@ -2098,8 +2099,11 @@ static int fec_enet_mii_init(struct plat
 
 	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)
@@ -2136,6 +2140,9 @@ static int fec_enet_mii_init(struct plat
 
 	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);
 
 	fep->mii_bus = mdiobus_alloc();