[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z9gklcNz6wHU9cPC@pengutronix.de>
Date: Mon, 17 Mar 2025 14:33:09 +0100
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: Kory Maincent <kory.maincent@...tlin.com>
Cc: Andrew Lunn <andrew@...n.ch>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Jonathan Corbet <corbet@....net>,
Donald Hunter <donald.hunter@...il.com>,
Rob Herring <robh@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>,
Simon Horman <horms@...nel.org>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
netdev@...r.kernel.org, linux-doc@...r.kernel.org,
Kyle Swenson <kyle.swenson@....tech>,
Dent Project <dentproject@...uxfoundation.org>,
kernel@...gutronix.de,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v6 11/12] net: pse-pd: tps23881: Add support for
static port priority feature
On Tue, Mar 04, 2025 at 11:19:00AM +0100, Kory Maincent wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@...tlin.com>
>
> This patch enhances PSE callbacks by introducing support for the static
> port priority feature. It extends interrupt management to handle and report
> detection, classification, and disconnection events. Additionally, it
> introduces the pi_get_pw_req() callback, which provides information about
> the power requested by the Powered Devices.
>
> Interrupt support is essential for the proper functioning of the TPS23881
> controller. Without it, after a power-on (PWON), the controller will
> no longer perform detection and classification. This could lead to
> potential hazards, such as connecting a non-PoE device after a PoE device,
> which might result in magic smoke.
>
> Signed-off-by: Kory Maincent (Dent Project) <kory.maincent@...tlin.com>
> ---
>
> We may need a fix for the interrupt support in old version of Linux.
>
> Change in v4:
> - Fix variable type nit.
>
> Change in v3:
> - New patch
> ---
> drivers/net/pse-pd/tps23881.c | 204 +++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 194 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
> index 1226667192977..6012c58b47e8a 100644
> --- a/drivers/net/pse-pd/tps23881.c
> +++ b/drivers/net/pse-pd/tps23881.c
> @@ -19,20 +19,30 @@
>
> #define TPS23881_REG_IT 0x0
> #define TPS23881_REG_IT_MASK 0x1
> +#define TPS23881_REG_IT_DISF BIT(2)
> +#define TPS23881_REG_IT_DETC BIT(3)
> +#define TPS23881_REG_IT_CLASC BIT(4)
> #define TPS23881_REG_IT_IFAULT BIT(5)
> #define TPS23881_REG_IT_SUPF BIT(7)
> +#define TPS23881_REG_DET_EVENT 0x5
> #define TPS23881_REG_FAULT 0x7
> #define TPS23881_REG_SUPF_EVENT 0xb
> #define TPS23881_REG_TSD BIT(7)
> +#define TPS23881_REG_DISC 0xc
> #define TPS23881_REG_PW_STATUS 0x10
> #define TPS23881_REG_OP_MODE 0x12
> +#define TPS23881_REG_DISC_EN 0x13
> #define TPS23881_OP_MODE_SEMIAUTO 0xaaaa
> #define TPS23881_REG_DIS_EN 0x13
> #define TPS23881_REG_DET_CLA_EN 0x14
> #define TPS23881_REG_GEN_MASK 0x17
> +#define TPS23881_REG_CLCHE BIT(2)
> +#define TPS23881_REG_DECHE BIT(3)
> #define TPS23881_REG_NBITACC BIT(5)
> #define TPS23881_REG_INTEN BIT(7)
> #define TPS23881_REG_PW_EN 0x19
> +#define TPS23881_REG_RESET 0x1a
> +#define TPS23881_REG_CLRAIN BIT(7)
> #define TPS23881_REG_2PAIR_POL1 0x1e
> #define TPS23881_REG_PORT_MAP 0x26
> #define TPS23881_REG_PORT_POWER 0x29
> @@ -177,6 +187,7 @@ static int tps23881_pi_enable(struct pse_controller_dev *pcdev, int id)
> struct i2c_client *client = priv->client;
> u8 chan;
> u16 val;
> + int ret;
>
> if (id >= TPS23881_MAX_CHANS)
> return -ERANGE;
> @@ -190,7 +201,22 @@ static int tps23881_pi_enable(struct pse_controller_dev *pcdev, int id)
> BIT(chan % 4));
> }
>
> - return i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val);
> + ret = i2c_smbus_write_word_data(client, TPS23881_REG_PW_EN, val);
> + if (ret)
> + return ret;
> +
> + /* Enable DC disconnect*/
> + chan = priv->port[id].chan[0];
> + ret = i2c_smbus_read_word_data(client, TPS23881_REG_DISC_EN);
> + if (ret < 0)
> + return ret;
Here we have RMW operation without lock on two paths: pi_enable and
pi_disable.
> + val = tps23881_set_val(ret, chan, 0, BIT(chan % 4), BIT(chan % 4));
> + ret = i2c_smbus_write_word_data(client, TPS23881_REG_DISC_EN, val);
> + if (ret)
> + return ret;
> +
> + return 0;
> }
>
> static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
> @@ -223,6 +249,17 @@ static int tps23881_pi_disable(struct pse_controller_dev *pcdev, int id)
> */
> mdelay(5);
>
> + /* Disable DC disconnect*/
> + chan = priv->port[id].chan[0];
> + ret = i2c_smbus_read_word_data(client, TPS23881_REG_DISC_EN);
> + if (ret < 0)
> + return ret;
dito
> + val = tps23881_set_val(ret, chan, 0, 0, BIT(chan % 4));
> + ret = i2c_smbus_write_word_data(client, TPS23881_REG_DISC_EN, val);
> + if (ret)
> + return ret;
> +
--
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 |
Powered by blists - more mailing lists