aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@free-electrons.com>2017-05-23 05:48:08 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-24 15:25:22 -0400
commit159a07604a99bd01e7db112de08d53dc4fcad109 (patch)
tree7cf7377276f4e82b10ef2dc1b53c290e829af7e2
parent11d3c949b4ca37124fcace1ee3a5c2db0737a268 (diff)
net: fec: add post PHY reset delay DT property
Some PHY require to wait for a bit after the reset GPIO has been toggled. This adds support for the DT property `phy-reset-post-delay` which gives the delay in milliseconds to wait after reset. If the DT property is not given, no delay is observed. Post reset delay greater than 1000ms are invalid. Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Acked-by: Fugang Duan <fugang.duan@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/devicetree/bindings/net/fsl-fec.txt4
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c16
2 files changed, 19 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/net/fsl-fec.txt b/Documentation/devicetree/bindings/net/fsl-fec.txt
index a1e3693cca16..6f55bdd52f8a 100644
--- a/Documentation/devicetree/bindings/net/fsl-fec.txt
+++ b/Documentation/devicetree/bindings/net/fsl-fec.txt
@@ -15,6 +15,10 @@ Optional properties:
15- phy-reset-active-high : If present then the reset sequence using the GPIO 15- phy-reset-active-high : If present then the reset sequence using the GPIO
16 specified in the "phy-reset-gpios" property is reversed (H=reset state, 16 specified in the "phy-reset-gpios" property is reversed (H=reset state,
17 L=operation state). 17 L=operation state).
18- phy-reset-post-delay : Post reset delay in milliseconds. If present then
19 a delay of phy-reset-post-delay milliseconds will be observed after the
20 phy-reset-gpios has been toggled. Can be omitted thus no delay is
21 observed. Delay is in range of 1ms to 1000ms. Other delays are invalid.
18- phy-supply : regulator that powers the Ethernet PHY. 22- phy-supply : regulator that powers the Ethernet PHY.
19- phy-handle : phandle to the PHY device connected to this device. 23- phy-handle : phandle to the PHY device connected to this device.
20- fixed-link : Assume a fixed link. See fixed-link.txt in the same directory. 24- fixed-link : Assume a fixed link. See fixed-link.txt in the same directory.
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 56a563f90b0b..f7c8649fd28f 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -3192,7 +3192,7 @@ static int fec_reset_phy(struct platform_device *pdev)
3192{ 3192{
3193 int err, phy_reset; 3193 int err, phy_reset;
3194 bool active_high = false; 3194 bool active_high = false;
3195 int msec = 1; 3195 int msec = 1, phy_post_delay = 0;
3196 struct device_node *np = pdev->dev.of_node; 3196 struct device_node *np = pdev->dev.of_node;
3197 3197
3198 if (!np) 3198 if (!np)
@@ -3209,6 +3209,11 @@ static int fec_reset_phy(struct platform_device *pdev)
3209 else if (!gpio_is_valid(phy_reset)) 3209 else if (!gpio_is_valid(phy_reset))
3210 return 0; 3210 return 0;
3211 3211
3212 err = of_property_read_u32(np, "phy-reset-post-delay", &phy_post_delay);
3213 /* valid reset duration should be less than 1s */
3214 if (!err && phy_post_delay > 1000)
3215 return -EINVAL;
3216
3212 active_high = of_property_read_bool(np, "phy-reset-active-high"); 3217 active_high = of_property_read_bool(np, "phy-reset-active-high");
3213 3218
3214 err = devm_gpio_request_one(&pdev->dev, phy_reset, 3219 err = devm_gpio_request_one(&pdev->dev, phy_reset,
@@ -3226,6 +3231,15 @@ static int fec_reset_phy(struct platform_device *pdev)
3226 3231
3227 gpio_set_value_cansleep(phy_reset, !active_high); 3232 gpio_set_value_cansleep(phy_reset, !active_high);
3228 3233
3234 if (!phy_post_delay)
3235 return 0;
3236
3237 if (phy_post_delay > 20)
3238 msleep(phy_post_delay);
3239 else
3240 usleep_range(phy_post_delay * 1000,
3241 phy_post_delay * 1000 + 1000);
3242
3229 return 0; 3243 return 0;
3230} 3244}
3231#else /* CONFIG_OF */ 3245#else /* CONFIG_OF */