Add an optional device tree property, "ti,output-impedance", which specifies the output impedance using a raw register field value from 0x0 to 0x1f. 0x0 corresponds to the highest impedance (approximately 70 ohms), while 0x1f represents the lowest (approximately 35 ohms). This property allows the impedance to be configured through the device-tree to any required value rather than being limited to fixed minimum or maximum settings. Signed-off-by: Teresa Remmet --- Documentation/devicetree/bindings/net/ti,dp83867.yaml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/net/ti,dp83867.yaml b/Documentation/devicetree/bindings/net/ti,dp83867.yaml index 4bc1f98fd9fe..a8d8bfb68bee 100644 --- a/Documentation/devicetree/bindings/net/ti,dp83867.yaml +++ b/Documentation/devicetree/bindings/net/ti,dp83867.yaml @@ -52,11 +52,20 @@ properties: description: | MAC Interface Impedance control to set the programmable output impedance to a maximum value (70 ohms). - Note: Specifying an io_impedance_ctrl nvmem cell or one of the - ti,min-output-impedance, ti,max-output-impedance properties - are mutually exclusive. If more than one is present, an nvmem - cell takes precedence over ti,max-output-impedance, which in - turn takes precedence over ti,min-output-impedance. + Note: Specifying an io_impedance_ctrl nvmem cell, ti,output-impedance + or one of the boolean ti,min-output-impedance and ti,max-output-impedance + properties is mutually exclusive. + If more than one is present the priority order is nvmem cell, + ti,output-impedance, ti,max-output-impedance and last + ti,min-output-impedance. + + ti,output-impedance: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + MAC Interface Impedance control to set the raw register value from 0x0 + (approx. 70 ohms) to 0x1f (approx. 35 ohms). + minimum: 0 + maximum: 31 tx-fifo-depth: $ref: /schemas/types.yaml#/definitions/uint32 -- 2.43.0 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