mirror of
https://github.com/openwrt/openwrt.git
synced 2026-05-03 11:55:46 +04:00
528c9259a7
Backport the PSE-PD (Power Sourcing Equipment - Powered Device) framework updates from Linux 6.13 through 6.19. This brings modern PoE (Power over Ethernet) controller support to OpenWrt, enabling userspace control of PSE hardware via ethtool. Key features: - Enhanced ethtool integration for PSE status and configuration - Power domain support with budget evaluation strategies - PSE event reporting via netlink - Port priority management for power budget allocation - New Si3474 PSE controller driver Backported commits: v6.13 core framework and TPS23881 improvements: - 6e56a6d47a7f net: pse-pd: Add power limit check - 0b567519d115 net: pse-pd: tps23881: Simplify function returns - 4c2bab507eb7 net: pse-pd: tps23881: Use helpers to calculate bit offset - f3cb3c7bea0c net: pse-pd: tps23881: Add missing configuration register - 3e9dbfec4998 net: pse-pd: Split ethtool_get_status into multiple callbacks - 4640a1f0d8f2 net: pse-pd: Remove is_enabled callback from drivers - 7f076ce3f173 net: pse-pd: tps23881: Add power limit and measurement features - 10276f3e1c7e net: pse-pd: Fix missing PI of_node description - 5385f1e1923c net: pse-pd: Clean ethtool header of PSE structures v6.17 power domains and event support: - fa2f0454174c net: pse-pd: Introduce attached_phydev to pse control - fc0e6db30941 net: pse-pd: Add support for reporting events - f5e7aecaa4ef net: pse-pd: tps23881: Add support for PSE events - 50f8b341d268 net: pse-pd: Add support for PSE power domains - 1176978ed851 net: ethtool: Add support for power domains index - c394e757dedd net: pse-pd: Add helper to report hw enable status - ffef61d6d273 net: pse-pd: Add support for budget evaluation strategies - 359754013e6a net: pse-pd: pd692x0: Add PSE PI priority feature - 24a4e3a05dd0 net: pse-pd: pd692x0: Add controller and manager power - 56cfc97635e9 net: pse-pd: tps23881: Add static port priority feature - d12b3dc10609 net: pse-pd: pd692x0: reduce stack usage v6.18 Si3474 driver and fixes: - 1c67f9c54cdc net: pse-pd: pd692x0: Fix power budget leak - 7ef353879f71 net: pse-pd: pd692x0: Skip power budget when undefined - a2317231df4b net: pse-pd: Add Si3474 PSE controller driver v6.19 maintenance and TPS23881B support: - 2c95a756e0cf net: pse-pd: tps23881: Fix current measurement scaling - f197902cd21a net: pse-pd: pd692x0: Replace __free macro - 6fa1f8b64a47 net: pse-pd: pd692x0: Separate configuration parsing - 8f3d044b34fe net: pse-pd: pd692x0: Preserve PSE configuration - 4d07797faaa1 net: pse-pd: tps23881: Add support for TPS23881B Signed-off-by: Carlo Szelinsky <github@szelinsky.de> Link: https://github.com/openwrt/openwrt/pull/21810 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
185 lines
6.1 KiB
Diff
185 lines
6.1 KiB
Diff
From 4640a1f0d8f2246f34d6e74330d7e7d2cf75605b Mon Sep 17 00:00:00 2001
|
|
From: Kory Maincent <kory.maincent@bootlin.com>
|
|
Date: Fri, 10 Jan 2025 10:40:28 +0100
|
|
Subject: [PATCH] net: pse-pd: Remove is_enabled callback from drivers
|
|
|
|
The is_enabled callback is now redundant as the admin_state can be obtained
|
|
directly from the driver and provides the same information.
|
|
|
|
To simplify functionality, the core will handle this internally, making
|
|
the is_enabled callback unnecessary at the driver level. Remove the
|
|
callback from all drivers.
|
|
|
|
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
|
|
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
|
|
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|
Signed-off-by: Carlo Szelinsky <github@szelinsky.de>
|
|
---
|
|
drivers/net/pse-pd/pd692x0.c | 26 --------------------------
|
|
drivers/net/pse-pd/pse_core.c | 13 +++++++++++--
|
|
drivers/net/pse-pd/pse_regulator.c | 9 ---------
|
|
drivers/net/pse-pd/tps23881.c | 28 ----------------------------
|
|
include/linux/pse-pd/pse.h | 3 ---
|
|
5 files changed, 11 insertions(+), 68 deletions(-)
|
|
|
|
--- a/drivers/net/pse-pd/pd692x0.c
|
|
+++ b/drivers/net/pse-pd/pd692x0.c
|
|
@@ -431,31 +431,6 @@ static int pd692x0_pi_disable(struct pse
|
|
return 0;
|
|
}
|
|
|
|
-static int pd692x0_pi_is_enabled(struct pse_controller_dev *pcdev, int id)
|
|
-{
|
|
- struct pd692x0_priv *priv = to_pd692x0_priv(pcdev);
|
|
- struct pd692x0_msg msg, buf = {0};
|
|
- int ret;
|
|
-
|
|
- ret = pd692x0_fw_unavailable(priv);
|
|
- if (ret)
|
|
- return ret;
|
|
-
|
|
- msg = pd692x0_msg_template_list[PD692X0_MSG_GET_PORT_STATUS];
|
|
- msg.sub[2] = id;
|
|
- ret = pd692x0_sendrecv_msg(priv, &msg, &buf);
|
|
- if (ret < 0)
|
|
- return ret;
|
|
-
|
|
- if (buf.sub[1]) {
|
|
- priv->admin_state[id] = ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED;
|
|
- return 1;
|
|
- } else {
|
|
- priv->admin_state[id] = ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED;
|
|
- return 0;
|
|
- }
|
|
-}
|
|
-
|
|
struct pd692x0_pse_ext_state_mapping {
|
|
u32 status_code;
|
|
enum ethtool_c33_pse_ext_state pse_ext_state;
|
|
@@ -1105,7 +1080,6 @@ static const struct pse_controller_ops p
|
|
.pi_get_actual_pw = pd692x0_pi_get_actual_pw,
|
|
.pi_enable = pd692x0_pi_enable,
|
|
.pi_disable = pd692x0_pi_disable,
|
|
- .pi_is_enabled = pd692x0_pi_is_enabled,
|
|
.pi_get_voltage = pd692x0_pi_get_voltage,
|
|
.pi_get_pw_limit = pd692x0_pi_get_pw_limit,
|
|
.pi_set_pw_limit = pd692x0_pi_set_pw_limit,
|
|
--- a/drivers/net/pse-pd/pse_core.c
|
|
+++ b/drivers/net/pse-pd/pse_core.c
|
|
@@ -210,16 +210,25 @@ out:
|
|
static int pse_pi_is_enabled(struct regulator_dev *rdev)
|
|
{
|
|
struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev);
|
|
+ struct pse_admin_state admin_state = {0};
|
|
const struct pse_controller_ops *ops;
|
|
int id, ret;
|
|
|
|
ops = pcdev->ops;
|
|
- if (!ops->pi_is_enabled)
|
|
+ if (!ops->pi_get_admin_state)
|
|
return -EOPNOTSUPP;
|
|
|
|
id = rdev_get_id(rdev);
|
|
mutex_lock(&pcdev->lock);
|
|
- ret = ops->pi_is_enabled(pcdev, id);
|
|
+ ret = ops->pi_get_admin_state(pcdev, id, &admin_state);
|
|
+ if (ret)
|
|
+ goto out;
|
|
+
|
|
+ if (admin_state.podl_admin_state == ETHTOOL_PODL_PSE_ADMIN_STATE_ENABLED ||
|
|
+ admin_state.c33_admin_state == ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED)
|
|
+ ret = 1;
|
|
+
|
|
+out:
|
|
mutex_unlock(&pcdev->lock);
|
|
|
|
return ret;
|
|
--- a/drivers/net/pse-pd/pse_regulator.c
|
|
+++ b/drivers/net/pse-pd/pse_regulator.c
|
|
@@ -52,14 +52,6 @@ pse_reg_pi_disable(struct pse_controller
|
|
}
|
|
|
|
static int
|
|
-pse_reg_pi_is_enabled(struct pse_controller_dev *pcdev, int id)
|
|
-{
|
|
- struct pse_reg_priv *priv = to_pse_reg(pcdev);
|
|
-
|
|
- return regulator_is_enabled(priv->ps);
|
|
-}
|
|
-
|
|
-static int
|
|
pse_reg_pi_get_admin_state(struct pse_controller_dev *pcdev, int id,
|
|
struct pse_admin_state *admin_state)
|
|
{
|
|
@@ -95,7 +87,6 @@ static const struct pse_controller_ops p
|
|
.pi_get_admin_state = pse_reg_pi_get_admin_state,
|
|
.pi_get_pw_status = pse_reg_pi_get_pw_status,
|
|
.pi_enable = pse_reg_pi_enable,
|
|
- .pi_is_enabled = pse_reg_pi_is_enabled,
|
|
.pi_disable = pse_reg_pi_disable,
|
|
};
|
|
|
|
--- a/drivers/net/pse-pd/tps23881.c
|
|
+++ b/drivers/net/pse-pd/tps23881.c
|
|
@@ -174,33 +174,6 @@ static int tps23881_pi_disable(struct ps
|
|
return i2c_smbus_write_word_data(client, TPS23881_REG_DET_CLA_EN, val);
|
|
}
|
|
|
|
-static int tps23881_pi_is_enabled(struct pse_controller_dev *pcdev, int id)
|
|
-{
|
|
- struct tps23881_priv *priv = to_tps23881_priv(pcdev);
|
|
- struct i2c_client *client = priv->client;
|
|
- bool enabled;
|
|
- u8 chan;
|
|
- u16 val;
|
|
- int ret;
|
|
-
|
|
- ret = i2c_smbus_read_word_data(client, TPS23881_REG_PW_STATUS);
|
|
- if (ret < 0)
|
|
- return ret;
|
|
-
|
|
- chan = priv->port[id].chan[0];
|
|
- val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4));
|
|
- enabled = !!(val);
|
|
-
|
|
- if (priv->port[id].is_4p) {
|
|
- chan = priv->port[id].chan[1];
|
|
- val = tps23881_calc_val(ret, chan, 0, BIT(chan % 4));
|
|
- enabled &= !!(val);
|
|
- }
|
|
-
|
|
- /* Return enabled status only if both channel are on this state */
|
|
- return enabled;
|
|
-}
|
|
-
|
|
static int
|
|
tps23881_pi_get_admin_state(struct pse_controller_dev *pcdev, int id,
|
|
struct pse_admin_state *admin_state)
|
|
@@ -690,7 +663,6 @@ static const struct pse_controller_ops t
|
|
.setup_pi_matrix = tps23881_setup_pi_matrix,
|
|
.pi_enable = tps23881_pi_enable,
|
|
.pi_disable = tps23881_pi_disable,
|
|
- .pi_is_enabled = tps23881_pi_is_enabled,
|
|
.pi_get_admin_state = tps23881_pi_get_admin_state,
|
|
.pi_get_pw_status = tps23881_pi_get_pw_status,
|
|
};
|
|
--- a/include/linux/pse-pd/pse.h
|
|
+++ b/include/linux/pse-pd/pse.h
|
|
@@ -122,8 +122,6 @@ struct ethtool_pse_control_status {
|
|
* @pi_get_ext_state: Get the extended state of the PSE PI.
|
|
* @pi_get_pw_class: Get the power class of the PSE PI.
|
|
* @pi_get_actual_pw: Get actual power of the PSE PI in mW.
|
|
- * @pi_is_enabled: Return 1 if the PSE PI is enabled, 0 if not.
|
|
- * May also return negative errno.
|
|
* @pi_enable: Configure the PSE PI as enabled.
|
|
* @pi_disable: Configure the PSE PI as disabled.
|
|
* @pi_get_voltage: Return voltage similarly to get_voltage regulator
|
|
@@ -145,7 +143,6 @@ struct pse_controller_ops {
|
|
struct pse_ext_state_info *ext_state_info);
|
|
int (*pi_get_pw_class)(struct pse_controller_dev *pcdev, int id);
|
|
int (*pi_get_actual_pw)(struct pse_controller_dev *pcdev, int id);
|
|
- int (*pi_is_enabled)(struct pse_controller_dev *pcdev, int id);
|
|
int (*pi_enable)(struct pse_controller_dev *pcdev, int id);
|
|
int (*pi_disable)(struct pse_controller_dev *pcdev, int id);
|
|
int (*pi_get_voltage)(struct pse_controller_dev *pcdev, int id);
|