Skip to content

Commit 9f6741b

Browse files
[nrf fromlist] soc: nordic: nrf54h20: restrict global hsfll freq
Introduce feature which restricts the minimum global hsfll frequency. This feature is selected by default to preserve the behavior of the global hsfll before the clock control driver for it was introduced, which configured it as a fixed clock at 320MHz. Upstream PR #: 81735 Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent ec280d5 commit 9f6741b

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

soc/nordic/nrf54h/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if(CONFIG_ARM)
99
endif()
1010

1111
zephyr_library_sources_ifdef(CONFIG_PM_S2RAM pm_s2ram.c)
12+
zephyr_library_sources_ifdef(CONFIG_SOC_NRF54H20_GLOBAL_HSFLL_RESTRICT_MIN_FREQ global_hsfll.c)
1213

1314
zephyr_include_directories(.)
1415

soc/nordic/nrf54h/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,23 @@ config SOC_NRF54H20_NO_MRAM_LATENCY
7373
imply NRFS
7474
imply NRFS_MRAM_SERVICE_ENABLED
7575
default y if SOC_NRF54H20_CPUAPP
76+
77+
config SOC_NRF54H20_GLOBAL_HSFLL_RESTRICT_MIN_FREQ
78+
bool "Restrict minimum global HSFLL clock frequency"
79+
select NRFS
80+
select NRFS_GDFS_SERVICE_ENABLED
81+
select CLOCK_CONTROL
82+
default y if SOC_NRF54H20_CPUAPP
83+
84+
if SOC_NRF54H20_GLOBAL_HSFLL_RESTRICT_MIN_FREQ
85+
86+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_HZ
87+
int "Minimum global HSFLL clock frequency in Hertz"
88+
range 64000000 320000000
89+
default 320000000
90+
91+
config SOC_NRF54H20_GLOBAL_HSFLL_TIMEOUT_MS
92+
int "Global HSFLL clock frequency timeout in milliseconds"
93+
default 1000
94+
95+
endif # SOC_NRF54H20_RESTRICT_GLOBAL_HSFLL_FREQ

soc/nordic/nrf54h/global_hsfll.c

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
8+
#include <zephyr/kernel.h>
9+
#include <zephyr/logging/log.h>
10+
#include <nrfs_backend_ipc_service.h>
11+
12+
LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL);
13+
14+
#define GLOBAL_HSFLL_MIN_FREQ_HZ \
15+
CONFIG_SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_HZ
16+
17+
#define NRFS_BACKEND_TIMEOUT \
18+
K_MSEC(CONFIG_SOC_NRF54H20_GLOBAL_HSFLL_TIMEOUT_MS)
19+
20+
#define GLOBAL_HSFLL_REQUEST_TIMEOUT_MS \
21+
CONFIG_SOC_NRF54H20_GLOBAL_HSFLL_TIMEOUT_MS
22+
23+
static struct onoff_client cli;
24+
static const struct device *global_hsfll = DEVICE_DT_GET(DT_NODELABEL(hsfll120));
25+
static const struct nrf_clock_spec spec = {
26+
.frequency = GLOBAL_HSFLL_MIN_FREQ_HZ,
27+
};
28+
29+
static int nordicsemi_nrf54h_global_hsfll_init(void)
30+
{
31+
int ret;
32+
int res;
33+
bool completed;
34+
35+
nrfs_backend_wait_for_connection(NRFS_BACKEND_TIMEOUT);
36+
37+
sys_notify_init_spinwait(&cli.notify);
38+
39+
ret = nrf_clock_control_request(global_hsfll, &spec, &cli);
40+
if (ret) {
41+
return ret;
42+
}
43+
44+
res = -EIO;
45+
completed = WAIT_FOR(sys_notify_fetch_result(&cli.notify, &res) == 0,
46+
GLOBAL_HSFLL_REQUEST_TIMEOUT_MS,
47+
k_msleep(1));
48+
49+
if (!completed || res) {
50+
LOG_ERR("Failed to restrict global HSFLL frequency");
51+
return -EIO;
52+
}
53+
54+
return 0;
55+
}
56+
57+
SYS_INIT(nordicsemi_nrf54h_global_hsfll_init, POST_KERNEL, 99);

0 commit comments

Comments
 (0)