mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-08 19:12:09 +01:00
net: dm: fec: Fix phy-reset-duration clamping and defaults
The DT binding says: - phy-reset-duration : Reset duration in milliseconds. Should present only if property "phy-reset-gpios" is available. Missing the property will have the duration be 1 millisecond. Numbers greater than 1000 are invalid and 1 millisecond will be used instead. However the current code: - clamps values greater than 1000ms to 1000ms rather than 1. - does not initialize the delay if the property does not exist (else clause mismatch) - returns an error if phy-reset-gpios is not defined Fix all this and simplify by using dev_read_u32_default() Signed-off-by: Martin Fuzzey <martin.fuzzey@flowbird.group> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
9b8b918884
commit
331fcabe4f
@ -1352,22 +1352,19 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev)
|
|||||||
|
|
||||||
#ifdef CONFIG_DM_GPIO
|
#ifdef CONFIG_DM_GPIO
|
||||||
ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
|
ret = gpio_request_by_name(dev, "phy-reset-gpios", 0,
|
||||||
&priv->phy_reset_gpio, GPIOD_IS_OUT);
|
&priv->phy_reset_gpio, GPIOD_IS_OUT);
|
||||||
if (ret == 0) {
|
if (ret < 0)
|
||||||
ret = dev_read_u32_array(dev, "phy-reset-duration",
|
return 0; /* property is optional, don't return error! */
|
||||||
&priv->reset_delay, 1);
|
|
||||||
} else if (ret == -ENOENT) {
|
|
||||||
priv->reset_delay = 1000;
|
|
||||||
ret = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
priv->reset_delay = dev_read_u32_default(dev, "phy-reset-duration", 1);
|
||||||
if (priv->reset_delay > 1000) {
|
if (priv->reset_delay > 1000) {
|
||||||
printf("FEX MXC: gpio reset timeout should be less the 1000\n");
|
printf("FEC MXC: phy reset duration should be <= 1000ms\n");
|
||||||
priv->reset_delay = 1000;
|
/* property value wrong, use default value */
|
||||||
|
priv->reset_delay = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct udevice_id fecmxc_ids[] = {
|
static const struct udevice_id fecmxc_ids[] = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user