Skip to contentSkip to conversation

dt-bindings: net: pse-pd: microchip,pd692x0: add port disable GPIO

PATCH Superseded Robert Marko 4 participants 5 messages May 15 – May 20

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 dt-bindings: net: pse-pd: microchip,pd692x0: add port disable GPIO

From: Robert Marko <[email protected]>

Microchip PSE controllers have a dedicated port disable input that like it name suggest, will disable PoE on all ports.

So, lets document that GPIO.

---
Changes in v2:
* Pick Acked-by from Rob

 .../devicetree/bindings/net/pse-pd/microchip,pd692x0.yaml     | 4 ++++
 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/net/pse-pd/microchip,pd692x0.yaml +4 -0
index ca61cc37a790..ca4200afa793 100644
@@ -22,6 +22,10 @@ properties:
   reg:
     maxItems: 1
 
+  disable-ports-gpios:
+    description: GPIO pin to disable PoE on all ports
+    maxItems: 1
+
   vdd-supply:
     description: Regulator that provides 3.3V VDD power supply.
 
Signature · 1 line
2.54.0
#1 lore raw

PATCH v2 2/2 net: pse-pd: pd692x0: support disabling disable ports GPIO

From: Robert Marko <[email protected]>

Microchip PSE controllers have a dedicated disable ports input that like it name says disables PoE on all ports.

So lets support parsing that GPIO and using the GPIO flags to set it to output high by default and enable PoE on all ports during probe.

---
Changes in v2:
* Use GPIOD_OUT_LOW by default so that DTS reflects the real active state

 drivers/net/pse-pd/pd692x0.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/pse-pd/pd692x0.c +7 -0
index 4a3c852780f5..6c5c5a26bbaa 100644
@@ -7,6 +7,7 @@
 
 #include <linux/delay.h>
 #include <linux/firmware.h>
+#include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -1757,6 +1758,7 @@ static int pd692x0_i2c_probe(struct i2c_client *client)
 	static const char * const regulators[] = { "vdd", "vdda" };
 	struct pd692x0_msg msg, buf = {0}, zero = {0};
 	struct device *dev = &client->dev;
+	struct gpio_desc *disable_ports;
 	struct pd692x0_msg_ver ver;
 	struct pd692x0_priv *priv;
 	struct fw_upload *fwl;
@@ -1780,6 +1782,11 @@ static int pd692x0_i2c_probe(struct i2c_client *client)
 	priv->client = client;
 	i2c_set_clientdata(client, priv);
 
+	disable_ports = devm_gpiod_get_optional(dev, "disable-ports", GPIOD_OUT_LOW);
+	if (IS_ERR(disable_ports))
+		return dev_err_probe(&client->dev, PTR_ERR(disable_ports),
+				     "Failed to get disable ports GPIO\n");
+
 	ret = i2c_master_recv(client, (u8 *)&buf, sizeof(buf));
 	if (ret != sizeof(buf)) {
 		dev_err(dev, "Failed to get device status\n");
Signature · 1 line
2.54.0
#2 lore raw

Re: [PATCH net-next v2 2/2] net: pse-pd: pd692x0: support disabling disable ports GPIO

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Contradiction between commit message and code regarding the initial GPIO state. - [Low]…

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Contradiction between commit message and code regarding the initial GPIO state.
- [Low] Inconsistent usage of the device pointer in the error handling path. --

commit e53266c93f6ce835ab8c0c15eb780fa85ffd5a46
Author: Robert Marko <[email protected]>

net: pse-pd: pd692x0: support disabling disable ports GPIO

This commit adds support for parsing the disable ports GPIO on Microchip PSE controllers and configuring its default state to enable PoE during probe.

Quoted 2 lines

So lets support parsing that GPIO and using the GPIO flags to set it to output high by default and enable PoE on all ports during probe.

Does the commit message contradict the implementation?

The message mentions setting the GPIO to "output high by default", but the code below uses GPIOD_OUT_LOW.

While setting a "disable-ports" pin low to enable PoE makes logical sense, could the commit message be updated to accurately reflect the code's behavior?

Quoted 4 lines
drivers/net/pse-pd/pd692x0.c +0 -0
index 4a3c852780f58..6c5c5a26bbaa6 100644

[ ... ]

drivers/net/pse-pd/pd692x0.c static int pd692x0_i2c_probe(struct i2c_client *client) · line 1788

Quoted 8 lines
drivers/net/pse-pd/pd692x0.c +4 -0
@@ -1780,6 +1782,11 @@ static int pd692x0_i2c_probe(struct i2c_client *client)
 	priv->client = client;
 	i2c_set_clientdata(client, priv);
 
+	disable_ports = devm_gpiod_get_optional(dev, "disable-ports", GPIOD_OUT_LOW);
+	if (IS_ERR(disable_ports))
+		return dev_err_probe(&client->dev, PTR_ERR(disable_ports),
+				     "Failed to get disable ports GPIO\n");

This isn't a bug, but should this use the local 'dev' variable instead of dereferencing '&client->dev' again?

The 'dev' variable is used in the devm_gpiod_get_optional() call just above this line.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
maintainer Acked-by on v2 2/2
#3 lore raw

Re: [PATCH net-next v2 2/2] net: pse-pd: pd692x0: support disabling disable ports GPIO

In reply to Robert Marko
Quoted 9 lines · Robert Marko

From: Robert Marko <[email protected]>

Microchip PSE controllers have a dedicated disable ports input that like it name says disables PoE on all ports.

So lets support parsing that GPIO and using the GPIO flags to set it to output high by default and enable PoE on all ports during probe.

Thank you!

Best Regards,
Oleksij

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
maintainer
#4 lore raw

Re: [PATCH net-next v2 2/2] net: pse-pd: pd692x0: support disabling disable ports GPIO

In reply to Robert Marko

This is an AI-generated review of your patch. The human sending this email says "nit picks but why not.."
---
net: pse-pd: pd692x0: support disabling disable ports GPIO

This commit adds support for parsing the disable ports GPIO on Microchip PSE controllers and configuring its default state to enable PoE during probe.

Quoted 2 lines

So lets support parsing that GPIO and using the GPIO flags to set it to output high by default and enable PoE on all ports during probe.

Does the commit message contradict the implementation?

The message mentions setting the GPIO to "output high by default", but the code below uses GPIOD_OUT_LOW.

While setting a "disable-ports" pin low to enable PoE makes logical sense, could the commit message be updated to accurately reflect the code's behavior?

Quoted 4 lines
drivers/net/pse-pd/pd692x0.c +0 -0
index 4a3c852780f58..6c5c5a26bbaa6 100644

[ ... ]

drivers/net/pse-pd/pd692x0.c static int pd692x0_i2c_probe(struct i2c_client *client) · line 1788

Quoted 8 lines
drivers/net/pse-pd/pd692x0.c +4 -0
@@ -1780,6 +1782,11 @@ static int pd692x0_i2c_probe(struct i2c_client *client)
 	priv->client = client;
 	i2c_set_clientdata(client, priv);
 
+	disable_ports = devm_gpiod_get_optional(dev, "disable-ports", GPIOD_OUT_LOW);
+	if (IS_ERR(disable_ports))
+		return dev_err_probe(&client->dev, PTR_ERR(disable_ports),
+				     "Failed to get disable ports GPIO\n");

This isn't a bug, but should this use the local 'dev' variable instead of dereferencing '&client->dev' again?

The 'dev' variable is used in the devm_gpiod_get_optional() call just above this line.

Signature · 1 line
pw-bot: cr