Skip to content

Commit bde2525

Browse files
bjarki-andreasencarlescufi
authored andcommitted
Revert "[nrf fromlist] soc: nordic: nrf54h: Move HSFLL trimming to clock_control driver"
This reverts commit ec07b19. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent f862808 commit bde2525

File tree

2 files changed

+47
-53
lines changed

2 files changed

+47
-53
lines changed

drivers/clock_control/clock_control_nrf2_hsfll.c

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ LOG_MODULE_DECLARE(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
1717
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
1818
"multiple instances not supported");
1919

20-
#include <hal/nrf_hsfll.h>
21-
2220
#ifdef CONFIG_NRFS_HAS_DVFS_SERVICE
2321
#include <ld_dvfs_handler.h>
2422

@@ -49,17 +47,7 @@ struct hsfll_dev_data {
4947
NRF2_STRUCT_CLOCK_CONFIG(hsfll, ARRAY_SIZE(clock_options)) clk_cfg;
5048
struct k_timer timer;
5149
};
52-
#endif /* CONFIG_NRFS_HAS_DVFS_SERVICE */
53-
54-
struct hsfll_dev_config {
55-
NRF_HSFLL_Type *hsfll;
56-
uint32_t trim_vsup;
57-
uint32_t trim_coarse;
58-
uint32_t trim_fine;
59-
uint8_t multiplier;
60-
};
6150

62-
#ifdef CONFIG_NRFS_HAS_DVFS_SERVICE
6351
static void freq_setting_applied_cb(enum dvfs_frequency_setting new_setting)
6452
{
6553
ARG_UNUSED(new_setting);
@@ -205,30 +193,6 @@ static int api_get_rate_hsfll(const struct device *dev,
205193

206194
static int hsfll_init(const struct device *dev)
207195
{
208-
const struct hsfll_dev_config *dev_config = dev->config;
209-
nrf_hsfll_trim_t trim = {
210-
.vsup = sys_read32(dev_config->trim_vsup),
211-
.coarse = sys_read32(dev_config->trim_coarse),
212-
.fine = sys_read32(dev_config->trim_fine),
213-
};
214-
215-
LOG_DBG("Trim: HSFLL VSUP: 0x%.8x", trim.vsup);
216-
LOG_DBG("Trim: HSFLL COARSE: 0x%.8x", trim.coarse);
217-
LOG_DBG("Trim: HSFLL FINE: 0x%.8x", trim.fine);
218-
219-
nrf_hsfll_clkctrl_mult_set(dev_config->hsfll, dev_config->multiplier);
220-
nrf_hsfll_trim_set(dev_config->hsfll, &trim);
221-
222-
nrf_hsfll_task_trigger(dev_config->hsfll, NRF_HSFLL_TASK_FREQ_CHANGE);
223-
/* HSFLL task frequency change needs to be triggered twice to take effect.
224-
* Refer to HMPAN-23.
225-
*/
226-
nrf_hsfll_task_trigger(dev_config->hsfll, NRF_HSFLL_TASK_FREQ_CHANGE);
227-
228-
LOG_DBG("NRF_HSFLL->TRIM.VSUP = %d", dev_config->hsfll->TRIM.VSUP);
229-
LOG_DBG("NRF_HSFLL->TRIM.COARSE = %d", dev_config->hsfll->TRIM.COARSE);
230-
LOG_DBG("NRF_HSFLL->TRIM.FINE = %d", dev_config->hsfll->TRIM.FINE);
231-
232196
#ifdef CONFIG_NRFS_HAS_DVFS_SERVICE
233197
struct hsfll_dev_data *dev_data = dev->data;
234198
int rc;
@@ -260,30 +224,14 @@ static struct nrf_clock_control_driver_api hsfll_drv_api = {
260224
.cancel_or_release = api_cancel_or_release_hsfll,
261225
};
262226

263-
#define HSFLL_MUTLIPLIER(n) \
264-
DT_PROP(DT_DRV_INST(n), clock_frequency) / \
265-
DT_PROP(DT_CLOCKS_CTLR(DT_DRV_INST(n)), clock_frequency)
266-
267-
#define FICR_ADDR_GET(n, name) \
268-
DT_REG_ADDR(DT_PHANDLE_BY_NAME(DT_DRV_INST(n), nordic_ficrs, name)) + \
269-
DT_PHA_BY_NAME(DT_DRV_INST(n), nordic_ficrs, name, offset)
270-
271227
#ifdef CONFIG_NRFS_HAS_DVFS_SERVICE
272228
static struct hsfll_dev_data hsfll_data;
273229
#endif
274230

275-
static const struct hsfll_dev_config hsfll_config = {
276-
.hsfll = (NRF_HSFLL_Type *)DT_INST_REG_ADDR(0),
277-
.multiplier = HSFLL_MUTLIPLIER(0),
278-
.trim_vsup = FICR_ADDR_GET(0, vsup),
279-
.trim_coarse = FICR_ADDR_GET(0, coarse),
280-
.trim_fine = FICR_ADDR_GET(0, fine),
281-
};
282-
283231
DEVICE_DT_INST_DEFINE(0, hsfll_init, NULL,
284232
COND_CODE_1(CONFIG_NRFS_HAS_DVFS_SERVICE,
285233
(&hsfll_data),
286234
(NULL)),
287-
&hsfll_config,
235+
NULL,
288236
PRE_KERNEL_1, CONFIG_CLOCK_CONTROL_INIT_PRIORITY,
289237
&hsfll_drv_api);

soc/nordic/nrf54h/soc.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,24 @@
1010
#include <zephyr/kernel.h>
1111
#include <zephyr/logging/log.h>
1212

13+
#include <hal/nrf_hsfll.h>
1314
#include <hal/nrf_lrcconf.h>
1415
#include <hal/nrf_spu.h>
1516
#include <hal/nrf_memconf.h>
1617
#include <soc/nrfx_coredep.h>
1718

1819
LOG_MODULE_REGISTER(soc, CONFIG_SOC_LOG_LEVEL);
1920

21+
#if defined(NRF_APPLICATION)
22+
#define HSFLL_NODE DT_NODELABEL(cpuapp_hsfll)
23+
#elif defined(NRF_RADIOCORE)
24+
#define HSFLL_NODE DT_NODELABEL(cpurad_hsfll)
25+
#endif
26+
27+
#define FICR_ADDR_GET(node_id, name) \
28+
DT_REG_ADDR(DT_PHANDLE_BY_NAME(node_id, nordic_ficrs, name)) + \
29+
DT_PHA_BY_NAME(node_id, nordic_ficrs, name, offset)
30+
2031
#define SPU_INSTANCE_GET(p_addr) \
2132
((NRF_SPU_Type *)((p_addr) & (ADDRESS_REGION_Msk | \
2233
ADDRESS_SECURITY_Msk | \
@@ -67,13 +78,48 @@ static void power_domain_init(void)
6778
#endif
6879
}
6980

81+
static int trim_hsfll(void)
82+
{
83+
#if defined(HSFLL_NODE)
84+
85+
NRF_HSFLL_Type *hsfll = (NRF_HSFLL_Type *)DT_REG_ADDR(HSFLL_NODE);
86+
nrf_hsfll_trim_t trim = {
87+
.vsup = sys_read32(FICR_ADDR_GET(HSFLL_NODE, vsup)),
88+
.coarse = sys_read32(FICR_ADDR_GET(HSFLL_NODE, coarse)),
89+
.fine = sys_read32(FICR_ADDR_GET(HSFLL_NODE, fine))
90+
};
91+
92+
LOG_DBG("Trim: HSFLL VSUP: 0x%.8x", trim.vsup);
93+
LOG_DBG("Trim: HSFLL COARSE: 0x%.8x", trim.coarse);
94+
LOG_DBG("Trim: HSFLL FINE: 0x%.8x", trim.fine);
95+
96+
nrf_hsfll_clkctrl_mult_set(hsfll,
97+
DT_PROP(HSFLL_NODE, clock_frequency) /
98+
DT_PROP(DT_CLOCKS_CTLR(HSFLL_NODE), clock_frequency));
99+
nrf_hsfll_trim_set(hsfll, &trim);
100+
101+
nrf_hsfll_task_trigger(hsfll, NRF_HSFLL_TASK_FREQ_CHANGE);
102+
/* HSFLL task frequency change needs to be triggered twice to take effect.*/
103+
nrf_hsfll_task_trigger(hsfll, NRF_HSFLL_TASK_FREQ_CHANGE);
104+
105+
LOG_DBG("NRF_HSFLL->TRIM.VSUP = %d", hsfll->TRIM.VSUP);
106+
LOG_DBG("NRF_HSFLL->TRIM.COARSE = %d", hsfll->TRIM.COARSE);
107+
LOG_DBG("NRF_HSFLL->TRIM.FINE = %d", hsfll->TRIM.FINE);
108+
109+
#endif /* defined(HSFLL_NODE) */
110+
111+
return 0;
112+
}
113+
70114
static int nordicsemi_nrf54h_init(void)
71115
{
72116
sys_cache_instr_enable();
73117
sys_cache_data_enable();
74118

75119
power_domain_init();
76120

121+
trim_hsfll();
122+
77123
#if DT_NODE_HAS_STATUS(DT_NODELABEL(ccm030), okay)
78124
/* DMASEC is set to non-secure by default, which prevents CCM from
79125
* accessing secure memory. Change DMASEC to secure.

0 commit comments

Comments
 (0)