devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] net: pse-pd: Add TPS23881B support
@ 2025-10-22 22:05 Thomas Wismer
  2025-10-22 22:05 ` [PATCH net-next v2 1/2] net: pse-pd: tps23881: Add support for TPS23881B Thomas Wismer
  2025-10-22 22:05 ` [PATCH net-next v2 2/2] dt-bindings: pse-pd: ti,tps23881: Add TPS23881B Thomas Wismer
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Wismer @ 2025-10-22 22:05 UTC (permalink / raw)
  To: Oleksij Rempel, Kory Maincent, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Thomas Wismer, Thomas Wismer, netdev, devicetree, linux-kernel

This patch series aims at adding support for the TI TPS23881B PoE
PSE controller.

Changes in v2:
- Repost after net-next reopened
- Split off bugfix commit
- Improve commit messages
- Link to v1: https://lore.kernel.org/netdev/20251004180351.118779-2-thomas@wismer.xyz/

Thomas Wismer (2):
  net: pse-pd: tps23881: Add support for TPS23881B
  dt-bindings: pse-pd: ti,tps23881: Add TPS23881B

 .../bindings/net/pse-pd/ti,tps23881.yaml      |  1 +
 drivers/net/pse-pd/tps23881.c                 | 65 +++++++++++++++----
 2 files changed, 52 insertions(+), 14 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 1/2] net: pse-pd: tps23881: Add support for TPS23881B
  2025-10-22 22:05 [PATCH net-next v2 0/2] net: pse-pd: Add TPS23881B support Thomas Wismer
@ 2025-10-22 22:05 ` Thomas Wismer
  2025-10-24 10:49   ` Oleksij Rempel
  2025-10-22 22:05 ` [PATCH net-next v2 2/2] dt-bindings: pse-pd: ti,tps23881: Add TPS23881B Thomas Wismer
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Wismer @ 2025-10-22 22:05 UTC (permalink / raw)
  To: Oleksij Rempel, Kory Maincent, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Thomas Wismer, Thomas Wismer, netdev, devicetree, linux-kernel

From: Thomas Wismer <thomas.wismer@scs.ch>

The TPS23881B uses different firmware than the TPS23881. Trying to load the
TPS23881 firmware on a TPS23881B device fails and must be omitted.

The TPS23881B ships with a more recent ROM firmware. Moreover, no updated
firmware has been released yet and so the firmware loading step must be
skipped. As of today, the TPS23881B is intended to use its ROM firmware.

Signed-off-by: Thomas Wismer <thomas.wismer@scs.ch>
---
 drivers/net/pse-pd/tps23881.c | 65 +++++++++++++++++++++++++++--------
 1 file changed, 51 insertions(+), 14 deletions(-)

diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
index b724b222ab44..f45c08759082 100644
--- a/drivers/net/pse-pd/tps23881.c
+++ b/drivers/net/pse-pd/tps23881.c
@@ -55,8 +55,6 @@
 #define TPS23881_REG_TPON	BIT(0)
 #define TPS23881_REG_FWREV	0x41
 #define TPS23881_REG_DEVID	0x43
-#define TPS23881_REG_DEVID_MASK	0xF0
-#define TPS23881_DEVICE_ID	0x02
 #define TPS23881_REG_CHAN1_CLASS	0x4c
 #define TPS23881_REG_SRAM_CTRL	0x60
 #define TPS23881_REG_SRAM_DATA	0x61
@@ -1012,8 +1010,28 @@ static const struct pse_controller_ops tps23881_ops = {
 	.pi_get_pw_req = tps23881_pi_get_pw_req,
 };
 
-static const char fw_parity_name[] = "ti/tps23881/tps23881-parity-14.bin";
-static const char fw_sram_name[] = "ti/tps23881/tps23881-sram-14.bin";
+struct tps23881_info {
+	u8 dev_id;	/* device ID and silicon revision */
+	const char *fw_parity_name;	/* parity code firmware file name */
+	const char *fw_sram_name;	/* SRAM code firmware file name */
+};
+
+enum tps23881_model {
+	TPS23881,
+	TPS23881B,
+};
+
+static const struct tps23881_info tps23881_info[] = {
+	[TPS23881] = {
+		.dev_id = 0x22,
+		.fw_parity_name = "ti/tps23881/tps23881-parity-14.bin",
+		.fw_sram_name = "ti/tps23881/tps23881-sram-14.bin",
+	},
+	[TPS23881B] = {
+		.dev_id = 0x24,
+		/* skip SRAM load, ROM firmware already IEEE802.3bt compliant */
+	},
+};
 
 struct tps23881_fw_conf {
 	u8 reg;
@@ -1085,16 +1103,17 @@ static int tps23881_flash_sram_fw_part(struct i2c_client *client,
 	return ret;
 }
 
-static int tps23881_flash_sram_fw(struct i2c_client *client)
+static int tps23881_flash_sram_fw(struct i2c_client *client,
+				  const struct tps23881_info *info)
 {
 	int ret;
 
-	ret = tps23881_flash_sram_fw_part(client, fw_parity_name,
+	ret = tps23881_flash_sram_fw_part(client, info->fw_parity_name,
 					  tps23881_fw_parity_conf);
 	if (ret)
 		return ret;
 
-	ret = tps23881_flash_sram_fw_part(client, fw_sram_name,
+	ret = tps23881_flash_sram_fw_part(client, info->fw_sram_name,
 					  tps23881_fw_sram_conf);
 	if (ret)
 		return ret;
@@ -1412,6 +1431,7 @@ static int tps23881_setup_irq(struct tps23881_priv *priv, int irq)
 static int tps23881_i2c_probe(struct i2c_client *client)
 {
 	struct device *dev = &client->dev;
+	const struct tps23881_info *info;
 	struct tps23881_priv *priv;
 	struct gpio_desc *reset;
 	int ret;
@@ -1422,6 +1442,10 @@ static int tps23881_i2c_probe(struct i2c_client *client)
 		return -ENXIO;
 	}
 
+	info = device_get_match_data(dev);
+	if (!info)
+		return -EINVAL;
+
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
@@ -1440,7 +1464,7 @@ static int tps23881_i2c_probe(struct i2c_client *client)
 		 * 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.
+		 * SRAM loading procedure.
 		 */
 		msleep(50);
 	}
@@ -1449,20 +1473,26 @@ static int tps23881_i2c_probe(struct i2c_client *client)
 	if (ret < 0)
 		return ret;
 
-	if (FIELD_GET(TPS23881_REG_DEVID_MASK, ret) != TPS23881_DEVICE_ID) {
+	if (ret != info->dev_id) {
 		dev_err(dev, "Wrong device ID\n");
 		return -ENXIO;
 	}
 
-	ret = tps23881_flash_sram_fw(client);
-	if (ret < 0)
-		return ret;
+	if (info->fw_sram_name) {
+		ret = tps23881_flash_sram_fw(client, info);
+		if (ret < 0)
+			return ret;
+	}
 
 	ret = i2c_smbus_read_byte_data(client, TPS23881_REG_FWREV);
 	if (ret < 0)
 		return ret;
 
-	dev_info(&client->dev, "Firmware revision 0x%x\n", ret);
+	if (ret == 0xFF)
+		dev_warn(&client->dev, "Device entered safe mode\n");
+	else
+		dev_info(&client->dev, "Firmware revision 0x%x%s\n", ret,
+			 ret == 0x00 ? " (ROM firmware)" : "");
 
 	/* Set configuration B, 16 bit access on a single device address */
 	ret = i2c_smbus_read_byte_data(client, TPS23881_REG_GEN_MASK);
@@ -1504,7 +1534,14 @@ static const struct i2c_device_id tps23881_id[] = {
 MODULE_DEVICE_TABLE(i2c, tps23881_id);
 
 static const struct of_device_id tps23881_of_match[] = {
-	{ .compatible = "ti,tps23881", },
+	{
+		.compatible = "ti,tps23881",
+		.data = &tps23881_info[TPS23881]
+	},
+	{
+		.compatible = "ti,tps23881b",
+		.data = &tps23881_info[TPS23881B]
+	},
 	{ },
 };
 MODULE_DEVICE_TABLE(of, tps23881_of_match);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 2/2] dt-bindings: pse-pd: ti,tps23881: Add TPS23881B
  2025-10-22 22:05 [PATCH net-next v2 0/2] net: pse-pd: Add TPS23881B support Thomas Wismer
  2025-10-22 22:05 ` [PATCH net-next v2 1/2] net: pse-pd: tps23881: Add support for TPS23881B Thomas Wismer
@ 2025-10-22 22:05 ` Thomas Wismer
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Wismer @ 2025-10-22 22:05 UTC (permalink / raw)
  To: Oleksij Rempel, Kory Maincent, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: Thomas Wismer, Thomas Wismer, netdev, devicetree, linux-kernel,
	Conor Dooley

From: Thomas Wismer <thomas.wismer@scs.ch>

Add the TPS23881B I2C power sourcing equipment controller to the list of
supported devices.

Falling back to the TPS23881 predecessor device is not suitable as firmware
loading needs to handled differently by the driver. The TPS23881 and
TPS23881B devices require different firmware. Trying to load the TPS23881
firmware on a TPS23881B device fails and must therefore be omitted.

Signed-off-by: Thomas Wismer <thomas.wismer@scs.ch>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
 Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml b/Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml
index bb1ee3398655..0b3803f647b7 100644
--- a/Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml
+++ b/Documentation/devicetree/bindings/net/pse-pd/ti,tps23881.yaml
@@ -16,6 +16,7 @@ properties:
   compatible:
     enum:
       - ti,tps23881
+      - ti,tps23881b
 
   reg:
     maxItems: 1
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2 1/2] net: pse-pd: tps23881: Add support for TPS23881B
  2025-10-22 22:05 ` [PATCH net-next v2 1/2] net: pse-pd: tps23881: Add support for TPS23881B Thomas Wismer
@ 2025-10-24 10:49   ` Oleksij Rempel
  2025-10-29 19:35     ` Thomas Wismer
  0 siblings, 1 reply; 5+ messages in thread
From: Oleksij Rempel @ 2025-10-24 10:49 UTC (permalink / raw)
  To: Thomas Wismer
  Cc: Kory Maincent, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Thomas Wismer, netdev, devicetree, linux-kernel

Hi Thomas,

Thank you for your work.

Looks good, here are some nits:

On Thu, Oct 23, 2025 at 12:05:18AM +0200, Thomas Wismer wrote:
> From: Thomas Wismer <thomas.wismer@scs.ch>
> 
> The TPS23881B uses different firmware than the TPS23881. Trying to load the
> TPS23881 firmware on a TPS23881B device fails and must be omitted.
> 
> The TPS23881B ships with a more recent ROM firmware. Moreover, no updated
> firmware has been released yet and so the firmware loading step must be
> skipped. As of today, the TPS23881B is intended to use its ROM firmware.
> 
> Signed-off-by: Thomas Wismer <thomas.wismer@scs.ch>
> ---
>  drivers/net/pse-pd/tps23881.c | 65 +++++++++++++++++++++++++++--------
>  1 file changed, 51 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
> index b724b222ab44..f45c08759082 100644
> --- a/drivers/net/pse-pd/tps23881.c
> +++ b/drivers/net/pse-pd/tps23881.c
> @@ -55,8 +55,6 @@
>  #define TPS23881_REG_TPON	BIT(0)
>  #define TPS23881_REG_FWREV	0x41
>  #define TPS23881_REG_DEVID	0x43
> -#define TPS23881_REG_DEVID_MASK	0xF0
> -#define TPS23881_DEVICE_ID	0x02
>  #define TPS23881_REG_CHAN1_CLASS	0x4c
>  #define TPS23881_REG_SRAM_CTRL	0x60
>  #define TPS23881_REG_SRAM_DATA	0x61
> @@ -1012,8 +1010,28 @@ static const struct pse_controller_ops tps23881_ops = {
>  	.pi_get_pw_req = tps23881_pi_get_pw_req,
>  };
>  
> -static const char fw_parity_name[] = "ti/tps23881/tps23881-parity-14.bin";
> -static const char fw_sram_name[] = "ti/tps23881/tps23881-sram-14.bin";
> +struct tps23881_info {
> +	u8 dev_id;	/* device ID and silicon revision */
> +	const char *fw_parity_name;	/* parity code firmware file name */
> +	const char *fw_sram_name;	/* SRAM code firmware file name */
> +};
> +
> +enum tps23881_model {
> +	TPS23881,
> +	TPS23881B,
> +};
> +
> +static const struct tps23881_info tps23881_info[] = {
> +	[TPS23881] = {
> +		.dev_id = 0x22,
> +		.fw_parity_name = "ti/tps23881/tps23881-parity-14.bin",
> +		.fw_sram_name = "ti/tps23881/tps23881-sram-14.bin",
> +	},
> +	[TPS23881B] = {
> +		.dev_id = 0x24,
> +		/* skip SRAM load, ROM firmware already IEEE802.3bt compliant */

TL;DR:

A more accurate comment would be:
/* skip SRAM load, ROM provides Clause 145 hardware-level support */

Longer version:

Please reference IEEE 802.3-2022 (Clause 145) instead of the "IEEE
802.3bt" amendment:
- The IEEE 802.3-2022 standard is free for everyone with the IEEE Xplore
  program.
- The "bt" amendment costs money.
- Using the free standard helps all community members review this driver.

The chip (hardware) alone cannot be "compliant." Full compliance for
Type 3 or Type 4 needs the whole system to work correctly:
- The Linux system must handle the DLL (LLDP) classification in software.
  The chip's ROM does not do this.
- The board must supply the correct voltage (e.g., 52V to 57V for Type
  4). This chip's minimum 44V is not compliant with Clause 145.
- The final power supply and board must be designed to handle the high
  power (like 90W).

[...]
> @@ -1422,6 +1442,10 @@ static int tps23881_i2c_probe(struct i2c_client *client)
[...]
>  
> -	dev_info(&client->dev, "Firmware revision 0x%x\n", ret);
> +	if (ret == 0xFF)
> +		dev_warn(&client->dev, "Device entered safe mode\n");

                return -ENODEV; /* Or another appropriate error */

The datasheet states this happens on an "un-recoverable firmware fault."
According to the datasheet, when in "Safe Mode," all ports are shut
down. The device is not in a functional state to act as a PSE
controller.


> +	else
> +		dev_info(&client->dev, "Firmware revision 0x%x%s\n", ret,
> +			 ret == 0x00 ? " (ROM firmware)" : "");
>  
>  	/* Set configuration B, 16 bit access on a single device address */
>  	ret = i2c_smbus_read_byte_data(client, TPS23881_REG_GEN_MASK);
> @@ -1504,7 +1534,14 @@ static const struct i2c_device_id tps23881_id[] = {
>  MODULE_DEVICE_TABLE(i2c, tps23881_id);

I guess tps23881_id should be updated too.

Best Regards,
Oleksij
-- 
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 |

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v2 1/2] net: pse-pd: tps23881: Add support for TPS23881B
  2025-10-24 10:49   ` Oleksij Rempel
@ 2025-10-29 19:35     ` Thomas Wismer
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Wismer @ 2025-10-29 19:35 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Kory Maincent, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley, Thomas Wismer, netdev, devicetree, linux-kernel

Hi Oleksij,

Many thanks for the review.

On Fri, Oct 24, 2025 at 12:49:58 +0200, Oleksij Rempel wrote:
> > +		/* skip SRAM load, ROM firmware already
> > IEEE802.3bt compliant */  
> 
> TL;DR:
> 
> A more accurate comment would be:
> /* skip SRAM load, ROM provides Clause 145 hardware-level support */
> 
> Longer version:
> 
> Please reference IEEE 802.3-2022 (Clause 145) instead of the "IEEE
> 802.3bt" amendment:
> - The IEEE 802.3-2022 standard is free for everyone with the IEEE
> Xplore program.
> - The "bt" amendment costs money.
> - Using the free standard helps all community members review this
> driver.
[...]

Good to know that the IEEE 802.3-2022 standard is available free of charge.
I'm happy to adopt your accurate wording.

> [...]
> > @@ -1422,6 +1442,10 @@ static int tps23881_i2c_probe(struct
> > i2c_client *client)  
> [...]
> >  
> > -	dev_info(&client->dev, "Firmware revision 0x%x\n", ret);
> > +	if (ret == 0xFF)
> > +		dev_warn(&client->dev, "Device entered safe
> > mode\n");  
> 
>                 return -ENODEV; /* Or another appropriate error */
> 
> The datasheet states this happens on an "un-recoverable firmware
> fault." According to the datasheet, when in "Safe Mode," all ports
> are shut down. The device is not in a functional state to act as a PSE
> controller.

The datasheets (TPS23881 from May 2023 / TPS23881B from May 2025) state that,
regarding entering "safe mode", "any channels that are currently powered will
remain powered, but the majority of the operation will be disabled". Because the
rest of the driver code assumes the device to be in a functional state, bailing
out here makes perfect sense.

> > static const struct i2c_device_id tps23881_id[] = {
> >  	{ "tps23881" },
> > 	{ }
> > };
> > MODULE_DEVICE_TABLE(i2c, tps23881_id);
> 
> I guess tps23881_id should be updated too.

Agreed. I will fix this.

Best regards,
Thomas


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-10-29 19:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 22:05 [PATCH net-next v2 0/2] net: pse-pd: Add TPS23881B support Thomas Wismer
2025-10-22 22:05 ` [PATCH net-next v2 1/2] net: pse-pd: tps23881: Add support for TPS23881B Thomas Wismer
2025-10-24 10:49   ` Oleksij Rempel
2025-10-29 19:35     ` Thomas Wismer
2025-10-22 22:05 ` [PATCH net-next v2 2/2] dt-bindings: pse-pd: ti,tps23881: Add TPS23881B Thomas Wismer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).