All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay
@ 2019-05-22 18:43 Trent Piepho
  2019-05-22 18:43 ` [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output Trent Piepho
                   ` (8 more replies)
  0 siblings, 9 replies; 24+ messages in thread
From: Trent Piepho @ 2019-05-22 18:43 UTC (permalink / raw)
  To: netdev, devicetree; +Cc: Trent Piepho, Rob Herring, Mark Rutland

Add a note to make it more clear how the driver behaves when "rgmii" vs
"rgmii-id", "rgmii-idrx", or "rgmii-idtx" interface modes are selected.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---

Notes:
    Changes from v1:
      Clarify behavior may change to enforce no delay in "rgmii" mode

 Documentation/devicetree/bindings/net/ti,dp83867.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ti,dp83867.txt b/Documentation/devicetree/bindings/net/ti,dp83867.txt
index 9ef9338aaee1..99b8681bde49 100644
--- a/Documentation/devicetree/bindings/net/ti,dp83867.txt
+++ b/Documentation/devicetree/bindings/net/ti,dp83867.txt
@@ -11,6 +11,14 @@ Required properties:
 	- ti,fifo-depth - Transmitt FIFO depth- see dt-bindings/net/ti-dp83867.h
 		for applicable values
 
+Note: If the interface type is PHY_INTERFACE_MODE_RGMII the TX/RX clock delays
+      will be left at their default values, as set by the PHY's pin strapping.
+      The default strapping will use a delay of 2.00 ns.  Thus
+      PHY_INTERFACE_MODE_RGMII, by default, does not behave as RGMII with no
+      internal delay, but as PHY_INTERFACE_MODE_RGMII_ID.  The device tree
+      should use "rgmii-id" if internal delays are desired as this may be
+      changed in future to cause "rgmii" mode to disable delays.
+
 Optional property:
 	- ti,min-output-impedance - MAC Interface Impedance control to set
 				    the programmable output impedance to
-- 
2.14.5


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

* [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
@ 2019-05-22 18:43 ` Trent Piepho
  2019-05-22 19:11   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  2019-05-22 18:43 ` [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock Trent Piepho
                   ` (7 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Trent Piepho @ 2019-05-22 18:43 UTC (permalink / raw)
  To: netdev, devicetree; +Cc: Trent Piepho, Rob Herring, Mark Rutland

The clock output is generally only used for testing and development and
not used to daisy-chain PHYs.  It's just a source of RF noise afterward.

Add a mux value for "off".  I've added it as another enumeration to the
output property.  In the actual PHY, the mux and the output enable are
independently controllable.  However, it doesn't seem useful to be able
to describe the mux setting when the output is disabled.

Document that PHY's default setting will be left as is if the property
is omitted.

Cc: Rob Herring <robh+dt@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 Documentation/devicetree/bindings/net/ti,dp83867.txt | 6 ++++--
 include/dt-bindings/net/ti-dp83867.h                 | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/net/ti,dp83867.txt b/Documentation/devicetree/bindings/net/ti,dp83867.txt
index 99b8681bde49..db6aa3f2215b 100644
--- a/Documentation/devicetree/bindings/net/ti,dp83867.txt
+++ b/Documentation/devicetree/bindings/net/ti,dp83867.txt
@@ -33,8 +33,10 @@ Optional property:
 				    software needs to take when this pin is
 				    strapped in these modes. See data manual
 				    for details.
-	- ti,clk-output-sel - Muxing option for CLK_OUT pin - see dt-bindings/net/ti-dp83867.h
-				    for applicable values.
+	- ti,clk-output-sel - Muxing option for CLK_OUT pin.  See dt-bindings/net/ti-dp83867.h
+			      for applicable values.  The CLK_OUT pin can also
+			      be disabled by this property.  When omitted, the
+			      PHY's default will be left as is.
 
 Note: ti,min-output-impedance and ti,max-output-impedance are mutually
       exclusive. When both properties are present ti,max-output-impedance
diff --git a/include/dt-bindings/net/ti-dp83867.h b/include/dt-bindings/net/ti-dp83867.h
index 7b1656427cbe..192b79439eb7 100644
--- a/include/dt-bindings/net/ti-dp83867.h
+++ b/include/dt-bindings/net/ti-dp83867.h
@@ -56,4 +56,6 @@
 #define DP83867_CLK_O_SEL_CHN_C_TCLK		0xA
 #define DP83867_CLK_O_SEL_CHN_D_TCLK		0xB
 #define DP83867_CLK_O_SEL_REF_CLK		0xC
+/* Special flag to indicate clock should be off */
+#define DP83867_CLK_O_SEL_OFF			0xFFFFFFFF
 #endif
-- 
2.14.5


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

* [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
  2019-05-22 18:43 ` [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output Trent Piepho
@ 2019-05-22 18:43 ` Trent Piepho
  2019-05-22 18:51   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  2019-05-22 18:43 ` [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling Trent Piepho
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Trent Piepho @ 2019-05-22 18:43 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: Trent Piepho, Andrew Lunn, Florian Fainelli, Heiner Kallweit

Generally, the output clock pin is only used for testing and only serves
as a source of RF noise after this.  It could be used to daisy-chain
PHYs, but this is uncommon.  Since the PHY can disable the output, make
doing so an option.  I do this by adding another enumeration to the
allowed values of ti,clk-output-sel.

The code was not using the value DP83867_CLK_O_SEL_REF_CLK as one might
expect: to select the REF_CLK as the output.  Rather it meant "keep
clock output setting as is", which, depending on PHY strapping, might
not be outputting REF_CLK.

Change this so DP83867_CLK_O_SEL_REF_CLK means enable REF_CLK output.
Omitting the property will leave the setting as is (which was the
previous behavior in this case).

Out of range values were silently converted into
DP83867_CLK_O_SEL_REF_CLK.  Change this so they generate an error.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 drivers/net/phy/dp83867.c | 37 ++++++++++++++++++++++++++++---------
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index fd35131a0c39..54fbc833bf5d 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -68,6 +68,7 @@
 
 #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX	0x0
 #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN	0x1f
+#define DP83867_IO_MUX_CFG_CLK_O_DISABLE	BIT(6)
 #define DP83867_IO_MUX_CFG_CLK_O_SEL_MASK	(0x1f << 8)
 #define DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT	8
 
@@ -87,7 +88,8 @@ struct dp83867_private {
 	int io_impedance;
 	int port_mirroring;
 	bool rxctrl_strap_quirk;
-	int clk_output_sel;
+	bool set_clk_output;
+	u32 clk_output_sel;
 };
 
 static int dp83867_ack_interrupt(struct phy_device *phydev)
@@ -154,11 +156,19 @@ static int dp83867_of_init(struct phy_device *phydev)
 	/* Optional configuration */
 	ret = of_property_read_u32(of_node, "ti,clk-output-sel",
 				   &dp83867->clk_output_sel);
-	if (ret || dp83867->clk_output_sel > DP83867_CLK_O_SEL_REF_CLK)
-		/* Keep the default value if ti,clk-output-sel is not set
-		 * or too high
+	/* If not set, keep default */
+	if (!ret) {
+		dp83867->set_clk_output = true;
+		/* Valid values are 0 to DP83867_CLK_O_SEL_REF_CLK or
+		 * DP83867_CLK_O_SEL_OFF.
 		 */
-		dp83867->clk_output_sel = DP83867_CLK_O_SEL_REF_CLK;
+		if (dp83867->clk_output_sel > DP83867_CLK_O_SEL_REF_CLK &&
+		    dp83867->clk_output_sel != DP83867_CLK_O_SEL_OFF) {
+			phydev_err(phydev, "ti,clk-output-sel value %u out of range\n",
+				   dp83867->clk_output_sel);
+			return -EINVAL;
+		}
+	}
 
 	if (of_property_read_bool(of_node, "ti,max-output-impedance"))
 		dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
@@ -288,11 +298,20 @@ static int dp83867_config_init(struct phy_device *phydev)
 		dp83867_config_port_mirroring(phydev);
 
 	/* Clock output selection if muxing property is set */
-	if (dp83867->clk_output_sel != DP83867_CLK_O_SEL_REF_CLK)
+	if (dp83867->set_clk_output) {
+		u16 mask = DP83867_IO_MUX_CFG_CLK_O_DISABLE;
+
+		if (dp83867->clk_output_sel == DP83867_CLK_O_SEL_OFF) {
+			val = DP83867_IO_MUX_CFG_CLK_O_DISABLE;
+		} else {
+			mask |= DP83867_IO_MUX_CFG_CLK_O_SEL_MASK;
+			val = dp83867->clk_output_sel <<
+			      DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT;
+		}
+
 		phy_modify_mmd(phydev, DP83867_DEVADDR, DP83867_IO_MUX_CFG,
-			       DP83867_IO_MUX_CFG_CLK_O_SEL_MASK,
-			       dp83867->clk_output_sel <<
-			       DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT);
+			       mask, val);
+	}
 
 	return 0;
 }
-- 
2.14.5


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

* [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
  2019-05-22 18:43 ` [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output Trent Piepho
  2019-05-22 18:43 ` [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock Trent Piepho
@ 2019-05-22 18:43 ` Trent Piepho
  2019-05-22 18:54   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  2019-05-22 18:43 ` [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties Trent Piepho
                   ` (5 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Trent Piepho @ 2019-05-22 18:43 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: Trent Piepho, Andrew Lunn, Florian Fainelli, Heiner Kallweit

The code was assuming the reset default of the delay control register
was to have delay disabled.  This is what the datasheet shows as the
register's initial value.  However, that's not actually true: the
default is controlled by the PHY's pin strapping.

If the interface mode is selected as RX or TX delay only, insure the
other direction's delay is disabled.

If the interface mode is just "rgmii", with neither TX or RX internal
delay, one might expect that the driver should disable both delays.  But
this is not what the driver does.  It leaves the setting at the PHY's
strapping's default.  And that default, for no pins with strapping
resistors, is to have delay enabled and 2.00 ns.

Rather than change this behavior, I've kept it the same and documented
it.  No delay will most likely not work and will break ethernet on any
board using "rgmii" mode.  If the board is strapped to have a delay and
is configured to use "rgmii" mode a warning is generated that "rgmii-id"
should have been used.

Also validate the delay values and fail if they are not in range.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---

Notes:
    Changes from v1:
      Print warning if pin strapping has delay when "rgmii" mode is used.

 drivers/net/phy/dp83867.c | 78 +++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 66 insertions(+), 12 deletions(-)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 54fbc833bf5d..fc5baa5d14d0 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -28,6 +28,7 @@
 #define DP83867_CFG4            0x0031
 #define DP83867_RGMIICTL	0x0032
 #define DP83867_STRAP_STS1	0x006E
+#define DP83867_STRAP_STS2	0x006f
 #define DP83867_RGMIIDCTL	0x0086
 #define DP83867_IO_MUX_CFG	0x0170
 
@@ -55,13 +56,23 @@
 /* STRAP_STS1 bits */
 #define DP83867_STRAP_STS1_RESERVED		BIT(11)
 
+/* STRAP_STS2 bits */
+#define DP83867_STRAP_STS2_CLK_SKEW_TX_MASK	GENMASK(6, 4)
+#define DP83867_STRAP_STS2_CLK_SKEW_TX_SHIFT	4
+#define DP83867_STRAP_STS2_CLK_SKEW_RX_MASK	GENMASK(2, 0)
+#define DP83867_STRAP_STS2_CLK_SKEW_RX_SHIFT	0
+#define DP83867_STRAP_STS2_CLK_SKEW_NONE	BIT(2)
+
 /* PHY CTRL bits */
 #define DP83867_PHYCR_FIFO_DEPTH_SHIFT		14
 #define DP83867_PHYCR_FIFO_DEPTH_MASK		(3 << 14)
 #define DP83867_PHYCR_RESERVED_MASK		BIT(11)
 
 /* RGMIIDCTL bits */
+#define DP83867_RGMII_TX_CLK_DELAY_MAX		0xf
 #define DP83867_RGMII_TX_CLK_DELAY_SHIFT	4
+#define DP83867_RGMII_RX_CLK_DELAY_MAX		0xf
+#define DP83867_RGMII_RX_CLK_DELAY_SHIFT	0
 
 /* IO_MUX_CFG bits */
 #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL	0x1f
@@ -178,19 +189,56 @@ static int dp83867_of_init(struct phy_device *phydev)
 	dp83867->rxctrl_strap_quirk = of_property_read_bool(of_node,
 					"ti,dp83867-rxctrl-strap-quirk");
 
-	ret = of_property_read_u32(of_node, "ti,rx-internal-delay",
-				   &dp83867->rx_id_delay);
-	if (ret &&
-	    (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
-	     phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID))
-		return ret;
+	/* Existing behavior was to use default pin strapping delay in rgmii
+	 * mode, but rgmii should have meant no delay.  Warn existing users.
+	 */
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII) {
+		const u16 val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_STRAP_STS2);
+		const u16 txskew = (val & DP83867_STRAP_STS2_CLK_SKEW_TX_MASK) >>
+				   DP83867_STRAP_STS2_CLK_SKEW_TX_SHIFT;
+		const u16 rxskew = (val & DP83867_STRAP_STS2_CLK_SKEW_RX_MASK) >>
+				   DP83867_STRAP_STS2_CLK_SKEW_RX_SHIFT;
+
+		if (txskew != DP83867_STRAP_STS2_CLK_SKEW_NONE ||
+		    rxskew != DP83867_STRAP_STS2_CLK_SKEW_NONE)
+			phydev_warn(phydev,
+				    "PHY has delays via pin strapping, but phy-mode = 'rgmii'\n"
+				    "Should be 'rgmii-id' to use internal delays\n");
+	}
 
-	ret = of_property_read_u32(of_node, "ti,tx-internal-delay",
-				   &dp83867->tx_id_delay);
-	if (ret &&
-	    (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
-	     phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID))
-		return ret;
+	/* RX delay *must* be specified if internal delay of RX is used. */
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+	    phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
+		ret = of_property_read_u32(of_node, "ti,rx-internal-delay",
+					   &dp83867->rx_id_delay);
+		if (ret) {
+			phydev_err(phydev, "ti,rx-internal-delay must be specified\n");
+			return ret;
+		}
+		if (dp83867->rx_id_delay > DP83867_RGMII_RX_CLK_DELAY_MAX) {
+			phydev_err(phydev,
+				   "ti,rx-internal-delay value of %u out of range\n",
+				   dp83867->rx_id_delay);
+			return -EINVAL;
+		}
+	}
+
+	/* TX delay *must* be specified if internal delay of RX is used. */
+	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
+	    phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
+		ret = of_property_read_u32(of_node, "ti,tx-internal-delay",
+					   &dp83867->tx_id_delay);
+		if (ret) {
+			phydev_err(phydev, "ti,tx-internal-delay must be specified\n");
+			return ret;
+		}
+		if (dp83867->tx_id_delay > DP83867_RGMII_TX_CLK_DELAY_MAX) {
+			phydev_err(phydev,
+				   "ti,tx-internal-delay value of %u out of range\n",
+				   dp83867->tx_id_delay);
+			return -EINVAL;
+		}
+	}
 
 	if (of_property_read_bool(of_node, "enet-phy-lane-swap"))
 		dp83867->port_mirroring = DP83867_PORT_MIRROING_EN;
@@ -259,10 +307,16 @@ static int dp83867_config_init(struct phy_device *phydev)
 			return ret;
 	}
 
+	/* If rgmii mode with no internal delay is selected, we do NOT use
+	 * aligned mode as one might expect.  Instead we use the PHY's default
+	 * based on pin strapping.  And the "mode 0" default is to *use*
+	 * internal delay with a value of 7 (2.00 ns).
+	 */
 	if ((phydev->interface >= PHY_INTERFACE_MODE_RGMII_ID) &&
 	    (phydev->interface <= PHY_INTERFACE_MODE_RGMII_RXID)) {
 		val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_RGMIICTL);
 
+		val &= ~(DP83867_RGMII_TX_CLK_DELAY_EN | DP83867_RGMII_RX_CLK_DELAY_EN);
 		if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
 			val |= (DP83867_RGMII_TX_CLK_DELAY_EN | DP83867_RGMII_RX_CLK_DELAY_EN);
 
-- 
2.14.5


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

* [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
                   ` (2 preceding siblings ...)
  2019-05-22 18:43 ` [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling Trent Piepho
@ 2019-05-22 18:43 ` Trent Piepho
  2019-05-22 18:59   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  2019-05-22 18:43 ` [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay Trent Piepho
                   ` (4 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Trent Piepho @ 2019-05-22 18:43 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: Trent Piepho, Andrew Lunn, Florian Fainelli, Heiner Kallweit

The variables used to store u32 DT properties were signed ints.  This
doesn't work properly if the value of the property were to overflow.
Use unsigned variables so this doesn't happen.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---
 drivers/net/phy/dp83867.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index fc5baa5d14d0..59051b0f5be9 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -93,9 +93,9 @@ enum {
 };
 
 struct dp83867_private {
-	int rx_id_delay;
-	int tx_id_delay;
-	int fifo_depth;
+	u32 rx_id_delay;
+	u32 tx_id_delay;
+	u32 fifo_depth;
 	int io_impedance;
 	int port_mirroring;
 	bool rxctrl_strap_quirk;
-- 
2.14.5


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

* [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
                   ` (3 preceding siblings ...)
  2019-05-22 18:43 ` [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties Trent Piepho
@ 2019-05-22 18:43 ` Trent Piepho
  2019-05-22 19:03   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  2019-05-22 18:43 ` [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property Trent Piepho
                   ` (3 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Trent Piepho @ 2019-05-22 18:43 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: Trent Piepho, Andrew Lunn, Florian Fainelli, Heiner Kallweit

The driver would only set the IO impedance value when RGMII internal
delays were enabled.  There is no reason for this.  Move the IO
impedance block out of the RGMII delay block.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---

Notes:
    Changes from v1:
      Patch added in v2.

 drivers/net/phy/dp83867.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 59051b0f5be9..5ece153aa9c3 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -75,8 +75,7 @@
 #define DP83867_RGMII_RX_CLK_DELAY_SHIFT	0
 
 /* IO_MUX_CFG bits */
-#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL	0x1f
-
+#define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK	0x1f
 #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX	0x0
 #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN	0x1f
 #define DP83867_IO_MUX_CFG_CLK_O_DISABLE	BIT(6)
@@ -162,8 +161,6 @@ static int dp83867_of_init(struct phy_device *phydev)
 	if (!of_node)
 		return -ENODEV;
 
-	dp83867->io_impedance = -EINVAL;
-
 	/* Optional configuration */
 	ret = of_property_read_u32(of_node, "ti,clk-output-sel",
 				   &dp83867->clk_output_sel);
@@ -185,6 +182,8 @@ static int dp83867_of_init(struct phy_device *phydev)
 		dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
 	else if (of_property_read_bool(of_node, "ti,min-output-impedance"))
 		dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN;
+	else
+		dp83867->io_impedance = -1; /* leave at default */
 
 	dp83867->rxctrl_strap_quirk = of_property_read_bool(of_node,
 					"ti,dp83867-rxctrl-strap-quirk");
@@ -333,14 +332,14 @@ static int dp83867_config_init(struct phy_device *phydev)
 
 		phy_write_mmd(phydev, DP83867_DEVADDR, DP83867_RGMIIDCTL,
 			      delay);
-
-		if (dp83867->io_impedance >= 0)
-			phy_modify_mmd(phydev, DP83867_DEVADDR, DP83867_IO_MUX_CFG,
-				       DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL,
-				       dp83867->io_impedance &
-				       DP83867_IO_MUX_CFG_IO_IMPEDANCE_CTRL);
 	}
 
+	/* If specified, set io impedance */
+	if (dp83867->io_impedance >= 0)
+		phy_modify_mmd(phydev, DP83867_DEVADDR, DP83867_IO_MUX_CFG,
+			       DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK,
+			       dp83867->io_impedance);
+
 	/* Enable Interrupt output INT_OE in CFG3 register */
 	if (phy_interrupt_is_valid(phydev)) {
 		val = phy_read(phydev, DP83867_CFG3);
-- 
2.14.5


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

* [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
                   ` (4 preceding siblings ...)
  2019-05-22 18:43 ` [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay Trent Piepho
@ 2019-05-22 18:43 ` Trent Piepho
  2019-05-22 19:05   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  2019-05-22 18:43 ` [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe Trent Piepho
                   ` (2 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Trent Piepho @ 2019-05-22 18:43 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: Trent Piepho, Andrew Lunn, Florian Fainelli, Heiner Kallweit

Insure property is in valid range and fail when reading DT if it is not.
Also add error message for existing failure if required property is not
present.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---

Notes:
    Changes from v1:
      New patch in series v2

 drivers/net/phy/dp83867.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 5ece153aa9c3..ce46ff4cf880 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -65,7 +65,8 @@
 
 /* PHY CTRL bits */
 #define DP83867_PHYCR_FIFO_DEPTH_SHIFT		14
-#define DP83867_PHYCR_FIFO_DEPTH_MASK		(3 << 14)
+#define DP83867_PHYCR_FIFO_DEPTH_MAX		0x03
+#define DP83867_PHYCR_FIFO_DEPTH_MASK		GENMASK(15, 14)
 #define DP83867_PHYCR_RESERVED_MASK		BIT(11)
 
 /* RGMIIDCTL bits */
@@ -245,8 +246,20 @@ static int dp83867_of_init(struct phy_device *phydev)
 	if (of_property_read_bool(of_node, "enet-phy-lane-no-swap"))
 		dp83867->port_mirroring = DP83867_PORT_MIRROING_DIS;
 
-	return of_property_read_u32(of_node, "ti,fifo-depth",
+	ret = of_property_read_u32(of_node, "ti,fifo-depth",
 				   &dp83867->fifo_depth);
+	if (ret) {
+		phydev_err(phydev,
+			   "ti,fifo-depth property is required\n");
+		return ret;
+	}
+	if (dp83867->fifo_depth > DP83867_PHYCR_FIFO_DEPTH_MAX) {
+		phydev_err(phydev,
+			   "ti,fifo-depth value %u out of range\n",
+			   dp83867->fifo_depth);
+		return -EINVAL;
+	}
+	return 0;
 }
 #else
 static int dp83867_of_init(struct phy_device *phydev)
-- 
2.14.5


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

* [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
                   ` (5 preceding siblings ...)
  2019-05-22 18:43 ` [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property Trent Piepho
@ 2019-05-22 18:43 ` Trent Piepho
  2019-05-22 19:09   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  2019-05-22 19:10 ` [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Andrew Lunn
  2019-05-23  0:43 ` David Miller
  8 siblings, 2 replies; 24+ messages in thread
From: Trent Piepho @ 2019-05-22 18:43 UTC (permalink / raw)
  To: netdev, devicetree
  Cc: Trent Piepho, Andrew Lunn, Florian Fainelli, Heiner Kallweit

This was being done in config the first time the phy was configured.
Should be in the probe method.

Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Trent Piepho <tpiepho@impinj.com>
---

Notes:
    Changes from v1:
      New patch in series v2

 drivers/net/phy/dp83867.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index ce46ff4cf880..3bdf94043693 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -268,25 +268,29 @@ static int dp83867_of_init(struct phy_device *phydev)
 }
 #endif /* CONFIG_OF_MDIO */
 
-static int dp83867_config_init(struct phy_device *phydev)
+static int dp83867_probe(struct phy_device *phydev)
 {
 	struct dp83867_private *dp83867;
+
+	dp83867 = devm_kzalloc(&phydev->mdio.dev, sizeof(*dp83867),
+			       GFP_KERNEL);
+	if (!dp83867)
+		return -ENOMEM;
+
+	phydev->priv = dp83867;
+
+	return 0;
+}
+
+static int dp83867_config_init(struct phy_device *phydev)
+{
+	struct dp83867_private *dp83867 = phydev->priv;
 	int ret, val, bs;
 	u16 delay;
 
-	if (!phydev->priv) {
-		dp83867 = devm_kzalloc(&phydev->mdio.dev, sizeof(*dp83867),
-				       GFP_KERNEL);
-		if (!dp83867)
-			return -ENOMEM;
-
-		phydev->priv = dp83867;
-		ret = dp83867_of_init(phydev);
-		if (ret)
-			return ret;
-	} else {
-		dp83867 = (struct dp83867_private *)phydev->priv;
-	}
+	ret = dp83867_of_init(phydev);
+	if (ret)
+		return ret;
 
 	/* RX_DV/RX_CTRL strapped in mode 1 or mode 2 workaround */
 	if (dp83867->rxctrl_strap_quirk)
@@ -402,6 +406,7 @@ static struct phy_driver dp83867_driver[] = {
 		.name		= "TI DP83867",
 		/* PHY_GBIT_FEATURES */
 
+		.probe          = dp83867_probe,
 		.config_init	= dp83867_config_init,
 		.soft_reset	= dp83867_phy_reset,
 
-- 
2.14.5


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

* Re: [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock
  2019-05-22 18:43 ` [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock Trent Piepho
@ 2019-05-22 18:51   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2019-05-22 18:51 UTC (permalink / raw)
  To: Trent Piepho; +Cc: netdev, devicetree, Florian Fainelli, Heiner Kallweit

On Wed, May 22, 2019 at 06:43:22PM +0000, Trent Piepho wrote:
> Generally, the output clock pin is only used for testing and only serves
> as a source of RF noise after this.  It could be used to daisy-chain
> PHYs, but this is uncommon.  Since the PHY can disable the output, make
> doing so an option.  I do this by adding another enumeration to the
> allowed values of ti,clk-output-sel.
> 
> The code was not using the value DP83867_CLK_O_SEL_REF_CLK as one might
> expect: to select the REF_CLK as the output.  Rather it meant "keep
> clock output setting as is", which, depending on PHY strapping, might
> not be outputting REF_CLK.
> 
> Change this so DP83867_CLK_O_SEL_REF_CLK means enable REF_CLK output.
> Omitting the property will leave the setting as is (which was the
> previous behavior in this case).
> 
> Out of range values were silently converted into
> DP83867_CLK_O_SEL_REF_CLK.  Change this so they generate an error.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling
  2019-05-22 18:43 ` [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling Trent Piepho
@ 2019-05-22 18:54   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2019-05-22 18:54 UTC (permalink / raw)
  To: Trent Piepho; +Cc: netdev, devicetree, Florian Fainelli, Heiner Kallweit

On Wed, May 22, 2019 at 06:43:23PM +0000, Trent Piepho wrote:
> The code was assuming the reset default of the delay control register
> was to have delay disabled.  This is what the datasheet shows as the
> register's initial value.  However, that's not actually true: the
> default is controlled by the PHY's pin strapping.
> 
> If the interface mode is selected as RX or TX delay only, insure the
> other direction's delay is disabled.
> 
> If the interface mode is just "rgmii", with neither TX or RX internal
> delay, one might expect that the driver should disable both delays.  But
> this is not what the driver does.  It leaves the setting at the PHY's
> strapping's default.  And that default, for no pins with strapping
> resistors, is to have delay enabled and 2.00 ns.
> 
> Rather than change this behavior, I've kept it the same and documented
> it.  No delay will most likely not work and will break ethernet on any
> board using "rgmii" mode.  If the board is strapped to have a delay and
> is configured to use "rgmii" mode a warning is generated that "rgmii-id"
> should have been used.
> 
> Also validate the delay values and fail if they are not in range.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties
  2019-05-22 18:43 ` [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties Trent Piepho
@ 2019-05-22 18:59   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2019-05-22 18:59 UTC (permalink / raw)
  To: Trent Piepho; +Cc: netdev, devicetree, Florian Fainelli, Heiner Kallweit

On Wed, May 22, 2019 at 06:43:24PM +0000, Trent Piepho wrote:
> The variables used to store u32 DT properties were signed ints.  This
> doesn't work properly if the value of the property were to overflow.
> Use unsigned variables so this doesn't happen.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay
  2019-05-22 18:43 ` [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay Trent Piepho
@ 2019-05-22 19:03   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2019-05-22 19:03 UTC (permalink / raw)
  To: Trent Piepho; +Cc: netdev, devicetree, Florian Fainelli, Heiner Kallweit

On Wed, May 22, 2019 at 06:43:25PM +0000, Trent Piepho wrote:
> The driver would only set the IO impedance value when RGMII internal
> delays were enabled.  There is no reason for this.  Move the IO
> impedance block out of the RGMII delay block.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property
  2019-05-22 18:43 ` [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property Trent Piepho
@ 2019-05-22 19:05   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2019-05-22 19:05 UTC (permalink / raw)
  To: Trent Piepho; +Cc: netdev, devicetree, Florian Fainelli, Heiner Kallweit

On Wed, May 22, 2019 at 06:43:26PM +0000, Trent Piepho wrote:
> Insure property is in valid range and fail when reading DT if it is not.
> Also add error message for existing failure if required property is not
> present.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe
  2019-05-22 18:43 ` [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe Trent Piepho
@ 2019-05-22 19:09   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2019-05-22 19:09 UTC (permalink / raw)
  To: Trent Piepho; +Cc: netdev, devicetree, Florian Fainelli, Heiner Kallweit

On Wed, May 22, 2019 at 06:43:27PM +0000, Trent Piepho wrote:
> This was being done in config the first time the phy was configured.
> Should be in the probe method.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
                   ` (6 preceding siblings ...)
  2019-05-22 18:43 ` [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe Trent Piepho
@ 2019-05-22 19:10 ` Andrew Lunn
  2019-05-23  0:43 ` David Miller
  8 siblings, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2019-05-22 19:10 UTC (permalink / raw)
  To: Trent Piepho; +Cc: netdev, devicetree, Rob Herring, Mark Rutland

>On Wed, May 22, 2019 at 06:43:19PM +0000, Trent Piepho wrote:
> Add a note to make it more clear how the driver behaves when "rgmii" vs
> "rgmii-id", "rgmii-idrx", or "rgmii-idtx" interface modes are selected.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output
  2019-05-22 18:43 ` [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output Trent Piepho
@ 2019-05-22 19:11   ` Andrew Lunn
  2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: Andrew Lunn @ 2019-05-22 19:11 UTC (permalink / raw)
  To: Trent Piepho; +Cc: netdev, devicetree, Rob Herring, Mark Rutland

On Wed, May 22, 2019 at 06:43:21PM +0000, Trent Piepho wrote:
> The clock output is generally only used for testing and development and
> not used to daisy-chain PHYs.  It's just a source of RF noise afterward.
> 
> Add a mux value for "off".  I've added it as another enumeration to the
> output property.  In the actual PHY, the mux and the output enable are
> independently controllable.  However, it doesn't seem useful to be able
> to describe the mux setting when the output is disabled.
> 
> Document that PHY's default setting will be left as is if the property
> is omitted.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay
  2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
                   ` (7 preceding siblings ...)
  2019-05-22 19:10 ` [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Andrew Lunn
@ 2019-05-23  0:43 ` David Miller
  8 siblings, 0 replies; 24+ messages in thread
From: David Miller @ 2019-05-23  0:43 UTC (permalink / raw)
  To: tpiepho; +Cc: netdev, devicetree, robh+dt, mark.rutland

From: Trent Piepho <tpiepho@impinj.com>
Date: Wed, 22 May 2019 18:43:19 +0000

> Add a note to make it more clear how the driver behaves when "rgmii" vs
> "rgmii-id", "rgmii-idrx", or "rgmii-idtx" interface modes are selected.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Applied.

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

* Re: [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output
  2019-05-22 18:43 ` [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output Trent Piepho
  2019-05-22 19:11   ` Andrew Lunn
@ 2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: David Miller @ 2019-05-23  0:44 UTC (permalink / raw)
  To: tpiepho; +Cc: netdev, devicetree, robh+dt, mark.rutland

From: Trent Piepho <tpiepho@impinj.com>
Date: Wed, 22 May 2019 18:43:21 +0000

> The clock output is generally only used for testing and development and
> not used to daisy-chain PHYs.  It's just a source of RF noise afterward.
> 
> Add a mux value for "off".  I've added it as another enumeration to the
> output property.  In the actual PHY, the mux and the output enable are
> independently controllable.  However, it doesn't seem useful to be able
> to describe the mux setting when the output is disabled.
> 
> Document that PHY's default setting will be left as is if the property
> is omitted.
> 
> Cc: Rob Herring <robh+dt@kernel.org>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Applied.

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

* Re: [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock
  2019-05-22 18:43 ` [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock Trent Piepho
  2019-05-22 18:51   ` Andrew Lunn
@ 2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: David Miller @ 2019-05-23  0:44 UTC (permalink / raw)
  To: tpiepho; +Cc: netdev, devicetree, andrew, f.fainelli, hkallweit1

From: Trent Piepho <tpiepho@impinj.com>
Date: Wed, 22 May 2019 18:43:22 +0000

> Generally, the output clock pin is only used for testing and only serves
> as a source of RF noise after this.  It could be used to daisy-chain
> PHYs, but this is uncommon.  Since the PHY can disable the output, make
> doing so an option.  I do this by adding another enumeration to the
> allowed values of ti,clk-output-sel.
> 
> The code was not using the value DP83867_CLK_O_SEL_REF_CLK as one might
> expect: to select the REF_CLK as the output.  Rather it meant "keep
> clock output setting as is", which, depending on PHY strapping, might
> not be outputting REF_CLK.
> 
> Change this so DP83867_CLK_O_SEL_REF_CLK means enable REF_CLK output.
> Omitting the property will leave the setting as is (which was the
> previous behavior in this case).
> 
> Out of range values were silently converted into
> DP83867_CLK_O_SEL_REF_CLK.  Change this so they generate an error.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Applied.

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

* Re: [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling
  2019-05-22 18:43 ` [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling Trent Piepho
  2019-05-22 18:54   ` Andrew Lunn
@ 2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: David Miller @ 2019-05-23  0:44 UTC (permalink / raw)
  To: tpiepho; +Cc: netdev, devicetree, andrew, f.fainelli, hkallweit1

From: Trent Piepho <tpiepho@impinj.com>
Date: Wed, 22 May 2019 18:43:23 +0000

> The code was assuming the reset default of the delay control register
> was to have delay disabled.  This is what the datasheet shows as the
> register's initial value.  However, that's not actually true: the
> default is controlled by the PHY's pin strapping.
> 
> If the interface mode is selected as RX or TX delay only, insure the
> other direction's delay is disabled.
> 
> If the interface mode is just "rgmii", with neither TX or RX internal
> delay, one might expect that the driver should disable both delays.  But
> this is not what the driver does.  It leaves the setting at the PHY's
> strapping's default.  And that default, for no pins with strapping
> resistors, is to have delay enabled and 2.00 ns.
> 
> Rather than change this behavior, I've kept it the same and documented
> it.  No delay will most likely not work and will break ethernet on any
> board using "rgmii" mode.  If the board is strapped to have a delay and
> is configured to use "rgmii" mode a warning is generated that "rgmii-id"
> should have been used.
> 
> Also validate the delay values and fail if they are not in range.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Applied.

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

* Re: [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties
  2019-05-22 18:43 ` [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties Trent Piepho
  2019-05-22 18:59   ` Andrew Lunn
@ 2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: David Miller @ 2019-05-23  0:44 UTC (permalink / raw)
  To: tpiepho; +Cc: netdev, devicetree, andrew, f.fainelli, hkallweit1

From: Trent Piepho <tpiepho@impinj.com>
Date: Wed, 22 May 2019 18:43:24 +0000

> The variables used to store u32 DT properties were signed ints.  This
> doesn't work properly if the value of the property were to overflow.
> Use unsigned variables so this doesn't happen.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Applied.

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

* Re: [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay
  2019-05-22 18:43 ` [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay Trent Piepho
  2019-05-22 19:03   ` Andrew Lunn
@ 2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: David Miller @ 2019-05-23  0:44 UTC (permalink / raw)
  To: tpiepho; +Cc: netdev, devicetree, andrew, f.fainelli, hkallweit1

From: Trent Piepho <tpiepho@impinj.com>
Date: Wed, 22 May 2019 18:43:25 +0000

> The driver would only set the IO impedance value when RGMII internal
> delays were enabled.  There is no reason for this.  Move the IO
> impedance block out of the RGMII delay block.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Applied.

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

* Re: [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property
  2019-05-22 18:43 ` [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property Trent Piepho
  2019-05-22 19:05   ` Andrew Lunn
@ 2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: David Miller @ 2019-05-23  0:44 UTC (permalink / raw)
  To: tpiepho; +Cc: netdev, devicetree, andrew, f.fainelli, hkallweit1

From: Trent Piepho <tpiepho@impinj.com>
Date: Wed, 22 May 2019 18:43:26 +0000

> Insure property is in valid range and fail when reading DT if it is not.
> Also add error message for existing failure if required property is not
> present.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Applied.

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

* Re: [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe
  2019-05-22 18:43 ` [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe Trent Piepho
  2019-05-22 19:09   ` Andrew Lunn
@ 2019-05-23  0:44   ` David Miller
  1 sibling, 0 replies; 24+ messages in thread
From: David Miller @ 2019-05-23  0:44 UTC (permalink / raw)
  To: tpiepho; +Cc: netdev, devicetree, andrew, f.fainelli, hkallweit1

From: Trent Piepho <tpiepho@impinj.com>
Date: Wed, 22 May 2019 18:43:27 +0000

> This was being done in config the first time the phy was configured.
> Should be in the probe method.
> 
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Florian Fainelli <f.fainelli@gmail.com>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Signed-off-by: Trent Piepho <tpiepho@impinj.com>

Applied.

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

end of thread, other threads:[~2019-05-23  0:44 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 18:43 [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Trent Piepho
2019-05-22 18:43 ` [PATCH net-next v2 2/8] dt-bindings: phy: dp83867: Add documentation for disabling clock output Trent Piepho
2019-05-22 19:11   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 3/8] net: phy: dp83867: Add ability to disable output clock Trent Piepho
2019-05-22 18:51   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 4/8] net: phy: dp83867: Rework delay rgmii delay handling Trent Piepho
2019-05-22 18:54   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 5/8] net: phy: dp83867: Use unsigned variables to store unsigned properties Trent Piepho
2019-05-22 18:59   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 6/8] net: phy: dp83867: IO impedance is not dependent on RGMII delay Trent Piepho
2019-05-22 19:03   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 7/8] net: phy: dp83867: Validate FIFO depth property Trent Piepho
2019-05-22 19:05   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 18:43 ` [PATCH net-next v2 8/8] net: phy: dp83867: Allocate state struct in probe Trent Piepho
2019-05-22 19:09   ` Andrew Lunn
2019-05-23  0:44   ` David Miller
2019-05-22 19:10 ` [PATCH net-next v2 1/8] dt-bindings: phy: dp83867: Describe how driver behaves w.r.t rgmii delay Andrew Lunn
2019-05-23  0:43 ` David Miller

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.