Maintainer: Giuseppe Cavallaro <peppe.cavallaro@st.com>
*******************************************************************************/
+#include <linux/gpio/consumer.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/mii.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <linux/of_mdio.h>
#include <linux/phy.h>
#include <linux/slab.h>
#ifdef CONFIG_OF
if (priv->device->of_node) {
+ struct gpio_desc *reset_gpio;
+
if (data->reset_gpio < 0) {
struct device_node *np = priv->device->of_node;
if (!np)
return 0;
- data->reset_gpio = of_get_named_gpio(np,
- "snps,reset-gpio", 0);
- if (data->reset_gpio < 0)
- return 0;
+ reset_gpio = devm_gpiod_get_optional(priv->device,
+ "snps,reset",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(reset_gpio))
+ return PTR_ERR(reset_gpio);
- data->active_low = of_property_read_bool(np,
- "snps,reset-active-low");
of_property_read_u32_array(np,
"snps,reset-delays-us", data->delays, 3);
+ } else {
+ reset_gpio = gpio_to_desc(data->reset_gpio);
- if (devm_gpio_request(priv->device, data->reset_gpio,
- "mdio-reset"))
- return 0;
+ gpiod_direction_output(reset_gpio, 0);
}
- gpio_direction_output(data->reset_gpio,
- data->active_low ? 1 : 0);
if (data->delays[0])
msleep(DIV_ROUND_UP(data->delays[0], 1000));
- gpio_set_value(data->reset_gpio, data->active_low ? 0 : 1);
+ gpiod_set_value_cansleep(reset_gpio, 1);
if (data->delays[1])
msleep(DIV_ROUND_UP(data->delays[1], 1000));
- gpio_set_value(data->reset_gpio, data->active_low ? 1 : 0);
+ gpiod_set_value_cansleep(reset_gpio, 0);
if (data->delays[2])
msleep(DIV_ROUND_UP(data->delays[2], 1000));
}