Skip to content

Commit 159a076

Browse files
QSchulzdavem330
authored andcommitted
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 <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Acked-by: Fugang Duan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 11d3c94 commit 159a076

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Documentation/devicetree/bindings/net/fsl-fec.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Optional properties:
1515
- phy-reset-active-high : If present then the reset sequence using the GPIO
1616
specified in the "phy-reset-gpios" property is reversed (H=reset state,
1717
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.
1822
- phy-supply : regulator that powers the Ethernet PHY.
1923
- phy-handle : phandle to the PHY device connected to this device.
2024
- fixed-link : Assume a fixed link. See fixed-link.txt in the same directory.

drivers/net/ethernet/freescale/fec_main.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,7 @@ static int fec_reset_phy(struct platform_device *pdev)
31923192
{
31933193
int err, phy_reset;
31943194
bool active_high = false;
3195-
int msec = 1;
3195+
int msec = 1, phy_post_delay = 0;
31963196
struct device_node *np = pdev->dev.of_node;
31973197

31983198
if (!np)
@@ -3209,6 +3209,11 @@ static int fec_reset_phy(struct platform_device *pdev)
32093209
else if (!gpio_is_valid(phy_reset))
32103210
return 0;
32113211

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+
32123217
active_high = of_property_read_bool(np, "phy-reset-active-high");
32133218

32143219
err = devm_gpio_request_one(&pdev->dev, phy_reset,
@@ -3226,6 +3231,15 @@ static int fec_reset_phy(struct platform_device *pdev)
32263231

32273232
gpio_set_value_cansleep(phy_reset, !active_high);
32283233

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+
32293243
return 0;
32303244
}
32313245
#else /* CONFIG_OF */

0 commit comments

Comments
 (0)