Skip to content

Conversation

@mathieuchopstm
Copy link
Owner

No description provided.

Introduce new SoC-specific framework to manage global peripheral clocks.
Update all STM32 code to make use of the framework when accessing one of
the global peripherals: PWR/SYSCFG.

Signed-off-by: Mathieu Choplain <[email protected]>
allow indicating which clocks are always-on such that the calls to
refer/release for thes clocks turn into no-ops which reduces footprint
and speeds up runtime

Signed-off-by: Mathieu Choplain <[email protected]>

/* Enable PWR */
LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_PWR);
stm32_global_periph_refer(STM32_GLOBAL_PERIPH_PWR);
Copy link

Choose a reason for hiding this comment

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

I'm not fond of this name.

1- Can we find an alternative to refer/release that already exist in tree ? (eg get/put even if I don't think this one is quite clear)
2- Alternative to stm32_global_periph:

  • stm32_soc_device
  • stm32_device
  • ...

Copy link
Owner Author

Choose a reason for hiding this comment

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

refer was inspired by net_buf_ref/net_buf_unref (that's why I have a comment somewhere suggesting to rename stm32_global_periph_release to _unref). In tree, we have net_buf_{ref,unref}, bt_conn_{ref,unref} and z_fd_{ref,unref}, all explicitly described as "inc/dec a refcount" which is what we're doing here, hence why I picked this name. On the other hand, get/put seems to only be used by the PM subsystem (pm_policy_state_lock_put, pm_device_runtime_put, ...) and refers to a lock-with-counter rather than a refcount.

I don't have any strong opinion on the name stm32_global_periph, that's just what I came up with. Fine with changing it.

Comment on lines +2123 to +2124
stm32_global_periph_refer(STM32_GLOBAL_PERIPH_PWR);
stm32_global_periph_refer(STM32_GLOBAL_PERIPH_SYSCFG);
Copy link

Choose a reason for hiding this comment

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

What about having it as a field (with maybe shorter names, then) ?

Suggested change
stm32_global_periph_refer(STM32_GLOBAL_PERIPH_PWR);
stm32_global_periph_refer(STM32_GLOBAL_PERIPH_SYSCFG);
stm32_global_periph_refer(STM32_GLOBAL_PERIPH_PWR|STM32_GLOBAL_PERIPH_SYSCFG);

Copy link
Owner Author

Choose a reason for hiding this comment

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

This could definitely be done, I'd just need to change logic a bit. (it would add a tiny additional overhead too)

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