summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorYe Li <[email protected]>2025-10-28 10:46:30 +0800
committerFabio Estevam <[email protected]>2025-11-04 12:39:46 -0300
commitb810035c83cc1899067cb3b764f50ba2b7449202 (patch)
tree2bd367c0d1702261ca5394ddd60c09859c715858 /drivers
parentf4e9645108701c1f8e2d2b66d75af95db5387f89 (diff)
net: fsl_enetc_mdio: Add support for phy-supply property
Add support for the optional 'phy-supply' property in the ENETC MDIO driver. This allows the driver to enable and manage the PHY's power supply via the regulator framework when specified in device tree. Signed-off-by: Ye Li <[email protected]> Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Alice Guo <[email protected]>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/fsl_enetc_mdio.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/net/fsl_enetc_mdio.c b/drivers/net/fsl_enetc_mdio.c
index c1d491f2c5a..3d76d92a62a 100644
--- a/drivers/net/fsl_enetc_mdio.c
+++ b/drivers/net/fsl_enetc_mdio.c
@@ -11,6 +11,8 @@
#include <asm/io.h>
#include <asm/processor.h>
#include <miiphy.h>
+#include <linux/delay.h>
+#include <power/regulator.h>
#include "fsl_enetc.h"
@@ -135,6 +137,8 @@ static int enetc_mdio_probe(struct udevice *dev)
struct pci_child_plat *pplat = dev_get_parent_plat(dev);
struct enetc_mdio_priv *priv = dev_get_priv(dev);
u16 cmd = PCI_COMMAND_MEMORY;
+ int ret;
+ struct udevice *supply = NULL;
priv->regs_base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, 0, 0, PCI_REGION_TYPE, 0);
if (!priv->regs_base) {
@@ -144,6 +148,27 @@ static int enetc_mdio_probe(struct udevice *dev)
priv->regs_base += ENETC_MDIO_BASE;
+ if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+ ret = device_get_supply_regulator(dev, "phy-supply",
+ &supply);
+ if (ret && ret != -ENOENT) {
+ printf("%s: device_get_supply_regulator failed: %d\n",
+ __func__, ret);
+ return ret;
+ }
+
+ if (supply) {
+ regulator_set_enable(supply, false);
+ mdelay(100);
+
+ ret = regulator_set_enable_if_allowed(supply, true);
+ if (ret) {
+ printf("%s: Error enabling phy supply\n", dev->name);
+ return ret;
+ }
+ }
+ }
+
if (pplat->vendor == PCI_VENDOR_ID_PHILIPS) /* i.MX95 */
cmd |= PCI_COMMAND_MASTER;