net: mvneta: Add GPIO configuration support
authorAditya Prayoga <aditya@kobol.io>
Tue, 4 Dec 2018 16:39:23 +0000 (00:39 +0800)
committerJoe Hershberger <joe.hershberger@ni.com>
Thu, 24 Jan 2019 17:35:29 +0000 (11:35 -0600)
This patch add GPIO configuration support in mvneta driver.
Driver will handle PHY reset. GPIO pins should be set in device tree.

Ported from mvpp2x
[https://patchwork.ozlabs.org/patch/799654/]

Initial discussion to port the changes into mvneta
[https://patchwork.ozlabs.org/patch/1005765/]

Signed-off-by: Aditya Prayoga <aditya@kobol.io>
Tested-by: Dennis Gilmore <dgilmore@redhat.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
drivers/net/mvneta.c

index 8cb04b52d71ca542ba3e77abcb2309707dde1f0f..333be8ff28b14d97c87d0d3f0396f0ceda13fe84 100644 (file)
@@ -27,6 +27,7 @@
 #include <asm/arch/soc.h>
 #include <linux/compat.h>
 #include <linux/mbus.h>
+#include <asm-generic/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -274,6 +275,9 @@ struct mvneta_port {
        int init;
        int phyaddr;
        struct phy_device *phydev;
+#ifdef CONFIG_DM_GPIO
+       struct gpio_desc phy_reset_gpio;
+#endif
        struct mii_dev *bus;
 };
 
@@ -1749,6 +1753,17 @@ static int mvneta_probe(struct udevice *dev)
        if (ret)
                return ret;
 
+#ifdef CONFIG_DM_GPIO
+       gpio_request_by_name(dev, "phy-reset-gpios", 0,
+                            &pp->phy_reset_gpio, GPIOD_IS_OUT);
+
+       if (dm_gpio_is_valid(&pp->phy_reset_gpio)) {
+               dm_gpio_set_value(&pp->phy_reset_gpio, 1);
+               mdelay(10);
+               dm_gpio_set_value(&pp->phy_reset_gpio, 0);
+       }
+#endif
+
        return board_network_enable(bus);
 }