Devicetree
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
To: Pavan Kondeti <quic_pkondeti@quicinc.com>
Cc: Sandeep Maheswaram <quic_c_sanm@quicinc.com>,
	Rob Herring <robh+dt@kernel.org>, Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	Vinod Koul <vkoul@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Wesley Cheng <wcheng@codeaurora.org>,
	Stephen Boyd <swboyd@chromium.org>,
	Doug Anderson <dianders@chromium.org>,
	Matthias Kaehlcke <mka@chromium.org>,
	devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org,
	linux-usb@vger.kernel.org, quic_ppratap@quicinc.com,
	quic_kriskura@quicinc.com
Subject: Re: [PATCH v2 1/3] dt-bindings: phy: qcom,usb-snps-femto-v2: Add phy override params bindings
Date: Mon, 14 Mar 2022 11:08:05 +0100	[thread overview]
Message-ID: <b45b3b7e-e1c0-79b6-81c0-53c70427dd10@canonical.com> (raw)
In-Reply-To: <20220314094054.GB28402@hu-pkondeti-hyd.qualcomm.com>

On 14/03/2022 10:40, Pavan Kondeti wrote:
> Hi Krzysztof,
> 
> Thanks for your suggestions and guidance on this.
> 
> On Mon, Mar 14, 2022 at 09:36:02AM +0100, Krzysztof Kozlowski wrote:
>> On 14/03/2022 09:16, Pavan Kondeti wrote:
>>> Hi Krzysztof,
>>>
>>> On Mon, Mar 14, 2022 at 08:39:57AM +0100, Krzysztof Kozlowski wrote:
>>>> On 14/03/2022 04:29, Pavan Kondeti wrote:
>>>>> Hi Krzysztof,
>>>>>
>>>>> On Thu, Mar 03, 2022 at 04:59:22PM +0100, Krzysztof Kozlowski wrote:
>>>>>> On 03/03/2022 07:13, Sandeep Maheswaram wrote:
>>>>>>> Add device tree bindings for SNPS phy tuning parameters.
>>>>>>>
>>>>>>> Signed-off-by: Sandeep Maheswaram <quic_c_sanm@quicinc.com>
>>>>>>> ---
>>>>>>>  .../bindings/phy/qcom,usb-snps-femto-v2.yaml       | 125 +++++++++++++++++++++
>>>>>>>  1 file changed, 125 insertions(+)
>>>>>>>
>>>>>>> diff --git a/Documentation/devicetree/bindings/phy/qcom,usb-snps-femto-v2.yaml b/Documentation/devicetree/bindings/phy/qcom,usb-snps-femto-v2.yaml
>>>>>>> index 0dfe691..227c097 100644
>>>>>>> --- a/Documentation/devicetree/bindings/phy/qcom,usb-snps-femto-v2.yaml
>>>>>>> +++ b/Documentation/devicetree/bindings/phy/qcom,usb-snps-femto-v2.yaml
>>>>>>> @@ -50,6 +50,131 @@ properties:
>>>>>>>    vdda33-supply:
>>>>>>>      description: phandle to the regulator 3.3V supply node.
>>>>>>>  
>>>>>>> +  qcom,hs-disconnect:
>>>>>>> +    $ref: /schemas/types.yaml#/definitions/uint32
>>>>>>> +    description:
>>>>>>> +      This adjusts the voltage level for the threshold used to
>>>>>>> +      detect a disconnect event at the host. Possible values are.
>>>>>>
>>>>>> ':', instead of full stop.
>>>>>>
>>>>>>> +      7 -> +21.56%
>>>>>>> +      6 -> +17.43%
>>>>>>> +      5 -> +13.32%
>>>>>>> +      4 -> +9.73%
>>>>>>> +      3 -> +6.3
>>>>>>> +      2 -> +3.17%
>>>>>>> +      1 -> 0, Design default%
>>>>>>
>>>>>> Use "default:" instead. Here and in other places.
>>>>>>
>>>>>>> +      0 -> -2.72%
>>>>>>
>>>>>> In current form this should be an enum... but actually current form is
>>>>>> wrong. You should not store register values in DT. What if next version
>>>>>> of hardware has a different meaning of these values?
>>>>>>
>>>>>> Instead, you should store here meaningful values, not register values.
>>>>>>
>>>>>
>>>>> Thanks for the feedback.
>>>>>
>>>>> The values in % really makes the tuning easy. People look at the eye diagram
>>>>> and decided whether to increase/decrease the margin. The absolute values
>>>>> may not be that useful. All we need is an "adjustment" here. The databook
>>>>> it self does not give any absolute values.
>>>>>
>>>>> I agree to the "enum" suggestion which we have been following for the
>>>>> qusb2 driver already. 
>>>>>
>>>>> The values have not changed in the last 5 years for this hardware block, so
>>>>> defining enums for the % values would be really helpful. 
>>>>
>>>> I did not say you cannot store here percentages. Quite opposite - store
>>>> here the percentages. Just do not store register value. No. Please read
>>>> my comment again - meaningful values are needed.
>>>>
>>>
>>> IIUC, you are asking us to come up with a meaningful values to encode the
>>> percentage values. However, all the % increments are not linear, so we can't
>>> come up with {min, max} scheme. Lets take an example of hostdisconnect
>>> threshold.
>>>
>>> As per the data book,
>>>
>>> +      7 -> +21.56%
>>> +      6 -> +17.43%
>>> +      5 -> +13.32%
>>> +      4 -> +9.73%
>>> +      3 -> +6.3
>>> +      2 -> +3.17%
>>> +      1 -> 0, Design default%
>>> +      0 -> -2.72%
>>>
>>> so how do we give meaningful values here? Does the below scheme make sense
>>> to you?
>>
>> By "meaningful value" I mean something which has a understandable
>> meaning to reader of this code or to hardware designer. For example
>> percentage values or some units (ms, ns, Hz, mA, mV). The value used in
>> register is not meaningful in that way to us because it has a meaning
>> only to the hardware block. Storing register values is more difficult to
>> read later, non-portable and non-scalable.
>>
>>>
>>> #define QCOM_SNPS_FEMTO_HS_DISCONNECT_NEG_2P72	(-272)
>>> #define QCOM_SNPS_FEMTO_HS_DISCONNECT_DEFAULT	0
>>> #define QCOM_SNPS_FEMTO_HS_DISCONNECT_3P17	317
>>> #define QCOM_SNPS_FEMTO_HS_DISCONNECT_6P3	63
>>
>> This is some define in driver, does not look related to bindings.
>>
>>> In the driver, we have a mapping (which can be per SoC if required in future)
>>> that takes these values and convert to the correct values for a given
>>> register.
>>
>> You focus on driver but I am talking here only about bindings.
> 
> I was saying we define those defines in include/dt-bindings/phy/... header and
> use it in the device tree and as well in the driver.

Ah, I did not get it. That's not the solution for this case. defines in
dt-bindings are for constants which already can be in DT, e.g. IDs. Your
register values should not be stored in DT.

> 
>>
>> What could be the meaningful value? Percentage could work. You have
>> there a negative value, so I wonder what type of percentage is it? What
>> is the formula?
> 
> I just multiplied by 100 since device tree has no support for floating (as per
> my knowledge). The negative value represents it lowers the disconnect
> threshold by 2.72% of the default value. if it makes sense, we could also
> start from 0 like below.

ok

> 
> #define QCOM_SNPS_FEMTO_HS_DISCONNECT_NEG_2P72_PCT 0
> #define QCOM_SNPS_FEMTO_HS_DISCONNECT_DEFAULT	1
> #define QCOM_SNPS_FEMTO_HS_DISCONNECT_3P17_PCT	2
> #define QCOM_SNPS_FEMTO_HS_DISCONNECT_6P3_PCT	3
> 
> The driver can have a table to map these bindings. This looks much better
> than those x100 formula values.

Again mention driver how he can map it. I mostly don't care about the
driver. :)

I think we are getting around the problem, so to emphasize again: do not
store register values in the bindings/DT but its meaning, so in your
case most likely percentages (or permille or ratio or some other value).


Best regards,
Krzysztof

  reply	other threads:[~2022-03-14 10:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03  6:13 [PATCH v2 0/3] Add QCOM SNPS PHY overriding params support Sandeep Maheswaram
2022-03-03  6:13 ` [PATCH v2 1/3] dt-bindings: phy: qcom,usb-snps-femto-v2: Add phy override params bindings Sandeep Maheswaram
2022-03-03 15:59   ` Krzysztof Kozlowski
2022-03-03 22:23     ` Stephen Boyd
2022-03-14  3:29     ` Pavan Kondeti
2022-03-14  7:39       ` Krzysztof Kozlowski
2022-03-14  8:16         ` Pavan Kondeti
2022-03-14  8:36           ` Krzysztof Kozlowski
2022-03-14  9:40             ` Pavan Kondeti
2022-03-14 10:08               ` Krzysztof Kozlowski [this message]
2022-03-14 10:30                 ` Pavan Kondeti
2022-03-14 10:41                   ` Krzysztof Kozlowski
2022-03-14 11:13                     ` Pavan Kondeti
2022-03-14 11:21                       ` Krzysztof Kozlowski
2022-03-03  6:13 ` [PATCH v2 2/3] phy: qcom-snps: Add support for overriding phy tuning parameters Sandeep Maheswaram
2022-04-13  9:42   ` Vinod Koul
2022-04-13  9:53     ` Pavan Kondeti
2022-03-03  6:13 ` [PATCH v2 3/3] arm64: dts: qcom: sc7280: Update SNPS Phy params for SC7280 IDP device Sandeep Maheswaram

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=b45b3b7e-e1c0-79b6-81c0-53c70427dd10@canonical.com \
    --to=krzysztof.kozlowski@canonical.com \
    --cc=agross@kernel.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kishon@ti.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mka@chromium.org \
    --cc=quic_c_sanm@quicinc.com \
    --cc=quic_kriskura@quicinc.com \
    --cc=quic_pkondeti@quicinc.com \
    --cc=quic_ppratap@quicinc.com \
    --cc=robh+dt@kernel.org \
    --cc=swboyd@chromium.org \
    --cc=vkoul@kernel.org \
    --cc=wcheng@codeaurora.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