Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dts: Add initial support of USB PHYs #10359

Merged
merged 4 commits into from
Nov 15, 2018
Merged

Conversation

ydamigos
Copy link
Collaborator

@ydamigos ydamigos commented Oct 3, 2018

Add initial support of USB PHYs.

@ydamigos ydamigos added area: Devicetree platform: STM32 ST Micro STM32 DNM This PR should not be merged (Do Not Merge) labels Oct 3, 2018
@ydamigos ydamigos changed the title dts: Add initial support of USB PHYs [DNM] dts: Add initial support of USB PHYs Oct 3, 2018
@ydamigos
Copy link
Collaborator Author

ydamigos commented Oct 3, 2018

@jli157 FYI

@codecov-io
Copy link

codecov-io commented Oct 3, 2018

Codecov Report

Merging #10359 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #10359   +/-   ##
=======================================
  Coverage   48.37%   48.37%           
=======================================
  Files         265      265           
  Lines       42188    42188           
  Branches    10137    10137           
=======================================
  Hits        20408    20408           
  Misses      17703    17703           
  Partials     4077     4077

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a933297...918015b. Read the comment docs.

Copy link
Collaborator

@galak galak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When phys has multiple handles (like on stm32f723.dtsi) what does that mean?

@ydamigos
Copy link
Collaborator Author

ydamigos commented Oct 3, 2018

When phys has multiple handles (like on stm32f723.dtsi) what does that mean?

The available PHYs for the USB controller. In case of stm32f723 the available PHYs are:
– An on-chip full-speed PHY
– A UTMI interface for internal HS PHY

@erwango
Copy link
Member

erwango commented Oct 4, 2018

@ydamigos , looks nice, but it is not clear to me what issue this addition is going to solve, and no application is provided to demonstrate.
Any pointer on a discussion that could help to understand the context?

@ydamigos
Copy link
Collaborator Author

ydamigos commented Oct 4, 2018

Any pointer on a discussion that could help to understand the context?

@erwango It needs PR #9062 to get merged. Then, we could use DT to get hw information for USBPHYC and not stm32cube in stm32 usb driver.

@galak
Copy link
Collaborator

galak commented Oct 9, 2018

@erwango It needs PR #9062 to get merged. Then, we could use DT to get hw information for USBPHYC and not stm32cube in stm32 usb driver.

merged #9062 :)

@aurel32
Copy link
Collaborator

aurel32 commented Oct 10, 2018

Thanks @ydamigos for working on that. I have to say I don't necessary understand all the logic parsing the device tree to produce an header file so I still find a bit difficult to understand how the new DT entries are going to be used in practice. Anyway I already have a few comments/questions:

  • The STM32F723 OTG_HS interface only has a single HS PHY (that can work in FS mode). The documentation about HS PHY is quite confusing, and even wrong in some aspects. Therefore I believe the usbotg_hs phys entry has to be changed to:
    phys = <&usbphyc>;
  • The usbotg_fs_phy basically has no address and no property, so the same is used for both the usbotg_hs and usbotg_fs instances. Is it a problem? In other part of the device tree we tend to have one instance per device, post-fixed with a number.
  • I guess in the future we can add support for an external PHY in the device tree, which in that case will be outside of the soc hierarchy. Is that correct?
  • When compiling with your patches applied (after fixing the conflicts), I get the following warnings:
stm32f723e_disco.dts_compiled: Warning (phys_property): /soc/usb@50000000: Missing property '#phy-cells' in node /soc/usbphy or bad phandle (referred from phys[0])
stm32f723e_disco.dts_compiled: Warning (phys_property): /soc/usb@40040000: Missing property '#phy-cells' in node /soc/usbphy or bad phandle (referred from phys[0])

@ydamigos
Copy link
Collaborator Author

@aurel32 Thanks for the review

The STM32F723 OTG_HS interface only has a single HS PHY (that can work in FS mode). The documentation about HS PHY is quite confusing, and even wrong in some aspects. Therefore I believe the usbotg_hs phys entry has to be changed to:
phys = <&usbphyc>;

You are right. I updated it.

The usbotg_fs_phy basically has no address and no property, so the same is used for both the usbotg_hs and usbotg_fs instances. Is it a problem? In other part of the device tree we tend to have one instance per device, post-fixed with a number.

Yes, I should use a different one. It is a different embedded phy in a different controller.

I guess in the future we can add support for an external PHY in the device tree, which in that case will be outside of the soc hierarchy. Is that correct?

Yes, on board level.

When compiling with your patches applied (after fixing the conflicts)

I have seen the warnings and I'll fix them. I thought #phy-cells was used in linux only but it is needed by DT compiler.

@ydamigos ydamigos changed the title [DNM] dts: Add initial support of USB PHYs [WIP] dts: Add initial support of USB PHYs Oct 12, 2018
@ydamigos ydamigos force-pushed the usb-phys branch 2 times, most recently from c2bd153 to 0f36059 Compare October 15, 2018 18:58
@ydamigos ydamigos force-pushed the usb-phys branch 2 times, most recently from 0c51f42 to 2df02d0 Compare October 17, 2018 16:52
@ydamigos
Copy link
Collaborator Author

When phys has multiple handles (like on stm32f723.dtsi) what does that mean?

I had a better look at linux phy bindings and a controller has multiple phys if it can use simultaneously.

@ydamigos ydamigos removed the DNM This PR should not be merged (Do Not Merge) label Oct 17, 2018
@ydamigos ydamigos changed the title [WIP] dts: Add initial support of USB PHYs dts: Add initial support of USB PHYs Oct 17, 2018
Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work.
Only adaptation would be to use CONFIG_DT_COMPAT_XX flags instead of CONFIG_XXX_BASE_ADDRESS

@@ -258,14 +258,14 @@ static int usb_dc_stm32_clock_enable(void)
#ifdef CONFIG_USB_HS_BASE_ADDRESS


#ifdef USB_HS_PHYC
#ifdef CONFIG_USBPHYC_BASE_ADDRESS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're now generating CONFIG_DT_COMPAT_XXXX flags (more details here: #9406).
These should be used for driver specific implementations/variations. Since you've set the ground with phys nodes it would fit perfectly here.
Please use this instead of 'CONFIG_USBPHYC_BASE_ADDRESS'.
Apply everywhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to DT_COMPAT_ST_STM32_USBPHYC.

Copy link
Collaborator

@galak galak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, why the use of "zephyr,usb-nop-xceiv" as a compatible (specifically the 'zephyr' bit?)

@ydamigos
Copy link
Collaborator Author

Curious, why the use of "zephyr,usb-nop-xceiv" as a compatible (specifically the 'zephyr' bit?)

@galak I borrowed the idea from linux, where usb-nop-xceiv is used by all the usb transceivers which are built-in with USB IP. I added the 'zephyr' part to highlight that it is a zephyr "implementation".

@galak
Copy link
Collaborator

galak commented Nov 13, 2018

@galak I borrowed the idea from linux, where usb-nop-xceiv is used by all the usb transceivers which are built-in with USB IP. I added the 'zephyr' part to highlight that it is a zephyr "implementation".

what compat does linux use?

@ydamigos
Copy link
Collaborator Author

what compat does linux use?

usb-nop-xceiv

@galak
Copy link
Collaborator

galak commented Nov 14, 2018

usb-nop-xceiv

Any reason not to use the same, is there some zephyr specific semantic we have?

Add yaml file for initial support of USB PHYs.
It adds also yaml files for STM32 USBPHYC and
USB controllers with embedded PHY.

PHY refers to the physical layer which is used
to connect a device to the physical medium e.g.
USB controller.

Origin: original

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Add phys property, which specifies USB PHY provider,
to STM32 USB yaml files.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Add USB phy nodes and phys property in USB nodes.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
Use DT to check if SoC has a USBPHYC controller.

Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
@ydamigos
Copy link
Collaborator Author

Any reason not to use the same, is there some zephyr specific semantic we have?

No, there is nothing zephyr specific. I changed it to usb-nop-xceiv.

@galak galak merged commit 954a943 into zephyrproject-rtos:master Nov 15, 2018
@ydamigos ydamigos deleted the usb-phys branch November 15, 2018 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants