Skip to contentSkip to conversation

net: pse-pd: tps23881: Reset GPIO support

PATCH In review Kyle Swenson 4 participants 8 messages Aug 22, 2024 – Aug 27, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover net: pse-pd: tps23881: Reset GPIO support

On some boards, the TPS2388x's reset line (active low) is pulled low to keep the chip in reset until the SoC pulls the device out of reset. This series updates the device-tree binding for the tps23881 and then adds support for the reset gpio handling in the tps23881 driver.

v1 -> v2:
- Changed the reset pulse duration to be between 5us and 10us, per the

    TPS23880 datasheet

- Changed the delay after reset to be 50ms instead of 1-10ms in order to meet the minimum recommended time before SRAM programming.

v1: https://lore.kernel.org/netdev/[email protected]/

Kyle Swenson (2):
dt-bindings: pse: tps23881: add reset-gpios
net: pse-pd: tps23881: Support reset-gpios

 .../bindings/net/pse-pd/ti,tps23881.yaml      |  3 +++
 drivers/net/pse-pd/tps23881.c                 | 21 +++++++++++++++++++
 2 files changed, 24 insertions(+)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/2 dt-bindings: pse: tps23881: add reset-gpios

The TPS23881 has an active-low reset pin that can be connected to an SoC. Document this with the device-tree binding.

---
 Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml +3 -0
index 6992d56832bf..d08abcb01211 100644
@@ -21,10 +21,13 @@ properties:
     maxItems: 1
 
   '#pse-cells':
     const: 1
 
+  reset-gpios:
+    maxItems: 1
+
   channels:
     description: each set of 8 ports can be assigned to one physical
       channels or two for PoE4. This parameter describes the configuration
       of the ports conversion matrix that establishes relationship between
       the logical ports and the physical channels.
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH net-next v2 1/2] dt-bindings: pse: tps23881: add reset-gpios

Quoted 5 lines · Kyle Swenson

The TPS23881 has an active-low reset pin that can be connected to an SoC. Document this with the device-tree binding.

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 Reviewed-by on v2 1/2
#3 lore raw

Re: [PATCH net-next v2 1/2] dt-bindings: pse: tps23881: add reset-gpios

In reply to Kyle Swenson
Quoted 2 lines · On Thu, 22 Aug 2024 22:01:21 +0000 Kyle Swenson <[email protected]> wrote:

The TPS23881 has an active-low reset pin that can be connected to an SoC. Document this with the device-tree binding.

Thank you!

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
#4 lore raw

PATCH v2 2/2 net: pse-pd: tps23881: Support reset-gpios

In reply to Kyle Swenson

The TPS23880/1 has an active-low reset pin that some boards connect to the SoC to control when the TPS23880 is pulled out of reset.

Add support for this via a reset-gpios property in the DTS.

---
 drivers/net/pse-pd/tps23881.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/net/pse-pd/tps23881.c +21 -0
index 2ea75686a319..5c4e88be46ee 100644
@@ -6,10 +6,11 @@
  */
 
 #include <linux/bitfield.h>
 #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>
 #include <linux/platform_device.h>
 #include <linux/pse-pd/pse.h>
@@ -735,10 +736,11 @@ static int tps23881_flash_sram_fw(struct i2c_client *client)
 
 static int tps23881_i2c_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
 	struct tps23881_priv *priv;
+	struct gpio_desc *reset;
 	int ret;
 	u8 val;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		dev_err(dev, "i2c check functionality failed\n");
@@ -747,10 +749,29 @@ static int tps23881_i2c_probe(struct i2c_client *client)
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
+	reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(reset))
+		return dev_err_probe(&client->dev, PTR_ERR(reset), "Failed to get reset GPIO\n");
+
+	if (reset) {
+		/* TPS23880 datasheet (Rev G) indicates minimum reset pulse is 5us */
+		usleep_range(5, 10);
+		gpiod_set_value_cansleep(reset, 0); /* De-assert reset */
+
+		/* TPS23880 datasheet indicates the minimum time after power on reset
+		 * should be 20ms, but the document describing how to load SRAM ("How
+		 * to Load TPS2388x SRAM and Parity Code over I2C" (Rev E))
+		 * indicates we should delay that programming by at least 50ms. So
+		 * we'll wait the entire 50ms here to ensure we're safe to go to the
+		 * SRAM loading proceedure.
+		 */
+		msleep(50);
+	}
+
 	ret = i2c_smbus_read_byte_data(client, TPS23881_REG_DEVID);
 	if (ret < 0)
 		return ret;
 
 	if (FIELD_GET(TPS23881_REG_DEVID_MASK, ret) != TPS23881_DEVICE_ID) {
Signature · 1 line
2.43.0
maintainer Acked-by on v2 2/2
#5 lore raw

Re: [PATCH net-next v2 2/2] net: pse-pd: tps23881: Support reset-gpios

Quoted 6 lines · Kyle Swenson

The TPS23880/1 has an active-low reset pin that some boards connect to the SoC to control when the TPS23880 is pulled out of reset.

Add support for this via a reset-gpios property in the DTS.

Thank you!

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 Reviewed-by on v2 2/2
#6 lore raw

Re: [PATCH net-next v2 2/2] net: pse-pd: tps23881: Support reset-gpios

In reply to Kyle Swenson
Quoted 4 lines · On Thu, 22 Aug 2024 22:01:22 +0000 Kyle Swenson <[email protected]> wrote:

The TPS23880/1 has an active-low reset pin that some boards connect to the SoC to control when the TPS23880 is pulled out of reset.

Add support for this via a reset-gpios property in the DTS.

Thank you!

Signature · 3 lines
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
maintainer
#7 lore raw
In reply to Kyle Swenson
Quoted 15 lines · Kyle Swenson

On some boards, the TPS2388x's reset line (active low) is pulled low to keep the chip in reset until the SoC pulls the device out of reset. This series updates the device-tree binding for the tps23881 and then adds support for the reset gpio handling in the tps23881 driver.

v1 -> v2:
- Changed the reset pulse duration to be between 5us and 10us, per the

     TPS23880 datasheet

- Changed the delay after reset to be 50ms instead of 1-10ms in order to meet the minimum recommended time before SRAM programming.

v1: https://lore.kernel.org/netdev/[email protected]/

Quoted 7 lines

Kyle Swenson (2):
dt-bindings: pse: tps23881: add reset-gpios
net: pse-pd: tps23881: Support reset-gpios

  .../bindings/net/pse-pd/ti,tps23881.yaml      |  3 +++
  drivers/net/pse-pd/tps23881.c                 | 21 +++++++++++++++++++
  2 files changed, 24 insertions(+)

This has been applied by Jakub, but the bot failed to send the notification.

Thanks,

Paolo