Commit d396e84c authored by Sergei Shtylyov's avatar Sergei Shtylyov Committed by David S. Miller

mdio_bus: handle only single PHY reset GPIO

Commit 4c5e7a2c ("dt-bindings: mdio: Clarify binding document")
declared that a MDIO reset GPIO property should have only a single GPIO
reference/specifier, however the supporting code was left intact, still
burdening the kernel with now apparently useless loops -- get rid of them.
Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 61d3e1d9
...@@ -353,19 +353,8 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) ...@@ -353,19 +353,8 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
mutex_init(&bus->mdio_lock); mutex_init(&bus->mdio_lock);
/* de-assert bus level PHY GPIO resets */ /* de-assert bus level PHY GPIO reset */
if (bus->num_reset_gpios > 0) { gpiod = devm_gpiod_get(&bus->dev, "reset", GPIOD_OUT_LOW);
bus->reset_gpiod = devm_kcalloc(&bus->dev,
bus->num_reset_gpios,
sizeof(struct gpio_desc *),
GFP_KERNEL);
if (!bus->reset_gpiod)
return -ENOMEM;
}
for (i = 0; i < bus->num_reset_gpios; i++) {
gpiod = devm_gpiod_get_index(&bus->dev, "reset", i,
GPIOD_OUT_LOW);
if (IS_ERR(gpiod)) { if (IS_ERR(gpiod)) {
err = PTR_ERR(gpiod); err = PTR_ERR(gpiod);
if (err != -ENOENT) { if (err != -ENOENT) {
...@@ -375,12 +364,12 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) ...@@ -375,12 +364,12 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
return err; return err;
} }
} else { } else {
bus->reset_gpiod[i] = gpiod; bus->reset_gpiod = gpiod;
gpiod_set_value_cansleep(gpiod, 1); gpiod_set_value_cansleep(gpiod, 1);
udelay(bus->reset_delay_us); udelay(bus->reset_delay_us);
gpiod_set_value_cansleep(gpiod, 0); gpiod_set_value_cansleep(gpiod, 0);
} }
}
if (bus->reset) if (bus->reset)
bus->reset(bus); bus->reset(bus);
...@@ -414,10 +403,8 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) ...@@ -414,10 +403,8 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner)
} }
/* Put PHYs in RESET to save power */ /* Put PHYs in RESET to save power */
for (i = 0; i < bus->num_reset_gpios; i++) { if (bus->reset_gpiod)
if (bus->reset_gpiod[i]) gpiod_set_value_cansleep(bus->reset_gpiod, 1);
gpiod_set_value_cansleep(bus->reset_gpiod[i], 1);
}
device_del(&bus->dev); device_del(&bus->dev);
return err; return err;
...@@ -442,10 +429,8 @@ void mdiobus_unregister(struct mii_bus *bus) ...@@ -442,10 +429,8 @@ void mdiobus_unregister(struct mii_bus *bus)
} }
/* Put PHYs in RESET to save power */ /* Put PHYs in RESET to save power */
for (i = 0; i < bus->num_reset_gpios; i++) { if (bus->reset_gpiod)
if (bus->reset_gpiod[i]) gpiod_set_value_cansleep(bus->reset_gpiod, 1);
gpiod_set_value_cansleep(bus->reset_gpiod[i], 1);
}
device_del(&bus->dev); device_del(&bus->dev);
} }
......
...@@ -226,7 +226,6 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) ...@@ -226,7 +226,6 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
/* Get bus level PHY reset GPIO details */ /* Get bus level PHY reset GPIO details */
mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY; mdio->reset_delay_us = DEFAULT_GPIO_RESET_DELAY;
of_property_read_u32(np, "reset-delay-us", &mdio->reset_delay_us); of_property_read_u32(np, "reset-delay-us", &mdio->reset_delay_us);
mdio->num_reset_gpios = of_gpio_named_count(np, "reset-gpios");
/* Register the MDIO bus */ /* Register the MDIO bus */
rc = mdiobus_register(mdio); rc = mdiobus_register(mdio);
......
...@@ -226,10 +226,8 @@ struct mii_bus { ...@@ -226,10 +226,8 @@ struct mii_bus {
/* GPIO reset pulse width in microseconds */ /* GPIO reset pulse width in microseconds */
int reset_delay_us; int reset_delay_us;
/* Number of reset GPIOs */ /* RESET GPIO descriptor pointer */
int num_reset_gpios; struct gpio_desc *reset_gpiod;
/* Array of RESET GPIO descriptors */
struct gpio_desc **reset_gpiod;
}; };
#define to_mii_bus(d) container_of(d, struct mii_bus, dev) #define to_mii_bus(d) container_of(d, struct mii_bus, dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment