Devicetree
 help / color / mirror / Atom feed
From: Dan Murphy <dmurphy@ti.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: <f.fainelli@gmail.com>, <hkallweit1@gmail.com>,
	<davem@davemloft.net>, <robh@kernel.org>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<devicetree@vger.kernel.org>
Subject: Re: [PATCH net-next v3 4/4] net: dp83869: Add RGMII internal delay configuration
Date: Wed, 27 May 2020 07:23:56 -0500	[thread overview]
Message-ID: <c0867d48-6f04-104b-8192-d61d4464a65f@ti.com> (raw)
In-Reply-To: <20200527005224.GF782807@lunn.ch>

Andrew

On 5/26/20 7:52 PM, Andrew Lunn wrote:
>> @@ -218,6 +224,7 @@ static int dp83869_of_init(struct phy_device *phydev)
>>   		ret = phy_read_mmd(phydev, DP83869_DEVADDR, DP83869_STRAP_STS1);
>>   		if (ret < 0)
>>   			return ret;
>> +
>>   		if (ret & DP83869_STRAP_MIRROR_ENABLED)
>>   			dp83869->port_mirroring = DP83869_PORT_MIRRORING_EN;
>>   		else
> This random white space change does not belong in this patch.

OK


>> @@ -232,6 +239,20 @@ static int dp83869_of_init(struct phy_device *phydev)
>>   				 &dp83869->tx_fifo_depth))
>>   		dp83869->tx_fifo_depth = DP83869_PHYCR_FIFO_DEPTH_4_B_NIB;
>>   
>> +	ret = of_property_read_u32(of_node, "rx-internal-delay-ps",
>> +				   &dp83869->rx_id_delay);
>> +	if (ret) {
>> +		dp83869->rx_id_delay = ret;
>> +		ret = 0;
>> +	}
> This looks odd.
>
> If this optional property is not found, -EINVAL will be returned. It
> could also return -ENODATA. You then assign this error value to
> dp83869->rx_id_delay? I would of expected you to assign 2000, the
> default value?

Well the driver cannot assume this is the intended value.

If the dt defines rgmii-rx/tx-id then these values are required not 
optional.  That was the discussion on the binding.

I set these to errno because when config_init is called the driver 
verifies that the values are valid and present and if they

are not then the PHY will fail to init.

If we set the delay to default then the PHY may be programmed with the 
wrong delay.


>> +
>> +	ret = of_property_read_u32(of_node, "tx-internal-delay-ps",
>> +				   &dp83869->tx_id_delay);
>> +	if (ret) {
>> +		dp83869->tx_id_delay = ret;
>> +		ret = 0;
>> +	}
>> +
>>   	return ret;
>>   }
>>   #else
>> @@ -367,10 +388,45 @@ static int dp83869_configure_mode(struct phy_device *phydev,
>>   	return ret;
>>   }
>>   
>> +static int dp83869_get_delay(struct phy_device *phydev)
>> +{
>> +	struct dp83869_private *dp83869 = phydev->priv;
>> +	int delay_size = ARRAY_SIZE(dp83869_internal_delay);
>> +	int tx_delay = 0;
>> +	int rx_delay = 0;
>> +
>> +	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID ||
>> +	    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
>> +		tx_delay = phy_get_delay_index(phydev,
>> +					       &dp83869_internal_delay[0],
>> +					       delay_size, dp83869->tx_id_delay,
>> +					       false);
>> +		if (tx_delay < 0) {
>> +			phydev_err(phydev, "Tx internal delay is invalid\n");
>> +			return tx_delay;
>> +		}
>> +	}
>> +
>> +	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID ||
>> +	    phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
>> +		rx_delay = phy_get_delay_index(phydev,
>> +					       &dp83869_internal_delay[0],
>> +					       delay_size, dp83869->rx_id_delay,
>> +					       false);
>> +		if (rx_delay < 0) {
>> +			phydev_err(phydev, "Rx internal delay is invalid\n");
>> +			return rx_delay;
>> +		}
>> +	}
> So any PHY using these properties is going to pretty much reproduce
> this code. Meaning is should all be in a helper.

The issue here is that the phy_mode may only be rgmii-txid so you only 
want to find the tx_delay and return.

Same with the RXID.  How is the helper supposed to know what delay to 
return and look for?

The PHY also only needs to use the helper if the PHY is in certain modes.

And the decision to use the checks is really based on the PHY driver.

Not sure if other PHYs delays require both delays to be set or if the 
delays are independent.

The helper cannot assume this.

Dan


>
>       Andrew

  reply	other threads:[~2020-05-27 12:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 17:47 [PATCH net-next v3 0/4] RGMII Internal delay common property Dan Murphy
2020-05-26 17:47 ` [PATCH net-next v3 1/4] dt-bindings: net: Add tx and rx internal delays Dan Murphy
2020-05-26 17:47 ` [PATCH net-next v3 2/4] net: phy: Add a helper to return the index for of the internal delay Dan Murphy
2020-05-27  0:42   ` Andrew Lunn
2020-05-27 12:13     ` Dan Murphy
2020-05-26 17:47 ` [PATCH net-next v3 3/4] dt-bindings: net: Add RGMII internal delay for DP83869 Dan Murphy
2020-05-26 17:47 ` [PATCH net-next v3 4/4] net: dp83869: Add RGMII internal delay configuration Dan Murphy
2020-05-27  0:52   ` Andrew Lunn
2020-05-27 12:23     ` Dan Murphy [this message]
2020-05-27 13:12       ` Andrew Lunn
2020-05-27 14:51         ` Dan Murphy
2020-05-27  0:54   ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c0867d48-6f04-104b-8192-d61d4464a65f@ti.com \
    --to=dmurphy@ti.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox