diff --git a/arch/arm/src/s32k1xx/s32k1xx_clockconfig.c b/arch/arm/src/s32k1xx/s32k1xx_clockconfig.c index 4641adab3f9..5b3e5d4f2c7 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_clockconfig.c +++ b/arch/arm/src/s32k1xx/s32k1xx_clockconfig.c @@ -59,6 +59,7 @@ #include #include +#include #include #include @@ -75,6 +76,84 @@ * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: s32k1xx_scgconfig + * + * Description: + * Configure SCG clocking. + * + * Input Parameters: + * scgcfg - Describes the new SCG clock configuration + * + * Returned Value: + * Zero (OK) is returned a success; A negated errno value is returned on + * any failure. + * + *****************************************************************************/ + +static inline int s32k1xx_scgconfig(const struct scg_config_s *scgcfg) +{ +#warning Missing logic + return -ENOSYS; +} + +/**************************************************************************** + * Name: s32k1xx_pccconfig + * + * Description: + * Configure PCC clocking. + * + * Input Parameters: + * pcccfg - Describes the new PCC clock configuration + * + * Returned Value: + * None. + * + *****************************************************************************/ + +static inline void s32k1xx_pccconfig(const struct pcc_config_s *pcccfg) +{ +#warning Missing logic +} + +/**************************************************************************** + * Name: s32k1xx_simconfig + * + * Description: + * Configure PCC clocking. + * + * Input Parameters: + * simcfg - Describes the new SIM clock configuration + * + * Returned Value: + * None. + * + *****************************************************************************/ + +static inline void s32k1xx_simconfig(const struct sim_clock_config_s *simcfg) +{ +#warning Missing logic +} + +/**************************************************************************** + * Name: s32k1xx_pmcconfig + * + * Description: + * Configure PMC clocking. + * + * Input Parameters: + * pmccfg - Describes the new PMC clock configuration + * + * Returned Value: + * None. + * + *****************************************************************************/ + +static inline void s32k1xx_pmcconfig(const struct pmc_config_s *pmccfg) +{ +#warning Missing logic +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -88,11 +167,40 @@ * clocking using the settings in board.h. This function also performs * other low-level chip as necessary. * + * Input Parameters: + * clkcfg - Describes the new clock configuration + * + * Returned Value: + * Zero (OK) is returned a success; A negated errno value is returned on + * any failure. + * *****************************************************************************/ -void s32k1xx_clockconfig(FAR const struct clock_configuration_s *clkcfg) +int s32k1xx_clockconfig(const struct clock_configuration_s *clkcfg) { -#warning Missing logic + int ret; + + DEBUGASSERT(clkcfg != NULL); + + /* Set SCG configuration */ + + ret = s32k1xx_scgconfig(&clkcfg->scg); + if (ret >= 0) + { + /* Set PCC configuration */ + + s32k1xx_pccconfig(&clkcfg->pcc); + + /* Set SIM configuration */ + + s32k1xx_simconfig(&clkcfg->sim); + + /* Set PMC configuration */ + + s32k1xx_pmcconfig(&clkcfg->pmc); + } + + return ret; } /**************************************************************************** diff --git a/arch/arm/src/s32k1xx/s32k1xx_clockconfig.h b/arch/arm/src/s32k1xx/s32k1xx_clockconfig.h index 0e89b7ef4a2..085281bb85b 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_clockconfig.h +++ b/arch/arm/src/s32k1xx/s32k1xx_clockconfig.h @@ -537,9 +537,16 @@ extern "C" * clocking using the settings in board.h. This function also performs * other low-level chip as necessary. * + * Input Parameters: + * clkcfg - Describes the new clock configuration + * + * Returned Value: + * Zero (OK) is returned a success; A negated errno value is returned on + * any failure. + * *****************************************************************************/ -void s32k1xx_clockconfig(FAR const struct clock_configuration_s *clkcfg); +int s32k1xx_clockconfig(FAR const struct clock_configuration_s *clkcfg); /**************************************************************************** * Name: s32k1xx_get_coreclk @@ -547,6 +554,13 @@ void s32k1xx_clockconfig(FAR const struct clock_configuration_s *clkcfg); * Description: * Return the current value of the CORE clock frequency. * + * Input Parameters: + * None + * + * Returned Values: + * The current value of the CORE clock frequency. Zero is returned on any + * failure. + * *****************************************************************************/ uint32_t s32k1xx_get_coreclk(void); diff --git a/arch/arm/src/s32k1xx/s32k1xx_start.c b/arch/arm/src/s32k1xx/s32k1xx_start.c index f91d10d7b3f..751da4b417e 100644 --- a/arch/arm/src/s32k1xx/s32k1xx_start.c +++ b/arch/arm/src/s32k1xx/s32k1xx_start.c @@ -187,10 +187,10 @@ void __start(void) /* Configure the clocking and the console uart so that we can get debug * output as soon as possible. NOTE: That this logic must not assume that - * .bss or .data have beeninitialized. + * .bss or .data have been initialized. */ - s32k1xx_clockconfig(&g_initial_clkconfig); + DEBUG_VERIFY(s32k1xx_clockconfig(&g_initial_clkconfig)); s32k1xx_lowsetup(); showprogress('A');