aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut2017-09-15 21:11:15 +0200
committerNobuhiro Iwamatsu2017-09-24 14:12:07 +0900
commitbddb44e94a51d387ff8fc307d21a5f76bd3093e9 (patch)
treef6b036655dddf3bf0d7f363cd48a420d95efa61c
parent849ab0a66f1a1272022bab912bcbcc4e22648c66 (diff)
net: ravb: Add PHY reset GPIO support
Add support for obtaining PHY reset GPIO from DT and toggling it before configuring the PHY to put the PHY into defined state. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Nobuhiro Iwamatsu <iwamatsu@nigauri.org> Cc: Joe Hershberger <joe.hershberger@ni.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
-rw-r--r--drivers/net/ravb.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c
index 8db127ba06f..dc7a52534e5 100644
--- a/drivers/net/ravb.c
+++ b/drivers/net/ravb.c
@@ -18,6 +18,7 @@
#include <linux/mii.h>
#include <wait_bit.h>
#include <asm/io.h>
+#include <asm/gpio.h>
/* Registers */
#define RAVB_REG_CCC 0x000
@@ -122,6 +123,7 @@ struct ravb_priv {
struct mii_dev *bus;
void __iomem *iobase;
struct clk clk;
+ struct gpio_desc reset_gpio;
};
static inline void ravb_flush_dcache(u32 addr, u32 len)
@@ -302,6 +304,13 @@ static int ravb_phy_config(struct udevice *dev)
struct phy_device *phydev;
int mask = 0xffffffff, reg;
+ if (dm_gpio_is_valid(&eth->reset_gpio)) {
+ dm_gpio_set_value(&eth->reset_gpio, 1);
+ mdelay(20);
+ dm_gpio_set_value(&eth->reset_gpio, 0);
+ mdelay(1);
+ }
+
phydev = phy_find_by_mask(eth->bus, mask, pdata->phy_interface);
if (!phydev)
return -ENODEV;
@@ -483,6 +492,9 @@ static int ravb_probe(struct udevice *dev)
if (ret < 0)
goto err_mdio_alloc;
+ gpio_request_by_name_nodev(dev_ofnode(dev), "reset-gpios", 0,
+ &eth->reset_gpio, GPIOD_IS_OUT);
+
mdiodev = mdio_alloc();
if (!mdiodev) {
ret = -ENOMEM;
@@ -516,6 +528,7 @@ static int ravb_remove(struct udevice *dev)
free(eth->phydev);
mdio_unregister(eth->bus);
mdio_free(eth->bus);
+ dm_gpio_free(dev, &eth->reset_gpio);
unmap_physmem(eth->iobase, MAP_NOCACHE);
return 0;