[PATCH v2 3/3] net: phy: dp83867: support setting output-impedance
From: Steffen Trumtrar
Date: Wed Aug 26 2026 - 08:51:52 EST
Currently the dp83867 supports setting the io impedance to minimum,
maximum, default or a value from a nvmem cell. In situations where there
is no backend for a nvmem cell, the value can not be set to anything but
minimum, maximum or default.
Add support for the ti,output-impedance-ohms binding, allowing to
specify the impedance via the devicetree. The existing boolean bindings
for minimum and maximum take precedence over this new binding. The nvmem
consumer still takes lowest precedence.
Signed-off-by: Steffen Trumtrar <s.trumtrar@xxxxxxxxxxxxxx>
---
drivers/net/phy/dp83867.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index 88255e92b4cdb..973b70f11c45a 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -531,7 +531,8 @@ static int dp83867_of_init_io_impedance(struct phy_device *phydev)
struct device *dev = &phydev->mdio.dev;
struct device_node *of_node = dev->of_node;
struct nvmem_cell *cell;
- u8 *buf, val;
+ u8 *buf;
+ u32 val;
int ret;
cell = of_nvmem_cell_get(of_node, "io_impedance_ctrl");
@@ -542,12 +543,21 @@ static int dp83867_of_init_io_impedance(struct phy_device *phydev)
"failed to get nvmem cell io_impedance_ctrl\n");
/* If no nvmem cell, check for the boolean properties. */
- if (of_property_read_bool(of_node, "ti,max-output-impedance"))
+ if (of_property_read_bool(of_node, "ti,max-output-impedance")) {
dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
- else if (of_property_read_bool(of_node, "ti,min-output-impedance"))
+ } else if (of_property_read_bool(of_node, "ti,min-output-impedance")) {
dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN;
- else
+ } else if (of_property_read_u32(of_node, "ti,output-impedance-ohms", &val) == 0) {
+ val = val & DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK;
+ if (val > DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN ||
+ val < DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX) {
+ phydev_err(phydev, "'ti,output-impedance-ohms' contents out of range\n");
+ return -ERANGE;
+ }
+ dp83867->io_impedance = val;
+ } else {
dp83867->io_impedance = -1; /* leave at default */
+ }
return 0;
}
--
2.54.0