Skip to content

Commit 50011dc

Browse files
committed
[nrf fromlist] hal_nordic: nrfs: dvfs: Update SystemCoreClock on frequency change
Update SystemCoreClock to match current core frequency. This MDK variable is used by nrfx_coredep_delay_us which performs busy waiting and is used by k_busy_wait. Upstream PR #: 82923 Signed-off-by: Krzysztof Chruściński <[email protected]>
1 parent 7733311 commit 50011dc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

modules/hal_nordic/nrfs/dvfs/ld_dvfs_handler.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,19 @@ static void dvfs_service_handler_scaling_background_job(enum dvfs_frequency_sett
139139
}
140140
}
141141

142+
/* Update MDK variable which is used by nrfx_coredep_delay_us (k_busy_wait). */
143+
static void dvfs_service_update_core_clock(enum dvfs_frequency_setting oppoint_freq)
144+
{
145+
extern uint32_t SystemCoreClock;
146+
147+
SystemCoreClock = oppoint_freq == DVFS_FREQ_HIGH ? 320000000 :
148+
oppoint_freq == DVFS_FREQ_MEDLOW ? 128000000 : 64000000;
149+
}
150+
142151
/* Perform scaling finnish procedure. */
143152
static void dvfs_service_handler_scaling_finish(enum dvfs_frequency_setting oppoint_freq)
144153
{
154+
145155
LOG_DBG("Scaling finnish oppoint freq %d", oppoint_freq);
146156
ld_dvfs_scaling_finish(dvfs_service_handler_is_downscaling(oppoint_freq));
147157
if (!dvfs_service_handler_is_downscaling(oppoint_freq)) {
@@ -153,6 +163,7 @@ static void dvfs_service_handler_scaling_finish(enum dvfs_frequency_setting oppo
153163
}
154164
dvfs_service_handler_clear_state_bit(DVFS_SERV_HDL_FREQ_CHANGE_REQ_PENDING_BIT_POS);
155165
current_freq_setting = oppoint_freq;
166+
dvfs_service_update_core_clock(oppoint_freq);
156167
LOG_DBG("Current LD freq setting: %d", current_freq_setting);
157168
if (dvfs_frequency_change_applied_clb) {
158169
dvfs_frequency_change_applied_clb(current_freq_setting);
@@ -216,6 +227,7 @@ static void nrfs_dvfs_evt_handler(nrfs_dvfs_evt_t const *p_evt, void *context)
216227
dvfs_service_handler_clear_state_bit(DVFS_SERV_HDL_FREQ_CHANGE_REQ_PENDING_BIT_POS);
217228
LOG_DBG("DVFS handler EVT_OPPOINT_REQ_CONFIRMED %d", (uint32_t)p_evt->freq);
218229
if (dvfs_service_handler_get_requested_oppoint() == p_evt->freq) {
230+
dvfs_service_update_core_clock(p_evt->freq);
219231
if (dvfs_frequency_change_applied_clb) {
220232
dvfs_frequency_change_applied_clb(p_evt->freq);
221233
}

0 commit comments

Comments
 (0)