net: pse-pd: Add new power limit get and set c33 features
authorKory Maincent (Dent Project) <kory.maincent@bootlin.com>
Thu, 4 Jul 2024 08:11:59 +0000 (10:11 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 6 Jul 2024 01:30:00 +0000 (18:30 -0700)
commit4a83abcef5f4f36be4e04ba18edd64226f6f4a19
tree0bbd9c04dcecd425f3131c8032c2be537d8cd8ab
parentae37dc574259f2750e9e2666591b752678fcd7cc
net: pse-pd: Add new power limit get and set c33 features

This patch add a way to get and set the power limit of a PSE PI.
For that it uses regulator API callbacks wrapper like get_voltage() and
get/set_current_limit() as power is simply V * I.
We used mW unit as defined by the IEEE 802.3-2022 standards.

set_current_limit() uses the voltage return by get_voltage() and the
desired power limit to calculate the current limit. get_voltage() callback
is then mandatory to set the power limit.

get_current_limit() callback is by default looking at a driver callback
and fallback to extracting the current limit from _pse_ethtool_get_status()
if the driver does not set its callback. We prefer let the user the choice
because ethtool_get_status return much more information than the current
limit.

expand pse status with c33_pw_limit_ranges to return the ranges available
to configure the power limit.

Reviewed-by: Sai Krishna <saikrishnag@marvell.com>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Link: https://patch.msgid.link/20240704-feature_poe_power_cap-v6-4-320003204264@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/pse-pd/pse_core.c
include/linux/pse-pd/pse.h