Skip to content

Commit

Permalink
dvfs_cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ppelikan-nordic committed Nov 8, 2024
1 parent 1e549f5 commit 40346b7
Showing 1 changed file with 5 additions and 123 deletions.
128 changes: 5 additions & 123 deletions modules/hal_nordic/nrfs/dvfs/ld_dvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,7 @@ void ld_dvfs_init(void)

const struct dvfs_oppoint_data *opp_data = get_dvfs_oppoint_data(DVFS_FREQ_HIGH);

#if defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
LOG_DBG("%s", __func__);
LOG_DBG("REGW: NRF_ABB->TRIM.RINGO[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.RINGO[CURR_TARG_ABB_SLOT],
opp_data->abb_ringo);
LOG_DBG("REGW: NRF_ABB->TRIM.LOCKRANGE[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.LOCKRANGE[CURR_TARG_ABB_SLOT],
opp_data->abb_lockrange);
LOG_DBG("REGW: NRF_ABB->TRIM.PVTMONCYCLES[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.PVTMONCYCLES[CURR_TARG_ABB_SLOT],
opp_data->abb_pvtmoncycles);

/*For app core.*/
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.RINGO[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.RINGO[CURR_TARG_ABB_SLOT],
opp_data->abb_ringo);
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.LOCKRANGE[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.LOCKRANGE[CURR_TARG_ABB_SLOT],
opp_data->abb_lockrange);
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.PVTMONCYCLES[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.PVTMONCYCLES[CURR_TARG_ABB_SLOT],
opp_data->abb_pvtmoncycles);
#else
#if !defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
/* TODO: Change to NRFX Hal function when available. */
NRF_ABB->TRIM.RINGO[CURR_TARG_ABB_SLOT] = opp_data->abb_ringo;
NRF_ABB->TRIM.LOCKRANGE[CURR_TARG_ABB_SLOT] = opp_data->abb_lockrange;
Expand All @@ -84,12 +56,7 @@ void ld_dvfs_init(void)
void ld_dvfs_clear_zbb(void)
{
#if defined(NRF_SECURE)
#if defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
LOG_DBG("%s", __func__);
LOG_DBG("REGW: NRF_ABB->CONFIG.CTRL1.MODE 0x%x, V: 0x%x",
(uint32_t)&NRF_ABB->CONFIG.CTRL1,
LD_ABB_CLR_ZBB);
#else
#if !defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
/* TODO: Change to NRFX Hal function when available. */
NRF_ABB->CONFIG.CTRL1 &= ~(ABB_CONFIG_CTRL1_MODE_Msk);
NRF_APPLICATION_ABB->CONFIG.CTRL1 &= ~(ABB_CONFIG_CTRL1_MODE_Msk);
Expand Down Expand Up @@ -161,34 +128,7 @@ void ld_dvfs_configure_abb_for_transition(enum dvfs_frequency_setting transient_
const struct dvfs_oppoint_data *opp_data = get_dvfs_oppoint_data(transient_opp);

#if defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
LOG_DBG("%s", __func__);
LOG_DBG("transient_opp: %d, curr_targ_opp: %d", transient_opp, curr_targ_opp);
LOG_DBG("REGW: NRF_ABB->TRIM.RINGO[%d] 0x%x, V: 0x%x",
TRANSIENT_ZBB_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.RINGO[TRANSIENT_ZBB_ABB_SLOT],
opp_data->abb_ringo);
LOG_DBG("REGW: NRF_ABB->TRIM.LOCKRANGE[%d] 0x%x, V: 0x%x",
TRANSIENT_ZBB_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.LOCKRANGE[TRANSIENT_ZBB_ABB_SLOT],
opp_data->abb_lockrange);
LOG_DBG("REGW: NRF_ABB->TRIM.PVTMONCYCLES[%d] 0x%x, V: 0x%x",
TRANSIENT_ZBB_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.PVTMONCYCLES[TRANSIENT_ZBB_ABB_SLOT],
opp_data->abb_pvtmoncycles);

/* For app core.*/
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.RINGO[%d] 0x%x, V: 0x%x",
TRANSIENT_ZBB_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.RINGO[TRANSIENT_ZBB_ABB_SLOT],
opp_data->abb_ringo);
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.LOCKRANGE[%d] 0x%x, V: 0x%x",
TRANSIENT_ZBB_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.LOCKRANGE[TRANSIENT_ZBB_ABB_SLOT],
opp_data->abb_lockrange);
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.PVTMONCYCLES[%d] 0x%x, V: 0x%x",
TRANSIENT_ZBB_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.PVTMONCYCLES[TRANSIENT_ZBB_ABB_SLOT],
opp_data->abb_pvtmoncycles);
#else

NRF_ABB->TRIM.RINGO[TRANSIENT_ZBB_ABB_SLOT] = opp_data->abb_ringo;
Expand All @@ -201,42 +141,8 @@ void ld_dvfs_configure_abb_for_transition(enum dvfs_frequency_setting transient_
#endif
opp_data = get_dvfs_oppoint_data(curr_targ_opp);

#if defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
LOG_DBG("REGW: NRF_ABB->TRIM.RINGO[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.RINGO[CURR_TARG_ABB_SLOT],
opp_data->abb_ringo);
LOG_DBG("REGW: NRF_ABB->TRIM.LOCKRANGE[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.LOCKRANGE[CURR_TARG_ABB_SLOT],
opp_data->abb_lockrange);
LOG_DBG("REGW: NRF_ABB->TRIM.PVTMONCYCLES[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_ABB->TRIM.PVTMONCYCLES[CURR_TARG_ABB_SLOT],
opp_data->abb_pvtmoncycles);

LOG_DBG("REGW: TODO: NRF_ABB->CONFIG.CTRL4 0x%x, V: 0x%lx",
(uint32_t)&NRF_ABB->CONFIG.CTRL4,
LD_ABB_CTRL4_TRANSITION_OPERATION);

/* For app core */
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.RINGO[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.RINGO[CURR_TARG_ABB_SLOT],
opp_data->abb_ringo);
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.LOCKRANGE[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.LOCKRANGE[CURR_TARG_ABB_SLOT],
opp_data->abb_lockrange);
LOG_DBG("REGW: NRF_APPLICATION_ABB->TRIM.PVTMONCYCLES[%d] 0x%x, V: 0x%x",
CURR_TARG_ABB_SLOT,
(uint32_t)&NRF_APPLICATION_ABB->TRIM.PVTMONCYCLES[CURR_TARG_ABB_SLOT],
opp_data->abb_pvtmoncycles);

LOG_DBG("REGW: TODO: NRF_APPLICATION_ABB->CONFIG.CTRL4 0x%x, V: 0x%lx",
(uint32_t)&NRF_APPLICATION_ABB->CONFIG.CTRL4,
LD_ABB_CTRL4_TRANSITION_OPERATION);
#else
#if !defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)

NRF_ABB->TRIM.RINGO[CURR_TARG_ABB_SLOT] = opp_data->abb_ringo;
NRF_ABB->TRIM.LOCKRANGE[CURR_TARG_ABB_SLOT] = opp_data->abb_lockrange;
NRF_ABB->TRIM.PVTMONCYCLES[CURR_TARG_ABB_SLOT] = opp_data->abb_pvtmoncycles;
Expand Down Expand Up @@ -281,22 +187,6 @@ int32_t ld_dvfs_configure_hsfll(enum dvfs_frequency_setting oppoint)

#if defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
LOG_DBG("%s oppoint: %d", __func__, oppoint);
LOG_DBG("REGW: NRF_HSFLL->MIRROR 0x%x, V: 0x%x", (uint32_t)&NRF_HSFLL->MIRROR, 1);
LOG_DBG("REGW: NRF_HSFLL->TRIM.COARSE 0x%x, V: 0x%x",
(uint32_t)&NRF_HSFLL->TRIM.COARSE,
hsfll_trim.coarse);
LOG_DBG("REGW: NRF_HSFLL->TRIM.FINE 0x%x, V: 0x%x",
(uint32_t)&NRF_HSFLL->TRIM.FINE,
hsfll_trim.fine);
LOG_DBG("REGW: NRF_HSFLL->MIRROR 0x%x, V: 0x%x", (uint32_t)&NRF_HSFLL->MIRROR, 0);

LOG_DBG("REGW: NRF_HSFLL->CLOCKCTRL.MULT 0x%x, V: 0x%x",
(uint32_t)&NRF_HSFLL->CLOCKCTRL.MULT,
get_dvfs_oppoint_data(oppoint)->new_f_mult);

LOG_DBG("REGW: NRF_HSFLL->NRF_HSFLL_TASK_FREQ_CHANGE 0x%x, V: 0x%x",
(uint32_t)NRF_HSFLL + NRF_HSFLL_TASK_FREQ_CHANGE,
0x1);
return 0;
#else

Expand Down Expand Up @@ -337,15 +227,7 @@ void ld_dvfs_scaling_background_process(bool downscaling)
void ld_dvfs_scaling_finish(bool downscaling)
{
#if defined(NRF_SECURE)
#if defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
LOG_DBG("%s", __func__);
LOG_DBG("REGW: NRF_ABB->CONFIG.CTRL4 0x%x, V: 0x%lx",
(uint32_t)&NRF_ABB->CONFIG.CTRL4,
LD_ABB_CTRL4_NORMAL_OPERATION);
LOG_DBG("REGW: NRF_APPLICATION_ABB->CONFIG.CTRL4 0x%x, V: 0x%lx",
(uint32_t)&NRF_APPLICATION_ABB->CONFIG.CTRL4,
LD_ABB_CTRL4_NORMAL_OPERATION);
#else
#if !defined(CONFIG_NRFS_LOCAL_DOMAIN_DVFS_TEST)
NRF_ABB->CONFIG.CTRL4 = LD_ABB_CTRL4_NORMAL_OPERATION;
NRF_APPLICATION_ABB->CONFIG.CTRL4 = LD_ABB_CTRL4_NORMAL_OPERATION;
#endif
Expand Down

0 comments on commit 40346b7

Please sign in to comment.