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

Add global HSFLL clock control device driver #81735

Merged
merged 9 commits into from
Dec 17, 2024

Conversation

bjarki-andreasen
Copy link
Collaborator

Draft for now since testing is blocked by missing firmware for the nRF54H20

@bjarki-andreasen
Copy link
Collaborator Author

Note @ppelikan-nordic

@zephyrbot
Copy link
Collaborator

zephyrbot commented Nov 21, 2024

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff
hal_nordic zephyrproject-rtos/hal_nordic@e0e48c4 zephyrproject-rtos/hal_nordic@fae1542 (master) zephyrproject-rtos/[email protected]

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-hal_nordic DNM This PR should not be merged (Do Not Merge) labels Nov 21, 2024
@bjarki-andreasen
Copy link
Collaborator Author

bjarki-andreasen commented Nov 21, 2024

I need the to update the frequencies to match the opaque GDFS_FREQ_MEDHIGH in devicetree, and verify that the initial frequency of the clock is the lowest one :) Also need to find appropriate timeout for gdfs requests.

west.yml Outdated Show resolved Hide resolved
@@ -37,6 +37,7 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RENESAS_RA_CGC clock_cont
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_AMBIQ clock_control_ambiq.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_PWM clock_control_pwm.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RPI_PICO clock_control_rpi_pico.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL clock_control_nrf2_global_hsfll.c)
Copy link
Collaborator

@masz-nordic masz-nordic Nov 29, 2024

Choose a reason for hiding this comment

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

Shouldn't this be below, after if(CONFIG_CLOCK_CONTROL_NRF2)? I see that Kconfig is under if CLOCK_CONTROL_NRF2

Copy link
Collaborator

Choose a reason for hiding this comment

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

up

nordic-krch
nordic-krch previously approved these changes Dec 13, 2024
@@ -117,6 +120,11 @@ config NRFS_GDPWR_SERVICE_ENABLED
depends on NRFS_HAS_GDPWR_SERVICE
default y

config NRFS_GDFS_SERVICE_ENABLED
bool "Global domain frequeny scaling service"
Copy link
Member

Choose a reason for hiding this comment

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

typo: "frequeny"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

Choose a reason for hiding this comment

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

It would be better to have the name matching the actual compatible, so nordic,nrf-hsfll-local.yaml.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated name of file to match compat

@@ -48,7 +47,7 @@ static const struct clock_options {
};

struct hsfll_dev_data {
STRUCT_CLOCK_CONFIG(hsfll, ARRAY_SIZE(clock_options)) clk_cfg;
STRUCT_CLOCK_CONFIG(global_hsfll, ARRAY_SIZE(clock_options)) clk_cfg;
Copy link
Member

Choose a reason for hiding this comment

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

Why? Isn't this local HSFLL?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

rogue mistake, changed back

Comment on lines 109 to 111
.frequency = MHZ(320),
.accuracy = 0,
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
Copy link
Member

Choose a reason for hiding this comment

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

Why not just:

Suggested change
.frequency = MHZ(320),
.accuracy = 0,
.precision = NRF_CLOCK_CONTROL_PRECISION_DEFAULT,
.frequency = MHZ(320),

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

shortened

@@ -221,7 +208,6 @@ static DEVICE_API(nrf_clock_control, hsfll_drv_api) = {
.std_api = {
.on = api_nosys_on_off,
.off = api_nosys_on_off,
.get_rate = api_get_rate_hsfll,
Copy link
Member

Choose a reason for hiding this comment

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

What was wrong with this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Its not useful when the frequency is dynamic, it can change at any time, the only way to guarantee any frequency is to request what you need, and wait for confirmation, so there is no value in checking the freq like this at any time. Its also not possible with the global hsfll (not this clock I know) but it proves the point :) there we can't even get the freq if we wanted :)

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. It could be mentioned in the commit message so that the motivation is clear.

return -EINVAL;
}

static struct nrf_clock_control_driver_api driver_api = {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static struct nrf_clock_control_driver_api driver_api = {
static DEVICE_API(nrf_clock_control, driver_api) = {

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is not done for other nrf2 drivers, I think we should update them together

ppelikan-nordic and others added 3 commits December 13, 2024 14:38
Adding the implementation for the GDFS service

Signed-off-by: Paweł Pelikan <[email protected]>
Add specific device model for global hsfll clock and update dts tree
to use specific model. The clock is not fixed, and configurable at
runtime to predefined frequencies specified by the platform.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
The nrf-hsfll was previously the only supported HSFLL clock, hence it
was not namespaced fully. Since we added nrf-hsfll-global, we should
add the namespace to nrf-hsfll as well.

Updates drivers and devicetree uses of HSFLL as well.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Add device driver support for global hsfll clock.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Extend sample to support global hsfll clock control.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Extend test suite to test global HSFLL clock.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
The assert BUILD_ASSERT(NRF_GPD_FAST_ACTIVE1 == 0); is not correct
given that NRF_GPD_FAST_ACTIVE1 is defined as 1U, and is not used
in the file anyway. Remove the build assert.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
Copy link
Member

@carlescufi carlescufi left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @bjarki-andreasen

@@ -37,6 +37,7 @@ zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RENESAS_RA_CGC clock_cont
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_AMBIQ clock_control_ambiq.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_PWM clock_control_pwm.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_RPI_PICO clock_control_rpi_pico.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_CONTROL_NRF2_GLOBAL_HSFLL clock_control_nrf2_global_hsfll.c)
Copy link
Collaborator

Choose a reason for hiding this comment

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

up

{
const struct global_hsfll_dev_config *dev_config = dev->config;

return dev_config->clock_frequencies[ARRAY_SIZE(dev_config->clock_frequencies) - 1];
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be returned build-time since there are build asserts checking for supported clock frequencies?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this driver does have some strangeness regarding single instances / multi instance code, I wanted to make it as easy as possible to extend it if we choose to support more HSFLLs in the future

@carlescufi carlescufi assigned anangl and unassigned nordic-krch Dec 17, 2024
@kartben kartben merged commit 7487eab into zephyrproject-rtos:main Dec 17, 2024
26 checks passed
@bjarki-andreasen bjarki-andreasen deleted the nordic-global-hsfll branch December 17, 2024 14:49
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.