2015-07-29 01:06:43

by Tim Bird

[permalink] [raw]
Subject: Bug: shared usb dt document is incorrect

Antoine and Rob,

I was just doing some testing with USB on a Qualcomm SoC.

I followed the instructions in the binding document:
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt

which has a compatible for "qcom,ci-hdrc", and is, in general,
for chipidea-based USB controllers.

It says in the document that the property usb-phy is deprecated, and to
use phys and phy-names instead. However, the Qualcomm
driver for this still uses usb-phy. That driver is in:
drivers/usb/chipidea/ci_hdrc_msm.c

I'm guessing I should update the Qualcomm driver to use
phys and phy-names, but wanted to check with you-all to
verify that this is the preferred method of getting
phys by phandle now. It's either change the driver
or make an exception in the binding document, I believe.

I presume I should be changing devm_usb_get_phy_by_phandle()
to of_phy_get(), but let me know if there's more to it than that.

In case I change the driver, do I then update the binding doc
to remove the information about the deprecated property, or not?

Please advise.
-- Tim


2015-07-29 01:37:03

by Peter Chen

[permalink] [raw]
Subject: Re: Bug: shared usb dt document is incorrect

On Tue, Jul 28, 2015 at 06:06:30PM -0700, Tim Bird wrote:
> Antoine and Rob,
>
> I was just doing some testing with USB on a Qualcomm SoC.
>
> I followed the instructions in the binding document:
> Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
>
> which has a compatible for "qcom,ci-hdrc", and is, in general,
> for chipidea-based USB controllers.
>
> It says in the document that the property usb-phy is deprecated, and to
> use phys and phy-names instead. However, the Qualcomm
> driver for this still uses usb-phy. That driver is in:
> drivers/usb/chipidea/ci_hdrc_msm.c
>
> I'm guessing I should update the Qualcomm driver to use
> phys and phy-names, but wanted to check with you-all to
> verify that this is the preferred method of getting
> phys by phandle now. It's either change the driver
> or make an exception in the binding document, I believe.
>
> I presume I should be changing devm_usb_get_phy_by_phandle()
> to of_phy_get(), but let me know if there's more to it than that.
>
> In case I change the driver, do I then update the binding doc
> to remove the information about the deprecated property, or not?
>
> Please advise.

In my opinion, you can just keep both driver and binding doc unchanging
until the generic PHY supports all things the current USB PHY supports,
eg, .notify_disconnect is used in your PHY driver, but it is not
supported in generic PHY framework.

--

Best Regards,
Peter Chen

2015-07-29 02:54:29

by Rob Herring

[permalink] [raw]
Subject: Re: Bug: shared usb dt document is incorrect

On Tue, Jul 28, 2015 at 8:06 PM, Tim Bird <[email protected]> wrote:
> Antoine and Rob,
>
> I was just doing some testing with USB on a Qualcomm SoC.
>
> I followed the instructions in the binding document:
> Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
>
> which has a compatible for "qcom,ci-hdrc", and is, in general,
> for chipidea-based USB controllers.
>
> It says in the document that the property usb-phy is deprecated, and to
> use phys and phy-names instead. However, the Qualcomm
> driver for this still uses usb-phy. That driver is in:
> drivers/usb/chipidea/ci_hdrc_msm.c

Deprecated means it still exists in the wild and should be maintained,
but don't use it for new dts files.

> I'm guessing I should update the Qualcomm driver to use
> phys and phy-names, but wanted to check with you-all to
> verify that this is the preferred method of getting
> phys by phandle now. It's either change the driver
> or make an exception in the binding document, I believe.

That would be fine along with updating the dts files, but the doc
should remain for some time.

> I presume I should be changing devm_usb_get_phy_by_phandle()
> to of_phy_get(), but let me know if there's more to qit than that.

devm_phy_get actually. The driver already supports it. See
ci_hdrc_probe in core.c.

> In case I change the driver, do I then update the binding doc
> to remove the information about the deprecated property, or not?

Not.

Rob

2015-07-29 03:12:29

by Peter Chen

[permalink] [raw]
Subject: RE: Bug: shared usb dt document is incorrect


> > I was just doing some testing with USB on a Qualcomm SoC.
> >
> > I followed the instructions in the binding document:
> > Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
> >
> > which has a compatible for "qcom,ci-hdrc", and is, in general, for
> > chipidea-based USB controllers.
> >
> > It says in the document that the property usb-phy is deprecated, and
> > to use phys and phy-names instead. However, the Qualcomm driver for
> > this still uses usb-phy. That driver is in:
> > drivers/usb/chipidea/ci_hdrc_msm.c
>
> Deprecated means it still exists in the wild and should be maintained, but don't
> use it for new dts files.
>

But how the new SoC (for new dts) which still uses current USB PHY driver?

Maybe we should not add additional description for this property,
it depends on which PHY driver (Generic PHY vs USB PHY) this controller
will use, if it uses a new PHY driver, it must use generic PHY framework, and will
use 'phy' and 'phy-names' corresponding.

Peter

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2015-07-29 03:25:40

by Rob Herring

[permalink] [raw]
Subject: Re: Bug: shared usb dt document is incorrect

On Tue, Jul 28, 2015 at 10:12 PM, Peter Chen <[email protected]> wrote:
>
>> > I was just doing some testing with USB on a Qualcomm SoC.
>> >
>> > I followed the instructions in the binding document:
>> > Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
>> >
>> > which has a compatible for "qcom,ci-hdrc", and is, in general, for
>> > chipidea-based USB controllers.
>> >
>> > It says in the document that the property usb-phy is deprecated, and
>> > to use phys and phy-names instead. However, the Qualcomm driver for
>> > this still uses usb-phy. That driver is in:
>> > drivers/usb/chipidea/ci_hdrc_msm.c
>>
>> Deprecated means it still exists in the wild and should be maintained, but don't
>> use it for new dts files.
>>
>
> But how the new SoC (for new dts) which still uses current USB PHY driver?

That's fine to use, but I would encourage people not to.

> Maybe we should not add additional description for this property,
> it depends on which PHY driver (Generic PHY vs USB PHY) this controller
> will use, if it uses a new PHY driver, it must use generic PHY framework, and will
> use 'phy' and 'phy-names' corresponding.

We're thinking about this the wrong way around. The driver should not
determine the binding used. The binding should be independent of the
driver used.

Either we should make the generic phy subsystem have feature parity
with usb-phy, or make the usb-phy drivers use the same generic phy
binding. Long term, I think we want the former and need a way to
subclass the generic phy. Other phys have similar needs for additional
protocol specific functions (e.g. configure the # of lanes for PCIe).
The generic phy subsystem needs some love in my brief experience with
it. For the latter case, this would make switching which phy driver is
used transparent to DT.

Rob

2015-07-29 17:29:16

by Tim Bird

[permalink] [raw]
Subject: Re: Bug: shared usb dt document is incorrect



On 07/28/2015 07:54 PM, Rob Herring wrote:
> On Tue, Jul 28, 2015 at 8:06 PM, Tim Bird <[email protected]> wrote:
>> Antoine and Rob,
>>
>> I was just doing some testing with USB on a Qualcomm SoC.
>>
>> I followed the instructions in the binding document:
>> Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
>>
>> which has a compatible for "qcom,ci-hdrc", and is, in general,
>> for chipidea-based USB controllers.
>>
>> It says in the document that the property usb-phy is deprecated, and to
>> use phys and phy-names instead. However, the Qualcomm
>> driver for this still uses usb-phy. That driver is in:
>> drivers/usb/chipidea/ci_hdrc_msm.c
>
> Deprecated means it still exists in the wild and should be maintained,
> but don't use it for new dts files.
OK. But for the Qualcomm driver, the new binding doesn't work (see below).
Since the binding doc specifically says: 'Use "phys" instead [of "usb-phy"].',
it is wrong as currently written, for this controller/phy combination.

>> I'm guessing I should update the Qualcomm driver to use
>> phys and phy-names, but wanted to check with you-all to
>> verify that this is the preferred method of getting
>> phys by phandle now. It's either change the driver
>> or make an exception in the binding document, I believe.
>
> That would be fine along with updating the dts files, but the doc
> should remain for some time.

Does this mean I should try phys/phy-names, and if that doesn't work
try usb-phy, for backwards compatibility?

>> I presume I should be changing devm_usb_get_phy_by_phandle()
>> to of_phy_get(), but let me know if there's more to it than that.
>
> devm_phy_get actually. The driver already supports it. See
> ci_hdrc_probe in core.c.

In my case the probe that is running is ci_hdrc_msm_probe(), in ci_hdrc_msm.c
This probe uses devm_usb_get_phy_by_phandle(..."usb-phy"). If I specify phys/phy-names
in my dts, the probe fails silently - leading ultimately to USB not working.
If I specify "usb-phy" in my dts, everything works. In this case, that property
is NOT deprecated. It's the only one that works.

I don't understand what's going on with the different probe routines and how the
SoC-specific parts interact with the core. I just know that the kernel behaviour
and the binding doc don't match, and I'd like to help fix it if I can.

Thanks for your patience while I try to understand this issue.
-- Tim

2015-07-29 20:25:05

by Rob Herring

[permalink] [raw]
Subject: Re: Bug: shared usb dt document is incorrect

On Wed, Jul 29, 2015 at 12:29 PM, Tim Bird <[email protected]> wrote:
>
>
> On 07/28/2015 07:54 PM, Rob Herring wrote:
>> On Tue, Jul 28, 2015 at 8:06 PM, Tim Bird <[email protected]> wrote:
>>> Antoine and Rob,
>>>
>>> I was just doing some testing with USB on a Qualcomm SoC.
>>>
>>> I followed the instructions in the binding document:
>>> Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt
>>>
>>> which has a compatible for "qcom,ci-hdrc", and is, in general,
>>> for chipidea-based USB controllers.
>>>
>>> It says in the document that the property usb-phy is deprecated, and to
>>> use phys and phy-names instead. However, the Qualcomm
>>> driver for this still uses usb-phy. That driver is in:
>>> drivers/usb/chipidea/ci_hdrc_msm.c
>>
>> Deprecated means it still exists in the wild and should be maintained,
>> but don't use it for new dts files.
> OK. But for the Qualcomm driver, the new binding doesn't work (see below).
> Since the binding doc specifically says: 'Use "phys" instead [of "usb-phy"].',
> it is wrong as currently written, for this controller/phy combination.

Perhaps we need to specify which compatible strings still use the old binding.

>>> I'm guessing I should update the Qualcomm driver to use
>>> phys and phy-names, but wanted to check with you-all to
>>> verify that this is the preferred method of getting
>>> phys by phandle now. It's either change the driver
>>> or make an exception in the binding document, I believe.
>>
>> That would be fine along with updating the dts files, but the doc
>> should remain for some time.
>
> Does this mean I should try phys/phy-names, and if that doesn't work
> try usb-phy, for backwards compatibility?
>
>>> I presume I should be changing devm_usb_get_phy_by_phandle()
>>> to of_phy_get(), but let me know if there's more to it than that.
>>
>> devm_phy_get actually. The driver already supports it. See
>> ci_hdrc_probe in core.c.
>
> In my case the probe that is running is ci_hdrc_msm_probe(), in ci_hdrc_msm.c
> This probe uses devm_usb_get_phy_by_phandle(..."usb-phy"). If I specify phys/phy-names
> in my dts, the probe fails silently - leading ultimately to USB not working.
> If I specify "usb-phy" in my dts, everything works. In this case, that property
> is NOT deprecated. It's the only one that works.

In my mind deprecated means "not recommended to be used", not that it
can't be used. If you were doing a new SOC, then I'd tell you don't
use usb-phy, but in this case as usb-phy is still used on QC SOCs I
think it is okay.

> I don't understand what's going on with the different probe routines and how the
> SoC-specific parts interact with the core. I just know that the kernel behaviour
> and the binding doc don't match, and I'd like to help fix it if I can.

I believe the msm probe calls the core which then creates sub-devices
for the host and device sides. Then the host and device drivers are
probed. The SOC probe can fill in a phy or the core code will do it.
The problem with the core code is that it will not do a deferred
probe. It may still work though if you remove this from the msm probe:

phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0);
if (IS_ERR(phy))
return PTR_ERR(phy);

ci_hdrc_msm_platdata.usb_phy = phy;


You can support the old and new bindings just by doing:

phy = devm_usb_get_phy_by_phandle(&pdev->dev, "usb-phy", 0);
if (IS_ERR(phy) == -EPROBE_DEFER)
return PTR_ERR(phy);
else {
phy = devm_usb_get_phy_by_phandle(&pdev->dev, "phys", 0);
if (IS_ERR(phy))
return PTR_ERR(phy);
}

Not the prettiest code. If the QC maintainers don't care about
compatibility with old dtb's then you could just switch everything
(dts's and driver) to use phys instead.

Perhaps this should be in a wrapper function as I'd like to see all
users of usb-phy migrate to phys and the driver shouldn't really care
what the property name is.

Rob