Go to the documentation of this file.
10 #ifndef FSL_COMPONENT_ID
11 #define FSL_COMPONENT_ID "platform.drivers.clock"
21 #if (defined(__ICCARM__))
23 #if (__ARMVFP__ >= __ARMFPV5__) && \
30 #elif (defined(__GNUC__))
38 #elif defined(__CC_ARM) || defined(__ARMCC_VERSION)
40 #if defined __TARGET_FPU_FPV5_D16
161 assert(!bypassXtalOsc);
413 for (i = 0; i < 400000U; i++)
440 for (i = 0; i < 400000U; i++)
669 switch (
config->postDivider)
756 switch (
config->postDivider)
816 if (
config->enableClkOutput)
821 if (
config->enableClkOutput25M)
863 const uint32_t enetRefClkFreq[] = {
906 freq += (uint32_t)freqTmp;
921 freq = freq * divSelect + (uint32_t)freqTmp;
986 freq = freq * divSelect + (uint32_t)freqTmp;
1046 freq = enetRefClkFreq[divSelect];
1077 uint32_t pfdIndex = (uint32_t)pfd;
1082 << (8UL * pfdIndex)));
1115 uint32_t pfdIndex = (uint32_t)pfd;
1120 << (8UL * pfdIndex)));
#define CCM_ANALOG_PLL_SYS_DENOM_B(x)
#define CCM_ANALOG_PLL_USB2_DIV_SELECT(x)
volatile uint32_t g_xtalFreq
External XTAL (24M OSC/SYSOSC) clock frequency.
PLL configuration for AUDIO and VIDEO.
#define CCM_ANALOG_PLL_AUDIO_NUM_A(x)
#define CCM_ANALOG_PLL_VIDEO_POST_DIV_SELECT(x)
#define CCM_ANALOG_PLL_ENET_BYPASS_MASK
#define XTALOSC24M_LOWPWR_CTRL_SET_OSC_SEL_MASK
uint32_t CLOCK_GetAhbFreq(void)
Gets the AHB clock frequency.
enum _clock_pfd clock_pfd_t
PLL PFD name.
#define CCM_ANALOG_MISC0_OSC_XTALOK_EN_MASK
#define USBPHY_CTRL_ENAUTOCLR_CLKGATE_MASK
#define CCM_ANALOG_PFD_528_PFD3_FRAC_MASK
#define CCM_ANALOG_PLL_ARM_BYPASS_CLK_SRC(x)
#define CCM_ANALOG_PLL_SYS_NUM_A(x)
#define CCM_ANALOG_PLL_SYS_DIV_SELECT(x)
#define CCM_ANALOG_PFD_528_PFD0_FRAC(x)
#define CCM_ANALOG_PLL_ENET_LOCK_MASK
#define CCM_ANALOG_PLL_AUDIO_BYPASS_MASK
#define CCM_ANALOG_PLL_ARM_LOCK_MASK
static uint32_t CLOCK_GetPeriphClkFreq(void)
Get the periph clock frequency.
void CLOCK_DeinitAudioPll(void)
De-initialize the Audio PLL.
#define CCM_ANALOG_MISC0_XTAL_24M_PWD_MASK
#define CCM_ANALOG_PLL_VIDEO_BYPASS_CLK_SRC(x)
static uint32_t CLOCK_GetPllBypassRefClk(CCM_ANALOG_Type *base, clock_pll_t pll)
Get PLL bypass clock value, it is PLL reference clock actually. If CLOCK1_P,CLOCK1_N is choose as the...
enum _clock_osc clock_osc_t
OSC 24M sorce select.
#define CCM_CBCDR_AHB_PODF_SHIFT
void CLOCK_DisableUsbhs0PhyPllClock(void)
Disable USB HS PHY PLL clock.
#define CCM_ANALOG_PFD_480_PFD1_FRAC_SHIFT
#define CCM_ANALOG_PLL_ARM_BYPASS_MASK
void CLOCK_DeinitUsb1Pfd(clock_pfd_t pfd)
De-initialize the USB1 PLL PFD.
uint32_t CLOCK_GetPerClkFreq(void)
Gets the PER clock frequency.
static uint32_t CLOCK_GetRtcFreq(void)
Gets the RTC clock frequency.
#define CCM_ANALOG_PFD_528_PFD0_FRAC_SHIFT
#define CCM_CCGR6_CG0_MASK
#define CCM_ANALOG_PLL_AUDIO_DIV_SELECT_SHIFT
#define CCM_ANALOG_PFD_528_PFD1_FRAC_SHIFT
#define CCM_ANALOG_PLL_VIDEO_POWERDOWN_MASK
#define CCM_ANALOG_PLL_USB1_LOCK_MASK
#define CCM_CBCDR_PERIPH_CLK_SEL_MASK
#define CCM_ANALOG_PFD_480_PFD2_FRAC_MASK
#define CCM_ANALOG_MISC2_VIDEO_DIV_MASK
#define CCM_CBCMR_PRE_PERIPH_CLK_SEL_MASK
#define CCM_CSCMR1_PERCLK_PODF_MASK
uint32_t CLOCK_GetUsb1PfdFreq(clock_pfd_t pfd)
Get current USB1 PLL PFD output frequency.
#define CCM_CBCDR_SEMC_PODF_MASK
#define CCM_CBCDR_SEMC_CLK_SEL_MASK
#define CCM_CBCDR_PERIPH_CLK2_PODF_MASK
#define CCM_CBCDR_IPG_PODF_SHIFT
#define CCM_ANALOG_PLL_ARM_DIV_SELECT_MASK
bool CLOCK_EnableUsbhs1Clock(clock_usb_src_t src, uint32_t freq)
Enable USB HS clock.
void CLOCK_InitVideoPll(const clock_video_pll_config_t *config)
Initialize the video PLL.
#define CCM_ANALOG_MISC2_AUDIO_DIV_MSB_MASK
#define CCM_ANALOG_PFD_528_PFD3_FRAC_SHIFT
#define CCM_ANALOG_PLL_VIDEO_NUM_A(x)
#define USBPHY_CTRL_ENUTMILEVEL2_MASK
#define USBHS_USBCMD_RST_MASK
uint32_t CLOCK_GetPllFreq(clock_pll_t pll)
Get current PLL output frequency.
void CLOCK_InitUsb2Pll(const clock_usb_pll_config_t *config)
Initialize the USB2 PLL.
void CLOCK_DeinitSysPfd(clock_pfd_t pfd)
De-initialize the System PLL PFD.
#define CCM_ANALOG_PFD_480_PFD0_FRAC_SHIFT
#define PMU_REG_3P0_ENABLE_LINREG_MASK
#define CCM_ANALOG_PFD_480_PFD3_FRAC_SHIFT
#define CCM_CBCDR_IPG_PODF_MASK
void CLOCK_DeinitSysPll(void)
De-initialize the System PLL.
#define CCM_ANALOG_PLL_VIDEO_ENABLE_MASK
#define CCM_ANALOG_PLL_AUDIO_DENOM_B(x)
#define CCM_CBCMR_PERIPH_CLK2_SEL_MASK
enum _clock_usb_phy_src clock_usb_phy_src_t
Source of the USB HS PHY.
#define CCM_ANALOG_PLL_USB2_LOCK_MASK
#define CCM_ANALOG_PLL_AUDIO_BYPASS_CLK_SRC(x)
#define CCM_CSCMR1_PERCLK_CLK_SEL_MASK
#define CCM_ANALOG_PLL_ENET_POWERDOWN_MASK
#define CCM_ANALOG_PLL_AUDIO_DIV_SELECT(x)
void CLOCK_InitAudioPll(const clock_audio_pll_config_t *config)
Initializes the Audio PLL.
#define CCM_ANALOG_PLL_ARM_BYPASS_CLK_SRC_MASK
#define CCM_ANALOG_PFD_480_PFD0_CLKGATE_MASK
#define CCM_ANALOG_PLL_USB2_BYPASS_CLK_SRC(x)
#define CCM_ANALOG_PLL_AUDIO_POST_DIV_SELECT_MASK
void CLOCK_DisableUsbhs1PhyPllClock(void)
Disable USB HS PHY PLL clock.
#define XTALOSC24M_LOWPWR_CTRL_CLR_OSC_SEL_MASK
#define USBPHY_CTRL_ENAUTOCLR_PHY_PWD_MASK
void CLOCK_InitUsb1Pfd(clock_pfd_t pfd, uint8_t pfdFrac)
Initialize the USB1 PLL PFD.
#define PMU_REG_3P0_OUTPUT_TRG(x)
#define CCM_ANALOG_PLL_USB1_ENABLE_MASK
#define CCM_CBCDR_AHB_PODF_MASK
#define CCM_ANALOG_PLL_VIDEO_DIV_SELECT_SHIFT
#define CCM_ANALOG_PLL_AUDIO_POST_DIV_SELECT(x)
PLL configuration for ARM.
#define XTALOSC24M_LOWPWR_CTRL_RC_OSC_EN_MASK
void CLOCK_DeinitUsb2Pll(void)
Deinitialize the USB2 PLL.
#define CCM_ANALOG_PLL_ENET_DIV_SELECT_MASK
#define CCM_ANALOG_PLL_SYS_ENABLE_MASK
#define CCM_ANALOG_PLL_VIDEO_LOCK_MASK
#define CCM_ANALOG_PFD_528_PFD1_FRAC_MASK
#define CCM_ANALOG_PLL_USB2_DIV_SELECT_MASK
#define CCM_ANALOG_PLL_AUDIO_BYPASS_CLK_SRC_MASK
#define CCM_ANALOG_PLL_ENET_DIV_SELECT(x)
#define CCM_ANALOG_PLL_VIDEO_DIV_SELECT_MASK
#define CCM_CBCMR_PERIPH_CLK2_SEL(x)
#define CCM_CBCDR_SEMC_ALT_CLK_SEL_MASK
#define CCM_ANALOG_PLL_USB2_EN_USB_CLKS_MASK
#define CCM_ANALOG_PLL_ENET_BYPASS_CLK_SRC(x)
#define CCM_ANALOG_PLL_USB2_ENABLE_MASK
#define CCM_ANALOG_PFD_528_PFD0_CLKGATE_MASK
#define CCM_ANALOG_PLL_ARM_ENABLE_MASK
void CLOCK_DeinitArmPll(void)
De-initialize the ARM PLL.
#define CCM_ANALOG_PLL_USB1_DIV_SELECT_MASK
#define CCM_ANALOG_PLL_AUDIO_ENABLE_MASK
#define CCM_ANALOG_PLL_ARM_DIV_SELECT(x)
#define CCM_ANALOG_PLL_USB1_POWER_MASK
#define CCM_ANALOG_PLL_USB2_BYPASS_CLK_SRC_MASK
void CLOCK_InitSysPfd(clock_pfd_t pfd, uint8_t pfdFrac)
Initialize the System PLL PFD.
#define CCM_ANALOG_PLL_USB1_BYPASS_MASK
PLL configuration for AUDIO and VIDEO.
#define CCM_CBCMR_PRE_PERIPH_CLK_SEL(x)
#define CCM_ANALOG_PLL_SYS_BYPASS_CLK_SRC_MASK
void CLOCK_InitRcOsc24M(void)
Initialize the RC oscillator 24MHz clock.
#define CCM_ANALOG_PLL_VIDEO_BYPASS_MASK
bool CLOCK_EnableUsbhs0Clock(clock_usb_src_t src, uint32_t freq)
Enable USB HS clock.
void CLOCK_InitEnetPll(const clock_enet_pll_config_t *config)
Initialize the ENET PLL.
#define CCM_ANALOG_PFD_528_PFD2_FRAC_SHIFT
bool CLOCK_EnableUsbhs1PhyPllClock(clock_usb_phy_src_t src, uint32_t freq)
Enable USB HS PHY PLL clock.
#define CCM_CSCMR1_PERCLK_PODF_SHIFT
void CLOCK_DeinitRcOsc24M(void)
Power down the RCOSC 24M clock.
#define CCM_ANALOG_PLL_USB2_POWER_MASK
#define CCM_ANALOG_PLL_ENET_ENABLE_MASK
#define CCM_ANALOG_PLL_SYS_BYPASS_MASK
#define XTALOSC24M_LOWPWR_CTRL_XTALOSC_PWRUP_STAT_MASK
#define CCM_ANALOG_PLL_VIDEO_POST_DIV_SELECT_MASK
#define CCM_ANALOG_PLL_ARM_POWERDOWN_MASK
void CLOCK_DeinitVideoPll(void)
De-initialize the Video PLL.
PLL configuration for USB.
void CLOCK_InitUsb1Pll(const clock_usb_pll_config_t *config)
Initialize the USB1 PLL.
#define CCM_CACRR_ARM_PODF_SHIFT
#define CCM_ANALOG_PFD_480_PFD0_FRAC_MASK
enum _clock_usb_src clock_usb_src_t
USB clock source definition.
enum _clock_pll clock_pll_t
PLL name.
#define CCM_ANALOG_PLL_SYS_POWERDOWN_MASK
#define CCM_ANALOG_PLL_AUDIO_POWERDOWN_MASK
#define CCM_ANALOG_PFD_480_PFD3_FRAC_MASK
#define CCM_ANALOG_PLL_USB1_EN_USB_CLKS_MASK
#define CCM_ANALOG_PLL_AUDIO_DIV_SELECT_MASK
#define CCM_ANALOG_PLL_USB2_BYPASS_MASK
#define CCM_ANALOG_MISC2_AUDIO_DIV_LSB(x)
void CLOCK_SwitchOsc(clock_osc_t osc)
Switch the OSC.
#define CCM_ANALOG_MISC2_VIDEO_DIV(x)
void CLOCK_InitSysPll(const clock_sys_pll_config_t *config)
Initialize the System PLL.
#define CCM_ANALOG_MISC0_OSC_XTALOK_MASK
#define CCM_ANALOG_PLL_SYS_BYPASS_CLK_SRC(x)
void CLOCK_DeinitEnetPll(void)
Deinitialize the ENET PLL.
uint32_t CLOCK_GetSemcFreq(void)
Gets the SEMC clock frequency.
#define CCM_ANALOG_PLL_ENET_ENET_25M_REF_EN_MASK
void CLOCK_DeinitExternalClk(void)
Deinitialize the external 24MHz clock.
enum _clock_name clock_name_t
Clock name used to get clock frequency.
#define CCM_ANALOG_PLL_ENET_BYPASS_CLK_SRC_MASK
bool CLOCK_EnableUsbhs0PhyPllClock(clock_usb_phy_src_t src, uint32_t freq)
Enable USB HS PHY PLL clock.
#define CCM_ANALOG_PLL_SYS_LOCK_MASK
#define CCM_ANALOG_PFD_528_PFD0_FRAC_MASK
#define CCM_ANALOG_PLL_SYS_SS_STOP(x)
#define CCM_CACRR_ARM_PODF_MASK
#define CCM_ANALOG_PLL_SYS_DIV_SELECT_MASK
#define CCM_ANALOG_PLL_VIDEO_DENOM_B(x)
#define CCM_ANALOG_PLL_ARM_DIV_SELECT_SHIFT
#define CCM_ANALOG_PFD_480_PFD0_FRAC(x)
static uint32_t CLOCK_GetOscFreq(void)
Gets the OSC clock frequency.
void CLOCK_InitExternalClk(bool bypassXtalOsc)
Initialize the external 24MHz clock.
#define CCM_ANALOG_PLL_AUDIO_LOCK_MASK
#define CCM_ANALOG_MISC2_AUDIO_DIV_LSB_MASK
#define CCM_ANALOG_PFD_480_PFD2_FRAC_SHIFT
#define CCM_ANALOG_PFD_528_PFD2_FRAC_MASK
void CLOCK_DeinitUsb1Pll(void)
Deinitialize the USB1 PLL.
#define USBPHY_CTRL_ENUTMILEVEL3_MASK
#define CCM_ANALOG_PLL_USB1_DIV_SELECT(x)
#define CCM_ANALOG_PLL_SYS_SS_ENABLE(x)
#define CCM_ANALOG_PLL_VIDEO_BYPASS_CLK_SRC_MASK
static bool CLOCK_IsPllEnabled(CCM_ANALOG_Type *base, clock_pll_t pll)
Check if PLL is enabled.
static sai_transceiver_t config
#define CCM_ANALOG_PLL_USB1_BYPASS_CLK_SRC(x)
uint32_t CLOCK_GetSysPfdFreq(clock_pfd_t pfd)
Get current System PLL PFD output frequency.
void CLOCK_InitArmPll(const clock_arm_pll_config_t *config)
Initialize the ARM PLL.
#define CCM_ANALOG_PLL_SYS_SS_STEP(x)
#define CCM_ANALOG_PLL_USB1_BYPASS_CLK_SRC_MASK
#define CCM_CBCDR_PERIPH_CLK2_PODF_SHIFT
#define USBPHY_CTRL_CLKGATE_MASK
#define USBPHY_CTRL_SFTRST_MASK
#define CCM_ANALOG_MISC2_AUDIO_DIV_MSB(x)
PLL configuration for ENET.
#define CCM_ANALOG_PFD_480_PFD1_FRAC_MASK
#define CCM_CBCDR_SEMC_PODF_SHIFT
volatile uint32_t g_rtcXtalFreq
External RTC XTAL (32K OSC) clock frequency.
PLL configuration for System.
static bool CLOCK_IsPllBypassed(CCM_ANALOG_Type *base, clock_pll_t pll)
Check if PLL is bypassed.
#define PMU_REG_3P0_OUTPUT_TRG_MASK
#define CCM_ANALOG_PLL_ENET_DIV_SELECT_SHIFT
uint32_t CLOCK_GetFreq(clock_name_t name)
Gets the clock frequency for a specific clock name.
#define CCM_ANALOG_PLL_VIDEO_DIV_SELECT(x)
uint32_t CLOCK_GetIpgFreq(void)
Gets the IPG clock frequency.