Skip to contentSkip to conversation

net: mvneta: Add GPIO configuration support

PATCH In review Aditya Prayoga 4 participants 5 messages Dec 4, 2018 – Jan 24, 2019 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: mvneta: Add GPIO configuration support

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/]

---
 drivers/net/mvneta.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/mvneta.c +15 -0
index 8cb04b5..333be8f 100644
@@ -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);
 }
 
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 net: mvneta: Add GPIO configuration support

Quoted 54 lines · Aditya Prayoga

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/]

---
 drivers/net/mvneta.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/mvneta.c +15 -0
index 8cb04b5..333be8f 100644
@@ -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);
 }
 
#2 lore raw

PATCH 1/1 net: mvneta: Add GPIO configuration support

In reply to Aditya Prayoga
Quoted 45 lines · Aditya Prayoga

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/]

---
  drivers/net/mvneta.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
drivers/net/mvneta.c +8 -0
index 8cb04b5..333be8f 100644
@@ -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);
+

drivers/net/mvneta.c static int mvneta_probe(struct udevice *dev) · line 1769

Quoted 10 lines
drivers/net/mvneta.c +7 -0
+	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);
  }
 

Thanks,
Stefan

#3 lore raw

PATCH 1/1 net: mvneta: Add GPIO configuration support

In reply to Aditya Prayoga
Quoted 11 lines · Aditya Prayoga

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/]