diff mbox

[U-Boot,PATCHv2,01/10] net: mvpp2x: Add GPIO configuration support

Message ID 1502264272-27773-2-git-send-email-stefanc@marvell.com
State Awaiting Upstream
Delegated to: Stefan Roese
Headers show

Commit Message

Stefan Chulski Aug. 9, 2017, 7:37 a.m. UTC
From: Stefan Chulski <stefanc@marvell.com>

This patch add GPIO configuration support in mvpp2x driver.
Driver will handle 10G SFP gpio reset and SFP TX disable. GPIO pins should
be set in device tree.

Signed-off-by: Stefan Chulski <stefanc@marvell.com>
Tested-by: iSoC Platform CI <ykjenk@marvell.com>
Reviewed-by: Kostya Porotchkin <kostap@marvell.com>
Reviewed-by: Igal Liberman <igall@marvell.com>
---
 drivers/net/mvpp2.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Comments

Joe Hershberger Aug. 9, 2017, 3:27 p.m. UTC | #1
On Wed, Aug 9, 2017 at 2:37 AM,  <stefanc@marvell.com> wrote:
> From: Stefan Chulski <stefanc@marvell.com>
>
> This patch add GPIO configuration support in mvpp2x driver.
> Driver will handle 10G SFP gpio reset and SFP TX disable. GPIO pins should
> be set in device tree.
>
> Signed-off-by: Stefan Chulski <stefanc@marvell.com>
> Tested-by: iSoC Platform CI <ykjenk@marvell.com>
> Reviewed-by: Kostya Porotchkin <kostap@marvell.com>
> Reviewed-by: Igal Liberman <igall@marvell.com>

When a former version of a patch has been Acked, you should include it
in the next version.

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

> ---
>  drivers/net/mvpp2.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
diff mbox

Patch

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index 1b46218..2198b73 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -30,6 +30,7 @@ 
 #include <asm/arch/soc.h>
 #include <linux/compat.h>
 #include <linux/mbus.h>
+#include <asm-generic/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -985,6 +986,10 @@  struct mvpp2_port {
 	phy_interface_t phy_interface;
 	int phy_node;
 	int phyaddr;
+#ifdef CONFIG_DM_GPIO
+	struct gpio_desc phy_reset_gpio;
+	struct gpio_desc phy_tx_disable_gpio;
+#endif
 	int init;
 	unsigned int link;
 	unsigned int duplex;
@@ -4765,6 +4770,13 @@  static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
 		return -EINVAL;
 	}
 
+#ifdef CONFIG_DM_GPIO
+	gpio_request_by_name(dev, "phy-reset-gpios", 0,
+			     &port->phy_reset_gpio, GPIOD_IS_OUT);
+	gpio_request_by_name(dev, "marvell,sfp-tx-disable-gpio", 0,
+			     &port->phy_tx_disable_gpio, GPIOD_IS_OUT);
+#endif
+
 	/*
 	 * ToDo:
 	 * Not sure if this DT property "phy-speed" will get accepted, so
@@ -4786,6 +4798,21 @@  static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port)
 	return 0;
 }
 
+#ifdef CONFIG_DM_GPIO
+/* Port GPIO initialization */
+static void mvpp2_gpio_init(struct mvpp2_port *port)
+{
+	if (dm_gpio_is_valid(&port->phy_reset_gpio)) {
+		dm_gpio_set_value(&port->phy_reset_gpio, 0);
+		udelay(1000);
+		dm_gpio_set_value(&port->phy_reset_gpio, 1);
+	}
+
+	if (dm_gpio_is_valid(&port->phy_tx_disable_gpio))
+		dm_gpio_set_value(&port->phy_tx_disable_gpio, 0);
+}
+#endif
+
 /* Ports initialization */
 static int mvpp2_port_probe(struct udevice *dev,
 			    struct mvpp2_port *port,
@@ -4804,6 +4831,10 @@  static int mvpp2_port_probe(struct udevice *dev,
 	}
 	mvpp2_port_power_up(port);
 
+#ifdef CONFIG_DM_GPIO
+	mvpp2_gpio_init(port);
+#endif
+
 	priv->port_list[port->id] = port;
 	return 0;
 }