Skip to content

Commit 0554f47

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 d94b66e commit 0554f47

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-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
@@ -69,3 +69,36 @@ config SOC_NRF54H20_CPUFLPR
6969
depends on RISCV_CORE_NORDIC_VPR
7070

7171
rsource "gpd/Kconfig"
72+
73+
config SOC_NRF54H20_GLOBAL_HSFLL_RESTRICT_MIN_FREQ
74+
bool "Restrict minimum global HSFLL clock frequency"
75+
select NRFS
76+
select NRFS_GDFS_SERVICE_ENABLED
77+
select CLOCK_CONTROL
78+
default y if SOC_NRF54H20_CPUAPP
79+
80+
if SOC_NRF54H20_GLOBAL_HSFLL_RESTRICT_MIN_FREQ
81+
82+
choice SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_CHOICE
83+
prompt "Minimum global HSFLL clock frequency in MHz"
84+
default SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_320_MHZ
85+
86+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_64_MHZ
87+
bool "Restrict minimum global HSFLL clock frequency to 64MHz"
88+
89+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_128_MHZ
90+
bool "Restrict minimum global HSFLL clock frequency to 128MHz"
91+
92+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_256_MHZ
93+
bool "Restrict minimum global HSFLL clock frequency to 256MHz"
94+
95+
config SOC_NRF54H20_GLOBAL_HSFLL_MIN_FREQ_320_MHZ
96+
bool "Restrict minimum global HSFLL clock frequency to 320MHz"
97+
98+
endchoice
99+
100+
config SOC_NRF54H20_GLOBAL_HSFLL_TIMEOUT_MS
101+
int "Global HSFLL clock frequency timeout in milliseconds"
102+
default 10000
103+
104+
endif # SOC_NRF54H20_RESTRICT_GLOBAL_HSFLL_FREQ

soc/nordic/nrf54h/global_hsfll.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
LOG_INF("%s to %uHz", "Restrict global HSFLL", GLOBAL_HSFLL_MIN_FREQ_HZ);
61+
return 0;
62+
}
63+
64+
SYS_INIT(nordicsemi_nrf54h_global_hsfll_init, POST_KERNEL, 99);

0 commit comments

Comments
 (0)