Skip to content

Commit 83164e5

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 62256d1 commit 83164e5

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,36 @@ 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+
choice SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_CHOICE
87+
prompt "Minimum global HSFLL clock frequency in MHz"
88+
default SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_320_MHZ
89+
90+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_64_MHZ
91+
bool "Restrict minimum global HSFLL clock frequency to 64MHz"
92+
93+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_128_MHZ
94+
bool "Restrict minimum global HSFLL clock frequency to 128MHz"
95+
96+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_256_MHZ
97+
bool "Restrict minimum global HSFLL clock frequency to 256MHz"
98+
99+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_320_MHZ
100+
bool "Restrict minimum global HSFLL clock frequency to 320MHz"
101+
102+
endchoice
103+
104+
config SOC_NRF54H20_GLOBAL_HSFLL_TIMEOUT_MS
105+
int "Global HSFLL clock frequency timeout in milliseconds"
106+
default 10000
107+
108+
endif # SOC_NRF54H20_RESTRICT_GLOBAL_HSFLL_FREQ

soc/nordic/nrf54h/global_hsfll.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
11+
LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL);
12+
13+
#if CONFIG_SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_64_MHZ
14+
#define GLOBAL_HSFLL_MIN_FREQ_HZ 64000000
15+
#elif CONFIG_SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_128_MHZ
16+
#define GLOBAL_HSFLL_MIN_FREQ_HZ 128000000
17+
#elif CONFIG_SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_256_MHZ
18+
#define GLOBAL_HSFLL_MIN_FREQ_HZ 256000000
19+
#else
20+
#define GLOBAL_HSFLL_MIN_FREQ_HZ 320000000
21+
#endif
22+
23+
#define GLOBAL_HSFLL_REQUEST_TIMEOUT_US \
24+
(CONFIG_SOC_NRF54H20_GLOBAL_HSFLL_TIMEOUT_MS * USEC_PER_SEC)
25+
26+
static struct onoff_client cli;
27+
static const struct device *global_hsfll = DEVICE_DT_GET(DT_NODELABEL(hsfll120));
28+
static const struct nrf_clock_spec spec = {
29+
.frequency = GLOBAL_HSFLL_MIN_FREQ_HZ,
30+
};
31+
32+
static int nordicsemi_nrf54h_global_hsfll_init(void)
33+
{
34+
int ret;
35+
int res;
36+
bool completed;
37+
38+
sys_notify_init_spinwait(&cli.notify);
39+
40+
ret = nrf_clock_control_request(global_hsfll, &spec, &cli);
41+
if (ret) {
42+
return ret;
43+
}
44+
45+
res = -EIO;
46+
completed = WAIT_FOR(sys_notify_fetch_result(&cli.notify, &res) == 0,
47+
GLOBAL_HSFLL_REQUEST_TIMEOUT_US,
48+
k_msleep(1));
49+
50+
if (!completed) {
51+
LOG_ERR("%s request timed out", "Restrict global HSFLL");
52+
return -EIO;
53+
}
54+
55+
if (res) {
56+
LOG_ERR("%s request failed: (res=%i)", "Restrict global HSFLL", res);
57+
return res;
58+
}
59+
60+
return 0;
61+
}
62+
63+
SYS_INIT(nordicsemi_nrf54h_global_hsfll_init, POST_KERNEL, 99);

0 commit comments

Comments
 (0)