Skip to content

Conversation

@gromero
Copy link
Contributor

@gromero gromero commented Sep 12, 2022

Commit 1d32c40 ("Add project overlay to overwrite device tree configs") added overlay for setting 'clock-frequency' property of node 'rcc' to 120 MHz, however to effectively change the PLL frequency that drivers the core it's necessary also to overlay the attributes for the 'pll' node. This commit does that.

Signed-off-by: Gustavo Romero [email protected]

cc @alanmacd @mehrdadh

Commit 1d32c40 ("Add project overlay to overwrite device tree configs")
added overlay for setting 'clock-frequency' property of node 'rcc' to
120 MHz, however to effectively change the PLL frequency that drivers
the core it's necessary also to overlay the attributes for the 'pll'
node. This commit does that.

Signed-off-by: Gustavo Romero <[email protected]>
@gromero gromero force-pushed the set_nucleo_l4r5zi_pll120 branch from 487c32e to 6eafc97 Compare September 12, 2022 15:51
@github-actions github-actions bot requested a review from mehrdadh September 12, 2022 15:52
@mehrdadh
Copy link
Member

@gromero Thanks for sending this fix!
LGTM!

I'll wait for @erwango's review

Comment on lines 44 to 45
div-p = <7>;
div-q = <2>;
Copy link

Choose a reason for hiding this comment

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

Note: To save power, you can just remove these if these PLL outputs are not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@erwango Thanks a lot for the reivew!

Interesting, it's good to keep in mind so that using the PLL48M1CLK and PLLSAI3CLK clocks can effect the power consumption. Since microTVM is not using any SAI (although we can use it in future for some voice recognition model), SMMDC, or USB OTG subsystem I think we can turn off these clocks, yep. But I'm scratching my head because I understand that even if properties div-p and div-q are removed from the overlay the dtc compiler will anyway "merge" the overlay properties for node pll with the values for these properties found in https://github.com/zephyrproject-rtos/zephyr/blob/main/boards/arm/nucleo_l4r5zi/nucleo_l4r5zi.dts#L76-L77 which are the same as the ones found in the overlay. But I thought also that even if these tuning values are set in the RCC_PLLCFGR it would be necessary to actually enable them explicitly by setting bits PLLQEN -- bit 20 -- and PLLPEN -- bit 16 -- in that register to effectively enable the clocks. Is my assumption wrong? Or even should we disable explicitly these clocks to save power? I haven't check what's the state for these bits because I don't have that board on hands ...

Now, re-reading my comments about Q param/property in the patch I think it's wrong.div-q = 2 => Q = 6 looks wrong to me because the value for the property in the .dts/overlay file should be 6, not the value for bit field (2), according to the semantics in https://github.com/zephyrproject-rtos/zephyr/blob/main/dts/bindings/clock/st%2Cstm32l4-pll-clock.yaml#L68 . So actually it seems div-q = 2 implies Q = 0 (bit field in register equal to zero), so actually by setting div-q = 2 we have PLL48M1CLK freq = 240 / 2 = 120 Mhz, not 240 / 6 = 40 MHz as in my comment. The Reference manual says Caution: The software has to set these bits correctly not to exceed 120 MHz on this domain. and with div-q=2 we don't violate this (we have it as 120 MHz), but I wonder if we should actually use div-q=6 to "honor" the clock signal name which implies it's a 48 MHz or so clock?

Since @mehrdadh plans to squash this patch with #12741 and contribute back to Zephyr I also I'd like to know if this comment #12741 should be update to 120 MHz accordingly.

Copy link

Choose a reason for hiding this comment

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

I oversaw this indeed. Prop values are the values to be used in the computation and driver makes the translation in register space.
Regarding the need for a 48MHz this depends on your needs. If required this can impose the use of a 96MHz Max freq on core. But note that USB, entropy and sdmmc are the only consumer of 48MHz clock available today in main zephyr tree.

Copy link

@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.

One comment depending on your usage, otherwise LGTM

@gromero
Copy link
Contributor Author

gromero commented Sep 13, 2022

One comment depending on your usage, otherwise LGTM

@erwango Thanks for the review! I've got some additional question about the Q and P params and associated clocks before we merge this PR. could you please check the comment inline? : ) Cheers.

Remove div-p and div-q properties from the overlay file since values for
these properties will be inherited from the 'pll' that is overlaid.

Since currently microTVM does not use any subsystem which relies on
clocks associated to either P or Q params, these params can be left
unchanged for now.
@gromero
Copy link
Contributor Author

gromero commented Sep 14, 2022

@mehrdadh @erwango Thanks a lot for the reviews. I think once the CI is green we can merge it. Cheers.

@mehrdadh mehrdadh merged commit e5adb83 into apache:main Sep 14, 2022
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…pache#12756)

* [microTVM][Zephyr] Fix PLL freq. in overlay for nucleo_l4r5zi board

Commit 1d32c40 ("Add project overlay to overwrite device tree configs")
added overlay for setting 'clock-frequency' property of node 'rcc' to
120 MHz, however to effectively change the PLL frequency that drivers
the core it's necessary also to overlay the attributes for the 'pll'
node. This commit does that.

Signed-off-by: Gustavo Romero <[email protected]>

* Remove div-p and div-q properties from overlay

Remove div-p and div-q properties from the overlay file since values for
these properties will be inherited from the 'pll' that is overlaid.

Since currently microTVM does not use any subsystem which relies on
clocks associated to either P or Q params, these params can be left
unchanged for now.

Signed-off-by: Gustavo Romero <[email protected]>
guberti pushed a commit that referenced this pull request Jan 13, 2023
…12756)

* [microTVM][Zephyr] Fix PLL freq. in overlay for nucleo_l4r5zi board

Commit 1d32c40 ("Add project overlay to overwrite device tree configs")
added overlay for setting 'clock-frequency' property of node 'rcc' to
120 MHz, however to effectively change the PLL frequency that drivers
the core it's necessary also to overlay the attributes for the 'pll'
node. This commit does that.

Signed-off-by: Gustavo Romero <[email protected]>

* Remove div-p and div-q properties from overlay

Remove div-p and div-q properties from the overlay file since values for
these properties will be inherited from the 'pll' that is overlaid.

Since currently microTVM does not use any subsystem which relies on
clocks associated to either P or Q params, these params can be left
unchanged for now.

Signed-off-by: Gustavo Romero <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants