Skip to content

Commit

Permalink
SM-73: Implement PLL lock timeouts and PLL power up delays.
Browse files Browse the repository at this point in the history
Signed-off-by: Glen Wienecke <[email protected]>
  • Loading branch information
Glen Wienecke authored and cecannon7 committed Jan 24, 2024
1 parent f749b08 commit 50c9775
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
45 changes: 33 additions & 12 deletions devices/MIMX9/drivers/fsl_fract_pll.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,34 @@ bool FRACTPLL_SetEnable(uint32_t pllIdx, uint32_t enMask, bool enable)
{
uint32_t pllNum = pll->NUMERATOR.RW;
pll->NUMERATOR.RW = pllNum;

/* Wait before POWERUP */
SystemTimeDelay(ES_MAX_USEC_PLL_PREP);
}
#endif
pll->CTRL.SET = enMask;

/* If powering up, wait for lock */
if ((enMask & PLL_CTRL_POWERUP_MASK) != 0U)
{
while ((pll->PLL_STATUS & PLL_PLL_STATUS_PLL_LOCK_MASK) == 0U)
uint32_t pllLockUsec = 0U;
while (((pll->PLL_STATUS & PLL_PLL_STATUS_PLL_LOCK_MASK) == 0U) &&
(pllLockUsec < ES_MAX_USEC_PLL_LOCK))
{
; /* Intentional empty default */
SystemTimeDelay(1U);
pllLockUsec++;
}
}

/* If enabling PLL output, disable bypass */
if ((enMask & PLL_CTRL_CLKMUX_EN_MASK) != 0U)
if ((pll->PLL_STATUS & PLL_PLL_STATUS_PLL_LOCK_MASK) != 0U)
{
pll->CTRL.CLR = PLL_CTRL_CLKMUX_BYPASS_MASK;
/* If enabling PLL output, disable bypass */
if ((enMask & PLL_CTRL_CLKMUX_EN_MASK) != 0U)
{
pll->CTRL.CLR = PLL_CTRL_CLKMUX_BYPASS_MASK;
}

enableUpdate = true;
}
}
else
Expand All @@ -113,9 +124,10 @@ bool FRACTPLL_SetEnable(uint32_t pllIdx, uint32_t enMask, bool enable)
pll->CTRL.SET = PLL_CTRL_CLKMUX_BYPASS_MASK;
}
pll->CTRL.CLR = enMask;

enableUpdate = true;
}

enableUpdate = true;
}

return enableUpdate;
Expand Down Expand Up @@ -216,18 +228,27 @@ bool FRACTPLL_UpdateRate(uint32_t pllIdx, uint32_t mfi, uint32_t mfn,
pll->DENOMINATOR.RW = PLL_DENOMINATOR_MFD(CLOCK_PLL_MFD);
}

/* Wait before POWERUP */
SystemTimeDelay(ES_MAX_USEC_PLL_PREP);

/* Power up for locking */
pll->CTRL.SET = PLL_CTRL_POWERUP_MASK;
while ((pll->PLL_STATUS & PLL_PLL_STATUS_PLL_LOCK_MASK) == 0U)
uint32_t pllLockUsec = 0U;
while (((pll->PLL_STATUS & PLL_PLL_STATUS_PLL_LOCK_MASK) == 0U) &&
(pllLockUsec < ES_MAX_USEC_PLL_LOCK))
{
; /* Intentional empty default */
SystemTimeDelay(1U);
pllLockUsec++;
}

/* Enable PLL and clean bypass*/
pll->CTRL.SET = PLL_CTRL_CLKMUX_EN_MASK;
pll->CTRL.CLR = PLL_CTRL_CLKMUX_BYPASS_MASK;
if ((pll->PLL_STATUS & PLL_PLL_STATUS_PLL_LOCK_MASK) != 0U)
{
/* Enable PLL and clean bypass*/
pll->CTRL.SET = PLL_CTRL_CLKMUX_EN_MASK;
pll->CTRL.CLR = PLL_CTRL_CLKMUX_BYPASS_MASK;

updateRate = true;
updateRate = true;
}
}

return updateRate;
Expand Down
4 changes: 4 additions & 0 deletions devices/MIMX95/MIMX95_elec_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@
#define ES_NOM_KHZ_DISP ES_666667KHZ
#define ES_ODV_KHZ_DISP ES_800000KHZ

/* PLL time limits */
#define ES_MAX_USEC_PLL_LOCK 100U
#define ES_MAX_USEC_PLL_PREP 5U

/* PLL frequency limits */
#define ES_MIN_HZ_PLLVCO 2520000000ULL /* 2.5GHz rounded to 24M */
#define ES_MAX_HZ_PLLVCO 4992000000ULL /* 5.0GHz rounded to 24M */
Expand Down

0 comments on commit 50c9775

Please sign in to comment.