From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jonathan Corbet <corbet@lwn.net>,
Donald Hunter <donald.hunter@gmail.com>,
Rob Herring <robh@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
Simon Horman <horms@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-doc@vger.kernel.org, Kyle Swenson <kyle.swenson@est.tech>,
Dent Project <dentproject@linuxfoundation.org>,
kernel@pengutronix.de,
Maxime Chevallier <maxime.chevallier@bootlin.com>
Subject: Re: [PATCH RFC net-next v3 14/27] net: pse-pd: tps23881: Add support for PSE events and interrupts
Date: Sun, 24 Nov 2024 10:34:04 +0100 [thread overview]
Message-ID: <Z0LzDE8cYdbvx79o@pengutronix.de> (raw)
In-Reply-To: <20241121-feature_poe_port_prio-v3-14-83299fa6967c@bootlin.com>
On Thu, Nov 21, 2024 at 03:42:40PM +0100, Kory Maincent wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@bootlin.com>
>
> Add support for PSE event reporting through interrupts. Set up the newly
> introduced devm_pse_irq_helper helper to register the interrupt. Events are
> reported for over-current and over-temperature conditions.
>
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
>
> Change in v3:
> - Loop over interruption register to be sure the interruption pin is
> freed before exiting the interrupt handler function.
> - Add exist variable to not report event for undescribed PIs.
> - Used helpers to convert the chan number to the PI port number.
>
> Change in v2:
> - Remove support for OSS pin and TPC23881 specific port priority management
> ---
> drivers/net/pse-pd/tps23881.c | 178 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 177 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/pse-pd/tps23881.c b/drivers/net/pse-pd/tps23881.c
> index b25561f95774..6fe8f150231f 100644
> --- a/drivers/net/pse-pd/tps23881.c
> +++ b/drivers/net/pse-pd/tps23881.c
> @@ -17,6 +17,13 @@
>
> #define TPS23881_MAX_CHANS 8
>
> +#define TPS23881_REG_IT 0x0
> +#define TPS23881_REG_IT_MASK 0x1
> +#define TPS23881_REG_IT_IFAULT BIT(5)
> +#define TPS23881_REG_IT_SUPF BIT(7)
> +#define TPS23881_REG_FAULT 0x7
> +#define TPS23881_REG_SUPF_EVENT 0xb
> +#define TPS23881_REG_TSD BIT(7)
> #define TPS23881_REG_PW_STATUS 0x10
> #define TPS23881_REG_OP_MODE 0x12
> #define TPS23881_OP_MODE_SEMIAUTO 0xaaaa
> @@ -24,6 +31,7 @@
> #define TPS23881_REG_DET_CLA_EN 0x14
> #define TPS23881_REG_GEN_MASK 0x17
> #define TPS23881_REG_NBITACC BIT(5)
> +#define TPS23881_REG_INTEN BIT(7)
> #define TPS23881_REG_PW_EN 0x19
> #define TPS23881_REG_2PAIR_POL1 0x1e
> #define TPS23881_REG_PORT_MAP 0x26
> @@ -53,6 +61,7 @@ struct tps23881_port_desc {
> u8 chan[2];
> bool is_4p;
> int pw_pol;
> + bool exist;
> };
>
> struct tps23881_priv {
> @@ -791,8 +800,10 @@ tps23881_write_port_matrix(struct tps23881_priv *priv,
> hw_chan = port_matrix[i].hw_chan[0] % 4;
>
> /* Set software port matrix for existing ports */
> - if (port_matrix[i].exist)
> + if (port_matrix[i].exist) {
> priv->port[pi_id].chan[0] = lgcl_chan;
> + priv->port[pi_id].exist = true;
> + }
>
> /* Initialize power policy internal value */
> priv->port[pi_id].pw_pol = -1;
> @@ -1098,6 +1109,165 @@ static int tps23881_flash_sram_fw(struct i2c_client *client)
> return 0;
> }
>
> +/* Convert interrupt events to 0xff to be aligned with the chan
> + * number.
> + */
> +static u8 tps23881_it_export_chans_helper(u16 reg_val, u8 field_offset)
What is the meaning of _it_?
> +{
> + u8 val;
> +
> + val = (reg_val >> (4 + field_offset) & 0xf0) |
> + (reg_val >> field_offset & 0x0f);
> +
> + return val;
> +}
> +
> +/* Convert chan number to port number */
> +static void tps23881_set_notifs_helper(struct tps23881_priv *priv,
> + u8 chans,
> + unsigned long *notifs,
> + unsigned long *notifs_mask,
> + enum ethtool_pse_events event)
> +{
> + u8 chan;
> + int i;
> +
> + if (!chans)
> + return;
> +
> + for (i = 0; i < TPS23881_MAX_CHANS; i++) {
> + if (!priv->port[i].exist)
> + continue;
> + /* No need to look at the 2nd channel in case of PoE4 as
> + * both registers are set.
> + */
> + chan = priv->port[i].chan[0];
> +
> + if (BIT(chan) & chans) {
> + *notifs_mask |= BIT(i);
> + notifs[i] |= event;
> + }
> + }
> +}
> +
> +static void tps23881_irq_event_over_temp(struct tps23881_priv *priv,
> + u16 reg_val,
> + unsigned long *notifs,
> + unsigned long *notifs_mask)
> +{
> + int i;
> +
> + if (reg_val & TPS23881_REG_TSD) {
> + for (i = 0; i < TPS23881_MAX_CHANS; i++) {
> + if (!priv->port[i].exist)
> + continue;
> +
> + *notifs_mask |= BIT(i);
> + notifs[i] |= ETHTOOL_PSE_EVENT_OVER_TEMP;
Hm, should it be bound to bound to therman zone frame work and start
cooling or something? I guess this can be done in a separate step..
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
--
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 |
next prev parent reply other threads:[~2024-11-24 9:34 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-21 14:42 [PATCH RFC net-next v3 00/27] Add support for PSE port priority Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 01/27] net: pse-pd: Remove unused pse_ethtool_get_pw_limit function declaration Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 02/27] regulator: core: Ignore unset max_uA constraints in current limit check Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 03/27] net: pse-pd: Avoid setting max_uA in regulator constraints Kory Maincent
2024-11-23 6:29 ` Oleksij Rempel
2024-11-24 11:47 ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 04/27] net: pse-pd: Add power limit check Kory Maincent
2024-11-23 6:31 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 05/27] net: pse-pd: tps23881: Simplify function returns by removing redundant checks Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 06/27] net: pse-pd: tps23881: Use helpers to calculate bit offset for a channel Kory Maincent (Dent Project)
2024-11-21 14:42 ` [PATCH RFC net-next v3 07/27] net: pse-pd: tps23881: Add missing configuration register after disable Kory Maincent
2024-11-23 6:35 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 08/27] net: pse-pd: tps23881: Add support for power limit and measurement features Kory Maincent
2024-11-23 7:31 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 09/27] net: pse-pd: Add support for PSE device index Kory Maincent
2024-11-23 7:34 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 10/27] net: ethtool: Add support for new PSE device index description Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 11/27] net: ethtool: Add support for ethnl_info_init_ntf helper function Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 12/27] net: pse-pd: Add support for reporting events Kory Maincent
2024-11-24 9:26 ` Oleksij Rempel
2024-11-25 10:42 ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 13/27] netlink: specs: Add support for PSE netlink notifications Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 14/27] net: pse-pd: tps23881: Add support for PSE events and interrupts Kory Maincent
2024-11-24 9:34 ` Oleksij Rempel [this message]
2024-11-25 11:39 ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 15/27] regulator: core: Resolve supply using of_node from regulator_config Kory Maincent
2024-11-24 9:39 ` Oleksij Rempel
2024-11-24 9:44 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 16/27] regulator: Add support for power budget description Kory Maincent
2024-11-24 9:46 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 17/27] regulator: dt-bindings: Add regulator-power-budget property Kory Maincent
2024-11-21 14:58 ` Mark Brown
2024-11-21 15:27 ` Kory Maincent
2024-11-22 6:57 ` Krzysztof Kozlowski
2024-11-21 14:42 ` [PATCH RFC net-next v3 18/27] net: pse-pd: Fix missing PI of_node description Kory Maincent
2024-11-24 9:49 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 19/27] net: pse-pd: Add support for PSE power domains Kory Maincent
2024-11-24 10:24 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 20/27] net: ethtool: Add support for new power domains index description Kory Maincent
2024-11-26 5:53 ` Oleksij Rempel
2024-11-21 14:42 ` [PATCH RFC net-next v3 21/27] net: pse-pd: Add support for getting and setting port priority Kory Maincent
2024-11-26 8:38 ` Oleksij Rempel
2024-11-26 15:31 ` Kory Maincent
2024-11-26 15:52 ` Kory Maincent
2024-11-27 9:30 ` Oleksij Rempel
2024-11-27 10:11 ` Kory Maincent
2024-11-27 10:31 ` Oleksij Rempel
2024-11-27 11:00 ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 22/27] net: ethtool: Add PSE new port priority support feature Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 23/27] netlink: specs: Expand the PSE netlink command with newly supported features Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 24/27] net: pse-pd: pd692x0: Add support for PSE PI priority feature Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 25/27] dt-bindings: net: pse-pd: microchip,pd692x0: Add manager regulator supply Kory Maincent
2024-11-22 6:58 ` Krzysztof Kozlowski
2024-11-22 8:42 ` Kory Maincent
2024-11-22 9:20 ` Krzysztof Kozlowski
2024-11-21 14:42 ` [PATCH RFC net-next v3 26/27] net: pse-pd: tps23881: Add support for static port priority feature Kory Maincent
2024-12-03 10:29 ` Simon Horman
2024-12-03 10:44 ` Kory Maincent
2024-11-21 14:42 ` [PATCH RFC net-next v3 27/27] dt-bindings: net: pse-pd: ti,tps23881: Add interrupt description Kory Maincent
2024-11-21 16:22 ` (subset) [PATCH RFC net-next v3 00/27] Add support for PSE port priority Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z0LzDE8cYdbvx79o@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=broonie@kernel.org \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=dentproject@linuxfoundation.org \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=kernel@pengutronix.de \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=kyle.swenson@est.tech \
--cc=lgirdwood@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).