net: pse-pd: Use regulator framework within PSE framework
authorKory Maincent (Dent Project) <kory.maincent@bootlin.com>
Wed, 17 Apr 2024 14:39:58 +0000 (16:39 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 19 Apr 2024 01:27:39 +0000 (18:27 -0700)
commitd83e13761d5b0568376963729abcccf6de5a43ba
tree389c26e850d2bc1b4d2d8be34d8b00ccb8adc1a0
parent29e28d1d7a16a3f6dba55c1df5cc6e0f9edf3017
net: pse-pd: Use regulator framework within PSE framework

Integrate the regulator framework to the PSE framework for enhanced
access to features such as voltage, power measurement, and limits, which
are akin to regulators. Additionally, PSE features like port priorities
could potentially enhance the regulator framework. Note that this
integration introduces some implementation complexity, including wrapper
callbacks, but the potential benefits make it worthwhile.

Regulator are using enable counter with specific behavior.
Two calls to regulator_disable will trigger kernel warnings.
If the counter exceeds one, regulator_disable call won't disable the
PSE PI. These behavior isn't suitable for PSE control.
Added a boolean 'enabled' state to prevent multiple calls to
regulator_enable/disable. These calls will only be called from PSE
framework as it won't have any regulator children, therefore no mutex are
needed to safeguards this boolean.

regulator_get needs the consumer device pointer. Use PSE as regulator
provider and consumer device until we have RJ45 ports represented in
the Kernel.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20240417-feature_poe-v9-10-242293fd1900@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/pse-pd/pse_core.c
drivers/net/pse-pd/pse_regulator.c
include/linux/pse-pd/pse.h