The DP83867 MAC-side IO impedance is currently configured in the driver either via an NVMEM cell or via the two boolean device tree properties ti,min-output-impedance and ti,max-output-impedance. Some boards require an impedance setting different from the default, minimum, or maximum values, and may not have NVMEM storage available. For such cases, a device tree configuration option is needed. Add a optional device-tree property "ti,output-impedance", that passes the raw register field value (0x0 - 0x1f) representing the range between approximately 70 ohms and 35 ohms. Because the actual impedance range and step size varies depending on the production process, no exact mapping between register value and impedance can be made. The values are determined empirically. If the property is not set the existing behavior is maintained. NVMEM cell has still priority but ti,output-impedance is checked before the boolean min and max values. Signed-off-by: Teresa Remmet --- drivers/net/phy/dp83867.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 5f5de01c41e1..b06d851c3487 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -516,13 +516,22 @@ static int dp83867_of_init_io_impedance(struct phy_device *phydev) return phydev_err_probe(phydev, ret, "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 no nvmem cell, check for the device tree entries */ + ret = of_property_read_u32(of_node, "ti,output-impedance", + (u32 *)&dp83867->io_impedance); + if (!ret) { + if (dp83867->io_impedance > DP83867_IO_MUX_CFG_IO_IMPEDANCE_MASK) { + phydev_err(phydev, "'ti,output-impedance' value %u out of range\n", + dp83867->io_impedance); + return -EINVAL; + } + } else 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 { dp83867->io_impedance = -1; /* leave at default */ + }; return 0; } -- 2.43.0