-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
USB HS support fixes on STM32U5 #80249
USB HS support fixes on STM32U5 #80249
Conversation
Yay it passed all the tests! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK. A few nits and proposals for simplification:
b50f9bb
to
8e7537c
Compare
8e7537c
to
65920fa
Compare
65920fa
to
a29b7cb
Compare
a07f824
to
6c9969c
Compare
anything else? is everything ok to merge? :P |
This PR will have to go into 4.1 (once 4.0 releases) as we are now in the 4.0 feature freeze. |
oh! dang ok, what's the timeline for that? I'm just trying to avoid multiple merges on my side! |
|
Please add |
6c9969c
to
02211d8
Compare
02211d8
to
641353b
Compare
hi! can you explain that a bit more please? |
bdeb107
to
22dfc2e
Compare
See
|
…ephyrproject-rtos#79823) This board has the required clock crystal (X4) and jumper settings present to enable the USB 2.0 HS support. * Enable the HSE clock (16MHz) * Flip the PLL1 configuration over to use the HSE clock, but still outputting 160MHz to sysclk/apbclk. * Add the USB HS device tree node. * Update the board documentation. Signed-off-by: Adrian Chadd <[email protected]>
…5xxx The existing code assumes that the HSE clock is a 16MHz crystal, however the hardware allows for a list of possible HSE clock values. Add them here as an enum, configure it for the STM32U595 chipset (which is the only device I have access to for testing). This addresses Issue zephyrproject-rtos#79825 . * Rename USBPHYC_SEL -> OTGHS_SEL which matches the definition in the stm32u5 CCIPR2 register (RM0456 Rev 5, Section 11.8.47). * Add a list of possible values to use in the DT bindings directory * Add a new PHY (st,stm32-otghs-phy) with an enum list matching the above list * Add support in the USB driver for checking the clock-cfg entry and compiling in the correct clock rate. * And also handle an out of enum configuration by failing compilation. Signed-off-by: Adrian Chadd <[email protected]>
22dfc2e
to
e21b99c
Compare
Done! |
ok, since this is a long review, would someone please help summarise what's left for me to address? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See some of my comments.
We also need to address OTGEN
and OTGHSPHYEN
clock enabling in RCC_AHB2ENR1
register. Commit 57723cf has changed from enabling both bits to just enabling OTGHSPHYEN
(bit 15) with:
clocks = <&rcc STM32_CLOCK(AHB2, 15U)>,
I think we should choose one of those options:
- Select OTG and OTG_PHY clocks separately in each devicetree node. This means that we should add
clocks
property to OTG_PHY node. That property will allow to define bit that enabled OTG_PHY clock, but will also allow us to select clock configuration (e.g. whether it is HSE, PLL1, HSE/2 or PLL1/2...). - Use only OTG devicetree node to select all clocks (including OTG_PHY). That way we should move
clock-cfg
selection out of OTG_PHY node, so we are consistent with where we select clock.
- 1 # OTGHS_PHY_CLK_16MHZ | ||
- 2 # OTGHS_PHY_CLK_19P2MHZ | ||
- 3 # OTGHS_PHY_CLK_20MHZ | ||
- 4 # OTGHS_PHY_CLK_24MHZ | ||
- 5 # OTGHS_PHY_CLK_26MHZ | ||
- 6 # OTGHS_PHY_CLK_32MHZ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense to define list of possible frequencies:
- 16000000
- 19200000
- 20000000
- 24000000
- 26000000
- 32000000
here. That way it will still be pretty straightforward to select specific configuration in devicetree, e.g. with DT_FREQ_M(16)
, while being able to drop include/zephyr/dt-bindings/phy/stm32u5_otg_hs_phy.h
entirely.
@@ -107,15 +107,15 @@ | |||
ram-size = <4096>; | |||
maximum-speed = "high-speed"; | |||
clocks = <&rcc STM32_CLOCK(AHB2, 15U)>, | |||
<&rcc STM32_SRC_HSI48 ICKLK_SEL(0)>; | |||
<&rcc STM32_SRC_HSI48 OTGHS_SEL(0)>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though STM32_SRC_HSI48
is not used by the driver (only second cell is used to configure clock, i.e. OTGHS_SEL(0)
), it is confusing to leave it like that since OTGHS_SEL(0)
select HSE
and not HSI48
as input clock.
Switching that to STM32_SRC_HSE
seems the way to go. However, we need to disable CONFIG_USB_DC_STM32_CLOCK_CHECK
so it won't complain about 48MHz frequency. Or we can update that check (it won't be easy to cover all cases, so I guess we can leave that as future enhancement).
Another thing that might be worth considering is calculating 16MHz...32MHz (which in current PR implementation is done with |
Please take a look at #82540, which implements following suggestion I had:
|
ok, this is all great feedback and ideas, but my goal right now is to get /something/ working into the tree that we can then build on. I kind of feel like I've stumbled into a rabbit hole of many "oh and this sharp corner should be fixed" tasks, which is great and I'd love to help with! But I'd also like to get something working into the tree. I'll go and re-test today and see if it even works. If it doesn't work without the clock enable then I'd appreciate some hand-holding to get that lined up. Even just getting the /first/ diff in the stack landed to enable USB on this board would be super helpful. Thanks! |
ok, so testing with the cdc_acm demo again:
So, there's been a bunch of other regressions in the meantime. This is why I really want to get this landed in some working form first! :) |
ok, PEBKAC - bad USB cable on the USB-C side. Yup, with that clock bit set, the demo still works fine. So first step - what to do about configuring that missing clock bit (bit 14). This seems like it could be a problem for other boards/parts, no? Should we create a separate diff /just/ for figuring out what to do there? |
Can you clarify ? |
Did any other STM32 parts get caught out by this clock config refactor? is it /just/ the stm32u5 series stuff that was setting >1 clock enable in the RCC? |
Not that I know, should be limited to U5 indeed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the last commit, remove (Issue #79823) from the commit title.
Closing as superseded by #82540 |
(This was for pull reuqest 80249, but that was against main and not a branch, and I was asked on discord to put it in a branch)